Selaa lähdekoodia

CanvasRenderer now (properly) handles textured triangles with determinant to 0
Proper IcosahedronGeometry next...

Mr.doob 13 vuotta sitten
vanhempi
commit
036caa64ee
4 muutettua tiedostoa jossa 397 lisäystä ja 373 poistoa
  1. 301 300
      build/Three.js
  2. 62 61
      build/custom/ThreeCanvas.js
  3. 3 1
      examples/canvas_sandbox.html
  4. 31 11
      src/renderers/CanvasRenderer.js

+ 301 - 300
build/Three.js

@@ -15,31 +15,31 @@ this.y=Math.asin(a.n13);Math.abs(c)>1.0E-5?(this.x=Math.atan2(-a.n23/c,a.n33/c),
 THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-
 c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c;return this}};
-THREE.Ray=function(a,c){function b(a,b,c){o.sub(c,a);r=o.dot(b);if(r<=0)return null;m=p.add(a,n.copy(b).multiplyScalar(r));return s=c.distanceTo(m)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);n.sub(a,b);t=o.dot(o);v=o.dot(p);q=o.dot(n);A=p.dot(p);w=p.dot(n);D=1/(t*A-v*v);x=(A*q-v*w)*D;J=(t*w-v*q)*D;return x>=0&&J>=0&&x+J<1}this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,
-c,d=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var g=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Vector3,h=new THREE.Vector3,a=new THREE.Vector3,c=new THREE.Vector3,i=new THREE.Vector3,l=new THREE.Vector3,k=new THREE.Vector3;this.intersectObject=function(n){for(var m,o=[],p=0,r=n.children.length;p<r;p++)Array.prototype.push.apply(o,this.intersectObject(n.children[p]));if(n instanceof THREE.Particle){p=
-b(this.origin,this.direction,n.matrixWorld.getPosition());if(p===null||p>n.scale.x)return[];m={distance:p,point:n.position,face:null,object:n};o.push(m)}else if(n instanceof THREE.Mesh){p=b(this.origin,this.direction,n.matrixWorld.getPosition());if(p===null||p>n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)))return o;var s,q=n.geometry,t=q.vertices,v;n.matrixRotationWorld.extractRotation(n.matrixWorld);p=0;for(r=q.faces.length;p<r;p++)if(m=q.faces[p],a.copy(this.origin),
-c.copy(this.direction),v=n.matrixWorld,i=v.multiplyVector3(i.copy(m.centroid)).subSelf(a),s=i.dot(c),!(s<=0)&&(g=v.multiplyVector3(g.copy(t[m.a].position)),e=v.multiplyVector3(e.copy(t[m.b].position)),f=v.multiplyVector3(f.copy(t[m.c].position)),h=m instanceof THREE.Face4?v.multiplyVector3(h.copy(t[m.d].position)):null,l=n.matrixRotationWorld.multiplyVector3(l.copy(m.normal)),s=c.dot(l),n.doubleSided||(n.flipSided?s>0:s<0)))if(s=l.dot(i.sub(g,a))/s,k.add(a,c.multiplyScalar(s)),m instanceof THREE.Face3)d(k,
-g,e,f)&&(m={distance:a.distanceTo(k),point:k.clone(),face:m,object:n},o.push(m));else if(m instanceof THREE.Face4&&(d(k,g,e,h)||d(k,e,f,h)))m={distance:a.distanceTo(k),point:k.clone(),face:m,object:n},o.push(m)}return o};var o=new THREE.Vector3,p=new THREE.Vector3,n=new THREE.Vector3,r,m,s,t,v,q,A,w,D,x,J};
+THREE.Ray=function(a,c){function b(a,b,c){o.sub(c,a);s=o.dot(b);if(s<=0)return null;m=p.add(a,n.copy(b).multiplyScalar(s));return q=c.distanceTo(m)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);n.sub(a,b);t=o.dot(o);u=o.dot(p);r=o.dot(n);z=p.dot(p);w=p.dot(n);C=1/(t*z-u*u);x=(z*r-u*w)*C;O=(t*w-u*r)*C;return x>=0&&O>=0&&x+O<1}this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,
+c,d=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var g=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Vector3,h=new THREE.Vector3,a=new THREE.Vector3,c=new THREE.Vector3,i=new THREE.Vector3,l=new THREE.Vector3,k=new THREE.Vector3;this.intersectObject=function(n){for(var m,o=[],p=0,s=n.children.length;p<s;p++)Array.prototype.push.apply(o,this.intersectObject(n.children[p]));if(n instanceof THREE.Particle){p=
+b(this.origin,this.direction,n.matrixWorld.getPosition());if(p===null||p>n.scale.x)return[];m={distance:p,point:n.position,face:null,object:n};o.push(m)}else if(n instanceof THREE.Mesh){p=b(this.origin,this.direction,n.matrixWorld.getPosition());if(p===null||p>n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)))return o;var q,r=n.geometry,t=r.vertices,u;n.matrixRotationWorld.extractRotation(n.matrixWorld);p=0;for(s=r.faces.length;p<s;p++)if(m=r.faces[p],a.copy(this.origin),
+c.copy(this.direction),u=n.matrixWorld,i=u.multiplyVector3(i.copy(m.centroid)).subSelf(a),q=i.dot(c),!(q<=0)&&(g=u.multiplyVector3(g.copy(t[m.a].position)),e=u.multiplyVector3(e.copy(t[m.b].position)),f=u.multiplyVector3(f.copy(t[m.c].position)),h=m instanceof THREE.Face4?u.multiplyVector3(h.copy(t[m.d].position)):null,l=n.matrixRotationWorld.multiplyVector3(l.copy(m.normal)),q=c.dot(l),n.doubleSided||(n.flipSided?q>0:q<0)))if(q=l.dot(i.sub(g,a))/q,k.add(a,c.multiplyScalar(q)),m instanceof THREE.Face3)d(k,
+g,e,f)&&(m={distance:a.distanceTo(k),point:k.clone(),face:m,object:n},o.push(m));else if(m instanceof THREE.Face4&&(d(k,g,e,h)||d(k,e,f,h)))m={distance:a.distanceTo(k),point:k.clone(),face:m,object:n},o.push(m)}return o};var o=new THREE.Vector3,p=new THREE.Vector3,n=new THREE.Vector3,s,m,q,t,u,r,z,w,C,x,O};
 THREE.Rectangle=function(){function a(){e=d-c;f=g-b}var c,b,d,g,e,f,h=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return e};this.getHeight=function(){return f};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(e,f,k,o){h=!1;c=e;b=f;d=k;g=o;a()};this.addPoint=function(e,f){h?(h=!1,c=e,b=f,d=e,g=f):(c=c<e?c:e,b=b<f?b:f,d=d>e?d:e,g=g>f?g:f);a()};this.add3Points=
 function(e,f,k,o,p,n){h?(h=!1,c=e<k?e<p?e:p:k<p?k:p,b=f<o?f<n?f:n:o<n?o:n,d=e>k?e>p?e:p:k>p?k:p,g=f>o?f>n?f:n:o>n?o:n):(c=e<k?e<p?e<c?e:c:p<c?p:c:k<p?k<c?k:c:p<c?p:c,b=f<o?f<n?f<b?f:b:n<b?n:b:o<n?o<b?o:b:n<b?n:b,d=e>k?e>p?e>d?e:d:p>d?p:d:k>p?k>d?k:d:p>d?p:d,g=f>o?f>n?f>g?f:g:n>g?n:g:o>n?o>g?o:g:n>g?n:g);a()};this.addRectangle=function(e){h?(h=!1,c=e.getLeft(),b=e.getTop(),d=e.getRight(),g=e.getBottom()):(c=c<e.getLeft()?c:e.getLeft(),b=b<e.getTop()?b:e.getTop(),d=d>e.getRight()?d:e.getRight(),g=g>
 e.getBottom()?g:e.getBottom());a()};this.inflate=function(e){c-=e;b-=e;d+=e;g+=e;a()};this.minSelf=function(e){c=c>e.getLeft()?c:e.getLeft();b=b>e.getTop()?b:e.getTop();d=d<e.getRight()?d:e.getRight();g=g<e.getBottom()?g:e.getBottom();a()};this.intersects=function(a){return Math.min(d,a.getRight())-Math.max(c,a.getLeft())>=0&&Math.min(g,a.getBottom())-Math.max(b,a.getTop())>=0};this.empty=function(){h=!0;g=d=b=c=0;a()};this.isEmpty=function(){return h}};
 THREE.Math={clamp:function(a,c,b){return a<c?c:a>b?b:a},clampBottom:function(a,c){return a<c?c:a},mapLinear:function(a,c,b,d,g){return d+(a-c)*(g-d)/(b-c)},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.Matrix3=function(){this.m=[]};
 THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
-THREE.Matrix4=function(a,c,b,d,g,e,f,h,i,l,k,o,p,n,r,m){this.set(a!==void 0?a:1,c||0,b||0,d||0,g||0,e!==void 0?e:1,f||0,h||0,i||0,l||0,k!==void 0?k:1,o||0,p||0,n||0,r||0,m!==void 0?m:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,c,b,d,g,e,f,h,i,l,k,o,p,n,r,m){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=g;this.n22=e;this.n23=f;this.n24=h;this.n31=i;this.n32=l;this.n33=k;this.n34=o;this.n41=p;this.n42=n;this.n43=r;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,
-c,b){var d=THREE.Matrix4.__v1,g=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;e.sub(a,c).normalize();if(e.length()===0)e.z=1;d.cross(b,e).normalize();d.length()===0&&(e.x+=1.0E-4,d.cross(b,e).normalize());g.cross(e,d).normalize();this.n11=d.x;this.n12=g.x;this.n13=e.x;this.n21=d.y;this.n22=g.y;this.n23=e.y;this.n31=d.z;this.n32=g.z;this.n33=e.z;return this},multiply:function(a,c){var b=a.n11,d=a.n12,g=a.n13,e=a.n14,f=a.n21,h=a.n22,i=a.n23,l=a.n24,k=a.n31,o=a.n32,p=a.n33,n=a.n34,r=a.n41,m=a.n42,s=a.n43,
-t=a.n44,v=c.n11,q=c.n12,A=c.n13,w=c.n14,D=c.n21,x=c.n22,J=c.n23,M=c.n24,K=c.n31,E=c.n32,P=c.n33,I=c.n34,V=c.n41,Z=c.n42,R=c.n43,W=c.n44;this.n11=b*v+d*D+g*K+e*V;this.n12=b*q+d*x+g*E+e*Z;this.n13=b*A+d*J+g*P+e*R;this.n14=b*w+d*M+g*I+e*W;this.n21=f*v+h*D+i*K+l*V;this.n22=f*q+h*x+i*E+l*Z;this.n23=f*A+h*J+i*P+l*R;this.n24=f*w+h*M+i*I+l*W;this.n31=k*v+o*D+p*K+n*V;this.n32=k*q+o*x+p*E+n*Z;this.n33=k*A+o*J+p*P+n*R;this.n34=k*w+o*M+p*I+n*W;this.n41=r*v+m*D+s*K+t*V;this.n42=r*q+m*x+s*E+t*Z;this.n43=r*A+m*
-J+s*P+t*R;this.n44=r*w+m*M+s*I+t*W;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
+THREE.Matrix4=function(a,c,b,d,g,e,f,h,i,l,k,o,p,n,s,m){this.set(a!==void 0?a:1,c||0,b||0,d||0,g||0,e!==void 0?e:1,f||0,h||0,i||0,l||0,k!==void 0?k:1,o||0,p||0,n||0,s||0,m!==void 0?m:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,c,b,d,g,e,f,h,i,l,k,o,p,n,s,m){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=g;this.n22=e;this.n23=f;this.n24=h;this.n31=i;this.n32=l;this.n33=k;this.n34=o;this.n41=p;this.n42=n;this.n43=s;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,
+c,b){var d=THREE.Matrix4.__v1,g=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;e.sub(a,c).normalize();if(e.length()===0)e.z=1;d.cross(b,e).normalize();d.length()===0&&(e.x+=1.0E-4,d.cross(b,e).normalize());g.cross(e,d).normalize();this.n11=d.x;this.n12=g.x;this.n13=e.x;this.n21=d.y;this.n22=g.y;this.n23=e.y;this.n31=d.z;this.n32=g.z;this.n33=e.z;return this},multiply:function(a,c){var b=a.n11,d=a.n12,g=a.n13,e=a.n14,f=a.n21,h=a.n22,i=a.n23,l=a.n24,k=a.n31,o=a.n32,p=a.n33,n=a.n34,s=a.n41,m=a.n42,q=a.n43,
+t=a.n44,u=c.n11,r=c.n12,z=c.n13,w=c.n14,C=c.n21,x=c.n22,O=c.n23,G=c.n24,K=c.n31,D=c.n32,P=c.n33,I=c.n34,W=c.n41,Z=c.n42,R=c.n43,S=c.n44;this.n11=b*u+d*C+g*K+e*W;this.n12=b*r+d*x+g*D+e*Z;this.n13=b*z+d*O+g*P+e*R;this.n14=b*w+d*G+g*I+e*S;this.n21=f*u+h*C+i*K+l*W;this.n22=f*r+h*x+i*D+l*Z;this.n23=f*z+h*O+i*P+l*R;this.n24=f*w+h*G+i*I+l*S;this.n31=k*u+o*C+p*K+n*W;this.n32=k*r+o*x+p*D+n*Z;this.n33=k*z+o*O+p*P+n*R;this.n34=k*w+o*G+p*I+n*S;this.n41=s*u+m*C+q*K+t*W;this.n42=s*r+m*x+q*D+t*Z;this.n43=s*z+m*
+O+q*P+t*R;this.n44=s*w+m*G+q*I+t*S;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return 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 c=a.x,b=a.y,d=a.z,g=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*g;a.y=(this.n21*c+this.n22*b+this.n23*d+this.n24)*g;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,g=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*g;a.y=this.n21*c+this.n22*
 b+this.n23*d+this.n24*g;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*g;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*g;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*
-a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,g=this.n21,e=this.n22,f=this.n23,h=this.n24,i=this.n31,l=this.n32,k=this.n33,o=this.n34,p=this.n41,n=this.n42,r=this.n43,m=this.n44;return d*f*l*p-b*h*l*p-d*e*k*p+c*h*k*p+b*e*o*p-c*f*o*p-d*f*i*n+b*h*i*n+d*g*k*n-a*h*k*n-b*g*o*n+a*f*o*n+d*e*i*r-c*h*i*r-d*g*l*r+a*h*l*r+c*g*o*r-a*e*o*r-b*e*i*m+c*f*i*m+b*g*l*m-a*f*l*m-c*g*k*m+a*e*k*m},transpose:function(){var a;
+a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,g=this.n21,e=this.n22,f=this.n23,h=this.n24,i=this.n31,l=this.n32,k=this.n33,o=this.n34,p=this.n41,n=this.n42,s=this.n43,m=this.n44;return d*f*l*p-b*h*l*p-d*e*k*p+c*h*k*p+b*e*o*p-c*f*o*p-d*f*i*n+b*h*i*n+d*g*k*n-a*h*k*n-b*g*o*n+a*f*o*n+d*e*i*s-c*h*i*s-d*g*l*s+a*h*l*s+c*g*o*s-a*e*o*s-b*e*i*m+c*f*i*m+b*g*l*m-a*f*l*m-c*g*k*m+a*e*k*m},transpose:function(){var a;
 a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;
 a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;
 a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},
 setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},
 setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),g=1-b,e=a.x,f=a.y,h=a.z,i=g*e,l=g*f;this.set(i*e+b,i*f-d*h,i*h+d*f,0,i*f+d*h,l*f+b,l*h-d*e,0,i*h-d*f,l*h+d*e,g*h*h+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,
-this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var c=a.n11,b=a.n12,d=a.n13,g=a.n14,e=a.n21,f=a.n22,h=a.n23,i=a.n24,l=a.n31,k=a.n32,o=a.n33,p=a.n34,n=a.n41,r=a.n42,m=a.n43,s=a.n44;this.n11=h*p*r-i*o*r+i*k*m-f*p*m-h*k*s+f*o*s;this.n12=g*o*r-d*p*r-g*k*m+b*p*m+d*k*s-b*o*s;this.n13=d*i*r-g*h*r+g*f*m-b*i*m-d*f*s+b*h*s;this.n14=g*h*k-d*i*k-g*f*o+b*i*o+d*f*p-b*h*p;this.n21=i*o*n-h*p*n-i*l*m+e*p*m+h*l*s-e*o*s;this.n22=d*p*n-g*o*n+
-g*l*m-c*p*m-d*l*s+c*o*s;this.n23=g*h*n-d*i*n-g*e*m+c*i*m+d*e*s-c*h*s;this.n24=d*i*l-g*h*l+g*e*o-c*i*o-d*e*p+c*h*p;this.n31=f*p*n-i*k*n+i*l*r-e*p*r-f*l*s+e*k*s;this.n32=g*k*n-b*p*n-g*l*r+c*p*r+b*l*s-c*k*s;this.n33=d*i*n-g*f*n+g*e*r-c*i*r-b*e*s+c*f*s;this.n34=g*f*l-b*i*l-g*e*k+c*i*k+b*e*p-c*f*p;this.n41=h*k*n-f*o*n-h*l*r+e*o*r+f*l*m-e*k*m;this.n42=b*o*n-d*k*n+d*l*r-c*o*r-b*l*m+c*k*m;this.n43=d*f*n-b*h*n-d*e*r+c*h*r+b*e*m-c*f*m;this.n44=b*h*l-d*f*l+d*e*k-c*h*k-b*e*o+c*f*o;this.multiplyScalar(1/a.determinant());
+this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var c=a.n11,b=a.n12,d=a.n13,g=a.n14,e=a.n21,f=a.n22,h=a.n23,i=a.n24,l=a.n31,k=a.n32,o=a.n33,p=a.n34,n=a.n41,s=a.n42,m=a.n43,q=a.n44;this.n11=h*p*s-i*o*s+i*k*m-f*p*m-h*k*q+f*o*q;this.n12=g*o*s-d*p*s-g*k*m+b*p*m+d*k*q-b*o*q;this.n13=d*i*s-g*h*s+g*f*m-b*i*m-d*f*q+b*h*q;this.n14=g*h*k-d*i*k-g*f*o+b*i*o+d*f*p-b*h*p;this.n21=i*o*n-h*p*n-i*l*m+e*p*m+h*l*q-e*o*q;this.n22=d*p*n-g*o*n+
+g*l*m-c*p*m-d*l*q+c*o*q;this.n23=g*h*n-d*i*n-g*e*m+c*i*m+d*e*q-c*h*q;this.n24=d*i*l-g*h*l+g*e*o-c*i*o-d*e*p+c*h*p;this.n31=f*p*n-i*k*n+i*l*s-e*p*s-f*l*q+e*k*q;this.n32=g*k*n-b*p*n-g*l*s+c*p*s+b*l*q-c*k*q;this.n33=d*i*n-g*f*n+g*e*s-c*i*s-b*e*q+c*f*q;this.n34=g*f*l-b*i*l-g*e*k+c*i*k+b*e*p-c*f*p;this.n41=h*k*n-f*o*n-h*l*s+e*o*s+f*l*m-e*k*m;this.n42=b*o*n-d*k*n+d*l*s-c*o*s-b*l*m+c*k*m;this.n43=d*f*n-b*h*n-d*e*s+c*h*s+b*e*m-c*f*m;this.n44=b*h*l-d*f*l+d*e*k-c*h*k-b*e*o+c*f*o;this.multiplyScalar(1/a.determinant());
 return this},setRotationFromEuler:function(a,c){var b=a.x,d=a.y,g=a.z,e=Math.cos(b),b=Math.sin(b),f=Math.cos(d),d=Math.sin(d),h=Math.cos(g),g=Math.sin(g);switch(c){case "YXZ":var i=f*h,l=f*g,k=d*h,o=d*g;this.n11=i+o*b;this.n12=k*b-l;this.n13=e*d;this.n21=e*g;this.n22=e*h;this.n23=-b;this.n31=l*b-k;this.n32=o+i*b;this.n33=e*f;break;case "ZXY":i=f*h;l=f*g;k=d*h;o=d*g;this.n11=i-o*b;this.n12=-e*g;this.n13=k+l*b;this.n21=l+k*b;this.n22=e*h;this.n23=o-i*b;this.n31=-e*d;this.n32=b;this.n33=e*f;break;case "ZYX":i=
 e*h;l=e*g;k=b*h;o=b*g;this.n11=f*h;this.n12=k*d-l;this.n13=i*d+o;this.n21=f*g;this.n22=o*d+i;this.n23=l*d-k;this.n31=-d;this.n32=b*f;this.n33=e*f;break;case "YZX":i=e*f;l=e*d;k=b*f;o=b*d;this.n11=f*h;this.n12=o-i*g;this.n13=k*g+l;this.n21=g;this.n22=e*h;this.n23=-b*h;this.n31=-d*h;this.n32=l*g+k;this.n33=i-o*g;break;case "XZY":i=e*f;l=e*d;k=b*f;o=b*d;this.n11=f*h;this.n12=-g;this.n13=d*h;this.n21=i*g+o;this.n22=e*h;this.n23=l*g-k;this.n31=k*g-l;this.n32=b*h;this.n33=o*g+i;break;default:i=e*h,l=e*
 g,k=b*h,o=b*g,this.n11=f*h,this.n12=-f*g,this.n13=d,this.n21=l+k*d,this.n22=i-o*d,this.n23=-b*f,this.n31=o-i*d,this.n32=k+l*d,this.n33=e*f}return this},setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,g=a.w,e=c+c,f=b+b,h=d+d,a=c*e,i=c*f;c*=h;var l=b*f;b*=h;d*=h;e*=g;f*=g;g*=h;this.n11=1-(l+d);this.n12=i-g;this.n13=c+f;this.n21=i+g;this.n22=1-(a+d);this.n23=b-e;this.n31=c-f;this.n32=b+e;this.n33=1-(a+l);return this},scale:function(a){var c=a.x,b=a.y,a=a.z;this.n11*=c;this.n12*=b;this.n13*=
@@ -56,17 +56,17 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,c){thi
 if(c&&(g=g.getChildByName(a,c),g!==void 0))return g}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},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 c=0,b=this.children.length;c<b;c++)this.children[c].updateMatrixWorld(a)}};THREE.Object3DCount=0;
 THREE.Projector=function(){function a(){var a=f[e]=f[e]||new THREE.RenderableObject;e++;return a}function c(){var a=l[i]=l[i]||new THREE.RenderableVertex;i++;return a}function b(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;return e>=0&&g>=0&&f>=0&&h>=0?!0:e<0&&g<0||f<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-g)):g<0&&(d=Math.min(d,e/(e-g))),f<0?c=Math.max(c,f/(f-h)):h<0&&(d=Math.min(d,f/(f-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var g,e,f=[],h,i,l=[],
-k,o,p=[],n,r=[],m,s,t=[],v,q,A=[],w={objects:[],sprites:[],lights:[],elements:[]},D=new THREE.Vector3,x=new THREE.Vector4,J=new THREE.Matrix4,M=new THREE.Matrix4,K=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],E=new THREE.Vector4,P=new THREE.Vector4;this.computeFrustum=function(a){K[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);K[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);K[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+
-a.n23,a.n44+a.n24);K[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);K[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);K[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;a<6;a++){var b=K[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);J.multiply(b.projectionMatrix,b.matrixWorldInverse);J.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);
-J.multiply(b.matrixWorld,b.projectionMatrixInverse);J.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(c,d){e=0;w.objects.length=0;w.sprites.length=0;w.lights.length=0;var f=function(b){if(b.visible!==!1){var c;if(c=b instanceof THREE.Mesh||b instanceof THREE.Line)if(!(c=b.frustumCulled===!1))a:{for(var d=b.matrixWorld,
-e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),h=0;h<6;h++)if(c=K[h].x*d.n14+K[h].y*d.n24+K[h].z*d.n34+K[h].w,c<=e){c=!1;break a}c=!0}c?(J.multiplyVector3(D.copy(b.position)),g=a(),g.object=b,g.z=D.z,w.objects.push(g)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(J.multiplyVector3(D.copy(b.position)),g=a(),g.object=b,g.z=D.z,w.sprites.push(g)):b instanceof THREE.Light&&w.lights.push(b);c=0;for(d=b.children.length;c<d;c++)f(b.children[c])}};f(c);d&&
-w.objects.sort(b);return w};this.projectScene=function(a,e,g){var f=e.near,D=e.far,K,G,z,y,L,j,ca,ga,N,X,T,ea,Q,C,Y,S;q=s=n=o=0;w.elements.length=0;e.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);J.multiply(e.projectionMatrix,e.matrixWorldInverse);this.computeFrustum(J);w=this.projectGraph(a,!1);a=0;for(K=w.objects.length;a<K;a++)if(N=w.objects[a].object,X=N.matrixWorld,
-ea=N.material,i=0,N instanceof THREE.Mesh){T=N.geometry;Q=N.geometry.materials;y=T.vertices;C=T.faces;Y=T.faceVertexUvs;T=N.matrixRotationWorld.extractRotation(X);G=0;for(z=y.length;G<z;G++)h=c(),h.positionWorld.copy(y[G].position),X.multiplyVector3(h.positionWorld),h.positionScreen.copy(h.positionWorld),J.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>f&&h.positionScreen.z<D;y=0;for(G=C.length;y<G;y++){z=
-C[y];if(z instanceof THREE.Face3)if(L=l[z.a],j=l[z.b],ca=l[z.c],L.visible&&j.visible&&ca.visible&&(N.doubleSided||N.flipSided!=(ca.positionScreen.x-L.positionScreen.x)*(j.positionScreen.y-L.positionScreen.y)-(ca.positionScreen.y-L.positionScreen.y)*(j.positionScreen.x-L.positionScreen.x)<0))ga=p[o]=p[o]||new THREE.RenderableFace3,o++,k=ga,k.v1.copy(L),k.v2.copy(j),k.v3.copy(ca);else continue;else if(z instanceof THREE.Face4)if(L=l[z.a],j=l[z.b],ca=l[z.c],ga=l[z.d],L.visible&&j.visible&&ca.visible&&
-ga.visible&&(N.doubleSided||N.flipSided!=((ga.positionScreen.x-L.positionScreen.x)*(j.positionScreen.y-L.positionScreen.y)-(ga.positionScreen.y-L.positionScreen.y)*(j.positionScreen.x-L.positionScreen.x)<0||(j.positionScreen.x-ca.positionScreen.x)*(ga.positionScreen.y-ca.positionScreen.y)-(j.positionScreen.y-ca.positionScreen.y)*(ga.positionScreen.x-ca.positionScreen.x)<0)))S=r[n]=r[n]||new THREE.RenderableFace4,n++,k=S,k.v1.copy(L),k.v2.copy(j),k.v3.copy(ca),k.v4.copy(ga);else continue;k.normalWorld.copy(z.normal);
-T.multiplyVector3(k.normalWorld);k.centroidWorld.copy(z.centroid);X.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);J.multiplyVector3(k.centroidScreen);ca=z.vertexNormals;L=0;for(j=ca.length;L<j;L++)ga=k.vertexNormalsWorld[L],ga.copy(ca[L]),T.multiplyVector3(ga);L=0;for(j=Y.length;L<j;L++)if(S=Y[L][y]){ca=0;for(ga=S.length;ca<ga;ca++)k.uvs[L][ca]=S[ca]}k.material=ea;k.faceMaterial=z.materialIndex!==null?Q[z.materialIndex]:null;k.z=k.centroidScreen.z;w.elements.push(k)}}else if(N instanceof
-THREE.Line){M.multiply(J,X);y=N.geometry.vertices;L=c();L.positionScreen.copy(y[0].position);M.multiplyVector4(L.positionScreen);G=1;for(z=y.length;G<z;G++)if(L=c(),L.positionScreen.copy(y[G].position),M.multiplyVector4(L.positionScreen),j=l[i-2],E.copy(L.positionScreen),P.copy(j.positionScreen),d(E,P))E.multiplyScalar(1/E.w),P.multiplyScalar(1/P.w),N=t[s]=t[s]||new THREE.RenderableLine,s++,m=N,m.v1.positionScreen.copy(E),m.v2.positionScreen.copy(P),m.z=Math.max(E.z,P.z),m.material=ea,w.elements.push(m)}a=
-0;for(K=w.sprites.length;a<K;a++)if(N=w.sprites[a].object,X=N.matrixWorld,N instanceof THREE.Particle&&(x.set(X.n14,X.n24,X.n34,1),J.multiplyVector4(x),x.z/=x.w,x.z>0&&x.z<1))f=A[q]=A[q]||new THREE.RenderableParticle,q++,v=f,v.x=x.x/x.w,v.y=x.y/x.w,v.z=x.z,v.rotation=N.rotation.z,v.scale.x=N.scale.x*Math.abs(v.x-(x.x+e.projectionMatrix.n11)/(x.w+e.projectionMatrix.n14)),v.scale.y=N.scale.y*Math.abs(v.y-(x.y+e.projectionMatrix.n22)/(x.w+e.projectionMatrix.n24)),v.material=N.material,w.elements.push(v);
+k,o,p=[],n,s=[],m,q,t=[],u,r,z=[],w={objects:[],sprites:[],lights:[],elements:[]},C=new THREE.Vector3,x=new THREE.Vector4,O=new THREE.Matrix4,G=new THREE.Matrix4,K=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],D=new THREE.Vector4,P=new THREE.Vector4;this.computeFrustum=function(a){K[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);K[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);K[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+
+a.n23,a.n44+a.n24);K[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);K[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);K[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;a<6;a++){var b=K[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);O.multiply(b.projectionMatrix,b.matrixWorldInverse);O.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);
+O.multiply(b.matrixWorld,b.projectionMatrixInverse);O.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(c,d){e=0;w.objects.length=0;w.sprites.length=0;w.lights.length=0;var f=function(b){if(b.visible!==!1){var c;if(c=b instanceof THREE.Mesh||b instanceof THREE.Line)if(!(c=b.frustumCulled===!1))a:{for(var d=b.matrixWorld,
+e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),h=0;h<6;h++)if(c=K[h].x*d.n14+K[h].y*d.n24+K[h].z*d.n34+K[h].w,c<=e){c=!1;break a}c=!0}c?(O.multiplyVector3(C.copy(b.position)),g=a(),g.object=b,g.z=C.z,w.objects.push(g)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(O.multiplyVector3(C.copy(b.position)),g=a(),g.object=b,g.z=C.z,w.sprites.push(g)):b instanceof THREE.Light&&w.lights.push(b);c=0;for(d=b.children.length;c<d;c++)f(b.children[c])}};f(c);d&&
+w.objects.sort(b);return w};this.projectScene=function(a,e,g){var f=e.near,C=e.far,K,H,F,y,L,j,X,fa,M,Q,Y,ca,T,B,ja,$;r=q=n=o=0;w.elements.length=0;e.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);O.multiply(e.projectionMatrix,e.matrixWorldInverse);this.computeFrustum(O);w=this.projectGraph(a,!1);a=0;for(K=w.objects.length;a<K;a++)if(M=w.objects[a].object,Q=M.matrixWorld,
+ca=M.material,i=0,M instanceof THREE.Mesh){Y=M.geometry;T=M.geometry.materials;y=Y.vertices;B=Y.faces;ja=Y.faceVertexUvs;Y=M.matrixRotationWorld.extractRotation(Q);H=0;for(F=y.length;H<F;H++)h=c(),h.positionWorld.copy(y[H].position),Q.multiplyVector3(h.positionWorld),h.positionScreen.copy(h.positionWorld),O.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>f&&h.positionScreen.z<C;y=0;for(H=B.length;y<H;y++){F=
+B[y];if(F instanceof THREE.Face3)if(L=l[F.a],j=l[F.b],X=l[F.c],L.visible&&j.visible&&X.visible&&(M.doubleSided||M.flipSided!=(X.positionScreen.x-L.positionScreen.x)*(j.positionScreen.y-L.positionScreen.y)-(X.positionScreen.y-L.positionScreen.y)*(j.positionScreen.x-L.positionScreen.x)<0))fa=p[o]=p[o]||new THREE.RenderableFace3,o++,k=fa,k.v1.copy(L),k.v2.copy(j),k.v3.copy(X);else continue;else if(F instanceof THREE.Face4)if(L=l[F.a],j=l[F.b],X=l[F.c],fa=l[F.d],L.visible&&j.visible&&X.visible&&fa.visible&&
+(M.doubleSided||M.flipSided!=((fa.positionScreen.x-L.positionScreen.x)*(j.positionScreen.y-L.positionScreen.y)-(fa.positionScreen.y-L.positionScreen.y)*(j.positionScreen.x-L.positionScreen.x)<0||(j.positionScreen.x-X.positionScreen.x)*(fa.positionScreen.y-X.positionScreen.y)-(j.positionScreen.y-X.positionScreen.y)*(fa.positionScreen.x-X.positionScreen.x)<0)))$=s[n]=s[n]||new THREE.RenderableFace4,n++,k=$,k.v1.copy(L),k.v2.copy(j),k.v3.copy(X),k.v4.copy(fa);else continue;k.normalWorld.copy(F.normal);
+Y.multiplyVector3(k.normalWorld);k.centroidWorld.copy(F.centroid);Q.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);O.multiplyVector3(k.centroidScreen);X=F.vertexNormals;L=0;for(j=X.length;L<j;L++)fa=k.vertexNormalsWorld[L],fa.copy(X[L]),Y.multiplyVector3(fa);L=0;for(j=ja.length;L<j;L++)if($=ja[L][y]){X=0;for(fa=$.length;X<fa;X++)k.uvs[L][X]=$[X]}k.material=ca;k.faceMaterial=F.materialIndex!==null?T[F.materialIndex]:null;k.z=k.centroidScreen.z;w.elements.push(k)}}else if(M instanceof
+THREE.Line){G.multiply(O,Q);y=M.geometry.vertices;L=c();L.positionScreen.copy(y[0].position);G.multiplyVector4(L.positionScreen);H=1;for(F=y.length;H<F;H++)if(L=c(),L.positionScreen.copy(y[H].position),G.multiplyVector4(L.positionScreen),j=l[i-2],D.copy(L.positionScreen),P.copy(j.positionScreen),d(D,P))D.multiplyScalar(1/D.w),P.multiplyScalar(1/P.w),M=t[q]=t[q]||new THREE.RenderableLine,q++,m=M,m.v1.positionScreen.copy(D),m.v2.positionScreen.copy(P),m.z=Math.max(D.z,P.z),m.material=ca,w.elements.push(m)}a=
+0;for(K=w.sprites.length;a<K;a++)if(M=w.sprites[a].object,Q=M.matrixWorld,M instanceof THREE.Particle&&(x.set(Q.n14,Q.n24,Q.n34,1),O.multiplyVector4(x),x.z/=x.w,x.z>0&&x.z<1))f=z[r]=z[r]||new THREE.RenderableParticle,r++,u=f,u.x=x.x/x.w,u.y=x.y/x.w,u.z=x.z,u.rotation=M.rotation.z,u.scale.x=M.scale.x*Math.abs(u.x-(x.x+e.projectionMatrix.n11)/(x.w+e.projectionMatrix.n14)),u.scale.y=M.scale.y*Math.abs(u.y-(x.y+e.projectionMatrix.n22)/(x.w+e.projectionMatrix.n24)),u.material=M.material,w.elements.push(u);
 g&&w.elements.sort(b);return w}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==void 0?d:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var c=Math.PI/360,b=a.x*c,d=a.y*c,g=a.z*c,a=Math.cos(d),d=Math.sin(d),c=Math.cos(-g),g=Math.sin(-g),e=Math.cos(b),b=Math.sin(b),f=a*c,h=d*g;this.w=f*e-h*b;this.x=f*b+h*e;this.y=d*c*e+a*g*b;this.z=a*g*e-d*c*b;return this},setFromAxisAngle:function(a,c){var b=c/2,d=Math.sin(b);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(b);return this},setFromRotationMatrix:function(a){var c=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,c+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,c-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,c-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
@@ -83,9 +83,9 @@ c;a++)b=this.faces[a],b.centroid.set(0,0,0),b instanceof THREE.Face3?(b.centroid
 b,d,g,e,f,h=new THREE.Vector3,i=new THREE.Vector3;d=0;for(g=this.faces.length;d<g;d++){e=this.faces[d];if(a&&e.vertexNormals.length){h.set(0,0,0);c=0;for(b=e.vertexNormals.length;c<b;c++)h.addSelf(e.vertexNormals[c]);h.divideScalar(3)}else c=this.vertices[e.a],b=this.vertices[e.b],f=this.vertices[e.c],h.sub(f.position,b.position),i.sub(c.position,b.position),h.crossSelf(i);h.isZero()||h.normalize();e.normal.copy(h)}},computeVertexNormals:function(){var a,c,b,d;if(this.__tmpVertices===void 0){d=this.__tmpVertices=
 Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)d[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++)if(b=this.faces[a],b instanceof THREE.Face3)b.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(b instanceof THREE.Face4)b.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)d[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++)b=this.faces[a],b instanceof
 THREE.Face3?(d[b.a].addSelf(b.normal),d[b.b].addSelf(b.normal),d[b.c].addSelf(b.normal)):b instanceof THREE.Face4&&(d[b.a].addSelf(b.normal),d[b.b].addSelf(b.normal),d[b.c].addSelf(b.normal),d[b.d].addSelf(b.normal));a=0;for(c=this.vertices.length;a<c;a++)d[a].normalize();a=0;for(c=this.faces.length;a<c;a++)b=this.faces[a],b instanceof THREE.Face3?(b.vertexNormals[0].copy(d[b.a]),b.vertexNormals[1].copy(d[b.b]),b.vertexNormals[2].copy(d[b.c])):b instanceof THREE.Face4&&(b.vertexNormals[0].copy(d[b.a]),
-b.vertexNormals[1].copy(d[b.b]),b.vertexNormals[2].copy(d[b.c]),b.vertexNormals[3].copy(d[b.d]))},computeTangents:function(){function a(a,b,c,d,e,g,j){h=a.vertices[b].position;i=a.vertices[c].position;l=a.vertices[d].position;k=f[e];o=f[g];p=f[j];n=i.x-h.x;r=l.x-h.x;m=i.y-h.y;s=l.y-h.y;t=i.z-h.z;v=l.z-h.z;q=o.u-k.u;A=p.u-k.u;w=o.v-k.v;D=p.v-k.v;x=1/(q*D-A*w);E.set((D*n-w*r)*x,(D*m-w*s)*x,(D*t-w*v)*x);P.set((q*r-A*n)*x,(q*s-A*m)*x,(q*v-A*t)*x);M[b].addSelf(E);M[c].addSelf(E);M[d].addSelf(E);K[b].addSelf(P);
-K[c].addSelf(P);K[d].addSelf(P)}var c,b,d,g,e,f,h,i,l,k,o,p,n,r,m,s,t,v,q,A,w,D,x,J,M=[],K=[],E=new THREE.Vector3,P=new THREE.Vector3,I=new THREE.Vector3,V=new THREE.Vector3,Z=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++)M[c]=new THREE.Vector3,K[c]=new THREE.Vector3;c=0;for(b=this.faces.length;c<b;c++)e=this.faces[c],f=this.faceVertexUvs[0][c],e instanceof THREE.Face3?a(this,e.a,e.b,e.c,0,1,2):e instanceof THREE.Face4&&(a(this,e.a,e.b,e.c,0,1,2),a(this,e.a,e.b,e.d,0,1,3));var R=["a","b",
-"c","d"];c=0;for(b=this.faces.length;c<b;c++){e=this.faces[c];for(d=0;d<e.vertexNormals.length;d++)Z.copy(e.vertexNormals[d]),g=e[R[d]],J=M[g],I.copy(J),I.subSelf(Z.multiplyScalar(Z.dot(J))).normalize(),V.cross(e.vertexNormals[d],J),g=V.dot(K[g]),g=g<0?-1:1,e.vertexTangents[d]=new THREE.Vector4(I.x,I.y,I.z,g)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,
+b.vertexNormals[1].copy(d[b.b]),b.vertexNormals[2].copy(d[b.c]),b.vertexNormals[3].copy(d[b.d]))},computeTangents:function(){function a(a,b,c,d,e,g,j){h=a.vertices[b].position;i=a.vertices[c].position;l=a.vertices[d].position;k=f[e];o=f[g];p=f[j];n=i.x-h.x;s=l.x-h.x;m=i.y-h.y;q=l.y-h.y;t=i.z-h.z;u=l.z-h.z;r=o.u-k.u;z=p.u-k.u;w=o.v-k.v;C=p.v-k.v;x=1/(r*C-z*w);D.set((C*n-w*s)*x,(C*m-w*q)*x,(C*t-w*u)*x);P.set((r*s-z*n)*x,(r*q-z*m)*x,(r*u-z*t)*x);G[b].addSelf(D);G[c].addSelf(D);G[d].addSelf(D);K[b].addSelf(P);
+K[c].addSelf(P);K[d].addSelf(P)}var c,b,d,g,e,f,h,i,l,k,o,p,n,s,m,q,t,u,r,z,w,C,x,O,G=[],K=[],D=new THREE.Vector3,P=new THREE.Vector3,I=new THREE.Vector3,W=new THREE.Vector3,Z=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++)G[c]=new THREE.Vector3,K[c]=new THREE.Vector3;c=0;for(b=this.faces.length;c<b;c++)e=this.faces[c],f=this.faceVertexUvs[0][c],e instanceof THREE.Face3?a(this,e.a,e.b,e.c,0,1,2):e instanceof THREE.Face4&&(a(this,e.a,e.b,e.c,0,1,2),a(this,e.a,e.b,e.d,0,1,3));var R=["a","b",
+"c","d"];c=0;for(b=this.faces.length;c<b;c++){e=this.faces[c];for(d=0;d<e.vertexNormals.length;d++)Z.copy(e.vertexNormals[d]),g=e[R[d]],O=G[g],I.copy(O),I.subSelf(Z.multiplyScalar(Z.dot(O))).normalize(),W.cross(e.vertexNormals[d],O),g=W.dot(K[g]),g=g<0?-1:1,e.vertexTangents[d]=new THREE.Vector4(I.x,I.y,I.z,g)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,
 this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,b=this.vertices.length;c<b;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=
 a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,c=0,b=this.vertices.length;c<b;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},c=[],b=[],d,g=Math.pow(10,4),e,f;e=0;for(f=this.vertices.length;e<f;e++)d=this.vertices[e].position,d=[Math.round(d.x*g),Math.round(d.y*g),Math.round(d.z*g)].join("_"),a[d]===void 0?(a[d]=e,c.push(this.vertices[e]),
 b[e]=c.length-1):b[e]=b[a[d]];e=0;for(f=this.faces.length;e<f;e++)if(a=this.faces[e],a instanceof THREE.Face3)a.a=b[a.a],a.b=b[a.b],a.c=b[a.c];else if(a instanceof THREE.Face4)a.a=b[a.a],a.b=b[a.b],a.c=b[a.c],a.d=b[a.d];this.vertices=c}};THREE.GeometryCount=0;
@@ -148,46 +148,47 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=
 THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a);var c=this.__objectsRemoved.indexOf(a);c!==-1&&this.__objectsRemoved.splice(c,1)}for(c=0;c<a.children.length;c++)this.addObject(a.children[c])};
 THREE.Scene.prototype.removeObject=function(a){if(a instanceof THREE.Light){var c=this.lights.indexOf(a);c!==-1&&this.lights.splice(c,1)}else a instanceof THREE.Camera||(c=this.objects.indexOf(a),c!==-1&&(this.objects.splice(c,1),this.__objectsRemoved.push(a),c=this.__objectsAdded.indexOf(a),c!==-1&&this.__objectsAdded.splice(c,1)));for(c=0;c<a.children.length;c++)this.removeObject(a.children[c])};
 THREE.Fog=function(a,c,b){this.color=new THREE.Color(a);this.near=c!==void 0?c:1;this.far=b!==void 0?b:1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c!==void 0?c:2.5E-4};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,g,e;this.domElement=document.createElement("div");this.setSize=function(a,c){b=a;d=c;g=b/2;e=d/2};this.render=function(b,d){var i,l,k,o,p,n,r,m;a=c.projectScene(b,d);i=0;for(l=a.length;i<l;i++)if(p=a[i],p instanceof THREE.RenderableParticle){r=p.x*g+g;m=p.y*e+e;k=0;for(o=p.material.length;k<o;k++)if(n=p.material[k],n instanceof THREE.ParticleDOMMaterial)n=n.domElement,n.style.left=r+"px",n.style.top=m+"px"}}};
-THREE.CanvasRenderer=function(a){function c(a){if(v!=a)m.globalAlpha=v=a}function b(a){if(q!=a){switch(a){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=a}}function d(a){if(A!=a)m.strokeStyle=A=a}function g(a){if(w!=a)m.fillStyle=w=a}var e=this,f,h,i,l=new THREE.Projector,a=a||{},k=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
-o,p,n,r,m=k.getContext("2d"),s=new THREE.Color(0),t=0,v=1,q=0,A=null,w=null,D=null,x=null,J=null,M,K,E,P,I=new THREE.RenderableVertex,V=new THREE.RenderableVertex,Z,R,W,ka,G,z,y,L,j,ca,ga,N,X=new THREE.Color,T=new THREE.Color,ea=new THREE.Color,Q=new THREE.Color,C=new THREE.Color,Y=[],S,$,oa,la,ra,ta,pa,qa,wa,U,u=new THREE.Rectangle,H=new THREE.Rectangle,aa=new THREE.Rectangle,ja=!1,da=new THREE.Color,ua=new THREE.Color,ba=new THREE.Color,fa=new THREE.Vector3,ia,xa,O,ma,sa,ha,a=16;ia=document.createElement("canvas");
-ia.width=ia.height=2;xa=ia.getContext("2d");xa.fillStyle="rgba(0,0,0,1)";xa.fillRect(0,0,2,2);O=xa.getImageData(0,0,2,2);ma=O.data;sa=document.createElement("canvas");sa.width=sa.height=a;ha=sa.getContext("2d");ha.translate(-a/2,-a/2);ha.scale(a,a);a--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){o=a;p=b;n=Math.floor(o/2);r=Math.floor(p/2);k.width=o;k.height=p;u.set(-n,-r,n,r);H.set(-n,-r,n,r);v=1;q=0;J=x=
-D=w=A=null};this.setClearColor=function(a,b){s.copy(a);t=b;H.set(-n,-r,n,r)};this.setClearColorHex=function(a,b){s.setHex(a);t=b;H.set(-n,-r,n,r)};this.clear=function(){m.setTransform(1,0,0,-1,n,r);H.isEmpty()||(H.minSelf(u),H.inflate(2),t<1&&m.clearRect(Math.floor(H.getX()),Math.floor(H.getY()),Math.floor(H.getWidth()),Math.floor(H.getHeight())),t>0&&(b(THREE.NormalBlending),c(1),g("rgba("+Math.floor(s.r*255)+","+Math.floor(s.g*255)+","+Math.floor(s.b*255)+","+t+")"),m.fillRect(Math.floor(H.getX()),
-Math.floor(H.getY()),Math.floor(H.getWidth()),Math.floor(H.getHeight()))),H.empty())};this.render=function(a,k){function p(a){var b,c,d,e;da.setRGB(0,0,0);ua.setRGB(0,0,0);ba.setRGB(0,0,0);b=0;for(c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(da.r+=e.r,da.g+=e.g,da.b+=e.b):d instanceof THREE.DirectionalLight?(ua.r+=e.r,ua.g+=e.g,ua.b+=e.b):d instanceof THREE.PointLight&&(ba.r+=e.r,ba.g+=e.g,ba.b+=e.b)}function o(a,b,c,d){var e,g,f,j,h,i;e=0;for(g=a.length;e<g;e++)f=a[e],j=f.color,
-f instanceof THREE.DirectionalLight?(h=f.matrixWorld.getPosition(),i=c.dot(h),i<=0||(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(fa.sub(h,b).normalize()),i<=0||(i*=f.distance==0?1:1-Math.min(b.distanceTo(h)/f.distance,1),i!=0&&(i*=f.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function s(a,e,f){c(f.opacity);b(f.blending);var j,h,i,k,l,ha;if(f instanceof THREE.ParticleBasicMaterial){if(f.map)k=f.map.image,l=k.width>>1,ha=
-k.height>>1,f=e.scale.x*n,i=e.scale.y*r,j=f*l,h=i*ha,aa.set(a.x-j,a.y-h,a.x+j,a.y+h),u.intersects(aa)&&(m.save(),m.translate(a.x,a.y),m.rotate(-e.rotation),m.scale(f,-i),m.translate(-l,-ha),m.drawImage(k,0,0),m.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(j=e.scale.x*n,h=e.scale.y*r,aa.set(a.x-j,a.y-h,a.x+j,a.y+h),u.intersects(aa)&&(d(f.color.getContextStyle()),g(f.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-e.rotation),m.scale(j,h),f.program(m),m.restore()))}function q(a,
-e,g,f){c(f.opacity);b(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(D!=a)m.lineWidth=D=a;a=f.linecap;if(x!=a)m.lineCap=x=a;a=f.linejoin;if(J!=a)m.lineJoin=J=a;d(f.color.getContextStyle());m.stroke();aa.inflate(f.linewidth*2)}}function t(a,d,f,g,j,h,n,l){e.info.render.vertices+=3;e.info.render.faces++;c(l.opacity);b(l.blending);Z=a.positionScreen.x;R=a.positionScreen.y;
-W=d.positionScreen.x;ka=d.positionScreen.y;G=f.positionScreen.x;z=f.positionScreen.y;A(Z,R,W,ka,G,z);if(l instanceof THREE.MeshBasicMaterial)if(l.map)l.map.mapping instanceof THREE.UVMapping&&(la=n.uvs[0],Ga(Z,R,W,ka,G,z,la[g].u,la[g].v,la[j].u,la[j].v,la[h].u,la[h].v,l.map));else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,fa.copy(n.vertexNormalsWorld[g]),ra=(fa.x*a.n11+fa.y*a.n12+fa.z*a.n13)*0.5+0.5,ta=-(fa.x*a.n21+fa.y*a.n22+fa.z*a.n23)*0.5+
-0.5,fa.copy(n.vertexNormalsWorld[j]),pa=(fa.x*a.n11+fa.y*a.n12+fa.z*a.n13)*0.5+0.5,qa=-(fa.x*a.n21+fa.y*a.n22+fa.z*a.n23)*0.5+0.5,fa.copy(n.vertexNormalsWorld[h]),wa=(fa.x*a.n11+fa.y*a.n12+fa.z*a.n13)*0.5+0.5,U=-(fa.x*a.n21+fa.y*a.n22+fa.z*a.n23)*0.5+0.5,Ga(Z,R,W,ka,G,z,ra,ta,pa,qa,wa,U,l.envMap)}else l.wireframe?ya(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):w(l.color);else if(l instanceof THREE.MeshLambertMaterial)l.map&&!l.wireframe&&(l.map.mapping instanceof THREE.UVMapping&&
-(la=n.uvs[0],Ga(Z,R,W,ka,G,z,la[g].u,la[g].v,la[j].u,la[j].v,la[h].u,la[h].v,l.map)),b(THREE.SubtractiveBlending)),ja?!l.wireframe&&l.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==3?(T.r=ea.r=Q.r=da.r,T.g=ea.g=Q.g=da.g,T.b=ea.b=Q.b=da.b,o(i,n.v1.positionWorld,n.vertexNormalsWorld[0],T),o(i,n.v2.positionWorld,n.vertexNormalsWorld[1],ea),o(i,n.v3.positionWorld,n.vertexNormalsWorld[2],Q),T.r=Math.max(0,Math.min(l.color.r*T.r,1)),T.g=Math.max(0,Math.min(l.color.g*T.g,1)),T.b=Math.max(0,Math.min(l.color.b*
-T.b,1)),ea.r=Math.max(0,Math.min(l.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(l.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(l.color.b*ea.b,1)),Q.r=Math.max(0,Math.min(l.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(l.color.g*Q.g,1)),Q.b=Math.max(0,Math.min(l.color.b*Q.b,1)),C.r=(ea.r+Q.r)*0.5,C.g=(ea.g+Q.g)*0.5,C.b=(ea.b+Q.b)*0.5,oa=Da(T,ea,Q,C),Ba(Z,R,W,ka,G,z,0,0,1,0,0,1,oa)):(X.r=da.r,X.g=da.g,X.b=da.b,o(i,n.centroidWorld,n.normalWorld,X),X.r=Math.max(0,Math.min(l.color.r*X.r,1)),X.g=Math.max(0,Math.min(l.color.g*
-X.g,1)),X.b=Math.max(0,Math.min(l.color.b*X.b,1)),l.wireframe?ya(X,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):w(X)):l.wireframe?ya(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):w(l.color);else if(l instanceof THREE.MeshDepthMaterial)S=k.near,$=k.far,T.r=T.g=T.b=1-Aa(a.positionScreen.z,S,$),ea.r=ea.g=ea.b=1-Aa(d.positionScreen.z,S,$),Q.r=Q.g=Q.b=1-Aa(f.positionScreen.z,S,$),C.r=(ea.r+Q.r)*0.5,C.g=(ea.g+Q.g)*0.5,C.b=(ea.b+Q.b)*0.5,oa=Da(T,ea,Q,C),Ba(Z,R,W,ka,
-G,z,0,0,1,0,0,1,oa);else if(l instanceof THREE.MeshNormalMaterial)X.r=Ca(n.normalWorld.x),X.g=Ca(n.normalWorld.y),X.b=Ca(n.normalWorld.z),l.wireframe?ya(X,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):w(X)}function v(a,d,f,g,h,l,n,m,ha){e.info.render.vertices+=4;e.info.render.faces++;c(m.opacity);b(m.blending);if(m.map||m.envMap)t(a,d,g,0,1,3,n,m,ha),t(h,f,l,1,2,3,n,m,ha);else if(Z=a.positionScreen.x,R=a.positionScreen.y,W=d.positionScreen.x,ka=d.positionScreen.y,G=f.positionScreen.x,
-z=f.positionScreen.y,y=g.positionScreen.x,L=g.positionScreen.y,j=h.positionScreen.x,ca=h.positionScreen.y,ga=l.positionScreen.x,N=l.positionScreen.y,m instanceof THREE.MeshBasicMaterial)Ea(Z,R,W,ka,G,z,y,L),m.wireframe?ya(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):w(m.color);else if(m instanceof THREE.MeshLambertMaterial)ja?!m.wireframe&&m.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==4?(T.r=ea.r=Q.r=C.r=da.r,T.g=ea.g=Q.g=C.g=da.g,T.b=ea.b=Q.b=C.b=da.b,o(i,n.v1.positionWorld,
-n.vertexNormalsWorld[0],T),o(i,n.v2.positionWorld,n.vertexNormalsWorld[1],ea),o(i,n.v4.positionWorld,n.vertexNormalsWorld[3],Q),o(i,n.v3.positionWorld,n.vertexNormalsWorld[2],C),T.r=Math.max(0,Math.min(m.color.r*T.r,1)),T.g=Math.max(0,Math.min(m.color.g*T.g,1)),T.b=Math.max(0,Math.min(m.color.b*T.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)),Q.r=Math.max(0,Math.min(m.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(m.color.g*
-Q.g,1)),Q.b=Math.max(0,Math.min(m.color.b*Q.b,1)),C.r=Math.max(0,Math.min(m.color.r*C.r,1)),C.g=Math.max(0,Math.min(m.color.g*C.g,1)),C.b=Math.max(0,Math.min(m.color.b*C.b,1)),oa=Da(T,ea,Q,C),A(Z,R,W,ka,y,L),Ba(Z,R,W,ka,y,L,0,0,1,0,0,1,oa),A(j,ca,G,z,ga,N),Ba(j,ca,G,z,ga,N,1,0,1,1,0,1,oa)):(X.r=da.r,X.g=da.g,X.b=da.b,o(i,n.centroidWorld,n.normalWorld,X),X.r=Math.max(0,Math.min(m.color.r*X.r,1)),X.g=Math.max(0,Math.min(m.color.g*X.g,1)),X.b=Math.max(0,Math.min(m.color.b*X.b,1)),Ea(Z,R,W,ka,G,z,y,L),
-m.wireframe?ya(X,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):w(X)):(Ea(Z,R,W,ka,G,z,y,L),m.wireframe?ya(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):w(m.color));else if(m instanceof THREE.MeshNormalMaterial)X.r=Ca(n.normalWorld.x),X.g=Ca(n.normalWorld.y),X.b=Ca(n.normalWorld.z),Ea(Z,R,W,ka,G,z,y,L),m.wireframe?ya(X,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):w(X);else if(m instanceof THREE.MeshDepthMaterial)S=k.near,$=k.far,T.r=T.g=T.b=1-Aa(a.positionScreen.z,
-S,$),ea.r=ea.g=ea.b=1-Aa(d.positionScreen.z,S,$),Q.r=Q.g=Q.b=1-Aa(g.positionScreen.z,S,$),C.r=C.g=C.b=1-Aa(f.positionScreen.z,S,$),oa=Da(T,ea,Q,C),A(Z,R,W,ka,y,L),Ba(Z,R,W,ka,y,L,0,0,1,0,0,1,oa),A(j,ca,G,z,ga,N),Ba(j,ca,G,z,ga,N,1,0,1,1,0,1,oa)}function A(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 Ea(a,b,c,d,e,f,g,j){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(g,j);m.lineTo(a,b);m.closePath()}function ya(a,b,c,e){if(D!=
-b)m.lineWidth=D=b;if(x!=c)m.lineCap=x=c;if(J!=e)m.lineJoin=J=e;d(a.getContextStyle());m.stroke();aa.inflate(b*2)}function w(a){g(a.getContextStyle());m.fill()}function Ga(a,b,c,d,e,f,j,h,i,k,n,l,ha){if(ha.image.width!=0){if(ha.needsUpdate==!0||Y[ha.id]==void 0){var o=ha.wrapS==THREE.RepeatWrapping,p=ha.wrapT==THREE.RepeatWrapping;Y[ha.id]=m.createPattern(ha.image,o&&p?"repeat":o&&!p?"repeat-x":!o&&p?"repeat-y":"no-repeat");ha.needsUpdate=!1}g(Y[ha.id]);var o=ha.offset.x/ha.repeat.x,p=ha.offset.y/
-ha.repeat.y,U=ha.image.width*ha.repeat.x,ha=ha.image.height*ha.repeat.y,j=(j+o)*U,h=(h+p)*ha,i=(i+o)*U+1,k=(k+p)*ha,n=(n+o)*U+1,l=(l+p)*ha+1;c-=a;d-=b;e-=a;f-=b;i-=j;k-=h;n-=j;l-=h;o=1/(i*l-n*k);ha=(l*c-k*e)*o;k=(l*d-k*f)*o;c=(i*e-n*c)*o;d=(i*f-n*d)*o;a=a-ha*j-c*h;b=b-k*j-d*h;m.save();m.transform(ha,k,c,d,a,b);m.fill();m.restore()}}function Ba(a,b,c,d,e,f,g,j,h,i,k,n,l){var ha,o;ha=l.width-1;o=l.height-1;g*=ha;j*=o;h*=ha;i*=o;k*=ha;n*=o;c-=a;d-=b;e-=a;f-=b;h-=g;i-=j;k-=g;n-=j;o=1/(h*n-k*i);ha=(n*
-c-i*e)*o;i=(n*d-i*f)*o;c=(h*e-k*c)*o;d=(h*f-k*d)*o;a=a-ha*g-c*j;b=b-i*g-d*j;m.save();m.transform(ha,i,c,d,a,b);m.clip();m.drawImage(l,0,0);m.restore()}function Da(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),j=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),i=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),n=~~(d.g*255),d=~~(d.b*255);ma[0]=e<0?0:e>255?255:e;ma[1]=f<0?0:f>255?255:f;ma[2]=a<0?0:a>255?255:a;ma[4]=g<0?0:g>255?255:g;ma[5]=j<0?0:j>255?255:j;ma[6]=b<0?0:b>255?255:b;ma[8]=h<0?0:h>
-255?255:h;ma[9]=i<0?0:i>255?255:i;ma[10]=c<0?0:c>255?255:c;ma[12]=k<0?0:k>255?255:k;ma[13]=n<0?0:n>255?255:n;ma[14]=d<0?0:d>255?255:d;xa.putImageData(O,0,0);ha.drawImage(ia,0,0);return sa}function Aa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ca(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function za(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Fa,Ha,na,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,n,r);e.info.render.vertices=0;e.info.render.faces=
-0;f=l.projectScene(a,k,this.sortElements);h=f.elements;i=f.lights;(ja=i.length>0)&&p(i);Fa=0;for(Ha=h.length;Fa<Ha;Fa++)if(na=h[Fa],va=na.material,va=va instanceof THREE.MeshFaceMaterial?na.faceMaterial:va,!(va==null||va.opacity==0)){aa.empty();if(na instanceof THREE.RenderableParticle)M=na,M.x*=n,M.y*=r,s(M,na,va,a);else if(na instanceof THREE.RenderableLine)M=na.v1,K=na.v2,M.positionScreen.x*=n,M.positionScreen.y*=r,K.positionScreen.x*=n,K.positionScreen.y*=r,aa.addPoint(M.positionScreen.x,M.positionScreen.y),
-aa.addPoint(K.positionScreen.x,K.positionScreen.y),u.intersects(aa)&&q(M,K,na,va,a);else if(na instanceof THREE.RenderableFace3)M=na.v1,K=na.v2,E=na.v3,M.positionScreen.x*=n,M.positionScreen.y*=r,K.positionScreen.x*=n,K.positionScreen.y*=r,E.positionScreen.x*=n,E.positionScreen.y*=r,va.overdraw&&(za(M.positionScreen,K.positionScreen),za(K.positionScreen,E.positionScreen),za(E.positionScreen,M.positionScreen)),aa.add3Points(M.positionScreen.x,M.positionScreen.y,K.positionScreen.x,K.positionScreen.y,
-E.positionScreen.x,E.positionScreen.y),u.intersects(aa)&&t(M,K,E,0,1,2,na,va,a);else if(na instanceof THREE.RenderableFace4)M=na.v1,K=na.v2,E=na.v3,P=na.v4,M.positionScreen.x*=n,M.positionScreen.y*=r,K.positionScreen.x*=n,K.positionScreen.y*=r,E.positionScreen.x*=n,E.positionScreen.y*=r,P.positionScreen.x*=n,P.positionScreen.y*=r,I.positionScreen.copy(K.positionScreen),V.positionScreen.copy(P.positionScreen),va.overdraw&&(za(M.positionScreen,K.positionScreen),za(K.positionScreen,P.positionScreen),
-za(P.positionScreen,M.positionScreen),za(E.positionScreen,I.positionScreen),za(E.positionScreen,V.positionScreen)),aa.addPoint(M.positionScreen.x,M.positionScreen.y),aa.addPoint(K.positionScreen.x,K.positionScreen.y),aa.addPoint(E.positionScreen.x,E.positionScreen.y),aa.addPoint(P.positionScreen.x,P.positionScreen.y),u.intersects(aa)&&v(M,K,E,P,I,V,na,va,a);H.addRectangle(aa)}m.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,j,h,i;e=0;for(f=a.length;e<f;e++)g=a[e],j=g.color,g instanceof THREE.DirectionalLight?(h=g.matrixWorld.getPosition(),i=c.dot(h),i<=0||(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),i=c.dot(M.sub(h,b).normalize()),i<=0||(i*=g.distance==0?1:1-Math.min(b.distanceTo(h)/g.distance,1),i!=0&&(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function c(a){K[a]==null&&(K[a]=document.createElementNS("http://www.w3.org/2000/svg",
-"path"),Z==0&&K[a].setAttribute("shape-rendering","crispEdges"));return K[a]}function b(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var d=this,g,e,f,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,k,o,p,n,r,m,s,t=new THREE.Rectangle,v=new THREE.Rectangle,q=!1,A=new THREE.Color,w=new THREE.Color,D=new THREE.Color,x=new THREE.Color,J,M=new THREE.Vector3,K=[],E=[],P,I,V,Z=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":Z=1;break;case "low":Z=0}};this.setSize=function(a,b){l=a;k=b;o=l/2;p=k/2;i.setAttribute("viewBox",-o+" "+-p+" "+l+" "+k);i.setAttribute("width",l);i.setAttribute("height",k);t.set(-o,-p,o,p)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,l){var M,G,z,y;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;g=h.projectScene(k,l,this.sortElements);e=g.elements;
-f=g.lights;V=I=0;if(q=f.length>0){w.setRGB(0,0,0);D.setRGB(0,0,0);x.setRGB(0,0,0);M=0;for(G=f.length;M<G;M++)y=f[M],z=y.color,y instanceof THREE.AmbientLight?(w.r+=z.r,w.g+=z.g,w.b+=z.b):y instanceof THREE.DirectionalLight?(D.r+=z.r,D.g+=z.g,D.b+=z.b):y instanceof THREE.PointLight&&(x.r+=z.r,x.g+=z.g,x.b+=z.b)}M=0;for(G=e.length;M<G;M++)if(z=e[M],y=z.material,y=y instanceof THREE.MeshFaceMaterial?z.faceMaterial:y,!(y==null||y.opacity==0))if(v.empty(),z instanceof THREE.RenderableParticle)n=z,n.x*=
-o,n.y*=-p;else if(z instanceof THREE.RenderableLine){if(n=z.v1,r=z.v2,n.positionScreen.x*=o,n.positionScreen.y*=-p,r.positionScreen.x*=o,r.positionScreen.y*=-p,v.addPoint(n.positionScreen.x,n.positionScreen.y),v.addPoint(r.positionScreen.x,r.positionScreen.y),t.intersects(v)){z=n;var L=r,j=V++;E[j]==null&&(E[j]=document.createElementNS("http://www.w3.org/2000/svg","line"),Z==0&&E[j].setAttribute("shape-rendering","crispEdges"));P=E[j];P.setAttribute("x1",z.positionScreen.x);P.setAttribute("y1",z.positionScreen.y);
-P.setAttribute("x2",L.positionScreen.x);P.setAttribute("y2",L.positionScreen.y);y instanceof THREE.LineBasicMaterial&&(P.setAttribute("style","fill: none; stroke: "+y.color.getContextStyle()+"; stroke-width: "+y.linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.linecap+"; stroke-linejoin: "+y.linejoin),i.appendChild(P))}}else if(z instanceof THREE.RenderableFace3){if(n=z.v1,r=z.v2,m=z.v3,n.positionScreen.x*=o,n.positionScreen.y*=-p,r.positionScreen.x*=o,r.positionScreen.y*=-p,m.positionScreen.x*=
-o,m.positionScreen.y*=-p,v.addPoint(n.positionScreen.x,n.positionScreen.y),v.addPoint(r.positionScreen.x,r.positionScreen.y),v.addPoint(m.positionScreen.x,m.positionScreen.y),t.intersects(v)){var L=n,j=r,K=m;d.info.render.vertices+=3;d.info.render.faces++;P=c(I++);P.setAttribute("d","M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+j.positionScreen.x+" "+j.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");y instanceof THREE.MeshBasicMaterial?A.copy(y.color):y instanceof THREE.MeshLambertMaterial?
-q?(A.r=w.r,A.g=w.g,A.b=w.b,a(f,z.centroidWorld,z.normalWorld,A),A.r=Math.max(0,Math.min(y.color.r*A.r,1)),A.g=Math.max(0,Math.min(y.color.g*A.g,1)),A.b=Math.max(0,Math.min(y.color.b*A.b,1))):A.copy(y.color):y instanceof THREE.MeshDepthMaterial?(J=1-y.__2near/(y.__farPlusNear-z.z*y.__farMinusNear),A.setRGB(J,J,J)):y instanceof THREE.MeshNormalMaterial&&A.setRGB(b(z.normalWorld.x),b(z.normalWorld.y),b(z.normalWorld.z));y.wireframe?P.setAttribute("style","fill: none; stroke: "+A.getContextStyle()+"; stroke-width: "+
-y.wireframeLinewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframeLinecap+"; stroke-linejoin: "+y.wireframeLinejoin):P.setAttribute("style","fill: "+A.getContextStyle()+"; fill-opacity: "+y.opacity);i.appendChild(P)}}else if(z instanceof THREE.RenderableFace4&&(n=z.v1,r=z.v2,m=z.v3,s=z.v4,n.positionScreen.x*=o,n.positionScreen.y*=-p,r.positionScreen.x*=o,r.positionScreen.y*=-p,m.positionScreen.x*=o,m.positionScreen.y*=-p,s.positionScreen.x*=o,s.positionScreen.y*=-p,v.addPoint(n.positionScreen.x,
-n.positionScreen.y),v.addPoint(r.positionScreen.x,r.positionScreen.y),v.addPoint(m.positionScreen.x,m.positionScreen.y),v.addPoint(s.positionScreen.x,s.positionScreen.y),t.intersects(v))){var L=n,j=r,K=m,ga=s;d.info.render.vertices+=4;d.info.render.faces++;P=c(I++);P.setAttribute("d","M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+j.positionScreen.x+" "+j.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+" L "+ga.positionScreen.x+","+ga.positionScreen.y+"z");y instanceof THREE.MeshBasicMaterial?
-A.copy(y.color):y instanceof THREE.MeshLambertMaterial?q?(A.r=w.r,A.g=w.g,A.b=w.b,a(f,z.centroidWorld,z.normalWorld,A),A.r=Math.max(0,Math.min(y.color.r*A.r,1)),A.g=Math.max(0,Math.min(y.color.g*A.g,1)),A.b=Math.max(0,Math.min(y.color.b*A.b,1))):A.copy(y.color):y instanceof THREE.MeshDepthMaterial?(J=1-y.__2near/(y.__farPlusNear-z.z*y.__farMinusNear),A.setRGB(J,J,J)):y instanceof THREE.MeshNormalMaterial&&A.setRGB(b(z.normalWorld.x),b(z.normalWorld.y),b(z.normalWorld.z));y.wireframe?P.setAttribute("style",
-"fill: none; stroke: "+A.getContextStyle()+"; stroke-width: "+y.wireframeLinewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframeLinecap+"; stroke-linejoin: "+y.wireframeLinejoin):P.setAttribute("style","fill: "+A.getContextStyle()+"; fill-opacity: "+y.opacity);i.appendChild(P)}}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,g,e;this.domElement=document.createElement("div");this.setSize=function(a,c){b=a;d=c;g=b/2;e=d/2};this.render=function(b,d){var i,l,k,o,p,n,s,m;a=c.projectScene(b,d);i=0;for(l=a.length;i<l;i++)if(p=a[i],p instanceof THREE.RenderableParticle){s=p.x*g+g;m=p.y*e+e;k=0;for(o=p.material.length;k<o;k++)if(n=p.material[k],n instanceof THREE.ParticleDOMMaterial)n=n.domElement,n.style.left=s+"px",n.style.top=m+"px"}}};
+THREE.CanvasRenderer=function(a){function c(a){if(u!=a)m.globalAlpha=u=a}function b(a){if(r!=a){switch(a){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}r=a}}function d(a){if(z!=a)m.strokeStyle=z=a}function g(a){if(w!=a)m.fillStyle=w=a}var e=this,f,h,i,l=new THREE.Projector,a=a||{},k=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
+o,p,n,s,m=k.getContext("2d"),q=new THREE.Color(0),t=0,u=1,r=0,z=null,w=null,C=null,x=null,O=null,G,K,D,P,I=new THREE.RenderableVertex,W=new THREE.RenderableVertex,Z,R,S,ia,H,F,y,L,j,X,fa,M,Q=new THREE.Color,Y=new THREE.Color,ca=new THREE.Color,T=new THREE.Color,B=new THREE.Color,ja=[],$=[],la,ra,ma,na,ta,pa,sa,xa,U,v,ba=new THREE.Rectangle,aa=new THREE.Rectangle,J=new THREE.Rectangle,ea=!1,ha=new THREE.Color,V=new THREE.Color,va=new THREE.Color,ka=new THREE.Vector3,ga,N,ua,qa,da,Ea,a=16;ga=document.createElement("canvas");
+ga.width=ga.height=2;N=ga.getContext("2d");N.fillStyle="rgba(0,0,0,1)";N.fillRect(0,0,2,2);ua=N.getImageData(0,0,2,2);qa=ua.data;da=document.createElement("canvas");da.width=da.height=a;Ea=da.getContext("2d");Ea.translate(-a/2,-a/2);Ea.scale(a,a);a--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){o=a;p=b;n=Math.floor(o/2);s=Math.floor(p/2);k.width=o;k.height=p;ba.set(-n,-s,n,s);aa.set(-n,-s,n,s);u=1;r=0;O=x=
+C=w=z=null};this.setClearColor=function(a,b){q.copy(a);t=b;aa.set(-n,-s,n,s)};this.setClearColorHex=function(a,b){q.setHex(a);t=b;aa.set(-n,-s,n,s)};this.clear=function(){m.setTransform(1,0,0,-1,n,s);aa.isEmpty()||(aa.minSelf(ba),aa.inflate(2),t<1&&m.clearRect(Math.floor(aa.getX()),Math.floor(aa.getY()),Math.floor(aa.getWidth()),Math.floor(aa.getHeight())),t>0&&(b(THREE.NormalBlending),c(1),g("rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+t+")"),m.fillRect(Math.floor(aa.getX()),
+Math.floor(aa.getY()),Math.floor(aa.getWidth()),Math.floor(aa.getHeight()))),aa.empty())};this.render=function(a,k){function p(a){var b,c,d,e;ha.setRGB(0,0,0);V.setRGB(0,0,0);va.setRGB(0,0,0);b=0;for(c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(ha.r+=e.r,ha.g+=e.g,ha.b+=e.b):d instanceof THREE.DirectionalLight?(V.r+=e.r,V.g+=e.g,V.b+=e.b):d instanceof THREE.PointLight&&(va.r+=e.r,va.g+=e.g,va.b+=e.b)}function o(a,b,c,d){var e,g,f,j,h,i;e=0;for(g=a.length;e<g;e++)f=a[e],j=f.color,
+f instanceof THREE.DirectionalLight?(h=f.matrixWorld.getPosition(),i=c.dot(h),i<=0||(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(ka.sub(h,b).normalize()),i<=0||(i*=f.distance==0?1:1-Math.min(b.distanceTo(h)/f.distance,1),i!=0&&(i*=f.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function q(a,e,f){c(f.opacity);b(f.blending);var j,h,i,k,l,da;if(f instanceof THREE.ParticleBasicMaterial){if(f.map)k=f.map.image,l=k.width>>1,da=
+k.height>>1,f=e.scale.x*n,i=e.scale.y*s,j=f*l,h=i*da,J.set(a.x-j,a.y-h,a.x+j,a.y+h),ba.intersects(J)&&(m.save(),m.translate(a.x,a.y),m.rotate(-e.rotation),m.scale(f,-i),m.translate(-l,-da),m.drawImage(k,0,0),m.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(j=e.scale.x*n,h=e.scale.y*s,J.set(a.x-j,a.y-h,a.x+j,a.y+h),ba.intersects(J)&&(d(f.color.getContextStyle()),g(f.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-e.rotation),m.scale(j,h),f.program(m),m.restore()))}function r(a,
+e,g,f){c(f.opacity);b(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(C!=a)m.lineWidth=C=a;a=f.linecap;if(x!=a)m.lineCap=x=a;a=f.linejoin;if(O!=a)m.lineJoin=O=a;d(f.color.getContextStyle());m.stroke();J.inflate(f.linewidth*2)}}function t(a,d,f,g,j,h,n,l){e.info.render.vertices+=3;e.info.render.faces++;c(l.opacity);b(l.blending);Z=a.positionScreen.x;R=a.positionScreen.y;
+S=d.positionScreen.x;ia=d.positionScreen.y;H=f.positionScreen.x;F=f.positionScreen.y;Da(Z,R,S,ia,H,F);if(l instanceof THREE.MeshBasicMaterial)if(l.map)l.map.mapping instanceof THREE.UVMapping&&(na=n.uvs[0],w(Z,R,S,ia,H,F,na[g].u,na[g].v,na[j].u,na[j].v,na[h].u,na[h].v,l.map));else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,ka.copy(n.vertexNormalsWorld[g]),ta=(ka.x*a.n11+ka.y*a.n12+ka.z*a.n13)*0.5+0.5,pa=-(ka.x*a.n21+ka.y*a.n22+ka.z*a.n23)*0.5+
+0.5,ka.copy(n.vertexNormalsWorld[j]),sa=(ka.x*a.n11+ka.y*a.n12+ka.z*a.n13)*0.5+0.5,xa=-(ka.x*a.n21+ka.y*a.n22+ka.z*a.n23)*0.5+0.5,ka.copy(n.vertexNormalsWorld[h]),U=(ka.x*a.n11+ka.y*a.n12+ka.z*a.n13)*0.5+0.5,v=-(ka.x*a.n21+ka.y*a.n22+ka.z*a.n23)*0.5+0.5,w(Z,R,S,ia,H,F,ta,pa,sa,xa,U,v,l.envMap)}else l.wireframe?z(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color);else if(l instanceof THREE.MeshLambertMaterial)l.map&&!l.wireframe&&(l.map.mapping instanceof THREE.UVMapping&&
+(na=n.uvs[0],w(Z,R,S,ia,H,F,na[g].u,na[g].v,na[j].u,na[j].v,na[h].u,na[h].v,l.map)),b(THREE.SubtractiveBlending)),ea?!l.wireframe&&l.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==3?(Y.r=ca.r=T.r=ha.r,Y.g=ca.g=T.g=ha.g,Y.b=ca.b=T.b=ha.b,o(i,n.v1.positionWorld,n.vertexNormalsWorld[0],Y),o(i,n.v2.positionWorld,n.vertexNormalsWorld[1],ca),o(i,n.v3.positionWorld,n.vertexNormalsWorld[2],T),Y.r=Math.max(0,Math.min(l.color.r*Y.r,1)),Y.g=Math.max(0,Math.min(l.color.g*Y.g,1)),Y.b=Math.max(0,Math.min(l.color.b*
+Y.b,1)),ca.r=Math.max(0,Math.min(l.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(l.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(l.color.b*ca.b,1)),T.r=Math.max(0,Math.min(l.color.r*T.r,1)),T.g=Math.max(0,Math.min(l.color.g*T.g,1)),T.b=Math.max(0,Math.min(l.color.b*T.b,1)),B.r=(ca.r+T.r)*0.5,B.g=(ca.g+T.g)*0.5,B.b=(ca.b+T.b)*0.5,ma=Fa(Y,ca,T,B),Ba(Z,R,S,ia,H,F,0,0,1,0,0,1,ma)):(Q.r=ha.r,Q.g=ha.g,Q.b=ha.b,o(i,n.centroidWorld,n.normalWorld,Q),Q.r=Math.max(0,Math.min(l.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(l.color.g*
+Q.g,1)),Q.b=Math.max(0,Math.min(l.color.b*Q.b,1)),l.wireframe?z(Q,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(Q)):l.wireframe?z(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color);else if(l instanceof THREE.MeshDepthMaterial)la=k.near,ra=k.far,Y.r=Y.g=Y.b=1-Aa(a.positionScreen.z,la,ra),ca.r=ca.g=ca.b=1-Aa(d.positionScreen.z,la,ra),T.r=T.g=T.b=1-Aa(f.positionScreen.z,la,ra),B.r=(ca.r+T.r)*0.5,B.g=(ca.g+T.g)*0.5,B.b=(ca.b+T.b)*0.5,ma=Fa(Y,ca,T,B),Ba(Z,
+R,S,ia,H,F,0,0,1,0,0,1,ma);else if(l instanceof THREE.MeshNormalMaterial)Q.r=Ca(n.normalWorld.x),Q.g=Ca(n.normalWorld.y),Q.b=Ca(n.normalWorld.z),l.wireframe?z(Q,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(Q)}function u(a,d,f,g,h,l,n,m,da){e.info.render.vertices+=4;e.info.render.faces++;c(m.opacity);b(m.blending);if(m.map||m.envMap)t(a,d,g,0,1,3,n,m,da),t(h,f,l,1,2,3,n,m,da);else if(Z=a.positionScreen.x,R=a.positionScreen.y,S=d.positionScreen.x,ia=d.positionScreen.y,H=f.positionScreen.x,
+F=f.positionScreen.y,y=g.positionScreen.x,L=g.positionScreen.y,j=h.positionScreen.x,X=h.positionScreen.y,fa=l.positionScreen.x,M=l.positionScreen.y,m instanceof THREE.MeshBasicMaterial)Ga(Z,R,S,ia,H,F,y,L),m.wireframe?z(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):ya(m.color);else if(m instanceof THREE.MeshLambertMaterial)ea?!m.wireframe&&m.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==4?(Y.r=ca.r=T.r=B.r=ha.r,Y.g=ca.g=T.g=B.g=ha.g,Y.b=ca.b=T.b=B.b=ha.b,o(i,n.v1.positionWorld,
+n.vertexNormalsWorld[0],Y),o(i,n.v2.positionWorld,n.vertexNormalsWorld[1],ca),o(i,n.v4.positionWorld,n.vertexNormalsWorld[3],T),o(i,n.v3.positionWorld,n.vertexNormalsWorld[2],B),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)),T.r=Math.max(0,Math.min(m.color.r*T.r,1)),T.g=Math.max(0,Math.min(m.color.g*
+T.g,1)),T.b=Math.max(0,Math.min(m.color.b*T.b,1)),B.r=Math.max(0,Math.min(m.color.r*B.r,1)),B.g=Math.max(0,Math.min(m.color.g*B.g,1)),B.b=Math.max(0,Math.min(m.color.b*B.b,1)),ma=Fa(Y,ca,T,B),Da(Z,R,S,ia,y,L),Ba(Z,R,S,ia,y,L,0,0,1,0,0,1,ma),Da(j,X,H,F,fa,M),Ba(j,X,H,F,fa,M,1,0,1,1,0,1,ma)):(Q.r=ha.r,Q.g=ha.g,Q.b=ha.b,o(i,n.centroidWorld,n.normalWorld,Q),Q.r=Math.max(0,Math.min(m.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(m.color.g*Q.g,1)),Q.b=Math.max(0,Math.min(m.color.b*Q.b,1)),Ga(Z,R,S,ia,H,F,y,L),
+m.wireframe?z(Q,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):ya(Q)):(Ga(Z,R,S,ia,H,F,y,L),m.wireframe?z(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):ya(m.color));else if(m instanceof THREE.MeshNormalMaterial)Q.r=Ca(n.normalWorld.x),Q.g=Ca(n.normalWorld.y),Q.b=Ca(n.normalWorld.z),Ga(Z,R,S,ia,H,F,y,L),m.wireframe?z(Q,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):ya(Q);else if(m instanceof THREE.MeshDepthMaterial)la=k.near,ra=k.far,Y.r=Y.g=Y.b=1-
+Aa(a.positionScreen.z,la,ra),ca.r=ca.g=ca.b=1-Aa(d.positionScreen.z,la,ra),T.r=T.g=T.b=1-Aa(g.positionScreen.z,la,ra),B.r=B.g=B.b=1-Aa(f.positionScreen.z,la,ra),ma=Fa(Y,ca,T,B),Da(Z,R,S,ia,y,L),Ba(Z,R,S,ia,y,L,0,0,1,0,0,1,ma),Da(j,X,H,F,fa,M),Ba(j,X,H,F,fa,M,1,0,1,1,0,1,ma)}function Da(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 Ga(a,b,c,d,e,f,g,j){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(g,j);m.lineTo(a,b);m.closePath()}
+function z(a,b,c,e){if(C!=b)m.lineWidth=C=b;if(x!=c)m.lineCap=x=c;if(O!=e)m.lineJoin=O=e;d(a.getContextStyle());m.stroke();J.inflate(b*2)}function ya(a){g(a.getContextStyle());m.fill()}function w(a,b,c,d,e,f,j,h,i,k,n,l,da){if(da.image.width!=0){if(da.needsUpdate==!0||ja[da.id]==void 0){var o=da.wrapS==THREE.RepeatWrapping,p=da.wrapT==THREE.RepeatWrapping;ja[da.id]=m.createPattern(da.image,o&&p?"repeat":o&&!p?"repeat-x":!o&&p?"repeat-y":"no-repeat");da.needsUpdate=!1}g(ja[da.id]);var o=da.offset.x/
+da.repeat.x,p=da.offset.y/da.repeat.y,U=da.image.width*da.repeat.x,s=da.image.height*da.repeat.y,j=(j+o)*U,h=(h+p)*s,i=(i+o)*U,k=(k+p)*s,n=(n+o)*U,l=(l+p)*s;c-=a;d-=b;e-=a;f-=b;i-=j;k-=h;n-=j;l-=h;o=i*l-n*k;if(o==0){if($[da.id]==void 0)b=document.createElement("canvas"),b.width=da.image.width,b.height=da.image.height,a=b.getContext("2d"),a.drawImage(da.image,0,0),$[da.id]=a.getImageData(0,0,da.image.width,da.image.height).data,delete b;b=$[da.id];j=(Math.floor(j)+Math.floor(h)*da.image.width)*4;Q.setRGB(b[j]/
+255,b[j+1]/255,b[j+2]/255);ya(Q)}else o=1/o,da=(l*c-k*e)*o,k=(l*d-k*f)*o,c=(i*e-n*c)*o,d=(i*f-n*d)*o,a=a-da*j-c*h,j=b-k*j-d*h,m.save(),m.transform(da,k,c,d,a,j),m.fill(),m.restore()}}function Ba(a,b,c,d,e,f,g,j,h,i,k,n,l){var da,o;da=l.width-1;o=l.height-1;g*=da;j*=o;h*=da;i*=o;k*=da;n*=o;c-=a;d-=b;e-=a;f-=b;h-=g;i-=j;k-=g;n-=j;o=1/(h*n-k*i);da=(n*c-i*e)*o;i=(n*d-i*f)*o;c=(h*e-k*c)*o;d=(h*f-k*d)*o;a=a-da*g-c*j;b=b-i*g-d*j;m.save();m.transform(da,i,c,d,a,b);m.clip();m.drawImage(l,0,0);m.restore()}
+function Fa(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),j=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),i=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),n=~~(d.g*255),d=~~(d.b*255);qa[0]=e<0?0:e>255?255:e;qa[1]=f<0?0:f>255?255:f;qa[2]=a<0?0:a>255?255:a;qa[4]=g<0?0:g>255?255:g;qa[5]=j<0?0:j>255?255:j;qa[6]=b<0?0:b>255?255:b;qa[8]=h<0?0:h>255?255:h;qa[9]=i<0?0:i>255?255:i;qa[10]=c<0?0:c>255?255:c;qa[12]=k<0?0:k>255?255:k;qa[13]=n<0?0:n>255?255:n;qa[14]=d<0?0:d>255?255:d;N.putImageData(ua,
+0,0);Ea.drawImage(ga,0,0);return da}function Aa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ca(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function za(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Ha,Ia,oa,wa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,n,s);e.info.render.vertices=0;e.info.render.faces=0;f=l.projectScene(a,k,this.sortElements);h=f.elements;i=f.lights;(ea=i.length>0)&&p(i);Ha=0;for(Ia=h.length;Ha<Ia;Ha++)if(oa=h[Ha],wa=
+oa.material,wa=wa instanceof THREE.MeshFaceMaterial?oa.faceMaterial:wa,!(wa==null||wa.opacity==0)){J.empty();if(oa instanceof THREE.RenderableParticle)G=oa,G.x*=n,G.y*=s,q(G,oa,wa,a);else if(oa instanceof THREE.RenderableLine)G=oa.v1,K=oa.v2,G.positionScreen.x*=n,G.positionScreen.y*=s,K.positionScreen.x*=n,K.positionScreen.y*=s,J.addPoint(G.positionScreen.x,G.positionScreen.y),J.addPoint(K.positionScreen.x,K.positionScreen.y),ba.intersects(J)&&r(G,K,oa,wa,a);else if(oa instanceof THREE.RenderableFace3)G=
+oa.v1,K=oa.v2,D=oa.v3,G.positionScreen.x*=n,G.positionScreen.y*=s,K.positionScreen.x*=n,K.positionScreen.y*=s,D.positionScreen.x*=n,D.positionScreen.y*=s,wa.overdraw&&(za(G.positionScreen,K.positionScreen),za(K.positionScreen,D.positionScreen),za(D.positionScreen,G.positionScreen)),J.add3Points(G.positionScreen.x,G.positionScreen.y,K.positionScreen.x,K.positionScreen.y,D.positionScreen.x,D.positionScreen.y),ba.intersects(J)&&t(G,K,D,0,1,2,oa,wa,a);else if(oa instanceof THREE.RenderableFace4)G=oa.v1,
+K=oa.v2,D=oa.v3,P=oa.v4,G.positionScreen.x*=n,G.positionScreen.y*=s,K.positionScreen.x*=n,K.positionScreen.y*=s,D.positionScreen.x*=n,D.positionScreen.y*=s,P.positionScreen.x*=n,P.positionScreen.y*=s,I.positionScreen.copy(K.positionScreen),W.positionScreen.copy(P.positionScreen),wa.overdraw&&(za(G.positionScreen,K.positionScreen),za(K.positionScreen,P.positionScreen),za(P.positionScreen,G.positionScreen),za(D.positionScreen,I.positionScreen),za(D.positionScreen,W.positionScreen)),J.addPoint(G.positionScreen.x,
+G.positionScreen.y),J.addPoint(K.positionScreen.x,K.positionScreen.y),J.addPoint(D.positionScreen.x,D.positionScreen.y),J.addPoint(P.positionScreen.x,P.positionScreen.y),ba.intersects(J)&&u(G,K,D,P,I,W,oa,wa,a);aa.addRectangle(J)}m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,j,h,i;e=0;for(f=a.length;e<f;e++)g=a[e],j=g.color,g instanceof THREE.DirectionalLight?(h=g.matrixWorld.getPosition(),i=c.dot(h),i<=0||(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),i=c.dot(G.sub(h,b).normalize()),i<=0||(i*=g.distance==0?1:1-Math.min(b.distanceTo(h)/g.distance,1),i!=0&&(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function c(a){K[a]==null&&(K[a]=document.createElementNS("http://www.w3.org/2000/svg",
+"path"),Z==0&&K[a].setAttribute("shape-rendering","crispEdges"));return K[a]}function b(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var d=this,g,e,f,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,k,o,p,n,s,m,q,t=new THREE.Rectangle,u=new THREE.Rectangle,r=!1,z=new THREE.Color,w=new THREE.Color,C=new THREE.Color,x=new THREE.Color,O,G=new THREE.Vector3,K=[],D=[],P,I,W,Z=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":Z=1;break;case "low":Z=0}};this.setSize=function(a,b){l=a;k=b;o=l/2;p=k/2;i.setAttribute("viewBox",-o+" "+-p+" "+l+" "+k);i.setAttribute("width",l);i.setAttribute("height",k);t.set(-o,-p,o,p)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,l){var G,H,F,y;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;g=h.projectScene(k,l,this.sortElements);e=g.elements;
+f=g.lights;W=I=0;if(r=f.length>0){w.setRGB(0,0,0);C.setRGB(0,0,0);x.setRGB(0,0,0);G=0;for(H=f.length;G<H;G++)y=f[G],F=y.color,y instanceof THREE.AmbientLight?(w.r+=F.r,w.g+=F.g,w.b+=F.b):y instanceof THREE.DirectionalLight?(C.r+=F.r,C.g+=F.g,C.b+=F.b):y instanceof THREE.PointLight&&(x.r+=F.r,x.g+=F.g,x.b+=F.b)}G=0;for(H=e.length;G<H;G++)if(F=e[G],y=F.material,y=y instanceof THREE.MeshFaceMaterial?F.faceMaterial:y,!(y==null||y.opacity==0))if(u.empty(),F instanceof THREE.RenderableParticle)n=F,n.x*=
+o,n.y*=-p;else if(F instanceof THREE.RenderableLine){if(n=F.v1,s=F.v2,n.positionScreen.x*=o,n.positionScreen.y*=-p,s.positionScreen.x*=o,s.positionScreen.y*=-p,u.addPoint(n.positionScreen.x,n.positionScreen.y),u.addPoint(s.positionScreen.x,s.positionScreen.y),t.intersects(u)){F=n;var L=s,j=W++;D[j]==null&&(D[j]=document.createElementNS("http://www.w3.org/2000/svg","line"),Z==0&&D[j].setAttribute("shape-rendering","crispEdges"));P=D[j];P.setAttribute("x1",F.positionScreen.x);P.setAttribute("y1",F.positionScreen.y);
+P.setAttribute("x2",L.positionScreen.x);P.setAttribute("y2",L.positionScreen.y);y instanceof THREE.LineBasicMaterial&&(P.setAttribute("style","fill: none; stroke: "+y.color.getContextStyle()+"; stroke-width: "+y.linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.linecap+"; stroke-linejoin: "+y.linejoin),i.appendChild(P))}}else if(F instanceof THREE.RenderableFace3){if(n=F.v1,s=F.v2,m=F.v3,n.positionScreen.x*=o,n.positionScreen.y*=-p,s.positionScreen.x*=o,s.positionScreen.y*=-p,m.positionScreen.x*=
+o,m.positionScreen.y*=-p,u.addPoint(n.positionScreen.x,n.positionScreen.y),u.addPoint(s.positionScreen.x,s.positionScreen.y),u.addPoint(m.positionScreen.x,m.positionScreen.y),t.intersects(u)){var L=n,j=s,K=m;d.info.render.vertices+=3;d.info.render.faces++;P=c(I++);P.setAttribute("d","M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+j.positionScreen.x+" "+j.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");y instanceof THREE.MeshBasicMaterial?z.copy(y.color):y instanceof THREE.MeshLambertMaterial?
+r?(z.r=w.r,z.g=w.g,z.b=w.b,a(f,F.centroidWorld,F.normalWorld,z),z.r=Math.max(0,Math.min(y.color.r*z.r,1)),z.g=Math.max(0,Math.min(y.color.g*z.g,1)),z.b=Math.max(0,Math.min(y.color.b*z.b,1))):z.copy(y.color):y instanceof THREE.MeshDepthMaterial?(O=1-y.__2near/(y.__farPlusNear-F.z*y.__farMinusNear),z.setRGB(O,O,O)):y instanceof THREE.MeshNormalMaterial&&z.setRGB(b(F.normalWorld.x),b(F.normalWorld.y),b(F.normalWorld.z));y.wireframe?P.setAttribute("style","fill: none; stroke: "+z.getContextStyle()+"; stroke-width: "+
+y.wireframeLinewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframeLinecap+"; stroke-linejoin: "+y.wireframeLinejoin):P.setAttribute("style","fill: "+z.getContextStyle()+"; fill-opacity: "+y.opacity);i.appendChild(P)}}else if(F instanceof THREE.RenderableFace4&&(n=F.v1,s=F.v2,m=F.v3,q=F.v4,n.positionScreen.x*=o,n.positionScreen.y*=-p,s.positionScreen.x*=o,s.positionScreen.y*=-p,m.positionScreen.x*=o,m.positionScreen.y*=-p,q.positionScreen.x*=o,q.positionScreen.y*=-p,u.addPoint(n.positionScreen.x,
+n.positionScreen.y),u.addPoint(s.positionScreen.x,s.positionScreen.y),u.addPoint(m.positionScreen.x,m.positionScreen.y),u.addPoint(q.positionScreen.x,q.positionScreen.y),t.intersects(u))){var L=n,j=s,K=m,fa=q;d.info.render.vertices+=4;d.info.render.faces++;P=c(I++);P.setAttribute("d","M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+j.positionScreen.x+" "+j.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+" L "+fa.positionScreen.x+","+fa.positionScreen.y+"z");y instanceof THREE.MeshBasicMaterial?
+z.copy(y.color):y instanceof THREE.MeshLambertMaterial?r?(z.r=w.r,z.g=w.g,z.b=w.b,a(f,F.centroidWorld,F.normalWorld,z),z.r=Math.max(0,Math.min(y.color.r*z.r,1)),z.g=Math.max(0,Math.min(y.color.g*z.g,1)),z.b=Math.max(0,Math.min(y.color.b*z.b,1))):z.copy(y.color):y instanceof THREE.MeshDepthMaterial?(O=1-y.__2near/(y.__farPlusNear-F.z*y.__farMinusNear),z.setRGB(O,O,O)):y instanceof THREE.MeshNormalMaterial&&z.setRGB(b(F.normalWorld.x),b(F.normalWorld.y),b(F.normalWorld.z));y.wireframe?P.setAttribute("style",
+"fill: none; stroke: "+z.getContextStyle()+"; stroke-width: "+y.wireframeLinewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframeLinecap+"; stroke-linejoin: "+y.wireframeLinejoin):P.setAttribute("style","fill: "+z.getContextStyle()+"; fill-opacity: "+y.opacity);i.appendChild(P)}}};
 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",
@@ -222,123 +223,123 @@ THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_
 THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,
 THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask  = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}};
 THREE.WebGLRenderer=function(a){function c(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(a.__webglCustomAttributesList===void 0)a.__webglCustomAttributesList=[];for(var e in d.attributes){var f=d.attributes[e];if(!f.__webglInitialized||f.createUniqueBuffers){f.__webglInitialized=!0;var g=1;f.type==="v2"?g=2:f.type==="v3"?g=3:f.type==="v4"?g=4:f.type==="c"&&(g=3);f.size=g;f.array=new Float32Array(c*g);f.buffer=j.createBuffer();f.buffer.belongsToAttribute=e;f.needsUpdate=!0}a.__webglCustomAttributesList.push(f)}}}
-function b(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;else if(b.materialIndex>=0)return a.geometry.materials[b.materialIndex]}function d(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;var i=a.colors,k=i.length,n=a.__vertexArray,l=a.__colorArray,m=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,U=a.__webglCustomAttributesList;if(c.sortParticles){H.multiplySelf(c.matrixWorld);for(d=0;d<g;d++)e=h[d].position,da.copy(e),H.multiplyVector3(da),m[d]=[da.z,d];m.sort(function(a,
-b){return b[0]-a[0]});for(d=0;d<g;d++)e=h[m[d][1]].position,f=d*3,n[f]=e.x,n[f+1]=e.y,n[f+2]=e.z;for(d=0;d<k;d++)f=d*3,e=i[m[d][1]],l[f]=e.r,l[f+1]=e.g,l[f+2]=e.b;if(U){i=0;for(k=U.length;i<k;i++)if(h=U[i],h.boundTo===void 0||h.boundTo==="vertices")if(f=0,e=h.value.length,h.size===1)for(d=0;d<e;d++)g=m[d][1],h.array[d]=h.value[g];else if(h.size===2)for(d=0;d<e;d++)g=m[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++)g=m[d][1],g=h.value[g],
-h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=m[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(h.size===4)for(d=0;d<e;d++)g=m[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}}else{if(o)for(d=0;d<g;d++)e=h[d].position,f=d*3,n[f]=e.x,n[f+1]=e.y,n[f+2]=e.z;if(p)for(d=0;d<k;d++)e=i[d],f=d*3,l[f]=e.r,l[f+1]=e.g,l[f+2]=e.b;if(U){i=0;for(k=U.length;i<k;i++)if(h=U[i],h.needsUpdate&&(h.boundTo===void 0||
-h.boundTo==="vertices"))if(e=h.value.length,f=0,h.size===1)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(h.size===2)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(h.size===4)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,
-f+=4}}if(o||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,n,b);if(p||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,l,b);if(U){i=0;for(k=U.length;i<k;i++)if(h=U[i],h.needsUpdate||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,h.buffer),j.bufferData(j.ARRAY_BUFFER,h.array,b)}}function g(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=j.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=j.createBuffer();
-a.hasPos&&(j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,a.positionArray,j.DYNAMIC_DRAW),j.enableVertexAttribArray(b.attributes.position),j.vertexAttribPointer(b.attributes.position,3,j.FLOAT,!1,0,0));if(a.hasNormal){j.bindBuffer(j.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,f,g,h,i,k,n,l,m,o=a.count*3;for(m=0;m<o;m+=9)c=a.normalArray,d=c[m],e=c[m+1],f=c[m+2],g=c[m+3],i=c[m+4],n=c[m+5],h=c[m+6],k=c[m+7],l=c[m+8],d=(d+g+h)/3,e=(e+i+k)/3,f=
-(f+n+l)/3,c[m]=d,c[m+1]=e,c[m+2]=f,c[m+3]=d,c[m+4]=e,c[m+5]=f,c[m+6]=d,c[m+7]=e,c[m+8]=f}j.bufferData(j.ARRAY_BUFFER,a.normalArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.normal);j.vertexAttribPointer(b.attributes.normal,3,j.FLOAT,!1,0,0)}j.drawArrays(j.TRIANGLES,0,a.count);a.count=0}function e(a,b,c,d,e,f){if(d.opacity!==0){var g,h,c=s(a,b,c,d,f),b=c.attributes,a=!1,c=e.id*16777215+c.id*2+(d.wireframe?1:0);c!==T&&(T=c,a=!0);if(!d.morphTargets&&b.position>=0)a&&(j.bindBuffer(j.ARRAY_BUFFER,
+function b(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;else if(b.materialIndex>=0)return a.geometry.materials[b.materialIndex]}function d(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;var i=a.colors,k=i.length,n=a.__vertexArray,l=a.__colorArray,m=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,U=a.__webglCustomAttributesList;if(c.sortParticles){ba.multiplySelf(c.matrixWorld);for(d=0;d<g;d++)e=h[d].position,ea.copy(e),ba.multiplyVector3(ea),m[d]=[ea.z,d];
+m.sort(function(a,b){return b[0]-a[0]});for(d=0;d<g;d++)e=h[m[d][1]].position,f=d*3,n[f]=e.x,n[f+1]=e.y,n[f+2]=e.z;for(d=0;d<k;d++)f=d*3,e=i[m[d][1]],l[f]=e.r,l[f+1]=e.g,l[f+2]=e.b;if(U){i=0;for(k=U.length;i<k;i++)if(h=U[i],h.boundTo===void 0||h.boundTo==="vertices")if(f=0,e=h.value.length,h.size===1)for(d=0;d<e;d++)g=m[d][1],h.array[d]=h.value[g];else if(h.size===2)for(d=0;d<e;d++)g=m[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++)g=m[d][1],
+g=h.value[g],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=m[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(h.size===4)for(d=0;d<e;d++)g=m[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}}else{if(o)for(d=0;d<g;d++)e=h[d].position,f=d*3,n[f]=e.x,n[f+1]=e.y,n[f+2]=e.z;if(p)for(d=0;d<k;d++)e=i[d],f=d*3,l[f]=e.r,l[f+1]=e.g,l[f+2]=e.b;if(U){i=0;for(k=U.length;i<k;i++)if(h=U[i],h.needsUpdate&&(h.boundTo===
+void 0||h.boundTo==="vertices"))if(e=h.value.length,f=0,h.size===1)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(h.size===2)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(h.size===4)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+
+3]=g.w,f+=4}}if(o||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,n,b);if(p||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,l,b);if(U){i=0;for(k=U.length;i<k;i++)if(h=U[i],h.needsUpdate||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,h.buffer),j.bufferData(j.ARRAY_BUFFER,h.array,b)}}function g(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=j.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=
+j.createBuffer();a.hasPos&&(j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,a.positionArray,j.DYNAMIC_DRAW),j.enableVertexAttribArray(b.attributes.position),j.vertexAttribPointer(b.attributes.position,3,j.FLOAT,!1,0,0));if(a.hasNormal){j.bindBuffer(j.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,f,g,h,i,k,n,l,m,o=a.count*3;for(m=0;m<o;m+=9)c=a.normalArray,d=c[m],e=c[m+1],f=c[m+2],g=c[m+3],i=c[m+4],n=c[m+5],h=c[m+6],k=c[m+7],l=c[m+8],d=(d+g+h)/
+3,e=(e+i+k)/3,f=(f+n+l)/3,c[m]=d,c[m+1]=e,c[m+2]=f,c[m+3]=d,c[m+4]=e,c[m+5]=f,c[m+6]=d,c[m+7]=e,c[m+8]=f}j.bufferData(j.ARRAY_BUFFER,a.normalArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.normal);j.vertexAttribPointer(b.attributes.normal,3,j.FLOAT,!1,0,0)}j.drawArrays(j.TRIANGLES,0,a.count);a.count=0}function e(a,b,c,d,e,f){if(d.opacity!==0){var g,h,c=q(a,b,c,d,f),b=c.attributes,a=!1,c=e.id*16777215+c.id*2+(d.wireframe?1:0);c!==Y&&(Y=c,a=!0);if(!d.morphTargets&&b.position>=0)a&&(j.bindBuffer(j.ARRAY_BUFFER,
 e.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;f.morphTargetBase!==-1?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):c.position>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){g=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;g<d.numSupportedMorphTargets&&
 g<i.length;)j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[g]]),j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,!1,0,0),f.__webglMorphTargetInfluences[g]=h[i[g]],g++}else{var i=[],k=-1,n=0;h=f.morphTargetInfluences;var l,m=h.length;g=0;for(f.morphTargetBase!==-1&&(i[f.morphTargetBase]=!0);g<d.numSupportedMorphTargets;){for(l=0;l<m;l++)!i[l]&&h[l]>k&&(n=l,k=h[n]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[n]);j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[g]=
 k;i[n]=1;k=-1;g++}}d.program.uniforms.morphTargetInfluences!==null&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){g=0;for(h=e.__webglCustomAttributesList.length;g<h;g++)c=e.__webglCustomAttributesList[g],b[c.buffer.belongsToAttribute]>=0&&(j.bindBuffer(j.ARRAY_BUFFER,c.buffer),j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,!1,0,0))}b.color>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglColorBuffer),j.vertexAttribPointer(b.color,
 3,j.FLOAT,!1,0,0));b.normal>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglNormalBuffer),j.vertexAttribPointer(b.normal,3,j.FLOAT,!1,0,0));b.tangent>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglTangentBuffer),j.vertexAttribPointer(b.tangent,4,j.FLOAT,!1,0,0));b.uv>=0&&(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));b.uv2>=0&&(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&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexABuffer),j.vertexAttribPointer(b.skinVertexA,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),j.vertexAttribPointer(b.skinIndex,
 4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==ta&&(j.lineWidth(d),ta=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)),L.info.render.calls++,L.info.render.vertices+=
-e.__webglFaceCount,L.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==ta&&(j.lineWidth(d),ta=d),j.drawArrays(f,0,e.__webglLineCount),L.info.render.calls++):f instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),L.info.render.calls++):f instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),L.info.render.calls++)}}function f(a){u[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-
-a.n13,a.n44-a.n14);u[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);u[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);u[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);u[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);u[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(var b,a=0;a<6;a++)b=u[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function h(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,
-a.scale.z)),d=0;d<6;d++)if(a=u[d].x*b.n14+u[d].y*b.n24+u[d].z*b.n34+u[d].w,a<=c)return!1;return!0}function i(a,b){return b.z-a.z}function l(a){var b,c,d,i,k,n,l,m,o=0,p=a.lights;ba||(ba=new THREE.PerspectiveCamera(L.shadowCameraFov,L.shadowMapWidth/L.shadowMapHeight,L.shadowCameraNear,L.shadowCameraFar));b=0;for(c=p.length;b<c;b++)if(m=p[b],m.castShadow&&m instanceof THREE.SpotLight){X=-1;L.shadowMap[o]||(L.shadowMap[o]=new THREE.WebGLRenderTarget(L.shadowMapWidth,L.shadowMapHeight,{minFilter:THREE.LinearFilter,
-magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}),fa[o]=new THREE.Matrix4);d=L.shadowMap[o];i=fa[o];ba.position.copy(m.position);ba.lookAt(m.target.position);ba.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),a.add(ba));this.autoUpdateScene&&a.updateMatrixWorld();ba.matrixWorldInverse.getInverse(ba.matrixWorld);i.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);i.multiplySelf(ba.projectionMatrix);i.multiplySelf(ba.matrixWorldInverse);ba.matrixWorldInverse.flattenToArray(ja);
-ba.projectionMatrix.flattenToArray(aa);H.multiply(ba.projectionMatrix,ba.matrixWorldInverse);f(H);E(d);j.clearColor(1,1,1,1);L.clear();j.clearColor(G.r,G.g,G.b,z);i=a.__webglObjects.length;for(d=0;d<i;d++)if(n=a.__webglObjects[d],m=n.object,n.render=!1,m.visible&&m.castShadow&&(!(m instanceof THREE.Mesh)||!m.frustumCulled||h(m)))m.matrixWorld.flattenToArray(m._objectMatrixArray),t(m,ba,!1),n.render=!0;q(!0);D(THREE.NormalBlending);for(d=0;d<i;d++)if(n=a.__webglObjects[d],n.render)m=n.object,n=n.buffer,
-v(m),l=m.customDepthMaterial?m.customDepthMaterial:m.geometry.morphTargets.length?xa:ia,e(ba,p,null,l,n,m);i=a.__webglObjectsImmediate.length;for(d=0;d<i;d++)n=a.__webglObjectsImmediate[d],m=n.object,m.visible&&m.castShadow&&(m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),T=-1,t(m,ba,!1),v(m),k=s(ba,p,null,ia,m),m.immediateRenderCallback?m.immediateRenderCallback(k,j,u):m.render(function(a){g(a,k,ia.shading)}));o++}}function k(a,b,c,d,f,g,h,j){var i,n,k,m;b?(n=a.length-1,m=
-b=-1):(n=0,b=a.length,m=1);for(var l=n;l!==b;l+=m)if(i=a[l],i.render){n=i.object;k=i.buffer;if(j)i=j;else{i=i[c];if(!i)continue;h&&D(i.blending);q(i.depthTest);A(i.depthWrite);w(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}v(n);e(d,f,g,i,k,n)}}function o(a,b,c,d,e,f,h){for(var i,n,k,m,l=0,o=a.length;l<o;l++)if(i=a[l],n=i.object,n.visible){T=-1;if(h)k=h;else{k=i[b];if(!k)continue;f&&D(k.blending);q(k.depthTest);A(k.depthWrite);w(k.polygonOffset,k.polygonOffsetFactor,k.polygonOffsetUnits)}v(n);
-m=s(c,d,e,k,n);n.immediateRenderCallback?n.immediateRenderCallback(m,j,u):n.render(function(a){g(a,m,k.shading)})}}function p(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 r(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function m(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function s(a,b,c,d,e){d.program||L.initMaterial(d,b,c,e);if(d.morphTargets&&
-!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(L.maxMorphTargets);for(var f=0,g=L.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=!1,f=d.program,g=f.uniforms,i=d.uniforms;f!==ga&&(j.useProgram(f),ga=f,h=!0);if(d.id!==X)X=d.id,h=!0;if(h){j.uniformMatrix4fv(g.projectionMatrix,!1,aa);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){for(var n,k,m=0,l=0,o=0,p,U,r,H=ua,s=H.directional.colors,u=H.directional.positions,q=H.point.colors,t=H.point.positions,v=H.point.distances,A=0,C=0,c=n=r=0,h=b.length;c<h;c++)if(n=b[c],k=n.color,p=n.position,U=n.intensity,r=n.distance,n instanceof THREE.AmbientLight)L.gammaInput?(m+=k.r*k.r,l+=k.g*k.g,o+=k.b*k.b):(m+=k.r,l+=k.g,o+=k.b);else if(n instanceof THREE.DirectionalLight)r=A*3,L.gammaInput?(s[r]=k.r*
-k.r*U*U,s[r+1]=k.g*k.g*U*U,s[r+2]=k.b*k.b*U*U):(s[r]=k.r*U,s[r+1]=k.g*U,s[r+2]=k.b*U),u[r]=p.x,u[r+1]=p.y,u[r+2]=p.z,A+=1;else if(n instanceof THREE.SpotLight)r=A*3,L.gammaInput?(s[r]=k.r*k.r*U*U,s[r+1]=k.g*k.g*U*U,s[r+2]=k.b*k.b*U*U):(s[r]=k.r*U,s[r+1]=k.g*U,s[r+2]=k.b*U),k=1/p.length(),u[r]=p.x*k,u[r+1]=p.y*k,u[r+2]=p.z*k,A+=1;else if(n instanceof THREE.PointLight)n=C*3,L.gammaInput?(q[n]=k.r*k.r*U*U,q[n+1]=k.g*k.g*U*U,q[n+2]=k.b*k.b*U*U):(q[n]=k.r*U,q[n+1]=k.g*U,q[n+2]=k.b*U),t[n]=p.x,t[n+1]=p.y,
-t[n+2]=p.z,v[C]=r,C+=1;c=A*3;for(h=s.length;c<h;c++)s[c]=0;c=C*3;for(h=q.length;c<h;c++)q[c]=0;H.point.length=C;H.directional.length=A;H.ambient[0]=m;H.ambient[1]=l;H.ambient[2]=o;b=ua;i.ambientLightColor.value=b.ambient;i.directionalLightColor.value=b.directional.colors;i.directionalLightDirection.value=b.directional.positions;i.pointLightColor.value=b.point.colors;i.pointLightPosition.value=b.point.positions;i.pointLightDistance.value=b.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof
-THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)i.opacity.value=d.opacity,L.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=V.height/2,i.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)i.shininess.value=d.shininess,L.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),i.specular.value.copyGammaToLinear(d.specular)):
-(i.ambient.value=d.ambient,i.specular.value=d.specular);else if(d instanceof THREE.MeshLambertMaterial)L.gammaInput?i.ambient.value.copyGammaToLinear(d.ambient):i.ambient.value=d.ambient;else if(d instanceof THREE.MeshDepthMaterial)i.mNear.value=a.near,i.mFar.value=a.far,i.opacity.value=d.opacity;else if(d instanceof THREE.MeshNormalMaterial)i.opacity.value=d.opacity;if(e.receiveShadow&&!d._shadowPass&&i.shadowMatrix){for(b=0;b<fa.length;b++)i.shadowMatrix.value[b]=fa[b],i.shadowMap.texture[b]=L.shadowMap[b];
-i.shadowDarkness.value=L.shadowMapDarkness;i.shadowBias.value=L.shadowMapBias}b=d.uniformsList;i=0;for(c=b.length;i<c;i++)if(l=f.uniforms[b[i][1]])if(m=b[i][0],o=m.type,h=m.value,o==="i")j.uniform1i(l,h);else if(o==="f")j.uniform1f(l,h);else if(o==="v2")j.uniform2f(l,h.x,h.y);else if(o==="v3")j.uniform3f(l,h.x,h.y,h.z);else if(o==="v4")j.uniform4f(l,h.x,h.y,h.z,h.w);else if(o==="c")j.uniform3f(l,h.r,h.g,h.b);else if(o==="fv1")j.uniform1fv(l,h);else if(o==="fv")j.uniform3fv(l,h);else if(o==="v3v"){if(!m._array)m._array=
-new Float32Array(3*h.length);o=0;for(p=h.length;o<p;o++)H=o*3,m._array[H]=h[o].x,m._array[H+1]=h[o].y,m._array[H+2]=h[o].z;j.uniform3fv(l,m._array)}else if(o==="m4"){if(!m._array)m._array=new Float32Array(16);h.flattenToArray(m._array);j.uniformMatrix4fv(l,!1,m._array)}else if(o==="m4v"){if(!m._array)m._array=new Float32Array(16*h.length);o=0;for(p=h.length;o<p;o++)h[o].flattenToArrayOffset(m._array,o*16);j.uniformMatrix4fv(l,!1,m._array)}else if(o==="t"){if(j.uniform1i(l,h),l=m.texture)if(l.image instanceof
-Array&&l.image.length===6){if(m=l,m.image.length===6)if(m.needsUpdate){if(!m.image.__webglTextureCube)m.image.__webglTextureCube=j.createTexture();j.activeTexture(j.TEXTURE0+h);j.bindTexture(j.TEXTURE_CUBE_MAP,m.image.__webglTextureCube);for(h=0;h<6;h++)j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,m.image[h]);J(j.TEXTURE_CUBE_MAP,m,m.image[0]);m.needsUpdate=!1}else j.activeTexture(j.TEXTURE0+h),j.bindTexture(j.TEXTURE_CUBE_MAP,m.image.__webglTextureCube)}else l instanceof
-THREE.WebGLRenderTargetCube?(m=l,j.activeTexture(j.TEXTURE0+h),j.bindTexture(j.TEXTURE_CUBE_MAP,m.__webglTexture)):M(l,h)}else if(o==="tv"){if(!m._array){m._array=[];o=0;for(p=m.texture.length;o<p;o++)m._array[o]=h+o}j.uniform1iv(l,m._array);o=0;for(p=m.texture.length;o<p;o++)(l=m.texture[o])&&M(l,m._array[o])}(d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&g.cameraPosition!==null&&j.uniform3f(g.cameraPosition,a.position.x,a.position.y,a.position.z);(d instanceof
-THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&g.viewMatrix!==null&&j.uniformMatrix4fv(g.viewMatrix,!1,ja);d.skinning&&(j.uniformMatrix4fv(g.cameraInverseMatrix,!1,ja),j.uniformMatrix4fv(g.boneGlobalMatrices,!1,e.boneMatrices))}j.uniformMatrix4fv(g.modelViewMatrix,!1,e._modelViewMatrixArray);g.normalMatrix&&j.uniformMatrix3fv(g.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&
-g.objectMatrix!==null&&j.uniformMatrix4fv(g.objectMatrix,!1,e._objectMatrixArray);return f}function t(a,b,c){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(a._modelViewMatrix).transposeIntoArray(a._normalMatrixArray)}function v(a){if(Q!==a.doubleSided)a.doubleSided?j.disable(j.CULL_FACE):j.enable(j.CULL_FACE),Q=a.doubleSided;if(C!==a.flipSided)a.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW),C=a.flipSided}function q(a){S!==
-a&&(a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST),S=a)}function A(a){$!==a&&(j.depthMask(a),$=a)}function w(a,b,c){oa!==a&&(a?j.enable(j.POLYGON_OFFSET_FILL):j.disable(j.POLYGON_OFFSET_FILL),oa=a);if(a&&(la!==b||ra!==c))j.polygonOffset(b,c),la=b,ra=c}function D(a){if(a!==Y){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)}Y=a}}function x(a,b){var c;a==="fragment"?c=j.createShader(j.FRAGMENT_SHADER):a==="vertex"&&(c=j.createShader(j.VERTEX_SHADER));j.shaderSource(c,b);j.compileShader(c);if(!j.getShaderParameter(c,j.COMPILE_STATUS))return console.error(j.getShaderInfoLog(c)),console.error(b),null;return c}function J(a,b,c){(c.width&c.width-1)===
-0&&(c.height&c.height-1)===0?(j.texParameteri(a,j.TEXTURE_WRAP_S,I(b.wrapS)),j.texParameteri(a,j.TEXTURE_WRAP_T,I(b.wrapT)),j.texParameteri(a,j.TEXTURE_MAG_FILTER,I(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,I(b.minFilter)),j.generateMipmap(a)):(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,P(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,P(b.minFilter)))}function M(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=
-!0,a.__webglTexture=j.createTexture(),L.info.memory.textures++;j.activeTexture(j.TEXTURE0+b);j.bindTexture(j.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?j.texImage2D(j.TEXTURE_2D,0,I(a.format),a.image.width,a.image.height,0,I(a.format),j.UNSIGNED_BYTE,a.image.data):j.texImage2D(j.TEXTURE_2D,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,a.image);J(j.TEXTURE_2D,a,a.image);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else j.activeTexture(j.TEXTURE0+b),j.bindTexture(j.TEXTURE_2D,a.__webglTexture)}
-function K(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 E(a){var b=
-a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=j.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];j.bindTexture(j.TEXTURE_CUBE_MAP,a.__webglTexture);J(j.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=j.createFramebuffer();a.__webglRenderbuffer[c]=j.createRenderbuffer();j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,I(a.format),
-a.width,a.height,0,I(a.format),I(a.type),null);var d=a,e=j.TEXTURE_CUBE_MAP_POSITIVE_X+c;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer[c]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,e,d.__webglTexture,0);K(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=j.createFramebuffer(),a.__webglRenderbuffer=j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture),J(j.TEXTURE_2D,a,a),j.texImage2D(j.TEXTURE_2D,0,I(a.format),a.width,a.height,0,I(a.format),I(a.type),null),
-c=j.TEXTURE_2D,j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer),j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,c,a.__webglTexture,0),j.bindRenderbuffer(j.RENDERBUFFER,a.__webglRenderbuffer),K(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,c=a.width,a=a.height,e=d=0):(b=null,c=wa,a=U,d=pa,
-e=qa);b!==N&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(d,e,c,a),N=b)}function P(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return j.NEAREST;default:return j.LINEAR}}function I(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;
+e.__webglFaceCount,L.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==ta&&(j.lineWidth(d),ta=d),j.drawArrays(f,0,e.__webglLineCount),L.info.render.calls++):f instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),L.info.render.calls++):f instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),L.info.render.calls++)}}function f(a){v[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-
+a.n13,a.n44-a.n14);v[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);v[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);v[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);v[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);v[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(var b,a=0;a<6;a++)b=v[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function h(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,
+a.scale.z)),d=0;d<6;d++)if(a=v[d].x*b.n14+v[d].y*b.n24+v[d].z*b.n34+v[d].w,a<=c)return!1;return!0}function i(a,b){return b.z-a.z}function l(a){var b,c,d,i,k,n,l,m,o=0,p=a.lights;V||(V=new THREE.PerspectiveCamera(L.shadowCameraFov,L.shadowMapWidth/L.shadowMapHeight,L.shadowCameraNear,L.shadowCameraFar));b=0;for(c=p.length;b<c;b++)if(m=p[b],m.castShadow&&m instanceof THREE.SpotLight){Q=-1;L.shadowMap[o]||(L.shadowMap[o]=new THREE.WebGLRenderTarget(L.shadowMapWidth,L.shadowMapHeight,{minFilter:THREE.LinearFilter,
+magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}),va[o]=new THREE.Matrix4);d=L.shadowMap[o];i=va[o];V.position.copy(m.position);V.lookAt(m.target.position);V.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),a.add(V));this.autoUpdateScene&&a.updateMatrixWorld();V.matrixWorldInverse.getInverse(V.matrixWorld);i.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);i.multiplySelf(V.projectionMatrix);i.multiplySelf(V.matrixWorldInverse);V.matrixWorldInverse.flattenToArray(J);V.projectionMatrix.flattenToArray(aa);
+ba.multiply(V.projectionMatrix,V.matrixWorldInverse);f(ba);D(d);j.clearColor(1,1,1,1);L.clear();j.clearColor(H.r,H.g,H.b,F);i=a.__webglObjects.length;for(d=0;d<i;d++)if(n=a.__webglObjects[d],m=n.object,n.render=!1,m.visible&&m.castShadow&&(!(m instanceof THREE.Mesh)||!m.frustumCulled||h(m)))m.matrixWorld.flattenToArray(m._objectMatrixArray),t(m,V,!1),n.render=!0;r(!0);C(THREE.NormalBlending);for(d=0;d<i;d++)if(n=a.__webglObjects[d],n.render)m=n.object,n=n.buffer,u(m),l=m.customDepthMaterial?m.customDepthMaterial:
+m.geometry.morphTargets.length?ga:ka,e(V,p,null,l,n,m);i=a.__webglObjectsImmediate.length;for(d=0;d<i;d++)n=a.__webglObjectsImmediate[d],m=n.object,m.visible&&m.castShadow&&(m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),Y=-1,t(m,V,!1),u(m),k=q(V,p,null,ka,m),m.immediateRenderCallback?m.immediateRenderCallback(k,j,v):m.render(function(a){g(a,k,ka.shading)}));o++}}function k(a,b,c,d,f,g,h,j){var i,n,k,m;b?(n=a.length-1,m=b=-1):(n=0,b=a.length,m=1);for(var l=n;l!==b;l+=m)if(i=
+a[l],i.render){n=i.object;k=i.buffer;if(j)i=j;else{i=i[c];if(!i)continue;h&&C(i.blending);r(i.depthTest);z(i.depthWrite);w(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}u(n);e(d,f,g,i,k,n)}}function o(a,b,c,d,e,f,h){for(var i,n,k,m,l=0,o=a.length;l<o;l++)if(i=a[l],n=i.object,n.visible){Y=-1;if(h)k=h;else{k=i[b];if(!k)continue;f&&C(k.blending);r(k.depthTest);z(k.depthWrite);w(k.polygonOffset,k.polygonOffsetFactor,k.polygonOffsetUnits)}u(n);m=q(c,d,e,k,n);n.immediateRenderCallback?n.immediateRenderCallback(m,
+j,v):n.render(function(a){g(a,m,k.shading)})}}function p(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 s(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function m(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function q(a,b,c,d,e){d.program||L.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(L.maxMorphTargets);
+for(var f=0,g=L.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=!1,f=d.program,g=f.uniforms,i=d.uniforms;f!==fa&&(j.useProgram(f),fa=f,h=!0);if(d.id!==Q)Q=d.id,h=!0;if(h){j.uniformMatrix4fv(g.projectionMatrix,!1,aa);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){for(var n,
+k,m=0,l=0,o=0,p,U,s,ba=ha,q=ba.directional.colors,v=ba.directional.positions,r=ba.point.colors,t=ba.point.positions,u=ba.point.distances,z=0,B=0,c=n=s=0,h=b.length;c<h;c++)if(n=b[c],k=n.color,p=n.position,U=n.intensity,s=n.distance,n instanceof THREE.AmbientLight)L.gammaInput?(m+=k.r*k.r,l+=k.g*k.g,o+=k.b*k.b):(m+=k.r,l+=k.g,o+=k.b);else if(n instanceof THREE.DirectionalLight)s=z*3,L.gammaInput?(q[s]=k.r*k.r*U*U,q[s+1]=k.g*k.g*U*U,q[s+2]=k.b*k.b*U*U):(q[s]=k.r*U,q[s+1]=k.g*U,q[s+2]=k.b*U),v[s]=p.x,
+v[s+1]=p.y,v[s+2]=p.z,z+=1;else if(n instanceof THREE.SpotLight)s=z*3,L.gammaInput?(q[s]=k.r*k.r*U*U,q[s+1]=k.g*k.g*U*U,q[s+2]=k.b*k.b*U*U):(q[s]=k.r*U,q[s+1]=k.g*U,q[s+2]=k.b*U),k=1/p.length(),v[s]=p.x*k,v[s+1]=p.y*k,v[s+2]=p.z*k,z+=1;else if(n instanceof THREE.PointLight)n=B*3,L.gammaInput?(r[n]=k.r*k.r*U*U,r[n+1]=k.g*k.g*U*U,r[n+2]=k.b*k.b*U*U):(r[n]=k.r*U,r[n+1]=k.g*U,r[n+2]=k.b*U),t[n]=p.x,t[n+1]=p.y,t[n+2]=p.z,u[B]=s,B+=1;c=z*3;for(h=q.length;c<h;c++)q[c]=0;c=B*3;for(h=r.length;c<h;c++)r[c]=
+0;ba.point.length=B;ba.directional.length=z;ba.ambient[0]=m;ba.ambient[1]=l;ba.ambient[2]=o;b=ha;i.ambientLightColor.value=b.ambient;i.directionalLightColor.value=b.directional.colors;i.directionalLightDirection.value=b.directional.positions;i.pointLightColor.value=b.point.colors;i.pointLightPosition.value=b.point.positions;i.pointLightDistance.value=b.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)i.opacity.value=
+d.opacity,L.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=W.height/2,i.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)i.shininess.value=d.shininess,L.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),i.specular.value.copyGammaToLinear(d.specular)):(i.ambient.value=d.ambient,i.specular.value=d.specular);else if(d instanceof
+THREE.MeshLambertMaterial)L.gammaInput?i.ambient.value.copyGammaToLinear(d.ambient):i.ambient.value=d.ambient;else if(d instanceof THREE.MeshDepthMaterial)i.mNear.value=a.near,i.mFar.value=a.far,i.opacity.value=d.opacity;else if(d instanceof THREE.MeshNormalMaterial)i.opacity.value=d.opacity;if(e.receiveShadow&&!d._shadowPass&&i.shadowMatrix){for(b=0;b<va.length;b++)i.shadowMatrix.value[b]=va[b],i.shadowMap.texture[b]=L.shadowMap[b];i.shadowDarkness.value=L.shadowMapDarkness;i.shadowBias.value=L.shadowMapBias}b=
+d.uniformsList;i=0;for(c=b.length;i<c;i++)if(l=f.uniforms[b[i][1]])if(m=b[i][0],o=m.type,h=m.value,o==="i")j.uniform1i(l,h);else if(o==="f")j.uniform1f(l,h);else if(o==="v2")j.uniform2f(l,h.x,h.y);else if(o==="v3")j.uniform3f(l,h.x,h.y,h.z);else if(o==="v4")j.uniform4f(l,h.x,h.y,h.z,h.w);else if(o==="c")j.uniform3f(l,h.r,h.g,h.b);else if(o==="fv1")j.uniform1fv(l,h);else if(o==="fv")j.uniform3fv(l,h);else if(o==="v3v"){if(!m._array)m._array=new Float32Array(3*h.length);o=0;for(p=h.length;o<p;o++)ba=
+o*3,m._array[ba]=h[o].x,m._array[ba+1]=h[o].y,m._array[ba+2]=h[o].z;j.uniform3fv(l,m._array)}else if(o==="m4"){if(!m._array)m._array=new Float32Array(16);h.flattenToArray(m._array);j.uniformMatrix4fv(l,!1,m._array)}else if(o==="m4v"){if(!m._array)m._array=new Float32Array(16*h.length);o=0;for(p=h.length;o<p;o++)h[o].flattenToArrayOffset(m._array,o*16);j.uniformMatrix4fv(l,!1,m._array)}else if(o==="t"){if(j.uniform1i(l,h),l=m.texture)if(l.image instanceof Array&&l.image.length===6){if(m=l,m.image.length===
+6)if(m.needsUpdate){if(!m.image.__webglTextureCube)m.image.__webglTextureCube=j.createTexture();j.activeTexture(j.TEXTURE0+h);j.bindTexture(j.TEXTURE_CUBE_MAP,m.image.__webglTextureCube);for(h=0;h<6;h++)j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,m.image[h]);O(j.TEXTURE_CUBE_MAP,m,m.image[0]);m.needsUpdate=!1}else j.activeTexture(j.TEXTURE0+h),j.bindTexture(j.TEXTURE_CUBE_MAP,m.image.__webglTextureCube)}else l instanceof THREE.WebGLRenderTargetCube?(m=l,j.activeTexture(j.TEXTURE0+
+h),j.bindTexture(j.TEXTURE_CUBE_MAP,m.__webglTexture)):G(l,h)}else if(o==="tv"){if(!m._array){m._array=[];o=0;for(p=m.texture.length;o<p;o++)m._array[o]=h+o}j.uniform1iv(l,m._array);o=0;for(p=m.texture.length;o<p;o++)(l=m.texture[o])&&G(l,m._array[o])}(d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&g.cameraPosition!==null&&j.uniform3f(g.cameraPosition,a.position.x,a.position.y,a.position.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||
+d instanceof THREE.ShaderMaterial||d.skinning)&&g.viewMatrix!==null&&j.uniformMatrix4fv(g.viewMatrix,!1,J);d.skinning&&(j.uniformMatrix4fv(g.cameraInverseMatrix,!1,J),j.uniformMatrix4fv(g.boneGlobalMatrices,!1,e.boneMatrices))}j.uniformMatrix4fv(g.modelViewMatrix,!1,e._modelViewMatrixArray);g.normalMatrix&&j.uniformMatrix3fv(g.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&g.objectMatrix!==null&&j.uniformMatrix4fv(g.objectMatrix,!1,
+e._objectMatrixArray);return f}function t(a,b,c){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(a._modelViewMatrix).transposeIntoArray(a._normalMatrixArray)}function u(a){if(T!==a.doubleSided)a.doubleSided?j.disable(j.CULL_FACE):j.enable(j.CULL_FACE),T=a.doubleSided;if(B!==a.flipSided)a.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW),B=a.flipSided}function r(a){$!==a&&(a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST),$=
+a)}function z(a){la!==a&&(j.depthMask(a),la=a)}function w(a,b,c){ra!==a&&(a?j.enable(j.POLYGON_OFFSET_FILL):j.disable(j.POLYGON_OFFSET_FILL),ra=a);if(a&&(ma!==b||na!==c))j.polygonOffset(b,c),ma=b,na=c}function C(a){if(a!==ja){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)}ja=a}}function x(a,b){var c;a==="fragment"?c=j.createShader(j.FRAGMENT_SHADER):a==="vertex"&&(c=j.createShader(j.VERTEX_SHADER));j.shaderSource(c,b);j.compileShader(c);if(!j.getShaderParameter(c,j.COMPILE_STATUS))return console.error(j.getShaderInfoLog(c)),console.error(b),null;return c}function O(a,b,c){(c.width&c.width-1)===0&&(c.height&c.height-
+1)===0?(j.texParameteri(a,j.TEXTURE_WRAP_S,I(b.wrapS)),j.texParameteri(a,j.TEXTURE_WRAP_T,I(b.wrapT)),j.texParameteri(a,j.TEXTURE_MAG_FILTER,I(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,I(b.minFilter)),j.generateMipmap(a)):(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,P(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,P(b.minFilter)))}function G(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=
+!0,a.__webglTexture=j.createTexture(),L.info.memory.textures++;j.activeTexture(j.TEXTURE0+b);j.bindTexture(j.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?j.texImage2D(j.TEXTURE_2D,0,I(a.format),a.image.width,a.image.height,0,I(a.format),j.UNSIGNED_BYTE,a.image.data):j.texImage2D(j.TEXTURE_2D,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,a.image);O(j.TEXTURE_2D,a,a.image);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else j.activeTexture(j.TEXTURE0+b),j.bindTexture(j.TEXTURE_2D,a.__webglTexture)}
+function K(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 D(a){var b=
+a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=j.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];j.bindTexture(j.TEXTURE_CUBE_MAP,a.__webglTexture);O(j.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=j.createFramebuffer();a.__webglRenderbuffer[c]=j.createRenderbuffer();j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,I(a.format),
+a.width,a.height,0,I(a.format),I(a.type),null);var d=a,e=j.TEXTURE_CUBE_MAP_POSITIVE_X+c;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer[c]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,e,d.__webglTexture,0);K(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=j.createFramebuffer(),a.__webglRenderbuffer=j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture),O(j.TEXTURE_2D,a,a),j.texImage2D(j.TEXTURE_2D,0,I(a.format),a.width,a.height,0,I(a.format),I(a.type),null),
+c=j.TEXTURE_2D,j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer),j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,c,a.__webglTexture,0),j.bindRenderbuffer(j.RENDERBUFFER,a.__webglRenderbuffer),K(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,c=a.width,a=a.height,e=d=0):(b=null,c=xa,a=U,d=pa,
+e=sa);b!==M&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(d,e,c,a),M=b)}function P(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return j.NEAREST;default:return j.LINEAR}}function I(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||{},V=a.canvas!==void 0?a.canvas:document.createElement("canvas"),Z=a.precision!==void 0?a.precision:"highp",R=a.antialias!==void 0?a.antialias:!1,W=a.stencil!==void 0?a.stencil:!0,ka=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,G=a.clearColor!==void 0?new THREE.Color(a.clearColor):
-new THREE.Color(0),z=a.clearAlpha!==void 0?a.clearAlpha:0,y=a.maxLights!==void 0?a.maxLights:4;this.domElement=V;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=
-50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.maxMorphTargets=8;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};var L=this,j,ca=[],ga=null,N=null,X=-1,T=null,ea=0,Q=null,C=null,Y=null,S=null,$=null,oa=null,la=null,ra=null,ta=null,pa=0,qa=0,wa=0,U=0,u=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],H=new THREE.Matrix4,aa=new Float32Array(16),
-ja=new Float32Array(16),da=new THREE.Vector4,ua={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},ba,fa=[],ia,xa,O={},ma=!1;j=function(){var a;try{if(!(a=V.getContext("experimental-webgl",{antialias:R,stencil:W,preserveDrawingBuffer:ka})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();
-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(G.r,G.g,G.b,z);(function(){O.vertices=new Float32Array(16);O.faces=new Uint16Array(6);var a=0;O.vertices[a++]=-1;O.vertices[a++]=-1;O.vertices[a++]=0;O.vertices[a++]=1;O.vertices[a++]=1;O.vertices[a++]=-1;O.vertices[a++]=1;O.vertices[a++]=
-1;O.vertices[a++]=1;O.vertices[a++]=1;O.vertices[a++]=1;O.vertices[a++]=0;O.vertices[a++]=-1;O.vertices[a++]=1;O.vertices[a++]=0;a=O.vertices[a++]=0;O.faces[a++]=0;O.faces[a++]=1;O.faces[a++]=2;O.faces[a++]=0;O.faces[a++]=2;O.faces[a++]=3;O.vertexBuffer=j.createBuffer();O.elementBuffer=j.createBuffer();j.bindBuffer(j.ARRAY_BUFFER,O.vertexBuffer);j.bufferData(j.ARRAY_BUFFER,O.vertices,j.STATIC_DRAW);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,O.elementBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,O.faces,j.STATIC_DRAW);
-O.program=j.createProgram();j.attachShader(O.program,x("fragment",THREE.ShaderLib.sprite.fragmentShader));j.attachShader(O.program,x("vertex",THREE.ShaderLib.sprite.vertexShader));j.linkProgram(O.program);O.attributes={};O.uniforms={};O.attributes.position=j.getAttribLocation(O.program,"position");O.attributes.uv=j.getAttribLocation(O.program,"uv");O.uniforms.uvOffset=j.getUniformLocation(O.program,"uvOffset");O.uniforms.uvScale=j.getUniformLocation(O.program,"uvScale");O.uniforms.rotation=j.getUniformLocation(O.program,
-"rotation");O.uniforms.scale=j.getUniformLocation(O.program,"scale");O.uniforms.alignment=j.getUniformLocation(O.program,"alignment");O.uniforms.color=j.getUniformLocation(O.program,"color");O.uniforms.map=j.getUniformLocation(O.program,"map");O.uniforms.opacity=j.getUniformLocation(O.program,"opacity");O.uniforms.useScreenCoordinates=j.getUniformLocation(O.program,"useScreenCoordinates");O.uniforms.affectedByDistance=j.getUniformLocation(O.program,"affectedByDistance");O.uniforms.screenPosition=
-j.getUniformLocation(O.program,"screenPosition");O.uniforms.modelViewMatrix=j.getUniformLocation(O.program,"modelViewMatrix");O.uniforms.projectionMatrix=j.getUniformLocation(O.program,"projectionMatrix")})();(function(){var a=THREE.ShaderLib.depthRGBA,b=THREE.UniformsUtils.clone(a.uniforms);ia=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:b});xa=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:b,morphTargets:!0});
-ia._shadowPass=!0;xa._shadowPass=!0})();this.context=j;var sa=j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;this.getContext=function(){return j};this.supportsVertexTextures=function(){return sa};this.setSize=function(a,b){V.width=a;V.height=b;this.setViewport(0,0,V.width,V.height)};this.setViewport=function(a,b,c,d){pa=a;qa=b;wa=c;U=d;j.viewport(pa,qa,wa,U)};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){G.setHex(a);z=b;j.clearColor(G.r,G.g,G.b,z)};this.setClearColor=function(a,b){G.copy(a);z=b;j.clearColor(G.r,G.g,G.b,z)};this.getClearColor=function(){return G};this.getClearAlpha=function(){return z};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=j.COLOR_BUFFER_BIT;if(b===void 0||b)d|=j.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=function(a,b,c,d){E(a);this.clear(b,c,d)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=
+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||{},W=a.canvas!==void 0?a.canvas:document.createElement("canvas"),Z=a.precision!==void 0?a.precision:"highp",R=a.antialias!==void 0?a.antialias:!1,S=a.stencil!==void 0?a.stencil:!0,ia=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,H=a.clearColor!==void 0?new THREE.Color(a.clearColor):
+new THREE.Color(0),F=a.clearAlpha!==void 0?a.clearAlpha:0,y=a.maxLights!==void 0?a.maxLights:4;this.domElement=W;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=
+50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.maxMorphTargets=8;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};var L=this,j,X=[],fa=null,M=null,Q=-1,Y=null,ca=0,T=null,B=null,ja=null,$=null,la=null,ra=null,ma=null,na=null,ta=null,pa=0,sa=0,xa=0,U=0,v=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ba=new THREE.Matrix4,aa=new Float32Array(16),
+J=new Float32Array(16),ea=new THREE.Vector4,ha={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},V,va=[],ka,ga,N={},ua=!1;j=function(){var a;try{if(!(a=W.getContext("experimental-webgl",{antialias:R,stencil:S,preserveDrawingBuffer:ia})))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(H.r,H.g,H.b,F);(function(){N.vertices=new Float32Array(16);N.faces=new Uint16Array(6);var a=0;N.vertices[a++]=-1;N.vertices[a++]=-1;N.vertices[a++]=0;N.vertices[a++]=1;N.vertices[a++]=1;N.vertices[a++]=-1;N.vertices[a++]=1;N.vertices[a++]=
+1;N.vertices[a++]=1;N.vertices[a++]=1;N.vertices[a++]=1;N.vertices[a++]=0;N.vertices[a++]=-1;N.vertices[a++]=1;N.vertices[a++]=0;a=N.vertices[a++]=0;N.faces[a++]=0;N.faces[a++]=1;N.faces[a++]=2;N.faces[a++]=0;N.faces[a++]=2;N.faces[a++]=3;N.vertexBuffer=j.createBuffer();N.elementBuffer=j.createBuffer();j.bindBuffer(j.ARRAY_BUFFER,N.vertexBuffer);j.bufferData(j.ARRAY_BUFFER,N.vertices,j.STATIC_DRAW);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,N.elementBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,N.faces,j.STATIC_DRAW);
+N.program=j.createProgram();j.attachShader(N.program,x("fragment",THREE.ShaderLib.sprite.fragmentShader));j.attachShader(N.program,x("vertex",THREE.ShaderLib.sprite.vertexShader));j.linkProgram(N.program);N.attributes={};N.uniforms={};N.attributes.position=j.getAttribLocation(N.program,"position");N.attributes.uv=j.getAttribLocation(N.program,"uv");N.uniforms.uvOffset=j.getUniformLocation(N.program,"uvOffset");N.uniforms.uvScale=j.getUniformLocation(N.program,"uvScale");N.uniforms.rotation=j.getUniformLocation(N.program,
+"rotation");N.uniforms.scale=j.getUniformLocation(N.program,"scale");N.uniforms.alignment=j.getUniformLocation(N.program,"alignment");N.uniforms.color=j.getUniformLocation(N.program,"color");N.uniforms.map=j.getUniformLocation(N.program,"map");N.uniforms.opacity=j.getUniformLocation(N.program,"opacity");N.uniforms.useScreenCoordinates=j.getUniformLocation(N.program,"useScreenCoordinates");N.uniforms.affectedByDistance=j.getUniformLocation(N.program,"affectedByDistance");N.uniforms.screenPosition=
+j.getUniformLocation(N.program,"screenPosition");N.uniforms.modelViewMatrix=j.getUniformLocation(N.program,"modelViewMatrix");N.uniforms.projectionMatrix=j.getUniformLocation(N.program,"projectionMatrix")})();(function(){var a=THREE.ShaderLib.depthRGBA,b=THREE.UniformsUtils.clone(a.uniforms);ka=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:b});ga=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:b,morphTargets:!0});
+ka._shadowPass=!0;ga._shadowPass=!0})();this.context=j;var qa=j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;this.getContext=function(){return j};this.supportsVertexTextures=function(){return qa};this.setSize=function(a,b){W.width=a;W.height=b;this.setViewport(0,0,W.width,W.height)};this.setViewport=function(a,b,c,d){pa=a;sa=b;xa=c;U=d;j.viewport(pa,sa,xa,U)};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){H.setHex(a);F=b;j.clearColor(H.r,H.g,H.b,F)};this.setClearColor=function(a,b){H.copy(a);F=b;j.clearColor(H.r,H.g,H.b,F)};this.getClearColor=function(){return H};this.getClearAlpha=function(){return F};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=j.COLOR_BUFFER_BIT;if(b===void 0||b)d|=j.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=function(a,b,c,d){D(a);this.clear(b,c,d)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=
 !1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];j.deleteBuffer(c.__webglVertexBuffer);j.deleteBuffer(c.__webglNormalBuffer);j.deleteBuffer(c.__webglTangentBuffer);j.deleteBuffer(c.__webglColorBuffer);j.deleteBuffer(c.__webglUVBuffer);j.deleteBuffer(c.__webglUV2Buffer);j.deleteBuffer(c.__webglSkinVertexABuffer);j.deleteBuffer(c.__webglSkinVertexBBuffer);
 j.deleteBuffer(c.__webglSkinIndicesBuffer);j.deleteBuffer(c.__webglSkinWeightsBuffer);j.deleteBuffer(c.__webglFaceBuffer);j.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d<e;d++)j.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)j.deleteBuffer(c.__webglCustomAttributesList[d].buffer);L.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),
 j.deleteBuffer(a.__webglColorBuffer),L.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),L.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),L.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,j.deleteTexture(a.__webglTexture),L.info.memory.textures--};this.updateShadowMap=
-function(a,b){l(a,b)};this.render=function(a,b,c,d){var e,g,m,n,p=a.lights,r=a.fog;X=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&l(a,b);L.info.render.calls=0;L.info.render.vertices=0;L.info.render.faces=0;b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(ja);
-b.projectionMatrix.flattenToArray(aa);H.multiply(b.projectionMatrix,b.matrixWorldInverse);f(H);E(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);n=a.__webglObjects;d=0;for(e=n.length;d<e;d++)if(g=n[d],m=g.object,g.render=!1,m.visible&&(!(m instanceof THREE.Mesh)||!m.frustumCulled||h(m))){m.matrixWorld.flattenToArray(m._objectMatrixArray);t(m,b,!0);var s=g,u=s.object,v=s.buffer,C=void 0,C=C=void 0,C=u.material;if(C instanceof THREE.MeshFaceMaterial){if(C=
-v.materialIndex,C>=0)C=u.geometry.materials[C],C.transparent?(s.transparent=C,s.opaque=null):(s.opaque=C,s.transparent=null)}else if(C)C.transparent?(s.transparent=C,s.opaque=null):(s.opaque=C,s.transparent=null);g.render=!0;if(this.sortObjects)m.renderDepth?g.z=m.renderDepth:(da.copy(m.position),H.multiplyVector3(da),g.z=da.z)}this.sortObjects&&n.sort(i);n=a.__webglObjectsImmediate;d=0;for(e=n.length;d<e;d++)if(g=n[d],m=g.object,m.visible)m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),
-t(m,b,!0),m=g.object.material,m.transparent?(g.transparent=m,g.opaque=null):(g.opaque=m,g.transparent=null);a.overrideMaterial?(D(a.overrideMaterial.blending),q(a.overrideMaterial.depthTest),A(a.overrideMaterial.depthWrite),w(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),k(a.__webglObjects,!1,"",b,p,r,!0,a.overrideMaterial),o(a.__webglObjectsImmediate,"",b,p,r,!1,a.overrideMaterial)):(D(THREE.NormalBlending),k(a.__webglObjects,!0,"opaque",
-b,p,r,!1),o(a.__webglObjectsImmediate,"opaque",b,p,r,!1),k(a.__webglObjects,!1,"transparent",b,p,r,!0),o(a.__webglObjectsImmediate,"transparent",b,p,r,!0));if(a.__webglSprites.length){m=O.attributes;p=O.uniforms;r=U/wa;d=[];e=wa*0.5;n=U*0.5;g=!0;j.useProgram(O.program);ga=O.program;T=S=Y=-1;ma||(j.enableVertexAttribArray(O.attributes.position),j.enableVertexAttribArray(O.attributes.uv),ma=!0);j.disable(j.CULL_FACE);j.enable(j.BLEND);j.depthMask(!0);j.bindBuffer(j.ARRAY_BUFFER,O.vertexBuffer);j.vertexAttribPointer(m.position,
-2,j.FLOAT,!1,16,0);j.vertexAttribPointer(m.uv,2,j.FLOAT,!1,16,8);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,O.elementBuffer);j.uniformMatrix4fv(p.projectionMatrix,!1,aa);j.activeTexture(j.TEXTURE0);j.uniform1i(p.map,0);m=0;for(s=a.__webglSprites.length;m<s;m++)if(u=a.__webglSprites[m],u.visible&&u.opacity!==0)u.useScreenCoordinates?u.z=-u.position.z:(u._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,u.matrixWorld,u._modelViewMatrixArray),u.z=-u._modelViewMatrix.n34);a.__webglSprites.sort(i);m=0;for(s=
-a.__webglSprites.length;m<s;m++)u=a.__webglSprites[m],u.visible&&u.opacity!==0&&u.map&&u.map.image&&u.map.image.width&&(u.useScreenCoordinates?(j.uniform1i(p.useScreenCoordinates,1),j.uniform3f(p.screenPosition,(u.position.x-e)/e,(n-u.position.y)/n,Math.max(0,Math.min(1,u.position.z)))):(j.uniform1i(p.useScreenCoordinates,0),j.uniform1i(p.affectedByDistance,u.affectedByDistance?1:0),j.uniformMatrix4fv(p.modelViewMatrix,!1,u._modelViewMatrixArray)),b=u.map.image.width/(u.scaleByViewport?U:1),d[0]=
-b*r*u.scale.x,d[1]=b*u.scale.y,j.uniform2f(p.uvScale,u.uvScale.x,u.uvScale.y),j.uniform2f(p.uvOffset,u.uvOffset.x,u.uvOffset.y),j.uniform2f(p.alignment,u.alignment.x,u.alignment.y),j.uniform1f(p.opacity,u.opacity),j.uniform3f(p.color,u.color.r,u.color.g,u.color.b),j.uniform1f(p.rotation,u.rotation),j.uniform2fv(p.scale,d),u.mergeWith3D&&!g?(j.enable(j.DEPTH_TEST),g=!0):!u.mergeWith3D&&g&&(j.disable(j.DEPTH_TEST),g=!1),D(u.blending),M(u.map,0),j.drawElements(j.TRIANGLES,6,j.UNSIGNED_SHORT,0));j.enable(j.CULL_FACE);
-j.enable(j.DEPTH_TEST);j.depthMask($)}c&&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.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=
-[];for(;a.__objectsAdded.length;){var e=a.__objectsAdded[0],g=a,f=void 0,h=void 0,i=void 0;if(!e.__webglInit)if(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=new Float32Array(16),e._objectMatrixArray=new Float32Array(16),e.matrixWorld.flattenToArray(e._objectMatrixArray),e instanceof THREE.Mesh){h=e.geometry;if(h.geometryGroups===void 0){var i=h,k=void 0,l=void 0,o=void 0,U=void 0,u=void 0,H=void 0,s=void 0,q={},t=i.morphTargets.length;
-i.geometryGroups={};k=0;for(l=i.faces.length;k<l;k++)o=i.faces[k],U=o.materialIndex,H=U!==void 0?U:-1,q[H]===void 0&&(q[H]={hash:H,counter:0}),s=q[H].hash+"_"+q[H].counter,i.geometryGroups[s]===void 0&&(i.geometryGroups[s]={faces3:[],faces4:[],materialIndex:U,vertices:0,numMorphTargets:t}),u=o instanceof THREE.Face3?3:4,i.geometryGroups[s].vertices+u>65535&&(q[H].counter+=1,s=q[H].hash+"_"+q[H].counter,i.geometryGroups[s]===void 0&&(i.geometryGroups[s]={faces3:[],faces4:[],materialIndex:U,vertices:0,
-numMorphTargets:t})),o instanceof THREE.Face3?i.geometryGroups[s].faces3.push(k):i.geometryGroups[s].faces4.push(k),i.geometryGroups[s].vertices+=u;i.geometryGroupsList=[];k=void 0;for(k in i.geometryGroups)i.geometryGroups[k].id=ea++,i.geometryGroupsList.push(i.geometryGroups[k])}for(f in h.geometryGroups)if(i=h.geometryGroups[f],!i.__webglVertexBuffer){k=i;k.__webglVertexBuffer=j.createBuffer();k.__webglNormalBuffer=j.createBuffer();k.__webglTangentBuffer=j.createBuffer();k.__webglColorBuffer=j.createBuffer();
-k.__webglUVBuffer=j.createBuffer();k.__webglUV2Buffer=j.createBuffer();k.__webglSkinVertexABuffer=j.createBuffer();k.__webglSkinVertexBBuffer=j.createBuffer();k.__webglSkinIndicesBuffer=j.createBuffer();k.__webglSkinWeightsBuffer=j.createBuffer();k.__webglFaceBuffer=j.createBuffer();k.__webglLineBuffer=j.createBuffer();if(k.numMorphTargets){o=l=void 0;k.__webglMorphTargetsBuffers=[];l=0;for(o=k.numMorphTargets;l<o;l++)k.__webglMorphTargetsBuffers.push(j.createBuffer())}L.info.memory.geometries++;
-U=e;u=U.geometry;l=i.faces3;H=i.faces4;k=l.length*3+H.length*4;o=l.length*1+H.length*2;H=l.length*3+H.length*4;l=b(U,i);s=l.map||l.lightMap||l instanceof THREE.ShaderMaterial?!0:!1;q=l instanceof THREE.MeshBasicMaterial&&!l.envMap||l instanceof THREE.MeshDepthMaterial?!1:l&&l.shading!==void 0&&l.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;t=l.vertexColors?l.vertexColors:!1;i.__vertexArray=new Float32Array(k*3);if(q)i.__normalArray=new Float32Array(k*3);if(u.hasTangents)i.__tangentArray=
-new Float32Array(k*4);if(t)i.__colorArray=new Float32Array(k*3);if(s){if(u.faceUvs.length>0||u.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(k*2)}if(U.geometry.skinWeights.length&&U.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4),i.__skinVertexBArray=new Float32Array(k*4),i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray=new Float32Array(k*4);i.__faceArray=new Uint16Array(o*3);
-i.__lineArray=new Uint16Array(H*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];U=0;for(u=i.numMorphTargets;U<u;U++)i.__morphTargetsArrays.push(new Float32Array(k*3))}i.__needsSmoothNormals=q===THREE.SmoothShading;i.__uvType=s;i.__vertexColorType=t;i.__normalType=q;i.__webglFaceCount=o*3;i.__webglLineCount=H*2;if(l.attributes){if(i.__webglCustomAttributesList===void 0)i.__webglCustomAttributesList=[];o=void 0;for(o in l.attributes){var U=l.attributes[o],u={},v;for(v in U)u[v]=U[v];if(!u.__webglInitialized||
-u.createUniqueBuffers)u.__webglInitialized=!0,H=1,u.type==="v2"?H=2:u.type==="v3"?H=3:u.type==="v4"?H=4:u.type==="c"&&(H=3),u.size=H,u.array=new Float32Array(k*H),u.buffer=j.createBuffer(),u.buffer.belongsToAttribute=o,U.needsUpdate=!0,u.__original=U;i.__webglCustomAttributesList.push(u)}}i.__inittedArrays=!0;h.__dirtyVertices=!0;h.__dirtyMorphTargets=!0;h.__dirtyElements=!0;h.__dirtyUvs=!0;h.__dirtyNormals=!0;h.__dirtyTangents=!0;h.__dirtyColors=!0}}else if(e instanceof THREE.Ribbon){if(h=e.geometry,
-!h.__webglVertexBuffer)i=h,i.__webglVertexBuffer=j.createBuffer(),i.__webglColorBuffer=j.createBuffer(),L.info.memory.geometries++,i=h,k=i.vertices.length,i.__vertexArray=new Float32Array(k*3),i.__colorArray=new Float32Array(k*3),i.__webglVertexCount=k,h.__dirtyVertices=!0,h.__dirtyColors=!0}else if(e instanceof THREE.Line){if(h=e.geometry,!h.__webglVertexBuffer)i=h,i.__webglVertexBuffer=j.createBuffer(),i.__webglColorBuffer=j.createBuffer(),L.info.memory.geometries++,i=h,k=e,l=i.vertices.length,
-i.__vertexArray=new Float32Array(l*3),i.__colorArray=new Float32Array(l*3),i.__webglLineCount=l,c(i,k),h.__dirtyVertices=!0,h.__dirtyColors=!0}else if(e instanceof THREE.ParticleSystem&&(h=e.geometry,!h.__webglVertexBuffer))i=h,i.__webglVertexBuffer=j.createBuffer(),i.__webglColorBuffer=j.createBuffer(),L.info.geometries++,i=h,k=e,l=i.vertices.length,i.__vertexArray=new Float32Array(l*3),i.__colorArray=new Float32Array(l*3),i.__sortArray=[],i.__webglParticleCount=l,c(i,k),h.__dirtyVertices=!0,h.__dirtyColors=
-!0;if(!e.__webglActive){if(e instanceof THREE.Mesh)for(f in h=e.geometry,h.geometryGroups)i=h.geometryGroups[f],p(g.__webglObjects,i,e);else e instanceof THREE.Ribbon||e instanceof THREE.Line||e instanceof THREE.ParticleSystem?(h=e.geometry,p(g.__webglObjects,h,e)):THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes||e.immediateRenderCallback?g.__webglObjectsImmediate.push({object:e,opaque:null,transparent:null}):e instanceof THREE.Sprite&&g.__webglSprites.push(e);e.__webglActive=!0}a.__objectsAdded.splice(0,
-1)}for(;a.__objectsRemoved.length;){e=a.__objectsRemoved[0];g=a;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)m(g.__webglObjects,e);else if(e instanceof THREE.Sprite){g=g.__webglSprites;f=e;for(h=g.length-1;h>=0;h--)g[h]===f&&g.splice(h,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&m(g.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(g=a.__webglObjects.length;e<g;e++)if(v=
-a.__webglObjects[e].object,f=v.geometry,h=o=l=void 0,v instanceof THREE.Mesh){i=0;for(k=f.geometryGroupsList.length;i<k;i++)if(l=f.geometryGroupsList[i],h=b(v,l),o=h.attributes&&n(h),f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||o)if(o=j.DYNAMIC_DRAW,U=!f.dynamic,l.__inittedArrays){var A=H=u=void 0,C=void 0,aa=void 0,E=void 0,w=void 0,da=void 0,D=void 0,M=void 0,J=void 0,Y=A=E=void 0,z=void 0,x=void 0,y=void 0,G=C=
-void 0,ja=void 0,O=C=D=J=void 0,I=void 0,K=y=x=z=w=void 0,S=C=y=x=z=K=y=x=z=K=y=x=z=void 0,ba=void 0,P=E=void 0,X=void 0,$=void 0,ua=void 0,R=void 0,N=Y=$=ba=0,fa=0,T=S=A=0,Q=w=G=0,F=0,W=void 0,Q=l.__vertexArray,X=l.__uvArray,F=l.__uv2Array,P=l.__normalArray,aa=l.__tangentArray,ja=l.__colorArray,O=l.__skinVertexAArray,I=l.__skinVertexBArray,da=l.__skinIndexArray,V=l.__skinWeightArray,K=l.__morphTargetsArrays,s=l.__webglCustomAttributesList,B=void 0,B=l.__faceArray,W=l.__lineArray,ca=l.__needsSmoothNormals,
-J=l.__vertexColorType,M=l.__uvType,E=l.__normalType,D=v.geometry,Z=D.__dirtyElements,oa=D.__dirtyUvs,ka=D.__dirtyNormals,ga=D.__dirtyTangents,xa=D.__dirtyColors,ua=D.__dirtyMorphTargets,R=D.vertices,q=l.faces3,t=l.faces4,ia=D.faces,la=D.faceVertexUvs[0],ta=D.faceVertexUvs[1],sa=D.skinVerticesA,ra=D.skinVerticesB,qa=D.skinIndices,ma=D.skinWeights,pa=D.morphTargets;if(D.__dirtyVertices){u=0;for(H=q.length;u<H;u++)C=ia[q[u]],z=R[C.a].position,x=R[C.b].position,y=R[C.c].position,Q[$]=z.x,Q[$+1]=z.y,Q[$+
-2]=z.z,Q[$+3]=x.x,Q[$+4]=x.y,Q[$+5]=x.z,Q[$+6]=y.x,Q[$+7]=y.y,Q[$+8]=y.z,$+=9;u=0;for(H=t.length;u<H;u++)C=ia[t[u]],z=R[C.a].position,x=R[C.b].position,y=R[C.c].position,C=R[C.d].position,Q[$]=z.x,Q[$+1]=z.y,Q[$+2]=z.z,Q[$+3]=x.x,Q[$+4]=x.y,Q[$+5]=x.z,Q[$+6]=y.x,Q[$+7]=y.y,Q[$+8]=y.z,Q[$+9]=C.x,Q[$+10]=C.y,Q[$+11]=C.z,$+=12;j.bindBuffer(j.ARRAY_BUFFER,l.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Q,o)}if(ua){$=0;for(ua=pa.length;$<ua;$++){u=Q=0;for(H=q.length;u<H;u++)C=ia[q[u]],z=pa[$].vertices[C.a].position,
-x=pa[$].vertices[C.b].position,y=pa[$].vertices[C.c].position,R=K[$],R[Q]=z.x,R[Q+1]=z.y,R[Q+2]=z.z,R[Q+3]=x.x,R[Q+4]=x.y,R[Q+5]=x.z,R[Q+6]=y.x,R[Q+7]=y.y,R[Q+8]=y.z,Q+=9;u=0;for(H=t.length;u<H;u++)C=ia[t[u]],z=pa[$].vertices[C.a].position,x=pa[$].vertices[C.b].position,y=pa[$].vertices[C.c].position,C=pa[$].vertices[C.d].position,R=K[$],R[Q]=z.x,R[Q+1]=z.y,R[Q+2]=z.z,R[Q+3]=x.x,R[Q+4]=x.y,R[Q+5]=x.z,R[Q+6]=y.x,R[Q+7]=y.y,R[Q+8]=y.z,R[Q+9]=C.x,R[Q+10]=C.y,R[Q+11]=C.z,Q+=12;j.bindBuffer(j.ARRAY_BUFFER,
-l.__webglMorphTargetsBuffers[$]);j.bufferData(j.ARRAY_BUFFER,K[$],o)}}if(ma.length){u=0;for(H=q.length;u<H;u++)C=ia[q[u]],z=ma[C.a],x=ma[C.b],y=ma[C.c],V[w]=z.x,V[w+1]=z.y,V[w+2]=z.z,V[w+3]=z.w,V[w+4]=x.x,V[w+5]=x.y,V[w+6]=x.z,V[w+7]=x.w,V[w+8]=y.x,V[w+9]=y.y,V[w+10]=y.z,V[w+11]=y.w,z=qa[C.a],x=qa[C.b],y=qa[C.c],da[w]=z.x,da[w+1]=z.y,da[w+2]=z.z,da[w+3]=z.w,da[w+4]=x.x,da[w+5]=x.y,da[w+6]=x.z,da[w+7]=x.w,da[w+8]=y.x,da[w+9]=y.y,da[w+10]=y.z,da[w+11]=y.w,z=sa[C.a],x=sa[C.b],y=sa[C.c],O[w]=z.x,O[w+
-1]=z.y,O[w+2]=z.z,O[w+3]=1,O[w+4]=x.x,O[w+5]=x.y,O[w+6]=x.z,O[w+7]=1,O[w+8]=y.x,O[w+9]=y.y,O[w+10]=y.z,O[w+11]=1,z=ra[C.a],x=ra[C.b],y=ra[C.c],I[w]=z.x,I[w+1]=z.y,I[w+2]=z.z,I[w+3]=1,I[w+4]=x.x,I[w+5]=x.y,I[w+6]=x.z,I[w+7]=1,I[w+8]=y.x,I[w+9]=y.y,I[w+10]=y.z,I[w+11]=1,w+=12;u=0;for(H=t.length;u<H;u++)C=ia[t[u]],z=ma[C.a],x=ma[C.b],y=ma[C.c],K=ma[C.d],V[w]=z.x,V[w+1]=z.y,V[w+2]=z.z,V[w+3]=z.w,V[w+4]=x.x,V[w+5]=x.y,V[w+6]=x.z,V[w+7]=x.w,V[w+8]=y.x,V[w+9]=y.y,V[w+10]=y.z,V[w+11]=y.w,V[w+12]=K.x,V[w+
-13]=K.y,V[w+14]=K.z,V[w+15]=K.w,z=qa[C.a],x=qa[C.b],y=qa[C.c],K=qa[C.d],da[w]=z.x,da[w+1]=z.y,da[w+2]=z.z,da[w+3]=z.w,da[w+4]=x.x,da[w+5]=x.y,da[w+6]=x.z,da[w+7]=x.w,da[w+8]=y.x,da[w+9]=y.y,da[w+10]=y.z,da[w+11]=y.w,da[w+12]=K.x,da[w+13]=K.y,da[w+14]=K.z,da[w+15]=K.w,z=sa[C.a],x=sa[C.b],y=sa[C.c],K=sa[C.d],O[w]=z.x,O[w+1]=z.y,O[w+2]=z.z,O[w+3]=1,O[w+4]=x.x,O[w+5]=x.y,O[w+6]=x.z,O[w+7]=1,O[w+8]=y.x,O[w+9]=y.y,O[w+10]=y.z,O[w+11]=1,O[w+12]=K.x,O[w+13]=K.y,O[w+14]=K.z,O[w+15]=1,z=ra[C.a],x=ra[C.b],y=
-ra[C.c],C=ra[C.d],I[w]=z.x,I[w+1]=z.y,I[w+2]=z.z,I[w+3]=1,I[w+4]=x.x,I[w+5]=x.y,I[w+6]=x.z,I[w+7]=1,I[w+8]=y.x,I[w+9]=y.y,I[w+10]=y.z,I[w+11]=1,I[w+12]=C.x,I[w+13]=C.y,I[w+14]=C.z,I[w+15]=1,w+=16;w>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,O,o),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,I,o),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,da,o),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinWeightsBuffer),
-j.bufferData(j.ARRAY_BUFFER,V,o))}if(xa&&J){u=0;for(H=q.length;u<H;u++)C=ia[q[u]],w=C.vertexColors,da=C.color,w.length===3&&J===THREE.VertexColors?(C=w[0],O=w[1],I=w[2]):I=O=C=da,ja[G]=C.r,ja[G+1]=C.g,ja[G+2]=C.b,ja[G+3]=O.r,ja[G+4]=O.g,ja[G+5]=O.b,ja[G+6]=I.r,ja[G+7]=I.g,ja[G+8]=I.b,G+=9;u=0;for(H=t.length;u<H;u++)C=ia[t[u]],w=C.vertexColors,da=C.color,w.length===4&&J===THREE.VertexColors?(C=w[0],O=w[1],I=w[2],w=w[3]):w=I=O=C=da,ja[G]=C.r,ja[G+1]=C.g,ja[G+2]=C.b,ja[G+3]=O.r,ja[G+4]=O.g,ja[G+5]=O.b,
-ja[G+6]=I.r,ja[G+7]=I.g,ja[G+8]=I.b,ja[G+9]=w.r,ja[G+10]=w.g,ja[G+11]=w.b,G+=12;G>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,ja,o))}if(ga&&D.hasTangents){u=0;for(H=q.length;u<H;u++)C=ia[q[u]],D=C.vertexTangents,G=D[0],ja=D[1],J=D[2],aa[S]=G.x,aa[S+1]=G.y,aa[S+2]=G.z,aa[S+3]=G.w,aa[S+4]=ja.x,aa[S+5]=ja.y,aa[S+6]=ja.z,aa[S+7]=ja.w,aa[S+8]=J.x,aa[S+9]=J.y,aa[S+10]=J.z,aa[S+11]=J.w,S+=12;u=0;for(H=t.length;u<H;u++)C=ia[t[u]],D=C.vertexTangents,G=D[0],ja=D[1],J=D[2],
-D=D[3],aa[S]=G.x,aa[S+1]=G.y,aa[S+2]=G.z,aa[S+3]=G.w,aa[S+4]=ja.x,aa[S+5]=ja.y,aa[S+6]=ja.z,aa[S+7]=ja.w,aa[S+8]=J.x,aa[S+9]=J.y,aa[S+10]=J.z,aa[S+11]=J.w,aa[S+12]=D.x,aa[S+13]=D.y,aa[S+14]=D.z,aa[S+15]=D.w,S+=16;j.bindBuffer(j.ARRAY_BUFFER,l.__webglTangentBuffer);j.bufferData(j.ARRAY_BUFFER,aa,o)}if(ka&&E){u=0;for(H=q.length;u<H;u++)if(C=ia[q[u]],aa=C.vertexNormals,E=C.normal,aa.length===3&&ca)for(S=0;S<3;S++)E=aa[S],P[A]=E.x,P[A+1]=E.y,P[A+2]=E.z,A+=3;else for(S=0;S<3;S++)P[A]=E.x,P[A+1]=E.y,P[A+
-2]=E.z,A+=3;u=0;for(H=t.length;u<H;u++)if(C=ia[t[u]],aa=C.vertexNormals,E=C.normal,aa.length===4&&ca)for(S=0;S<4;S++)E=aa[S],P[A]=E.x,P[A+1]=E.y,P[A+2]=E.z,A+=3;else for(S=0;S<4;S++)P[A]=E.x,P[A+1]=E.y,P[A+2]=E.z,A+=3;j.bindBuffer(j.ARRAY_BUFFER,l.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,P,o)}if(oa&&la&&M){u=0;for(H=q.length;u<H;u++)if(A=q[u],A=la[A],A!==void 0)for(S=0;S<3;S++)P=A[S],X[Y]=P.u,X[Y+1]=P.v,Y+=2;u=0;for(H=t.length;u<H;u++)if(A=t[u],A=la[A],A!==void 0)for(S=0;S<4;S++)P=A[S],X[Y]=
-P.u,X[Y+1]=P.v,Y+=2;Y>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,X,o))}if(oa&&ta&&M){u=0;for(H=q.length;u<H;u++)if(A=q[u],Y=ta[A],Y!==void 0)for(S=0;S<3;S++)X=Y[S],F[N]=X.u,F[N+1]=X.v,N+=2;u=0;for(H=t.length;u<H;u++)if(A=t[u],Y=ta[A],Y!==void 0)for(S=0;S<4;S++)X=Y[S],F[N]=X.u,F[N+1]=X.v,N+=2;N>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,F,o))}if(Z){u=0;for(H=q.length;u<H;u++)B[fa]=ba,B[fa+1]=ba+1,B[fa+2]=ba+2,fa+=3,W[T]=ba,W[T+
-1]=ba+1,W[T+2]=ba,W[T+3]=ba+2,W[T+4]=ba+1,W[T+5]=ba+2,T+=6,ba+=3;u=0;for(H=t.length;u<H;u++)B[fa]=ba,B[fa+1]=ba+1,B[fa+2]=ba+3,B[fa+3]=ba+1,B[fa+4]=ba+2,B[fa+5]=ba+3,fa+=6,W[T]=ba,W[T+1]=ba+1,W[T+2]=ba,W[T+3]=ba+3,W[T+4]=ba+1,W[T+5]=ba+2,W[T+6]=ba+2,W[T+7]=ba+3,T+=8,ba+=4;j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,l.__webglFaceBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,B,o);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,l.__webglLineBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,W,o)}if(s){S=0;for(ba=s.length;S<ba;S++)if(B=
-s[S],B.__original.needsUpdate){F=0;if(B.size===1)if(B.boundTo===void 0||B.boundTo==="vertices"){u=0;for(H=q.length;u<H;u++)C=ia[q[u]],B.array[F]=B.value[C.a],B.array[F+1]=B.value[C.b],B.array[F+2]=B.value[C.c],F+=3;u=0;for(H=t.length;u<H;u++)C=ia[t[u]],B.array[F]=B.value[C.a],B.array[F+1]=B.value[C.b],B.array[F+2]=B.value[C.c],B.array[F+3]=B.value[C.d],F+=4}else{if(B.boundTo==="faces"){u=0;for(H=q.length;u<H;u++)W=B.value[q[u]],B.array[F]=W,B.array[F+1]=W,B.array[F+2]=W,F+=3;u=0;for(H=t.length;u<
-H;u++)W=B.value[t[u]],B.array[F]=W,B.array[F+1]=W,B.array[F+2]=W,B.array[F+3]=W,F+=4}}else if(B.size===2)if(B.boundTo===void 0||B.boundTo==="vertices"){u=0;for(H=q.length;u<H;u++)C=ia[q[u]],z=B.value[C.a],x=B.value[C.b],y=B.value[C.c],B.array[F]=z.x,B.array[F+1]=z.y,B.array[F+2]=x.x,B.array[F+3]=x.y,B.array[F+4]=y.x,B.array[F+5]=y.y,F+=6;u=0;for(H=t.length;u<H;u++)C=ia[t[u]],z=B.value[C.a],x=B.value[C.b],y=B.value[C.c],C=B.value[C.d],B.array[F]=z.x,B.array[F+1]=z.y,B.array[F+2]=x.x,B.array[F+3]=x.y,
-B.array[F+4]=y.x,B.array[F+5]=y.y,B.array[F+6]=C.x,B.array[F+7]=C.y,F+=8}else{if(B.boundTo==="faces"){u=0;for(H=q.length;u<H;u++)y=x=z=W=B.value[q[u]],B.array[F]=z.x,B.array[F+1]=z.y,B.array[F+2]=x.x,B.array[F+3]=x.y,B.array[F+4]=y.x,B.array[F+5]=y.y,F+=6;u=0;for(H=t.length;u<H;u++)C=y=x=z=W=B.value[t[u]],B.array[F]=z.x,B.array[F+1]=z.y,B.array[F+2]=x.x,B.array[F+3]=x.y,B.array[F+4]=y.x,B.array[F+5]=y.y,B.array[F+6]=C.x,B.array[F+7]=C.y,F+=8}}else if(B.size===3)if(N=B.type==="c"?["r","g","b"]:["x",
-"y","z"],B.boundTo===void 0||B.boundTo==="vertices"){u=0;for(H=q.length;u<H;u++)C=ia[q[u]],z=B.value[C.a],x=B.value[C.b],y=B.value[C.c],B.array[F]=z[N[0]],B.array[F+1]=z[N[1]],B.array[F+2]=z[N[2]],B.array[F+3]=x[N[0]],B.array[F+4]=x[N[1]],B.array[F+5]=x[N[2]],B.array[F+6]=y[N[0]],B.array[F+7]=y[N[1]],B.array[F+8]=y[N[2]],F+=9;u=0;for(H=t.length;u<H;u++)C=ia[t[u]],z=B.value[C.a],x=B.value[C.b],y=B.value[C.c],C=B.value[C.d],B.array[F]=z[N[0]],B.array[F+1]=z[N[1]],B.array[F+2]=z[N[2]],B.array[F+3]=x[N[0]],
-B.array[F+4]=x[N[1]],B.array[F+5]=x[N[2]],B.array[F+6]=y[N[0]],B.array[F+7]=y[N[1]],B.array[F+8]=y[N[2]],B.array[F+9]=C[N[0]],B.array[F+10]=C[N[1]],B.array[F+11]=C[N[2]],F+=12}else{if(B.boundTo==="faces"){u=0;for(H=q.length;u<H;u++)y=x=z=W=B.value[q[u]],B.array[F]=z[N[0]],B.array[F+1]=z[N[1]],B.array[F+2]=z[N[2]],B.array[F+3]=x[N[0]],B.array[F+4]=x[N[1]],B.array[F+5]=x[N[2]],B.array[F+6]=y[N[0]],B.array[F+7]=y[N[1]],B.array[F+8]=y[N[2]],F+=9;u=0;for(H=t.length;u<H;u++)C=y=x=z=W=B.value[t[u]],B.array[F]=
-z[N[0]],B.array[F+1]=z[N[1]],B.array[F+2]=z[N[2]],B.array[F+3]=x[N[0]],B.array[F+4]=x[N[1]],B.array[F+5]=x[N[2]],B.array[F+6]=y[N[0]],B.array[F+7]=y[N[1]],B.array[F+8]=y[N[2]],B.array[F+9]=C[N[0]],B.array[F+10]=C[N[1]],B.array[F+11]=C[N[2]],F+=12}}else if(B.size===4)if(B.boundTo===void 0||B.boundTo==="vertices"){u=0;for(H=q.length;u<H;u++)C=ia[q[u]],z=B.value[C.a],x=B.value[C.b],y=B.value[C.c],B.array[F]=z.x,B.array[F+1]=z.y,B.array[F+2]=z.z,B.array[F+3]=z.w,B.array[F+4]=x.x,B.array[F+5]=x.y,B.array[F+
-6]=x.z,B.array[F+7]=x.w,B.array[F+8]=y.x,B.array[F+9]=y.y,B.array[F+10]=y.z,B.array[F+11]=y.w,F+=12;u=0;for(H=t.length;u<H;u++)C=ia[t[u]],z=B.value[C.a],x=B.value[C.b],y=B.value[C.c],C=B.value[C.d],B.array[F]=z.x,B.array[F+1]=z.y,B.array[F+2]=z.z,B.array[F+3]=z.w,B.array[F+4]=x.x,B.array[F+5]=x.y,B.array[F+6]=x.z,B.array[F+7]=x.w,B.array[F+8]=y.x,B.array[F+9]=y.y,B.array[F+10]=y.z,B.array[F+11]=y.w,B.array[F+12]=C.x,B.array[F+13]=C.y,B.array[F+14]=C.z,B.array[F+15]=C.w,F+=16}else if(B.boundTo==="faces"){u=
-0;for(H=q.length;u<H;u++)y=x=z=W=B.value[q[u]],B.array[F]=z.x,B.array[F+1]=z.y,B.array[F+2]=z.z,B.array[F+3]=z.w,B.array[F+4]=x.x,B.array[F+5]=x.y,B.array[F+6]=x.z,B.array[F+7]=x.w,B.array[F+8]=y.x,B.array[F+9]=y.y,B.array[F+10]=y.z,B.array[F+11]=y.w,F+=12;u=0;for(H=t.length;u<H;u++)C=y=x=z=W=B.value[t[u]],B.array[F]=z.x,B.array[F+1]=z.y,B.array[F+2]=z.z,B.array[F+3]=z.w,B.array[F+4]=x.x,B.array[F+5]=x.y,B.array[F+6]=x.z,B.array[F+7]=x.w,B.array[F+8]=y.x,B.array[F+9]=y.y,B.array[F+10]=y.z,B.array[F+
-11]=y.w,B.array[F+12]=C.x,B.array[F+13]=C.y,B.array[F+14]=C.z,B.array[F+15]=C.w,F+=16}j.bindBuffer(j.ARRAY_BUFFER,B.buffer);j.bufferData(j.ARRAY_BUFFER,B.array,o)}}U&&(delete l.__inittedArrays,delete l.__colorArray,delete l.__normalArray,delete l.__tangentArray,delete l.__uvArray,delete l.__uv2Array,delete l.__faceArray,delete l.__vertexArray,delete l.__lineArray,delete l.__skinVertexAArray,delete l.__skinVertexBArray,delete l.__skinIndexArray,delete l.__skinWeightArray)}f.__dirtyVertices=!1;f.__dirtyMorphTargets=
-!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyColors=!1;f.__dirtyTangents=!1;h.attributes&&r(h)}else if(v instanceof THREE.Ribbon){if(f.__dirtyVertices||f.__dirtyColors){h=f;v=j.DYNAMIC_DRAW;u=i=u=U=U=void 0;H=h.vertices;k=h.colors;s=H.length;l=k.length;q=h.__vertexArray;o=h.__colorArray;t=h.__dirtyColors;if(h.__dirtyVertices){for(U=0;U<s;U++)u=H[U].position,i=U*3,q[i]=u.x,q[i+1]=u.y,q[i+2]=u.z;j.bindBuffer(j.ARRAY_BUFFER,h.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,q,
-v)}if(t){for(U=0;U<l;U++)u=k[U],i=U*3,o[i]=u.r,o[i+1]=u.g,o[i+2]=u.b;j.bindBuffer(j.ARRAY_BUFFER,h.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,o,v)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(v instanceof THREE.Line){h=b(v,l);o=h.attributes&&n(h);if(f.__dirtyVertices||f.__dirtyColors||o){v=f;i=j.DYNAMIC_DRAW;s=k=ba=H=ia=void 0;H=v.vertices;l=v.colors;s=H.length;o=l.length;q=v.__vertexArray;U=v.__colorArray;t=v.__dirtyColors;u=v.__webglCustomAttributesList;Y=T=fa=N=ba=ia=void 0;if(v.__dirtyVertices){for(ia=
-0;ia<s;ia++)ba=H[ia].position,k=ia*3,q[k]=ba.x,q[k+1]=ba.y,q[k+2]=ba.z;j.bindBuffer(j.ARRAY_BUFFER,v.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,q,i)}if(t){for(H=0;H<o;H++)s=l[H],k=H*3,U[k]=s.r,U[k+1]=s.g,U[k+2]=s.b;j.bindBuffer(j.ARRAY_BUFFER,v.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,U,i)}if(u){ia=0;for(ba=u.length;ia<ba;ia++)if(Y=u[ia],Y.needsUpdate&&(Y.boundTo===void 0||Y.boundTo==="vertices")){k=0;fa=Y.value.length;if(Y.size===1)for(N=0;N<fa;N++)Y.array[N]=Y.value[N];else if(Y.size===
-2)for(N=0;N<fa;N++)T=Y.value[N],Y.array[k]=T.x,Y.array[k+1]=T.y,k+=2;else if(Y.size===3)if(Y.type==="c")for(N=0;N<fa;N++)T=Y.value[N],Y.array[k]=T.r,Y.array[k+1]=T.g,Y.array[k+2]=T.b,k+=3;else for(N=0;N<fa;N++)T=Y.value[N],Y.array[k]=T.x,Y.array[k+1]=T.y,Y.array[k+2]=T.z,k+=3;else if(Y.size===4)for(N=0;N<fa;N++)T=Y.value[N],Y.array[k]=T.x,Y.array[k+1]=T.y,Y.array[k+2]=T.z,Y.array[k+3]=T.w,k+=4;j.bindBuffer(j.ARRAY_BUFFER,Y.buffer);j.bufferData(j.ARRAY_BUFFER,Y.array,i)}}}f.__dirtyVertices=!1;f.__dirtyColors=
-!1;h.attributes&&r(h)}else if(v instanceof THREE.ParticleSystem)h=b(v,l),o=h.attributes&&n(h),(f.__dirtyVertices||f.__dirtyColors||v.sortParticles||o)&&d(f,j.DYNAMIC_DRAW,v),f.__dirtyVertices=!1,f.__dirtyColors=!1,h.attributes&&r(h)};this.initMaterial=function(a,b,c,d){var e,f,g,h;a instanceof THREE.MeshDepthMaterial?h="depth":a instanceof THREE.MeshNormalMaterial?h="normal":a instanceof THREE.MeshBasicMaterial?h="basic":a instanceof THREE.MeshLambertMaterial?h="lambert":a instanceof THREE.MeshPhongMaterial?
-h="phong":a instanceof THREE.LineBasicMaterial?h="basic":a instanceof THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var i=THREE.ShaderLib[h];a.uniforms=THREE.UniformsUtils.clone(i.uniforms);a.vertexShader=i.vertexShader;a.fragmentShader=i.fragmentShader}var k,l,m;k=m=i=0;for(l=b.length;k<l;k++)g=b[k],g instanceof THREE.SpotLight&&m++,g instanceof THREE.DirectionalLight&&m++,g instanceof THREE.PointLight&&i++;i+m<=y?k=m:(k=Math.ceil(y*m/(i+m)),i=y-k);g={directional:k,point:i};i=m=0;for(k=
-b.length;i<k;i++)l=b[i],l instanceof THREE.SpotLight&&l.castShadow&&m++;var n=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)n=d.bones.length;var o;a:{k=a.fragmentShader;l=a.vertexShader;var i=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:g.directional,maxPointLights:g.point,maxBones:n,
-shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:m,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel},u,d=[];h?d.push(h):(d.push(k),d.push(l));for(u in c)d.push(u),d.push(c[u]);h=d.join();u=0;for(d=ca.length;u<d;u++)if(ca[u].code===h){o=ca[u].program;break a}u=j.createProgram();d=[sa?"#define VERTEX_TEXTURES":"",L.gammaInput?"#define GAMMA_INPUT":"",L.gammaOutput?"#define GAMMA_OUTPUT":
-"",L.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":
-"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+function(a,b){l(a,b)};this.render=function(a,b,c,d){var e,g,m,n,p=a.lights,s=a.fog;Q=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&l(a,b);L.info.render.calls=0;L.info.render.vertices=0;L.info.render.faces=0;b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(J);b.projectionMatrix.flattenToArray(aa);
+ba.multiply(b.projectionMatrix,b.matrixWorldInverse);f(ba);D(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);n=a.__webglObjects;d=0;for(e=n.length;d<e;d++)if(g=n[d],m=g.object,g.render=!1,m.visible&&(!(m instanceof THREE.Mesh)||!m.frustumCulled||h(m))){m.matrixWorld.flattenToArray(m._objectMatrixArray);t(m,b,!0);var q=g,v=q.object,u=q.buffer,B=void 0,B=B=void 0,B=v.material;if(B instanceof THREE.MeshFaceMaterial){if(B=u.materialIndex,B>=0)B=v.geometry.materials[B],
+B.transparent?(q.transparent=B,q.opaque=null):(q.opaque=B,q.transparent=null)}else if(B)B.transparent?(q.transparent=B,q.opaque=null):(q.opaque=B,q.transparent=null);g.render=!0;if(this.sortObjects)m.renderDepth?g.z=m.renderDepth:(ea.copy(m.position),ba.multiplyVector3(ea),g.z=ea.z)}this.sortObjects&&n.sort(i);n=a.__webglObjectsImmediate;d=0;for(e=n.length;d<e;d++)if(g=n[d],m=g.object,m.visible)m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),t(m,b,!0),m=g.object.material,m.transparent?
+(g.transparent=m,g.opaque=null):(g.opaque=m,g.transparent=null);a.overrideMaterial?(C(a.overrideMaterial.blending),r(a.overrideMaterial.depthTest),z(a.overrideMaterial.depthWrite),w(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),k(a.__webglObjects,!1,"",b,p,s,!0,a.overrideMaterial),o(a.__webglObjectsImmediate,"",b,p,s,!1,a.overrideMaterial)):(C(THREE.NormalBlending),k(a.__webglObjects,!0,"opaque",b,p,s,!1),o(a.__webglObjectsImmediate,
+"opaque",b,p,s,!1),k(a.__webglObjects,!1,"transparent",b,p,s,!0),o(a.__webglObjectsImmediate,"transparent",b,p,s,!0));if(a.__webglSprites.length){m=N.attributes;p=N.uniforms;s=U/xa;d=[];e=xa*0.5;n=U*0.5;g=!0;j.useProgram(N.program);fa=N.program;Y=$=ja=-1;ua||(j.enableVertexAttribArray(N.attributes.position),j.enableVertexAttribArray(N.attributes.uv),ua=!0);j.disable(j.CULL_FACE);j.enable(j.BLEND);j.depthMask(!0);j.bindBuffer(j.ARRAY_BUFFER,N.vertexBuffer);j.vertexAttribPointer(m.position,2,j.FLOAT,
+!1,16,0);j.vertexAttribPointer(m.uv,2,j.FLOAT,!1,16,8);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,N.elementBuffer);j.uniformMatrix4fv(p.projectionMatrix,!1,aa);j.activeTexture(j.TEXTURE0);j.uniform1i(p.map,0);m=0;for(q=a.__webglSprites.length;m<q;m++)if(v=a.__webglSprites[m],v.visible&&v.opacity!==0)v.useScreenCoordinates?v.z=-v.position.z:(v._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,v.matrixWorld,v._modelViewMatrixArray),v.z=-v._modelViewMatrix.n34);a.__webglSprites.sort(i);m=0;for(q=a.__webglSprites.length;m<
+q;m++)v=a.__webglSprites[m],v.visible&&v.opacity!==0&&v.map&&v.map.image&&v.map.image.width&&(v.useScreenCoordinates?(j.uniform1i(p.useScreenCoordinates,1),j.uniform3f(p.screenPosition,(v.position.x-e)/e,(n-v.position.y)/n,Math.max(0,Math.min(1,v.position.z)))):(j.uniform1i(p.useScreenCoordinates,0),j.uniform1i(p.affectedByDistance,v.affectedByDistance?1:0),j.uniformMatrix4fv(p.modelViewMatrix,!1,v._modelViewMatrixArray)),b=v.map.image.width/(v.scaleByViewport?U:1),d[0]=b*s*v.scale.x,d[1]=b*v.scale.y,
+j.uniform2f(p.uvScale,v.uvScale.x,v.uvScale.y),j.uniform2f(p.uvOffset,v.uvOffset.x,v.uvOffset.y),j.uniform2f(p.alignment,v.alignment.x,v.alignment.y),j.uniform1f(p.opacity,v.opacity),j.uniform3f(p.color,v.color.r,v.color.g,v.color.b),j.uniform1f(p.rotation,v.rotation),j.uniform2fv(p.scale,d),v.mergeWith3D&&!g?(j.enable(j.DEPTH_TEST),g=!0):!v.mergeWith3D&&g&&(j.disable(j.DEPTH_TEST),g=!1),C(v.blending),G(v.map,0),j.drawElements(j.TRIANGLES,6,j.UNSIGNED_SHORT,0));j.enable(j.CULL_FACE);j.enable(j.DEPTH_TEST);
+j.depthMask(la)}c&&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.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[];for(;a.__objectsAdded.length;){var e=
+a.__objectsAdded[0],g=a,f=void 0,h=void 0,i=void 0;if(!e.__webglInit)if(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=new Float32Array(16),e._objectMatrixArray=new Float32Array(16),e.matrixWorld.flattenToArray(e._objectMatrixArray),e instanceof THREE.Mesh){h=e.geometry;if(h.geometryGroups===void 0){var i=h,k=void 0,l=void 0,o=void 0,U=void 0,v=void 0,q=void 0,ba=void 0,r={},t=i.morphTargets.length;i.geometryGroups={};k=0;for(l=
+i.faces.length;k<l;k++)o=i.faces[k],U=o.materialIndex,q=U!==void 0?U:-1,r[q]===void 0&&(r[q]={hash:q,counter:0}),ba=r[q].hash+"_"+r[q].counter,i.geometryGroups[ba]===void 0&&(i.geometryGroups[ba]={faces3:[],faces4:[],materialIndex:U,vertices:0,numMorphTargets:t}),v=o instanceof THREE.Face3?3:4,i.geometryGroups[ba].vertices+v>65535&&(r[q].counter+=1,ba=r[q].hash+"_"+r[q].counter,i.geometryGroups[ba]===void 0&&(i.geometryGroups[ba]={faces3:[],faces4:[],materialIndex:U,vertices:0,numMorphTargets:t})),
+o instanceof THREE.Face3?i.geometryGroups[ba].faces3.push(k):i.geometryGroups[ba].faces4.push(k),i.geometryGroups[ba].vertices+=v;i.geometryGroupsList=[];k=void 0;for(k in i.geometryGroups)i.geometryGroups[k].id=ca++,i.geometryGroupsList.push(i.geometryGroups[k])}for(f in h.geometryGroups)if(i=h.geometryGroups[f],!i.__webglVertexBuffer){k=i;k.__webglVertexBuffer=j.createBuffer();k.__webglNormalBuffer=j.createBuffer();k.__webglTangentBuffer=j.createBuffer();k.__webglColorBuffer=j.createBuffer();k.__webglUVBuffer=
+j.createBuffer();k.__webglUV2Buffer=j.createBuffer();k.__webglSkinVertexABuffer=j.createBuffer();k.__webglSkinVertexBBuffer=j.createBuffer();k.__webglSkinIndicesBuffer=j.createBuffer();k.__webglSkinWeightsBuffer=j.createBuffer();k.__webglFaceBuffer=j.createBuffer();k.__webglLineBuffer=j.createBuffer();if(k.numMorphTargets){o=l=void 0;k.__webglMorphTargetsBuffers=[];l=0;for(o=k.numMorphTargets;l<o;l++)k.__webglMorphTargetsBuffers.push(j.createBuffer())}L.info.memory.geometries++;U=e;v=U.geometry;l=
+i.faces3;q=i.faces4;k=l.length*3+q.length*4;o=l.length*1+q.length*2;q=l.length*3+q.length*4;l=b(U,i);ba=l.map||l.lightMap||l instanceof THREE.ShaderMaterial?!0:!1;r=l instanceof THREE.MeshBasicMaterial&&!l.envMap||l instanceof THREE.MeshDepthMaterial?!1:l&&l.shading!==void 0&&l.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;t=l.vertexColors?l.vertexColors:!1;i.__vertexArray=new Float32Array(k*3);if(r)i.__normalArray=new Float32Array(k*3);if(v.hasTangents)i.__tangentArray=new Float32Array(k*
+4);if(t)i.__colorArray=new Float32Array(k*3);if(ba){if(v.faceUvs.length>0||v.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*2);if(v.faceUvs.length>1||v.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(k*2)}if(U.geometry.skinWeights.length&&U.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4),i.__skinVertexBArray=new Float32Array(k*4),i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray=new Float32Array(k*4);i.__faceArray=new Uint16Array(o*3);i.__lineArray=new Uint16Array(q*
+2);if(i.numMorphTargets){i.__morphTargetsArrays=[];U=0;for(v=i.numMorphTargets;U<v;U++)i.__morphTargetsArrays.push(new Float32Array(k*3))}i.__needsSmoothNormals=r===THREE.SmoothShading;i.__uvType=ba;i.__vertexColorType=t;i.__normalType=r;i.__webglFaceCount=o*3;i.__webglLineCount=q*2;if(l.attributes){if(i.__webglCustomAttributesList===void 0)i.__webglCustomAttributesList=[];o=void 0;for(o in l.attributes){var U=l.attributes[o],v={},u;for(u in U)v[u]=U[u];if(!v.__webglInitialized||v.createUniqueBuffers)v.__webglInitialized=
+!0,q=1,v.type==="v2"?q=2:v.type==="v3"?q=3:v.type==="v4"?q=4:v.type==="c"&&(q=3),v.size=q,v.array=new Float32Array(k*q),v.buffer=j.createBuffer(),v.buffer.belongsToAttribute=o,U.needsUpdate=!0,v.__original=U;i.__webglCustomAttributesList.push(v)}}i.__inittedArrays=!0;h.__dirtyVertices=!0;h.__dirtyMorphTargets=!0;h.__dirtyElements=!0;h.__dirtyUvs=!0;h.__dirtyNormals=!0;h.__dirtyTangents=!0;h.__dirtyColors=!0}}else if(e instanceof THREE.Ribbon){if(h=e.geometry,!h.__webglVertexBuffer)i=h,i.__webglVertexBuffer=
+j.createBuffer(),i.__webglColorBuffer=j.createBuffer(),L.info.memory.geometries++,i=h,k=i.vertices.length,i.__vertexArray=new Float32Array(k*3),i.__colorArray=new Float32Array(k*3),i.__webglVertexCount=k,h.__dirtyVertices=!0,h.__dirtyColors=!0}else if(e instanceof THREE.Line){if(h=e.geometry,!h.__webglVertexBuffer)i=h,i.__webglVertexBuffer=j.createBuffer(),i.__webglColorBuffer=j.createBuffer(),L.info.memory.geometries++,i=h,k=e,l=i.vertices.length,i.__vertexArray=new Float32Array(l*3),i.__colorArray=
+new Float32Array(l*3),i.__webglLineCount=l,c(i,k),h.__dirtyVertices=!0,h.__dirtyColors=!0}else if(e instanceof THREE.ParticleSystem&&(h=e.geometry,!h.__webglVertexBuffer))i=h,i.__webglVertexBuffer=j.createBuffer(),i.__webglColorBuffer=j.createBuffer(),L.info.geometries++,i=h,k=e,l=i.vertices.length,i.__vertexArray=new Float32Array(l*3),i.__colorArray=new Float32Array(l*3),i.__sortArray=[],i.__webglParticleCount=l,c(i,k),h.__dirtyVertices=!0,h.__dirtyColors=!0;if(!e.__webglActive){if(e instanceof THREE.Mesh)for(f in h=
+e.geometry,h.geometryGroups)i=h.geometryGroups[f],p(g.__webglObjects,i,e);else e instanceof THREE.Ribbon||e instanceof THREE.Line||e instanceof THREE.ParticleSystem?(h=e.geometry,p(g.__webglObjects,h,e)):THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes||e.immediateRenderCallback?g.__webglObjectsImmediate.push({object:e,opaque:null,transparent:null}):e instanceof THREE.Sprite&&g.__webglSprites.push(e);e.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){e=
+a.__objectsRemoved[0];g=a;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)m(g.__webglObjects,e);else if(e instanceof THREE.Sprite){g=g.__webglSprites;f=e;for(h=g.length-1;h>=0;h--)g[h]===f&&g.splice(h,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&m(g.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(g=a.__webglObjects.length;e<g;e++)if(u=a.__webglObjects[e].object,f=u.geometry,
+h=o=l=void 0,u instanceof THREE.Mesh){i=0;for(k=f.geometryGroupsList.length;i<k;i++)if(l=f.geometryGroupsList[i],h=b(u,l),o=h.attributes&&n(h),f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||o)if(o=j.DYNAMIC_DRAW,U=!f.dynamic,l.__inittedArrays){var z=q=v=void 0,B=void 0,aa=void 0,D=void 0,w=void 0,C=void 0,G=void 0,O=void 0,ja=void 0,F=z=D=void 0,x=void 0,J=void 0,y=void 0,ea=B=void 0,H=void 0,N=B=G=ja=void 0,I=void 0,
+K=y=J=x=w=void 0,V=B=y=J=x=K=y=J=x=K=y=J=x=void 0,$=void 0,ha=D=void 0,P=void 0,Q=void 0,la=void 0,R=void 0,M=F=Q=$=0,Y=0,T=V=z=0,S=w=ea=0,E=0,W=void 0,S=l.__vertexArray,P=l.__uvArray,E=l.__uv2Array,ha=l.__normalArray,aa=l.__tangentArray,H=l.__colorArray,N=l.__skinVertexAArray,I=l.__skinVertexBArray,C=l.__skinIndexArray,X=l.__skinWeightArray,K=l.__morphTargetsArrays,ba=l.__webglCustomAttributesList,A=void 0,A=l.__faceArray,W=l.__lineArray,va=l.__needsSmoothNormals,ja=l.__vertexColorType,O=l.__uvType,
+D=l.__normalType,G=u.geometry,Z=G.__dirtyElements,ra=G.__dirtyUvs,ka=G.__dirtyNormals,ia=G.__dirtyTangents,fa=G.__dirtyColors,la=G.__dirtyMorphTargets,R=G.vertices,r=l.faces3,t=l.faces4,ga=G.faces,na=G.faceVertexUvs[0],qa=G.faceVertexUvs[1],ma=G.skinVerticesA,ta=G.skinVerticesB,sa=G.skinIndices,pa=G.skinWeights,ua=G.morphTargets;if(G.__dirtyVertices){v=0;for(q=r.length;v<q;v++)B=ga[r[v]],x=R[B.a].position,J=R[B.b].position,y=R[B.c].position,S[Q]=x.x,S[Q+1]=x.y,S[Q+2]=x.z,S[Q+3]=J.x,S[Q+4]=J.y,S[Q+
+5]=J.z,S[Q+6]=y.x,S[Q+7]=y.y,S[Q+8]=y.z,Q+=9;v=0;for(q=t.length;v<q;v++)B=ga[t[v]],x=R[B.a].position,J=R[B.b].position,y=R[B.c].position,B=R[B.d].position,S[Q]=x.x,S[Q+1]=x.y,S[Q+2]=x.z,S[Q+3]=J.x,S[Q+4]=J.y,S[Q+5]=J.z,S[Q+6]=y.x,S[Q+7]=y.y,S[Q+8]=y.z,S[Q+9]=B.x,S[Q+10]=B.y,S[Q+11]=B.z,Q+=12;j.bindBuffer(j.ARRAY_BUFFER,l.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,S,o)}if(la){Q=0;for(la=ua.length;Q<la;Q++){v=S=0;for(q=r.length;v<q;v++)B=ga[r[v]],x=ua[Q].vertices[B.a].position,J=ua[Q].vertices[B.b].position,
+y=ua[Q].vertices[B.c].position,R=K[Q],R[S]=x.x,R[S+1]=x.y,R[S+2]=x.z,R[S+3]=J.x,R[S+4]=J.y,R[S+5]=J.z,R[S+6]=y.x,R[S+7]=y.y,R[S+8]=y.z,S+=9;v=0;for(q=t.length;v<q;v++)B=ga[t[v]],x=ua[Q].vertices[B.a].position,J=ua[Q].vertices[B.b].position,y=ua[Q].vertices[B.c].position,B=ua[Q].vertices[B.d].position,R=K[Q],R[S]=x.x,R[S+1]=x.y,R[S+2]=x.z,R[S+3]=J.x,R[S+4]=J.y,R[S+5]=J.z,R[S+6]=y.x,R[S+7]=y.y,R[S+8]=y.z,R[S+9]=B.x,R[S+10]=B.y,R[S+11]=B.z,S+=12;j.bindBuffer(j.ARRAY_BUFFER,l.__webglMorphTargetsBuffers[Q]);
+j.bufferData(j.ARRAY_BUFFER,K[Q],o)}}if(pa.length){v=0;for(q=r.length;v<q;v++)B=ga[r[v]],x=pa[B.a],J=pa[B.b],y=pa[B.c],X[w]=x.x,X[w+1]=x.y,X[w+2]=x.z,X[w+3]=x.w,X[w+4]=J.x,X[w+5]=J.y,X[w+6]=J.z,X[w+7]=J.w,X[w+8]=y.x,X[w+9]=y.y,X[w+10]=y.z,X[w+11]=y.w,x=sa[B.a],J=sa[B.b],y=sa[B.c],C[w]=x.x,C[w+1]=x.y,C[w+2]=x.z,C[w+3]=x.w,C[w+4]=J.x,C[w+5]=J.y,C[w+6]=J.z,C[w+7]=J.w,C[w+8]=y.x,C[w+9]=y.y,C[w+10]=y.z,C[w+11]=y.w,x=ma[B.a],J=ma[B.b],y=ma[B.c],N[w]=x.x,N[w+1]=x.y,N[w+2]=x.z,N[w+3]=1,N[w+4]=J.x,N[w+5]=
+J.y,N[w+6]=J.z,N[w+7]=1,N[w+8]=y.x,N[w+9]=y.y,N[w+10]=y.z,N[w+11]=1,x=ta[B.a],J=ta[B.b],y=ta[B.c],I[w]=x.x,I[w+1]=x.y,I[w+2]=x.z,I[w+3]=1,I[w+4]=J.x,I[w+5]=J.y,I[w+6]=J.z,I[w+7]=1,I[w+8]=y.x,I[w+9]=y.y,I[w+10]=y.z,I[w+11]=1,w+=12;v=0;for(q=t.length;v<q;v++)B=ga[t[v]],x=pa[B.a],J=pa[B.b],y=pa[B.c],K=pa[B.d],X[w]=x.x,X[w+1]=x.y,X[w+2]=x.z,X[w+3]=x.w,X[w+4]=J.x,X[w+5]=J.y,X[w+6]=J.z,X[w+7]=J.w,X[w+8]=y.x,X[w+9]=y.y,X[w+10]=y.z,X[w+11]=y.w,X[w+12]=K.x,X[w+13]=K.y,X[w+14]=K.z,X[w+15]=K.w,x=sa[B.a],J=sa[B.b],
+y=sa[B.c],K=sa[B.d],C[w]=x.x,C[w+1]=x.y,C[w+2]=x.z,C[w+3]=x.w,C[w+4]=J.x,C[w+5]=J.y,C[w+6]=J.z,C[w+7]=J.w,C[w+8]=y.x,C[w+9]=y.y,C[w+10]=y.z,C[w+11]=y.w,C[w+12]=K.x,C[w+13]=K.y,C[w+14]=K.z,C[w+15]=K.w,x=ma[B.a],J=ma[B.b],y=ma[B.c],K=ma[B.d],N[w]=x.x,N[w+1]=x.y,N[w+2]=x.z,N[w+3]=1,N[w+4]=J.x,N[w+5]=J.y,N[w+6]=J.z,N[w+7]=1,N[w+8]=y.x,N[w+9]=y.y,N[w+10]=y.z,N[w+11]=1,N[w+12]=K.x,N[w+13]=K.y,N[w+14]=K.z,N[w+15]=1,x=ta[B.a],J=ta[B.b],y=ta[B.c],B=ta[B.d],I[w]=x.x,I[w+1]=x.y,I[w+2]=x.z,I[w+3]=1,I[w+4]=J.x,
+I[w+5]=J.y,I[w+6]=J.z,I[w+7]=1,I[w+8]=y.x,I[w+9]=y.y,I[w+10]=y.z,I[w+11]=1,I[w+12]=B.x,I[w+13]=B.y,I[w+14]=B.z,I[w+15]=1,w+=16;w>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,N,o),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,I,o),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,C,o),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,X,o))}if(fa&&ja){v=
+0;for(q=r.length;v<q;v++)B=ga[r[v]],w=B.vertexColors,C=B.color,w.length===3&&ja===THREE.VertexColors?(B=w[0],N=w[1],I=w[2]):I=N=B=C,H[ea]=B.r,H[ea+1]=B.g,H[ea+2]=B.b,H[ea+3]=N.r,H[ea+4]=N.g,H[ea+5]=N.b,H[ea+6]=I.r,H[ea+7]=I.g,H[ea+8]=I.b,ea+=9;v=0;for(q=t.length;v<q;v++)B=ga[t[v]],w=B.vertexColors,C=B.color,w.length===4&&ja===THREE.VertexColors?(B=w[0],N=w[1],I=w[2],w=w[3]):w=I=N=B=C,H[ea]=B.r,H[ea+1]=B.g,H[ea+2]=B.b,H[ea+3]=N.r,H[ea+4]=N.g,H[ea+5]=N.b,H[ea+6]=I.r,H[ea+7]=I.g,H[ea+8]=I.b,H[ea+9]=
+w.r,H[ea+10]=w.g,H[ea+11]=w.b,ea+=12;ea>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,H,o))}if(ia&&G.hasTangents){v=0;for(q=r.length;v<q;v++)B=ga[r[v]],G=B.vertexTangents,ea=G[0],H=G[1],ja=G[2],aa[V]=ea.x,aa[V+1]=ea.y,aa[V+2]=ea.z,aa[V+3]=ea.w,aa[V+4]=H.x,aa[V+5]=H.y,aa[V+6]=H.z,aa[V+7]=H.w,aa[V+8]=ja.x,aa[V+9]=ja.y,aa[V+10]=ja.z,aa[V+11]=ja.w,V+=12;v=0;for(q=t.length;v<q;v++)B=ga[t[v]],G=B.vertexTangents,ea=G[0],H=G[1],ja=G[2],G=G[3],aa[V]=ea.x,aa[V+1]=ea.y,aa[V+
+2]=ea.z,aa[V+3]=ea.w,aa[V+4]=H.x,aa[V+5]=H.y,aa[V+6]=H.z,aa[V+7]=H.w,aa[V+8]=ja.x,aa[V+9]=ja.y,aa[V+10]=ja.z,aa[V+11]=ja.w,aa[V+12]=G.x,aa[V+13]=G.y,aa[V+14]=G.z,aa[V+15]=G.w,V+=16;j.bindBuffer(j.ARRAY_BUFFER,l.__webglTangentBuffer);j.bufferData(j.ARRAY_BUFFER,aa,o)}if(ka&&D){v=0;for(q=r.length;v<q;v++)if(B=ga[r[v]],aa=B.vertexNormals,D=B.normal,aa.length===3&&va)for(V=0;V<3;V++)D=aa[V],ha[z]=D.x,ha[z+1]=D.y,ha[z+2]=D.z,z+=3;else for(V=0;V<3;V++)ha[z]=D.x,ha[z+1]=D.y,ha[z+2]=D.z,z+=3;v=0;for(q=t.length;v<
+q;v++)if(B=ga[t[v]],aa=B.vertexNormals,D=B.normal,aa.length===4&&va)for(V=0;V<4;V++)D=aa[V],ha[z]=D.x,ha[z+1]=D.y,ha[z+2]=D.z,z+=3;else for(V=0;V<4;V++)ha[z]=D.x,ha[z+1]=D.y,ha[z+2]=D.z,z+=3;j.bindBuffer(j.ARRAY_BUFFER,l.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,ha,o)}if(ra&&na&&O){v=0;for(q=r.length;v<q;v++)if(z=r[v],z=na[z],z!==void 0)for(V=0;V<3;V++)ha=z[V],P[F]=ha.u,P[F+1]=ha.v,F+=2;v=0;for(q=t.length;v<q;v++)if(z=t[v],z=na[z],z!==void 0)for(V=0;V<4;V++)ha=z[V],P[F]=ha.u,P[F+1]=ha.v,F+=
+2;F>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,P,o))}if(ra&&qa&&O){v=0;for(q=r.length;v<q;v++)if(z=r[v],F=qa[z],F!==void 0)for(V=0;V<3;V++)P=F[V],E[M]=P.u,E[M+1]=P.v,M+=2;v=0;for(q=t.length;v<q;v++)if(z=t[v],F=qa[z],F!==void 0)for(V=0;V<4;V++)P=F[V],E[M]=P.u,E[M+1]=P.v,M+=2;M>0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,E,o))}if(Z){v=0;for(q=r.length;v<q;v++)A[Y]=$,A[Y+1]=$+1,A[Y+2]=$+2,Y+=3,W[T]=$,W[T+1]=$+1,W[T+2]=$,W[T+3]=$+
+2,W[T+4]=$+1,W[T+5]=$+2,T+=6,$+=3;v=0;for(q=t.length;v<q;v++)A[Y]=$,A[Y+1]=$+1,A[Y+2]=$+3,A[Y+3]=$+1,A[Y+4]=$+2,A[Y+5]=$+3,Y+=6,W[T]=$,W[T+1]=$+1,W[T+2]=$,W[T+3]=$+3,W[T+4]=$+1,W[T+5]=$+2,W[T+6]=$+2,W[T+7]=$+3,T+=8,$+=4;j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,l.__webglFaceBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,A,o);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,l.__webglLineBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,W,o)}if(ba){V=0;for($=ba.length;V<$;V++)if(A=ba[V],A.__original.needsUpdate){E=0;if(A.size===
+1)if(A.boundTo===void 0||A.boundTo==="vertices"){v=0;for(q=r.length;v<q;v++)B=ga[r[v]],A.array[E]=A.value[B.a],A.array[E+1]=A.value[B.b],A.array[E+2]=A.value[B.c],E+=3;v=0;for(q=t.length;v<q;v++)B=ga[t[v]],A.array[E]=A.value[B.a],A.array[E+1]=A.value[B.b],A.array[E+2]=A.value[B.c],A.array[E+3]=A.value[B.d],E+=4}else{if(A.boundTo==="faces"){v=0;for(q=r.length;v<q;v++)W=A.value[r[v]],A.array[E]=W,A.array[E+1]=W,A.array[E+2]=W,E+=3;v=0;for(q=t.length;v<q;v++)W=A.value[t[v]],A.array[E]=W,A.array[E+1]=
+W,A.array[E+2]=W,A.array[E+3]=W,E+=4}}else if(A.size===2)if(A.boundTo===void 0||A.boundTo==="vertices"){v=0;for(q=r.length;v<q;v++)B=ga[r[v]],x=A.value[B.a],J=A.value[B.b],y=A.value[B.c],A.array[E]=x.x,A.array[E+1]=x.y,A.array[E+2]=J.x,A.array[E+3]=J.y,A.array[E+4]=y.x,A.array[E+5]=y.y,E+=6;v=0;for(q=t.length;v<q;v++)B=ga[t[v]],x=A.value[B.a],J=A.value[B.b],y=A.value[B.c],B=A.value[B.d],A.array[E]=x.x,A.array[E+1]=x.y,A.array[E+2]=J.x,A.array[E+3]=J.y,A.array[E+4]=y.x,A.array[E+5]=y.y,A.array[E+6]=
+B.x,A.array[E+7]=B.y,E+=8}else{if(A.boundTo==="faces"){v=0;for(q=r.length;v<q;v++)y=J=x=W=A.value[r[v]],A.array[E]=x.x,A.array[E+1]=x.y,A.array[E+2]=J.x,A.array[E+3]=J.y,A.array[E+4]=y.x,A.array[E+5]=y.y,E+=6;v=0;for(q=t.length;v<q;v++)B=y=J=x=W=A.value[t[v]],A.array[E]=x.x,A.array[E+1]=x.y,A.array[E+2]=J.x,A.array[E+3]=J.y,A.array[E+4]=y.x,A.array[E+5]=y.y,A.array[E+6]=B.x,A.array[E+7]=B.y,E+=8}}else if(A.size===3)if(M=A.type==="c"?["r","g","b"]:["x","y","z"],A.boundTo===void 0||A.boundTo==="vertices"){v=
+0;for(q=r.length;v<q;v++)B=ga[r[v]],x=A.value[B.a],J=A.value[B.b],y=A.value[B.c],A.array[E]=x[M[0]],A.array[E+1]=x[M[1]],A.array[E+2]=x[M[2]],A.array[E+3]=J[M[0]],A.array[E+4]=J[M[1]],A.array[E+5]=J[M[2]],A.array[E+6]=y[M[0]],A.array[E+7]=y[M[1]],A.array[E+8]=y[M[2]],E+=9;v=0;for(q=t.length;v<q;v++)B=ga[t[v]],x=A.value[B.a],J=A.value[B.b],y=A.value[B.c],B=A.value[B.d],A.array[E]=x[M[0]],A.array[E+1]=x[M[1]],A.array[E+2]=x[M[2]],A.array[E+3]=J[M[0]],A.array[E+4]=J[M[1]],A.array[E+5]=J[M[2]],A.array[E+
+6]=y[M[0]],A.array[E+7]=y[M[1]],A.array[E+8]=y[M[2]],A.array[E+9]=B[M[0]],A.array[E+10]=B[M[1]],A.array[E+11]=B[M[2]],E+=12}else{if(A.boundTo==="faces"){v=0;for(q=r.length;v<q;v++)y=J=x=W=A.value[r[v]],A.array[E]=x[M[0]],A.array[E+1]=x[M[1]],A.array[E+2]=x[M[2]],A.array[E+3]=J[M[0]],A.array[E+4]=J[M[1]],A.array[E+5]=J[M[2]],A.array[E+6]=y[M[0]],A.array[E+7]=y[M[1]],A.array[E+8]=y[M[2]],E+=9;v=0;for(q=t.length;v<q;v++)B=y=J=x=W=A.value[t[v]],A.array[E]=x[M[0]],A.array[E+1]=x[M[1]],A.array[E+2]=x[M[2]],
+A.array[E+3]=J[M[0]],A.array[E+4]=J[M[1]],A.array[E+5]=J[M[2]],A.array[E+6]=y[M[0]],A.array[E+7]=y[M[1]],A.array[E+8]=y[M[2]],A.array[E+9]=B[M[0]],A.array[E+10]=B[M[1]],A.array[E+11]=B[M[2]],E+=12}}else if(A.size===4)if(A.boundTo===void 0||A.boundTo==="vertices"){v=0;for(q=r.length;v<q;v++)B=ga[r[v]],x=A.value[B.a],J=A.value[B.b],y=A.value[B.c],A.array[E]=x.x,A.array[E+1]=x.y,A.array[E+2]=x.z,A.array[E+3]=x.w,A.array[E+4]=J.x,A.array[E+5]=J.y,A.array[E+6]=J.z,A.array[E+7]=J.w,A.array[E+8]=y.x,A.array[E+
+9]=y.y,A.array[E+10]=y.z,A.array[E+11]=y.w,E+=12;v=0;for(q=t.length;v<q;v++)B=ga[t[v]],x=A.value[B.a],J=A.value[B.b],y=A.value[B.c],B=A.value[B.d],A.array[E]=x.x,A.array[E+1]=x.y,A.array[E+2]=x.z,A.array[E+3]=x.w,A.array[E+4]=J.x,A.array[E+5]=J.y,A.array[E+6]=J.z,A.array[E+7]=J.w,A.array[E+8]=y.x,A.array[E+9]=y.y,A.array[E+10]=y.z,A.array[E+11]=y.w,A.array[E+12]=B.x,A.array[E+13]=B.y,A.array[E+14]=B.z,A.array[E+15]=B.w,E+=16}else if(A.boundTo==="faces"){v=0;for(q=r.length;v<q;v++)y=J=x=W=A.value[r[v]],
+A.array[E]=x.x,A.array[E+1]=x.y,A.array[E+2]=x.z,A.array[E+3]=x.w,A.array[E+4]=J.x,A.array[E+5]=J.y,A.array[E+6]=J.z,A.array[E+7]=J.w,A.array[E+8]=y.x,A.array[E+9]=y.y,A.array[E+10]=y.z,A.array[E+11]=y.w,E+=12;v=0;for(q=t.length;v<q;v++)B=y=J=x=W=A.value[t[v]],A.array[E]=x.x,A.array[E+1]=x.y,A.array[E+2]=x.z,A.array[E+3]=x.w,A.array[E+4]=J.x,A.array[E+5]=J.y,A.array[E+6]=J.z,A.array[E+7]=J.w,A.array[E+8]=y.x,A.array[E+9]=y.y,A.array[E+10]=y.z,A.array[E+11]=y.w,A.array[E+12]=B.x,A.array[E+13]=B.y,
+A.array[E+14]=B.z,A.array[E+15]=B.w,E+=16}j.bindBuffer(j.ARRAY_BUFFER,A.buffer);j.bufferData(j.ARRAY_BUFFER,A.array,o)}}U&&(delete l.__inittedArrays,delete l.__colorArray,delete l.__normalArray,delete l.__tangentArray,delete l.__uvArray,delete l.__uv2Array,delete l.__faceArray,delete l.__vertexArray,delete l.__lineArray,delete l.__skinVertexAArray,delete l.__skinVertexBArray,delete l.__skinIndexArray,delete l.__skinWeightArray)}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=
+!1;f.__dirtyNormals=!1;f.__dirtyColors=!1;f.__dirtyTangents=!1;h.attributes&&s(h)}else if(u instanceof THREE.Ribbon){if(f.__dirtyVertices||f.__dirtyColors){h=f;u=j.DYNAMIC_DRAW;v=i=v=U=U=void 0;q=h.vertices;k=h.colors;ba=q.length;l=k.length;r=h.__vertexArray;o=h.__colorArray;t=h.__dirtyColors;if(h.__dirtyVertices){for(U=0;U<ba;U++)v=q[U].position,i=U*3,r[i]=v.x,r[i+1]=v.y,r[i+2]=v.z;j.bindBuffer(j.ARRAY_BUFFER,h.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,r,u)}if(t){for(U=0;U<l;U++)v=k[U],i=
+U*3,o[i]=v.r,o[i+1]=v.g,o[i+2]=v.b;j.bindBuffer(j.ARRAY_BUFFER,h.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,o,u)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(u instanceof THREE.Line){h=b(u,l);o=h.attributes&&n(h);if(f.__dirtyVertices||f.__dirtyColors||o){u=f;i=j.DYNAMIC_DRAW;ba=k=$=q=ga=void 0;q=u.vertices;l=u.colors;ba=q.length;o=l.length;r=u.__vertexArray;U=u.__colorArray;t=u.__dirtyColors;v=u.__webglCustomAttributesList;F=T=Y=M=$=ga=void 0;if(u.__dirtyVertices){for(ga=0;ga<ba;ga++)$=q[ga].position,
+k=ga*3,r[k]=$.x,r[k+1]=$.y,r[k+2]=$.z;j.bindBuffer(j.ARRAY_BUFFER,u.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,r,i)}if(t){for(q=0;q<o;q++)ba=l[q],k=q*3,U[k]=ba.r,U[k+1]=ba.g,U[k+2]=ba.b;j.bindBuffer(j.ARRAY_BUFFER,u.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,U,i)}if(v){ga=0;for($=v.length;ga<$;ga++)if(F=v[ga],F.needsUpdate&&(F.boundTo===void 0||F.boundTo==="vertices")){k=0;Y=F.value.length;if(F.size===1)for(M=0;M<Y;M++)F.array[M]=F.value[M];else if(F.size===2)for(M=0;M<Y;M++)T=F.value[M],
+F.array[k]=T.x,F.array[k+1]=T.y,k+=2;else if(F.size===3)if(F.type==="c")for(M=0;M<Y;M++)T=F.value[M],F.array[k]=T.r,F.array[k+1]=T.g,F.array[k+2]=T.b,k+=3;else for(M=0;M<Y;M++)T=F.value[M],F.array[k]=T.x,F.array[k+1]=T.y,F.array[k+2]=T.z,k+=3;else if(F.size===4)for(M=0;M<Y;M++)T=F.value[M],F.array[k]=T.x,F.array[k+1]=T.y,F.array[k+2]=T.z,F.array[k+3]=T.w,k+=4;j.bindBuffer(j.ARRAY_BUFFER,F.buffer);j.bufferData(j.ARRAY_BUFFER,F.array,i)}}}f.__dirtyVertices=!1;f.__dirtyColors=!1;h.attributes&&s(h)}else if(u instanceof
+THREE.ParticleSystem)h=b(u,l),o=h.attributes&&n(h),(f.__dirtyVertices||f.__dirtyColors||u.sortParticles||o)&&d(f,j.DYNAMIC_DRAW,u),f.__dirtyVertices=!1,f.__dirtyColors=!1,h.attributes&&s(h)};this.initMaterial=function(a,b,c,d){var e,f,g,h;a instanceof THREE.MeshDepthMaterial?h="depth":a instanceof THREE.MeshNormalMaterial?h="normal":a instanceof THREE.MeshBasicMaterial?h="basic":a instanceof THREE.MeshLambertMaterial?h="lambert":a instanceof THREE.MeshPhongMaterial?h="phong":a instanceof THREE.LineBasicMaterial?
+h="basic":a instanceof THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var i=THREE.ShaderLib[h];a.uniforms=THREE.UniformsUtils.clone(i.uniforms);a.vertexShader=i.vertexShader;a.fragmentShader=i.fragmentShader}var k,l,m;k=m=i=0;for(l=b.length;k<l;k++)g=b[k],g instanceof THREE.SpotLight&&m++,g instanceof THREE.DirectionalLight&&m++,g instanceof THREE.PointLight&&i++;i+m<=y?k=m:(k=Math.ceil(y*m/(i+m)),i=y-k);g={directional:k,point:i};i=m=0;for(k=b.length;i<k;i++)l=b[i],l instanceof THREE.SpotLight&&
+l.castShadow&&m++;var n=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)n=d.bones.length;var o;a:{k=a.fragmentShader;l=a.vertexShader;var i=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:g.directional,maxPointLights:g.point,maxBones:n,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,
+shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:m,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel},v,d=[];h?d.push(h):(d.push(k),d.push(l));for(v in c)d.push(v),d.push(c[v]);h=d.join();v=0;for(d=X.length;v<d;v++)if(X[v].code===h){o=X[v].program;break a}v=j.createProgram();d=[qa?"#define VERTEX_TEXTURES":"",L.gammaInput?"#define GAMMA_INPUT":"",L.gammaOutput?"#define GAMMA_OUTPUT":"",L.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":
+"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":
+"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
 g=["#ifdef GL_ES","precision "+Z+" float;","#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",L.gammaInput?"#define GAMMA_INPUT":"",L.gammaOutput?"#define GAMMA_OUTPUT":"",L.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.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");j.attachShader(u,x("fragment",g+k));j.attachShader(u,
-x("vertex",d+l));j.linkProgram(u);j.getProgramParameter(u,j.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+j.getProgramParameter(u,j.VALIDATE_STATUS)+", gl error ["+j.getError()+"]");u.uniforms={};u.attributes={};var p,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(p in i)d.push(p);p=d;d=0;for(i=p.length;d<i;d++)k=p[d],u.uniforms[k]=j.getUniformLocation(u,
-k);d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(p=0;p<c.maxMorphTargets;p++)d.push("morphTarget"+p);for(o in b)d.push(o);o=d;p=0;for(b=o.length;p<b;p++)c=o[p],u.attributes[c]=j.getAttribLocation(u,c);u.id=ca.length;ca.push({program:u,code:h});L.info.memory.programs=ca.length;o=u}a.program=o;o=a.program.attributes;o.position>=0&&j.enableVertexAttribArray(o.position);o.color>=0&&j.enableVertexAttribArray(o.color);o.normal>=0&&j.enableVertexAttribArray(o.normal);
+"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");j.attachShader(v,x("fragment",g+k));j.attachShader(v,
+x("vertex",d+l));j.linkProgram(v);j.getProgramParameter(v,j.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+j.getProgramParameter(v,j.VALIDATE_STATUS)+", gl error ["+j.getError()+"]");v.uniforms={};v.attributes={};var p,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(p in i)d.push(p);p=d;d=0;for(i=p.length;d<i;d++)k=p[d],v.uniforms[k]=j.getUniformLocation(v,
+k);d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(p=0;p<c.maxMorphTargets;p++)d.push("morphTarget"+p);for(o in b)d.push(o);o=d;p=0;for(b=o.length;p<b;p++)c=o[p],v.attributes[c]=j.getAttribLocation(v,c);v.id=X.length;X.push({program:v,code:h});L.info.memory.programs=X.length;o=v}a.program=o;o=a.program.attributes;o.position>=0&&j.enableVertexAttribArray(o.position);o.color>=0&&j.enableVertexAttribArray(o.color);o.normal>=0&&j.enableVertexAttribArray(o.normal);
 o.tangent>=0&&j.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(j.enableVertexAttribArray(o.skinVertexA),j.enableVertexAttribArray(o.skinVertexB),j.enableVertexAttribArray(o.skinIndex),j.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(f in a.attributes)o[f]!==void 0&&o[f]>=0&&j.enableVertexAttribArray(o[f]);if(a.morphTargets)for(f=a.numSupportedMorphTargets=0;f<this.maxMorphTargets;f++)p="morphTarget"+f,o[p]>=0&&(j.enableVertexAttribArray(o[p]),
 a.numSupportedMorphTargets++);a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?j.frontFace(j.CCW):j.frontFace(j.CW),a==="back"?j.cullFace(j.BACK):a==="front"?j.cullFace(j.FRONT):j.cullFace(j.FRONT_AND_BACK),j.enable(j.CULL_FACE)):j.disable(j.CULL_FACE)}};
 THREE.WebGLRenderTarget=function(a,c,b){this.width=a;this.height=c;b=b||{};this.wrapS=b.wrapS!==void 0?b.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=b.wrapT!==void 0?b.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=b.magFilter!==void 0?b.magFilter:THREE.LinearFilter;this.minFilter=b.minFilter!==void 0?b.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=b.format!==void 0?b.format:THREE.RGBAFormat;this.type=b.type!==void 0?b.type:
@@ -350,9 +351,9 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};
 THREE.ColorUtils={adjustHSV:function(a,c,b,d){var g=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,g);g.h=THREE.Math.clamp(g.h+c,0,1);g.s=THREE.Math.clamp(g.s+b,0,1);g.v=THREE.Math.clamp(g.v+d,0,1);a.setHSV(g.h,g.s,g.v)},rgbToHsv:function(a,c){var b=a.r,d=a.g,g=a.b,e=Math.max(Math.max(b,d),g),f=Math.min(Math.min(b,d),g);if(f===e)f=b=0;else{var h=e-f,f=h/e,b=b===e?(d-g)/h:d===e?2+(g-b)/h:4+(b-d)/h;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=b;c.s=f;c.v=e;return c}};
 THREE.ColorUtils.__hsv={h:0,s:0,v:0};
-THREE.GeometryUtils={merge:function(a,c){for(var b,d,g=a.vertices.length,e=c instanceof THREE.Mesh?c.geometry:c,f=a.vertices,h=e.vertices,i=a.faces,l=e.faces,k=a.faceVertexUvs[0],o=e.faceVertexUvs[0],p={},n=0;n<a.materials.length;n++)p[a.materials[n].id]=n;if(c instanceof THREE.Mesh)c.matrixAutoUpdate&&c.updateMatrix(),b=c.matrix,d=new THREE.Matrix4,d.extractRotation(b,c.scale);for(var n=0,r=h.length;n<r;n++){var m=new THREE.Vertex(h[n].position.clone());b&&b.multiplyVector3(m.position);f.push(m)}n=
-0;for(r=l.length;n<r;n++){var f=l[n],s,t,v=f.vertexNormals,q=f.vertexColors;f instanceof THREE.Face3?s=new THREE.Face3(f.a+g,f.b+g,f.c+g):f instanceof THREE.Face4&&(s=new THREE.Face4(f.a+g,f.b+g,f.c+g,f.d+g));s.normal.copy(f.normal);d&&d.multiplyVector3(s.normal);h=0;for(m=v.length;h<m;h++)t=v[h].clone(),d&&d.multiplyVector3(t),s.vertexNormals.push(t);s.color.copy(f.color);h=0;for(m=q.length;h<m;h++)t=q[h],s.vertexColors.push(t.clone());if(f.materialIndex!==void 0){h=e.materials[f.materialIndex];
-m=p[h.id];if(m===void 0)m=a.materials.length,a.materials.push(h);s.materialIndex=m}s.centroid.copy(f.centroid);b&&b.multiplyVector3(s.centroid);i.push(s)}n=0;for(r=o.length;n<r;n++){b=o[n];d=[];h=0;for(m=b.length;h<m;h++)d.push(new THREE.UV(b[h].u,b[h].v));k.push(d)}},clone:function(a){var c=new THREE.Geometry,b,d=a.vertices,g=a.faces,e=a.faceVertexUvs[0];if(a.materials)c.materials=a.materials.slice();a=0;for(b=d.length;a<b;a++){var f=new THREE.Vertex(d[a].position.clone());c.vertices.push(f)}a=0;
+THREE.GeometryUtils={merge:function(a,c){for(var b,d,g=a.vertices.length,e=c instanceof THREE.Mesh?c.geometry:c,f=a.vertices,h=e.vertices,i=a.faces,l=e.faces,k=a.faceVertexUvs[0],o=e.faceVertexUvs[0],p={},n=0;n<a.materials.length;n++)p[a.materials[n].id]=n;if(c instanceof THREE.Mesh)c.matrixAutoUpdate&&c.updateMatrix(),b=c.matrix,d=new THREE.Matrix4,d.extractRotation(b,c.scale);for(var n=0,s=h.length;n<s;n++){var m=new THREE.Vertex(h[n].position.clone());b&&b.multiplyVector3(m.position);f.push(m)}n=
+0;for(s=l.length;n<s;n++){var f=l[n],q,t,u=f.vertexNormals,r=f.vertexColors;f instanceof THREE.Face3?q=new THREE.Face3(f.a+g,f.b+g,f.c+g):f instanceof THREE.Face4&&(q=new THREE.Face4(f.a+g,f.b+g,f.c+g,f.d+g));q.normal.copy(f.normal);d&&d.multiplyVector3(q.normal);h=0;for(m=u.length;h<m;h++)t=u[h].clone(),d&&d.multiplyVector3(t),q.vertexNormals.push(t);q.color.copy(f.color);h=0;for(m=r.length;h<m;h++)t=r[h],q.vertexColors.push(t.clone());if(f.materialIndex!==void 0){h=e.materials[f.materialIndex];
+m=p[h.id];if(m===void 0)m=a.materials.length,a.materials.push(h);q.materialIndex=m}q.centroid.copy(f.centroid);b&&b.multiplyVector3(q.centroid);i.push(q)}n=0;for(s=o.length;n<s;n++){b=o[n];d=[];h=0;for(m=b.length;h<m;h++)d.push(new THREE.UV(b[h].u,b[h].v));k.push(d)}},clone:function(a){var c=new THREE.Geometry,b,d=a.vertices,g=a.faces,e=a.faceVertexUvs[0];if(a.materials)c.materials=a.materials.slice();a=0;for(b=d.length;a<b;a++){var f=new THREE.Vertex(d[a].position.clone());c.vertices.push(f)}a=0;
 for(b=g.length;a<b;a++){var h=g[a],i,l,k=h.vertexNormals,o=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(f=k.length;d<f;d++)l=k[d],i.vertexNormals.push(l.clone());i.color.copy(h.color);d=0;for(f=o.length;d<f;d++)l=o[d],i.vertexColors.push(l.clone());i.materialIndex=h.materialIndex;i.centroid.copy(h.centroid);c.faces.push(i)}a=0;for(b=e.length;a<b;a++){g=e[a];i=[];d=0;for(f=g.length;d<
 f;d++)i.push(new THREE.UV(g[d].u,g[d].v));c.faceVertexUvs[0].push(i)}return c},randomPointInTriangle:function(a,c,b){var d,g,e,f=new THREE.Vector3,h=THREE.GeometryUtils.__v1;d=THREE.GeometryUtils.random();g=THREE.GeometryUtils.random();d+g>1&&(d=1-d,g=1-g);e=1-d-g;f.copy(a);f.multiplyScalar(d);h.copy(c);h.multiplyScalar(g);f.addSelf(h);h.copy(b);h.multiplyScalar(e);f.addSelf(h);return f},randomPointInFace:function(a,c,b){var d,g,e;if(a instanceof THREE.Face3)return d=c.vertices[a.a].position,g=c.vertices[a.b].position,
 e=c.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,g,e);else if(a instanceof THREE.Face4){d=c.vertices[a.a].position;g=c.vertices[a.b].position;e=c.vertices[a.c].position;var c=c.vertices[a.d].position,f;b?a._area1&&a._area2?(b=a._area1,f=a._area2):(b=THREE.GeometryUtils.triangleArea(d,g,c),f=THREE.GeometryUtils.triangleArea(g,e,c),a._area1=b,a._area2=f):(b=THREE.GeometryUtils.triangleArea(d,g,c),f=THREE.GeometryUtils.triangleArea(g,e,c));return THREE.GeometryUtils.random()*(b+
@@ -360,9 +361,9 @@ f)<b?THREE.GeometryUtils.randomPointInTriangle(d,g,c):THREE.GeometryUtils.random
 THREE.Face4)k=f[d.a].position,o=f[d.b].position,p=f[d.c].position,n=f[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(k,o,n),d._area2=THREE.GeometryUtils.triangleArea(o,p,n),d._area=d._area1+d._area2;i+=d._area;l[g]=i}d=[];f={};for(g=0;g<c;g++)h=THREE.GeometryUtils.random()*i,h=b(h),d[g]=THREE.GeometryUtils.randomPointInFace(e[h],a,!0),f[h]?f[h]+=1:f[h]=1;return d},triangleArea:function(a,c,b){var d,g=THREE.GeometryUtils.__v1;g.sub(a,c);d=g.length();g.sub(a,b);a=g.length();g.sub(c,b);b=g.length();
 c=0.5*(d+a+b);return Math.sqrt(c*(c-d)*(c-a)*(c-b))},center:function(a){a.computeBoundingBox();var c=new THREE.Matrix4;c.setTranslation(-0.5*(a.boundingBox.x[1]+a.boundingBox.x[0]),-0.5*(a.boundingBox.y[1]+a.boundingBox.y[0]),-0.5*(a.boundingBox.z[1]+a.boundingBox.z[0]));a.applyMatrix(c);a.computeBoundingBox()}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
 THREE.ImageUtils={loadTexture:function(a,c,b){var d=new Image,g=new THREE.Texture(d,c);d.onload=function(){g.needsUpdate=!0;b&&b(this)};d.crossOrigin="";d.src=a;return g},loadTextureCube:function(a,c,b){var d,g=[],e=new THREE.Texture(g,c),c=g.loadCount=0;for(d=a.length;c<d;++c)g[c]=new Image,g[c].onload=function(){g.loadCount+=1;if(g.loadCount===6)e.needsUpdate=!0;b&&b(this)},g[c].crossOrigin="",g[c].src=a[c];return e},getNormalMap:function(a,c){var b=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]};c|=1;var d=a.width,g=a.height,e=document.createElement("canvas");e.width=d;e.height=g;var f=e.getContext("2d");f.drawImage(a,0,0);for(var h=f.getImageData(0,0,d,g).data,i=f.createImageData(d,g),l=i.data,k=0;k<d;k++)for(var o=1;o<g;o++){var p=o-1<0?g-1:o-1,n=(o+1)%g,r=k-1<0?d-1:k-1,m=(k+1)%d,s=[],t=[0,0,h[(o*d+k)*4]/255*c];s.push([-1,0,h[(o*d+r)*4]/255*c]);s.push([-1,-1,h[(p*d+r)*4]/255*c]);s.push([0,-1,h[(p*d+k)*4]/255*c]);s.push([1,-1,h[(p*d+m)*4]/255*c]);
-s.push([1,0,h[(o*d+m)*4]/255*c]);s.push([1,1,h[(n*d+m)*4]/255*c]);s.push([0,1,h[(n*d+k)*4]/255*c]);s.push([-1,1,h[(n*d+r)*4]/255*c]);p=[];r=s.length;for(n=0;n<r;n++){var m=s[n],v=s[(n+1)%r],m=[m[0]-t[0],m[1]-t[1],m[2]-t[2]],v=[v[0]-t[0],v[1]-t[1],v[2]-t[2]];p.push(b([m[1]*v[2]-m[2]*v[1],m[2]*v[0]-m[0]*v[2],m[0]*v[1]-m[1]*v[0]]))}s=[0,0,0];for(n=0;n<p.length;n++)s[0]+=p[n][0],s[1]+=p[n][1],s[2]+=p[n][2];s[0]/=p.length;s[1]/=p.length;s[2]/=p.length;t=(o*d+k)*4;l[t]=(s[0]+1)/2*255|0;l[t+1]=(s[1]+0.5)*
-255|0;l[t+2]=s[2]*255|0;l[t+3]=255}f.putImageData(i,0,0);return e}};THREE.SceneUtils={showHierarchy:function(a,c){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=c})},traverseHierarchy:function(a,c){var b,d,g=a.children.length;for(d=0;d<g;d++)b=a.children[d],c(b),THREE.SceneUtils.traverseHierarchy(b,c)},createMultiMaterialObject:function(a,c){var b,d=c.length,g=new THREE.Object3D;for(b=0;b<d;b++){var e=new THREE.Mesh(a,c[b]);g.add(e)}return g}};
+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]};c|=1;var d=a.width,g=a.height,e=document.createElement("canvas");e.width=d;e.height=g;var f=e.getContext("2d");f.drawImage(a,0,0);for(var h=f.getImageData(0,0,d,g).data,i=f.createImageData(d,g),l=i.data,k=0;k<d;k++)for(var o=1;o<g;o++){var p=o-1<0?g-1:o-1,n=(o+1)%g,s=k-1<0?d-1:k-1,m=(k+1)%d,q=[],t=[0,0,h[(o*d+k)*4]/255*c];q.push([-1,0,h[(o*d+s)*4]/255*c]);q.push([-1,-1,h[(p*d+s)*4]/255*c]);q.push([0,-1,h[(p*d+k)*4]/255*c]);q.push([1,-1,h[(p*d+m)*4]/255*c]);
+q.push([1,0,h[(o*d+m)*4]/255*c]);q.push([1,1,h[(n*d+m)*4]/255*c]);q.push([0,1,h[(n*d+k)*4]/255*c]);q.push([-1,1,h[(n*d+s)*4]/255*c]);p=[];s=q.length;for(n=0;n<s;n++){var m=q[n],u=q[(n+1)%s],m=[m[0]-t[0],m[1]-t[1],m[2]-t[2]],u=[u[0]-t[0],u[1]-t[1],u[2]-t[2]];p.push(b([m[1]*u[2]-m[2]*u[1],m[2]*u[0]-m[0]*u[2],m[0]*u[1]-m[1]*u[0]]))}q=[0,0,0];for(n=0;n<p.length;n++)q[0]+=p[n][0],q[1]+=p[n][1],q[2]+=p[n][2];q[0]/=p.length;q[1]/=p.length;q[2]/=p.length;t=(o*d+k)*4;l[t]=(q[0]+1)/2*255|0;l[t+1]=(q[1]+0.5)*
+255|0;l[t+2]=q[2]*255|0;l[t+3]=255}f.putImageData(i,0,0);return e}};THREE.SceneUtils={showHierarchy:function(a,c){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=c})},traverseHierarchy:function(a,c){var b,d,g=a.children.length;for(d=0;d<g;d++)b=a.children[d],c(b),THREE.SceneUtils.traverseHierarchy(b,c)},createMultiMaterialObject:function(a,c){var b,d=c.length,g=new THREE.Object3D;for(b=0;b<d;b++){var e=new THREE.Mesh(a,c[b]);g.add(e)}return g}};
 if(THREE.WebGLRenderer)THREE.ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
 vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
 normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tCube:{type:"t",value:1,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},tDisplacement:{type:"t",value:5,texture:null},uNormalScale:{type:"f",
@@ -401,9 +402,9 @@ THREE.Path.prototype.quadraticCurveTo=function(a,c,b,d){var g=Array.prototype.sl
 THREE.Path.prototype.bezierCurveTo=function(a,c,b,d,g,e){var f=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args;this.curves.push(new THREE.CubicBezierCurve(new THREE.Vector2(h[h.length-2],h[h.length-1]),new THREE.Vector2(a,c),new THREE.Vector2(b,d),new THREE.Vector2(g,e)));this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:f})};
 THREE.Path.prototype.splineThru=function(a){var c=Array.prototype.slice.call(arguments),b=this.actions[this.actions.length-1].args,b=[new THREE.Vector2(b[b.length-2],b[b.length-1])];Array.prototype.push.apply(b,a);this.curves.push(new THREE.SplineCurve(b));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:c})};
 THREE.Path.prototype.arc=function(a,c,b,d,g,e){var f=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(a,c,b,d,g,e));this.actions.push({action:THREE.PathActions.ARC,args:f})};THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var c=[],b=0;b<a;b++)c.push(this.getPoint(b/a));return c};
-THREE.Path.prototype.getPoints=function(a,c){var a=a||12,b=[],d,g,e,f,h,i,l,k,o,p,n,r,m;d=0;for(g=this.actions.length;d<g;d++)switch(e=this.actions[d],f=e.action,e=e.args,f){case THREE.PathActions.LINE_TO:b.push(new THREE.Vector2(e[0],e[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=e[2];i=e[3];o=e[0];p=e[1];b.length>0?(f=b[b.length-1],n=f.x,r=f.y):(f=this.actions[d-1].args,n=f[f.length-2],r=f[f.length-1]);for(f=1;f<=a;f++)m=f/a,e=THREE.Shape.Utils.b2(m,n,o,h),m=THREE.Shape.Utils.b2(m,r,p,
-i),b.push(new THREE.Vector2(e,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=e[4];i=e[5];o=e[0];p=e[1];l=e[2];k=e[3];b.length>0?(f=b[b.length-1],n=f.x,r=f.y):(f=this.actions[d-1].args,n=f[f.length-2],r=f[f.length-1]);for(f=1;f<=a;f++)m=f/a,e=THREE.Shape.Utils.b3(m,n,o,l,h),m=THREE.Shape.Utils.b3(m,r,p,k,i),b.push(new THREE.Vector2(e,m));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];m=a*e[0].length;f=f.concat(e[0]);e=new THREE.SplineCurve(f);
-for(f=1;f<=m;f++)b.push(e.getPointAt(f/m));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=e[0];i=e[1];l=e[2];o=e[3];m=e[4];p=!!e[5];k=f[f.length-2];n=f[f.length-1];f.length==0&&(k=n=0);r=m-o;var s=a*2;for(f=1;f<=s;f++)m=f/s,p||(m=1-m),m=o+m*r,e=k+h+l*Math.cos(m),m=n+i+l*Math.sin(m),b.push(new THREE.Vector2(e,m))}c&&b.push(b[0]);return b};THREE.Path.prototype.transform=function(a,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),a)};
+THREE.Path.prototype.getPoints=function(a,c){var a=a||12,b=[],d,g,e,f,h,i,l,k,o,p,n,s,m;d=0;for(g=this.actions.length;d<g;d++)switch(e=this.actions[d],f=e.action,e=e.args,f){case THREE.PathActions.LINE_TO:b.push(new THREE.Vector2(e[0],e[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=e[2];i=e[3];o=e[0];p=e[1];b.length>0?(f=b[b.length-1],n=f.x,s=f.y):(f=this.actions[d-1].args,n=f[f.length-2],s=f[f.length-1]);for(f=1;f<=a;f++)m=f/a,e=THREE.Shape.Utils.b2(m,n,o,h),m=THREE.Shape.Utils.b2(m,s,p,
+i),b.push(new THREE.Vector2(e,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=e[4];i=e[5];o=e[0];p=e[1];l=e[2];k=e[3];b.length>0?(f=b[b.length-1],n=f.x,s=f.y):(f=this.actions[d-1].args,n=f[f.length-2],s=f[f.length-1]);for(f=1;f<=a;f++)m=f/a,e=THREE.Shape.Utils.b3(m,n,o,l,h),m=THREE.Shape.Utils.b3(m,s,p,k,i),b.push(new THREE.Vector2(e,m));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];m=a*e[0].length;f=f.concat(e[0]);e=new THREE.SplineCurve(f);
+for(f=1;f<=m;f++)b.push(e.getPointAt(f/m));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=e[0];i=e[1];l=e[2];o=e[3];m=e[4];p=!!e[5];k=f[f.length-2];n=f[f.length-1];f.length==0&&(k=n=0);s=m-o;var q=a*2;for(f=1;f<=q;f++)m=f/q,p||(m=1-m),m=o+m*s,e=k+h+l*Math.cos(m),m=n+i+l*Math.sin(m),b.push(new THREE.Vector2(e,m))}c&&b.push(b[0]);return b};THREE.Path.prototype.transform=function(a,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),a)};
 THREE.Path.prototype.nltransform=function(a,c,b,d,g,e){var f=this.getPoints(),h,i,l,k,o;h=0;for(i=f.length;h<i;h++)l=f[h],k=l.x,o=l.y,l.x=a*k+c*o+b,l.y=d*o+g*k+e;return f};
 THREE.Path.prototype.debug=function(a){var c=this.getBoundingBox();a||(a=document.createElement("canvas"),a.setAttribute("width",c.maxX+100),a.setAttribute("height",c.maxY+100),document.body.appendChild(a));c=a.getContext("2d");c.fillStyle="white";c.fillRect(0,0,a.width,a.height);c.strokeStyle="black";c.beginPath();var b,d,g,a=0;for(b=this.actions.length;a<b;a++)d=this.actions[a],g=d.args,d=d.action,d!=THREE.PathActions.CSPLINE_THRU&&c[d].apply(c,g);c.stroke();c.closePath();c.strokeStyle="red";d=
 this.getPoints();a=0;for(b=d.length;a<b;a++)g=d[a],c.beginPath(),c.arc(g.x,g.y,1.5,0,Math.PI*2,!1),c.stroke(),c.closePath()};
@@ -411,9 +412,9 @@ THREE.Path.prototype.toShapes=function(){var a,c,b,d,g=[],e=new THREE.Path;a=0;f
 d.curves):f.holes.push(d);e.push(f)}else{f=new THREE.Shape;a=0;for(c=g.length;a<c;a++)d=g[a],THREE.Shape.Utils.isClockWise(d.getPoints())?(f.actions=d.actions,f.curves=d.curves,e.push(f),f=new THREE.Shape):f.holes.push(d)}return e};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 c,b=this.holes.length,d=[];for(c=0;c<b;c++)d[c]=this.holes[c].getTransformedPoints(a,this.bends);return d};THREE.Shape.prototype.getSpacedPointsHoles=function(a){var c,b=this.holes.length,d=[];for(c=0;c<b;c++)d[c]=this.holes[c].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,c){var b=a.concat(),d=b.concat(),g,e,f,h,i,l,k,o,p,n,r=[];for(i=0;i<c.length;i++){l=c[i];Array.prototype.push.apply(d,l);e=Number.POSITIVE_INFINITY;for(g=0;g<l.length;g++){p=l[g];n=[];for(o=0;o<b.length;o++)k=b[o],k=p.distanceToSquared(k),n.push(k),k<e&&(e=k,f=g,h=o)}g=h-1>=0?h-1:b.length-1;e=f-1>=0?f-1:l.length-1;var m=[l[f],b[h],b[g]];o=THREE.FontUtils.Triangulate.area(m);var s=[l[f],l[e],b[h]];p=THREE.FontUtils.Triangulate.area(s);n=h;k=f;h+=1;f+=-1;h<
-0&&(h+=b.length);h%=b.length;f<0&&(f+=l.length);f%=l.length;g=h-1>=0?h-1:b.length-1;e=f-1>=0?f-1:l.length-1;m=[l[f],b[h],b[g]];m=THREE.FontUtils.Triangulate.area(m);s=[l[f],l[e],b[h]];s=THREE.FontUtils.Triangulate.area(s);o+p>m+s&&(h=n,f=k,h<0&&(h+=b.length),h%=b.length,f<0&&(f+=l.length),f%=l.length,g=h-1>=0?h-1:b.length-1,e=f-1>=0?f-1:l.length-1);o=b.slice(0,h);p=b.slice(h);n=l.slice(f);k=l.slice(0,f);e=[l[f],l[e],b[h]];r.push([l[f],b[h],b[g]]);r.push(e);b=o.concat(n).concat(k).concat(p)}return{shape:b,
-isolatedPts:r,allpoints:d}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),d=b.allpoints,g=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),e,f,h,i,l={};e=0;for(f=d.length;e<f;e++)i=d[e].x+":"+d[e].y,l[i]!==void 0&&console.log("Duplicate point",i),l[i]=e;e=0;for(f=b.length;e<f;e++){h=b[e];for(d=0;d<3;d++)i=h[d].x+":"+h[d].y,i=l[i],i!==void 0&&(h[d]=i)}e=0;for(f=g.length;e<f;e++){h=g[e];for(d=0;d<3;d++)i=h[d].x+":"+h[d].y,i=l[i],i!==void 0&&(h[d]=i)}return b.concat(g)},
+THREE.Shape.Utils={removeHoles:function(a,c){var b=a.concat(),d=b.concat(),g,e,f,h,i,l,k,o,p,n,s=[];for(i=0;i<c.length;i++){l=c[i];Array.prototype.push.apply(d,l);e=Number.POSITIVE_INFINITY;for(g=0;g<l.length;g++){p=l[g];n=[];for(o=0;o<b.length;o++)k=b[o],k=p.distanceToSquared(k),n.push(k),k<e&&(e=k,f=g,h=o)}g=h-1>=0?h-1:b.length-1;e=f-1>=0?f-1:l.length-1;var m=[l[f],b[h],b[g]];o=THREE.FontUtils.Triangulate.area(m);var q=[l[f],l[e],b[h]];p=THREE.FontUtils.Triangulate.area(q);n=h;k=f;h+=1;f+=-1;h<
+0&&(h+=b.length);h%=b.length;f<0&&(f+=l.length);f%=l.length;g=h-1>=0?h-1:b.length-1;e=f-1>=0?f-1:l.length-1;m=[l[f],b[h],b[g]];m=THREE.FontUtils.Triangulate.area(m);q=[l[f],l[e],b[h]];q=THREE.FontUtils.Triangulate.area(q);o+p>m+q&&(h=n,f=k,h<0&&(h+=b.length),h%=b.length,f<0&&(f+=l.length),f%=l.length,g=h-1>=0?h-1:b.length-1,e=f-1>=0?f-1:l.length-1);o=b.slice(0,h);p=b.slice(h);n=l.slice(f);k=l.slice(0,f);e=[l[f],l[e],b[h]];s.push([l[f],b[h],b[g]]);s.push(e);b=o.concat(n).concat(k).concat(p)}return{shape:b,
+isolatedPts:s,allpoints:d}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),d=b.allpoints,g=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),e,f,h,i,l={};e=0;for(f=d.length;e<f;e++)i=d[e].x+":"+d[e].y,l[i]!==void 0&&console.log("Duplicate point",i),l[i]=e;e=0;for(f=b.length;e<f;e++){h=b[e];for(d=0;d<3;d++)i=h[d].x+":"+h[d].y,i=l[i],i!==void 0&&(h[d]=i)}e=0;for(f=g.length;e<f;e++){h=g[e];for(d=0;d<3;d++)i=h[d].x+":"+h[d].y,i=l[i],i!==void 0&&(h[d]=i)}return b.concat(g)},
 isClockWise:function(a){return THREE.FontUtils.Triangulate.area(a)<0},b2p0:function(a,c){var b=1-a;return b*b*c},b2p1:function(a,c){return 2*(1-a)*a*c},b2p2:function(a,c){return a*a*c},b2:function(a,c,b,d){return this.b2p0(a,c)+this.b2p1(a,b)+this.b2p2(a,d)},b3p0:function(a,c){var b=1-a;return b*b*b*c},b3p1:function(a,c){var b=1-a;return 3*b*b*a*c},b3p2:function(a,c){return 3*(1-a)*a*a*c},b3p3:function(a,c){return a*a*a*c},b3:function(a,c,b,d,g){return this.b3p0(a,c)+this.b3p1(a,b)+this.b3p2(a,d)+
 this.b3p3(a,g)}};THREE.TextPath=function(a,c){THREE.Path.call(this);this.parameters=c||{};this.set(a)};THREE.TextPath.prototype.set=function(a,c){this.text=a;var c=c||this.parameters,b=c.curveSegments!==void 0?c.curveSegments:4,d=c.font!==void 0?c.font:"helvetiker",g=c.weight!==void 0?c.weight:"normal",e=c.style!==void 0?c.style:"normal";THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=b;THREE.FontUtils.face=d;THREE.FontUtils.weight=g;THREE.FontUtils.style=e};
 THREE.TextPath.prototype.toShapes=function(){for(var a=THREE.FontUtils.drawText(this.text).paths,c=[],b=0,d=a.length;b<d;b++)Array.prototype.push.apply(c,a[b].toShapes());return c};
@@ -426,7 +427,7 @@ THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=
 THREE.Bone?g.skinMatrix:g.matrix;var e=g.animationCache.prevKey;g=g.animationCache.nextKey;e.pos=this.data.hierarchy[b].keys[0];e.rot=this.data.hierarchy[b].keys[0];e.scl=this.data.hierarchy[b].keys[0];g.pos=this.getNextKeyWith("pos",b,1);g.rot=this.getNextKeyWith("rot",b,1);g.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==void 0)this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix:this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix,delete this.hierarchy[a].animationCache};
-THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,g,e,f,h,i,l,k=this.data.JIT.hierarchy,o,p;this.currentTime+=a*this.timeScale;p=this.currentTime;o=this.currentTime%=this.data.length;l=parseInt(Math.min(o*this.data.fps,this.data.length*this.data.fps),10);for(var n=0,r=this.hierarchy.length;n<r;n++)if(a=this.hierarchy[n],i=a.animationCache,this.JITCompile&&k[n][l]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=k[n][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
+THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,g,e,f,h,i,l,k=this.data.JIT.hierarchy,o,p;this.currentTime+=a*this.timeScale;p=this.currentTime;o=this.currentTime%=this.data.length;l=parseInt(Math.min(o*this.data.fps,this.data.length*this.data.fps),10);for(var n=0,s=this.hierarchy.length;n<s;n++)if(a=this.hierarchy[n],i=a.animationCache,this.JITCompile&&k[n][l]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=k[n][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
 !1):(a.matrix=k[n][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var m=0;m<3;m++){b=c[m];f=i.prevKey[b];h=i.nextKey[b];if(h.time<=p){if(o<p)if(this.loop){f=this.data.hierarchy[n].keys[0];for(h=this.getNextKeyWith(b,n,1);h.time<o;)f=h,h=this.getNextKeyWith(b,n,h.index+1)}else{this.stop();return}else{do f=h,h=this.getNextKeyWith(b,n,h.index+1);while(h.time<
 o)}i.prevKey[b]=f;i.nextKey[b]=h}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(o-f.time)/(h.time-f.time);g=f[b];e=h[b];if(d<0||d>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+n),d=d<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=g[0]+(e[0]-g[0])*d,b.y=g[1]+(e[1]-g[1])*d,b.z=g[2]+(e[2]-g[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
 this.getPrevKeyWith("pos",n,f.index-1).pos,this.points[1]=g,this.points[2]=e,this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos,d=d*0.33+0.33,g=this.interpolateCatmullRom(this.points,d),b.x=g[0],b.y=g[1],b.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(b===
@@ -453,7 +454,7 @@ function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:
 this.object.translateX(b);this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);c=a*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a=
 1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*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;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*
 Math.sin(this.theta);this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)};
-THREE.PathControls=function(a,c){function b(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function g(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),s=g.length,t=0;f=s-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<s-1;f++)t=d*h.chunks[f]/h.total,b.keys[f]={time:t,pos:g[f]};e.hierarchy[0]=
+THREE.PathControls=function(a,c){function b(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function g(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),q=g.length,t=0;f=q-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<q-1;f++)t=d*h.chunks[f]/h.total,b.keys[f]={time:t,pos:g[f]};e.hierarchy[0]=
 b;THREE.AnimationHandler.add(e);return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(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=c!==void 0?c: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.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=Math.PI*2,h=Math.PI/180;this.update=function(a){var c;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=a>=0?a:a+f;c=this.verticalAngleMap.srcRange;
@@ -471,12 +472,12 @@ THREE.FlyControls=function(a,c){function b(a,b){return function(){b.apply(a,argu
 this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=
 -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",b(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",b(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",b(this,
 this.mouseup),!1);this.domElement.addEventListener("keydown",b(this,this.keydown),!1);this.domElement.addEventListener("keyup",b(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};
-THREE.RollControls=function(a,c){this.object=a;this.domElement=c!==void 0?c:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var b=new THREE.Vector3,d=new THREE.Vector3,g=new THREE.Vector3,e=new THREE.Matrix4,f=!1,h=1,i=0,l=0,k=0,o=0,p=0,n=window.innerWidth/2,r=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var c=a*this.lookSpeed;
+THREE.RollControls=function(a,c){this.object=a;this.domElement=c!==void 0?c:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var b=new THREE.Vector3,d=new THREE.Vector3,g=new THREE.Vector3,e=new THREE.Matrix4,f=!1,h=1,i=0,l=0,k=0,o=0,p=0,n=window.innerWidth/2,s=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var c=a*this.lookSpeed;
 this.rotateHorizontally(c*o);this.rotateVertically(c*p)}c=a*this.movementSpeed;this.object.translateZ(-c*(i>0||this.autoForward&&!(i<0)?1:i));this.object.translateX(c*l);this.object.translateY(c*k);f&&(this.roll+=this.rollSpeed*a*h);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();g.copy(this.forward);d.set(0,1,0);b.cross(d,
 g).normalize();d.cross(g,b).normalize();this.object.matrix.n11=b.x;this.object.matrix.n12=d.x;this.object.matrix.n13=g.x;this.object.matrix.n21=b.y;this.object.matrix.n22=d.y;this.object.matrix.n23=g.y;this.object.matrix.n31=b.z;this.object.matrix.n32=d.z;this.object.matrix.n33=g.z;e.identity();e.n11=Math.cos(this.roll);e.n12=-Math.sin(this.roll);e.n21=Math.sin(this.roll);e.n22=Math.cos(this.roll);this.object.matrix.multiplySelf(e);this.object.matrixWorldNeedsUpdate=!0;this.object.matrix.n14=this.object.position.x;
 this.object.matrix.n24=this.object.position.y;this.object.matrix.n34=this.object.position.z};this.translateX=function(a){this.object.position.x+=this.object.matrix.n11*a;this.object.position.y+=this.object.matrix.n21*a;this.object.position.z+=this.object.matrix.n31*a};this.translateY=function(a){this.object.position.x+=this.object.matrix.n12*a;this.object.position.y+=this.object.matrix.n22*a;this.object.position.z+=this.object.matrix.n32*a};this.translateZ=function(a){this.object.position.x-=this.object.matrix.n13*
 a;this.object.position.y-=this.object.matrix.n23*a;this.object.position.z-=this.object.matrix.n33*a};this.rotateHorizontally=function(a){b.set(this.object.matrix.n11,this.object.matrix.n21,this.object.matrix.n31);b.multiplyScalar(a);this.forward.subSelf(b);this.forward.normalize()};this.rotateVertically=function(a){d.set(this.object.matrix.n12,this.object.matrix.n22,this.object.matrix.n32);d.multiplyScalar(a);this.forward.addSelf(d);this.forward.normalize()};this.domElement.addEventListener("contextmenu",
-function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){o=(a.clientX-n)/window.innerWidth;p=(a.clientY-r)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=1;break;case 2:i=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=0;break;case 2:i=0}},!1);this.domElement.addEventListener("keydown",
+function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){o=(a.clientX-n)/window.innerWidth;p=(a.clientY-s)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=1;break;case 2:i=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=0;break;case 2:i=0}},!1);this.domElement.addEventListener("keydown",
 function(a){switch(a.keyCode){case 38:case 87:i=1;break;case 37:case 65:l=-1;break;case 40:case 83:i=-1;break;case 39:case 68:l=1;break;case 81:f=!0;h=1;break;case 69:f=!0;h=-1;break;case 82:k=1;break;case 70:k=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:i=0;break;case 37:case 65:l=0;break;case 40:case 83:i=0;break;case 39:case 68:l=0;break;case 81:f=!1;break;case 69:f=!1;break;case 82:k=0;break;case 70:k=0}},!1)};
 THREE.TrackballControls=function(a,c){var b=this,d={NONE:-1,ROTATE:0,ZOOM:1,PAN:2};this.object=a;this.domElement=c!==void 0?c:document;this.enabled=!0;this.screen={width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=(this.screen.width+this.screen.height)/4;this.rotateSpeed=1;this.zoomSpeed=1.2;this.panSpeed=0.3;this.staticMoving=this.noPan=this.noZoom=!1;this.dynamicDampingFactor=0.2;this.minDistance=0;this.maxDistance=Infinity;this.keys=[65,83,68];this.target=
 new THREE.Vector3(0,0,0);var g=!1,e=d.NONE,f=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,l=new THREE.Vector2,k=new THREE.Vector2,o=new THREE.Vector2,p=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,c){return new THREE.Vector2((a-b.screen.offsetLeft)/b.radius*0.5,(c-b.screen.offsetTop)/b.radius*0.5)};this.getMouseProjectionOnBall=function(a,c){var d=new THREE.Vector3((a-b.screen.width*0.5-b.screen.offsetLeft)/
@@ -486,23 +487,23 @@ b.object.position.addSelf(c);b.target.addSelf(c);b.staticMoving?o=p:o.addSelf(a.
 b.panCamera();b.object.position.add(b.target,f);b.checkDistances();b.object.lookAt(b.target)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){b.enabled&&(g&&(h=i=b.getMouseProjectionOnBall(a.clientX,a.clientY),l=k=b.getMouseOnScreen(a.clientX,a.clientY),o=p=b.getMouseOnScreen(a.clientX,a.clientY),g=!1),e!==d.NONE&&(e===d.ROTATE?i=b.getMouseProjectionOnBall(a.clientX,a.clientY):e===d.ZOOM&&!b.noZoom?k=b.getMouseOnScreen(a.clientX,
 a.clientY):e===d.PAN&&!b.noPan&&(p=b.getMouseOnScreen(a.clientX,a.clientY))))},!1);this.domElement.addEventListener("mousedown",function(a){if(b.enabled&&(a.preventDefault(),a.stopPropagation(),e===d.NONE))e=a.button,e===d.ROTATE?h=i=b.getMouseProjectionOnBall(a.clientX,a.clientY):e===d.ZOOM&&!b.noZoom?l=k=b.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(o=p=b.getMouseOnScreen(a.clientX,a.clientY))},!1);this.domElement.addEventListener("mouseup",function(a){if(b.enabled)a.preventDefault(),a.stopPropagation(),
 e=d.NONE},!1);window.addEventListener("keydown",function(a){if(b.enabled&&e===d.NONE){if(a.keyCode===b.keys[d.ROTATE])e=d.ROTATE;else if(a.keyCode===b.keys[d.ZOOM]&&!b.noZoom)e=d.ZOOM;else if(a.keyCode===b.keys[d.PAN]&&!b.noPan)e=d.PAN;e!==d.NONE&&(g=!0)}},!1);window.addEventListener("keyup",function(){if(b.enabled&&e!==d.NONE)e=d.NONE},!1)};
-THREE.CubeGeometry=function(a,c,b,d,g,e,f,h){function i(a,b,c,f,h,i,k,m){var n,o=d||1,p=g||1,r=h/2,s=i/2,q=l.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x")n="y",p=e||1;else if(a==="z"&&b==="y"||a==="y"&&b==="z")n="x",o=e||1;var t=o+1,v=p+1,z=h/o,y=i/p,L=new THREE.Vector3;L[n]=k>0?1:-1;for(h=0;h<v;h++)for(i=0;i<t;i++){var j=new THREE.Vector3;j[a]=(i*z-r)*c;j[b]=(h*y-s)*f;j[n]=k;l.vertices.push(new THREE.Vertex(j))}for(h=0;h<p;h++)for(i=0;i<o;i++)a=
-new THREE.Face4(i+t*h+q,i+t*(h+1)+q,i+1+t*(h+1)+q,i+1+t*h+q),a.normal.copy(L),a.vertexNormals.push(L.clone(),L.clone(),L.clone(),L.clone()),a.materialIndex=m,l.faces.push(a),l.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 l=this,k=a/2,o=c/2,p=b/2,n,r,m,s,t,v;if(f!==void 0){if(f instanceof Array)this.materials=f;else{this.materials=[];for(n=0;n<6;n++)this.materials.push(f)}n=0;s=1;r=2;t=
-3;m=4;v=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(h!=void 0)for(var q in h)this.sides[q]!=void 0&&(this.sides[q]=h[q]);this.sides.px&&i("z","y",-1,-1,b,c,k,n);this.sides.nx&&i("z","y",1,-1,b,c,-k,s);this.sides.py&&i("x","z",1,1,a,b,o,r);this.sides.ny&&i("x","z",1,-1,a,b,-o,t);this.sides.pz&&i("x","y",1,-1,a,c,p,m);this.sides.nz&&i("x","y",-1,-1,a,c,-p,v);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry;
+THREE.CubeGeometry=function(a,c,b,d,g,e,f,h){function i(a,b,c,f,h,i,k,m){var n,o=d||1,p=g||1,q=h/2,s=i/2,r=l.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x")n="y",p=e||1;else if(a==="z"&&b==="y"||a==="y"&&b==="z")n="x",o=e||1;var t=o+1,u=p+1,F=h/o,y=i/p,L=new THREE.Vector3;L[n]=k>0?1:-1;for(h=0;h<u;h++)for(i=0;i<t;i++){var j=new THREE.Vector3;j[a]=(i*F-q)*c;j[b]=(h*y-s)*f;j[n]=k;l.vertices.push(new THREE.Vertex(j))}for(h=0;h<p;h++)for(i=0;i<o;i++)a=
+new THREE.Face4(i+t*h+r,i+t*(h+1)+r,i+1+t*(h+1)+r,i+1+t*h+r),a.normal.copy(L),a.vertexNormals.push(L.clone(),L.clone(),L.clone(),L.clone()),a.materialIndex=m,l.faces.push(a),l.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 l=this,k=a/2,o=c/2,p=b/2,n,s,m,q,t,u;if(f!==void 0){if(f instanceof Array)this.materials=f;else{this.materials=[];for(n=0;n<6;n++)this.materials.push(f)}n=0;q=1;s=2;t=
+3;m=4;u=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(h!=void 0)for(var r in h)this.sides[r]!=void 0&&(this.sides[r]=h[r]);this.sides.px&&i("z","y",-1,-1,b,c,k,n);this.sides.nx&&i("z","y",1,-1,b,c,-k,q);this.sides.py&&i("x","z",1,1,a,b,o,s);this.sides.ny&&i("x","z",1,-1,a,b,-o,t);this.sides.pz&&i("x","y",1,-1,a,c,p,m);this.sides.nz&&i("x","y",-1,-1,a,c,-p,u);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry;
 THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
-THREE.CylinderGeometry=function(a,c,b,d,g,e){THREE.Geometry.call(this);var a=a!=null?a:20,c=c!=null?c:20,b=b||100,f=b/2,d=d||8,g=g||1,h,i,l=[],k=[];for(i=0;i<=g;i++){var o=[],p=[],n=i/g,r=n*(c-a)+a;for(h=0;h<=d;h++){var m=h/d;this.vertices.push(new THREE.Vertex(new THREE.Vector3(r*Math.sin(m*Math.PI*2),-n*b+f,r*Math.cos(m*Math.PI*2))));o.push(this.vertices.length-1);p.push(new THREE.UV(m,n))}l.push(o);k.push(p)}for(i=0;i<g;i++)for(h=0;h<d;h++){var b=l[i][h],o=l[i+1][h],p=l[i+1][h+1],n=l[i][h+1],r=
-this.vertices[b].position.clone().setY(0).normalize(),m=this.vertices[o].position.clone().setY(0).normalize(),s=this.vertices[p].position.clone().setY(0).normalize(),t=this.vertices[n].position.clone().setY(0).normalize(),v=k[i][h].clone(),q=k[i+1][h].clone(),A=k[i+1][h+1].clone(),w=k[i][h+1].clone();this.faces.push(new THREE.Face4(b,o,p,n,[r,m,s,t]));this.faceVertexUvs[0].push([v,q,A,w])}if(!e&&a>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(h=0;h<d;h++)b=l[0][h],o=l[0][h+
-1],p=this.vertices.length-1,r=new THREE.Vector3(0,1,0),m=new THREE.Vector3(0,1,0),s=new THREE.Vector3(0,1,0),v=k[0][h].clone(),q=k[0][h+1].clone(),A=new THREE.UV(q.u,0),this.faces.push(new THREE.Face3(b,o,p,[r,m,s])),this.faceVertexUvs[0].push([v,q,A])}if(!e&&c>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(h=0;h<d;h++)b=l[i][h+1],o=l[i][h],p=this.vertices.length-1,r=new THREE.Vector3(0,-1,0),m=new THREE.Vector3(0,-1,0),s=new THREE.Vector3(0,-1,0),v=k[i][h+1].clone(),q=k[i][h].clone(),
-A=new THREE.UV(q.u,1),this.faces.push(new THREE.Face3(b,o,p,[r,m,s])),this.faceVertexUvs[0].push([v,q,A])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
+THREE.CylinderGeometry=function(a,c,b,d,g,e){THREE.Geometry.call(this);var a=a!=null?a:20,c=c!=null?c:20,b=b||100,f=b/2,d=d||8,g=g||1,h,i,l=[],k=[];for(i=0;i<=g;i++){var o=[],p=[],n=i/g,s=n*(c-a)+a;for(h=0;h<=d;h++){var m=h/d;this.vertices.push(new THREE.Vertex(new THREE.Vector3(s*Math.sin(m*Math.PI*2),-n*b+f,s*Math.cos(m*Math.PI*2))));o.push(this.vertices.length-1);p.push(new THREE.UV(m,n))}l.push(o);k.push(p)}for(i=0;i<g;i++)for(h=0;h<d;h++){var b=l[i][h],o=l[i+1][h],p=l[i+1][h+1],n=l[i][h+1],s=
+this.vertices[b].position.clone().setY(0).normalize(),m=this.vertices[o].position.clone().setY(0).normalize(),q=this.vertices[p].position.clone().setY(0).normalize(),t=this.vertices[n].position.clone().setY(0).normalize(),u=k[i][h].clone(),r=k[i+1][h].clone(),z=k[i+1][h+1].clone(),w=k[i][h+1].clone();this.faces.push(new THREE.Face4(b,o,p,n,[s,m,q,t]));this.faceVertexUvs[0].push([u,r,z,w])}if(!e&&a>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(h=0;h<d;h++)b=l[0][h],o=l[0][h+
+1],p=this.vertices.length-1,s=new THREE.Vector3(0,1,0),m=new THREE.Vector3(0,1,0),q=new THREE.Vector3(0,1,0),u=k[0][h].clone(),r=k[0][h+1].clone(),z=new THREE.UV(r.u,0),this.faces.push(new THREE.Face3(b,o,p,[s,m,q])),this.faceVertexUvs[0].push([u,r,z])}if(!e&&c>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(h=0;h<d;h++)b=l[i][h+1],o=l[i][h],p=this.vertices.length-1,s=new THREE.Vector3(0,-1,0),m=new THREE.Vector3(0,-1,0),q=new THREE.Vector3(0,-1,0),u=k[i][h+1].clone(),r=k[i][h].clone(),
+z=new THREE.UV(r.u,1),this.faces.push(new THREE.Face3(b,o,p,[s,m,q])),this.faceVertexUvs[0].push([u,r,z])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
 THREE.ExtrudeGeometry=function(a,c){if(typeof a!=="undefined"){THREE.Geometry.call(this);var a=a instanceof Array?a:[a],b,d=a.length,g;this.shapebb=a[d-1].getBoundingBox();for(b=0;b<d;b++)g=a[b],this.addShape(g,c);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
 THREE.ExtrudeGeometry.prototype.addShape=function(a,c){function b(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);f===0&&(console.log("Either infinite or no solutions!"),g===0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;if(g<0)return 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+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function g(a){for(E=a.length;--E>=0;){j=E;ca=E-1;ca<0&&(ca=a.length-1);for(var b=
-0,c=n+k*2,b=0;b<c;b++){var d=W*b,e=W*(b+1),f=ga+j+d,g=ga+j+e,l=f,d=ga+ca+d,e=ga+ca+e,m=g;l+=K;d+=K;e+=K;m+=K;M.faces.push(new THREE.Face4(l,d,e,m,null,null,A));A&&(l=b/c,d=(b+1)/c,e=h+i*2,f=(M.vertices[f].position.z+i)/e,g=(M.vertices[g].position.z+i)/e,M.faceVertexUvs[0].push([new THREE.UV(f,l),new THREE.UV(g,l),new THREE.UV(g,d),new THREE.UV(f,d)]))}}}function e(a,b,c){M.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function f(a,b,c){a+=K;b+=K;c+=K;M.faces.push(new THREE.Face3(a,b,c,
-null,null,q));if(q){var d=w.maxY,e=w.maxX,f=M.vertices[b].position.x,b=M.vertices[b].position.y,g=M.vertices[c].position.x,c=M.vertices[c].position.y;M.faceVertexUvs[0].push([new THREE.UV(M.vertices[a].position.x/e,M.vertices[a].position.y/d),new THREE.UV(f/e,b/d),new THREE.UV(g/e,c/d)])}}var h=c.amount!==void 0?c.amount:100,i=c.bevelThickness!==void 0?c.bevelThickness:6,l=c.bevelSize!==void 0?c.bevelSize:i-2,k=c.bevelSegments!==void 0?c.bevelSegments:3,o=c.bevelEnabled!==void 0?c.bevelEnabled:!0,
-p=c.curveSegments!==void 0?c.curveSegments:12,n=c.steps!==void 0?c.steps:1,r=c.bendPath,m=c.extrudePath,s,t=!1,v=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,q=c.material,A=c.extrudeMaterial,w=this.shapebb;if(m)s=m.getPoints(p),n=s.length,t=!0,o=!1;o||(l=i=k=0);var D,x,J,M=this,K=this.vertices.length;r&&a.addWrapPath(r);p=v?a.extractAllSpacedPoints(p):a.extractAllPoints(p);r=p.shape;p=p.holes;if(m=!THREE.Shape.Utils.isClockWise(r)){r=r.reverse();x=0;for(J=p.length;x<J;x++)D=p[x],THREE.Shape.Utils.isClockWise(D)&&
-(p[x]=D.reverse());m=!1}m=THREE.Shape.Utils.triangulateShape(r,p);v=r;x=0;for(J=p.length;x<J;x++)D=p[x],r=r.concat(D);var E,P,I,V,Z,R,W=r.length,ka=m.length,G=[];E=0;P=v.length;j=P-1;for(ca=E+1;E<P;E++,j++,ca++)j===P&&(j=0),ca===P&&(ca=0),G[E]=d(v[E],v[j],v[ca]);var z=[],y,L=G.concat();x=0;for(J=p.length;x<J;x++){D=p[x];y=[];E=0;P=D.length;j=P-1;for(ca=E+1;E<P;E++,j++,ca++)j===P&&(j=0),ca===P&&(ca=0),y[E]=d(D[E],D[j],D[ca]);z.push(y);L=L.concat(y)}for(I=0;I<k;I++){V=I/k;Z=i*(1-V);V=l*Math.sin(V*Math.PI/
-2);E=0;for(P=v.length;E<P;E++)R=b(v[E],G[E],V),e(R.x,R.y,-Z);x=0;for(J=p.length;x<J;x++){D=p[x];y=z[x];E=0;for(P=D.length;E<P;E++)R=b(D[E],y[E],V),e(R.x,R.y,-Z)}}V=l;for(E=0;E<W;E++)R=o?b(r[E],L[E],V):r[E],t?e(R.x,R.y+s[0].y,s[0].x):e(R.x,R.y,0);for(I=1;I<=n;I++)for(E=0;E<W;E++)R=o?b(r[E],L[E],V):r[E],t?e(R.x,R.y+s[I-1].y,s[I-1].x):e(R.x,R.y,h/n*I);for(I=k-1;I>=0;I--){V=I/k;Z=i*(1-V);V=l*Math.sin(V*Math.PI/2);E=0;for(P=v.length;E<P;E++)R=b(v[E],G[E],V),e(R.x,R.y,h+Z);x=0;for(J=p.length;x<J;x++){D=
-p[x];y=z[x];E=0;for(P=D.length;E<P;E++)R=b(D[E],y[E],V),t?e(R.x,R.y+s[n-1].y,s[n-1].x+Z):e(R.x,R.y,h+Z)}}if(o){o=W*0;for(E=0;E<ka;E++)l=m[E],f(l[2]+o,l[1]+o,l[0]+o);o=W*(n+k*2);for(E=0;E<ka;E++)l=m[E],f(l[0]+o,l[1]+o,l[2]+o)}else{for(E=0;E<ka;E++)l=m[E],f(l[2],l[1],l[0]);for(E=0;E<ka;E++)l=m[E],f(l[0]+W*n,l[1]+W*n,l[2]+W*n)}var j,ca,ga=0;g(v);ga+=v.length;x=0;for(J=p.length;x<J;x++)D=p[x],g(D),ga+=D.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;
+h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);f===0&&(console.log("Either infinite or no solutions!"),g===0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;if(g<0)return 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+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function g(a){for(D=a.length;--D>=0;){j=D;X=D-1;X<0&&(X=a.length-1);for(var b=
+0,c=n+k*2,b=0;b<c;b++){var d=S*b,e=S*(b+1),f=fa+j+d,g=fa+j+e,l=f,d=fa+X+d,e=fa+X+e,m=g;l+=K;d+=K;e+=K;m+=K;G.faces.push(new THREE.Face4(l,d,e,m,null,null,z));z&&(l=b/c,d=(b+1)/c,e=h+i*2,f=(G.vertices[f].position.z+i)/e,g=(G.vertices[g].position.z+i)/e,G.faceVertexUvs[0].push([new THREE.UV(f,l),new THREE.UV(g,l),new THREE.UV(g,d),new THREE.UV(f,d)]))}}}function e(a,b,c){G.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function f(a,b,c){a+=K;b+=K;c+=K;G.faces.push(new THREE.Face3(a,b,c,null,
+null,r));if(r){var d=w.maxY,e=w.maxX,f=G.vertices[b].position.x,b=G.vertices[b].position.y,g=G.vertices[c].position.x,c=G.vertices[c].position.y;G.faceVertexUvs[0].push([new THREE.UV(G.vertices[a].position.x/e,G.vertices[a].position.y/d),new THREE.UV(f/e,b/d),new THREE.UV(g/e,c/d)])}}var h=c.amount!==void 0?c.amount:100,i=c.bevelThickness!==void 0?c.bevelThickness:6,l=c.bevelSize!==void 0?c.bevelSize:i-2,k=c.bevelSegments!==void 0?c.bevelSegments:3,o=c.bevelEnabled!==void 0?c.bevelEnabled:!0,p=c.curveSegments!==
+void 0?c.curveSegments:12,n=c.steps!==void 0?c.steps:1,s=c.bendPath,m=c.extrudePath,q,t=!1,u=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,r=c.material,z=c.extrudeMaterial,w=this.shapebb;if(m)q=m.getPoints(p),n=q.length,t=!0,o=!1;o||(l=i=k=0);var C,x,O,G=this,K=this.vertices.length;s&&a.addWrapPath(s);p=u?a.extractAllSpacedPoints(p):a.extractAllPoints(p);s=p.shape;p=p.holes;if(m=!THREE.Shape.Utils.isClockWise(s)){s=s.reverse();x=0;for(O=p.length;x<O;x++)C=p[x],THREE.Shape.Utils.isClockWise(C)&&
+(p[x]=C.reverse());m=!1}m=THREE.Shape.Utils.triangulateShape(s,p);u=s;x=0;for(O=p.length;x<O;x++)C=p[x],s=s.concat(C);var D,P,I,W,Z,R,S=s.length,ia=m.length,H=[];D=0;P=u.length;j=P-1;for(X=D+1;D<P;D++,j++,X++)j===P&&(j=0),X===P&&(X=0),H[D]=d(u[D],u[j],u[X]);var F=[],y,L=H.concat();x=0;for(O=p.length;x<O;x++){C=p[x];y=[];D=0;P=C.length;j=P-1;for(X=D+1;D<P;D++,j++,X++)j===P&&(j=0),X===P&&(X=0),y[D]=d(C[D],C[j],C[X]);F.push(y);L=L.concat(y)}for(I=0;I<k;I++){W=I/k;Z=i*(1-W);W=l*Math.sin(W*Math.PI/2);
+D=0;for(P=u.length;D<P;D++)R=b(u[D],H[D],W),e(R.x,R.y,-Z);x=0;for(O=p.length;x<O;x++){C=p[x];y=F[x];D=0;for(P=C.length;D<P;D++)R=b(C[D],y[D],W),e(R.x,R.y,-Z)}}W=l;for(D=0;D<S;D++)R=o?b(s[D],L[D],W):s[D],t?e(R.x,R.y+q[0].y,q[0].x):e(R.x,R.y,0);for(I=1;I<=n;I++)for(D=0;D<S;D++)R=o?b(s[D],L[D],W):s[D],t?e(R.x,R.y+q[I-1].y,q[I-1].x):e(R.x,R.y,h/n*I);for(I=k-1;I>=0;I--){W=I/k;Z=i*(1-W);W=l*Math.sin(W*Math.PI/2);D=0;for(P=u.length;D<P;D++)R=b(u[D],H[D],W),e(R.x,R.y,h+Z);x=0;for(O=p.length;x<O;x++){C=p[x];
+y=F[x];D=0;for(P=C.length;D<P;D++)R=b(C[D],y[D],W),t?e(R.x,R.y+q[n-1].y,q[n-1].x+Z):e(R.x,R.y,h+Z)}}if(o){o=S*0;for(D=0;D<ia;D++)l=m[D],f(l[2]+o,l[1]+o,l[0]+o);o=S*(n+k*2);for(D=0;D<ia;D++)l=m[D],f(l[0]+o,l[1]+o,l[2]+o)}else{for(D=0;D<ia;D++)l=m[D],f(l[2],l[1],l[0]);for(D=0;D<ia;D++)l=m[D],f(l[0]+S*n,l[1]+S*n,l[2]+S*n)}var j,X,fa=0;g(u);fa+=u.length;x=0;for(O=p.length;x<O;x++)C=p[x],g(C),fa+=C.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;
 THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
 THREE.IcosahedronGeometry=function(a){function c(a,b,c){var d=Math.sqrt(a*a+b*b+c*c);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(a/d,b/d,c/d)))-1}function b(a,b,c,d){d.faces.push(new THREE.Face3(a,b,c))}function d(a,b){var d=g.vertices[a].position,e=g.vertices[b].position;return c((d.x+e.x)/2,(d.y+e.y)/2,(d.z+e.z)/2)}var g=this,e=new THREE.Geometry;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,
 -a);c(0,1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,e);b(0,5,1,e);b(0,1,7,e);b(0,7,10,e);b(0,10,11,e);b(1,5,9,e);b(5,11,4,e);b(11,10,2,e);b(10,7,6,e);b(7,1,8,e);b(3,9,4,e);b(3,4,2,e);b(3,2,6,e);b(3,6,8,e);b(3,8,9,e);b(4,9,5,e);b(2,4,11,e);b(6,2,10,e);b(8,6,7,e);b(9,8,1,e);for(var f=0;f<this.subdivisions;f++){var a=new THREE.Geometry,h;for(h in e.faces){var i=d(e.faces[h].a,e.faces[h].b),l=d(e.faces[h].b,e.faces[h].c),k=d(e.faces[h].c,e.faces[h].a);b(e.faces[h].a,i,k,a);b(e.faces[h].b,l,
@@ -515,18 +516,18 @@ f.faces.push(h),h=Math.atan2(h.centroid.z,-h.centroid.x),f.faceVertexUvs[0].push
 {radius:a}};THREE.OctahedronGeometry.prototype=new THREE.Geometry;THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry;
 THREE.PlaneGeometry=function(a,c,b,d){THREE.Geometry.call(this);for(var g=a/2,e=c/2,b=b||1,d=d||1,f=b+1,h=d+1,i=a/b,l=c/d,k=new THREE.Vector3(0,0,1),a=0;a<h;a++)for(c=0;c<f;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*i-g,-(a*l-e),0)));for(a=0;a<d;a++)for(c=0;c<b;c++)g=new THREE.Face4(c+f*a,c+f*(a+1),c+1+f*(a+1),c+1+f*a),g.normal.copy(k),g.vertexNormals.push(k.clone(),k.clone(),k.clone(),k.clone()),this.faces.push(g),this.faceVertexUvs[0].push([new THREE.UV(c/b,a/d),new THREE.UV(c/
 b,(a+1)/d),new THREE.UV((c+1)/b,(a+1)/d),new THREE.UV((c+1)/b,a/d)]);this.computeCentroids()};THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
-THREE.SphereGeometry=function(a,c,b){THREE.Geometry.call(this);for(var a=a||50,d,g=Math.PI,e=Math.max(3,c||8),f=Math.max(2,b||6),c=[],b=0;b<f+1;b++){d=b/f;var h=a*Math.cos(d*g),i=a*Math.sin(d*g),l=[],k=0;for(d=0;d<e;d++){var o=2*d/e,p=i*Math.sin(o*g),o=i*Math.cos(o*g);(b==0||b==f)&&d>0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o,h,p)))-1);l.push(k)}c.push(l)}for(var n,r,m,g=c.length,b=0;b<g;b++)if(e=c[b].length,b>0)for(d=0;d<e;d++){l=d==e-1;f=c[b][l?0:d+1];h=c[b][l?e-1:d];i=c[b-1][l?
-e-1:d];l=c[b-1][l?0:d+1];p=b/(g-1);n=(b-1)/(g-1);r=(d+1)/e;var o=d/e,k=new THREE.UV(1-r,p),p=new THREE.UV(1-o,p),o=new THREE.UV(1-o,n),s=new THREE.UV(1-r,n);b<c.length-1&&(n=this.vertices[f].position.clone(),r=this.vertices[h].position.clone(),m=this.vertices[i].position.clone(),n.normalize(),r.normalize(),m.normalize(),this.faces.push(new THREE.Face3(f,h,i,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(m.x,m.y,m.z)])),this.faceVertexUvs[0].push([k,p,o]));b>1&&(n=
-this.vertices[f].position.clone(),r=this.vertices[i].position.clone(),m=this.vertices[l].position.clone(),n.normalize(),r.normalize(),m.normalize(),this.faces.push(new THREE.Face3(f,i,l,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(m.x,m.y,m.z)])),this.faceVertexUvs[0].push([k,o,s]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;
+THREE.SphereGeometry=function(a,c,b){THREE.Geometry.call(this);for(var a=a||50,d,g=Math.PI,e=Math.max(3,c||8),f=Math.max(2,b||6),c=[],b=0;b<f+1;b++){d=b/f;var h=a*Math.cos(d*g),i=a*Math.sin(d*g),l=[],k=0;for(d=0;d<e;d++){var o=2*d/e,p=i*Math.sin(o*g),o=i*Math.cos(o*g);(b==0||b==f)&&d>0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o,h,p)))-1);l.push(k)}c.push(l)}for(var n,s,m,g=c.length,b=0;b<g;b++)if(e=c[b].length,b>0)for(d=0;d<e;d++){l=d==e-1;f=c[b][l?0:d+1];h=c[b][l?e-1:d];i=c[b-1][l?
+e-1:d];l=c[b-1][l?0:d+1];p=b/(g-1);n=(b-1)/(g-1);s=(d+1)/e;var o=d/e,k=new THREE.UV(1-s,p),p=new THREE.UV(1-o,p),o=new THREE.UV(1-o,n),q=new THREE.UV(1-s,n);b<c.length-1&&(n=this.vertices[f].position.clone(),s=this.vertices[h].position.clone(),m=this.vertices[i].position.clone(),n.normalize(),s.normalize(),m.normalize(),this.faces.push(new THREE.Face3(f,h,i,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(s.x,s.y,s.z),new THREE.Vector3(m.x,m.y,m.z)])),this.faceVertexUvs[0].push([k,p,o]));b>1&&(n=
+this.vertices[f].position.clone(),s=this.vertices[i].position.clone(),m=this.vertices[l].position.clone(),n.normalize(),s.normalize(),m.normalize(),this.faces.push(new THREE.Face3(f,i,l,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(s.x,s.y,s.z),new THREE.Vector3(m.x,m.y,m.z)])),this.faceVertexUvs[0].push([k,o,q]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;
 THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
 THREE.TextGeometry=function(a,c){var b=(new THREE.TextPath(a,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var d=b[b.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(d/2,120),new THREE.Vector2(d,0))}THREE.ExtrudeGeometry.call(this,b,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;
 THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
 THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var c=a.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][a.cssFontWeight]=this.faces[c][a.cssFontWeight]||{};this.faces[c][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[c][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var c=this.getFace(),b=this.size/c.resolution,d=
-0,g=String(a).split(""),e=g.length,f=[],a=0;a<e;a++){var h=new THREE.Path,h=this.extractGlyphPoints(g[a],c,b,d,h);d+=h.offset;f.push(h.path)}return{paths:f,offset:d/2}},extractGlyphPoints:function(a,c,b,d,g){var e=[],f,h,i,l,k,o,p,n,r,m,s,t=c.glyphs[a]||c.glyphs["?"];if(t){if(t.o){c=t._cachedOutline||(t._cachedOutline=t.o.split(" "));l=c.length;for(a=0;a<l;)switch(i=c[a++],i){case "m":i=c[a++]*b+d;k=c[a++]*b;e.push(new THREE.Vector2(i,k));g.moveTo(i,k);break;case "l":i=c[a++]*b+d;k=c[a++]*b;e.push(new THREE.Vector2(i,
-k));g.lineTo(i,k);break;case "q":i=c[a++]*b+d;k=c[a++]*b;n=c[a++]*b+d;r=c[a++]*b;g.quadraticCurveTo(n,r,i,k);if(f=e[e.length-1]){o=f.x;p=f.y;f=1;for(h=this.divisions;f<=h;f++){var v=f/h,q=THREE.Shape.Utils.b2(v,o,n,i),v=THREE.Shape.Utils.b2(v,p,r,k);e.push(new THREE.Vector2(q,v))}}break;case "b":if(i=c[a++]*b+d,k=c[a++]*b,n=c[a++]*b+d,r=c[a++]*-b,m=c[a++]*b+d,s=c[a++]*-b,g.bezierCurveTo(i,k,n,r,m,s),f=e[e.length-1]){o=f.x;p=f.y;f=1;for(h=this.divisions;f<=h;f++)v=f/h,q=THREE.Shape.Utils.b3(v,o,n,
-m,i),v=THREE.Shape.Utils.b3(v,p,r,s,k),e.push(new THREE.Vector2(q,v))}}}return{offset:t.ha*b,points:e,path:g}}}};
-(function(a){var c=function(a){for(var c=a.length,g=0,e=c-1,f=0;f<c;e=f++)g+=a[e].x*a[f].y-a[f].x*a[e].y;return g*0.5};a.Triangulate=function(a,d){var g=a.length;if(g<3)return null;var e=[],f=[],h=[],i,l,k;if(c(a)>0)for(l=0;l<g;l++)f[l]=l;else for(l=0;l<g;l++)f[l]=g-1-l;var o=2*g;for(l=g-1;g>2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return e}i=l;g<=i&&(i=0);l=i+1;g<=l&&(l=0);k=l+1;g<=k&&(k=0);var p;a:{p=a;var n=i,r=l,m=k,s=g,t=f,v=void 0,q=void 0,A=void 0,
-w=void 0,D=void 0,x=void 0,J=void 0,M=void 0,K=void 0,q=p[t[n]].x,A=p[t[n]].y,w=p[t[r]].x,D=p[t[r]].y,x=p[t[m]].x,J=p[t[m]].y;if(1.0E-10>(w-q)*(J-A)-(D-A)*(x-q))p=!1;else{for(v=0;v<s;v++)if(!(v==n||v==r||v==m)){var M=p[t[v]].x,K=p[t[v]].y,E=void 0,P=void 0,I=void 0,V=void 0,Z=void 0,R=void 0,W=void 0,ka=void 0,G=void 0,z=void 0,y=void 0,L=void 0,E=I=Z=void 0,E=x-w,P=J-D,I=q-x,V=A-J,Z=w-q,R=D-A,W=M-q,ka=K-A,G=M-w,z=K-D,y=M-x,L=K-J,E=E*z-P*G,Z=Z*ka-R*W,I=I*L-V*y;if(E>=0&&I>=0&&Z>=0){p=!1;break a}}p=
+0,g=String(a).split(""),e=g.length,f=[],a=0;a<e;a++){var h=new THREE.Path,h=this.extractGlyphPoints(g[a],c,b,d,h);d+=h.offset;f.push(h.path)}return{paths:f,offset:d/2}},extractGlyphPoints:function(a,c,b,d,g){var e=[],f,h,i,l,k,o,p,n,s,m,q,t=c.glyphs[a]||c.glyphs["?"];if(t){if(t.o){c=t._cachedOutline||(t._cachedOutline=t.o.split(" "));l=c.length;for(a=0;a<l;)switch(i=c[a++],i){case "m":i=c[a++]*b+d;k=c[a++]*b;e.push(new THREE.Vector2(i,k));g.moveTo(i,k);break;case "l":i=c[a++]*b+d;k=c[a++]*b;e.push(new THREE.Vector2(i,
+k));g.lineTo(i,k);break;case "q":i=c[a++]*b+d;k=c[a++]*b;n=c[a++]*b+d;s=c[a++]*b;g.quadraticCurveTo(n,s,i,k);if(f=e[e.length-1]){o=f.x;p=f.y;f=1;for(h=this.divisions;f<=h;f++){var u=f/h,r=THREE.Shape.Utils.b2(u,o,n,i),u=THREE.Shape.Utils.b2(u,p,s,k);e.push(new THREE.Vector2(r,u))}}break;case "b":if(i=c[a++]*b+d,k=c[a++]*b,n=c[a++]*b+d,s=c[a++]*-b,m=c[a++]*b+d,q=c[a++]*-b,g.bezierCurveTo(i,k,n,s,m,q),f=e[e.length-1]){o=f.x;p=f.y;f=1;for(h=this.divisions;f<=h;f++)u=f/h,r=THREE.Shape.Utils.b3(u,o,n,
+m,i),u=THREE.Shape.Utils.b3(u,p,s,q,k),e.push(new THREE.Vector2(r,u))}}}return{offset:t.ha*b,points:e,path:g}}}};
+(function(a){var c=function(a){for(var c=a.length,g=0,e=c-1,f=0;f<c;e=f++)g+=a[e].x*a[f].y-a[f].x*a[e].y;return g*0.5};a.Triangulate=function(a,d){var g=a.length;if(g<3)return null;var e=[],f=[],h=[],i,l,k;if(c(a)>0)for(l=0;l<g;l++)f[l]=l;else for(l=0;l<g;l++)f[l]=g-1-l;var o=2*g;for(l=g-1;g>2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return e}i=l;g<=i&&(i=0);l=i+1;g<=l&&(l=0);k=l+1;g<=k&&(k=0);var p;a:{p=a;var n=i,s=l,m=k,q=g,t=f,u=void 0,r=void 0,z=void 0,
+w=void 0,C=void 0,x=void 0,O=void 0,G=void 0,K=void 0,r=p[t[n]].x,z=p[t[n]].y,w=p[t[s]].x,C=p[t[s]].y,x=p[t[m]].x,O=p[t[m]].y;if(1.0E-10>(w-r)*(O-z)-(C-z)*(x-r))p=!1;else{for(u=0;u<q;u++)if(!(u==n||u==s||u==m)){var G=p[t[u]].x,K=p[t[u]].y,D=void 0,P=void 0,I=void 0,W=void 0,Z=void 0,R=void 0,S=void 0,ia=void 0,H=void 0,F=void 0,y=void 0,L=void 0,D=I=Z=void 0,D=x-w,P=O-C,I=r-x,W=z-O,Z=w-r,R=C-z,S=G-r,ia=K-z,H=G-w,F=K-C,y=G-x,L=K-O,D=D*F-P*H,Z=Z*ia-R*S,I=I*L-W*y;if(D>=0&&I>=0&&Z>=0){p=!1;break a}}p=
 !0}}if(p){e.push([a[f[i]],a[f[l]],a[f[k]]]);h.push([f[i],f[l],f[k]]);i=l;for(k=l+1;k<g;i++,k++)f[i]=f[k];g--;o=2*g}}if(d)return h;return e};a.Triangulate.area=c;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
 THREE.TorusGeometry=function(a,c,b,d,g){THREE.Geometry.call(this);this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;this.arc=g||Math.PI*2;g=new THREE.Vector3;a=[];c=[];for(b=0;b<=this.segmentsR;b++)for(d=0;d<=this.segmentsT;d++){var e=d/this.segmentsT*this.arc,f=b/this.segmentsR*Math.PI*2;g.x=this.radius*Math.cos(e);g.y=this.radius*Math.sin(e);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(f))*Math.cos(e);h.y=(this.radius+this.tube*Math.cos(f))*Math.sin(e);h.z=
 this.tube*Math.sin(f);this.vertices.push(new THREE.Vertex(h));a.push(new THREE.UV(d/this.segmentsT,1-b/this.segmentsR));c.push(h.clone().subSelf(g).normalize())}for(b=1;b<=this.segmentsR;b++)for(d=1;d<=this.segmentsT;d++){var g=(this.segmentsT+1)*b+d-1,e=(this.segmentsT+1)*(b-1)+d-1,f=(this.segmentsT+1)*(b-1)+d,h=(this.segmentsT+1)*b+d,i=new THREE.Face4(g,e,f,h,[c[g],c[e],c[f],c[h]]);i.normal.addSelf(c[g]);i.normal.addSelf(c[e]);i.normal.addSelf(c[f]);i.normal.addSelf(c[h]);i.normal.normalize();this.faces.push(i);
@@ -536,12 +537,12 @@ this.segmentsT;++c){var i=a/this.segmentsR*2*this.p*Math.PI,f=c/this.segmentsT*2
 g.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=0;c<this.segmentsT;++c){var d=(a+1)%this.segmentsR,e=(c+1)%this.segmentsT,g=this.grid[a][c],b=this.grid[d][c],d=this.grid[d][e],e=this.grid[a][e],f=new THREE.UV(a/this.segmentsR,c/this.segmentsT),i=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT),l=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT),k=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(g,b,d,e));this.faceVertexUvs[0].push([f,i,l,k])}this.computeCentroids();
 this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;THREE.SubdivisionModifier=function(a){this.subdivisions=a===void 0?1:a;this.useOldVertexColors=!1;this.supportUVs=!0};THREE.SubdivisionModifier.prototype.constructor=THREE.SubdivisionModifier;THREE.SubdivisionModifier.prototype.modify=function(a){for(var c=this.subdivisions;c-- >0;)this.smooth(a)};
 THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,d,h,i){var k=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(f.useOldVertexColors){k.vertexColors=[];for(var j,l,m,n=0;n<4;n++){m=i[n];j=new THREE.Color;j.setRGB(0,0,0);for(var o=0;o<m.length;o++)l=h.vertexColors[m[o]-1],j.r+=l.r,j.g+=l.g,j.b+=l.b;j.r/=m.length;j.g/=m.length;j.b/=m.length;k.vertexColors[n]=j}}g.push(k);(!f.supportUVs||p.length!=0)&&e.push([p[a],p[b],p[c],p[d]])}function b(a,b){return Math.min(a,b)+"_"+Math.max(a,
-b)}var d=[],g=[],e=[],f=this,h=a.vertices,d=a.faces,i=h.concat(),l=[],k={},o={},p=[],n,r,m,s,t,v=a.faceVertexUvs[0];n=0;for(r=v.length;n<r;n++){m=0;for(s=v[n].length;m<s;m++)t=d[n]["abcd".charAt(m)],p[t]||(p[t]=v[n][m])}var q;n=0;for(r=d.length;n<r;n++)if(t=d[n],l.push(t.centroid),i.push(new THREE.Vertex(t.centroid)),f.supportUVs&&p.length!=0){q=new THREE.UV;if(t instanceof THREE.Face3)q.u=p[t.a].u+p[t.b].u+p[t.c].u,q.v=p[t.a].v+p[t.b].v+p[t.c].v,q.u/=3,q.v/=3;else if(t instanceof THREE.Face4)q.u=
-p[t.a].u+p[t.b].u+p[t.c].u+p[t.d].u,q.v=p[t.a].v+p[t.b].v+p[t.c].v+p[t.d].v,q.u/=4,q.v/=4;p.push(q)}r=function(a){function c(a,b,d){a[b]===void 0&&(a[b]=[]);a[b].push(d)}var d,e,f,g,h={};d=0;for(e=a.faces.length;d<e;d++)f=a.faces[d],f instanceof THREE.Face3?(g=b(f.a,f.b),c(h,g,d),g=b(f.b,f.c),c(h,g,d),g=b(f.c,f.a),c(h,g,d)):f instanceof THREE.Face4&&(g=b(f.a,f.b),c(h,g,d),g=b(f.b,f.c),c(h,g,d),g=b(f.c,f.d),c(h,g,d),g=b(f.d,f.a),c(h,g,d));return h}(a);var A=0,v=h.length,w,D,x={},J={},M=function(a,
-b){x[a]===void 0&&(x[a]=[]);x[a].push(b)},K=function(a,b){J[a]===void 0&&(J[a]={});J[a][b]=null};for(n in r){q=r[n];w=n.split("_");D=w[0];w=w[1];M(D,[D,w]);M(w,[D,w]);m=0;for(s=q.length;m<s;m++)t=q[m],K(D,t,n),K(w,t,n);q.length<2&&(o[n]=!0)}for(n in r)if(q=r[n],t=q[0],q=q[1],w=n.split("_"),D=w[0],w=w[1],s=new THREE.Vector3,o[n]?(s.addSelf(h[D].position),s.addSelf(h[w].position),s.multiplyScalar(0.5)):(s.addSelf(l[t]),s.addSelf(l[q]),s.addSelf(h[D].position),s.addSelf(h[w].position),s.multiplyScalar(0.25)),
-k[n]=v+d.length+A,i.push(new THREE.Vertex(s)),A++,f.supportUVs&&p.length!=0)q=new THREE.UV,q.u=p[D].u+p[w].u,q.v=p[D].v+p[w].v,q.u/=2,q.v/=2,p.push(q);var E,P;w=["123","12","2","23"];s=["123","23","3","31"];var M=["123","31","1","12"],K=["1234","12","2","23"],I=["1234","23","3","34"],V=["1234","34","4","41"],Z=["1234","41","1","12"];n=0;for(r=l.length;n<r;n++)t=d[n],q=v+n,t instanceof THREE.Face3?(A=b(t.a,t.b),D=b(t.b,t.c),E=b(t.c,t.a),c(q,k[A],t.b,k[D],t,w),c(q,k[D],t.c,k[E],t,s),c(q,k[E],t.a,k[A],
-t,M)):t instanceof THREE.Face4?(A=b(t.a,t.b),D=b(t.b,t.c),E=b(t.c,t.d),P=b(t.d,t.a),c(q,k[A],t.b,k[D],t,K),c(q,k[D],t.c,k[E],t,I),c(q,k[E],t.d,k[P],t,V),c(q,k[P],t.a,k[A],t,Z)):console.log("face should be a face!",t);d=i;i=new THREE.Vector3;k=new THREE.Vector3;n=0;for(r=h.length;n<r;n++)if(x[n]!==void 0){i.set(0,0,0);k.set(0,0,0);t=new THREE.Vector3(0,0,0);q=0;for(m in J[n])i.addSelf(l[m]),q++;A=0;v=x[n].length;for(m=0;m<v;m++)o[b(x[n][m][0],x[n][m][1])]&&A++;if(A!=2){i.divideScalar(q);for(m=0;m<
-v;m++)q=x[n][m],q=h[q[0]].position.clone().addSelf(h[q[1]].position).divideScalar(2),k.addSelf(q);k.divideScalar(v);t.addSelf(h[n].position);t.multiplyScalar(v-3);t.addSelf(i);t.addSelf(k.multiplyScalar(2));t.divideScalar(v);d[n].position=t}}a.vertices=d;a.faces=g;a.faceVertexUvs[0]=e;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};
+b)}var d=[],g=[],e=[],f=this,h=a.vertices,d=a.faces,i=h.concat(),l=[],k={},o={},p=[],n,s,m,q,t,u=a.faceVertexUvs[0];n=0;for(s=u.length;n<s;n++){m=0;for(q=u[n].length;m<q;m++)t=d[n]["abcd".charAt(m)],p[t]||(p[t]=u[n][m])}var r;n=0;for(s=d.length;n<s;n++)if(t=d[n],l.push(t.centroid),i.push(new THREE.Vertex(t.centroid)),f.supportUVs&&p.length!=0){r=new THREE.UV;if(t instanceof THREE.Face3)r.u=p[t.a].u+p[t.b].u+p[t.c].u,r.v=p[t.a].v+p[t.b].v+p[t.c].v,r.u/=3,r.v/=3;else if(t instanceof THREE.Face4)r.u=
+p[t.a].u+p[t.b].u+p[t.c].u+p[t.d].u,r.v=p[t.a].v+p[t.b].v+p[t.c].v+p[t.d].v,r.u/=4,r.v/=4;p.push(r)}s=function(a){function c(a,b,d){a[b]===void 0&&(a[b]=[]);a[b].push(d)}var d,e,f,g,h={};d=0;for(e=a.faces.length;d<e;d++)f=a.faces[d],f instanceof THREE.Face3?(g=b(f.a,f.b),c(h,g,d),g=b(f.b,f.c),c(h,g,d),g=b(f.c,f.a),c(h,g,d)):f instanceof THREE.Face4&&(g=b(f.a,f.b),c(h,g,d),g=b(f.b,f.c),c(h,g,d),g=b(f.c,f.d),c(h,g,d),g=b(f.d,f.a),c(h,g,d));return h}(a);var z=0,u=h.length,w,C,x={},O={},G=function(a,
+b){x[a]===void 0&&(x[a]=[]);x[a].push(b)},K=function(a,b){O[a]===void 0&&(O[a]={});O[a][b]=null};for(n in s){r=s[n];w=n.split("_");C=w[0];w=w[1];G(C,[C,w]);G(w,[C,w]);m=0;for(q=r.length;m<q;m++)t=r[m],K(C,t,n),K(w,t,n);r.length<2&&(o[n]=!0)}for(n in s)if(r=s[n],t=r[0],r=r[1],w=n.split("_"),C=w[0],w=w[1],q=new THREE.Vector3,o[n]?(q.addSelf(h[C].position),q.addSelf(h[w].position),q.multiplyScalar(0.5)):(q.addSelf(l[t]),q.addSelf(l[r]),q.addSelf(h[C].position),q.addSelf(h[w].position),q.multiplyScalar(0.25)),
+k[n]=u+d.length+z,i.push(new THREE.Vertex(q)),z++,f.supportUVs&&p.length!=0)r=new THREE.UV,r.u=p[C].u+p[w].u,r.v=p[C].v+p[w].v,r.u/=2,r.v/=2,p.push(r);var D,P;w=["123","12","2","23"];q=["123","23","3","31"];var G=["123","31","1","12"],K=["1234","12","2","23"],I=["1234","23","3","34"],W=["1234","34","4","41"],Z=["1234","41","1","12"];n=0;for(s=l.length;n<s;n++)t=d[n],r=u+n,t instanceof THREE.Face3?(z=b(t.a,t.b),C=b(t.b,t.c),D=b(t.c,t.a),c(r,k[z],t.b,k[C],t,w),c(r,k[C],t.c,k[D],t,q),c(r,k[D],t.a,k[z],
+t,G)):t instanceof THREE.Face4?(z=b(t.a,t.b),C=b(t.b,t.c),D=b(t.c,t.d),P=b(t.d,t.a),c(r,k[z],t.b,k[C],t,K),c(r,k[C],t.c,k[D],t,I),c(r,k[D],t.d,k[P],t,W),c(r,k[P],t.a,k[z],t,Z)):console.log("face should be a face!",t);d=i;i=new THREE.Vector3;k=new THREE.Vector3;n=0;for(s=h.length;n<s;n++)if(x[n]!==void 0){i.set(0,0,0);k.set(0,0,0);t=new THREE.Vector3(0,0,0);r=0;for(m in O[n])i.addSelf(l[m]),r++;z=0;u=x[n].length;for(m=0;m<u;m++)o[b(x[n][m][0],x[n][m][1])]&&z++;if(z!=2){i.divideScalar(r);for(m=0;m<
+u;m++)r=x[n][m],r=h[r[0]].position.clone().addSelf(h[r[1]].position).divideScalar(2),k.addSelf(r);k.divideScalar(u);t.addSelf(h[n].position);t.multiplyScalar(u-3);t.addSelf(i);t.addSelf(k.multiplyScalar(2));t.divideScalar(u);d[n].position=t}}a.vertices=d;a.faces=g;a.faceVertexUvs[0]=e;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,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 c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/
 1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=c},extractUrlbase:function(a){a=a.split("/");a.pop();return a.length<1?"":a.join("/")+"/"},initMaterials:function(a,c,b){a.materials=[];for(var d=0;d<c.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(c[d],b)},hasNormals:function(a){var c,b,d=a.materials.length;for(b=0;b<d;b++)if(c=a.materials[b],c instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(a,c){function b(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==
@@ -557,115 +558,115 @@ f.status+"]")};f.open("GET",c,!0);f.overrideMimeType("text/plain; charset=x-user
 THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,c,b,d,g){var e=new XMLHttpRequest,f=b+"/"+a.buffers,h=0;e.onreadystatechange=function(){e.readyState==4?e.status==200||e.status==0?THREE.BinaryLoader.prototype.createBinModel(e.responseText,c,d,a.materials):console.error("Couldn't load ["+f+"] ["+e.status+"]"):e.readyState==3?g&&(h==0&&(h=e.getResponseHeader("Content-Length")),g({total:h,loaded:e.responseText.length})):e.readyState==2&&(h=e.getResponseHeader("Content-Length"))};e.open("GET",
 f,!0);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)};
 THREE.BinaryLoader.prototype.createBinModel=function(a,c,b,d){var g=function(b){function c(a,b){var d=k(a,b),e=k(a,b+1),f=k(a,b+2),g=k(a,b+3),h=(g<<1&255|f>>7)-127;d|=(f&127)<<16|e<<8;if(d==0&&h==-127)return 0;return(1-2*(g>>7))*(1+d*Math.pow(2,-23))*Math.pow(2,h)}function g(a,b){var c=k(a,b),d=k(a,b+1),e=k(a,b+2);return(k(a,b+3)<<24)+(e<<16)+(d<<8)+c}function i(a,b){var c=k(a,b);return(k(a,b+1)<<8)+c}function l(a,b){var c=k(a,b);return c>127?c-256:c}function k(a,b){return a.charCodeAt(b)&255}function o(b){var c,
-d,e;c=g(a,b);d=g(a,b+D);e=g(a,b+x);b=i(a,b+J);t.faces.push(new THREE.Face3(c,d,e,null,null,b))}function p(b){var c,d,e,f,j,k,l;c=g(a,b);d=g(a,b+D);e=g(a,b+x);f=i(a,b+J);j=g(a,b+M);k=g(a,b+K);l=g(a,b+E);var b=A[k*3],m=A[k*3+1];k=A[k*3+2];var n=A[l*3],o=A[l*3+1];l=A[l*3+2];t.faces.push(new THREE.Face3(c,d,e,[new THREE.Vector3(A[j*3],A[j*3+1],A[j*3+2]),new THREE.Vector3(b,m,k),new THREE.Vector3(n,o,l)],null,f))}function n(b){var c,d,e,f;c=g(a,b);d=g(a,b+P);e=g(a,b+I);f=g(a,b+V);b=i(a,b+Z);t.faces.push(new THREE.Face4(c,
-d,e,f,null,null,b))}function r(b){var c,d,e,f,j,k,l,m,n;c=g(a,b);d=g(a,b+P);e=g(a,b+I);f=g(a,b+V);j=i(a,b+Z);k=g(a,b+R);l=g(a,b+W);m=g(a,b+ka);n=g(a,b+G);var b=A[l*3],o=A[l*3+1];l=A[l*3+2];var p=A[m*3],u=A[m*3+1];m=A[m*3+2];var H=A[n*3],q=A[n*3+1];n=A[n*3+2];t.faces.push(new THREE.Face4(c,d,e,f,[new THREE.Vector3(A[k*3],A[k*3+1],A[k*3+2]),new THREE.Vector3(b,o,l),new THREE.Vector3(p,u,m),new THREE.Vector3(H,q,n)],null,j))}function m(b){var c,d,e,f;c=g(a,b);d=g(a,b+z);e=g(a,b+y);b=w[c*2];f=w[c*2+1];
-c=w[d*2];var i=t.faceVertexUvs[0];d=w[d*2+1];var j=w[e*2];e=w[e*2+1];var k=[];k.push(new THREE.UV(b,f));k.push(new THREE.UV(c,d));k.push(new THREE.UV(j,e));i.push(k)}function s(b){var c,d,e,f,i,k;c=g(a,b);d=g(a,b+L);e=g(a,b+j);f=g(a,b+ca);b=w[c*2];i=w[c*2+1];c=w[d*2];k=w[d*2+1];d=w[e*2];var l=t.faceVertexUvs[0];e=w[e*2+1];var m=w[f*2];f=w[f*2+1];var n=[];n.push(new THREE.UV(b,i));n.push(new THREE.UV(c,k));n.push(new THREE.UV(d,e));n.push(new THREE.UV(m,f));l.push(n)}var t=this,v=0,q,A=[],w=[],D,x,
-J,M,K,E,P,I,V,Z,R,W,ka,G,z,y,L,j,ca,ga,N,X,T,ea,Q;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(t,d,b);q={signature:a.substr(v,8),header_bytes:k(a,v+8),vertex_coordinate_bytes:k(a,v+9),normal_coordinate_bytes:k(a,v+10),uv_coordinate_bytes:k(a,v+11),vertex_index_bytes:k(a,v+12),normal_index_bytes:k(a,v+13),uv_index_bytes:k(a,v+14),material_index_bytes:k(a,v+15),nvertices:g(a,v+16),nnormals:g(a,v+16+4),nuvs:g(a,v+16+8),ntri_flat:g(a,v+16+12),ntri_smooth:g(a,v+16+16),ntri_flat_uv:g(a,
-v+16+20),ntri_smooth_uv:g(a,v+16+24),nquad_flat:g(a,v+16+28),nquad_smooth:g(a,v+16+32),nquad_flat_uv:g(a,v+16+36),nquad_smooth_uv:g(a,v+16+40)};v+=q.header_bytes;D=q.vertex_index_bytes;x=q.vertex_index_bytes*2;J=q.vertex_index_bytes*3;M=q.vertex_index_bytes*3+q.material_index_bytes;K=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes;E=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*2;P=q.vertex_index_bytes;I=q.vertex_index_bytes*2;V=q.vertex_index_bytes*3;Z=q.vertex_index_bytes*
-4;R=q.vertex_index_bytes*4+q.material_index_bytes;W=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes;ka=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*2;G=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*3;z=q.uv_index_bytes;y=q.uv_index_bytes*2;L=q.uv_index_bytes;j=q.uv_index_bytes*2;ca=q.uv_index_bytes*3;b=q.vertex_index_bytes*3+q.material_index_bytes;Q=q.vertex_index_bytes*4+q.material_index_bytes;ga=q.ntri_flat*b;N=q.ntri_smooth*(b+q.normal_index_bytes*
-3);X=q.ntri_flat_uv*(b+q.uv_index_bytes*3);T=q.ntri_smooth_uv*(b+q.normal_index_bytes*3+q.uv_index_bytes*3);ea=q.nquad_flat*Q;b=q.nquad_smooth*(Q+q.normal_index_bytes*4);Q=q.nquad_flat_uv*(Q+q.uv_index_bytes*4);v+=function(b){for(var d,e,g,h=q.vertex_coordinate_bytes*3,i=b+q.nvertices*h;b<i;b+=h)d=c(a,b),e=c(a,b+q.vertex_coordinate_bytes),g=c(a,b+q.vertex_coordinate_bytes*2),t.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,g)));return q.nvertices*h}(v);v+=function(b){for(var c,d,e,f=q.normal_coordinate_bytes*
-3,g=b+q.nnormals*f;b<g;b+=f)c=l(a,b),d=l(a,b+q.normal_coordinate_bytes),e=l(a,b+q.normal_coordinate_bytes*2),A.push(c/127,d/127,e/127);return q.nnormals*f}(v);v+=function(b){for(var d,e,g=q.uv_coordinate_bytes*2,h=b+q.nuvs*g;b<h;b+=g)d=c(a,b),e=c(a,b+q.uv_coordinate_bytes),w.push(d,e);return q.nuvs*g}(v);ga=v+ga;N=ga+N;X=N+X;T=X+T;ea=T+ea;b=ea+b;Q=b+Q;(function(a){var b,c=q.vertex_index_bytes*3+q.material_index_bytes,d=c+q.uv_index_bytes*3,e=a+q.ntri_flat_uv*d;for(b=a;b<e;b+=d)o(b),m(b+c);return e-
-a})(N);(function(a){var b,c=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*3,d=c+q.uv_index_bytes*3,e=a+q.ntri_smooth_uv*d;for(b=a;b<e;b+=d)p(b),m(b+c);return e-a})(X);(function(a){var b,c=q.vertex_index_bytes*4+q.material_index_bytes,d=c+q.uv_index_bytes*4,e=a+q.nquad_flat_uv*d;for(b=a;b<e;b+=d)n(b),s(b+c);return e-a})(b);(function(a){var b,c=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*4,d=c+q.uv_index_bytes*4,e=a+q.nquad_smooth_uv*d;for(b=a;b<e;b+=d)r(b),
-s(b+c);return e-a})(Q);(function(a){var b,c=q.vertex_index_bytes*3+q.material_index_bytes,d=a+q.ntri_flat*c;for(b=a;b<d;b+=c)o(b);return d-a})(v);(function(a){var b,c=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*3,d=a+q.ntri_smooth*c;for(b=a;b<d;b+=c)p(b);return d-a})(ga);(function(a){var b,c=q.vertex_index_bytes*4+q.material_index_bytes,d=a+q.nquad_flat*c;for(b=a;b<d;b+=c)n(b);return d-a})(T);(function(a){var b,c=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*
-4,d=a+q.nquad_smooth*c;for(b=a;b<d;b+=c)r(b);return d-a})(ea);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(b))};
-THREE.ColladaLoader=function(){function a(a,d,g){N=a;d=d||ea;g!==void 0&&(a=g.split("/"),a.pop(),ta=a.length<1?"":a.join("/")+"/");C=c("//dae:library_images/dae:image",f,"image");oa=c("//dae:library_materials/dae:material",J,"material");la=c("//dae:library_effects/dae:effect",I,"effect");$=c("//dae:library_geometries/dae:geometry",s,"geometry");S=c("//dae:library_controllers/dae:controller",h,"controller");Y=c("//dae:library_animations/dae:animation",Z,"animation");ra=c(".//dae:library_visual_scenes/dae:visual_scene",
-k,"visual_scene");pa=[];qa=[];(a=N.evaluate(".//dae:scene/dae:instance_visual_scene",N,G,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),T=ra[a]):T=null;X=new THREE.Object3D;for(a=0;a<T.nodes.length;a++)X.add(e(T.nodes[a]));b();for(var i in Y);i={scene:X,morphs:pa,skins:qa,dae:{images:C,materials:oa,effects:la,geometries:$,controllers:S,animations:Y,visualScenes:ra,scene:T}};d&&d(i);return i}function c(a,b,c){for(var a=N.evaluate(a,N,G,XPathResult.ORDERED_NODE_ITERATOR_TYPE,
-null),d={},e=a.iterateNext(),f=0;e;){e=(new b).parse(e);if(e.id.length==0)e.id=c+f++;d[e.id]=e;e=a.iterateNext()}return d}function b(){var a=1E6,b=-a,c=0,d;for(d in Y)for(var e=Y[d],f=0;f<e.sampler.length;f++){var g=e.sampler[f];g.create();a=Math.min(a,g.startTime);b=Math.max(b,g.endTime);c=Math.max(c,g.input.length)}return{start:a,end:b,frames:c}}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 g(a,c,e){var f=S[c.url];if(!f||!f.skin)console.log("ColladaLoader: Could not find skin controller.");else if(!c.skeleton||!c.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{var g=b(),c=T.getChildById(c.skeleton[0],!0)||T.getChildBySid(c.skeleton[0],!0),h,i,j,k,l=new THREE.Vector3,m;for(h=0;h<a.vertices.length;h++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[h].position);
+d,e;c=g(a,b);d=g(a,b+C);e=g(a,b+x);b=i(a,b+O);t.faces.push(new THREE.Face3(c,d,e,null,null,b))}function p(b){var c,d,e,f,j,k,l;c=g(a,b);d=g(a,b+C);e=g(a,b+x);f=i(a,b+O);j=g(a,b+G);k=g(a,b+K);l=g(a,b+D);var b=z[k*3],m=z[k*3+1];k=z[k*3+2];var n=z[l*3],o=z[l*3+1];l=z[l*3+2];t.faces.push(new THREE.Face3(c,d,e,[new THREE.Vector3(z[j*3],z[j*3+1],z[j*3+2]),new THREE.Vector3(b,m,k),new THREE.Vector3(n,o,l)],null,f))}function n(b){var c,d,e,f;c=g(a,b);d=g(a,b+P);e=g(a,b+I);f=g(a,b+W);b=i(a,b+Z);t.faces.push(new THREE.Face4(c,
+d,e,f,null,null,b))}function s(b){var c,d,e,f,j,k,l,m,n;c=g(a,b);d=g(a,b+P);e=g(a,b+I);f=g(a,b+W);j=i(a,b+Z);k=g(a,b+R);l=g(a,b+S);m=g(a,b+ia);n=g(a,b+H);var b=z[l*3],o=z[l*3+1];l=z[l*3+2];var p=z[m*3],v=z[m*3+1];m=z[m*3+2];var q=z[n*3],r=z[n*3+1];n=z[n*3+2];t.faces.push(new THREE.Face4(c,d,e,f,[new THREE.Vector3(z[k*3],z[k*3+1],z[k*3+2]),new THREE.Vector3(b,o,l),new THREE.Vector3(p,v,m),new THREE.Vector3(q,r,n)],null,j))}function m(b){var c,d,e,f;c=g(a,b);d=g(a,b+F);e=g(a,b+y);b=w[c*2];f=w[c*2+1];
+c=w[d*2];var i=t.faceVertexUvs[0];d=w[d*2+1];var j=w[e*2];e=w[e*2+1];var k=[];k.push(new THREE.UV(b,f));k.push(new THREE.UV(c,d));k.push(new THREE.UV(j,e));i.push(k)}function q(b){var c,d,e,f,i,k;c=g(a,b);d=g(a,b+L);e=g(a,b+j);f=g(a,b+X);b=w[c*2];i=w[c*2+1];c=w[d*2];k=w[d*2+1];d=w[e*2];var l=t.faceVertexUvs[0];e=w[e*2+1];var m=w[f*2];f=w[f*2+1];var n=[];n.push(new THREE.UV(b,i));n.push(new THREE.UV(c,k));n.push(new THREE.UV(d,e));n.push(new THREE.UV(m,f));l.push(n)}var t=this,u=0,r,z=[],w=[],C,x,
+O,G,K,D,P,I,W,Z,R,S,ia,H,F,y,L,j,X,fa,M,Q,Y,ca,T;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(t,d,b);r={signature:a.substr(u,8),header_bytes:k(a,u+8),vertex_coordinate_bytes:k(a,u+9),normal_coordinate_bytes:k(a,u+10),uv_coordinate_bytes:k(a,u+11),vertex_index_bytes:k(a,u+12),normal_index_bytes:k(a,u+13),uv_index_bytes:k(a,u+14),material_index_bytes:k(a,u+15),nvertices:g(a,u+16),nnormals:g(a,u+16+4),nuvs:g(a,u+16+8),ntri_flat:g(a,u+16+12),ntri_smooth:g(a,u+16+16),ntri_flat_uv:g(a,
+u+16+20),ntri_smooth_uv:g(a,u+16+24),nquad_flat:g(a,u+16+28),nquad_smooth:g(a,u+16+32),nquad_flat_uv:g(a,u+16+36),nquad_smooth_uv:g(a,u+16+40)};u+=r.header_bytes;C=r.vertex_index_bytes;x=r.vertex_index_bytes*2;O=r.vertex_index_bytes*3;G=r.vertex_index_bytes*3+r.material_index_bytes;K=r.vertex_index_bytes*3+r.material_index_bytes+r.normal_index_bytes;D=r.vertex_index_bytes*3+r.material_index_bytes+r.normal_index_bytes*2;P=r.vertex_index_bytes;I=r.vertex_index_bytes*2;W=r.vertex_index_bytes*3;Z=r.vertex_index_bytes*
+4;R=r.vertex_index_bytes*4+r.material_index_bytes;S=r.vertex_index_bytes*4+r.material_index_bytes+r.normal_index_bytes;ia=r.vertex_index_bytes*4+r.material_index_bytes+r.normal_index_bytes*2;H=r.vertex_index_bytes*4+r.material_index_bytes+r.normal_index_bytes*3;F=r.uv_index_bytes;y=r.uv_index_bytes*2;L=r.uv_index_bytes;j=r.uv_index_bytes*2;X=r.uv_index_bytes*3;b=r.vertex_index_bytes*3+r.material_index_bytes;T=r.vertex_index_bytes*4+r.material_index_bytes;fa=r.ntri_flat*b;M=r.ntri_smooth*(b+r.normal_index_bytes*
+3);Q=r.ntri_flat_uv*(b+r.uv_index_bytes*3);Y=r.ntri_smooth_uv*(b+r.normal_index_bytes*3+r.uv_index_bytes*3);ca=r.nquad_flat*T;b=r.nquad_smooth*(T+r.normal_index_bytes*4);T=r.nquad_flat_uv*(T+r.uv_index_bytes*4);u+=function(b){for(var d,e,g,h=r.vertex_coordinate_bytes*3,i=b+r.nvertices*h;b<i;b+=h)d=c(a,b),e=c(a,b+r.vertex_coordinate_bytes),g=c(a,b+r.vertex_coordinate_bytes*2),t.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,g)));return r.nvertices*h}(u);u+=function(b){for(var c,d,e,f=r.normal_coordinate_bytes*
+3,g=b+r.nnormals*f;b<g;b+=f)c=l(a,b),d=l(a,b+r.normal_coordinate_bytes),e=l(a,b+r.normal_coordinate_bytes*2),z.push(c/127,d/127,e/127);return r.nnormals*f}(u);u+=function(b){for(var d,e,g=r.uv_coordinate_bytes*2,h=b+r.nuvs*g;b<h;b+=g)d=c(a,b),e=c(a,b+r.uv_coordinate_bytes),w.push(d,e);return r.nuvs*g}(u);fa=u+fa;M=fa+M;Q=M+Q;Y=Q+Y;ca=Y+ca;b=ca+b;T=b+T;(function(a){var b,c=r.vertex_index_bytes*3+r.material_index_bytes,d=c+r.uv_index_bytes*3,e=a+r.ntri_flat_uv*d;for(b=a;b<e;b+=d)o(b),m(b+c);return e-
+a})(M);(function(a){var b,c=r.vertex_index_bytes*3+r.material_index_bytes+r.normal_index_bytes*3,d=c+r.uv_index_bytes*3,e=a+r.ntri_smooth_uv*d;for(b=a;b<e;b+=d)p(b),m(b+c);return e-a})(Q);(function(a){var b,c=r.vertex_index_bytes*4+r.material_index_bytes,d=c+r.uv_index_bytes*4,e=a+r.nquad_flat_uv*d;for(b=a;b<e;b+=d)n(b),q(b+c);return e-a})(b);(function(a){var b,c=r.vertex_index_bytes*4+r.material_index_bytes+r.normal_index_bytes*4,d=c+r.uv_index_bytes*4,e=a+r.nquad_smooth_uv*d;for(b=a;b<e;b+=d)s(b),
+q(b+c);return e-a})(T);(function(a){var b,c=r.vertex_index_bytes*3+r.material_index_bytes,d=a+r.ntri_flat*c;for(b=a;b<d;b+=c)o(b);return d-a})(u);(function(a){var b,c=r.vertex_index_bytes*3+r.material_index_bytes+r.normal_index_bytes*3,d=a+r.ntri_smooth*c;for(b=a;b<d;b+=c)p(b);return d-a})(fa);(function(a){var b,c=r.vertex_index_bytes*4+r.material_index_bytes,d=a+r.nquad_flat*c;for(b=a;b<d;b+=c)n(b);return d-a})(Y);(function(a){var b,c=r.vertex_index_bytes*4+r.material_index_bytes+r.normal_index_bytes*
+4,d=a+r.nquad_smooth*c;for(b=a;b<d;b+=c)s(b);return d-a})(ca);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(b))};
+THREE.ColladaLoader=function(){function a(a,d,g){M=a;d=d||ca;g!==void 0&&(a=g.split("/"),a.pop(),ta=a.length<1?"":a.join("/")+"/");B=c("//dae:library_images/dae:image",f,"image");ra=c("//dae:library_materials/dae:material",O,"material");ma=c("//dae:library_effects/dae:effect",I,"effect");la=c("//dae:library_geometries/dae:geometry",q,"geometry");$=c("//dae:library_controllers/dae:controller",h,"controller");ja=c("//dae:library_animations/dae:animation",Z,"animation");na=c(".//dae:library_visual_scenes/dae:visual_scene",
+k,"visual_scene");pa=[];sa=[];(a=M.evaluate(".//dae:scene/dae:instance_visual_scene",M,H,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),Y=na[a]):Y=null;Q=new THREE.Object3D;for(a=0;a<Y.nodes.length;a++)Q.add(e(Y.nodes[a]));b();for(var i in ja);i={scene:Q,morphs:pa,skins:sa,dae:{images:B,materials:ra,effects:ma,geometries:la,controllers:$,animations:ja,visualScenes:na,scene:Y}};d&&d(i);return i}function c(a,b,c){for(var a=M.evaluate(a,M,H,XPathResult.ORDERED_NODE_ITERATOR_TYPE,
+null),d={},e=a.iterateNext(),f=0;e;){e=(new b).parse(e);if(e.id.length==0)e.id=c+f++;d[e.id]=e;e=a.iterateNext()}return d}function b(){var a=1E6,b=-a,c=0,d;for(d in ja)for(var e=ja[d],f=0;f<e.sampler.length;f++){var g=e.sampler[f];g.create();a=Math.min(a,g.startTime);b=Math.max(b,g.endTime);c=Math.max(c,g.input.length)}return{start:a,end:b,frames:c}}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 g(a,c,e){var f=$[c.url];if(!f||!f.skin)console.log("ColladaLoader: Could not find skin controller.");else if(!c.skeleton||!c.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{var g=b(),c=Y.getChildById(c.skeleton[0],!0)||Y.getChildBySid(c.skeleton[0],!0),h,i,j,k,l=new THREE.Vector3,m;for(h=0;h<a.vertices.length;h++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[h].position);
 for(e=0;e<g.frames;e++){var n=[],o=[];for(h=0;h<a.vertices.length;h++)o.push(new THREE.Vertex(new THREE.Vector3));d(c,n,e);h=n;i=f.skin;for(k=0;k<h.length;k++)if(j=h[k],m=-1,j.type=="JOINT"){for(var p=0;p<i.joints.length;p++)if(j.sid==i.joints[p]){m=p;break}if(m>=0){p=i.invBindMatrices[m];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p<i.weights.length;p++)for(var q=0;q<i.weights[p].length;q++){var r=i.weights[p][q];r.joint==m&&j.weights.push(r)}}else throw"ColladaLoader: Could not find joint '"+
-j.sid+"'.";}for(h=0;h<n.length;h++)if(n[h].type=="JOINT")for(i=0;i<n[h].weights.length;i++)j=n[h].weights[i],k=j.index,j=j.weight,m=a.vertices[k],k=o[k],l.x=m.position.x,l.y=m.position.y,l.z=m.position.z,n[h].skinningMatrix.multiplyVector3(l),k.position.x+=l.x*j,k.position.y+=l.y*j,k.position.z+=l.z*j;a.morphTargets.push({name:"target_"+e,vertices:o})}}}function e(a){var b=new THREE.Object3D,c,d,f,h;for(f=0;f<a.controllers.length;f++){var i=S[a.controllers[f].url];switch(i.type){case "skin":if($[i.skin.source]){var j=
-new m;j.url=i.skin.source;j.instance_material=a.controllers[f].instance_material;a.geometries.push(j);c=a.controllers[f]}else if(S[i.skin.source]&&(d=i=S[i.skin.source],i.morph&&$[i.morph.source]))j=new m,j.url=i.morph.source,j.instance_material=a.controllers[f].instance_material,a.geometries.push(j);break;case "morph":if($[i.morph.source])j=new m,j.url=i.morph.source,j.instance_material=a.controllers[f].instance_material,a.geometries.push(j),d=a.controllers[f];console.log("ColladaLoader: Morph-controller partially supported.")}}for(f=
-0;f<a.geometries.length;f++){var i=a.geometries[f],j=i.instance_material,i=$[i.url],k={},l=0,o;if(i&&i.mesh&&i.mesh.primitives){if(b.name.length==0)b.name=i.id;if(j)for(h=0;h<j.length;h++){o=j[h];var p=la[oa[o.target].instance_effect.url].shader;p.material.opacity=!p.material.opacity?1:p.material.opacity;o=k[o.symbol]=p.material;l++}j=o||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});i=i.mesh.geometry3js;if(l>1){j=new THREE.MeshFaceMaterial;for(h=0;h<i.faces.length;h++)l=
-i.faces[h],l.materials=[k[l.daeMaterial]]}if(c!==void 0)g(i,c),j.morphTargets=!0,j=new THREE.SkinnedMesh(i,j),j.skeleton=c.skeleton,j.skinController=S[c.url],j.skinInstanceController=c,j.name="skin_"+qa.length,qa.push(j);else if(d!==void 0){h=i;k=d instanceof n?S[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(p=$[k.targets[l]],p.mesh&&p.mesh.primitives&&p.mesh.primitives.length)p=p.mesh.primitives[0].geometry,p.vertices.length===
+j.sid+"'.";}for(h=0;h<n.length;h++)if(n[h].type=="JOINT")for(i=0;i<n[h].weights.length;i++)j=n[h].weights[i],k=j.index,j=j.weight,m=a.vertices[k],k=o[k],l.x=m.position.x,l.y=m.position.y,l.z=m.position.z,n[h].skinningMatrix.multiplyVector3(l),k.position.x+=l.x*j,k.position.y+=l.y*j,k.position.z+=l.z*j;a.morphTargets.push({name:"target_"+e,vertices:o})}}}function e(a){var b=new THREE.Object3D,c,d,f,h;for(f=0;f<a.controllers.length;f++){var i=$[a.controllers[f].url];switch(i.type){case "skin":if(la[i.skin.source]){var j=
+new m;j.url=i.skin.source;j.instance_material=a.controllers[f].instance_material;a.geometries.push(j);c=a.controllers[f]}else if($[i.skin.source]&&(d=i=$[i.skin.source],i.morph&&la[i.morph.source]))j=new m,j.url=i.morph.source,j.instance_material=a.controllers[f].instance_material,a.geometries.push(j);break;case "morph":if(la[i.morph.source])j=new m,j.url=i.morph.source,j.instance_material=a.controllers[f].instance_material,a.geometries.push(j),d=a.controllers[f];console.log("ColladaLoader: Morph-controller partially supported.")}}for(f=
+0;f<a.geometries.length;f++){var i=a.geometries[f],j=i.instance_material,i=la[i.url],k={},l=0,o;if(i&&i.mesh&&i.mesh.primitives){if(b.name.length==0)b.name=i.id;if(j)for(h=0;h<j.length;h++){o=j[h];var p=ma[ra[o.target].instance_effect.url].shader;p.material.opacity=!p.material.opacity?1:p.material.opacity;o=k[o.symbol]=p.material;l++}j=o||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});i=i.mesh.geometry3js;if(l>1){j=new THREE.MeshFaceMaterial;for(h=0;h<i.faces.length;h++)l=
+i.faces[h],l.materials=[k[l.daeMaterial]]}if(c!==void 0)g(i,c),j.morphTargets=!0,j=new THREE.SkinnedMesh(i,j),j.skeleton=c.skeleton,j.skinController=$[c.url],j.skinInstanceController=c,j.name="skin_"+sa.length,sa.push(j);else if(d!==void 0){h=i;k=d instanceof n?$[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(p=la[k.targets[l]],p.mesh&&p.mesh.primitives&&p.mesh.primitives.length)p=p.mesh.primitives[0].geometry,p.vertices.length===
 h.vertices.length&&h.morphTargets.push({name:"target_1",vertices:p.vertices});h.morphTargets.push({name:"target_Z",vertices:h.vertices})}j.morphTargets=!0;j=new THREE.Mesh(i,j);j.name="morph_"+pa.length;pa.push(j)}else j=new THREE.Mesh(i,j);a.geometries.length>1?b.add(j):b=j}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(f=0;f<a.nodes.length;f++)b.add(e(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 l(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];this.joints=[];this.weights=[]}function k(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function o(){this.sid=this.name=this.id="";this.nodes=[];this.controllers=[];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function p(){this.type=this.sid="";this.data=[];this.matrix=new THREE.Matrix4}function n(){this.url=
-"";this.skeleton=[];this.instance_material=[]}function r(){this.target=this.symbol=""}function m(){this.url="";this.instance_material=[]}function s(){this.id="";this.mesh=null}function t(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function v(){}function q(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function A(){this.source="";this.stride=this.count=0;this.params=[]}function w(){this.input={}}function D(){this.semantic=
-"";this.offset=0;this.source="";this.set=0}function x(a){this.id=a;this.type=null}function J(){this.name=this.id="";this.instance_effect=null}function M(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texcoord=this.texture=null}function K(a,b){this.type=a;this.effect=b;this.material=null}function E(a){this.effect=a;this.format=this.init_from=null}function P(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=
-this.source=null}function I(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function V(){this.url=""}function Z(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function R(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=this.dotSyntax=this.sid=null}function W(a){this.id="";this.animation=a;this.inputs=[];this.endTime=this.startTime=this.interpolation=this.output=this.input=null;this.duration=0}function ka(a){var b=a.getAttribute("id");
-if(Q[b]!=void 0)return Q[b];Q[b]=(new x(b)).parse(a);return Q[b]}function G(a){if(a=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function z(a){for(var a=L(a),b=[],c=0;c<a.length;c++)b.push(parseFloat(a[c]));return b}function y(a){for(var a=L(a),b=[],c=0;c<a.length;c++)b.push(parseInt(a[c],10));return b}function L(a){return a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/)}function j(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function ca(a,b){if(a===
-void 0){for(var c="0.";c.length<b+2;)c+="0";return c}b=b||2;c=a.toString().split(".");for(c[1]=c.length>1?c[1].substr(0,b):"0";c[1].length<b;)c[1]+="0";return c.join(".")}function ga(a,b){var c="";c+=ca(a.x,b)+",";c+=ca(a.y,b)+",";c+=ca(a.z,b);return c}var N=null,X=null,T,ea=null,Q={},C={},Y={},S={},$={},oa={},la={},ra,ta,pa,qa,wa=THREE.SmoothShading;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(c.nodeName=="init_from")this.init_from=
+"";this.skeleton=[];this.instance_material=[]}function s(){this.target=this.symbol=""}function m(){this.url="";this.instance_material=[]}function q(){this.id="";this.mesh=null}function t(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function u(){}function r(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function z(){this.source="";this.stride=this.count=0;this.params=[]}function w(){this.input={}}function C(){this.semantic=
+"";this.offset=0;this.source="";this.set=0}function x(a){this.id=a;this.type=null}function O(){this.name=this.id="";this.instance_effect=null}function G(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texcoord=this.texture=null}function K(a,b){this.type=a;this.effect=b;this.material=null}function D(a){this.effect=a;this.format=this.init_from=null}function P(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=
+this.source=null}function I(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function W(){this.url=""}function Z(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function R(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=this.dotSyntax=this.sid=null}function S(a){this.id="";this.animation=a;this.inputs=[];this.endTime=this.startTime=this.interpolation=this.output=this.input=null;this.duration=0}function ia(a){var b=a.getAttribute("id");
+if(T[b]!=void 0)return T[b];T[b]=(new x(b)).parse(a);return T[b]}function H(a){if(a=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function F(a){for(var a=L(a),b=[],c=0;c<a.length;c++)b.push(parseFloat(a[c]));return b}function y(a){for(var a=L(a),b=[],c=0;c<a.length;c++)b.push(parseInt(a[c],10));return b}function L(a){return a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/)}function j(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function X(a,b){if(a===
+void 0){for(var c="0.";c.length<b+2;)c+="0";return c}b=b||2;c=a.toString().split(".");for(c[1]=c.length>1?c[1].substr(0,b):"0";c[1].length<b;)c[1]+="0";return c.join(".")}function fa(a,b){var c="";c+=X(a.x,b)+",";c+=X(a.y,b)+",";c+=X(a.z,b);return c}var M=null,Q=null,Y,ca=null,T={},B={},ja={},$={},la={},ra={},ma={},na,ta,pa,sa,xa=THREE.SmoothShading;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(c.nodeName=="init_from")this.init_from=
 c.textContent}return this};h.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.type="none";for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "skin":this.skin=(new l).parse(c);this.type=c.nodeName;break;case "morph":this.morph=(new i).parse(c),this.type=c.nodeName}}return this};i.prototype.parse=function(a){var b={},c=[],d;this.method=a.getAttribute("method");this.source=a.getAttribute("source").replace(/^#/,"");for(d=
-0;d<a.childNodes.length;d++){var e=a.childNodes[d];if(e.nodeType==1)switch(e.nodeName){case "source":e=(new x).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(d.nodeType==1)switch(d.nodeName){case "input":b.push((new D).parse(d))}}return b};
-l.prototype.parse=function(a){var b={},c,d;this.source=a.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var e=0;e<a.childNodes.length;e++){var f=a.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "bind_shape_matrix":f=z(f.textContent);this.bindShapeMatrix=new THREE.Matrix4;this.bindShapeMatrix.set(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9],f[10],f[11],f[12],f[13],f[14],f[15]);break;case "source":f=(new x).parse(f);b[f.id]=f;break;case "joints":c=
-f;break;case "vertex_weights":d=f;break;default:console.log(f.nodeName)}}this.parseJoints(c,b);this.parseWeights(d,b);return this};l.prototype.parseJoints=function(a,b){for(var c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "input":var d=(new D).parse(d),e=b[d.source];if(d.semantic=="JOINT")this.joints=e.read();else if(d.semantic=="INV_BIND_MATRIX")this.invBindMatrices=e.read()}}};l.prototype.parseWeights=function(a,b){for(var c,d,e=[],f=0;f<a.childNodes.length;f++){var g=
-a.childNodes[f];if(g.nodeType==1)switch(g.nodeName){case "input":e.push((new D).parse(g));break;case "v":c=y(g.textContent);break;case "vcount":d=y(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],i=[],j=0;j<h;j++){for(var k={},l=0;l<e.length;l++){var m=e[l],n=c[g+m.offset];switch(m.semantic){case "JOINT":k.joint=n;break;case "WEIGHT":k.weight=b[m.source].data[n]}}i.push(k);g+=e.length}for(j=0;j<i.length;j++)i[j].index=f;this.weights.push(i)}};k.prototype.getChildById=function(a,b){for(var c=
+0;d<a.childNodes.length;d++){var e=a.childNodes[d];if(e.nodeType==1)switch(e.nodeName){case "source":e=(new x).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(d.nodeType==1)switch(d.nodeName){case "input":b.push((new C).parse(d))}}return b};
+l.prototype.parse=function(a){var b={},c,d;this.source=a.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var e=0;e<a.childNodes.length;e++){var f=a.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "bind_shape_matrix":f=F(f.textContent);this.bindShapeMatrix=new THREE.Matrix4;this.bindShapeMatrix.set(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9],f[10],f[11],f[12],f[13],f[14],f[15]);break;case "source":f=(new x).parse(f);b[f.id]=f;break;case "joints":c=
+f;break;case "vertex_weights":d=f;break;default:console.log(f.nodeName)}}this.parseJoints(c,b);this.parseWeights(d,b);return this};l.prototype.parseJoints=function(a,b){for(var c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "input":var d=(new C).parse(d),e=b[d.source];if(d.semantic=="JOINT")this.joints=e.read();else if(d.semantic=="INV_BIND_MATRIX")this.invBindMatrices=e.read()}}};l.prototype.parseWeights=function(a,b){for(var c,d,e=[],f=0;f<a.childNodes.length;f++){var g=
+a.childNodes[f];if(g.nodeType==1)switch(g.nodeName){case "input":e.push((new C).parse(g));break;case "v":c=y(g.textContent);break;case "vcount":d=y(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],i=[],j=0;j<h;j++){for(var k={},l=0;l<e.length;l++){var m=e[l],n=c[g+m.offset];switch(m.semantic){case "JOINT":k.joint=n;break;case "WEIGHT":k.weight=b[m.source].data[n]}}i.push(k);g+=e.length}for(j=0;j<i.length;j++)i[j].index=f;this.weights.push(i)}};k.prototype.getChildById=function(a,b){for(var c=
 0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,b);if(d)return d}return null};k.prototype.getChildBySid=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};k.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.nodes=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "node":this.nodes.push((new o).parse(c))}}return this};o.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=e.indexOf(".")>=0,g=e.indexOf("(")>=0,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};o.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};o.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};o.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};o.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=this.type=="JOINT"?this.type:"NODE";this.nodes=[];this.transforms=[];this.geometries=[];this.controllers=[];this.matrix=new THREE.Matrix4;for(var c=0;c<a.childNodes.length;c++)if(b=a.childNodes[c],b.nodeType==1)switch(b.nodeName){case "node":this.nodes.push((new o).parse(b));break;case "instance_camera":break;case "instance_controller":this.controllers.push((new n).parse(b));break;case "instance_geometry":this.geometries.push((new m).parse(b));break;case "instance_light":break;case "instance_node":b=
-b.getAttribute("url").replace(/^#/,"");(b=N.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",N,G,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new o).parse(b));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new p).parse(b));break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in Y)for(var e=Y[d],f=0;f<e.channel.length;f++){var g=e.channel[f],h=e.sampler[f];d=g.target.split("/")[0];
+b.getAttribute("url").replace(/^#/,"");(b=M.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",M,H,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new o).parse(b));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new p).parse(b));break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in ja)for(var e=ja[d],f=0;f<e.channel.length;f++){var g=e.channel[f],h=e.sampler[f];d=g.target.split("/")[0];
 if(d==this.id)h.create(),g.sampler=h,c=Math.min(c,h.startTime),b=Math.max(b,h.endTime),a.push(g)}if(a.length)this.startTime=c,this.endTime=b;if((this.channels=a)&&this.channels.length){d=1E7;for(a=0;a<this.channels.length;a++){c=this.channels[a].sampler;for(b=0;b<c.input.length-1;b++)d=Math.min(d,c.input[b+1]-c.input[b])}c=[];for(a=this.startTime;a<this.endTime;a+=d){b=a;for(var e={},i=f=void 0,f=0;f<this.channels.length;f++)i=this.channels[f],e[i.sid]=i;g=new THREE.Matrix4;for(f=0;f<this.transforms.length;f++)if(h=
 this.transforms[f],i=e[h.sid],i!==void 0){for(var j=i.sampler,k,i=0;i<j.input.length-1;i++)if(j.input[i+1]>b){k=j.output[i];break}g=k!==void 0?k instanceof THREE.Matrix4?g.multiply(g,k):g.multiply(g,h.matrix):g.multiply(g,h.matrix)}else g=g.multiply(g,h.matrix);b=g;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};o.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a<this.transforms.length;a++)this.matrix.multiply(this.matrix,
-this.transforms[a].matrix)};p.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=z(a.textContent);this.updateMatrix();return this};p.prototype.updateMatrix=function(){var a=0;this.matrix.identity();switch(this.type){case "matrix":this.matrix.set(this.data[0],this.data[1],this.data[2],this.data[3],this.data[4],this.data[5],this.data[6],this.data[7],this.data[8],this.data[9],this.data[10],this.data[11],this.data[12],this.data[13],this.data[14],this.data[15]);break;
+this.transforms[a].matrix)};p.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=F(a.textContent);this.updateMatrix();return this};p.prototype.updateMatrix=function(){var a=0;this.matrix.identity();switch(this.type){case "matrix":this.matrix.set(this.data[0],this.data[1],this.data[2],this.data[3],this.data[4],this.data[5],this.data[6],this.data[7],this.data[8],this.data[9],this.data[10],this.data[11],this.data[12],this.data[13],this.data[14],this.data[15]);break;
 case "translate":this.matrix.setTranslation(this.data[0],this.data[1],this.data[2]);break;case "rotate":a=this.data[3]*(Math.PI/180);this.matrix.setRotationAxis(new THREE.Vector3(this.data[0],this.data[1],this.data[2]),a);break;case "scale":this.matrix.setScale(this.data[0],this.data[1],this.data[2])}return this.matrix};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(c.nodeType==1)switch(c.nodeName){case "skeleton":this.skeleton.push(c.textContent.replace(/^#/,""));break;case "bind_material":if(c=N.evaluate(".//dae:instance_material",c,G,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(c.nodeType==1&&c.nodeName=="bind_material"){if(a=N.evaluate(".//dae:instance_material",c,G,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};s.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 t(this)).parse(c)}}return this};t.prototype.parse=function(a){function b(a,c){var d=ga(a.position);e[d]===void 0&&(e[d]={v:a,index:c});return e[d]}this.primitives=[];var c;for(c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];switch(d.nodeName){case "source":ka(d);break;case "vertices":this.vertices=(new w).parse(d);break;case "triangles":this.primitives.push((new q).parse(d));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new v).parse(d))}}var e=
-{};this.geometry3js=new THREE.Geometry;d=Q[this.vertices.input.POSITION.source].data;for(a=c=0;c<d.length;c+=3,a++){var f=new THREE.Vertex(new THREE.Vector3(d[c],d[c+1],d[c+2]));b(f,a);this.geometry3js.vertices.push(f)}for(c=0;c<this.primitives.length;c++)a=this.primitives[c],a.setVertices(this.vertices),this.handlePrimitive(a,this.geometry3js,e);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();
-return this};t.prototype.handlePrimitive=function(a,b,c){var d=0,e,f,g=a.p,h=a.inputs,i,j,k,l,m=0,n=3,o=[];for(e=0;e<h.length;e++)switch(i=h[e],i.semantic){case "TEXCOORD":o.push(i.set)}for(;d<g.length;){var p=[],q=[],r={},s=[];a.vcount&&(n=a.vcount[m++]);for(e=0;e<n;e++)for(f=0;f<h.length;f++)switch(i=h[f],l=Q[i.source],j=g[d+e*h.length+i.offset],k=l.accessor.params.length,k*=j,i.semantic){case "VERTEX":i=ga(b.vertices[j].position);p.push(c[i].index);break;case "NORMAL":q.push(new THREE.Vector3(l.data[k],
+if(c.nodeType==1)switch(c.nodeName){case "skeleton":this.skeleton.push(c.textContent.replace(/^#/,""));break;case "bind_material":if(c=M.evaluate(".//dae:instance_material",c,H,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var d=c.iterateNext();d;)this.instance_material.push((new s).parse(d)),d=c.iterateNext()}}return this};s.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(c.nodeType==1&&c.nodeName=="bind_material"){if(a=M.evaluate(".//dae:instance_material",c,H,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(b=a.iterateNext();b;)this.instance_material.push((new s).parse(b)),b=a.iterateNext();break}}return this};q.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 t(this)).parse(c)}}return this};t.prototype.parse=function(a){function b(a,c){var d=fa(a.position);e[d]===void 0&&(e[d]={v:a,index:c});return e[d]}this.primitives=[];var c;for(c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];switch(d.nodeName){case "source":ia(d);break;case "vertices":this.vertices=(new w).parse(d);break;case "triangles":this.primitives.push((new r).parse(d));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new u).parse(d))}}var e=
+{};this.geometry3js=new THREE.Geometry;d=T[this.vertices.input.POSITION.source].data;for(a=c=0;c<d.length;c+=3,a++){var f=new THREE.Vertex(new THREE.Vector3(d[c],d[c+1],d[c+2]));b(f,a);this.geometry3js.vertices.push(f)}for(c=0;c<this.primitives.length;c++)a=this.primitives[c],a.setVertices(this.vertices),this.handlePrimitive(a,this.geometry3js,e);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();
+return this};t.prototype.handlePrimitive=function(a,b,c){var d=0,e,f,g=a.p,h=a.inputs,i,j,k,l,m=0,n=3,o=[];for(e=0;e<h.length;e++)switch(i=h[e],i.semantic){case "TEXCOORD":o.push(i.set)}for(;d<g.length;){var p=[],q=[],r={},s=[];a.vcount&&(n=a.vcount[m++]);for(e=0;e<n;e++)for(f=0;f<h.length;f++)switch(i=h[f],l=T[i.source],j=g[d+e*h.length+i.offset],k=l.accessor.params.length,k*=j,i.semantic){case "VERTEX":i=fa(b.vertices[j].position);p.push(c[i].index);break;case "NORMAL":q.push(new THREE.Vector3(l.data[k],
 l.data[k+1],l.data[k+2]));break;case "TEXCOORD":r[i.set]===void 0&&(r[i.set]=[]);r[i.set].push(new THREE.UV(l.data[k],l.data[k+1]));break;case "COLOR":s.push((new THREE.Color).setRGB(l.data[k],l.data[k+1],l.data[k+2]))}var t;n==3?t=new THREE.Face3(p[0],p[1],p[2],[q[0],q[1],q[2]],s.length?s:new THREE.Color):n==4&&(t=new THREE.Face4(p[0],p[1],p[2],p[3],[q[0],q[1],q[2],q[3]],s.length?s:new THREE.Color));t.daeMaterial=a.material;b.faces.push(t);for(f=0;f<o.length;f++)e=r[o[f]],b.faceVertexUvs[f].push([e[0],
-e[1],e[2]]);d+=h.length*n}};v.prototype=new q;v.prototype.constructor=v;q.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};q.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=j(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 D).parse(a.childNodes[b]));break;case "vcount":this.vcount=
-y(c.textContent);break;case "p":this.p=y(c.textContent)}}return this};A.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=j(a,"count",0);this.stride=j(a,"stride",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeName=="param"){var d={};d.name=c.getAttribute("name");d.type=c.getAttribute("type");this.params.push(d)}}return this};w.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName==
-"input"){var c=(new D).parse(a.childNodes[b]);this.input[c.semantic]=c}return this};D.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,"");this.set=j(a,"set",-1);this.offset=j(a,"offset",0);if(this.semantic=="TEXCOORD"&&this.set<0)this.set=0;return this};x.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=L(c.textContent),
-e=[],f=0;f<d.length;f++)e.push(d[f]=="true"||d[f]=="1"?!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=y(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=L(c.textContent);this.type=c.nodeName;break;case "technique_common":for(d=0;d<c.childNodes.length;d++)if(c.childNodes[d].nodeName=="accessor"){this.accessor=(new A).parse(c.childNodes[d]);break}}}return this};
-x.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),d=new THREE.Matrix4;d.set(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12],c[13],c[14],c[15]);a.push(d)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};J.prototype.parse=function(a){this.id=a.getAttribute("id");
-this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName=="instance_effect"){this.instance_effect=(new V).parse(a.childNodes[b]);break}return this};M.prototype.isColor=function(){return this.texture==null};M.prototype.isTexture=function(){return this.texture!=null};M.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)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")}}return this};K.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=(new M).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=N.evaluate(".//dae:float",c,G,XPathResult.ORDERED_NODE_ITERATOR_TYPE,
-null);for(var e=d.iterateNext(),f=[];e;)f.push(e),e=d.iterateNext();d=f;d.length>0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};K.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof M)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=C[this.effect.surface.init_from]))a.map=
-THREE.ImageUtils.loadTexture(ta+d.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=wa;return this.material=new THREE.MeshLambertMaterial(a)};E.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];
+e[1],e[2]]);d+=h.length*n}};u.prototype=new r;u.prototype.constructor=u;r.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};r.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=j(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 C).parse(a.childNodes[b]));break;case "vcount":this.vcount=
+y(c.textContent);break;case "p":this.p=y(c.textContent)}}return this};z.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=j(a,"count",0);this.stride=j(a,"stride",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeName=="param"){var d={};d.name=c.getAttribute("name");d.type=c.getAttribute("type");this.params.push(d)}}return this};w.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName==
+"input"){var c=(new C).parse(a.childNodes[b]);this.input[c.semantic]=c}return this};C.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,"");this.set=j(a,"set",-1);this.offset=j(a,"offset",0);if(this.semantic=="TEXCOORD"&&this.set<0)this.set=0;return this};x.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=L(c.textContent),
+e=[],f=0;f<d.length;f++)e.push(d[f]=="true"||d[f]=="1"?!0:!1);this.data=e;this.type=c.nodeName;break;case "float_array":this.data=F(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=y(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=L(c.textContent);this.type=c.nodeName;break;case "technique_common":for(d=0;d<c.childNodes.length;d++)if(c.childNodes[d].nodeName=="accessor"){this.accessor=(new z).parse(c.childNodes[d]);break}}}return this};
+x.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),d=new THREE.Matrix4;d.set(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12],c[13],c[14],c[15]);a.push(d)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};O.prototype.parse=function(a){this.id=a.getAttribute("id");
+this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName=="instance_effect"){this.instance_effect=(new W).parse(a.childNodes[b]);break}return this};G.prototype.isColor=function(){return this.texture==null};G.prototype.isTexture=function(){return this.texture!=null};G.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "color":c=F(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")}}return this};K.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=(new G).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=M.evaluate(".//dae:float",c,H,XPathResult.ORDERED_NODE_ITERATOR_TYPE,
+null);for(var e=d.iterateNext(),f=[];e;)f.push(e),e=d.iterateNext();d=f;d.length>0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};K.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof G)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=B[this.effect.surface.init_from]))a.map=
+THREE.ImageUtils.loadTexture(ta+d.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?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=xa;return this.material=new THREE.MeshLambertMaterial(a)};D.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];
 if(c.nodeType==1)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};P.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "source":this.source=c.textContent;break;case "minfilter":this.minfilter=c.textContent;break;case "magfilter":this.magfilter=c.textContent;break;case "mipfilter":this.mipfilter=
 c.textContent;break;case "wrap_s":this.wrap_s=c.textContent;break;case "wrap_t":this.wrap_t=c.textContent;break;default:console.log("unhandled Sampler2D prop: "+c.nodeName)}}return this};I.prototype.create=function(){if(this.shader==null)return null};I.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(c.nodeType==1)switch(c.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(c))}}return this};
-I.prototype.parseNewparam=function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "surface":this.surface=(new E(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new P(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};I.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)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};I.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "lambert":case "blinn":case "phong":this.shader=(new K(c.nodeName,this)).parse(c)}}};V.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};Z.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(c.nodeType==1)switch(c.nodeName){case "source":c=(new x).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new W(this)).parse(c));break;case "channel":this.channel.push((new R(this)).parse(c))}}return this};R.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=a.indexOf(".")>=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");a=e.shift();for(b=0;b<e.length;b++)e[b]=parseInt(e[b].replace(/\)/,""))}this.sid=a;this.dotSyntax=c;this.arrSyntax=d;this.arrIndices=e;this.member=f;return this};W.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(c.nodeType==1)switch(c.nodeName){case "input":this.inputs.push((new D).parse(c))}}return this};
-W.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();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=
+I.prototype.parseNewparam=function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "surface":this.surface=(new D(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new P(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};I.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)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};I.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "lambert":case "blinn":case "phong":this.shader=(new K(c.nodeName,this)).parse(c)}}};W.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};Z.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(c.nodeType==1)switch(c.nodeName){case "source":c=(new x).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new S(this)).parse(c));break;case "channel":this.channel.push((new R(this)).parse(c))}}return this};R.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=a.indexOf(".")>=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");a=e.shift();for(b=0;b<e.length;b++)e[b]=parseInt(e[b].replace(/\)/,""))}this.sid=a;this.dotSyntax=c;this.arrSyntax=d;this.arrIndices=e;this.member=f;return this};S.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(c.nodeType==1)switch(c.nodeName){case "input":this.inputs.push((new C).parse(c))}}return this};
+S.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();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}};return{load:function(b,c){if(document.implementation&&document.implementation.createDocument){document.implementation.createDocument("http://www.collada.org/2005/11/COLLADASchema","COLLADA",null);b+="?rnd="+Math.random();var d=new XMLHttpRequest;d.overrideMimeType&&d.overrideMimeType("text/xml");d.onreadystatechange=function(){if(d.readyState==4&&(d.status==0||d.status==
-200))ea=c,a(d.responseXML,void 0,b)};d.open("GET",b,!0);d.send(null)}else alert("Don't know how to parse XML!")},parse:a,setPreferredShading:function(a){wa=a},applySkin:g,geometries:$}};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;
+200))ca=c,a(d.responseXML,void 0,b)};d.open("GET",b,!0);d.send(null)}else alert("Don't know how to parse XML!")},parse:a,setPreferredShading:function(a){xa=a},applySkin:g,geometries:la}};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,c,b){if(a instanceof Object)console.warn("DEPRECATED: JSONLoader( parameters ) is now JSONLoader( url, callback, texturePath )."),b=a,a=b.model,c=b.callback,b=b.texture_path;b=b?b:this.extractUrlbase(a);this.onLoadStart();this.loadAjaxJSON(this,a,c,b)};
 THREE.JSONLoader.prototype.loadAjaxJSON=function(a,c,b,d,g){var e=new XMLHttpRequest,f=0;e.onreadystatechange=function(){if(e.readyState==4)if(e.status==200||e.status==0)try{var h=JSON.parse(e.responseText);a.createModel(h,b,d);a.onLoadComplete()}catch(i){console.error(i),console.warn("DEPRECATED: ["+c+"] seems to be using old model format")}else console.error("Couldn't load ["+c+"] ["+e.status+"]");else e.readyState==3?g&&(f==0&&(f=e.getResponseHeader("Content-Length")),g({total:f,loaded:e.responseText.length})):
 e.readyState==2&&(f=e.getResponseHeader("Content-Length"))};e.open("GET",c,!0);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)};
-THREE.JSONLoader.prototype.createModel=function(a,c,b){var d=new THREE.Geometry,g=a.scale!==void 0?1/a.scale:1;this.initMaterials(d,a.materials,b);(function(b){if(a.metadata===void 0||a.metadata.formatVersion===void 0||a.metadata.formatVersion!==3)console.error("Deprecated file format.");else{var c,g,i,l,k,o,p,n,r,m,s,t,v,q,A=a.faces;o=a.vertices;var w=a.normals,D=a.colors,x=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&x++;for(c=0;c<x;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];l=0;for(k=o.length;l<
-k;)p=new THREE.Vertex,p.position.x=o[l++]*b,p.position.y=o[l++]*b,p.position.z=o[l++]*b,d.vertices.push(p);l=0;for(k=A.length;l<k;){b=A[l++];o=b&1;i=b&2;c=b&4;g=b&8;n=b&16;p=b&32;m=b&64;b&=128;o?(s=new THREE.Face4,s.a=A[l++],s.b=A[l++],s.c=A[l++],s.d=A[l++],o=4):(s=new THREE.Face3,s.a=A[l++],s.b=A[l++],s.c=A[l++],o=3);if(i)i=A[l++],s.materialIndex=i;i=d.faces.length;if(c)for(c=0;c<x;c++)t=a.uvs[c],r=A[l++],q=t[r*2],r=t[r*2+1],d.faceUvs[c][i]=new THREE.UV(q,r);if(g)for(c=0;c<x;c++){t=a.uvs[c];v=[];
-for(g=0;g<o;g++)r=A[l++],q=t[r*2],r=t[r*2+1],v[g]=new THREE.UV(q,r);d.faceVertexUvs[c][i]=v}if(n)n=A[l++]*3,g=new THREE.Vector3,g.x=w[n++],g.y=w[n++],g.z=w[n],s.normal=g;if(p)for(c=0;c<o;c++)n=A[l++]*3,g=new THREE.Vector3,g.x=w[n++],g.y=w[n++],g.z=w[n],s.vertexNormals.push(g);if(m)p=A[l++],p=new THREE.Color(D[p]),s.color=p;if(b)for(c=0;c<o;c++)p=A[l++],p=new THREE.Color(D[p]),s.vertexColors.push(p);d.faces.push(s)}}})(g);(function(){var b,c,g,i;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b+=
-2)g=a.skinWeights[b],i=a.skinWeights[b+1],d.skinWeights.push(new THREE.Vector4(g,i,0,0))}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b+=2)g=a.skinIndices[b],i=a.skinIndices[b+1],d.skinIndices.push(new THREE.Vector4(g,i,0,0))}d.bones=a.bones;d.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,g,i,l,k,o,p,n,r;c=0;for(g=a.morphTargets.length;c<g;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;i=0;for(l=r.length;i<l;i+=3)k=r[i]*b,o=r[i+1]*b,p=r[i+2]*b,n.push(new THREE.Vertex(new THREE.Vector3(k,o,p)))}}if(a.morphColors!==void 0){c=0;for(g=a.morphColors.length;c<g;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];l=d.morphColors[c].colors;k=a.morphColors[c].colors;b=0;for(i=k.length;b<i;b+=3)o=new THREE.Color(16755200),o.setRGB(k[b],k[b+1],k[b+2]),l.push(o)}}})(g);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&
+THREE.JSONLoader.prototype.createModel=function(a,c,b){var d=new THREE.Geometry,g=a.scale!==void 0?1/a.scale:1;this.initMaterials(d,a.materials,b);(function(b){if(a.metadata===void 0||a.metadata.formatVersion===void 0||a.metadata.formatVersion!==3)console.error("Deprecated file format.");else{var c,g,i,l,k,o,p,n,s,m,q,t,u,r,z=a.faces;o=a.vertices;var w=a.normals,C=a.colors,x=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&x++;for(c=0;c<x;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];l=0;for(k=o.length;l<
+k;)p=new THREE.Vertex,p.position.x=o[l++]*b,p.position.y=o[l++]*b,p.position.z=o[l++]*b,d.vertices.push(p);l=0;for(k=z.length;l<k;){b=z[l++];o=b&1;i=b&2;c=b&4;g=b&8;n=b&16;p=b&32;m=b&64;b&=128;o?(q=new THREE.Face4,q.a=z[l++],q.b=z[l++],q.c=z[l++],q.d=z[l++],o=4):(q=new THREE.Face3,q.a=z[l++],q.b=z[l++],q.c=z[l++],o=3);if(i)i=z[l++],q.materialIndex=i;i=d.faces.length;if(c)for(c=0;c<x;c++)t=a.uvs[c],s=z[l++],r=t[s*2],s=t[s*2+1],d.faceUvs[c][i]=new THREE.UV(r,s);if(g)for(c=0;c<x;c++){t=a.uvs[c];u=[];
+for(g=0;g<o;g++)s=z[l++],r=t[s*2],s=t[s*2+1],u[g]=new THREE.UV(r,s);d.faceVertexUvs[c][i]=u}if(n)n=z[l++]*3,g=new THREE.Vector3,g.x=w[n++],g.y=w[n++],g.z=w[n],q.normal=g;if(p)for(c=0;c<o;c++)n=z[l++]*3,g=new THREE.Vector3,g.x=w[n++],g.y=w[n++],g.z=w[n],q.vertexNormals.push(g);if(m)p=z[l++],p=new THREE.Color(C[p]),q.color=p;if(b)for(c=0;c<o;c++)p=z[l++],p=new THREE.Color(C[p]),q.vertexColors.push(p);d.faces.push(q)}}})(g);(function(){var b,c,g,i;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b+=
+2)g=a.skinWeights[b],i=a.skinWeights[b+1],d.skinWeights.push(new THREE.Vector4(g,i,0,0))}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b+=2)g=a.skinIndices[b],i=a.skinIndices[b+1],d.skinIndices.push(new THREE.Vector4(g,i,0,0))}d.bones=a.bones;d.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,g,i,l,k,o,p,n,s;c=0;for(g=a.morphTargets.length;c<g;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];n=d.morphTargets[c].vertices;
+s=a.morphTargets[c].vertices;i=0;for(l=s.length;i<l;i+=3)k=s[i]*b,o=s[i+1]*b,p=s[i+2]*b,n.push(new THREE.Vertex(new THREE.Vector3(k,o,p)))}}if(a.morphColors!==void 0){c=0;for(g=a.morphColors.length;c<g;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];l=d.morphColors[c].colors;k=a.morphColors[c].colors;b=0;for(i=k.length;b<i;b+=3)o=new THREE.Color(16755200),o.setRGB(k[b],k[b+1],k[b+2]),l.push(o)}}})(g);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&
 d.computeTangents();c(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,c){var b=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(d.readyState==4)if(d.status==200||d.status==0)try{var g=JSON.parse(d.responseText);g.metadata===void 0||g.metadata.formatVersion===void 0||g.metadata.formatVersion!==3?console.error("Deprecated file format."):b.createScene(g,c,a)}catch(e){console.error(e),console.warn("DEPRECATED: ["+a+"] seems to be using old model format")}else console.error("Couldn't load ["+a+"] ["+d.status+"]")};
 d.open("GET",a,!0);d.overrideMimeType("text/plain; charset=x-user-defined");d.setRequestHeader("Content-Type","text/plain");d.send(null)};
-THREE.SceneLoader.prototype.createScene=function(a,c,b){function d(a,b){return b=="relativeToHTML"?a:l+"/"+a}function g(){var a;for(p in I.objects)if(!G.objects[p])if(t=I.objects[p],t.geometry!==void 0){if(M=G.geometries[t.geometry]){a=!1;for(y=0;y<t.materials.length;y++)P=G.materials[t.materials[y]],a=P instanceof THREE.ShaderMaterial;a&&M.computeTangents();A=t.position;w=t.rotation;D=t.quaternion;x=t.scale;D=0;P.length==0&&(P=new THREE.MeshFaceMaterial);P.length>1&&(P=new THREE.MeshFaceMaterial);
-a=new THREE.Mesh(M,P);a.name=p;a.position.set(A[0],A[1],A[2]);D?(a.quaternion.set(D[0],D[1],D[2],D[3]),a.useQuaternion=!0):a.rotation.set(w[0],w[1],w[2]);a.scale.set(x[0],x[1],x[2]);a.visible=t.visible;G.scene.add(a);G.objects[p]=a;if(t.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);G.scene.collisions.colliders.push(b)}if(t.castsShadow)b=new THREE.ShadowVolume(M),G.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;t.trigger&&t.trigger.toLowerCase()!="none"&&(b=
-{type:t.trigger,object:t},G.triggers[a.name]=b)}}else A=t.position,w=t.rotation,D=t.quaternion,x=t.scale,D=0,a=new THREE.Object3D,a.name=p,a.position.set(A[0],A[1],A[2]),D?(a.quaternion.set(D[0],D[1],D[2],D[3]),a.useQuaternion=!0):a.rotation.set(w[0],w[1],w[2]),a.scale.set(x[0],x[1],x[2]),a.visible=t.visible!==void 0?t.visible:!1,G.scene.add(a),G.objects[p]=a,G.empties[p]=a,t.trigger&&t.trigger.toLowerCase()!="none"&&(b={type:t.trigger,object:t},G.triggers[a.name]=b)}function e(a){return function(b){G.geometries[a]=
-b;g();Z-=1;i.onLoadComplete();h()}}function f(a){return function(b){G.geometries[a]=b}}function h(){i.callbackProgress({totalModels:W,totalTextures:ka,loadedModels:W-Z,loadedTextures:ka-R},G);i.onLoadProgress();Z==0&&R==0&&c(G)}var i=this,l=THREE.Loader.prototype.extractUrlbase(b),k,o,p,n,r,m,s,t,v,q,A,w,D,x,J,M,K,E,P,I,V,Z,R,W,ka,G;I=a;b=new THREE.BinaryLoader;V=new THREE.JSONLoader;R=Z=0;G={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
-empties:{}};a=!1;for(p in I.objects)if(t=I.objects[p],t.meshCollider){a=!0;break}if(a)G.scene.collisions=new THREE.CollisionSystem;if(I.transform){a=I.transform.position;v=I.transform.rotation;var z=I.transform.scale;a&&G.scene.position.set(a[0],a[1],a[2]);v&&G.scene.rotation.set(v[0],v[1],v[2]);z&&G.scene.scale.set(z[0],z[1],z[2]);(a||v||z)&&G.scene.updateMatrix()}a=function(){R-=1;h();i.onLoadComplete()};for(r in I.cameras)v=I.cameras[r],v.type=="perspective"?K=new THREE.PerspectiveCamera(v.fov,
-v.aspect,v.near,v.far):v.type=="ortho"&&(K=new THREE.OrthographicCamera(v.left,v.right,v.top,v.bottom,v.near,v.far)),A=v.position,v=v.target,K.position.set(A[0],A[1],A[2]),K.target=new THREE.Vector3(v[0],v[1],v[2]),G.cameras[r]=K;for(n in I.lights)v=I.lights[n],r=v.color!==void 0?v.color:16777215,K=v.intensity!==void 0?v.intensity:1,v.type=="directional"?(A=v.direction,q=new THREE.DirectionalLight(r,K),q.position.set(A[0],A[1],A[2]),q.position.normalize()):v.type=="point"?(A=v.position,q=v.distance,
-q=new THREE.PointLight(r,K,q),q.position.set(A[0],A[1],A[2])):v.type=="ambient"&&(q=new THREE.AmbientLight(r)),G.scene.add(q),G.lights[n]=q;for(m in I.fogs)n=I.fogs[m],n.type=="linear"?E=new THREE.Fog(0,n.near,n.far):n.type=="exp2"&&(E=new THREE.FogExp2(0,n.density)),v=n.color,E.color.setRGB(v[0],v[1],v[2]),G.fogs[m]=E;if(G.cameras&&I.defaults.camera)G.currentCamera=G.cameras[I.defaults.camera];if(G.fogs&&I.defaults.fog)G.scene.fog=G.fogs[I.defaults.fog];v=I.defaults.bgcolor;G.bgColor=new THREE.Color;
-G.bgColor.setRGB(v[0],v[1],v[2]);G.bgColorAlpha=I.defaults.bgalpha;for(k in I.geometries)if(m=I.geometries[k],m.type=="bin_mesh"||m.type=="ascii_mesh")Z+=1,i.onLoadStart();W=Z;for(k in I.geometries)m=I.geometries[k],m.type=="cube"?(M=new THREE.CubeGeometry(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides),G.geometries[k]=M):m.type=="plane"?(M=new THREE.PlaneGeometry(m.width,m.height,m.segmentsWidth,m.segmentsHeight),G.geometries[k]=M):m.type=="sphere"?
-(M=new THREE.SphereGeometry(m.radius,m.segmentsWidth,m.segmentsHeight),G.geometries[k]=M):m.type=="cylinder"?(M=new THREE.CylinderGeometry(m.topRad,m.botRad,m.height,m.radSegs,m.heightSegs),G.geometries[k]=M):m.type=="torus"?(M=new THREE.TorusGeometry(m.radius,m.tube,m.segmentsR,m.segmentsT),G.geometries[k]=M):m.type=="icosahedron"?(M=new THREE.IcosahedronGeometry(m.subdivisions),G.geometries[k]=M):m.type=="bin_mesh"?b.load(d(m.url,I.urlBaseType),e(k)):m.type=="ascii_mesh"?V.load(d(m.url,I.urlBaseType),
-e(k)):m.type=="embedded_mesh"&&(m=I.embeds[m.id])&&V.createModel(m,f(k),"");for(s in I.textures)if(k=I.textures[s],k.url instanceof Array){R+=k.url.length;for(m=0;m<k.url.length;m++)i.onLoadStart()}else R+=1,i.onLoadStart();ka=R;for(s in I.textures){k=I.textures[s];if(k.mapping!=void 0&&THREE[k.mapping]!=void 0)k.mapping=new THREE[k.mapping];if(k.url instanceof Array){m=[];for(var y=0;y<k.url.length;y++)m[y]=d(k.url[y],I.urlBaseType);m=THREE.ImageUtils.loadTextureCube(m,k.mapping,a)}else{m=THREE.ImageUtils.loadTexture(d(k.url,
-I.urlBaseType),k.mapping,a);if(THREE[k.minFilter]!=void 0)m.minFilter=THREE[k.minFilter];if(THREE[k.magFilter]!=void 0)m.magFilter=THREE[k.magFilter];if(k.repeat){m.repeat.set(k.repeat[0],k.repeat[1]);if(k.repeat[0]!=1)m.wrapS=THREE.RepeatWrapping;if(k.repeat[1]!=1)m.wrapT=THREE.RepeatWrapping}k.offset&&m.offset.set(k.offset[0],k.offset[1]);if(k.wrap){E={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(E[k.wrap[0]]!==void 0)m.wrapS=E[k.wrap[0]];if(E[k.wrap[1]]!==void 0)m.wrapT=
-E[k.wrap[1]]}}G.textures[s]=m}for(o in I.materials){s=I.materials[o];for(J in s.parameters)if(J=="envMap"||J=="map"||J=="lightMap")s.parameters[J]=G.textures[s.parameters[J]];else if(J=="shading")s.parameters[J]=s.parameters[J]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(J=="blending")s.parameters[J]=THREE[s.parameters[J]]?THREE[s.parameters[J]]:THREE.NormalBlending;else if(J=="combine")s.parameters[J]=s.parameters[J]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(J==
-"vertexColors")if(s.parameters[J]=="face")s.parameters[J]=THREE.FaceColors;else if(s.parameters[J])s.parameters[J]=THREE.VertexColors;if(s.parameters.opacity!==void 0&&s.parameters.opacity<1)s.parameters.transparent=!0;if(s.parameters.normalMap){k=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(k.uniforms);m=s.parameters.color;E=s.parameters.specular;b=s.parameters.ambient;V=s.parameters.shininess;a.tNormal.texture=G.textures[s.parameters.normalMap];if(s.parameters.normalMapFactor)a.uNormalScale.value=
-s.parameters.normalMapFactor;if(s.parameters.map)a.tDiffuse.texture=s.parameters.map,a.enableDiffuse.value=!0;if(s.parameters.lightMap)a.tAO.texture=s.parameters.lightMap,a.enableAO.value=!0;if(s.parameters.specularMap)a.tSpecular.texture=G.textures[s.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(m);a.uSpecularColor.value.setHex(E);a.uAmbientColor.value.setHex(b);a.uShininess.value=V;if(s.parameters.opacity)a.uOpacity.value=s.parameters.opacity;s=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,
-vertexShader:k.vertexShader,uniforms:a,lights:!0,fog:!0})}else s=new THREE[s.type](s.parameters);G.materials[o]=s}g();i.callbackSync(G);h()};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
+THREE.SceneLoader.prototype.createScene=function(a,c,b){function d(a,b){return b=="relativeToHTML"?a:l+"/"+a}function g(){var a;for(p in I.objects)if(!H.objects[p])if(t=I.objects[p],t.geometry!==void 0){if(G=H.geometries[t.geometry]){a=!1;for(y=0;y<t.materials.length;y++)P=H.materials[t.materials[y]],a=P instanceof THREE.ShaderMaterial;a&&G.computeTangents();z=t.position;w=t.rotation;C=t.quaternion;x=t.scale;C=0;P.length==0&&(P=new THREE.MeshFaceMaterial);P.length>1&&(P=new THREE.MeshFaceMaterial);
+a=new THREE.Mesh(G,P);a.name=p;a.position.set(z[0],z[1],z[2]);C?(a.quaternion.set(C[0],C[1],C[2],C[3]),a.useQuaternion=!0):a.rotation.set(w[0],w[1],w[2]);a.scale.set(x[0],x[1],x[2]);a.visible=t.visible;H.scene.add(a);H.objects[p]=a;if(t.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);H.scene.collisions.colliders.push(b)}if(t.castsShadow)b=new THREE.ShadowVolume(G),H.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;t.trigger&&t.trigger.toLowerCase()!="none"&&(b=
+{type:t.trigger,object:t},H.triggers[a.name]=b)}}else z=t.position,w=t.rotation,C=t.quaternion,x=t.scale,C=0,a=new THREE.Object3D,a.name=p,a.position.set(z[0],z[1],z[2]),C?(a.quaternion.set(C[0],C[1],C[2],C[3]),a.useQuaternion=!0):a.rotation.set(w[0],w[1],w[2]),a.scale.set(x[0],x[1],x[2]),a.visible=t.visible!==void 0?t.visible:!1,H.scene.add(a),H.objects[p]=a,H.empties[p]=a,t.trigger&&t.trigger.toLowerCase()!="none"&&(b={type:t.trigger,object:t},H.triggers[a.name]=b)}function e(a){return function(b){H.geometries[a]=
+b;g();Z-=1;i.onLoadComplete();h()}}function f(a){return function(b){H.geometries[a]=b}}function h(){i.callbackProgress({totalModels:S,totalTextures:ia,loadedModels:S-Z,loadedTextures:ia-R},H);i.onLoadProgress();Z==0&&R==0&&c(H)}var i=this,l=THREE.Loader.prototype.extractUrlbase(b),k,o,p,n,s,m,q,t,u,r,z,w,C,x,O,G,K,D,P,I,W,Z,R,S,ia,H;I=a;b=new THREE.BinaryLoader;W=new THREE.JSONLoader;R=Z=0;H={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
+empties:{}};a=!1;for(p in I.objects)if(t=I.objects[p],t.meshCollider){a=!0;break}if(a)H.scene.collisions=new THREE.CollisionSystem;if(I.transform){a=I.transform.position;u=I.transform.rotation;var F=I.transform.scale;a&&H.scene.position.set(a[0],a[1],a[2]);u&&H.scene.rotation.set(u[0],u[1],u[2]);F&&H.scene.scale.set(F[0],F[1],F[2]);(a||u||F)&&H.scene.updateMatrix()}a=function(){R-=1;h();i.onLoadComplete()};for(s in I.cameras)u=I.cameras[s],u.type=="perspective"?K=new THREE.PerspectiveCamera(u.fov,
+u.aspect,u.near,u.far):u.type=="ortho"&&(K=new THREE.OrthographicCamera(u.left,u.right,u.top,u.bottom,u.near,u.far)),z=u.position,u=u.target,K.position.set(z[0],z[1],z[2]),K.target=new THREE.Vector3(u[0],u[1],u[2]),H.cameras[s]=K;for(n in I.lights)u=I.lights[n],s=u.color!==void 0?u.color:16777215,K=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(z=u.direction,r=new THREE.DirectionalLight(s,K),r.position.set(z[0],z[1],z[2]),r.position.normalize()):u.type=="point"?(z=u.position,r=u.distance,
+r=new THREE.PointLight(s,K,r),r.position.set(z[0],z[1],z[2])):u.type=="ambient"&&(r=new THREE.AmbientLight(s)),H.scene.add(r),H.lights[n]=r;for(m in I.fogs)n=I.fogs[m],n.type=="linear"?D=new THREE.Fog(0,n.near,n.far):n.type=="exp2"&&(D=new THREE.FogExp2(0,n.density)),u=n.color,D.color.setRGB(u[0],u[1],u[2]),H.fogs[m]=D;if(H.cameras&&I.defaults.camera)H.currentCamera=H.cameras[I.defaults.camera];if(H.fogs&&I.defaults.fog)H.scene.fog=H.fogs[I.defaults.fog];u=I.defaults.bgcolor;H.bgColor=new THREE.Color;
+H.bgColor.setRGB(u[0],u[1],u[2]);H.bgColorAlpha=I.defaults.bgalpha;for(k in I.geometries)if(m=I.geometries[k],m.type=="bin_mesh"||m.type=="ascii_mesh")Z+=1,i.onLoadStart();S=Z;for(k in I.geometries)m=I.geometries[k],m.type=="cube"?(G=new THREE.CubeGeometry(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides),H.geometries[k]=G):m.type=="plane"?(G=new THREE.PlaneGeometry(m.width,m.height,m.segmentsWidth,m.segmentsHeight),H.geometries[k]=G):m.type=="sphere"?
+(G=new THREE.SphereGeometry(m.radius,m.segmentsWidth,m.segmentsHeight),H.geometries[k]=G):m.type=="cylinder"?(G=new THREE.CylinderGeometry(m.topRad,m.botRad,m.height,m.radSegs,m.heightSegs),H.geometries[k]=G):m.type=="torus"?(G=new THREE.TorusGeometry(m.radius,m.tube,m.segmentsR,m.segmentsT),H.geometries[k]=G):m.type=="icosahedron"?(G=new THREE.IcosahedronGeometry(m.subdivisions),H.geometries[k]=G):m.type=="bin_mesh"?b.load(d(m.url,I.urlBaseType),e(k)):m.type=="ascii_mesh"?W.load(d(m.url,I.urlBaseType),
+e(k)):m.type=="embedded_mesh"&&(m=I.embeds[m.id])&&W.createModel(m,f(k),"");for(q in I.textures)if(k=I.textures[q],k.url instanceof Array){R+=k.url.length;for(m=0;m<k.url.length;m++)i.onLoadStart()}else R+=1,i.onLoadStart();ia=R;for(q in I.textures){k=I.textures[q];if(k.mapping!=void 0&&THREE[k.mapping]!=void 0)k.mapping=new THREE[k.mapping];if(k.url instanceof Array){m=[];for(var y=0;y<k.url.length;y++)m[y]=d(k.url[y],I.urlBaseType);m=THREE.ImageUtils.loadTextureCube(m,k.mapping,a)}else{m=THREE.ImageUtils.loadTexture(d(k.url,
+I.urlBaseType),k.mapping,a);if(THREE[k.minFilter]!=void 0)m.minFilter=THREE[k.minFilter];if(THREE[k.magFilter]!=void 0)m.magFilter=THREE[k.magFilter];if(k.repeat){m.repeat.set(k.repeat[0],k.repeat[1]);if(k.repeat[0]!=1)m.wrapS=THREE.RepeatWrapping;if(k.repeat[1]!=1)m.wrapT=THREE.RepeatWrapping}k.offset&&m.offset.set(k.offset[0],k.offset[1]);if(k.wrap){D={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(D[k.wrap[0]]!==void 0)m.wrapS=D[k.wrap[0]];if(D[k.wrap[1]]!==void 0)m.wrapT=
+D[k.wrap[1]]}}H.textures[q]=m}for(o in I.materials){q=I.materials[o];for(O in q.parameters)if(O=="envMap"||O=="map"||O=="lightMap")q.parameters[O]=H.textures[q.parameters[O]];else if(O=="shading")q.parameters[O]=q.parameters[O]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(O=="blending")q.parameters[O]=THREE[q.parameters[O]]?THREE[q.parameters[O]]:THREE.NormalBlending;else if(O=="combine")q.parameters[O]=q.parameters[O]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(O==
+"vertexColors")if(q.parameters[O]=="face")q.parameters[O]=THREE.FaceColors;else if(q.parameters[O])q.parameters[O]=THREE.VertexColors;if(q.parameters.opacity!==void 0&&q.parameters.opacity<1)q.parameters.transparent=!0;if(q.parameters.normalMap){k=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(k.uniforms);m=q.parameters.color;D=q.parameters.specular;b=q.parameters.ambient;W=q.parameters.shininess;a.tNormal.texture=H.textures[q.parameters.normalMap];if(q.parameters.normalMapFactor)a.uNormalScale.value=
+q.parameters.normalMapFactor;if(q.parameters.map)a.tDiffuse.texture=q.parameters.map,a.enableDiffuse.value=!0;if(q.parameters.lightMap)a.tAO.texture=q.parameters.lightMap,a.enableAO.value=!0;if(q.parameters.specularMap)a.tSpecular.texture=H.textures[q.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(m);a.uSpecularColor.value.setHex(D);a.uAmbientColor.value.setHex(b);a.uShininess.value=W;if(q.parameters.opacity)a.uOpacity.value=q.parameters.opacity;q=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,
+vertexShader:k.vertexShader,uniforms:a,lights:!0,fog:!0})}else q=new THREE[q.type](q.parameters);H.materials[o]=q}g();i.callbackSync(H);h()};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
 THREE.UTF8Loader.prototype.load=function(a,c,b){if(a instanceof Object)console.warn("DEPRECATED: UTF8Loader( parameters ) is now UTF8Loader( url, callback, metaData )."),b=a,a=b.model,c=b.callback,b={scale:b.scale,offsetX:b.offsetX,offsetY:b.offsetY,offsetZ:b.offsetZ};var d=new XMLHttpRequest,g=b.scale!==void 0?b.scale:1,e=b.offsetX!==void 0?b.offsetX:0,f=b.offsetY!==void 0?b.offsetY:0,h=b.offsetZ!==void 0?b.offsetZ:0;d.onreadystatechange=function(){d.readyState==4?d.status==200||d.status==0?THREE.UTF8Loader.prototype.createModel(d.responseText,
 c,g,e,f,h):alert("Couldn't load ["+a+"] ["+d.status+"]"):d.readyState!=3&&d.readyState==2&&d.getResponseHeader("Content-Length")};d.open("GET",a,!0);d.send(null)};THREE.UTF8Loader.prototype.decompressMesh=function(a){var c=a.charCodeAt(0);c>=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),d=1,g=0;g<8;g++){for(var e=0,f=0;f<c;++f){var h=a.charCodeAt(f+d);e+=h>>1^-(h&1);b[8*f+g]=e}d+=c}c=a.length-d;e=new Uint16Array(c);for(g=f=0;g<c;g++)h=a.charCodeAt(g+d),e[g]=f-h,h==0&&f++;return[b,e]};
-THREE.UTF8Loader.prototype.createModel=function(a,c,b,d,g,e){var f=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var f=THREE.UTF8Loader.prototype.decompressMesh(a),l=[],k=[];(function(a,f,i){for(var k,l,s,t=a.length;i<t;i+=f)k=a[i],l=a[i+1],s=a[i+2],k=k/16383*b,l=l/16383*b,s=s/16383*b,k+=d,l+=g,s+=e,c.vertices.push(new THREE.Vertex(new THREE.Vector3(k,l,s)))})(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,k.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,l.push(d,e,f)})(f[0],8,5);(function(a){var b,d,e,f,g,i,v,q,A,w=a.length;for(b=0;b<w;b+=3){d=a[b];e=a[b+1];f=a[b+2];g=c;q=d;A=e;i=f;v=d;var D=e,x=f,J=g.materials[0],M=l[D*3],K=l[D*3+1],D=l[D*3+2],E=l[x*3],P=l[x*3+1],x=l[x*3+2];v=new THREE.Vector3(l[v*3],l[v*3+1],l[v*3+2]);D=new THREE.Vector3(M,K,D);x=new THREE.Vector3(E,P,x);g.faces.push(new THREE.Face3(q,A,i,[v,D,x],null,J));g=k[d*2];d=k[d*2+
-1];i=k[e*2];v=k[e*2+1];q=k[f*2];A=k[f*2+1];f=c.faceVertexUvs[0];e=i;i=v;v=[];v.push(new THREE.UV(g,d));v.push(new THREE.UV(e,i));v.push(new THREE.UV(q,A));f.push(v)}})(f[1]);this.computeCentroids();this.computeFaceNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f)};
+THREE.UTF8Loader.prototype.createModel=function(a,c,b,d,g,e){var f=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var f=THREE.UTF8Loader.prototype.decompressMesh(a),l=[],k=[];(function(a,f,i){for(var k,l,q,t=a.length;i<t;i+=f)k=a[i],l=a[i+1],q=a[i+2],k=k/16383*b,l=l/16383*b,q=q/16383*b,k+=d,l+=g,q+=e,c.vertices.push(new THREE.Vertex(new THREE.Vector3(k,l,q)))})(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,k.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,l.push(d,e,f)})(f[0],8,5);(function(a){var b,d,e,f,g,i,u,r,z,w=a.length;for(b=0;b<w;b+=3){d=a[b];e=a[b+1];f=a[b+2];g=c;r=d;z=e;i=f;u=d;var C=e,x=f,O=g.materials[0],G=l[C*3],K=l[C*3+1],C=l[C*3+2],D=l[x*3],P=l[x*3+1],x=l[x*3+2];u=new THREE.Vector3(l[u*3],l[u*3+1],l[u*3+2]);C=new THREE.Vector3(G,K,C);x=new THREE.Vector3(D,P,x);g.faces.push(new THREE.Face3(r,z,i,[u,C,x],null,O));g=k[d*2];d=k[d*2+
+1];i=k[e*2];u=k[e*2+1];r=k[f*2];z=k[f*2+1];f=c.faceVertexUvs[0];e=i;i=u;u=[];u.push(new THREE.UV(g,d));u.push(new THREE.UV(e,i));u.push(new THREE.UV(r,z));f.push(u)}})(f[1]);this.computeCentroids();this.computeFaceNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f)};
 THREE.Axes=function(){THREE.Object3D.call(this);var a=new THREE.Geometry;a.vertices.push(new THREE.Vertex);a.vertices.push(new THREE.Vertex(new THREE.Vector3(0,100,0)));var c=new THREE.CylinderGeometry(0,5,25,5,1),b=new THREE.Line(a,new THREE.LineBasicMaterial({color:16711680}));b.rotation.z=-Math.PI/2;this.add(b);b=new THREE.Mesh(c,new THREE.MeshBasicMaterial({color:16711680}));b.position.x=100;b.rotation.z=-Math.PI/2;this.add(b);b=new THREE.Line(a,new THREE.LineBasicMaterial({color:65280}));this.add(b);
 b=new THREE.Mesh(c,new THREE.MeshBasicMaterial({color:65280}));b.position.y=100;this.add(b);b=new THREE.Line(a,new THREE.LineBasicMaterial({color:255}));b.rotation.x=Math.PI/2;this.add(b);b=new THREE.Mesh(c,new THREE.MeshBasicMaterial({color:255}));b.position.z=100;b.rotation.x=Math.PI/2;this.add(b)};THREE.Axes.prototype=new THREE.Object3D;THREE.Axes.prototype.constructor=THREE.Axes;
 THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(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(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
 0;this.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(a,c,g){return a+(c-a)*g};this.VIntX=function(a,c,g,e,f,h,i,l,k,o){f=(f-k)/(o-k);k=this.normal_cache;c[e]=h+f*this.delta;c[e+1]=i;c[e+2]=l;g[e]=this.lerp(k[a],k[a+3],f);g[e+1]=this.lerp(k[a+1],k[a+4],f);g[e+2]=this.lerp(k[a+2],k[a+5],f)};this.VIntY=function(a,c,g,e,f,h,i,l,k,o){f=(f-k)/(o-k);k=this.normal_cache;c[e]=h;c[e+1]=i+f*this.delta;c[e+
 2]=l;c=a+this.yd*3;g[e]=this.lerp(k[a],k[c],f);g[e+1]=this.lerp(k[a+1],k[c+1],f);g[e+2]=this.lerp(k[a+2],k[c+2],f)};this.VIntZ=function(a,c,g,e,f,h,i,l,k,o){f=(f-k)/(o-k);k=this.normal_cache;c[e]=h;c[e+1]=i;c[e+2]=l+f*this.delta;c=a+this.zd*3;g[e]=this.lerp(k[a],k[c],f);g[e+1]=this.lerp(k[a+1],k[c+1],f);g[e+2]=this.lerp(k[a+2],k[c+2],f)};this.compNorm=function(a){var c=a*3;this.normal_cache[c]===0&&(this.normal_cache[c]=this.field[a-1]-this.field[a+1],this.normal_cache[c+1]=this.field[a-this.yd]-
-this.field[a+this.yd],this.normal_cache[c+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,c,g,e,f,h){var i=e+1,l=e+this.yd,k=e+this.zd,o=i+this.yd,p=i+this.zd,n=e+this.yd+this.zd,r=i+this.yd+this.zd,m=0,s=this.field[e],t=this.field[i],v=this.field[l],q=this.field[o],A=this.field[k],w=this.field[p],D=this.field[n],x=this.field[r];s<f&&(m|=1);t<f&&(m|=2);v<f&&(m|=8);q<f&&(m|=4);A<f&&(m|=16);w<f&&(m|=32);D<f&&(m|=128);x<f&&(m|=64);var J=THREE.edgeTable[m];if(J===0)return 0;
-var M=this.delta,K=a+M,E=c+M,M=g+M;J&1&&(this.compNorm(e),this.compNorm(i),this.VIntX(e*3,this.vlist,this.nlist,0,f,a,c,g,s,t));J&2&&(this.compNorm(i),this.compNorm(o),this.VIntY(i*3,this.vlist,this.nlist,3,f,K,c,g,t,q));J&4&&(this.compNorm(l),this.compNorm(o),this.VIntX(l*3,this.vlist,this.nlist,6,f,a,E,g,v,q));J&8&&(this.compNorm(e),this.compNorm(l),this.VIntY(e*3,this.vlist,this.nlist,9,f,a,c,g,s,v));J&16&&(this.compNorm(k),this.compNorm(p),this.VIntX(k*3,this.vlist,this.nlist,12,f,a,c,M,A,w));
-J&32&&(this.compNorm(p),this.compNorm(r),this.VIntY(p*3,this.vlist,this.nlist,15,f,K,c,M,w,x));J&64&&(this.compNorm(n),this.compNorm(r),this.VIntX(n*3,this.vlist,this.nlist,18,f,a,E,M,D,x));J&128&&(this.compNorm(k),this.compNorm(n),this.VIntY(k*3,this.vlist,this.nlist,21,f,a,c,M,A,D));J&256&&(this.compNorm(e),this.compNorm(k),this.VIntZ(e*3,this.vlist,this.nlist,24,f,a,c,g,s,A));J&512&&(this.compNorm(i),this.compNorm(p),this.VIntZ(i*3,this.vlist,this.nlist,27,f,K,c,g,t,w));J&1024&&(this.compNorm(o),
-this.compNorm(r),this.VIntZ(o*3,this.vlist,this.nlist,30,f,K,E,g,q,x));J&2048&&(this.compNorm(l),this.compNorm(n),this.VIntZ(l*3,this.vlist,this.nlist,33,f,a,E,g,v,D));m<<=4;for(f=e=0;THREE.triTable[m+f]!=-1;)a=m+f,c=a+1,g=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[c],3*THREE.triTable[g],h),f+=3,e++;return e};this.posnormtriv=function(a,c,g,e,f,h){var i=this.count*3;this.positionArray[i]=a[g];this.positionArray[i+1]=a[g+1];this.positionArray[i+2]=a[g+2];this.positionArray[i+
+this.field[a+this.yd],this.normal_cache[c+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,c,g,e,f,h){var i=e+1,l=e+this.yd,k=e+this.zd,o=i+this.yd,p=i+this.zd,n=e+this.yd+this.zd,s=i+this.yd+this.zd,m=0,q=this.field[e],t=this.field[i],u=this.field[l],r=this.field[o],z=this.field[k],w=this.field[p],C=this.field[n],x=this.field[s];q<f&&(m|=1);t<f&&(m|=2);u<f&&(m|=8);r<f&&(m|=4);z<f&&(m|=16);w<f&&(m|=32);C<f&&(m|=128);x<f&&(m|=64);var O=THREE.edgeTable[m];if(O===0)return 0;
+var G=this.delta,K=a+G,D=c+G,G=g+G;O&1&&(this.compNorm(e),this.compNorm(i),this.VIntX(e*3,this.vlist,this.nlist,0,f,a,c,g,q,t));O&2&&(this.compNorm(i),this.compNorm(o),this.VIntY(i*3,this.vlist,this.nlist,3,f,K,c,g,t,r));O&4&&(this.compNorm(l),this.compNorm(o),this.VIntX(l*3,this.vlist,this.nlist,6,f,a,D,g,u,r));O&8&&(this.compNorm(e),this.compNorm(l),this.VIntY(e*3,this.vlist,this.nlist,9,f,a,c,g,q,u));O&16&&(this.compNorm(k),this.compNorm(p),this.VIntX(k*3,this.vlist,this.nlist,12,f,a,c,G,z,w));
+O&32&&(this.compNorm(p),this.compNorm(s),this.VIntY(p*3,this.vlist,this.nlist,15,f,K,c,G,w,x));O&64&&(this.compNorm(n),this.compNorm(s),this.VIntX(n*3,this.vlist,this.nlist,18,f,a,D,G,C,x));O&128&&(this.compNorm(k),this.compNorm(n),this.VIntY(k*3,this.vlist,this.nlist,21,f,a,c,G,z,C));O&256&&(this.compNorm(e),this.compNorm(k),this.VIntZ(e*3,this.vlist,this.nlist,24,f,a,c,g,q,z));O&512&&(this.compNorm(i),this.compNorm(p),this.VIntZ(i*3,this.vlist,this.nlist,27,f,K,c,g,t,w));O&1024&&(this.compNorm(o),
+this.compNorm(s),this.VIntZ(o*3,this.vlist,this.nlist,30,f,K,D,g,r,x));O&2048&&(this.compNorm(l),this.compNorm(n),this.VIntZ(l*3,this.vlist,this.nlist,33,f,a,D,g,u,C));m<<=4;for(f=e=0;THREE.triTable[m+f]!=-1;)a=m+f,c=a+1,g=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[c],3*THREE.triTable[g],h),f+=3,e++;return e};this.posnormtriv=function(a,c,g,e,f,h){var i=this.count*3;this.positionArray[i]=a[g];this.positionArray[i+1]=a[g+1];this.positionArray[i+2]=a[g+2];this.positionArray[i+
 3]=a[e];this.positionArray[i+4]=a[e+1];this.positionArray[i+5]=a[e+2];this.positionArray[i+6]=a[f];this.positionArray[i+7]=a[f+1];this.positionArray[i+8]=a[f+2];this.normalArray[i]=c[g];this.normalArray[i+1]=c[g+1];this.normalArray[i+2]=c[g+2];this.normalArray[i+3]=c[e];this.normalArray[i+4]=c[e+1];this.normalArray[i+5]=c[e+2];this.normalArray[i+6]=c[f];this.normalArray[i+7]=c[f+1];this.normalArray[i+8]=c[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(this.count!==0){for(var c=this.count*3;c<this.positionArray.length;c++)this.positionArray[c]=0;a(this)}};this.addBall=function(a,c,g,e,f){var h=this.size*Math.sqrt(e/f),i=g*this.size,l=c*this.size,k=a*this.size,o=Math.floor(i-h);o<1&&(o=1);i=Math.floor(i+h);i>this.size-1&&(i=this.size-1);var p=Math.floor(l-h);p<1&&(p=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var n=Math.floor(k-h);n<1&&(n=1);h=Math.floor(k+h);
-h>this.size-1&&(h=this.size-1);for(var r,m,s,t,v,q;o<i;o++){k=this.size2*o;m=o/this.size-g;v=m*m;for(m=p;m<l;m++){s=k+this.size*m;r=m/this.size-c;q=r*r;for(r=n;r<h;r++)t=r/this.size-a,t=e/(1.0E-6+t*t+q+v)-f,t>0&&(this.field[s+r]+=t)}}};this.addPlaneX=function(a,c){var g,e,f,h,i,l=this.size,k=this.yd,o=this.zd,p=this.field,n=l*Math.sqrt(a/c);n>l&&(n=l);for(g=0;g<n;g++)if(e=g/l,e*=e,h=a/(1.0E-4+e)-c,h>0)for(e=0;e<l;e++){i=g+e*k;for(f=0;f<l;f++)p[o*f+i]+=h}};this.addPlaneY=function(a,c){var g,e,f,h,
-i,l,k=this.size,o=this.yd,p=this.zd,n=this.field,r=k*Math.sqrt(a/c);r>k&&(r=k);for(e=0;e<r;e++)if(g=e/k,g*=g,h=a/(1.0E-4+g)-c,h>0){i=e*o;for(g=0;g<k;g++){l=i+g;for(f=0;f<k;f++)n[p*f+l]+=h}}};this.addPlaneZ=function(a,c){var g,e,f,h,i,l,k=this.size,o=this.yd,p=this.zd,n=this.field,r=k*Math.sqrt(a/c);r>k&&(r=k);for(f=0;f<r;f++)if(g=f/k,g*=g,h=a/(1.0E-4+g)-c,h>0){i=p*f;for(e=0;e<k;e++){l=i+e*o;for(g=0;g<k;g++)n[l+g]+=h}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[a*3]=0,
+h>this.size-1&&(h=this.size-1);for(var s,m,q,t,u,r;o<i;o++){k=this.size2*o;m=o/this.size-g;u=m*m;for(m=p;m<l;m++){q=k+this.size*m;s=m/this.size-c;r=s*s;for(s=n;s<h;s++)t=s/this.size-a,t=e/(1.0E-6+t*t+r+u)-f,t>0&&(this.field[q+s]+=t)}}};this.addPlaneX=function(a,c){var g,e,f,h,i,l=this.size,k=this.yd,o=this.zd,p=this.field,n=l*Math.sqrt(a/c);n>l&&(n=l);for(g=0;g<n;g++)if(e=g/l,e*=e,h=a/(1.0E-4+e)-c,h>0)for(e=0;e<l;e++){i=g+e*k;for(f=0;f<l;f++)p[o*f+i]+=h}};this.addPlaneY=function(a,c){var g,e,f,h,
+i,l,k=this.size,o=this.yd,p=this.zd,n=this.field,s=k*Math.sqrt(a/c);s>k&&(s=k);for(e=0;e<s;e++)if(g=e/k,g*=g,h=a/(1.0E-4+g)-c,h>0){i=e*o;for(g=0;g<k;g++){l=i+g;for(f=0;f<k;f++)n[p*f+l]+=h}}};this.addPlaneZ=function(a,c){var g,e,f,h,i,l,k=this.size,o=this.yd,p=this.zd,n=this.field,s=k*Math.sqrt(a/c);s>k&&(s=k);for(f=0;f<s;f++)if(g=f/k,g*=g,h=a/(1.0E-4+g)-c,h>0){i=p*f;for(e=0;e<k;e++){l=i+e*o;for(g=0;g<k;g++)n[l+g]+=h}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[a*3]=0,
 this.field[a]=0};this.render=function(a){this.begin();var c,g,e,f,h,i,l,k,o,p=this.size-2;for(f=1;f<p;f++){o=this.size2*f;l=(f-this.halfsize)/this.halfsize;for(e=1;e<p;e++){k=o+this.size*e;i=(e-this.halfsize)/this.halfsize;for(g=1;g<p;g++)h=(g-this.halfsize)/this.halfsize,c=k+g,this.polygonize(h,i,l,c,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,c=new THREE.Geometry,g=[];this.render(function(e){var f,h,i,l,k,o,p,n;for(f=0;f<e.count;f++)p=f*3,k=p+1,n=p+2,h=e.positionArray[p],
 i=e.positionArray[k],l=e.positionArray[n],o=new THREE.Vector3(h,i,l),h=e.normalArray[p],i=e.normalArray[k],l=e.normalArray[n],p=new THREE.Vector3(h,i,l),p.normalize(),k=new THREE.Vertex(o),c.vertices.push(k),g.push(p);o=e.count/3;for(f=0;f<o;f++)p=(a+f)*3,k=p+1,n=p+2,h=g[p],i=g[k],l=g[n],p=new THREE.Face3(p,k,n,[h,i,l]),c.faces.push(p);a+=o;e.count=0});return c};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
@@ -707,9 +708,9 @@ d;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(0,h,0);break;case
 THREE.CollisionSystem.prototype.raySphere=function(a,c){var b=c.center.clone().subSelf(a.origin);if(b.lengthSq<c.radiusSq)return-1;var d=b.dot(a.direction.clone());if(d<=0)return Number.MAX_VALUE;b=c.radiusSq-(b.lengthSq()-d*d);if(b>=0)return Math.abs(d)-Math.sqrt(b);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4;
 THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var c=a.geometry.boundingBox,b=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),b=new THREE.BoxCollider(b,c);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var c=THREE.CollisionUtils.MeshOBB(a);c.min.addSelf(a.position);c.max.addSelf(a.position);c.dynamic=!1;return c};
 THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))};
-if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var c=this,b=this.setSize,d=this.render,g=new THREE.PerspectiveCamera,e=new THREE.PerspectiveCamera,f=new THREE.Matrix4,h=new THREE.Matrix4,i,l,k,o;g.matrixAutoUpdate=e.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},p=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:p},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){b.call(c,a,d);p.width=a;p.height=d;n.width=a;n.height=d};this.render=function(a,b){a.updateMatrixWorld();if(i!==b.aspect||l!==b.near||k!==b.far||o!==b.fov){i=b.aspect;l=b.near;k=b.far;o=b.fov;var v=b.projectionMatrix.clone(),q=125/30*0.5,A=q*l/125,w=l*Math.tan(o*Math.PI/360),D;f.n14=q;h.n14=-q;q=-w*i+A;D=w*i+A;v.n11=2*l/(D-q);v.n13=(D+q)/(D-q);g.projectionMatrix.copy(v);q=-w*i-A;D=w*i-A;v.n11=
-2*l/(D-q);v.n13=(D+q)/(D-q);e.projectionMatrix.copy(v)}g.matrixWorld.copy(b.matrixWorld).multiplySelf(h);g.position.copy(b.position);g.near=b.near;g.far=b.far;d.call(c,a,g,p,!0);e.matrixWorld.copy(b.matrixWorld).multiplySelf(f);e.position.copy(b.position);e.near=b.near;e.far=b.far;d.call(c,a,e,n,!0);m.updateMatrixWorld();d.call(c,m,r)}};
+if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var c=this,b=this.setSize,d=this.render,g=new THREE.PerspectiveCamera,e=new THREE.PerspectiveCamera,f=new THREE.Matrix4,h=new THREE.Matrix4,i,l,k,o;g.matrixAutoUpdate=e.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},p=new THREE.WebGLRenderTarget(512,512,a),n=new THREE.WebGLRenderTarget(512,512,a),s=new THREE.PerspectiveCamera(53,
+1,1,1E4);s.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:p},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(s);this.setSize=function(a,d){b.call(c,a,d);p.width=a;p.height=d;n.width=a;n.height=d};this.render=function(a,b){a.updateMatrixWorld();if(i!==b.aspect||l!==b.near||k!==b.far||o!==b.fov){i=b.aspect;l=b.near;k=b.far;o=b.fov;var u=b.projectionMatrix.clone(),r=125/30*0.5,z=r*l/125,w=l*Math.tan(o*Math.PI/360),C;f.n14=r;h.n14=-r;r=-w*i+z;C=w*i+z;u.n11=2*l/(C-r);u.n13=(C+r)/(C-r);g.projectionMatrix.copy(u);r=-w*i-z;C=w*i-z;u.n11=
+2*l/(C-r);u.n13=(C+r)/(C-r);e.projectionMatrix.copy(u)}g.matrixWorld.copy(b.matrixWorld).multiplySelf(h);g.position.copy(b.position);g.near=b.near;g.far=b.far;d.call(c,a,g,p,!0);e.matrixWorld.copy(b.matrixWorld).multiplySelf(f);e.position.copy(b.position);e.near=b.near;e.far=b.far;d.call(c,a,e,n,!0);m.updateMatrixWorld();d.call(c,m,s)}};
 if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,d=this.render,g,e,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);c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;this.setSize=function(a,d){b.call(c,a,d);g=a/2;e=d};this.render=function(a,b){this.clear();f.fov=b.fov;f.aspect=0.5*b.aspect;f.near=b.near;f.far=
 b.far;f.updateProjectionMatrix();f.position.copy(b.position);f.target.copy(b.target);f.translateX(c.separation);f.lookAt(f.target);h.projectionMatrix=f.projectionMatrix;h.position.copy(b.position);h.target.copy(b.target);h.translateX(-c.separation);h.lookAt(h.target);this.setViewport(0,0,g,e);d.call(c,a,f);this.setViewport(g,0,g,e);d.call(c,a,h,!1)}};

+ 62 - 61
build/custom/ThreeCanvas.js

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

+ 3 - 1
examples/canvas_sandbox.html

@@ -90,7 +90,9 @@
 
 				objects = [];
 
-				geometry = new THREE.SphereGeometry( 100, 16, 8 );
+				geometry = new THREE.IcosahedronGeometry( 1 );
+				geometry.applyMatrix( new THREE.Matrix4().setScale( 100, 100, 100 ) );
+
 				material = new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', new THREE.SphericalReflectionMapping() ), overdraw: true } );
 
 				for ( var i = 0; i < 10; i ++ ) {

+ 31 - 11
src/renderers/CanvasRenderer.js

@@ -39,7 +39,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 	_color3 = new THREE.Color(),
 	_color4 = new THREE.Color(),
 
-	_patterns = [],
+	_patterns = [], _imagedatas = [],
 
 	_near, _far,
 
@@ -871,16 +871,14 @@ THREE.CanvasRenderer = function ( parameters ) {
 			width = texture.image.width * texture.repeat.x,
 			height = texture.image.height * texture.repeat.y;
 
-			// Adding ones so we don't get a 0x0 pixel get
-
 			u0 = ( u0 + offsetX ) * width;
 			v0 = ( v0 + offsetY ) * height;
 
-			u1 = ( u1 + offsetX ) * width + 1;
+			u1 = ( u1 + offsetX ) * width;
 			v1 = ( v1 + offsetY ) * height;
 
-			u2 = ( u2 + offsetX ) * width + 1;
-			v2 = ( v2 + offsetY ) * height + 1;
+			u2 = ( u2 + offsetX ) * width;
+			v2 = ( v2 + offsetY ) * height;
 
 			x1 -= x0; y1 -= y0;
 			x2 -= x0; y2 -= y0;
@@ -890,6 +888,33 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 			det = u1 * v2 - u2 * v1;
 
+			if ( det == 0 ) {
+
+				if ( _imagedatas[ texture.id ] == undefined ) {
+
+					var canvas = document.createElement( 'canvas' )
+					canvas.width = texture.image.width;
+					canvas.height = texture.image.height;
+
+					var context = canvas.getContext( '2d' );
+					context.drawImage( texture.image, 0, 0 );
+
+					_imagedatas[ texture.id ] = context.getImageData( 0, 0, texture.image.width, texture.image.height ).data;
+
+					delete canvas;
+
+				}
+
+				var data = _imagedatas[ texture.id ];
+				var index = ( Math.floor( u0 ) + Math.floor( v0 ) * texture.image.width ) * 4;
+
+				_color.setRGB( data[ index ] / 255, data[ index + 1 ] / 255, data[ index + 2 ] / 255 );
+				fillPath( _color );
+
+				return;
+
+			}
+
 			idet = 1 / det;
 
 			a = ( v2 * x1 - v1 * x2 ) * idet;
@@ -979,11 +1004,6 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 		function smoothstep( value, min, max ) {
 
-			/*
-			if ( value <= min ) return 0;
-			if ( value >= max ) return 1;
-			*/
-
 			var x = ( value - min ) / ( max - min );
 			return x * x * ( 3 - 2 * x );