浏览代码

Got WebGLRenderer working again.

I had to resurrect parts of old code (keeping track of scene graph changes).

Good news: performance is great, new scene graph gains compound with buffers optimizations and non-array materials refactoring. Together we gained about 15% for rotating cubes performance test (pushing max to 2650 cubes at 60 fps).

Still broken with new scene graph: lod, skinning, collisions, AnaglyphWebGLRenderer, ParallaxBarrierWebGLRenderer, multi-canvas circle example.
alteredq 13 年之前
父节点
当前提交
408c82d306

+ 114 - 111
build/Three.js

@@ -1,6 +1,6 @@
 // Three.js r46dev - http://github.com/mrdoob/three.js
 var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;THREE.Clock=function(a){this.autoStart=a!==void 0?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1};THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=!0};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=!1};THREE.Clock.prototype.getElapsedTime=function(){this.elapsedTime+=this.getDelta();return this.elapsedTime};
-THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var c=Date.now(),a=0.001*(c-this.oldTime);this.oldTime=c;this.elapsedTime+=a}return a};THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
+THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var c=Date.now(),a=0.0010*(c-this.oldTime);this.oldTime=c;this.elapsedTime+=a}return a};THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
 THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;return this},setHSV:function(a,c,b){var e,k,h;if(b===0)this.r=this.g=this.b=0;else switch(e=Math.floor(a*6),k=a*6-e,a=b*(1-c),h=b*(1-
 c*k),c=b*(1-c*(1-k)),e){case 1:this.r=h;this.g=b;this.b=a;break;case 2:this.r=a;this.g=b;this.b=c;break;case 3:this.r=a;this.g=h;this.b=b;break;case 4:this.r=c;this.g=a;this.b=b;break;case 5:this.r=b;this.g=a;this.b=h;break;case 6:case 0:this.r=b,this.g=c,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+
 Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
@@ -28,8 +28,8 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,c=
 THREE.Matrix4=function(a,c,b,e,k,h,f,l,n,u,t,p,w,v,z,x){this.set(a!==void 0?a:1,c||0,b||0,e||0,k||0,h!==void 0?h:1,f||0,l||0,n||0,u||0,t!==void 0?t:1,p||0,w||0,v||0,z||0,x!==void 0?x:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,c,b,e,k,h,f,l,n,u,t,p,w,v,z,x){this.n11=a;this.n12=c;this.n13=b;this.n14=e;this.n21=k;this.n22=h;this.n23=f;this.n24=l;this.n31=n;this.n32=u;this.n33=t;this.n34=p;this.n41=w;this.n42=v;this.n43=z;this.n44=x;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 e=THREE.Matrix4.__v1,k=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,c).normalize();if(h.length()===0)h.z=1;e.cross(b,h).normalize();e.length()===0&&(h.x+=1.0E-4,e.cross(b,h).normalize());k.cross(h,e).normalize();this.n11=e.x;this.n12=k.x;this.n13=h.x;this.n21=e.y;this.n22=k.y;this.n23=h.y;this.n31=e.z;this.n32=k.z;this.n33=h.z;return this},multiply:function(a,c){var b=a.n11,e=a.n12,k=a.n13,h=a.n14,f=a.n21,l=a.n22,n=a.n23,u=a.n24,t=a.n31,p=a.n32,w=a.n33,v=a.n34,z=a.n41,x=a.n42,y=a.n43,
-C=a.n44,A=c.n11,B=c.n12,D=c.n13,K=c.n14,H=c.n21,M=c.n22,V=c.n23,L=c.n24,W=c.n31,N=c.n32,O=c.n33,$=c.n34,Y=c.n41,P=c.n42,o=c.n43,U=c.n44;this.n11=b*A+e*H+k*W+h*Y;this.n12=b*B+e*M+k*N+h*P;this.n13=b*D+e*V+k*O+h*o;this.n14=b*K+e*L+k*$+h*U;this.n21=f*A+l*H+n*W+u*Y;this.n22=f*B+l*M+n*N+u*P;this.n23=f*D+l*V+n*O+u*o;this.n24=f*K+l*L+n*$+u*U;this.n31=t*A+p*H+w*W+v*Y;this.n32=t*B+p*M+w*N+v*P;this.n33=t*D+p*V+w*O+v*o;this.n34=t*K+p*L+w*$+v*U;this.n41=z*A+x*H+y*W+C*Y;this.n42=z*B+x*M+y*N+C*P;this.n43=z*D+x*
-V+y*O+C*o;this.n44=z*K+x*L+y*$+C*U;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*=
+C=a.n44,A=c.n11,B=c.n12,D=c.n13,K=c.n14,H=c.n21,M=c.n22,V=c.n23,L=c.n24,W=c.n31,N=c.n32,O=c.n33,Z=c.n34,Y=c.n41,P=c.n42,o=c.n43,U=c.n44;this.n11=b*A+e*H+k*W+h*Y;this.n12=b*B+e*M+k*N+h*P;this.n13=b*D+e*V+k*O+h*o;this.n14=b*K+e*L+k*Z+h*U;this.n21=f*A+l*H+n*W+u*Y;this.n22=f*B+l*M+n*N+u*P;this.n23=f*D+l*V+n*O+u*o;this.n24=f*K+l*L+n*Z+u*U;this.n31=t*A+p*H+w*W+v*Y;this.n32=t*B+p*M+w*N+v*P;this.n33=t*D+p*V+w*O+v*o;this.n34=t*K+p*L+w*Z+v*U;this.n41=z*A+x*H+y*W+C*Y;this.n42=z*B+x*M+y*N+C*P;this.n43=z*D+x*
+V+y*O+C*o;this.n44=z*K+x*L+y*Z+C*U;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,e=a.z,k=1/(this.n41*c+this.n42*b+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*e+this.n14)*k;a.y=(this.n21*c+this.n22*b+this.n23*e+this.n24)*k;a.z=(this.n31*c+this.n32*b+this.n33*e+this.n34)*k;return a},multiplyVector4:function(a){var c=a.x,b=a.y,e=a.z,k=a.w;a.x=this.n11*c+this.n12*b+this.n13*e+this.n14*k;a.y=this.n21*c+this.n22*
 b+this.n23*e+this.n24*k;a.z=this.n31*c+this.n32*b+this.n33*e+this.n34*k;a.w=this.n41*c+this.n42*b+this.n43*e+this.n44*k;return a},rotateAxis:function(a){var c=a.x,b=a.y,e=a.z;a.x=c*this.n11+b*this.n12+e*this.n13;a.y=c*this.n21+b*this.n22+e*this.n23;a.z=c*this.n31+b*this.n32+e*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,e=this.n14,k=this.n21,h=this.n22,f=this.n23,l=this.n24,n=this.n31,u=this.n32,t=this.n33,p=this.n34,w=this.n41,v=this.n42,z=this.n43,x=this.n44;return e*f*u*w-b*l*u*w-e*h*t*w+c*l*t*w+b*h*p*w-c*f*p*w-e*f*n*v+b*l*n*v+e*k*t*v-a*l*t*v-b*k*p*v+a*f*p*v+e*h*n*z-c*l*n*z-e*k*u*z+a*l*u*z+c*k*p*z-a*h*p*z-b*h*n*x+c*f*n*x+b*k*u*x-a*f*u*x-c*k*t*x+a*h*t*x},transpose:function(){var a;
@@ -52,27 +52,27 @@ THREE.Matrix4.makeOrtho=function(a,c,b,e,k,h){var f,l,n,u;f=new THREE.Matrix4;l=
 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,c){this.matrix.rotateAxis(c);this.position.addSelf(c.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)},remove:function(a){var c=this.children.indexOf(a);if(c!==-1)a.parent=void 0,this.children.splice(c,1)},getChildByName:function(a,c){var b,e,k;b=0;for(e=this.children.length;b<e;b++){k=this.children[b];if(k.name===a)return k;if(c&&(k=k.getChildByName(a,c),k!==void 0))return k}},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;
+-1){a.parent!==void 0&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addObject(a)}},remove:function(a){var c=this.children.indexOf(a);if(c!==-1){a.parent=void 0;this.children.splice(c,1);for(c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.removeObject(a)}},getChildByName:function(a,c){var b,e,k;b=0;for(e=this.children.length;b<e;b++){k=this.children[b];if(k.name===a)return k;
+if(c&&(k=k.getChildByName(a,c),k!==void 0))return k}},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=h[k]=h[k]||new THREE.RenderableVertex;k++;return a}function c(a,b){return b.z-a.z}function b(a,b){var c=0,e=1,f=a.z+a.w,k=b.z+b.w,h=-a.z+a.w,l=-b.z+b.w;return f>=0&&k>=0&&h>=0&&l>=0?!0:f<0&&k<0||h<0&&l<0?!1:(f<0?c=Math.max(c,f/(f-k)):k<0&&(e=Math.min(e,f/(f-k))),h<0?c=Math.max(c,h/(h-l)):l<0&&(e=Math.min(e,h/(h-l))),e<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-e),!0))}var e,k,h=[],f,l,n=[],u,t=[],p,w,v=[],z,x,y=[],C={objects:[],sprites:[],lights:[],elements:[]};
 new THREE.Vector3;var A=new THREE.Vector4,B=new THREE.Matrix4,D=new THREE.Matrix4,K=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],H=new THREE.Vector4,M=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);B.multiply(b.projectionMatrix,b.matrixWorldInverse);B.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);B.multiply(b.matrixWorld,b.projectionMatrixInverse);B.multiplyVector3(a);
 return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(a){C.objects.length=0;C.sprites.length=0;C.lights.length=0;var b=function(a){if(a.visible!=!1){var c;if(c=a instanceof THREE.Mesh)if(!(c=a.frustumCulled==!1))a:{for(var e=a.matrixWorld,f=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)),k=0;k<6;k++)if(c=
-K[k].x*e.n14+K[k].y*e.n24+K[k].z*e.n34+K[k].w,c<=f){c=!1;break a}c=!0}c?C.objects.push(a):a instanceof THREE.Line?C.objects.push(a):a instanceof THREE.Sprite||a instanceof THREE.Particle?C.sprites.push(a):a instanceof THREE.Light&&C.lights.push(a);c=0;for(e=a.children.length;c<e;c++)b(a.children[c])}};b(a);return C};this.projectScene=function(K,L,W){var N=L.near,O=L.far,$,Y,P,o,U,Q,aa,T,J,ra,pa,na,qa,ja,la,ea;x=w=u=l=0;C.elements.length=0;L.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),
-K.add(L));K.updateMatrixWorld();L.matrixWorldInverse.getInverse(L.matrixWorld);B.multiply(L.projectionMatrix,L.matrixWorldInverse);this.computeFrustum(B);C=this.projectGraph(K);K=0;for($=C.objects.length;K<$;K++)if(J=C.objects[K],ra=J.matrixWorld,na=J.material,k=0,J instanceof THREE.Mesh){pa=J.geometry;qa=J.geometry.materials;o=pa.vertices;ja=pa.faces;la=pa.faceVertexUvs;pa=J.matrixRotationWorld.extractRotation(ra);Y=0;for(P=o.length;Y<P;Y++)e=a(),e.positionWorld.copy(o[Y].position),ra.multiplyVector3(e.positionWorld),
+K[k].x*e.n14+K[k].y*e.n24+K[k].z*e.n34+K[k].w,c<=f){c=!1;break a}c=!0}c?C.objects.push(a):a instanceof THREE.Line?C.objects.push(a):a instanceof THREE.Sprite||a instanceof THREE.Particle?C.sprites.push(a):a instanceof THREE.Light&&C.lights.push(a);c=0;for(e=a.children.length;c<e;c++)b(a.children[c])}};b(a);return C};this.projectScene=function(K,L,W){var N=L.near,O=L.far,Z,Y,P,o,U,Q,aa,T,J,ra,pa,na,qa,ja,la,ea;x=w=u=l=0;C.elements.length=0;L.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),
+K.add(L));K.updateMatrixWorld();L.matrixWorldInverse.getInverse(L.matrixWorld);B.multiply(L.projectionMatrix,L.matrixWorldInverse);this.computeFrustum(B);C=this.projectGraph(K);K=0;for(Z=C.objects.length;K<Z;K++)if(J=C.objects[K],ra=J.matrixWorld,na=J.material,k=0,J instanceof THREE.Mesh){pa=J.geometry;qa=J.geometry.materials;o=pa.vertices;ja=pa.faces;la=pa.faceVertexUvs;pa=J.matrixRotationWorld.extractRotation(ra);Y=0;for(P=o.length;Y<P;Y++)e=a(),e.positionWorld.copy(o[Y].position),ra.multiplyVector3(e.positionWorld),
 e.positionScreen.copy(e.positionWorld),B.multiplyVector4(e.positionScreen),e.positionScreen.x/=e.positionScreen.w,e.positionScreen.y/=e.positionScreen.w,e.visible=e.positionScreen.z>N&&e.positionScreen.z<O;o=0;for(Y=ja.length;o<Y;o++){P=ja[o];if(P instanceof THREE.Face3)if(U=h[P.a],Q=h[P.b],aa=h[P.c],U.visible&&Q.visible&&aa.visible&&(J.doubleSided||J.flipSided!=(aa.positionScreen.x-U.positionScreen.x)*(Q.positionScreen.y-U.positionScreen.y)-(aa.positionScreen.y-U.positionScreen.y)*(Q.positionScreen.x-
 U.positionScreen.x)<0))T=n[l]=n[l]||new THREE.RenderableFace3,l++,f=T,f.v1.copy(U),f.v2.copy(Q),f.v3.copy(aa);else continue;else if(P instanceof THREE.Face4)if(U=h[P.a],Q=h[P.b],aa=h[P.c],T=h[P.d],U.visible&&Q.visible&&aa.visible&&T.visible&&(J.doubleSided||J.flipSided!=((T.positionScreen.x-U.positionScreen.x)*(Q.positionScreen.y-U.positionScreen.y)-(T.positionScreen.y-U.positionScreen.y)*(Q.positionScreen.x-U.positionScreen.x)<0||(Q.positionScreen.x-aa.positionScreen.x)*(T.positionScreen.y-aa.positionScreen.y)-
 (Q.positionScreen.y-aa.positionScreen.y)*(T.positionScreen.x-aa.positionScreen.x)<0)))ea=t[u]=t[u]||new THREE.RenderableFace4,u++,f=ea,f.v1.copy(U),f.v2.copy(Q),f.v3.copy(aa),f.v4.copy(T);else continue;f.normalWorld.copy(P.normal);pa.multiplyVector3(f.normalWorld);f.centroidWorld.copy(P.centroid);ra.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);B.multiplyVector3(f.centroidScreen);aa=P.vertexNormals;U=0;for(Q=aa.length;U<Q;U++)T=f.vertexNormalsWorld[U],T.copy(aa[U]),pa.multiplyVector3(T);
 U=0;for(Q=la.length;U<Q;U++)if(ea=la[U][o]){aa=0;for(T=ea.length;aa<T;aa++)f.uvs[U][aa]=ea[aa]}f.material=na;f.faceMaterial=P.materialIndex!==null?qa[P.materialIndex]:null;f.z=f.centroidScreen.z;C.elements.push(f)}}else if(J instanceof THREE.Line){D.multiply(B,ra);o=J.geometry.vertices;U=a();U.positionScreen.copy(o[0].position);D.multiplyVector4(U.positionScreen);Y=1;for(P=o.length;Y<P;Y++)if(U=a(),U.positionScreen.copy(o[Y].position),D.multiplyVector4(U.positionScreen),Q=h[k-2],H.copy(U.positionScreen),
-M.copy(Q.positionScreen),b(H,M))H.multiplyScalar(1/H.w),M.multiplyScalar(1/M.w),J=v[w]=v[w]||new THREE.RenderableLine,w++,p=J,p.v1.positionScreen.copy(H),p.v2.positionScreen.copy(M),p.z=Math.max(H.z,M.z),p.material=na,C.elements.push(p)}K=0;for($=C.sprites.length;K<$;K++)if(J=C.sprites[K],ra=J.matrixWorld,J instanceof THREE.Particle&&(A.set(ra.n14,ra.n24,ra.n34,1),B.multiplyVector4(A),A.z/=A.w,A.z>0&&A.z<1))N=y[x]=y[x]||new THREE.RenderableParticle,x++,z=N,z.x=A.x/A.w,z.y=A.y/A.w,z.z=A.z,z.rotation=
+M.copy(Q.positionScreen),b(H,M))H.multiplyScalar(1/H.w),M.multiplyScalar(1/M.w),J=v[w]=v[w]||new THREE.RenderableLine,w++,p=J,p.v1.positionScreen.copy(H),p.v2.positionScreen.copy(M),p.z=Math.max(H.z,M.z),p.material=na,C.elements.push(p)}K=0;for(Z=C.sprites.length;K<Z;K++)if(J=C.sprites[K],ra=J.matrixWorld,J instanceof THREE.Particle&&(A.set(ra.n14,ra.n24,ra.n34,1),B.multiplyVector4(A),A.z/=A.w,A.z>0&&A.z<1))N=y[x]=y[x]||new THREE.RenderableParticle,x++,z=N,z.x=A.x/A.w,z.y=A.y/A.w,z.z=A.z,z.rotation=
 J.rotation.z,z.scale.x=J.scale.x*Math.abs(z.x-(A.x+L.projectionMatrix.n11)/(A.w+L.projectionMatrix.n14)),z.scale.y=J.scale.y*Math.abs(z.y-(A.y+L.projectionMatrix.n22)/(A.w+L.projectionMatrix.n24)),z.material=J.material,C.elements.push(z);W&&C.elements.sort(c);return C}};THREE.Quaternion=function(a,c,b,e){this.set(a||0,c||0,b||0,e!==void 0?e:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,c,b,e){this.x=a;this.y=c;this.z=b;this.w=e;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,e=a.y*c,k=a.z*c,a=Math.cos(e),e=Math.sin(e),c=Math.cos(-k),k=Math.sin(-k),h=Math.cos(b),b=Math.sin(b),f=a*c,l=e*k;this.w=f*h-l*b;this.x=f*b+l*h;this.y=e*c*h+a*k*b;this.z=a*k*h-e*c*b;return this},setFromAxisAngle:function(a,c){var b=c/2,e=Math.sin(b);
 this.x=a.x*e;this.y=a.y*e;this.z=a.z*e;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);
 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 c=
 this.x,b=this.y,e=this.z,k=this.w,h=a.x,f=a.y,l=a.z,a=a.w;this.x=c*a+k*h+b*l-e*f;this.y=b*a+k*f+e*h-c*l;this.z=e*a+k*l+c*f-b*h;this.w=k*a-c*h-b*f-e*l;return this},multiply:function(a,c){this.x=a.x*c.w+a.y*c.z-a.z*c.y+a.w*c.x;this.y=-a.x*c.z+a.y*c.w+a.z*c.x+a.w*c.y;this.z=a.x*c.y-a.y*c.x+a.z*c.w+a.w*c.z;this.w=-a.x*c.x-a.y*c.y-a.z*c.z+a.w*c.w;return this},multiplyVector3:function(a,c){c||(c=a);var b=a.x,e=a.y,k=a.z,h=this.x,f=this.y,l=this.z,n=this.w,u=n*b+f*k-l*e,t=n*e+l*b-h*k,p=n*k+h*e-f*b,b=-h*
 b-f*e-l*k;c.x=u*n+b*-h+t*-l-p*-f;c.y=t*n+b*-f+p*-h-u*-l;c.z=p*n+b*-l+u*-f-t*-h;return c}};
-THREE.Quaternion.slerp=function(a,c,b,e){var k=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;k<0?(b.w=-c.w,b.x=-c.x,b.y=-c.y,b.z=-c.z,k=-k):b.copy(c);if(Math.abs(k)>=1)return b.w=a.w,b.x=a.x,b.y=a.y,b.z=a.z,b;var h=Math.acos(k),k=Math.sqrt(1-k*k);if(Math.abs(k)<0.001)return b.w=0.5*(a.w+c.w),b.x=0.5*(a.x+c.x),b.y=0.5*(a.y+c.y),b.z=0.5*(a.z+c.z),b;c=Math.sin((1-e)*h)/k;e=Math.sin(e*h)/k;b.w=a.w*c+b.w*e;b.x=a.x*c+b.x*e;b.y=a.y*c+b.y*e;b.z=a.z*c+b.z*e;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,c,b,e){var k=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;k<0?(b.w=-c.w,b.x=-c.x,b.y=-c.y,b.z=-c.z,k=-k):b.copy(c);if(Math.abs(k)>=1)return b.w=a.w,b.x=a.x,b.y=a.y,b.z=a.z,b;var h=Math.acos(k),k=Math.sqrt(1-k*k);if(Math.abs(k)<0.0010)return b.w=0.5*(a.w+c.w),b.x=0.5*(a.x+c.x),b.y=0.5*(a.y+c.y),b.z=0.5*(a.z+c.z),b;c=Math.sin((1-e)*h)/k;e=Math.sin(e*h)/k;b.w=a.w*c+b.w*e;b.x=a.x*c+b.x*e;b.y=a.y*c+b.y*e;b.z=a.z*c+b.z*e;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,c,b,e,k,h){this.a=a;this.b=c;this.c=b;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=k instanceof THREE.Color?k:new THREE.Color;this.vertexColors=k instanceof Array?k:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,c,b,e,k,h,f){this.a=a;this.b=c;this.c=b;this.d=e;this.normal=k instanceof THREE.Vector3?k:new THREE.Vector3;this.vertexNormals=k instanceof Array?k:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
@@ -83,8 +83,8 @@ b,e,k,h,f,l=new THREE.Vector3,n=new THREE.Vector3;e=0;for(k=this.faces.length;e<
 Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[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{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++)b=this.faces[a],b instanceof
 THREE.Face3?(e[b.a].addSelf(b.normal),e[b.b].addSelf(b.normal),e[b.c].addSelf(b.normal)):b instanceof THREE.Face4&&(e[b.a].addSelf(b.normal),e[b.b].addSelf(b.normal),e[b.c].addSelf(b.normal),e[b.d].addSelf(b.normal));a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<c;a++)b=this.faces[a],b instanceof THREE.Face3?(b.vertexNormals[0].copy(e[b.a]),b.vertexNormals[1].copy(e[b.b]),b.vertexNormals[2].copy(e[b.c])):b instanceof THREE.Face4&&(b.vertexNormals[0].copy(e[b.a]),
 b.vertexNormals[1].copy(e[b.b]),b.vertexNormals[2].copy(e[b.c]),b.vertexNormals[3].copy(e[b.d]))},computeTangents:function(){function a(a,b,c,e,k,h,o){l=a.vertices[b].position;n=a.vertices[c].position;u=a.vertices[e].position;t=f[k];p=f[h];w=f[o];v=n.x-l.x;z=u.x-l.x;x=n.y-l.y;y=u.y-l.y;C=n.z-l.z;A=u.z-l.z;B=p.u-t.u;D=w.u-t.u;K=p.v-t.v;H=w.v-t.v;M=1/(B*H-D*K);N.set((H*v-K*z)*M,(H*x-K*y)*M,(H*C-K*A)*M);O.set((B*z-D*v)*M,(B*y-D*x)*M,(B*A-D*C)*M);L[b].addSelf(N);L[c].addSelf(N);L[e].addSelf(N);W[b].addSelf(O);
-W[c].addSelf(O);W[e].addSelf(O)}var c,b,e,k,h,f,l,n,u,t,p,w,v,z,x,y,C,A,B,D,K,H,M,V,L=[],W=[],N=new THREE.Vector3,O=new THREE.Vector3,$=new THREE.Vector3,Y=new THREE.Vector3,P=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++)L[c]=new THREE.Vector3,W[c]=new THREE.Vector3;c=0;for(b=this.faces.length;c<b;c++)h=this.faces[c],f=this.faceVertexUvs[0][c],h instanceof THREE.Face3?a(this,h.a,h.b,h.c,0,1,2):h instanceof THREE.Face4&&(a(this,h.a,h.b,h.c,0,1,2),a(this,h.a,h.b,h.d,0,1,3));var o=["a","b",
-"c","d"];c=0;for(b=this.faces.length;c<b;c++){h=this.faces[c];for(e=0;e<h.vertexNormals.length;e++)P.copy(h.vertexNormals[e]),k=h[o[e]],V=L[k],$.copy(V),$.subSelf(P.multiplyScalar(P.dot(V))).normalize(),Y.cross(h.vertexNormals[e],V),k=Y.dot(W[k]),k=k<0?-1:1,h.vertexTangents[e]=new THREE.Vector4($.x,$.y,$.z,k)}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,
+W[c].addSelf(O);W[e].addSelf(O)}var c,b,e,k,h,f,l,n,u,t,p,w,v,z,x,y,C,A,B,D,K,H,M,V,L=[],W=[],N=new THREE.Vector3,O=new THREE.Vector3,Z=new THREE.Vector3,Y=new THREE.Vector3,P=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++)L[c]=new THREE.Vector3,W[c]=new THREE.Vector3;c=0;for(b=this.faces.length;c<b;c++)h=this.faces[c],f=this.faceVertexUvs[0][c],h instanceof THREE.Face3?a(this,h.a,h.b,h.c,0,1,2):h instanceof THREE.Face4&&(a(this,h.a,h.b,h.c,0,1,2),a(this,h.a,h.b,h.d,0,1,3));var o=["a","b",
+"c","d"];c=0;for(b=this.faces.length;c<b;c++){h=this.faces[c];for(e=0;e<h.vertexNormals.length;e++)P.copy(h.vertexNormals[e]),k=h[o[e]],V=L[k],Z.copy(V),Z.subSelf(P.multiplyScalar(P.dot(V))).normalize(),Y.cross(h.vertexNormals[e],V),k=Y.dot(W[k]),k=k<0?-1:1,h.vertexTangents[e]=new THREE.Vector4(Z.x,Z.y,Z.z,k)}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=[],e,k=Math.pow(10,4),h,f;h=0;for(f=this.vertices.length;h<f;h++)e=this.vertices[h].position,e=[Math.round(e.x*k),Math.round(e.y*k),Math.round(e.z*k)].join("_"),a[e]===void 0?(a[e]=h,c.push(this.vertices[h]),
 b[h]=c.length-1):b[h]=b[a[e]];h=0;for(f=this.faces.length;h<f;h++)if(a=this.faces[h],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;
@@ -146,46 +146,49 @@ THREE.Sprite=function(a){THREE.Object3D.call(this);this.color=a.color!==void 0?n
 !this.useScreenCoordinates;this.scaleByViewport=a.scaleByViewport!==void 0?a.scaleByViewport:!this.affectedByDistance;this.alignment=a.alignment instanceof THREE.Vector2?a.alignment:THREE.SpriteAlignment.center;this.rotation3d=this.rotation;this.rotation=0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=new THREE.Vector2(1,1)};THREE.Sprite.prototype=new THREE.Object3D;THREE.Sprite.prototype.constructor=THREE.Sprite;THREE.Sprite.prototype.supr=THREE.Object3D.prototype;
 THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(this.scale.x!==1||this.scale.y!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);
 THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.centerLeft=new THREE.Vector2(1,0);THREE.SpriteAlignment.center=new THREE.Vector2(0,0);THREE.SpriteAlignment.centerRight=new THREE.Vector2(-1,0);THREE.SpriteAlignment.bottomLeft=new THREE.Vector2(1,1);THREE.SpriteAlignment.bottomCenter=new THREE.Vector2(0,1);THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);
-THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;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.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 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,e,k,h;this.domElement=document.createElement("div");this.setSize=function(a,c){b=a;e=c;k=b/2;h=e/2};this.render=function(b,e){var n,u,t,p,w,v,z,x;a=c.projectScene(b,e);n=0;for(u=a.length;n<u;n++)if(w=a[n],w instanceof THREE.RenderableParticle){z=w.x*k+k;x=w.y*h+h;t=0;for(p=w.material.length;t<p;t++)if(v=w.material[t],v instanceof THREE.ParticleDOMMaterial)v=v.domElement,v.style.left=z+"px",v.style.top=x+"px"}}};
 THREE.CanvasRenderer=function(a){function c(a){if(A!=a)x.globalAlpha=A=a}function b(a){if(B!=a){switch(a){case THREE.NormalBlending:x.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:x.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:x.globalCompositeOperation="darker"}B=a}}function e(a){if(D!=a)x.strokeStyle=D=a}function k(a){if(K!=a)x.fillStyle=K=a}var h=this,f,l,n,u=new THREE.Projector,a=a||{},t=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
-p,w,v,z,x=t.getContext("2d"),y=new THREE.Color(0),C=0,A=1,B=0,D=null,K=null,H=null,M=null,V=null,L,W,N,O,$=new THREE.RenderableVertex,Y=new THREE.RenderableVertex,P,o,U,Q,aa,T,J,ra,pa,na,qa,ja,la=new THREE.Color,ea=new THREE.Color,ca=new THREE.Color,Z=new THREE.Color,ga=new THREE.Color,ha=[],oa,ma,ka,sa,Da,Ea,Ca,Fa,za,F,fa=new THREE.Rectangle,ia=new THREE.Rectangle,G=new THREE.Rectangle,da=!1,va=new THREE.Color,ua=new THREE.Color,ta=new THREE.Color,wa=new THREE.Vector3,Ga,Ba,Ka,ya,X,Ia,a=16;Ga=document.createElement("canvas");
+p,w,v,z,x=t.getContext("2d"),y=new THREE.Color(0),C=0,A=1,B=0,D=null,K=null,H=null,M=null,V=null,L,W,N,O,Z=new THREE.RenderableVertex,Y=new THREE.RenderableVertex,P,o,U,Q,aa,T,J,ra,pa,na,qa,ja,la=new THREE.Color,ea=new THREE.Color,ca=new THREE.Color,$=new THREE.Color,ga=new THREE.Color,ha=[],oa,ma,ka,sa,Da,Ea,Ca,Fa,za,F,fa=new THREE.Rectangle,ia=new THREE.Rectangle,G=new THREE.Rectangle,da=!1,ua=new THREE.Color,va=new THREE.Color,ta=new THREE.Color,wa=new THREE.Vector3,Ga,Ba,Ka,ya,X,Ia,a=16;Ga=document.createElement("canvas");
 Ga.width=Ga.height=2;Ba=Ga.getContext("2d");Ba.fillStyle="rgba(0,0,0,1)";Ba.fillRect(0,0,2,2);Ka=Ba.getImageData(0,0,2,2);ya=Ka.data;X=document.createElement("canvas");X.width=X.height=a;Ia=X.getContext("2d");Ia.translate(-a/2,-a/2);Ia.scale(a,a);a--;this.domElement=t;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){p=a;w=b;v=Math.floor(p/2);z=Math.floor(w/2);t.width=p;t.height=w;fa.set(-v,-z,v,z);ia.set(-v,-z,v,z);A=1;B=0;V=M=
 H=K=D=null};this.setClearColor=function(a,b){y.copy(a);C=b;ia.set(-v,-z,v,z)};this.setClearColorHex=function(a,b){y.setHex(a);C=b;ia.set(-v,-z,v,z)};this.clear=function(){x.setTransform(1,0,0,-1,v,z);ia.isEmpty()||(ia.minSelf(fa),ia.inflate(2),C<1&&x.clearRect(Math.floor(ia.getX()),Math.floor(ia.getY()),Math.floor(ia.getWidth()),Math.floor(ia.getHeight())),C>0&&(b(THREE.NormalBlending),c(1),k("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*255)+","+C+")"),x.fillRect(Math.floor(ia.getX()),
-Math.floor(ia.getY()),Math.floor(ia.getWidth()),Math.floor(ia.getHeight()))),ia.empty())};this.render=function(a,t){function p(a){var b,c,e,f;va.setRGB(0,0,0);ua.setRGB(0,0,0);ta.setRGB(0,0,0);b=0;for(c=a.length;b<c;b++)e=a[b],f=e.color,e instanceof THREE.AmbientLight?(va.r+=f.r,va.g+=f.g,va.b+=f.b):e instanceof THREE.DirectionalLight?(ua.r+=f.r,ua.g+=f.g,ua.b+=f.b):e instanceof THREE.PointLight&&(ta.r+=f.r,ta.g+=f.g,ta.b+=f.b)}function w(a,b,c,e){var f,k,h,o,l,n;f=0;for(k=a.length;f<k;f++)h=a[f],
+Math.floor(ia.getY()),Math.floor(ia.getWidth()),Math.floor(ia.getHeight()))),ia.empty())};this.render=function(a,t){function p(a){var b,c,e,f;ua.setRGB(0,0,0);va.setRGB(0,0,0);ta.setRGB(0,0,0);b=0;for(c=a.length;b<c;b++)e=a[b],f=e.color,e instanceof THREE.AmbientLight?(ua.r+=f.r,ua.g+=f.g,ua.b+=f.b):e instanceof THREE.DirectionalLight?(va.r+=f.r,va.g+=f.g,va.b+=f.b):e instanceof THREE.PointLight&&(ta.r+=f.r,ta.g+=f.g,ta.b+=f.b)}function w(a,b,c,e){var f,k,h,o,l,n;f=0;for(k=a.length;f<k;f++)h=a[f],
 o=h.color,h instanceof THREE.DirectionalLight?(l=h.matrixWorld.getPosition(),n=c.dot(l),n<=0||(n*=h.intensity,e.r+=o.r*n,e.g+=o.g*n,e.b+=o.b*n)):h instanceof THREE.PointLight&&(l=h.matrixWorld.getPosition(),n=c.dot(wa.sub(l,b).normalize()),n<=0||(n*=h.distance==0?1:1-Math.min(b.distanceTo(l)/h.distance,1),n!=0&&(n*=h.intensity,e.r+=o.r*n,e.g+=o.g*n,e.b+=o.b*n)))}function y(a,f,h){c(h.opacity);b(h.blending);var o,l,n,u,t,p;if(h instanceof THREE.ParticleBasicMaterial){if(h.map)u=h.map.image,t=u.width>>
 1,p=u.height>>1,h=f.scale.x*v,n=f.scale.y*z,o=h*t,l=n*p,G.set(a.x-o,a.y-l,a.x+o,a.y+l),fa.intersects(G)&&(x.save(),x.translate(a.x,a.y),x.rotate(-f.rotation),x.scale(h,-n),x.translate(-t,-p),x.drawImage(u,0,0),x.restore())}else h instanceof THREE.ParticleCanvasMaterial&&(o=f.scale.x*v,l=f.scale.y*z,G.set(a.x-o,a.y-l,a.x+o,a.y+l),fa.intersects(G)&&(e(h.color.getContextStyle()),k(h.color.getContextStyle()),x.save(),x.translate(a.x,a.y),x.rotate(-f.rotation),x.scale(o,l),h.program(x),x.restore()))}function ab(a,
 f,h,k){c(k.opacity);b(k.blending);x.beginPath();x.moveTo(a.positionScreen.x,a.positionScreen.y);x.lineTo(f.positionScreen.x,f.positionScreen.y);x.closePath();if(k instanceof THREE.LineBasicMaterial){a=k.linewidth;if(H!=a)x.lineWidth=H=a;a=k.linecap;if(M!=a)x.lineCap=M=a;a=k.linejoin;if(V!=a)x.lineJoin=V=a;e(k.color.getContextStyle());x.stroke();G.inflate(k.linewidth*2)}}function A(a,e,f,k,l,u,v,p){h.info.render.vertices+=3;h.info.render.faces++;c(p.opacity);b(p.blending);P=a.positionScreen.x;o=a.positionScreen.y;
 U=e.positionScreen.x;Q=e.positionScreen.y;aa=f.positionScreen.x;T=f.positionScreen.y;C(P,o,U,Q,aa,T);if(p instanceof THREE.MeshBasicMaterial)if(p.map)p.map.mapping instanceof THREE.UVMapping&&(sa=v.uvs[0],Wa(P,o,U,Q,aa,T,sa[k].u,sa[k].v,sa[l].u,sa[l].v,sa[u].u,sa[u].v,p.map));else if(p.envMap){if(p.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=t.matrixWorldInverse,wa.copy(v.vertexNormalsWorld[k]),Da=(wa.x*a.n11+wa.y*a.n12+wa.z*a.n13)*0.5+0.5,Ea=-(wa.x*a.n21+wa.y*a.n22+wa.z*a.n23)*0.5+
 0.5,wa.copy(v.vertexNormalsWorld[l]),Ca=(wa.x*a.n11+wa.y*a.n12+wa.z*a.n13)*0.5+0.5,Fa=-(wa.x*a.n21+wa.y*a.n22+wa.z*a.n23)*0.5+0.5,wa.copy(v.vertexNormalsWorld[u]),za=(wa.x*a.n11+wa.y*a.n12+wa.z*a.n13)*0.5+0.5,F=-(wa.x*a.n21+wa.y*a.n22+wa.z*a.n23)*0.5+0.5,Wa(P,o,U,Q,aa,T,Da,Ea,Ca,Fa,za,F,p.envMap)}else p.wireframe?K(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Ma(p.color);else if(p instanceof THREE.MeshLambertMaterial)p.map&&!p.wireframe&&(p.map.mapping instanceof THREE.UVMapping&&
-(sa=v.uvs[0],Wa(P,o,U,Q,aa,T,sa[k].u,sa[k].v,sa[l].u,sa[l].v,sa[u].u,sa[u].v,p.map)),b(THREE.SubtractiveBlending)),da?!p.wireframe&&p.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==3?(ea.r=ca.r=Z.r=va.r,ea.g=ca.g=Z.g=va.g,ea.b=ca.b=Z.b=va.b,w(n,v.v1.positionWorld,v.vertexNormalsWorld[0],ea),w(n,v.v2.positionWorld,v.vertexNormalsWorld[1],ca),w(n,v.v3.positionWorld,v.vertexNormalsWorld[2],Z),ea.r=Math.max(0,Math.min(p.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(p.color.g*ea.g,1)),ea.b=Math.max(0,
-Math.min(p.color.b*ea.b,1)),ca.r=Math.max(0,Math.min(p.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(p.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(p.color.b*ca.b,1)),Z.r=Math.max(0,Math.min(p.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(p.color.g*Z.g,1)),Z.b=Math.max(0,Math.min(p.color.b*Z.b,1)),ga.r=(ca.r+Z.r)*0.5,ga.g=(ca.g+Z.g)*0.5,ga.b=(ca.b+Z.b)*0.5,ka=Ua(ea,ca,Z,ga),Sa(P,o,U,Q,aa,T,0,0,1,0,0,1,ka)):(la.r=va.r,la.g=va.g,la.b=va.b,w(n,v.centroidWorld,v.normalWorld,la),la.r=Math.max(0,Math.min(p.color.r*
-la.r,1)),la.g=Math.max(0,Math.min(p.color.g*la.g,1)),la.b=Math.max(0,Math.min(p.color.b*la.b,1)),p.wireframe?K(la,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Ma(la)):p.wireframe?K(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Ma(p.color);else if(p instanceof THREE.MeshDepthMaterial)oa=t.near,ma=t.far,ea.r=ea.g=ea.b=1-Oa(a.positionScreen.z,oa,ma),ca.r=ca.g=ca.b=1-Oa(e.positionScreen.z,oa,ma),Z.r=Z.g=Z.b=1-Oa(f.positionScreen.z,oa,ma),ga.r=(ca.r+Z.r)*0.5,ga.g=
-(ca.g+Z.g)*0.5,ga.b=(ca.b+Z.b)*0.5,ka=Ua(ea,ca,Z,ga),Sa(P,o,U,Q,aa,T,0,0,1,0,0,1,ka);else if(p instanceof THREE.MeshNormalMaterial)la.r=Ta(v.normalWorld.x),la.g=Ta(v.normalWorld.y),la.b=Ta(v.normalWorld.z),p.wireframe?K(la,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Ma(la)}function B(a,e,f,k,l,u,p,v,xa){h.info.render.vertices+=4;h.info.render.faces++;c(v.opacity);b(v.blending);if(v.map||v.envMap)A(a,e,k,0,1,3,p,v,xa),A(l,f,u,1,2,3,p,v,xa);else if(P=a.positionScreen.x,o=a.positionScreen.y,
+(sa=v.uvs[0],Wa(P,o,U,Q,aa,T,sa[k].u,sa[k].v,sa[l].u,sa[l].v,sa[u].u,sa[u].v,p.map)),b(THREE.SubtractiveBlending)),da?!p.wireframe&&p.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==3?(ea.r=ca.r=$.r=ua.r,ea.g=ca.g=$.g=ua.g,ea.b=ca.b=$.b=ua.b,w(n,v.v1.positionWorld,v.vertexNormalsWorld[0],ea),w(n,v.v2.positionWorld,v.vertexNormalsWorld[1],ca),w(n,v.v3.positionWorld,v.vertexNormalsWorld[2],$),ea.r=Math.max(0,Math.min(p.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(p.color.g*ea.g,1)),ea.b=Math.max(0,
+Math.min(p.color.b*ea.b,1)),ca.r=Math.max(0,Math.min(p.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(p.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(p.color.b*ca.b,1)),$.r=Math.max(0,Math.min(p.color.r*$.r,1)),$.g=Math.max(0,Math.min(p.color.g*$.g,1)),$.b=Math.max(0,Math.min(p.color.b*$.b,1)),ga.r=(ca.r+$.r)*0.5,ga.g=(ca.g+$.g)*0.5,ga.b=(ca.b+$.b)*0.5,ka=Ua(ea,ca,$,ga),Sa(P,o,U,Q,aa,T,0,0,1,0,0,1,ka)):(la.r=ua.r,la.g=ua.g,la.b=ua.b,w(n,v.centroidWorld,v.normalWorld,la),la.r=Math.max(0,Math.min(p.color.r*
+la.r,1)),la.g=Math.max(0,Math.min(p.color.g*la.g,1)),la.b=Math.max(0,Math.min(p.color.b*la.b,1)),p.wireframe?K(la,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Ma(la)):p.wireframe?K(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Ma(p.color);else if(p instanceof THREE.MeshDepthMaterial)oa=t.near,ma=t.far,ea.r=ea.g=ea.b=1-Oa(a.positionScreen.z,oa,ma),ca.r=ca.g=ca.b=1-Oa(e.positionScreen.z,oa,ma),$.r=$.g=$.b=1-Oa(f.positionScreen.z,oa,ma),ga.r=(ca.r+$.r)*0.5,ga.g=
+(ca.g+$.g)*0.5,ga.b=(ca.b+$.b)*0.5,ka=Ua(ea,ca,$,ga),Sa(P,o,U,Q,aa,T,0,0,1,0,0,1,ka);else if(p instanceof THREE.MeshNormalMaterial)la.r=Ta(v.normalWorld.x),la.g=Ta(v.normalWorld.y),la.b=Ta(v.normalWorld.z),p.wireframe?K(la,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Ma(la)}function B(a,e,f,k,l,u,p,v,xa){h.info.render.vertices+=4;h.info.render.faces++;c(v.opacity);b(v.blending);if(v.map||v.envMap)A(a,e,k,0,1,3,p,v,xa),A(l,f,u,1,2,3,p,v,xa);else if(P=a.positionScreen.x,o=a.positionScreen.y,
 U=e.positionScreen.x,Q=e.positionScreen.y,aa=f.positionScreen.x,T=f.positionScreen.y,J=k.positionScreen.x,ra=k.positionScreen.y,pa=l.positionScreen.x,na=l.positionScreen.y,qa=u.positionScreen.x,ja=u.positionScreen.y,v instanceof THREE.MeshBasicMaterial)D(P,o,U,Q,aa,T,J,ra),v.wireframe?K(v.color,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Ma(v.color);else if(v instanceof THREE.MeshLambertMaterial)da?!v.wireframe&&v.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==4?(ea.r=
-ca.r=Z.r=ga.r=va.r,ea.g=ca.g=Z.g=ga.g=va.g,ea.b=ca.b=Z.b=ga.b=va.b,w(n,p.v1.positionWorld,p.vertexNormalsWorld[0],ea),w(n,p.v2.positionWorld,p.vertexNormalsWorld[1],ca),w(n,p.v4.positionWorld,p.vertexNormalsWorld[3],Z),w(n,p.v3.positionWorld,p.vertexNormalsWorld[2],ga),ea.r=Math.max(0,Math.min(v.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(v.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(v.color.b*ea.b,1)),ca.r=Math.max(0,Math.min(v.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(v.color.g*ca.g,1)),ca.b=Math.max(0,
-Math.min(v.color.b*ca.b,1)),Z.r=Math.max(0,Math.min(v.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(v.color.g*Z.g,1)),Z.b=Math.max(0,Math.min(v.color.b*Z.b,1)),ga.r=Math.max(0,Math.min(v.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(v.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(v.color.b*ga.b,1)),ka=Ua(ea,ca,Z,ga),C(P,o,U,Q,J,ra),Sa(P,o,U,Q,J,ra,0,0,1,0,0,1,ka),C(pa,na,aa,T,qa,ja),Sa(pa,na,aa,T,qa,ja,1,0,1,1,0,1,ka)):(la.r=va.r,la.g=va.g,la.b=va.b,w(n,p.centroidWorld,p.normalWorld,la),la.r=Math.max(0,Math.min(v.color.r*
+ca.r=$.r=ga.r=ua.r,ea.g=ca.g=$.g=ga.g=ua.g,ea.b=ca.b=$.b=ga.b=ua.b,w(n,p.v1.positionWorld,p.vertexNormalsWorld[0],ea),w(n,p.v2.positionWorld,p.vertexNormalsWorld[1],ca),w(n,p.v4.positionWorld,p.vertexNormalsWorld[3],$),w(n,p.v3.positionWorld,p.vertexNormalsWorld[2],ga),ea.r=Math.max(0,Math.min(v.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(v.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(v.color.b*ea.b,1)),ca.r=Math.max(0,Math.min(v.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(v.color.g*ca.g,1)),ca.b=Math.max(0,
+Math.min(v.color.b*ca.b,1)),$.r=Math.max(0,Math.min(v.color.r*$.r,1)),$.g=Math.max(0,Math.min(v.color.g*$.g,1)),$.b=Math.max(0,Math.min(v.color.b*$.b,1)),ga.r=Math.max(0,Math.min(v.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(v.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(v.color.b*ga.b,1)),ka=Ua(ea,ca,$,ga),C(P,o,U,Q,J,ra),Sa(P,o,U,Q,J,ra,0,0,1,0,0,1,ka),C(pa,na,aa,T,qa,ja),Sa(pa,na,aa,T,qa,ja,1,0,1,1,0,1,ka)):(la.r=ua.r,la.g=ua.g,la.b=ua.b,w(n,p.centroidWorld,p.normalWorld,la),la.r=Math.max(0,Math.min(v.color.r*
 la.r,1)),la.g=Math.max(0,Math.min(v.color.g*la.g,1)),la.b=Math.max(0,Math.min(v.color.b*la.b,1)),D(P,o,U,Q,aa,T,J,ra),v.wireframe?K(la,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Ma(la)):(D(P,o,U,Q,aa,T,J,ra),v.wireframe?K(v.color,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Ma(v.color));else if(v instanceof THREE.MeshNormalMaterial)la.r=Ta(p.normalWorld.x),la.g=Ta(p.normalWorld.y),la.b=Ta(p.normalWorld.z),D(P,o,U,Q,aa,T,J,ra),v.wireframe?K(la,v.wireframeLinewidth,
-v.wireframeLinecap,v.wireframeLinejoin):Ma(la);else if(v instanceof THREE.MeshDepthMaterial)oa=t.near,ma=t.far,ea.r=ea.g=ea.b=1-Oa(a.positionScreen.z,oa,ma),ca.r=ca.g=ca.b=1-Oa(e.positionScreen.z,oa,ma),Z.r=Z.g=Z.b=1-Oa(k.positionScreen.z,oa,ma),ga.r=ga.g=ga.b=1-Oa(f.positionScreen.z,oa,ma),ka=Ua(ea,ca,Z,ga),C(P,o,U,Q,J,ra),Sa(P,o,U,Q,J,ra,0,0,1,0,0,1,ka),C(pa,na,aa,T,qa,ja),Sa(pa,na,aa,T,qa,ja,1,0,1,1,0,1,ka)}function C(a,b,c,e,f,k){x.beginPath();x.moveTo(a,b);x.lineTo(c,e);x.lineTo(f,k);x.lineTo(a,
+v.wireframeLinecap,v.wireframeLinejoin):Ma(la);else if(v instanceof THREE.MeshDepthMaterial)oa=t.near,ma=t.far,ea.r=ea.g=ea.b=1-Oa(a.positionScreen.z,oa,ma),ca.r=ca.g=ca.b=1-Oa(e.positionScreen.z,oa,ma),$.r=$.g=$.b=1-Oa(k.positionScreen.z,oa,ma),ga.r=ga.g=ga.b=1-Oa(f.positionScreen.z,oa,ma),ka=Ua(ea,ca,$,ga),C(P,o,U,Q,J,ra),Sa(P,o,U,Q,J,ra,0,0,1,0,0,1,ka),C(pa,na,aa,T,qa,ja),Sa(pa,na,aa,T,qa,ja,1,0,1,1,0,1,ka)}function C(a,b,c,e,f,k){x.beginPath();x.moveTo(a,b);x.lineTo(c,e);x.lineTo(f,k);x.lineTo(a,
 b);x.closePath()}function D(a,b,c,e,f,k,h,o){x.beginPath();x.moveTo(a,b);x.lineTo(c,e);x.lineTo(f,k);x.lineTo(h,o);x.lineTo(a,b);x.closePath()}function K(a,b,c,f){if(H!=b)x.lineWidth=H=b;if(M!=c)x.lineCap=M=c;if(V!=f)x.lineJoin=V=f;e(a.getContextStyle());x.stroke();G.inflate(b*2)}function Ma(a){k(a.getContextStyle());x.fill()}function Wa(a,b,c,e,f,h,o,l,n,v,p,u,t){if(t.image.width!=0){if(t.needsUpdate==!0||ha[t.id]==void 0){var xa=t.wrapS==THREE.RepeatWrapping,w=t.wrapT==THREE.RepeatWrapping;ha[t.id]=
 x.createPattern(t.image,xa&&w?"repeat":xa&&!w?"repeat-x":!xa&&w?"repeat-y":"no-repeat");t.needsUpdate=!1}k(ha[t.id]);var xa=t.offset.x/t.repeat.x,w=t.offset.y/t.repeat.y,F=(t.image.width-1)*t.repeat.x,t=(t.image.height-1)*t.repeat.y,o=(o+xa)*F,l=(l+w)*t,n=(n+xa)*F,v=(v+w)*t,p=(p+xa)*F,u=(u+w)*t;c-=a;e-=b;f-=a;h-=b;n-=o;v-=l;p-=o;u-=l;xa=1/(n*u-p*v);t=(u*c-v*f)*xa;v=(u*e-v*h)*xa;c=(n*f-p*c)*xa;e=(n*h-p*e)*xa;a=a-t*o-c*l;b=b-v*o-e*l;x.save();x.transform(t,v,c,e,a,b);x.fill();x.restore()}}function Sa(a,
 b,c,e,f,k,h,o,l,n,v,p,u){var t,xa;t=u.width-1;xa=u.height-1;h*=t;o*=xa;l*=t;n*=xa;v*=t;p*=xa;c-=a;e-=b;f-=a;k-=b;l-=h;n-=o;v-=h;p-=o;xa=1/(l*p-v*n);t=(p*c-n*f)*xa;n=(p*e-n*k)*xa;c=(l*f-v*c)*xa;e=(l*k-v*e)*xa;a=a-t*h-c*o;b=b-n*h-e*o;x.save();x.transform(t,n,c,e,a,b);x.clip();x.drawImage(u,0,0);x.restore()}function Ua(a,b,c,e){var f=~~(a.r*255),k=~~(a.g*255),a=~~(a.b*255),h=~~(b.r*255),o=~~(b.g*255),b=~~(b.b*255),l=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),v=~~(e.r*255),p=~~(e.g*255),e=~~(e.b*255);ya[0]=
 f<0?0:f>255?255:f;ya[1]=k<0?0:k>255?255:k;ya[2]=a<0?0:a>255?255:a;ya[4]=h<0?0:h>255?255:h;ya[5]=o<0?0:o>255?255:o;ya[6]=b<0?0:b>255?255:b;ya[8]=l<0?0:l>255?255:l;ya[9]=n<0?0:n>255?255:n;ya[10]=c<0?0:c>255?255:c;ya[12]=v<0?0:v>255?255:v;ya[13]=p<0?0:p>255?255:p;ya[14]=e<0?0:e>255?255:e;Ba.putImageData(Ka,0,0);Ia.drawImage(Ga,0,0);return X}function Oa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ta(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Na(a,b){var c=b.x-a.x,e=b.y-a.y,f=c*c+e*e;f!=0&&(f=1/
 Math.sqrt(f),c*=f,e*=f,b.x+=c,b.y+=e,a.x-=c,a.y-=e)}var Va,Xa,Aa,Ha;this.autoClear?this.clear():x.setTransform(1,0,0,-1,v,z);h.info.render.vertices=0;h.info.render.faces=0;f=u.projectScene(a,t,this.sortElements);l=f.elements;n=f.lights;(da=n.length>0)&&p(n);Va=0;for(Xa=l.length;Va<Xa;Va++)if(Aa=l[Va],Ha=Aa.material,Ha=Ha instanceof THREE.MeshFaceMaterial?Aa.faceMaterial:Ha,!(Ha==null||Ha.opacity==0)){G.empty();if(Aa instanceof THREE.RenderableParticle)L=Aa,L.x*=v,L.y*=z,y(L,Aa,Ha,a);else if(Aa instanceof
 THREE.RenderableLine)L=Aa.v1,W=Aa.v2,L.positionScreen.x*=v,L.positionScreen.y*=z,W.positionScreen.x*=v,W.positionScreen.y*=z,G.addPoint(L.positionScreen.x,L.positionScreen.y),G.addPoint(W.positionScreen.x,W.positionScreen.y),fa.intersects(G)&&ab(L,W,Aa,Ha,a);else if(Aa instanceof THREE.RenderableFace3)L=Aa.v1,W=Aa.v2,N=Aa.v3,L.positionScreen.x*=v,L.positionScreen.y*=z,W.positionScreen.x*=v,W.positionScreen.y*=z,N.positionScreen.x*=v,N.positionScreen.y*=z,Ha.overdraw&&(Na(L.positionScreen,W.positionScreen),
-Na(W.positionScreen,N.positionScreen),Na(N.positionScreen,L.positionScreen)),G.add3Points(L.positionScreen.x,L.positionScreen.y,W.positionScreen.x,W.positionScreen.y,N.positionScreen.x,N.positionScreen.y),fa.intersects(G)&&A(L,W,N,0,1,2,Aa,Ha,a);else if(Aa instanceof THREE.RenderableFace4)L=Aa.v1,W=Aa.v2,N=Aa.v3,O=Aa.v4,L.positionScreen.x*=v,L.positionScreen.y*=z,W.positionScreen.x*=v,W.positionScreen.y*=z,N.positionScreen.x*=v,N.positionScreen.y*=z,O.positionScreen.x*=v,O.positionScreen.y*=z,$.positionScreen.copy(W.positionScreen),
-Y.positionScreen.copy(O.positionScreen),Ha.overdraw&&(Na(L.positionScreen,W.positionScreen),Na(W.positionScreen,O.positionScreen),Na(O.positionScreen,L.positionScreen),Na(N.positionScreen,$.positionScreen),Na(N.positionScreen,Y.positionScreen)),G.addPoint(L.positionScreen.x,L.positionScreen.y),G.addPoint(W.positionScreen.x,W.positionScreen.y),G.addPoint(N.positionScreen.x,N.positionScreen.y),G.addPoint(O.positionScreen.x,O.positionScreen.y),fa.intersects(G)&&Ha.opacity!=0&&B(L,W,N,O,$,Y,Aa,Ha,a);
+Na(W.positionScreen,N.positionScreen),Na(N.positionScreen,L.positionScreen)),G.add3Points(L.positionScreen.x,L.positionScreen.y,W.positionScreen.x,W.positionScreen.y,N.positionScreen.x,N.positionScreen.y),fa.intersects(G)&&A(L,W,N,0,1,2,Aa,Ha,a);else if(Aa instanceof THREE.RenderableFace4)L=Aa.v1,W=Aa.v2,N=Aa.v3,O=Aa.v4,L.positionScreen.x*=v,L.positionScreen.y*=z,W.positionScreen.x*=v,W.positionScreen.y*=z,N.positionScreen.x*=v,N.positionScreen.y*=z,O.positionScreen.x*=v,O.positionScreen.y*=z,Z.positionScreen.copy(W.positionScreen),
+Y.positionScreen.copy(O.positionScreen),Ha.overdraw&&(Na(L.positionScreen,W.positionScreen),Na(W.positionScreen,O.positionScreen),Na(O.positionScreen,L.positionScreen),Na(N.positionScreen,Z.positionScreen),Na(N.positionScreen,Y.positionScreen)),G.addPoint(L.positionScreen.x,L.positionScreen.y),G.addPoint(W.positionScreen.x,W.positionScreen.y),G.addPoint(N.positionScreen.x,N.positionScreen.y),G.addPoint(O.positionScreen.x,O.positionScreen.y),fa.intersects(G)&&Ha.opacity!=0&&B(L,W,N,O,Z,Y,Aa,Ha,a);
 ia.addRectangle(G)}x.setTransform(1,0,0,1,0,0)}};
 THREE.SVGRenderer=function(){function a(a,b,c,e){var f,k,h,l,n,v;f=0;for(k=a.length;f<k;f++)h=a[f],l=h.color,h instanceof THREE.DirectionalLight?(n=h.matrixWorld.getPosition(),v=c.dot(n),v<=0||(v*=h.intensity,e.r+=l.r*v,e.g+=l.g*v,e.b+=l.b*v)):h instanceof THREE.PointLight&&(n=h.matrixWorld.getPosition(),v=c.dot(L.sub(n,b).normalize()),v<=0||(v*=h.distance==0?1:1-Math.min(b.distanceTo(n)/h.distance,1),v!=0&&(v*=h.intensity,e.r+=l.r*v,e.g+=l.g*v,e.b+=l.b*v)))}function c(a){W[a]==null&&(W[a]=document.createElementNS("http://www.w3.org/2000/svg",
-"path"),P==0&&W[a].setAttribute("shape-rendering","crispEdges"));return W[a]}function b(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var e=this,k,h,f,l=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),u,t,p,w,v,z,x,y,C=new THREE.Rectangle,A=new THREE.Rectangle,B=!1,D=new THREE.Color,K=new THREE.Color,H=new THREE.Color,M=new THREE.Color,V,L=new THREE.Vector3,W=[],N=[],O,$,Y,P=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,
+"path"),P==0&&W[a].setAttribute("shape-rendering","crispEdges"));return W[a]}function b(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var e=this,k,h,f,l=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),u,t,p,w,v,z,x,y,C=new THREE.Rectangle,A=new THREE.Rectangle,B=!1,D=new THREE.Color,K=new THREE.Color,H=new THREE.Color,M=new THREE.Color,V,L=new THREE.Vector3,W=[],N=[],O,Z,Y,P=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,
 faces:0}};this.setQuality=function(a){switch(a){case "high":P=1;break;case "low":P=0}};this.setSize=function(a,b){u=a;t=b;p=u/2;w=t/2;n.setAttribute("viewBox",-p+" "+-w+" "+u+" "+t);n.setAttribute("width",u);n.setAttribute("height",t);C.set(-p,-w,p,w)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=function(o,u){var t,L,T,J;this.autoClear&&this.clear();e.info.render.vertices=0;e.info.render.faces=0;k=l.projectScene(o,u,this.sortElements);h=k.elements;
-f=k.lights;Y=$=0;if(B=f.length>0){K.setRGB(0,0,0);H.setRGB(0,0,0);M.setRGB(0,0,0);t=0;for(L=f.length;t<L;t++)J=f[t],T=J.color,J instanceof THREE.AmbientLight?(K.r+=T.r,K.g+=T.g,K.b+=T.b):J instanceof THREE.DirectionalLight?(H.r+=T.r,H.g+=T.g,H.b+=T.b):J instanceof THREE.PointLight&&(M.r+=T.r,M.g+=T.g,M.b+=T.b)}t=0;for(L=h.length;t<L;t++)if(T=h[t],J=T.material,J=J instanceof THREE.MeshFaceMaterial?T.faceMaterial:J,!(J==null||J.opacity==0))if(A.empty(),T instanceof THREE.RenderableParticle)v=T,v.x*=
+f=k.lights;Y=Z=0;if(B=f.length>0){K.setRGB(0,0,0);H.setRGB(0,0,0);M.setRGB(0,0,0);t=0;for(L=f.length;t<L;t++)J=f[t],T=J.color,J instanceof THREE.AmbientLight?(K.r+=T.r,K.g+=T.g,K.b+=T.b):J instanceof THREE.DirectionalLight?(H.r+=T.r,H.g+=T.g,H.b+=T.b):J instanceof THREE.PointLight&&(M.r+=T.r,M.g+=T.g,M.b+=T.b)}t=0;for(L=h.length;t<L;t++)if(T=h[t],J=T.material,J=J instanceof THREE.MeshFaceMaterial?T.faceMaterial:J,!(J==null||J.opacity==0))if(A.empty(),T instanceof THREE.RenderableParticle)v=T,v.x*=
 p,v.y*=-w,m=0,ml=T.materials.length;else if(T instanceof THREE.RenderableLine){if(v=T.v1,z=T.v2,v.positionScreen.x*=p,v.positionScreen.y*=-w,z.positionScreen.x*=p,z.positionScreen.y*=-w,A.addPoint(v.positionScreen.x,v.positionScreen.y),A.addPoint(z.positionScreen.x,z.positionScreen.y),C.intersects(A)){T=v;var W=z,pa=Y++;N[pa]==null&&(N[pa]=document.createElementNS("http://www.w3.org/2000/svg","line"),P==0&&N[pa].setAttribute("shape-rendering","crispEdges"));O=N[pa];O.setAttribute("x1",T.positionScreen.x);
 O.setAttribute("y1",T.positionScreen.y);O.setAttribute("x2",W.positionScreen.x);O.setAttribute("y2",W.positionScreen.y);J instanceof THREE.LineBasicMaterial&&(O.setAttribute("style","fill: none; stroke: "+J.color.getContextStyle()+"; stroke-width: "+J.linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.linecap+"; stroke-linejoin: "+J.linejoin),n.appendChild(O))}}else if(T instanceof THREE.RenderableFace3){if(v=T.v1,z=T.v2,x=T.v3,v.positionScreen.x*=p,v.positionScreen.y*=-w,z.positionScreen.x*=
-p,z.positionScreen.y*=-w,x.positionScreen.x*=p,x.positionScreen.y*=-w,A.addPoint(v.positionScreen.x,v.positionScreen.y),A.addPoint(z.positionScreen.x,z.positionScreen.y),A.addPoint(x.positionScreen.x,x.positionScreen.y),C.intersects(A)){var W=v,pa=z,na=x;e.info.render.vertices+=3;e.info.render.faces++;O=c($++);O.setAttribute("d","M "+W.positionScreen.x+" "+W.positionScreen.y+" L "+pa.positionScreen.x+" "+pa.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+"z");J instanceof THREE.MeshBasicMaterial?
+p,z.positionScreen.y*=-w,x.positionScreen.x*=p,x.positionScreen.y*=-w,A.addPoint(v.positionScreen.x,v.positionScreen.y),A.addPoint(z.positionScreen.x,z.positionScreen.y),A.addPoint(x.positionScreen.x,x.positionScreen.y),C.intersects(A)){var W=v,pa=z,na=x;e.info.render.vertices+=3;e.info.render.faces++;O=c(Z++);O.setAttribute("d","M "+W.positionScreen.x+" "+W.positionScreen.y+" L "+pa.positionScreen.x+" "+pa.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+"z");J instanceof THREE.MeshBasicMaterial?
 D.copy(J.color):J instanceof THREE.MeshLambertMaterial?B?(D.r=K.r,D.g=K.g,D.b=K.b,a(f,T.centroidWorld,T.normalWorld,D),D.r=Math.max(0,Math.min(J.color.r*D.r,1)),D.g=Math.max(0,Math.min(J.color.g*D.g,1)),D.b=Math.max(0,Math.min(J.color.b*D.b,1))):D.copy(J.color):J instanceof THREE.MeshDepthMaterial?(V=1-J.__2near/(J.__farPlusNear-T.z*J.__farMinusNear),D.setRGB(V,V,V)):J instanceof THREE.MeshNormalMaterial&&D.setRGB(b(T.normalWorld.x),b(T.normalWorld.y),b(T.normalWorld.z));J.wireframe?O.setAttribute("style",
 "fill: none; stroke: "+D.getContextStyle()+"; stroke-width: "+J.wireframeLinewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframeLinecap+"; stroke-linejoin: "+J.wireframeLinejoin):O.setAttribute("style","fill: "+D.getContextStyle()+"; fill-opacity: "+J.opacity);n.appendChild(O)}}else if(T instanceof THREE.RenderableFace4&&(v=T.v1,z=T.v2,x=T.v3,y=T.v4,v.positionScreen.x*=p,v.positionScreen.y*=-w,z.positionScreen.x*=p,z.positionScreen.y*=-w,x.positionScreen.x*=p,x.positionScreen.y*=
--w,y.positionScreen.x*=p,y.positionScreen.y*=-w,A.addPoint(v.positionScreen.x,v.positionScreen.y),A.addPoint(z.positionScreen.x,z.positionScreen.y),A.addPoint(x.positionScreen.x,x.positionScreen.y),A.addPoint(y.positionScreen.x,y.positionScreen.y),C.intersects(A))){var W=v,pa=z,na=x,qa=y;e.info.render.vertices+=4;e.info.render.faces++;O=c($++);O.setAttribute("d","M "+W.positionScreen.x+" "+W.positionScreen.y+" L "+pa.positionScreen.x+" "+pa.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+
+-w,y.positionScreen.x*=p,y.positionScreen.y*=-w,A.addPoint(v.positionScreen.x,v.positionScreen.y),A.addPoint(z.positionScreen.x,z.positionScreen.y),A.addPoint(x.positionScreen.x,x.positionScreen.y),A.addPoint(y.positionScreen.x,y.positionScreen.y),C.intersects(A))){var W=v,pa=z,na=x,qa=y;e.info.render.vertices+=4;e.info.render.faces++;O=c(Z++);O.setAttribute("d","M "+W.positionScreen.x+" "+W.positionScreen.y+" L "+pa.positionScreen.x+" "+pa.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+
 " L "+qa.positionScreen.x+","+qa.positionScreen.y+"z");J instanceof THREE.MeshBasicMaterial?D.copy(J.color):J instanceof THREE.MeshLambertMaterial?B?(D.r=K.r,D.g=K.g,D.b=K.b,a(f,T.centroidWorld,T.normalWorld,D),D.r=Math.max(0,Math.min(J.color.r*D.r,1)),D.g=Math.max(0,Math.min(J.color.g*D.g,1)),D.b=Math.max(0,Math.min(J.color.b*D.b,1))):D.copy(J.color):J instanceof THREE.MeshDepthMaterial?(V=1-J.__2near/(J.__farPlusNear-T.z*J.__farMinusNear),D.setRGB(V,V,V)):J instanceof THREE.MeshNormalMaterial&&
 D.setRGB(b(T.normalWorld.x),b(T.normalWorld.y),b(T.normalWorld.z));J.wireframe?O.setAttribute("style","fill: none; stroke: "+D.getContextStyle()+"; stroke-width: "+J.wireframeLinewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframeLinecap+"; stroke-linejoin: "+J.wireframeLinejoin):O.setAttribute("style","fill: "+D.getContextStyle()+"; fill-opacity: "+J.opacity);n.appendChild(O)}}};
 THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
@@ -249,54 +252,54 @@ h.__webglTangentBuffer),o.vertexAttribPointer(a.tangent,4,o.FLOAT,!1,0,0));a.uv>
 0,h.__webglLineCount),P.info.render.calls++):k instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,h.__webglParticleCount),P.info.render.calls++):k instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,0,h.__webglVertexCount),P.info.render.calls++)}}function h(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=o.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=o.createBuffer();a.hasPos&&(o.bindBuffer(o.ARRAY_BUFFER,a.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,a.positionArray,
 o.DYNAMIC_DRAW),o.enableVertexAttribArray(b.attributes.position),o.vertexAttribPointer(b.attributes.position,3,o.FLOAT,!1,0,0));if(a.hasNormal){o.bindBuffer(o.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var e,f,h,k,l,n,v,p,u,t,x=a.count*3;for(t=0;t<x;t+=9)c=a.normalArray,e=c[t],f=c[t+1],h=c[t+2],k=c[t+3],n=c[t+4],p=c[t+5],l=c[t+6],v=c[t+7],u=c[t+8],e=(e+k+l)/3,f=(f+n+v)/3,h=(h+p+u)/3,c[t]=e,c[t+1]=f,c[t+2]=h,c[t+3]=e,c[t+4]=f,c[t+5]=h,c[t+6]=e,c[t+7]=f,c[t+8]=h}o.bufferData(o.ARRAY_BUFFER,
 a.normalArray,o.DYNAMIC_DRAW);o.enableVertexAttribArray(b.attributes.normal);o.vertexAttribPointer(b.attributes.normal,3,o.FLOAT,!1,0,0)}o.drawArrays(o.TRIANGLES,0,a.count);a.count=0}function f(a){if(pa!==a.doubleSided)a.doubleSided?o.disable(o.CULL_FACE):o.enable(o.CULL_FACE),pa=a.doubleSided;if(na!==a.flipSided)a.flipSided?o.frontFace(o.CW):o.frontFace(o.CCW),na=a.flipSided}function l(a){ja!==a&&(a?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),ja=a)}function n(a){la!==a&&(o.depthMask(a),la=a)}
-function u(a,b,c){ea!==a&&(a?o.enable(o.POLYGON_OFFSET_FILL):o.disable(o.POLYGON_OFFSET_FILL),ea=a);if(a&&(ca!==b||Z!==c))o.polygonOffset(b,c),ca=b,Z=c}function t(a){ka[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);ka[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);ka[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);ka[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);ka[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);ka[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+
+function u(a,b,c){ea!==a&&(a?o.enable(o.POLYGON_OFFSET_FILL):o.disable(o.POLYGON_OFFSET_FILL),ea=a);if(a&&(ca!==b||$!==c))o.polygonOffset(b,c),ca=b,$=c}function t(a){ka[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);ka[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);ka[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);ka[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);ka[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);ka[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=ka[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function p(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)),e=0;e<6;e++)if(a=ka[e].x*b.n14+ka[e].y*b.n24+ka[e].z*b.n34+ka[e].w,a<=c)return!1;return!0}function w(a){var b=a.object.material;b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function v(a){var b=a.object,c=a.buffer,e;e=b.material;if(e instanceof THREE.MeshFaceMaterial){if(c=
-c.materialIndex,c>=0)b=b.geometry.materials[c],b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}else if(b=e)b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function z(a,b){return b.z-a.z}function x(a){var b,c,n,v=0,u,x,w,F,y=a.lights;ua||(ua=new THREE.PerspectiveCamera(P.shadowCameraFov,P.shadowMapWidth/P.shadowMapHeight,P.shadowCameraNear,P.shadowCameraFar));b=0;for(c=y.length;b<c;b++)if(n=y[b],n instanceof THREE.SpotLight&&n.castShadow){T=
--1;P.shadowMap[v]||(P.shadowMap[v]=new THREE.WebGLRenderTarget(P.shadowMapWidth,P.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));ta[v]||(ta[v]=new THREE.Matrix4);u=P.shadowMap[v];x=ta[v];ua.position.copy(n.position);ua.lookAt(n.target.position);ua.update(void 0,!0);a.update(void 0,!1,ua);x.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);x.multiplySelf(ua.projectionMatrix);x.multiplySelf(ua.matrixWorldInverse);ua.matrixWorldInverse.flattenToArray(Ea);
-ua.projectionMatrix.flattenToArray(Da);sa.multiply(ua.projectionMatrix,ua.matrixWorldInverse);t(sa);W(u);o.clearColor(1,1,1,1);P.clear();o.clearColor(G.r,G.g,G.b,da);x=a.__webglObjects.length;n=a.__webglObjectsImmediate.length;for(u=0;u<x;u++)w=a.__webglObjects[u],F=w.object,F.visible&&F.castShadow?!(F instanceof THREE.Mesh)||!F.frustumCulled||p(F)?(F.matrixWorld.flattenToArray(F._objectMatrixArray),C(F,ua,!1),w.render=!0):w.render=!1:w.render=!1;l(!0);H(THREE.NormalBlending);for(u=0;u<x;u++)if(w=
-a.__webglObjects[u],w.render)F=w.object,buffer=w.buffer,f(F),w=F.customDepthMaterial?F.customDepthMaterial:F.geometry.morphTargets.length?Ba:Ga,k(ua,y,null,w,buffer,F);for(u=0;u<n;u++)w=a.__webglObjectsImmediate[u],F=w.object,F.visible&&F.castShadow&&(F.matrixAutoUpdate&&F.matrixWorld.flattenToArray(F._objectMatrixArray),J=-1,C(F,ua,!1),f(F),program=e(ua,y,null,Ga,F),F.immediateRenderCallback?F.immediateRenderCallback(program,o,ka):F.render(function(a){h(a,program,Ga.shading)}));v++}}function y(a,
-b){var c,e,f;c=X.attributes;var h=X.uniforms,k=ma/oa,l,n=[],v=oa*0.5,u=ma*0.5,p=!0;o.useProgram(X.program);Q=X.program;J=ja=qa=-1;Ia||(o.enableVertexAttribArray(X.attributes.position),o.enableVertexAttribArray(X.attributes.uv),Ia=!0);o.disable(o.CULL_FACE);o.enable(o.BLEND);o.depthMask(!0);o.bindBuffer(o.ARRAY_BUFFER,X.vertexBuffer);o.vertexAttribPointer(c.position,2,o.FLOAT,!1,16,0);o.vertexAttribPointer(c.uv,2,o.FLOAT,!1,16,8);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,X.elementBuffer);o.uniformMatrix4fv(h.projectionMatrix,
-!1,Da);o.activeTexture(o.TEXTURE0);o.uniform1i(h.map,0);c=0;for(e=a.__webglSprites.length;c<e;c++)if(f=a.__webglSprites[c],f.visible&&f.opacity!==0)f.useScreenCoordinates?f.z=-f.position.z:(f._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray),f.z=-f._modelViewMatrix.n34);a.__webglSprites.sort(z);c=0;for(e=a.__webglSprites.length;c<e;c++)f=a.__webglSprites[c],f.visible&&f.opacity!==0&&f.map&&f.map.image&&f.map.image.width&&(f.useScreenCoordinates?(o.uniform1i(h.useScreenCoordinates,
-1),o.uniform3f(h.screenPosition,(f.position.x-v)/v,(u-f.position.y)/u,Math.max(0,Math.min(1,f.position.z)))):(o.uniform1i(h.useScreenCoordinates,0),o.uniform1i(h.affectedByDistance,f.affectedByDistance?1:0),o.uniformMatrix4fv(h.modelViewMatrix,!1,f._modelViewMatrixArray)),l=f.map.image.width/(f.scaleByViewport?ma:1),n[0]=l*k*f.scale.x,n[1]=l*f.scale.y,o.uniform2f(h.uvScale,f.uvScale.x,f.uvScale.y),o.uniform2f(h.uvOffset,f.uvOffset.x,f.uvOffset.y),o.uniform2f(h.alignment,f.alignment.x,f.alignment.y),
-o.uniform1f(h.opacity,f.opacity),o.uniform3f(h.color,f.color.r,f.color.g,f.color.b),o.uniform1f(h.rotation,f.rotation),o.uniform2fv(h.scale,n),f.mergeWith3D&&!p?(o.enable(o.DEPTH_TEST),p=!0):!f.mergeWith3D&&p&&(o.disable(o.DEPTH_TEST),p=!1),H(f.blending),V(f.map,0),o.drawElements(o.TRIANGLES,6,o.UNSIGNED_SHORT,0));o.enable(o.CULL_FACE);o.enable(o.DEPTH_TEST);o.depthMask(la)}function C(a,b,c){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(a._modelViewMatrix).transposeIntoArray(a._normalMatrixArray)}
-function A(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function B(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function D(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function K(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function H(a){if(a!==qa){switch(a){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,
-o.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.SRC_COLOR);break;default:o.blendEquationSeparate(o.FUNC_ADD,o.FUNC_ADD),o.blendFuncSeparate(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA)}qa=a}}function M(a,b,c){(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(o.texParameteri(a,o.TEXTURE_WRAP_S,Y(b.wrapS)),o.texParameteri(a,o.TEXTURE_WRAP_T,Y(b.wrapT)),o.texParameteri(a,o.TEXTURE_MAG_FILTER,Y(b.magFilter)),o.texParameteri(a,
-o.TEXTURE_MIN_FILTER,Y(b.minFilter)),o.generateMipmap(a)):(o.texParameteri(a,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(a,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(a,o.TEXTURE_MAG_FILTER,$(b.magFilter)),o.texParameteri(a,o.TEXTURE_MIN_FILTER,$(b.minFilter)))}function V(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=o.createTexture(),P.info.memory.textures++;o.activeTexture(o.TEXTURE0+b);o.bindTexture(o.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?
-o.texImage2D(o.TEXTURE_2D,0,Y(a.format),a.image.width,a.image.height,0,Y(a.format),o.UNSIGNED_BYTE,a.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,a.image);M(o.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+b),o.bindTexture(o.TEXTURE_2D,a.__webglTexture)}function L(a,b){o.bindRenderbuffer(o.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_COMPONENT16,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,
-o.DEPTH_ATTACHMENT,o.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,a)):o.renderbufferStorage(o.RENDERBUFFER,o.RGBA4,b.width,b.height)}function W(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=o.createTexture();
-if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];o.bindTexture(o.TEXTURE_CUBE_MAP,a.__webglTexture);M(o.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=o.createFramebuffer();a.__webglRenderbuffer[c]=o.createRenderbuffer();o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,Y(a.format),a.width,a.height,0,Y(a.format),Y(a.type),null);var e=a,f=o.TEXTURE_CUBE_MAP_POSITIVE_X+c;o.bindFramebuffer(o.FRAMEBUFFER,a.__webglFramebuffer[c]);o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,
-f,e.__webglTexture,0);L(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=o.createFramebuffer(),a.__webglRenderbuffer=o.createRenderbuffer(),o.bindTexture(o.TEXTURE_2D,a.__webglTexture),M(o.TEXTURE_2D,a,a),o.texImage2D(o.TEXTURE_2D,0,Y(a.format),a.width,a.height,0,Y(a.format),Y(a.type),null),c=o.TEXTURE_2D,o.bindFramebuffer(o.FRAMEBUFFER,a.__webglFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,c,a.__webglTexture,0),o.bindRenderbuffer(o.RENDERBUFFER,a.__webglRenderbuffer),
-L(a.__webglRenderbuffer,a);b?o.bindTexture(o.TEXTURE_CUBE_MAP,null):o.bindTexture(o.TEXTURE_2D,null);o.bindRenderbuffer(o.RENDERBUFFER,null);o.bindFramebuffer(o.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=e=0):(b=null,c=oa,a=ma,e=ga,f=ha);b!==aa&&(o.bindFramebuffer(o.FRAMEBUFFER,b),o.viewport(e,f,c,a),aa=b)}function N(a){a instanceof THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,a.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP),
-o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,a.__webglTexture),o.generateMipmap(o.TEXTURE_2D),o.bindTexture(o.TEXTURE_2D,null))}function O(a,b){var c;a==="fragment"?c=o.createShader(o.FRAGMENT_SHADER):a==="vertex"&&(c=o.createShader(o.VERTEX_SHADER));o.shaderSource(c,b);o.compileShader(c);if(!o.getShaderParameter(c,o.COMPILE_STATUS))return console.error(o.getShaderInfoLog(c)),console.error(b),null;return c}function $(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return o.NEAREST;
-default:return o.LINEAR}}function Y(a){switch(a){case THREE.RepeatWrapping:return o.REPEAT;case THREE.ClampToEdgeWrapping:return o.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return o.MIRRORED_REPEAT;case THREE.NearestFilter:return o.NEAREST;case THREE.NearestMipMapNearestFilter:return o.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return o.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return o.LINEAR;case THREE.LinearMipMapNearestFilter:return o.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return o.LINEAR_MIPMAP_LINEAR;
-case THREE.ByteType:return o.BYTE;case THREE.UnsignedByteType:return o.UNSIGNED_BYTE;case THREE.ShortType:return o.SHORT;case THREE.UnsignedShortType:return o.UNSIGNED_SHORT;case THREE.IntType:return o.INT;case THREE.UnsignedShortType:return o.UNSIGNED_INT;case THREE.FloatType:return o.FLOAT;case THREE.AlphaFormat:return o.ALPHA;case THREE.RGBFormat:return o.RGB;case THREE.RGBAFormat:return o.RGBA;case THREE.LuminanceFormat:return o.LUMINANCE;case THREE.LuminanceAlphaFormat:return o.LUMINANCE_ALPHA}return 0}
-var P=this,o,U=[],Q=null,aa=null,T=-1,J=null,ra=0,pa=null,na=null,qa=null,ja=null,la=null,ea=null,ca=null,Z=null,ga=0,ha=0,oa=0,ma=0,ka=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],sa=new THREE.Matrix4,Da=new Float32Array(16),Ea=new Float32Array(16),Ca=new THREE.Vector4,Fa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},za=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
-F=a.stencil!==void 0?a.stencil:!0,fa=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,ia=a.antialias!==void 0?a.antialias:!1,G=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),da=a.clearAlpha!==void 0?a.clearAlpha:0,va=a.maxLights!==void 0?a.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=za;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;var ua,ta=[],a=THREE.ShaderLib.depthRGBA,wa=THREE.UniformsUtils.clone(a.uniforms),Ga=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,
-vertexShader:a.vertexShader,uniforms:wa}),Ba=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:wa,morphTargets:!0});Ga._shadowPass=!0;Ba._shadowPass=!0;try{if(!(o=za.getContext("experimental-webgl",{antialias:ia,stencil:F,preserveDrawingBuffer:fa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+o.getParameter(o.VERSION)+" | "+o.getParameter(o.VENDOR)+" | "+o.getParameter(o.RENDERER)+" | "+o.getParameter(o.SHADING_LANGUAGE_VERSION))}catch(Ka){console.error(Ka)}o.clearColor(0,
-0,0,1);o.clearDepth(1);o.clearStencil(0);o.enable(o.DEPTH_TEST);o.depthFunc(o.LEQUAL);o.frontFace(o.CCW);o.cullFace(o.BACK);o.enable(o.CULL_FACE);o.enable(o.BLEND);o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA);o.clearColor(G.r,G.g,G.b,da);this.context=o;var ya=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,X={};X.vertices=new Float32Array(16);X.faces=new Uint16Array(6);F=0;X.vertices[F++]=-1;X.vertices[F++]=-1;X.vertices[F++]=0;X.vertices[F++]=1;X.vertices[F++]=1;
-X.vertices[F++]=-1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=0;X.vertices[F++]=-1;X.vertices[F++]=1;X.vertices[F++]=0;F=X.vertices[F++]=0;X.faces[F++]=0;X.faces[F++]=1;X.faces[F++]=2;X.faces[F++]=0;X.faces[F++]=2;X.faces[F++]=3;X.vertexBuffer=o.createBuffer();X.elementBuffer=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,X.vertexBuffer);o.bufferData(o.ARRAY_BUFFER,X.vertices,o.STATIC_DRAW);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,X.elementBuffer);
-o.bufferData(o.ELEMENT_ARRAY_BUFFER,X.faces,o.STATIC_DRAW);X.program=o.createProgram();o.attachShader(X.program,O("fragment",THREE.ShaderLib.sprite.fragmentShader));o.attachShader(X.program,O("vertex",THREE.ShaderLib.sprite.vertexShader));o.linkProgram(X.program);X.attributes={};X.uniforms={};X.attributes.position=o.getAttribLocation(X.program,"position");X.attributes.uv=o.getAttribLocation(X.program,"uv");X.uniforms.uvOffset=o.getUniformLocation(X.program,"uvOffset");X.uniforms.uvScale=o.getUniformLocation(X.program,
-"uvScale");X.uniforms.rotation=o.getUniformLocation(X.program,"rotation");X.uniforms.scale=o.getUniformLocation(X.program,"scale");X.uniforms.alignment=o.getUniformLocation(X.program,"alignment");X.uniforms.color=o.getUniformLocation(X.program,"color");X.uniforms.map=o.getUniformLocation(X.program,"map");X.uniforms.opacity=o.getUniformLocation(X.program,"opacity");X.uniforms.useScreenCoordinates=o.getUniformLocation(X.program,"useScreenCoordinates");X.uniforms.affectedByDistance=o.getUniformLocation(X.program,
-"affectedByDistance");X.uniforms.screenPosition=o.getUniformLocation(X.program,"screenPosition");X.uniforms.modelViewMatrix=o.getUniformLocation(X.program,"modelViewMatrix");X.uniforms.projectionMatrix=o.getUniformLocation(X.program,"projectionMatrix");var Ia=!1;this.setSize=function(a,b){za.width=a;za.height=b;this.setViewport(0,0,za.width,za.height)};this.setViewport=function(a,b,c,e){ga=a;ha=b;oa=c;ma=e;o.viewport(ga,ha,oa,ma)};this.setScissor=function(a,b,c,e){o.scissor(a,b,c,e)};this.enableScissorTest=
-function(a){a?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)};this.setClearColorHex=function(a,b){G.setHex(a);da=b;o.clearColor(G.r,G.g,G.b,da)};this.setClearColor=function(a,b){G.copy(a);da=b;o.clearColor(G.r,G.g,G.b,da)};this.getClearColor=function(){return G};this.getClearAlpha=function(){return da};this.clear=function(a,b,c){var e=0;if(a===void 0||a)e|=o.COLOR_BUFFER_BIT;if(b===void 0||b)e|=o.DEPTH_BUFFER_BIT;if(c===void 0||c)e|=o.STENCIL_BUFFER_BIT;o.clear(e)};this.getContext=function(){return o};
-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(g in a.geometry.geometryGroups){var b=a.geometry.geometryGroups[g];o.deleteBuffer(b.__webglVertexBuffer);o.deleteBuffer(b.__webglNormalBuffer);o.deleteBuffer(b.__webglTangentBuffer);o.deleteBuffer(b.__webglColorBuffer);o.deleteBuffer(b.__webglUVBuffer);o.deleteBuffer(b.__webglUV2Buffer);o.deleteBuffer(b.__webglSkinVertexABuffer);
-o.deleteBuffer(b.__webglSkinVertexBBuffer);o.deleteBuffer(b.__webglSkinIndicesBuffer);o.deleteBuffer(b.__webglSkinWeightsBuffer);o.deleteBuffer(b.__webglFaceBuffer);o.deleteBuffer(b.__webglLineBuffer);if(b.numMorphTargets)for(var c=0,e=b.numMorphTargets;c<e;c++)o.deleteBuffer(b.__webglMorphTargetsBuffers[c]);P.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,o.deleteBuffer(a.__webglVertexBuffer),o.deleteBuffer(a.__webglColorBuffer),P.info.memory.geometries--;else if(a instanceof
-THREE.Line)a=a.geometry,o.deleteBuffer(a.__webglVertexBuffer),o.deleteBuffer(a.__webglColorBuffer),P.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,o.deleteBuffer(a.__webglVertexBuffer),o.deleteBuffer(a.__webglColorBuffer),P.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,o.deleteTexture(a.__webglTexture),P.info.memory.textures--};this.initMaterial=function(a,b,c,e){var f,h,k,l;a instanceof THREE.MeshDepthMaterial?l="depth":
-a instanceof THREE.MeshNormalMaterial?l="normal":a instanceof THREE.MeshBasicMaterial?l="basic":a instanceof THREE.MeshLambertMaterial?l="lambert":a instanceof THREE.MeshPhongMaterial?l="phong":a instanceof THREE.LineBasicMaterial?l="basic":a instanceof THREE.ParticleBasicMaterial&&(l="particle_basic");if(l){var n=THREE.ShaderLib[l];a.uniforms=THREE.UniformsUtils.clone(n.uniforms);a.vertexShader=n.vertexShader;a.fragmentShader=n.fragmentShader}var v,p,u;v=u=n=0;for(p=b.length;v<p;v++)k=b[v],k instanceof
-THREE.SpotLight&&u++,k instanceof THREE.DirectionalLight&&u++,k instanceof THREE.PointLight&&n++;n+u<=va?v=u:(v=Math.ceil(va*u/(n+u)),n=va-v);k={directional:v,point:n};n=u=0;for(v=b.length;n<v;n++)p=b[n],p instanceof THREE.SpotLight&&p.castShadow&&u++;var t=50;if(e!==void 0&&e instanceof THREE.SkinnedMesh)t=e.bones.length;var x;a:{v=a.fragmentShader;p=a.vertexShader;var n=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:k.directional,maxPointLights:k.point,maxBones:t,shadowMapEnabled:this.shadowMapEnabled&&e.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:u,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel},F,e=[];l?e.push(l):(e.push(v),e.push(p));for(F in c)e.push(F),e.push(c[F]);l=e.join();F=0;
-for(e=U.length;F<e;F++)if(U[F].code===l){x=U[F].program;break a}F=o.createProgram();e=[ya?"#define VERTEX_TEXTURES":"",P.gammaInput?"#define GAMMA_INPUT":"",P.gammaOutput?"#define GAMMA_OUTPUT":"",P.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.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");
+c.materialIndex,c>=0)b=b.geometry.materials[c],b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}else if(b=e)b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function z(a,b){return b.z-a.z}function x(a){var b,c,n,v=0,u,x,w,F,y=a.lights;va||(va=new THREE.PerspectiveCamera(P.shadowCameraFov,P.shadowMapWidth/P.shadowMapHeight,P.shadowCameraNear,P.shadowCameraFar));b=0;for(c=y.length;b<c;b++)if(n=y[b],n instanceof THREE.SpotLight&&n.castShadow){T=
+-1;P.shadowMap[v]||(P.shadowMap[v]=new THREE.WebGLRenderTarget(P.shadowMapWidth,P.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));ta[v]||(ta[v]=new THREE.Matrix4);u=P.shadowMap[v];x=ta[v];va.position.copy(n.position);va.lookAt(n.target.position);va.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),a.add(va));a.updateMatrixWorld();va.matrixWorldInverse.getInverse(va.matrixWorld);x.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,
+0,0,1);x.multiplySelf(va.projectionMatrix);x.multiplySelf(va.matrixWorldInverse);va.matrixWorldInverse.flattenToArray(Ea);va.projectionMatrix.flattenToArray(Da);sa.multiply(va.projectionMatrix,va.matrixWorldInverse);t(sa);W(u);o.clearColor(1,1,1,1);P.clear();o.clearColor(G.r,G.g,G.b,da);x=a.__webglObjects.length;n=a.__webglObjectsImmediate.length;for(u=0;u<x;u++)w=a.__webglObjects[u],F=w.object,F.visible&&F.castShadow?!(F instanceof THREE.Mesh)||!F.frustumCulled||p(F)?(F.matrixWorld.flattenToArray(F._objectMatrixArray),
+C(F,va,!1),w.render=!0):w.render=!1:w.render=!1;l(!0);H(THREE.NormalBlending);for(u=0;u<x;u++)if(w=a.__webglObjects[u],w.render)F=w.object,buffer=w.buffer,f(F),w=F.customDepthMaterial?F.customDepthMaterial:F.geometry.morphTargets.length?Ba:Ga,k(va,y,null,w,buffer,F);for(u=0;u<n;u++)w=a.__webglObjectsImmediate[u],F=w.object,F.visible&&F.castShadow&&(F.matrixAutoUpdate&&F.matrixWorld.flattenToArray(F._objectMatrixArray),J=-1,C(F,va,!1),f(F),program=e(va,y,null,Ga,F),F.immediateRenderCallback?F.immediateRenderCallback(program,
+o,ka):F.render(function(a){h(a,program,Ga.shading)}));v++}}function y(a,b){var c,e,f;c=X.attributes;var h=X.uniforms,k=ma/oa,l,n=[],v=oa*0.5,u=ma*0.5,p=!0;o.useProgram(X.program);Q=X.program;J=ja=qa=-1;Ia||(o.enableVertexAttribArray(X.attributes.position),o.enableVertexAttribArray(X.attributes.uv),Ia=!0);o.disable(o.CULL_FACE);o.enable(o.BLEND);o.depthMask(!0);o.bindBuffer(o.ARRAY_BUFFER,X.vertexBuffer);o.vertexAttribPointer(c.position,2,o.FLOAT,!1,16,0);o.vertexAttribPointer(c.uv,2,o.FLOAT,!1,16,
+8);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,X.elementBuffer);o.uniformMatrix4fv(h.projectionMatrix,!1,Da);o.activeTexture(o.TEXTURE0);o.uniform1i(h.map,0);c=0;for(e=a.__webglSprites.length;c<e;c++)if(f=a.__webglSprites[c],f.visible&&f.opacity!==0)f.useScreenCoordinates?f.z=-f.position.z:(f._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray),f.z=-f._modelViewMatrix.n34);a.__webglSprites.sort(z);c=0;for(e=a.__webglSprites.length;c<e;c++)f=a.__webglSprites[c],f.visible&&
+f.opacity!==0&&f.map&&f.map.image&&f.map.image.width&&(f.useScreenCoordinates?(o.uniform1i(h.useScreenCoordinates,1),o.uniform3f(h.screenPosition,(f.position.x-v)/v,(u-f.position.y)/u,Math.max(0,Math.min(1,f.position.z)))):(o.uniform1i(h.useScreenCoordinates,0),o.uniform1i(h.affectedByDistance,f.affectedByDistance?1:0),o.uniformMatrix4fv(h.modelViewMatrix,!1,f._modelViewMatrixArray)),l=f.map.image.width/(f.scaleByViewport?ma:1),n[0]=l*k*f.scale.x,n[1]=l*f.scale.y,o.uniform2f(h.uvScale,f.uvScale.x,
+f.uvScale.y),o.uniform2f(h.uvOffset,f.uvOffset.x,f.uvOffset.y),o.uniform2f(h.alignment,f.alignment.x,f.alignment.y),o.uniform1f(h.opacity,f.opacity),o.uniform3f(h.color,f.color.r,f.color.g,f.color.b),o.uniform1f(h.rotation,f.rotation),o.uniform2fv(h.scale,n),f.mergeWith3D&&!p?(o.enable(o.DEPTH_TEST),p=!0):!f.mergeWith3D&&p&&(o.disable(o.DEPTH_TEST),p=!1),H(f.blending),V(f.map,0),o.drawElements(o.TRIANGLES,6,o.UNSIGNED_SHORT,0));o.enable(o.CULL_FACE);o.enable(o.DEPTH_TEST);o.depthMask(la)}function C(a,
+b,c){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(a._modelViewMatrix).transposeIntoArray(a._normalMatrixArray)}function A(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function B(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function D(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function K(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}
+function H(a){if(a!==qa){switch(a){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.SRC_COLOR);break;default:o.blendEquationSeparate(o.FUNC_ADD,o.FUNC_ADD),o.blendFuncSeparate(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA)}qa=a}}function M(a,b,c){(c.width&c.width-
+1)===0&&(c.height&c.height-1)===0?(o.texParameteri(a,o.TEXTURE_WRAP_S,Y(b.wrapS)),o.texParameteri(a,o.TEXTURE_WRAP_T,Y(b.wrapT)),o.texParameteri(a,o.TEXTURE_MAG_FILTER,Y(b.magFilter)),o.texParameteri(a,o.TEXTURE_MIN_FILTER,Y(b.minFilter)),o.generateMipmap(a)):(o.texParameteri(a,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(a,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(a,o.TEXTURE_MAG_FILTER,Z(b.magFilter)),o.texParameteri(a,o.TEXTURE_MIN_FILTER,Z(b.minFilter)))}function V(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=
+!0,a.__webglTexture=o.createTexture(),P.info.memory.textures++;o.activeTexture(o.TEXTURE0+b);o.bindTexture(o.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?o.texImage2D(o.TEXTURE_2D,0,Y(a.format),a.image.width,a.image.height,0,Y(a.format),o.UNSIGNED_BYTE,a.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,a.image);M(o.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+b),o.bindTexture(o.TEXTURE_2D,a.__webglTexture)}function L(a,b){o.bindRenderbuffer(o.RENDERBUFFER,
+a);b.depthBuffer&&!b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_COMPONENT16,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,a)):o.renderbufferStorage(o.RENDERBUFFER,o.RGBA4,b.width,b.height)}function W(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=o.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];o.bindTexture(o.TEXTURE_CUBE_MAP,a.__webglTexture);M(o.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=o.createFramebuffer();a.__webglRenderbuffer[c]=o.createRenderbuffer();o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,Y(a.format),a.width,a.height,0,Y(a.format),Y(a.type),
+null);var e=a,f=o.TEXTURE_CUBE_MAP_POSITIVE_X+c;o.bindFramebuffer(o.FRAMEBUFFER,a.__webglFramebuffer[c]);o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,f,e.__webglTexture,0);L(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=o.createFramebuffer(),a.__webglRenderbuffer=o.createRenderbuffer(),o.bindTexture(o.TEXTURE_2D,a.__webglTexture),M(o.TEXTURE_2D,a,a),o.texImage2D(o.TEXTURE_2D,0,Y(a.format),a.width,a.height,0,Y(a.format),Y(a.type),null),c=o.TEXTURE_2D,o.bindFramebuffer(o.FRAMEBUFFER,
+a.__webglFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,c,a.__webglTexture,0),o.bindRenderbuffer(o.RENDERBUFFER,a.__webglRenderbuffer),L(a.__webglRenderbuffer,a);b?o.bindTexture(o.TEXTURE_CUBE_MAP,null):o.bindTexture(o.TEXTURE_2D,null);o.bindRenderbuffer(o.RENDERBUFFER,null);o.bindFramebuffer(o.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=e=0):(b=null,c=oa,a=ma,e=ga,f=ha);b!==aa&&(o.bindFramebuffer(o.FRAMEBUFFER,
+b),o.viewport(e,f,c,a),aa=b)}function N(a){a instanceof THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,a.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP),o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,a.__webglTexture),o.generateMipmap(o.TEXTURE_2D),o.bindTexture(o.TEXTURE_2D,null))}function O(a,b){var c;a==="fragment"?c=o.createShader(o.FRAGMENT_SHADER):a==="vertex"&&(c=o.createShader(o.VERTEX_SHADER));o.shaderSource(c,b);o.compileShader(c);if(!o.getShaderParameter(c,
+o.COMPILE_STATUS))return console.error(o.getShaderInfoLog(c)),console.error(b),null;return c}function Z(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return o.NEAREST;default:return o.LINEAR}}function Y(a){switch(a){case THREE.RepeatWrapping:return o.REPEAT;case THREE.ClampToEdgeWrapping:return o.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return o.MIRRORED_REPEAT;case THREE.NearestFilter:return o.NEAREST;case THREE.NearestMipMapNearestFilter:return o.NEAREST_MIPMAP_NEAREST;
+case THREE.NearestMipMapLinearFilter:return o.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return o.LINEAR;case THREE.LinearMipMapNearestFilter:return o.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return o.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return o.BYTE;case THREE.UnsignedByteType:return o.UNSIGNED_BYTE;case THREE.ShortType:return o.SHORT;case THREE.UnsignedShortType:return o.UNSIGNED_SHORT;case THREE.IntType:return o.INT;case THREE.UnsignedShortType:return o.UNSIGNED_INT;case THREE.FloatType:return o.FLOAT;
+case THREE.AlphaFormat:return o.ALPHA;case THREE.RGBFormat:return o.RGB;case THREE.RGBAFormat:return o.RGBA;case THREE.LuminanceFormat:return o.LUMINANCE;case THREE.LuminanceAlphaFormat:return o.LUMINANCE_ALPHA}return 0}var P=this,o,U=[],Q=null,aa=null,T=-1,J=null,ra=0,pa=null,na=null,qa=null,ja=null,la=null,ea=null,ca=null,$=null,ga=0,ha=0,oa=0,ma=0,ka=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],sa=new THREE.Matrix4,Da=new Float32Array(16),
+Ea=new Float32Array(16),Ca=new THREE.Vector4,Fa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},za=a.canvas!==void 0?a.canvas:document.createElement("canvas"),F=a.stencil!==void 0?a.stencil:!0,fa=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,ia=a.antialias!==void 0?a.antialias:!1,G=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),da=a.clearAlpha!==void 0?a.clearAlpha:0,ua=a.maxLights!==
+void 0?a.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=za;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;var va,ta=[],a=THREE.ShaderLib.depthRGBA,wa=THREE.UniformsUtils.clone(a.uniforms),Ga=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:wa}),Ba=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:wa,morphTargets:!0});Ga._shadowPass=!0;Ba._shadowPass=!0;try{if(!(o=za.getContext("experimental-webgl",{antialias:ia,stencil:F,
+preserveDrawingBuffer:fa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+o.getParameter(o.VERSION)+" | "+o.getParameter(o.VENDOR)+" | "+o.getParameter(o.RENDERER)+" | "+o.getParameter(o.SHADING_LANGUAGE_VERSION))}catch(Ka){console.error(Ka)}o.clearColor(0,0,0,1);o.clearDepth(1);o.clearStencil(0);o.enable(o.DEPTH_TEST);o.depthFunc(o.LEQUAL);o.frontFace(o.CCW);o.cullFace(o.BACK);o.enable(o.CULL_FACE);o.enable(o.BLEND);o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,
+o.ONE_MINUS_SRC_ALPHA);o.clearColor(G.r,G.g,G.b,da);this.context=o;var ya=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,X={};X.vertices=new Float32Array(16);X.faces=new Uint16Array(6);F=0;X.vertices[F++]=-1;X.vertices[F++]=-1;X.vertices[F++]=0;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=-1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=0;X.vertices[F++]=-1;X.vertices[F++]=1;X.vertices[F++]=0;F=X.vertices[F++]=0;X.faces[F++]=0;
+X.faces[F++]=1;X.faces[F++]=2;X.faces[F++]=0;X.faces[F++]=2;X.faces[F++]=3;X.vertexBuffer=o.createBuffer();X.elementBuffer=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,X.vertexBuffer);o.bufferData(o.ARRAY_BUFFER,X.vertices,o.STATIC_DRAW);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,X.elementBuffer);o.bufferData(o.ELEMENT_ARRAY_BUFFER,X.faces,o.STATIC_DRAW);X.program=o.createProgram();o.attachShader(X.program,O("fragment",THREE.ShaderLib.sprite.fragmentShader));o.attachShader(X.program,O("vertex",THREE.ShaderLib.sprite.vertexShader));
+o.linkProgram(X.program);X.attributes={};X.uniforms={};X.attributes.position=o.getAttribLocation(X.program,"position");X.attributes.uv=o.getAttribLocation(X.program,"uv");X.uniforms.uvOffset=o.getUniformLocation(X.program,"uvOffset");X.uniforms.uvScale=o.getUniformLocation(X.program,"uvScale");X.uniforms.rotation=o.getUniformLocation(X.program,"rotation");X.uniforms.scale=o.getUniformLocation(X.program,"scale");X.uniforms.alignment=o.getUniformLocation(X.program,"alignment");X.uniforms.color=o.getUniformLocation(X.program,
+"color");X.uniforms.map=o.getUniformLocation(X.program,"map");X.uniforms.opacity=o.getUniformLocation(X.program,"opacity");X.uniforms.useScreenCoordinates=o.getUniformLocation(X.program,"useScreenCoordinates");X.uniforms.affectedByDistance=o.getUniformLocation(X.program,"affectedByDistance");X.uniforms.screenPosition=o.getUniformLocation(X.program,"screenPosition");X.uniforms.modelViewMatrix=o.getUniformLocation(X.program,"modelViewMatrix");X.uniforms.projectionMatrix=o.getUniformLocation(X.program,
+"projectionMatrix");var Ia=!1;this.setSize=function(a,b){za.width=a;za.height=b;this.setViewport(0,0,za.width,za.height)};this.setViewport=function(a,b,c,e){ga=a;ha=b;oa=c;ma=e;o.viewport(ga,ha,oa,ma)};this.setScissor=function(a,b,c,e){o.scissor(a,b,c,e)};this.enableScissorTest=function(a){a?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)};this.setClearColorHex=function(a,b){G.setHex(a);da=b;o.clearColor(G.r,G.g,G.b,da)};this.setClearColor=function(a,b){G.copy(a);da=b;o.clearColor(G.r,G.g,G.b,
+da)};this.getClearColor=function(){return G};this.getClearAlpha=function(){return da};this.clear=function(a,b,c){var e=0;if(a===void 0||a)e|=o.COLOR_BUFFER_BIT;if(b===void 0||b)e|=o.DEPTH_BUFFER_BIT;if(c===void 0||c)e|=o.STENCIL_BUFFER_BIT;o.clear(e)};this.getContext=function(){return o};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(g in a.geometry.geometryGroups){var b=
+a.geometry.geometryGroups[g];o.deleteBuffer(b.__webglVertexBuffer);o.deleteBuffer(b.__webglNormalBuffer);o.deleteBuffer(b.__webglTangentBuffer);o.deleteBuffer(b.__webglColorBuffer);o.deleteBuffer(b.__webglUVBuffer);o.deleteBuffer(b.__webglUV2Buffer);o.deleteBuffer(b.__webglSkinVertexABuffer);o.deleteBuffer(b.__webglSkinVertexBBuffer);o.deleteBuffer(b.__webglSkinIndicesBuffer);o.deleteBuffer(b.__webglSkinWeightsBuffer);o.deleteBuffer(b.__webglFaceBuffer);o.deleteBuffer(b.__webglLineBuffer);if(b.numMorphTargets)for(var c=
+0,e=b.numMorphTargets;c<e;c++)o.deleteBuffer(b.__webglMorphTargetsBuffers[c]);P.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,o.deleteBuffer(a.__webglVertexBuffer),o.deleteBuffer(a.__webglColorBuffer),P.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,o.deleteBuffer(a.__webglVertexBuffer),o.deleteBuffer(a.__webglColorBuffer),P.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,o.deleteBuffer(a.__webglVertexBuffer),o.deleteBuffer(a.__webglColorBuffer),
+P.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,o.deleteTexture(a.__webglTexture),P.info.memory.textures--};this.initMaterial=function(a,b,c,e){var f,h,k,l;a instanceof THREE.MeshDepthMaterial?l="depth":a instanceof THREE.MeshNormalMaterial?l="normal":a instanceof THREE.MeshBasicMaterial?l="basic":a instanceof THREE.MeshLambertMaterial?l="lambert":a instanceof THREE.MeshPhongMaterial?l="phong":a instanceof THREE.LineBasicMaterial?l="basic":a instanceof
+THREE.ParticleBasicMaterial&&(l="particle_basic");if(l){var n=THREE.ShaderLib[l];a.uniforms=THREE.UniformsUtils.clone(n.uniforms);a.vertexShader=n.vertexShader;a.fragmentShader=n.fragmentShader}var v,p,u;v=u=n=0;for(p=b.length;v<p;v++)k=b[v],k instanceof THREE.SpotLight&&u++,k instanceof THREE.DirectionalLight&&u++,k instanceof THREE.PointLight&&n++;n+u<=ua?v=u:(v=Math.ceil(ua*u/(n+u)),n=ua-v);k={directional:v,point:n};n=u=0;for(v=b.length;n<v;n++)p=b[n],p instanceof THREE.SpotLight&&p.castShadow&&
+u++;var t=50;if(e!==void 0&&e instanceof THREE.SkinnedMesh)t=e.bones.length;var x;a:{v=a.fragmentShader;p=a.vertexShader;var n=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:k.directional,maxPointLights:k.point,maxBones:t,shadowMapEnabled:this.shadowMapEnabled&&e.receiveShadow,shadowMapSoft:this.shadowMapSoft,
+shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:u,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel},F,e=[];l?e.push(l):(e.push(v),e.push(p));for(F in c)e.push(F),e.push(c[F]);l=e.join();F=0;for(e=U.length;F<e;F++)if(U[F].code===l){x=U[F].program;break a}F=o.createProgram();e=[ya?"#define VERTEX_TEXTURES":"",P.gammaInput?"#define GAMMA_INPUT":"",P.gammaOutput?"#define GAMMA_OUTPUT":"",P.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.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");
 k=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",P.gammaInput?"#define GAMMA_INPUT":"",P.gammaOutput?"#define GAMMA_OUTPUT":"",P.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");o.attachShader(F,O("fragment",k+v));o.attachShader(F,
 O("vertex",e+p));o.linkProgram(F);o.getProgramParameter(F,o.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+o.getProgramParameter(F,o.VALIDATE_STATUS)+", gl error ["+o.getError()+"]");F.uniforms={};F.attributes={};var w,e=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(w in n)e.push(w);w=e;e=0;for(n=w.length;e<n;e++)v=w[e],F.uniforms[v]=o.getUniformLocation(F,
 v);e=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(w=0;w<c.maxMorphTargets;w++)e.push("morphTarget"+w);for(x in b)e.push(x);x=e;w=0;for(b=x.length;w<b;w++)c=x[w],F.attributes[c]=o.getAttribLocation(F,c);F.id=U.length;U.push({program:F,code:l});P.info.memory.programs=U.length;x=F}a.program=x;x=a.program.attributes;x.position>=0&&o.enableVertexAttribArray(x.position);x.color>=0&&o.enableVertexAttribArray(x.color);x.normal>=0&&o.enableVertexAttribArray(x.normal);
 x.tangent>=0&&o.enableVertexAttribArray(x.tangent);a.skinning&&x.skinVertexA>=0&&x.skinVertexB>=0&&x.skinIndex>=0&&x.skinWeight>=0&&(o.enableVertexAttribArray(x.skinVertexA),o.enableVertexAttribArray(x.skinVertexB),o.enableVertexAttribArray(x.skinIndex),o.enableVertexAttribArray(x.skinWeight));if(a.attributes)for(h in a.attributes)x[h]!==void 0&&x[h]>=0&&o.enableVertexAttribArray(x[h]);if(a.morphTargets)for(h=a.numSupportedMorphTargets=0;h<this.maxMorphTargets;h++)w="morphTarget"+h,x[w]>=0&&(o.enableVertexAttribArray(x[w]),
-a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,b,c,e){W(a);this.clear(b,c,e)};this.updateShadowMap=function(a,b){x(a,b)};this.render=function(a,b,c,F){var ia,fa,A,B,D,G,ga,L=a.lights,K=a.fog;T=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&x(a,b);P.info.render.calls=0;P.info.render.vertices=0;P.info.render.faces=0;if(b.matrixAutoUpdate){for(A=b;A.parent;)A=
-A.parent;A.update(void 0,!0)}a.update(void 0,!1,b);b.matrixWorldInverse.flattenToArray(Ea);b.projectionMatrix.flattenToArray(Da);sa.multiply(b.projectionMatrix,b.matrixWorldInverse);t(sa);W(c);(this.autoClear||F)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);A=a.__webglObjects.length;for(F=0;F<A;F++)if(D=a.__webglObjects[F],G=D.object,G.visible)if(!(G instanceof THREE.Mesh)||!G.frustumCulled||p(G)){if(G.matrixWorld.flattenToArray(G._objectMatrixArray),C(G,b,!0),v(D),D.render=
-!0,this.sortObjects)G.renderDepth?D.z=G.renderDepth:(Ca.copy(G.position),sa.multiplyVector3(Ca),D.z=Ca.z)}else D.render=!1;else D.render=!1;this.sortObjects&&a.__webglObjects.sort(z);B=a.__webglObjectsImmediate.length;for(F=0;F<B;F++)D=a.__webglObjectsImmediate[F],G=D.object,G.visible&&(G.matrixAutoUpdate&&G.matrixWorld.flattenToArray(G._objectMatrixArray),C(G,b,!0),w(D));if(a.overrideMaterial){l(a.overrideMaterial.depthTest);H(a.overrideMaterial.blending);for(F=0;F<A;F++)if(D=a.__webglObjects[F],
-D.render)G=D.object,ga=D.buffer,f(G),k(b,L,K,a.overrideMaterial,ga,G);for(F=0;F<B;F++)D=a.__webglObjectsImmediate[F],G=D.object,G.visible&&(J=-1,f(G),ia=e(b,L,K,a.overrideMaterial,G),G.immediateRenderCallback?G.immediateRenderCallback(ia,o,ka):G.render(function(b){h(b,ia,a.overrideMaterial.shading)}))}else{H(THREE.NormalBlending);for(F=A-1;F>=0;F--)if(D=a.__webglObjects[F],D.render&&(G=D.object,ga=D.buffer,fa=D.opaque))f(G),l(fa.depthTest),n(fa.depthWrite),u(fa.polygonOffset,fa.polygonOffsetFactor,
+a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,b,c,e){W(a);this.clear(b,c,e)};this.updateShadowMap=function(a,b){x(a,b)};this.render=function(a,b,c,F){var ia,fa,A,B,D,G,ga,L=a.lights,K=a.fog;T=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&x(a,b);P.info.render.calls=0;P.info.render.vertices=0;P.info.render.faces=0;b.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),
+a.add(b));a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(Ea);b.projectionMatrix.flattenToArray(Da);sa.multiply(b.projectionMatrix,b.matrixWorldInverse);t(sa);W(c);(this.autoClear||F)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);A=a.__webglObjects.length;for(F=0;F<A;F++)if(D=a.__webglObjects[F],G=D.object,G.visible)if(!(G instanceof THREE.Mesh)||!G.frustumCulled||p(G)){if(G.matrixWorld.flattenToArray(G._objectMatrixArray),
+C(G,b,!0),v(D),D.render=!0,this.sortObjects)G.renderDepth?D.z=G.renderDepth:(Ca.copy(G.position),sa.multiplyVector3(Ca),D.z=Ca.z)}else D.render=!1;else D.render=!1;this.sortObjects&&a.__webglObjects.sort(z);B=a.__webglObjectsImmediate.length;for(F=0;F<B;F++)D=a.__webglObjectsImmediate[F],G=D.object,G.visible&&(G.matrixAutoUpdate&&G.matrixWorld.flattenToArray(G._objectMatrixArray),C(G,b,!0),w(D));if(a.overrideMaterial){l(a.overrideMaterial.depthTest);H(a.overrideMaterial.blending);for(F=0;F<A;F++)if(D=
+a.__webglObjects[F],D.render)G=D.object,ga=D.buffer,f(G),k(b,L,K,a.overrideMaterial,ga,G);for(F=0;F<B;F++)D=a.__webglObjectsImmediate[F],G=D.object,G.visible&&(J=-1,f(G),ia=e(b,L,K,a.overrideMaterial,G),G.immediateRenderCallback?G.immediateRenderCallback(ia,o,ka):G.render(function(b){h(b,ia,a.overrideMaterial.shading)}))}else{H(THREE.NormalBlending);for(F=A-1;F>=0;F--)if(D=a.__webglObjects[F],D.render&&(G=D.object,ga=D.buffer,fa=D.opaque))f(G),l(fa.depthTest),n(fa.depthWrite),u(fa.polygonOffset,fa.polygonOffsetFactor,
 fa.polygonOffsetUnits),k(b,L,K,fa,ga,G);for(F=0;F<B;F++)if(D=a.__webglObjectsImmediate[F],G=D.object,G.visible&&(J=-1,fa=D.opaque))f(G),l(fa.depthTest),n(fa.depthWrite),u(fa.polygonOffset,fa.polygonOffsetFactor,fa.polygonOffsetUnits),ia=e(b,L,K,fa,G),G.immediateRenderCallback?G.immediateRenderCallback(ia,o,ka):G.render(function(a){h(a,ia,fa.shading)});for(F=0;F<A;F++)if(D=a.__webglObjects[F],D.render&&(G=D.object,ga=D.buffer,fa=D.transparent))f(G),H(fa.blending),l(fa.depthTest),n(fa.depthWrite),u(fa.polygonOffset,
 fa.polygonOffsetFactor,fa.polygonOffsetUnits),k(b,L,K,fa,ga,G);for(F=0;F<B;F++)if(D=a.__webglObjectsImmediate[F],G=D.object,G.visible&&(J=-1,fa=D.transparent))f(G),H(fa.blending),l(fa.depthTest),n(fa.depthWrite),u(fa.polygonOffset,fa.polygonOffsetFactor,fa.polygonOffsetUnits),ia=e(b,L,K,fa,G),G.immediateRenderCallback?G.immediateRenderCallback(ia,o,ka):G.render(function(a){h(a,ia,fa.shading)})}a.__webglSprites.length&&y(a,b);c&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&
 N(c)};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[];for(;a.__objectsAdded.length;){var e=a.__objectsAdded[0],f=a,h=void 0,k=void 0,l=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){k=e.geometry;
@@ -313,27 +316,27 @@ l.__webglColorBuffer=o.createBuffer(),P.info.memory.geometries++,l=k,n=l.vertice
 attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(n*size),attribute.buffer=o.createBuffer(),attribute.buffer.belongsToAttribute=p,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;l.__webglCustomAttributesList.push(attribute)}}k.__dirtyVertices=!0;k.__dirtyColors=!0}if(!e.__webglActive){if(e instanceof THREE.Mesh)for(h in k=e.geometry,k.geometryGroups)l=k.geometryGroups[h],K(f.__webglObjects,l,e);else e instanceof THREE.Ribbon||e instanceof THREE.Line||
 e instanceof THREE.ParticleSystem?(k=e.geometry,K(f.__webglObjects,k,e)):THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes||e.immediateRenderCallback?f.__webglObjectsImmediate.push({object:e,opaque:null,transparent:null}):e instanceof THREE.Sprite&&f.__webglSprites.push(e);e.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){e=a.__objectsRemoved[0];f=a;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)D(f.__webglObjects,
 e);else if(e instanceof THREE.Sprite){f=f.__webglSprites;h=e;for(k=f.length-1;k>=0;k--)f[k]===h&&f.splice(k,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&D(f.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(f=a.__webglObjects.length;e<f;e++)if(k=a.__webglObjects[e].object,h=k.geometry,l=t=p=void 0,k instanceof THREE.Mesh){n=0;for(v=h.geometryGroupsList.length;n<v;n++)if(p=h.geometryGroupsList[n],l=c(k,p),t=l.attributes&&A(l),h.__dirtyVertices||
-h.__dirtyMorphTargets||h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||t)if(t=o.DYNAMIC_DRAW,F=!h.dynamic,p.__inittedArrays){var fa=w=x=void 0,G=void 0,C=fa=void 0,ga=void 0,L=void 0,va=void 0,N=y=ia=z=u=void 0,J=void 0,H=void 0,ha=void 0,O=void 0,R=G=va=G=L=ga=void 0,da=void 0,I=da=R=ga=void 0,E=void 0,I=da=R=fa=fa=C=da=R=G=I=da=R=E=I=da=R=E=I=da=R=void 0,M=0,Q=0,T=0,W=0,$=0,ua=0,oa=0,X=0,Y=0,S=0,U=0,ma=I=0,ma=void 0,V=p.__vertexArray,wa=p.__uvArray,la=p.__uv2Array,
-aa=p.__normalArray,ka=p.__tangentArray,ea=p.__colorArray,Z=p.__skinVertexAArray,ca=p.__skinVertexBArray,ta=p.__skinIndexArray,ja=p.__skinWeightArray,pa=p.__morphTargetsArrays,sa=p.__webglCustomAttributesList,E=void 0,Ba=p.__faceArray,na=p.__lineArray,Ga=p.__needsSmoothNormals,z=p.__vertexColorType,u=p.__uvType,ia=p.__normalType,qa=k.geometry,Da=qa.__dirtyVertices,Ea=qa.__dirtyElements,ya=qa.__dirtyUvs,Ka=qa.__dirtyNormals,Ca=qa.__dirtyTangents,Fa=qa.__dirtyColors,Ia=qa.__dirtyMorphTargets,za=qa.vertices,
-Ya=p.faces,bb=qa.faces,Za=qa.faceVertexUvs[0],$a=qa.faceVertexUvs[1],Pa=qa.skinVerticesA,Qa=qa.skinVerticesB,Ra=qa.skinIndices,La=qa.skinWeights,Ja=qa.morphTargets;if(sa){R=0;for(da=sa.length;R<da;R++)sa[R].offset=0,sa[R].offsetSrc=0}x=0;for(w=Ya.length;x<w;x++)if(fa=Ya[x],G=bb[fa],Za&&(y=Za[fa]),$a&&(N=$a[fa]),fa=G.vertexNormals,C=G.normal,ga=G.vertexColors,L=G.color,va=G.vertexTangents,G instanceof THREE.Face3){if(Da)J=za[G.a].position,H=za[G.b].position,ha=za[G.c].position,V[Q]=J.x,V[Q+1]=J.y,
+h.__dirtyMorphTargets||h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||t)if(t=o.DYNAMIC_DRAW,F=!h.dynamic,p.__inittedArrays){var fa=w=x=void 0,G=void 0,C=fa=void 0,ga=void 0,L=void 0,ua=void 0,N=y=ia=z=u=void 0,J=void 0,H=void 0,ha=void 0,O=void 0,R=G=ua=G=L=ga=void 0,da=void 0,I=da=R=ga=void 0,E=void 0,I=da=R=fa=fa=C=da=R=G=I=da=R=E=I=da=R=E=I=da=R=void 0,M=0,Q=0,T=0,W=0,va=0,Z=0,oa=0,X=0,Y=0,S=0,U=0,ma=I=0,ma=void 0,V=p.__vertexArray,wa=p.__uvArray,la=p.__uv2Array,
+aa=p.__normalArray,ka=p.__tangentArray,ea=p.__colorArray,$=p.__skinVertexAArray,ca=p.__skinVertexBArray,ta=p.__skinIndexArray,ja=p.__skinWeightArray,pa=p.__morphTargetsArrays,sa=p.__webglCustomAttributesList,E=void 0,Ba=p.__faceArray,na=p.__lineArray,Ga=p.__needsSmoothNormals,z=p.__vertexColorType,u=p.__uvType,ia=p.__normalType,qa=k.geometry,Da=qa.__dirtyVertices,Ea=qa.__dirtyElements,ya=qa.__dirtyUvs,Ka=qa.__dirtyNormals,Ca=qa.__dirtyTangents,Fa=qa.__dirtyColors,Ia=qa.__dirtyMorphTargets,za=qa.vertices,
+Ya=p.faces,bb=qa.faces,Za=qa.faceVertexUvs[0],$a=qa.faceVertexUvs[1],Pa=qa.skinVerticesA,Qa=qa.skinVerticesB,Ra=qa.skinIndices,La=qa.skinWeights,Ja=qa.morphTargets;if(sa){R=0;for(da=sa.length;R<da;R++)sa[R].offset=0,sa[R].offsetSrc=0}x=0;for(w=Ya.length;x<w;x++)if(fa=Ya[x],G=bb[fa],Za&&(y=Za[fa]),$a&&(N=$a[fa]),fa=G.vertexNormals,C=G.normal,ga=G.vertexColors,L=G.color,ua=G.vertexTangents,G instanceof THREE.Face3){if(Da)J=za[G.a].position,H=za[G.b].position,ha=za[G.c].position,V[Q]=J.x,V[Q+1]=J.y,
 V[Q+2]=J.z,V[Q+3]=H.x,V[Q+4]=H.y,V[Q+5]=H.z,V[Q+6]=ha.x,V[Q+7]=ha.y,V[Q+8]=ha.z,Q+=9;if(sa){R=0;for(da=sa.length;R<da;R++)if(E=sa[R],E.__original.needsUpdate)I=E.offset,ma=E.offsetSrc,E.size===1?(E.boundTo===void 0||E.boundTo==="vertices"?(E.array[I]=E.value[G.a],E.array[I+1]=E.value[G.b],E.array[I+2]=E.value[G.c]):E.boundTo==="faces"?(ma=E.value[ma],E.array[I]=ma,E.array[I+1]=ma,E.array[I+2]=ma,E.offsetSrc++):E.boundTo==="faceVertices"&&(E.array[I]=E.value[ma],E.array[I+1]=E.value[ma+1],E.array[I+
 2]=E.value[ma+2],E.offsetSrc+=3),E.offset+=3):(E.boundTo===void 0||E.boundTo==="vertices"?(J=E.value[G.a],H=E.value[G.b],ha=E.value[G.c]):E.boundTo==="faces"?(ha=H=J=ma=E.value[ma],E.offsetSrc++):E.boundTo==="faceVertices"&&(J=E.value[ma],H=E.value[ma+1],ha=E.value[ma+2],E.offsetSrc+=3),E.size===2?(E.array[I]=J.x,E.array[I+1]=J.y,E.array[I+2]=H.x,E.array[I+3]=H.y,E.array[I+4]=ha.x,E.array[I+5]=ha.y,E.offset+=6):E.size===3?(E.type==="c"?(E.array[I]=J.r,E.array[I+1]=J.g,E.array[I+2]=J.b,E.array[I+3]=
 H.r,E.array[I+4]=H.g,E.array[I+5]=H.b,E.array[I+6]=ha.r,E.array[I+7]=ha.g,E.array[I+8]=ha.b):(E.array[I]=J.x,E.array[I+1]=J.y,E.array[I+2]=J.z,E.array[I+3]=H.x,E.array[I+4]=H.y,E.array[I+5]=H.z,E.array[I+6]=ha.x,E.array[I+7]=ha.y,E.array[I+8]=ha.z),E.offset+=9):(E.array[I]=J.x,E.array[I+1]=J.y,E.array[I+2]=J.z,E.array[I+3]=J.w,E.array[I+4]=H.x,E.array[I+5]=H.y,E.array[I+6]=H.z,E.array[I+7]=H.w,E.array[I+8]=ha.x,E.array[I+9]=ha.y,E.array[I+10]=ha.z,E.array[I+11]=ha.w,E.offset+=12))}if(Ia){R=0;for(da=
 Ja.length;R<da;R++)J=Ja[R].vertices[G.a].position,H=Ja[R].vertices[G.b].position,ha=Ja[R].vertices[G.c].position,I=pa[R],I[U]=J.x,I[U+1]=J.y,I[U+2]=J.z,I[U+3]=H.x,I[U+4]=H.y,I[U+5]=H.z,I[U+6]=ha.x,I[U+7]=ha.y,I[U+8]=ha.z;U+=9}if(La.length)R=La[G.a],da=La[G.b],I=La[G.c],ja[S]=R.x,ja[S+1]=R.y,ja[S+2]=R.z,ja[S+3]=R.w,ja[S+4]=da.x,ja[S+5]=da.y,ja[S+6]=da.z,ja[S+7]=da.w,ja[S+8]=I.x,ja[S+9]=I.y,ja[S+10]=I.z,ja[S+11]=I.w,R=Ra[G.a],da=Ra[G.b],I=Ra[G.c],ta[S]=R.x,ta[S+1]=R.y,ta[S+2]=R.z,ta[S+3]=R.w,ta[S+4]=
-da.x,ta[S+5]=da.y,ta[S+6]=da.z,ta[S+7]=da.w,ta[S+8]=I.x,ta[S+9]=I.y,ta[S+10]=I.z,ta[S+11]=I.w,R=Pa[G.a],da=Pa[G.b],I=Pa[G.c],Z[S]=R.x,Z[S+1]=R.y,Z[S+2]=R.z,Z[S+3]=1,Z[S+4]=da.x,Z[S+5]=da.y,Z[S+6]=da.z,Z[S+7]=1,Z[S+8]=I.x,Z[S+9]=I.y,Z[S+10]=I.z,Z[S+11]=1,R=Qa[G.a],da=Qa[G.b],I=Qa[G.c],ca[S]=R.x,ca[S+1]=R.y,ca[S+2]=R.z,ca[S+3]=1,ca[S+4]=da.x,ca[S+5]=da.y,ca[S+6]=da.z,ca[S+7]=1,ca[S+8]=I.x,ca[S+9]=I.y,ca[S+10]=I.z,ca[S+11]=1,S+=12;if(Fa&&z)ga.length===3&&z===THREE.VertexColors?(G=ga[0],R=ga[1],da=ga[2]):
-da=R=G=L,ea[Y]=G.r,ea[Y+1]=G.g,ea[Y+2]=G.b,ea[Y+3]=R.r,ea[Y+4]=R.g,ea[Y+5]=R.b,ea[Y+6]=da.r,ea[Y+7]=da.g,ea[Y+8]=da.b,Y+=9;if(Ca&&qa.hasTangents)ga=va[0],L=va[1],G=va[2],ka[oa]=ga.x,ka[oa+1]=ga.y,ka[oa+2]=ga.z,ka[oa+3]=ga.w,ka[oa+4]=L.x,ka[oa+5]=L.y,ka[oa+6]=L.z,ka[oa+7]=L.w,ka[oa+8]=G.x,ka[oa+9]=G.y,ka[oa+10]=G.z,ka[oa+11]=G.w,oa+=12;if(Ka&&ia)if(fa.length===3&&Ga)for(R=0;R<3;R++)C=fa[R],aa[ua]=C.x,aa[ua+1]=C.y,aa[ua+2]=C.z,ua+=3;else for(R=0;R<3;R++)aa[ua]=C.x,aa[ua+1]=C.y,aa[ua+2]=C.z,ua+=3;if(ya&&
-y!==void 0&&u)for(R=0;R<3;R++)fa=y[R],wa[T]=fa.u,wa[T+1]=fa.v,T+=2;if(ya&&N!==void 0&&u)for(R=0;R<3;R++)fa=N[R],la[W]=fa.u,la[W+1]=fa.v,W+=2;Ea&&(Ba[$]=M,Ba[$+1]=M+1,Ba[$+2]=M+2,$+=3,na[X]=M,na[X+1]=M+1,na[X+2]=M,na[X+3]=M+2,na[X+4]=M+1,na[X+5]=M+2,X+=6,M+=3)}else if(G instanceof THREE.Face4){if(Da)J=za[G.a].position,H=za[G.b].position,ha=za[G.c].position,O=za[G.d].position,V[Q]=J.x,V[Q+1]=J.y,V[Q+2]=J.z,V[Q+3]=H.x,V[Q+4]=H.y,V[Q+5]=H.z,V[Q+6]=ha.x,V[Q+7]=ha.y,V[Q+8]=ha.z,V[Q+9]=O.x,V[Q+10]=O.y,V[Q+
+da.x,ta[S+5]=da.y,ta[S+6]=da.z,ta[S+7]=da.w,ta[S+8]=I.x,ta[S+9]=I.y,ta[S+10]=I.z,ta[S+11]=I.w,R=Pa[G.a],da=Pa[G.b],I=Pa[G.c],$[S]=R.x,$[S+1]=R.y,$[S+2]=R.z,$[S+3]=1,$[S+4]=da.x,$[S+5]=da.y,$[S+6]=da.z,$[S+7]=1,$[S+8]=I.x,$[S+9]=I.y,$[S+10]=I.z,$[S+11]=1,R=Qa[G.a],da=Qa[G.b],I=Qa[G.c],ca[S]=R.x,ca[S+1]=R.y,ca[S+2]=R.z,ca[S+3]=1,ca[S+4]=da.x,ca[S+5]=da.y,ca[S+6]=da.z,ca[S+7]=1,ca[S+8]=I.x,ca[S+9]=I.y,ca[S+10]=I.z,ca[S+11]=1,S+=12;if(Fa&&z)ga.length===3&&z===THREE.VertexColors?(G=ga[0],R=ga[1],da=ga[2]):
+da=R=G=L,ea[Y]=G.r,ea[Y+1]=G.g,ea[Y+2]=G.b,ea[Y+3]=R.r,ea[Y+4]=R.g,ea[Y+5]=R.b,ea[Y+6]=da.r,ea[Y+7]=da.g,ea[Y+8]=da.b,Y+=9;if(Ca&&qa.hasTangents)ga=ua[0],L=ua[1],G=ua[2],ka[oa]=ga.x,ka[oa+1]=ga.y,ka[oa+2]=ga.z,ka[oa+3]=ga.w,ka[oa+4]=L.x,ka[oa+5]=L.y,ka[oa+6]=L.z,ka[oa+7]=L.w,ka[oa+8]=G.x,ka[oa+9]=G.y,ka[oa+10]=G.z,ka[oa+11]=G.w,oa+=12;if(Ka&&ia)if(fa.length===3&&Ga)for(R=0;R<3;R++)C=fa[R],aa[Z]=C.x,aa[Z+1]=C.y,aa[Z+2]=C.z,Z+=3;else for(R=0;R<3;R++)aa[Z]=C.x,aa[Z+1]=C.y,aa[Z+2]=C.z,Z+=3;if(ya&&y!==
+void 0&&u)for(R=0;R<3;R++)fa=y[R],wa[T]=fa.u,wa[T+1]=fa.v,T+=2;if(ya&&N!==void 0&&u)for(R=0;R<3;R++)fa=N[R],la[W]=fa.u,la[W+1]=fa.v,W+=2;Ea&&(Ba[va]=M,Ba[va+1]=M+1,Ba[va+2]=M+2,va+=3,na[X]=M,na[X+1]=M+1,na[X+2]=M,na[X+3]=M+2,na[X+4]=M+1,na[X+5]=M+2,X+=6,M+=3)}else if(G instanceof THREE.Face4){if(Da)J=za[G.a].position,H=za[G.b].position,ha=za[G.c].position,O=za[G.d].position,V[Q]=J.x,V[Q+1]=J.y,V[Q+2]=J.z,V[Q+3]=H.x,V[Q+4]=H.y,V[Q+5]=H.z,V[Q+6]=ha.x,V[Q+7]=ha.y,V[Q+8]=ha.z,V[Q+9]=O.x,V[Q+10]=O.y,V[Q+
 11]=O.z,Q+=12;if(sa){R=0;for(da=sa.length;R<da;R++)if(E=sa[R],E.__original.needsUpdate)I=E.offset,ma=E.offsetSrc,E.size===1?(E.boundTo===void 0||E.boundTo==="vertices"?(E.array[I]=E.value[G.a],E.array[I+1]=E.value[G.b],E.array[I+2]=E.value[G.c],E.array[I+3]=E.value[G.d]):E.boundTo==="faces"?(ma=E.value[ma],E.array[I]=ma,E.array[I+1]=ma,E.array[I+2]=ma,E.array[I+3]=ma,E.offsetSrc++):E.boundTo==="faceVertices"&&(E.array[I]=E.value[ma],E.array[I+1]=E.value[ma+1],E.array[I+2]=E.value[ma+2],E.array[I+
 3]=E.value[ma+3],E.offsetSrc+=4),E.offset+=4):(E.boundTo===void 0||E.boundTo==="vertices"?(J=E.value[G.a],H=E.value[G.b],ha=E.value[G.c],O=E.value[G.d]):E.boundTo==="faces"?(O=ha=H=J=ma=E.value[ma],E.offsetSrc++):E.boundTo==="faceVertices"&&(J=E.value[ma],H=E.value[ma+1],ha=E.value[ma+2],O=E.value[ma+3],E.offsetSrc+=4),E.size===2?(E.array[I]=J.x,E.array[I+1]=J.y,E.array[I+2]=H.x,E.array[I+3]=H.y,E.array[I+4]=ha.x,E.array[I+5]=ha.y,E.array[I+6]=O.x,E.array[I+7]=O.y,E.offset+=8):E.size===3?(E.type===
 "c"?(E.array[I]=J.r,E.array[I+1]=J.g,E.array[I+2]=J.b,E.array[I+3]=H.r,E.array[I+4]=H.g,E.array[I+5]=H.b,E.array[I+6]=ha.r,E.array[I+7]=ha.g,E.array[I+8]=ha.b,E.array[I+9]=O.r,E.array[I+10]=O.g,E.array[I+11]=O.b):(E.array[I]=J.x,E.array[I+1]=J.y,E.array[I+2]=J.z,E.array[I+3]=H.x,E.array[I+4]=H.y,E.array[I+5]=H.z,E.array[I+6]=ha.x,E.array[I+7]=ha.y,E.array[I+8]=ha.z,E.array[I+9]=O.x,E.array[I+10]=O.y,E.array[I+11]=O.z),E.offset+=12):(E.array[I]=J.x,E.array[I+1]=J.y,E.array[I+2]=J.z,E.array[I+3]=J.w,
 E.array[I+4]=H.x,E.array[I+5]=H.y,E.array[I+6]=H.z,E.array[I+7]=H.w,E.array[I+8]=ha.x,E.array[I+9]=ha.y,E.array[I+10]=ha.z,E.array[I+11]=ha.w,E.array[I+12]=O.x,E.array[I+13]=O.y,E.array[I+14]=O.z,E.array[I+15]=O.w,E.offset+=16))}if(Ia){R=0;for(da=Ja.length;R<da;R++)J=Ja[R].vertices[G.a].position,H=Ja[R].vertices[G.b].position,ha=Ja[R].vertices[G.c].position,O=Ja[R].vertices[G.d].position,I=pa[R],I[U]=J.x,I[U+1]=J.y,I[U+2]=J.z,I[U+3]=H.x,I[U+4]=H.y,I[U+5]=H.z,I[U+6]=ha.x,I[U+7]=ha.y,I[U+8]=ha.z,I[U+
 9]=O.x,I[U+10]=O.y,I[U+11]=O.z;U+=12}if(La.length)R=La[G.a],da=La[G.b],I=La[G.c],E=La[G.d],ja[S]=R.x,ja[S+1]=R.y,ja[S+2]=R.z,ja[S+3]=R.w,ja[S+4]=da.x,ja[S+5]=da.y,ja[S+6]=da.z,ja[S+7]=da.w,ja[S+8]=I.x,ja[S+9]=I.y,ja[S+10]=I.z,ja[S+11]=I.w,ja[S+12]=E.x,ja[S+13]=E.y,ja[S+14]=E.z,ja[S+15]=E.w,R=Ra[G.a],da=Ra[G.b],I=Ra[G.c],E=Ra[G.d],ta[S]=R.x,ta[S+1]=R.y,ta[S+2]=R.z,ta[S+3]=R.w,ta[S+4]=da.x,ta[S+5]=da.y,ta[S+6]=da.z,ta[S+7]=da.w,ta[S+8]=I.x,ta[S+9]=I.y,ta[S+10]=I.z,ta[S+11]=I.w,ta[S+12]=E.x,ta[S+13]=
-E.y,ta[S+14]=E.z,ta[S+15]=E.w,R=Pa[G.a],da=Pa[G.b],I=Pa[G.c],E=Pa[G.d],Z[S]=R.x,Z[S+1]=R.y,Z[S+2]=R.z,Z[S+3]=1,Z[S+4]=da.x,Z[S+5]=da.y,Z[S+6]=da.z,Z[S+7]=1,Z[S+8]=I.x,Z[S+9]=I.y,Z[S+10]=I.z,Z[S+11]=1,Z[S+12]=E.x,Z[S+13]=E.y,Z[S+14]=E.z,Z[S+15]=1,R=Qa[G.a],da=Qa[G.b],I=Qa[G.c],G=Qa[G.d],ca[S]=R.x,ca[S+1]=R.y,ca[S+2]=R.z,ca[S+3]=1,ca[S+4]=da.x,ca[S+5]=da.y,ca[S+6]=da.z,ca[S+7]=1,ca[S+8]=I.x,ca[S+9]=I.y,ca[S+10]=I.z,ca[S+11]=1,ca[S+12]=G.x,ca[S+13]=G.y,ca[S+14]=G.z,ca[S+15]=1,S+=16;if(Fa&&z)ga.length===
-4&&z===THREE.VertexColors?(G=ga[0],R=ga[1],da=ga[2],ga=ga[3]):ga=da=R=G=L,ea[Y]=G.r,ea[Y+1]=G.g,ea[Y+2]=G.b,ea[Y+3]=R.r,ea[Y+4]=R.g,ea[Y+5]=R.b,ea[Y+6]=da.r,ea[Y+7]=da.g,ea[Y+8]=da.b,ea[Y+9]=ga.r,ea[Y+10]=ga.g,ea[Y+11]=ga.b,Y+=12;if(Ca&&qa.hasTangents)ga=va[0],L=va[1],G=va[2],va=va[3],ka[oa]=ga.x,ka[oa+1]=ga.y,ka[oa+2]=ga.z,ka[oa+3]=ga.w,ka[oa+4]=L.x,ka[oa+5]=L.y,ka[oa+6]=L.z,ka[oa+7]=L.w,ka[oa+8]=G.x,ka[oa+9]=G.y,ka[oa+10]=G.z,ka[oa+11]=G.w,ka[oa+12]=va.x,ka[oa+13]=va.y,ka[oa+14]=va.z,ka[oa+15]=
-va.w,oa+=16;if(Ka&&ia)if(fa.length===4&&Ga)for(R=0;R<4;R++)C=fa[R],aa[ua]=C.x,aa[ua+1]=C.y,aa[ua+2]=C.z,ua+=3;else for(R=0;R<4;R++)aa[ua]=C.x,aa[ua+1]=C.y,aa[ua+2]=C.z,ua+=3;if(ya&&y!==void 0&&u)for(R=0;R<4;R++)fa=y[R],wa[T]=fa.u,wa[T+1]=fa.v,T+=2;if(ya&&N!==void 0&&u)for(R=0;R<4;R++)fa=N[R],la[W]=fa.u,la[W+1]=fa.v,W+=2;Ea&&(Ba[$]=M,Ba[$+1]=M+1,Ba[$+2]=M+3,Ba[$+3]=M+1,Ba[$+4]=M+2,Ba[$+5]=M+3,$+=6,na[X]=M,na[X+1]=M+1,na[X+2]=M,na[X+3]=M+3,na[X+4]=M+1,na[X+5]=M+2,na[X+6]=M+2,na[X+7]=M+3,X+=8,M+=4)}Da&&
+E.y,ta[S+14]=E.z,ta[S+15]=E.w,R=Pa[G.a],da=Pa[G.b],I=Pa[G.c],E=Pa[G.d],$[S]=R.x,$[S+1]=R.y,$[S+2]=R.z,$[S+3]=1,$[S+4]=da.x,$[S+5]=da.y,$[S+6]=da.z,$[S+7]=1,$[S+8]=I.x,$[S+9]=I.y,$[S+10]=I.z,$[S+11]=1,$[S+12]=E.x,$[S+13]=E.y,$[S+14]=E.z,$[S+15]=1,R=Qa[G.a],da=Qa[G.b],I=Qa[G.c],G=Qa[G.d],ca[S]=R.x,ca[S+1]=R.y,ca[S+2]=R.z,ca[S+3]=1,ca[S+4]=da.x,ca[S+5]=da.y,ca[S+6]=da.z,ca[S+7]=1,ca[S+8]=I.x,ca[S+9]=I.y,ca[S+10]=I.z,ca[S+11]=1,ca[S+12]=G.x,ca[S+13]=G.y,ca[S+14]=G.z,ca[S+15]=1,S+=16;if(Fa&&z)ga.length===
+4&&z===THREE.VertexColors?(G=ga[0],R=ga[1],da=ga[2],ga=ga[3]):ga=da=R=G=L,ea[Y]=G.r,ea[Y+1]=G.g,ea[Y+2]=G.b,ea[Y+3]=R.r,ea[Y+4]=R.g,ea[Y+5]=R.b,ea[Y+6]=da.r,ea[Y+7]=da.g,ea[Y+8]=da.b,ea[Y+9]=ga.r,ea[Y+10]=ga.g,ea[Y+11]=ga.b,Y+=12;if(Ca&&qa.hasTangents)ga=ua[0],L=ua[1],G=ua[2],ua=ua[3],ka[oa]=ga.x,ka[oa+1]=ga.y,ka[oa+2]=ga.z,ka[oa+3]=ga.w,ka[oa+4]=L.x,ka[oa+5]=L.y,ka[oa+6]=L.z,ka[oa+7]=L.w,ka[oa+8]=G.x,ka[oa+9]=G.y,ka[oa+10]=G.z,ka[oa+11]=G.w,ka[oa+12]=ua.x,ka[oa+13]=ua.y,ka[oa+14]=ua.z,ka[oa+15]=
+ua.w,oa+=16;if(Ka&&ia)if(fa.length===4&&Ga)for(R=0;R<4;R++)C=fa[R],aa[Z]=C.x,aa[Z+1]=C.y,aa[Z+2]=C.z,Z+=3;else for(R=0;R<4;R++)aa[Z]=C.x,aa[Z+1]=C.y,aa[Z+2]=C.z,Z+=3;if(ya&&y!==void 0&&u)for(R=0;R<4;R++)fa=y[R],wa[T]=fa.u,wa[T+1]=fa.v,T+=2;if(ya&&N!==void 0&&u)for(R=0;R<4;R++)fa=N[R],la[W]=fa.u,la[W+1]=fa.v,W+=2;Ea&&(Ba[va]=M,Ba[va+1]=M+1,Ba[va+2]=M+3,Ba[va+3]=M+1,Ba[va+4]=M+2,Ba[va+5]=M+3,va+=6,na[X]=M,na[X+1]=M+1,na[X+2]=M,na[X+3]=M+3,na[X+4]=M+1,na[X+5]=M+2,na[X+6]=M+2,na[X+7]=M+3,X+=8,M+=4)}Da&&
 (o.bindBuffer(o.ARRAY_BUFFER,p.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,V,t));if(sa){R=0;for(da=sa.length;R<da;R++)E=sa[R],E.__original.needsUpdate&&(o.bindBuffer(o.ARRAY_BUFFER,E.buffer),o.bufferData(o.ARRAY_BUFFER,E.array,t))}if(Ia){R=0;for(da=Ja.length;R<da;R++)o.bindBuffer(o.ARRAY_BUFFER,p.__webglMorphTargetsBuffers[R]),o.bufferData(o.ARRAY_BUFFER,pa[R],t)}Fa&&Y>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,ea,t));Ka&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglNormalBuffer),
 o.bufferData(o.ARRAY_BUFFER,aa,t));Ca&&qa.hasTangents&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglTangentBuffer),o.bufferData(o.ARRAY_BUFFER,ka,t));ya&&T>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,wa,t));ya&&W>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,la,t));Ea&&(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,p.__webglFaceBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,Ba,t),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,p.__webglLineBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,
-na,t));S>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,Z,t),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,ca,t),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ta,t),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER,ja,t));F&&(delete p.__inittedArrays,delete p.__colorArray,delete p.__normalArray,delete p.__tangentArray,delete p.__uvArray,delete p.__uv2Array,
+na,t));S>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,$,t),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,ca,t),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ta,t),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER,ja,t));F&&(delete p.__inittedArrays,delete p.__colorArray,delete p.__normalArray,delete p.__tangentArray,delete p.__uvArray,delete p.__uv2Array,
 delete p.__faceArray,delete p.__vertexArray,delete p.__lineArray,delete p.__skinVertexAArray,delete p.__skinVertexBArray,delete p.__skinIndexArray,delete p.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyColors=!1;h.__dirtyTangents=!1;l.attributes&&B(l)}else if(k instanceof THREE.Ribbon){if(h.__dirtyVertices||h.__dirtyColors){k=h;l=o.DYNAMIC_DRAW;n=x=F=F=void 0;w=k.vertices;v=k.colors;u=w.length;p=v.length;z=k.__vertexArray;
 t=k.__colorArray;ia=k.__dirtyColors;if(k.__dirtyVertices){for(F=0;F<u;F++)x=w[F].position,n=F*3,z[n]=x.x,z[n+1]=x.y,z[n+2]=x.z;o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer);o.bufferData(o.ARRAY_BUFFER,z,l)}if(ia){for(F=0;F<p;F++)color=v[F],n=F*3,t[n]=color.r,t[n+1]=color.g,t[n+2]=color.b;o.bindBuffer(o.ARRAY_BUFFER,k.__webglColorBuffer);o.bufferData(o.ARRAY_BUFFER,t,l)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(k instanceof THREE.Line){if(h.__dirtyVertices||h.__dirtyColors){k=h;l=o.DYNAMIC_DRAW;
 n=x=F=F=void 0;w=k.vertices;v=k.colors;u=w.length;p=v.length;z=k.__vertexArray;t=k.__colorArray;ia=k.__dirtyColors;if(k.__dirtyVertices){for(F=0;F<u;F++)x=w[F].position,n=F*3,z[n]=x.x,z[n+1]=x.y,z[n+2]=x.z;o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer);o.bufferData(o.ARRAY_BUFFER,z,l)}if(ia){for(F=0;F<p;F++)color=v[F],n=F*3,t[n]=color.r,t[n+1]=color.g,t[n+2]=color.b;o.bindBuffer(o.ARRAY_BUFFER,k.__webglColorBuffer);o.bufferData(o.ARRAY_BUFFER,t,l)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(k instanceof
@@ -439,7 +442,7 @@ this.cameraNY,c);c.activeCubeFace=4;a.render(b,this.cameraPZ,c);c.activeCubeFace
 THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(a,c,b,e,k,h,f){THREE.Camera.call(this);this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,c/2,c/-2,h,f);this.cameraP=new THREE.PerspectiveCamera(b,a/c,e,k);this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera;
 THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.projectionMatrix=this.cameraP.projectionMatrix};THREE.CombinedCamera.prototype.toOrthographic=function(){this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix};THREE.CombinedCamera.prototype.setFov=function(a){this.cameraP.fov=a;this.cameraP.updateProjectionMatrix();this.toPerspective()};
 THREE.CombinedCamera.prototype.setLens=function(a,c){c||(c=43.25);var b=2*Math.atan(c/(a*2));b*=180/Math.PI;this.setFov(b);return b};
-THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
+THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
 0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=
 !0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=
 function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=
@@ -449,14 +452,14 @@ this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b)
 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 e(a,b){return function(){b.apply(a,arguments)}}function k(a,b,c,e){var f={name:c,fps:0.6,length:e,hierarchy:[]},h,k=b.getControlPointsArray(),l=b.getLength(),y=k.length,C=0;h=y-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:k[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[h]={time:e,pos:k[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<y-1;h++)C=e*l.chunks[h]/l.total,b.keys[h]={time:C,pos:k[h]};f.hierarchy[0]=
 b;THREE.AnimationHandler.add(f);return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function h(a,b){var c,e,f=new THREE.Geometry;for(c=0;c<a.points.length*b;c++)e=c/(a.points.length*b),e=a.getPoint(e),f.vertices[c]=new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z));return f}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=
+new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=
 this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var f=Math.PI*2,l=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)*l;this.theta=this.lon*l;a=this.phi%f;this.phi=a>=0?a:a+f;c=this.verticalAngleMap.srcRange;
 a=this.verticalAngleMap.dstRange;c=THREE.Math.mapLinear(this.phi,c[0],c[1],a[0],a[1]);var e=a[1]-a[0];this.phi=b((c-a[0])/e)*e+a[0];c=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;c=THREE.Math.mapLinear(this.theta,c[0],c[1],a[0],a[1]);e=a[1]-a[0];this.theta=b((c-a[0])/e)*e+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=
 function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}),
 c=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(f,b);a.position.set(0,10,0);this.animation=k(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=k(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a=
 this.debugPath,b=this.spline,c=h(b,10),f=h(b,10),l=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(c,l);particleObj=new THREE.ParticleSystem(f,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);a.add(lineObj);particleObj.scale.set(1,1,1);a.add(particleObj);f=new THREE.SphereGeometry(1,16,8);l=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<b.points.length;i++)c=new THREE.Mesh(f,l),c.position.copy(b.points[i]),a.add(c)}this.domElement.addEventListener("mousemove",
 e(this,this.onMouseMove),!1)}};THREE.PathControlsIdCounter=0;
-THREE.FlyControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=c!==void 0?c:document;c&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
+THREE.FlyControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=c!==void 0?c:document;c&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
 0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=
 1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=
 0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
@@ -493,14 +496,14 @@ l.copy(b).addSelf(h);n.copy(c).addSelf(k);h=e.dot(k);k=n.subSelf(l).dot(k);h===0
 1);for(var b=0,c=v+t*2,b=0;b<c;b++){var e=U*b,f=U*(b+1),h=qa+pa+e,k=qa+pa+f,o=h,e=qa+na+e,f=qa+na+f,p=k;o+=W;e+=W;f+=W;p+=W;L.faces.push(new THREE.Face4(o,e,f,p,null,null,D));D&&(o=b/c,e=(b+1)/c,f=l+n*2,h=(L.vertices[h].position.z+n)/f,k=(L.vertices[k].position.z+n)/f,L.faceVertexUvs[0].push([new THREE.UV(h,o),new THREE.UV(k,o),new THREE.UV(k,e),new THREE.UV(h,e)]))}}}function h(a,b,c){L.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function f(a,b,c){a+=W;b+=W;c+=W;L.faces.push(new THREE.Face3(a,
 b,c,null,null,B));if(B){var e=K.maxY,f=K.maxX,h=L.vertices[b].position.x,b=L.vertices[b].position.y,k=L.vertices[c].position.x,c=L.vertices[c].position.y;L.faceVertexUvs[0].push([new THREE.UV(L.vertices[a].position.x/f,L.vertices[a].position.y/e),new THREE.UV(h/f,b/e),new THREE.UV(k/f,c/e)])}}var l=c.amount!==void 0?c.amount:100,n=c.bevelThickness!==void 0?c.bevelThickness:6,u=c.bevelSize!==void 0?c.bevelSize:n-2,t=c.bevelSegments!==void 0?c.bevelSegments:3,p=c.bevelEnabled!==void 0?c.bevelEnabled:
 !0,w=c.curveSegments!==void 0?c.curveSegments:12,v=c.steps!==void 0?c.steps:1,z=c.bendPath,x=c.extrudePath,y,C=!1,A=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,B=c.material,D=c.extrudeMaterial,K=this.shapebb;if(x)y=x.getPoints(w),v=y.length,C=!0,p=!1;p||(u=n=t=0);var H,M,V,L=this,W=this.vertices.length;z&&a.addWrapPath(z);w=A?a.extractAllSpacedPoints(w):a.extractAllPoints(w);z=w.shape;w=w.holes;if(x=!THREE.Shape.Utils.isClockWise(z)){z=z.reverse();M=0;for(V=w.length;M<V;M++)H=w[M],THREE.Shape.Utils.isClockWise(H)&&
-(w[M]=H.reverse());x=!1}x=THREE.Shape.Utils.triangulateShape(z,w);A=z;M=0;for(V=w.length;M<V;M++)H=w[M],z=z.concat(H);var N,O,$,Y,P,o,U=z.length,Q=x.length,aa=[];N=0;O=A.length;pa=O-1;for(na=N+1;N<O;N++,pa++,na++)pa===O&&(pa=0),na===O&&(na=0),aa[N]=e(A[N],A[pa],A[na]);var T=[],J,ra=aa.concat();M=0;for(V=w.length;M<V;M++){H=w[M];J=[];N=0;O=H.length;pa=O-1;for(na=N+1;N<O;N++,pa++,na++)pa===O&&(pa=0),na===O&&(na=0),J[N]=e(H[N],H[pa],H[na]);T.push(J);ra=ra.concat(J)}for($=0;$<t;$++){Y=$/t;P=n*(1-Y);Y=
-u*Math.sin(Y*Math.PI/2);N=0;for(O=A.length;N<O;N++)o=b(A[N],aa[N],Y),h(o.x,o.y,-P);M=0;for(V=w.length;M<V;M++){H=w[M];J=T[M];N=0;for(O=H.length;N<O;N++)o=b(H[N],J[N],Y),h(o.x,o.y,-P)}}Y=u;for(N=0;N<U;N++)o=p?b(z[N],ra[N],Y):z[N],C?h(o.x,o.y+y[0].y,y[0].x):h(o.x,o.y,0);for($=1;$<=v;$++)for(N=0;N<U;N++)o=p?b(z[N],ra[N],Y):z[N],C?h(o.x,o.y+y[$-1].y,y[$-1].x):h(o.x,o.y,l/v*$);for($=t-1;$>=0;$--){Y=$/t;P=n*(1-Y);Y=u*Math.sin(Y*Math.PI/2);N=0;for(O=A.length;N<O;N++)o=b(A[N],aa[N],Y),h(o.x,o.y,l+P);M=0;
+(w[M]=H.reverse());x=!1}x=THREE.Shape.Utils.triangulateShape(z,w);A=z;M=0;for(V=w.length;M<V;M++)H=w[M],z=z.concat(H);var N,O,Z,Y,P,o,U=z.length,Q=x.length,aa=[];N=0;O=A.length;pa=O-1;for(na=N+1;N<O;N++,pa++,na++)pa===O&&(pa=0),na===O&&(na=0),aa[N]=e(A[N],A[pa],A[na]);var T=[],J,ra=aa.concat();M=0;for(V=w.length;M<V;M++){H=w[M];J=[];N=0;O=H.length;pa=O-1;for(na=N+1;N<O;N++,pa++,na++)pa===O&&(pa=0),na===O&&(na=0),J[N]=e(H[N],H[pa],H[na]);T.push(J);ra=ra.concat(J)}for(Z=0;Z<t;Z++){Y=Z/t;P=n*(1-Y);Y=
+u*Math.sin(Y*Math.PI/2);N=0;for(O=A.length;N<O;N++)o=b(A[N],aa[N],Y),h(o.x,o.y,-P);M=0;for(V=w.length;M<V;M++){H=w[M];J=T[M];N=0;for(O=H.length;N<O;N++)o=b(H[N],J[N],Y),h(o.x,o.y,-P)}}Y=u;for(N=0;N<U;N++)o=p?b(z[N],ra[N],Y):z[N],C?h(o.x,o.y+y[0].y,y[0].x):h(o.x,o.y,0);for(Z=1;Z<=v;Z++)for(N=0;N<U;N++)o=p?b(z[N],ra[N],Y):z[N],C?h(o.x,o.y+y[Z-1].y,y[Z-1].x):h(o.x,o.y,l/v*Z);for(Z=t-1;Z>=0;Z--){Y=Z/t;P=n*(1-Y);Y=u*Math.sin(Y*Math.PI/2);N=0;for(O=A.length;N<O;N++)o=b(A[N],aa[N],Y),h(o.x,o.y,l+P);M=0;
 for(V=w.length;M<V;M++){H=w[M];J=T[M];N=0;for(O=H.length;N<O;N++)o=b(H[N],J[N],Y),C?h(o.x,o.y+y[v-1].y,y[v-1].x+P):h(o.x,o.y,l+P)}}if(p){p=U*0;for(N=0;N<Q;N++)u=x[N],f(u[2]+p,u[1]+p,u[0]+p);p=U*(v+t*2);for(N=0;N<Q;N++)u=x[N],f(u[0]+p,u[1]+p,u[2]+p)}else{for(N=0;N<Q;N++)u=x[N],f(u[2],u[1],u[0]);for(N=0;N<Q;N++)u=x[N],f(u[0]+U*v,u[1]+U*v,u[2]+U*v)}var pa,na,qa=0;k(A);qa+=A.length;M=0;for(V=w.length;M<V;M++)H=w[M],k(H),qa+=H.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 e=Math.sqrt(a*a+b*b+c*c);return k.vertices.push(new THREE.Vertex(new THREE.Vector3(a/e,b/e,c/e)))-1}function b(a,b,c,e){e.faces.push(new THREE.Face3(a,b,c))}function e(a,b){var e=k.vertices[a].position,f=k.vertices[b].position;return c((e.x+f.x)/2,(e.y+f.y)/2,(e.z+f.z)/2)}var k=this,h=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,h);b(0,5,1,h);b(0,1,7,h);b(0,7,10,h);b(0,10,11,h);b(1,5,9,h);b(5,11,4,h);b(11,10,2,h);b(10,7,6,h);b(7,1,8,h);b(3,9,4,h);b(3,4,2,h);b(3,2,6,h);b(3,6,8,h);b(3,8,9,h);b(4,9,5,h);b(2,4,11,h);b(6,2,10,h);b(8,6,7,h);b(9,8,1,h);for(var f=0;f<this.subdivisions;f++){var a=new THREE.Geometry,l;for(l in h.faces){var n=e(h.faces[l].a,h.faces[l].b),u=e(h.faces[l].b,h.faces[l].c),t=e(h.faces[l].c,h.faces[l].a);b(h.faces[l].a,n,t,a);b(h.faces[l].b,u,
 n,a);b(h.faces[l].c,t,u,a);b(n,u,t,a)}h.faces=a.faces}k.faces=h.faces;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
-THREE.LatheGeometry=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;for(var c=this.angle/this.steps,b=[],e=[],k=[],h=[],f=(new THREE.Matrix4).setRotationZ(c),l=0;l<a.length;l++)this.vertices.push(new THREE.Vertex(a[l])),b[l]=a[l].clone(),e[l]=this.vertices.length-1;for(var n=0;n<=this.angle+0.001;n+=c){for(l=0;l<b.length;l++)n<this.angle?(b[l]=f.multiplyVector3(b[l].clone()),this.vertices.push(new THREE.Vertex(b[l])),k[l]=this.vertices.length-1):k=h;n==0&&(h=e);
+THREE.LatheGeometry=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;for(var c=this.angle/this.steps,b=[],e=[],k=[],h=[],f=(new THREE.Matrix4).setRotationZ(c),l=0;l<a.length;l++)this.vertices.push(new THREE.Vertex(a[l])),b[l]=a[l].clone(),e[l]=this.vertices.length-1;for(var n=0;n<=this.angle+0.0010;n+=c){for(l=0;l<b.length;l++)n<this.angle?(b[l]=f.multiplyVector3(b[l].clone()),this.vertices.push(new THREE.Vertex(b[l])),k[l]=this.vertices.length-1):k=h;n==0&&(h=e);
 for(l=0;l<e.length-1;l++)this.faces.push(new THREE.Face4(k[l],k[l+1],e[l+1],e[l])),this.faceVertexUvs[0].push([new THREE.UV(1-n/this.angle,l/a.length),new THREE.UV(1-n/this.angle,(l+1)/a.length),new THREE.UV(1-(n-c)/this.angle,(l+1)/a.length),new THREE.UV(1-(n-c)/this.angle,l/a.length)]);e=k;k=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
 THREE.OctahedronGeometry=function(a,c){function b(b){var c=b.clone().normalize(),c=new THREE.Vertex(c.clone().multiplyScalar(a));c.index=f.vertices.push(c)-1;c.uv=new THREE.UV(Math.atan2(b.z,-b.x)/2/Math.PI+0.5,Math.atan2(-b.y,Math.sqrt(b.x*b.x+b.z*b.z))/Math.PI+0.5);return c}function e(a,b,c,l){l<1?(l=new THREE.Face3(a.index,b.index,c.index,[a.position,b.position,c.position]),l.centroid.addSelf(a.position).addSelf(b.position).addSelf(c.position).divideScalar(3),l.normal=l.centroid.clone().normalize(),
 f.faces.push(l),l=Math.atan2(l.centroid.z,-l.centroid.x),f.faceVertexUvs[0].push([h(a.uv,a.position,l),h(b.uv,b.position,l),h(c.uv,c.position,l)])):(l-=1,e(a,k(a,b),k(a,c),l),e(k(a,b),b,k(b,c),l),e(k(a,c),k(b,c),c,l),e(k(a,b),k(b,c),k(a,c),l))}function k(a,c){l[a.index]||(l[a.index]=[]);l[c.index]||(l[c.index]=[]);var e=l[a.index][c.index];e===void 0&&(l[a.index][c.index]=l[c.index][a.index]=e=b((new THREE.Vector3).add(a.position,c.position).divideScalar(2)));return e}function h(a,b,c){c<0&&a.u===
@@ -519,7 +522,7 @@ this.getFace(),b=this.size/c.resolution,e=0,k=String(a).split(""),h=k.length,f=[
 u));k.moveTo(l,u);break;case "l":l=c[a++]*b+e;u=c[a++]*b;h.push(new THREE.Vector2(l,u));k.lineTo(l,u);break;case "q":l=c[a++]*b+e;u=c[a++]*b;w=c[a++]*b+e;v=c[a++]*b;k.quadraticCurveTo(w,v,l,u);if(f=h[h.length-1]){t=f.x;p=f.y;f=1;for(divisions=this.divisions;f<=divisions;f++){var C=f/divisions,A=THREE.Shape.Utils.b2(C,t,w,l),C=THREE.Shape.Utils.b2(C,p,v,u);h.push(new THREE.Vector2(A,C))}}break;case "b":if(l=c[a++]*b+e,u=c[a++]*b,w=c[a++]*b+e,v=c[a++]*-b,z=c[a++]*b+e,x=c[a++]*-b,k.bezierCurveTo(l,u,
 w,v,z,x),f=h[h.length-1]){t=f.x;p=f.y;f=1;for(divisions=this.divisions;f<=divisions;f++)C=f/divisions,A=THREE.Shape.Utils.b3(C,t,w,z,l),C=THREE.Shape.Utils.b3(C,p,v,x,u),h.push(new THREE.Vector2(A,C))}}}return{offset:y.ha*b,points:h,path:k}}}};
 (function(a){var c=function(a){for(var c=a.length,k=0,h=c-1,f=0;f<c;h=f++)k+=a[h].x*a[f].y-a[f].x*a[h].y;return k*0.5};a.Triangulate=function(a,e){var k=a.length;if(k<3)return null;var h=[],f=[],l=[],n,u,t;if(c(a)>0)for(u=0;u<k;u++)f[u]=u;else for(u=0;u<k;u++)f[u]=k-1-u;var p=2*k;for(u=k-1;k>2;){if(p--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return l;return h}n=u;k<=n&&(n=0);u=n+1;k<=u&&(u=0);t=u+1;k<=t&&(t=0);var w;a:{w=a;var v=n,z=u,x=t,y=k,C=f,A=void 0,B=void 0,D=void 0,
-K=void 0,H=void 0,M=void 0,V=void 0,L=void 0,W=void 0,B=w[C[v]].x,D=w[C[v]].y,K=w[C[z]].x,H=w[C[z]].y,M=w[C[x]].x,V=w[C[x]].y;if(1.0E-10>(K-B)*(V-D)-(H-D)*(M-B))w=!1;else{for(A=0;A<y;A++)if(!(A==v||A==z||A==x)){var L=w[C[A]].x,W=w[C[A]].y,N=void 0,O=void 0,$=void 0,Y=void 0,P=void 0,o=void 0,U=void 0,Q=void 0,aa=void 0,T=void 0,J=void 0,ra=void 0,N=$=P=void 0,N=M-K,O=V-H,$=B-M,Y=D-V,P=K-B,o=H-D,U=L-B,Q=W-D,aa=L-K,T=W-H,J=L-M,ra=W-V,N=N*T-O*aa,P=P*Q-o*U,$=$*ra-Y*J;if(N>=0&&$>=0&&P>=0){w=!1;break a}}w=
+K=void 0,H=void 0,M=void 0,V=void 0,L=void 0,W=void 0,B=w[C[v]].x,D=w[C[v]].y,K=w[C[z]].x,H=w[C[z]].y,M=w[C[x]].x,V=w[C[x]].y;if(1.0E-10>(K-B)*(V-D)-(H-D)*(M-B))w=!1;else{for(A=0;A<y;A++)if(!(A==v||A==z||A==x)){var L=w[C[A]].x,W=w[C[A]].y,N=void 0,O=void 0,Z=void 0,Y=void 0,P=void 0,o=void 0,U=void 0,Q=void 0,aa=void 0,T=void 0,J=void 0,ra=void 0,N=Z=P=void 0,N=M-K,O=V-H,Z=B-M,Y=D-V,P=K-B,o=H-D,U=L-B,Q=W-D,aa=L-K,T=W-H,J=L-M,ra=W-V,N=N*T-O*aa,P=P*Q-o*U,Z=Z*ra-Y*J;if(N>=0&&Z>=0&&P>=0){w=!1;break a}}w=
 !0}}if(w){h.push([a[f[n]],a[f[u]],a[f[t]]]);l.push([f[n],f[u],f[t]]);n=u;for(t=u+1;t<k;n++,t++)f[n]=f[t];k--;p=2*k}}if(e)return l;return h};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,e,k){THREE.Geometry.call(this);this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=e||6;this.arc=k||Math.PI*2;k=new THREE.Vector3;a=[];c=[];for(b=0;b<=this.segmentsR;b++)for(e=0;e<=this.segmentsT;e++){var h=e/this.segmentsT*this.arc,f=b/this.segmentsR*Math.PI*2;k.x=this.radius*Math.cos(h);k.y=this.radius*Math.sin(h);var l=new THREE.Vector3;l.x=(this.radius+this.tube*Math.cos(f))*Math.cos(h);l.y=(this.radius+this.tube*Math.cos(f))*Math.sin(h);l.z=
 this.tube*Math.sin(f);this.vertices.push(new THREE.Vertex(l));a.push(new THREE.UV(e/this.segmentsT,1-b/this.segmentsR));c.push(l.clone().subSelf(k).normalize())}for(b=1;b<=this.segmentsR;b++)for(e=1;e<=this.segmentsT;e++){var k=(this.segmentsT+1)*b+e-1,h=(this.segmentsT+1)*(b-1)+e-1,f=(this.segmentsT+1)*(b-1)+e,l=(this.segmentsT+1)*b+e,n=new THREE.Face4(k,h,f,l,[c[k],c[h],c[f],c[l]]);n.normal.addSelf(c[k]);n.normal.addSelf(c[h]);n.normal.addSelf(c[f]);n.normal.addSelf(c[l]);n.normal.normalize();this.faces.push(n);
@@ -549,18 +552,18 @@ c,e,b,h)};a.onerror=function(a){alert("worker.onerror: "+a.message+"\n"+a.data);
 THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,c,b,e,k,h){var f=new XMLHttpRequest,l=e+"/"+a,n=0;f.onreadystatechange=function(){f.readyState==4?f.status==200||f.status==0?THREE.BinaryLoader.prototype.createBinModel(f.responseText,b,k,c):alert("Couldn't load ["+l+"] ["+f.status+"]"):f.readyState==3?h&&(n==0&&(n=f.getResponseHeader("Content-Length")),h({total:n,loaded:f.responseText.length})):f.readyState==2&&(n=f.getResponseHeader("Content-Length"))};f.open("GET",l,!0);f.overrideMimeType("text/plain; charset=x-user-defined");
 f.setRequestHeader("Content-Type","text/plain");f.send(null)};
 THREE.BinaryLoader.prototype.createBinModel=function(a,c,b,e){var k=function(b){function c(a,b){var e=t(a,b),h=t(a,b+1),f=t(a,b+2),k=t(a,b+3),l=(k<<1&255|f>>7)-127;e|=(f&127)<<16|h<<8;if(e==0&&l==-127)return 0;return(1-2*(k>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,l)}function k(a,b){var c=t(a,b),e=t(a,b+1),h=t(a,b+2);return(t(a,b+3)<<24)+(h<<16)+(e<<8)+c}function n(a,b){var c=t(a,b);return(t(a,b+1)<<8)+c}function u(a,b){var c=t(a,b);return c>127?c-256:c}function t(a,b){return a.charCodeAt(b)&255}function p(b){var c,
-e,h;c=k(a,b);e=k(a,b+H);h=k(a,b+M);b=n(a,b+V);C.faces.push(new THREE.Face3(c,e,h,null,null,b))}function w(b){var c,e,h,f,o,p,u;c=k(a,b);e=k(a,b+H);h=k(a,b+M);f=n(a,b+V);o=k(a,b+L);p=k(a,b+W);u=k(a,b+N);var b=D[p*3],t=D[p*3+1];p=D[p*3+2];var v=D[u*3],x=D[u*3+1];u=D[u*3+2];C.faces.push(new THREE.Face3(c,e,h,[new THREE.Vector3(D[o*3],D[o*3+1],D[o*3+2]),new THREE.Vector3(b,t,p),new THREE.Vector3(v,x,u)],null,f))}function v(b){var c,e,h,f;c=k(a,b);e=k(a,b+O);h=k(a,b+$);f=k(a,b+Y);b=n(a,b+P);C.faces.push(new THREE.Face4(c,
-e,h,f,null,null,b))}function z(b){var c,e,h,f,p,u,t,v,x;c=k(a,b);e=k(a,b+O);h=k(a,b+$);f=k(a,b+Y);p=n(a,b+P);u=k(a,b+o);t=k(a,b+U);v=k(a,b+Q);x=k(a,b+aa);var b=D[t*3],w=D[t*3+1];t=D[t*3+2];var F=D[v*3],y=D[v*3+1];v=D[v*3+2];var ia=D[x*3],G=D[x*3+1];x=D[x*3+2];C.faces.push(new THREE.Face4(c,e,h,f,[new THREE.Vector3(D[u*3],D[u*3+1],D[u*3+2]),new THREE.Vector3(b,w,t),new THREE.Vector3(F,y,v),new THREE.Vector3(ia,G,x)],null,p))}function x(b){var c,e,h,f;c=k(a,b);e=k(a,b+T);h=k(a,b+J);b=K[c*2];f=K[c*2+
+e,h;c=k(a,b);e=k(a,b+H);h=k(a,b+M);b=n(a,b+V);C.faces.push(new THREE.Face3(c,e,h,null,null,b))}function w(b){var c,e,h,f,o,p,u;c=k(a,b);e=k(a,b+H);h=k(a,b+M);f=n(a,b+V);o=k(a,b+L);p=k(a,b+W);u=k(a,b+N);var b=D[p*3],t=D[p*3+1];p=D[p*3+2];var v=D[u*3],x=D[u*3+1];u=D[u*3+2];C.faces.push(new THREE.Face3(c,e,h,[new THREE.Vector3(D[o*3],D[o*3+1],D[o*3+2]),new THREE.Vector3(b,t,p),new THREE.Vector3(v,x,u)],null,f))}function v(b){var c,e,h,f;c=k(a,b);e=k(a,b+O);h=k(a,b+Z);f=k(a,b+Y);b=n(a,b+P);C.faces.push(new THREE.Face4(c,
+e,h,f,null,null,b))}function z(b){var c,e,h,f,p,u,t,v,x;c=k(a,b);e=k(a,b+O);h=k(a,b+Z);f=k(a,b+Y);p=n(a,b+P);u=k(a,b+o);t=k(a,b+U);v=k(a,b+Q);x=k(a,b+aa);var b=D[t*3],w=D[t*3+1];t=D[t*3+2];var F=D[v*3],y=D[v*3+1];v=D[v*3+2];var ia=D[x*3],G=D[x*3+1];x=D[x*3+2];C.faces.push(new THREE.Face4(c,e,h,f,[new THREE.Vector3(D[u*3],D[u*3+1],D[u*3+2]),new THREE.Vector3(b,w,t),new THREE.Vector3(F,y,v),new THREE.Vector3(ia,G,x)],null,p))}function x(b){var c,e,h,f;c=k(a,b);e=k(a,b+T);h=k(a,b+J);b=K[c*2];f=K[c*2+
 1];c=K[e*2];var n=C.faceVertexUvs[0];e=K[e*2+1];var o=K[h*2];h=K[h*2+1];var p=[];p.push(new THREE.UV(b,f));p.push(new THREE.UV(c,e));p.push(new THREE.UV(o,h));n.push(p)}function y(b){var c,e,h,f,n,o;c=k(a,b);e=k(a,b+ra);h=k(a,b+pa);f=k(a,b+na);b=K[c*2];n=K[c*2+1];c=K[e*2];o=K[e*2+1];e=K[h*2];var p=C.faceVertexUvs[0];h=K[h*2+1];var u=K[f*2];f=K[f*2+1];var t=[];t.push(new THREE.UV(b,n));t.push(new THREE.UV(c,o));t.push(new THREE.UV(e,h));t.push(new THREE.UV(u,f));p.push(t)}var C=this,A=0,B,D=[],K=[],
-H,M,V,L,W,N,O,$,Y,P,o,U,Q,aa,T,J,ra,pa,na,qa,ja,la,ea,ca,Z;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(C,e,b);B={signature:a.substr(A,8),header_bytes:t(a,A+8),vertex_coordinate_bytes:t(a,A+9),normal_coordinate_bytes:t(a,A+10),uv_coordinate_bytes:t(a,A+11),vertex_index_bytes:t(a,A+12),normal_index_bytes:t(a,A+13),uv_index_bytes:t(a,A+14),material_index_bytes:t(a,A+15),nvertices:k(a,A+16),nnormals:k(a,A+16+4),nuvs:k(a,A+16+8),ntri_flat:k(a,A+16+12),ntri_smooth:k(a,A+16+16),ntri_flat_uv:k(a,
-A+16+20),ntri_smooth_uv:k(a,A+16+24),nquad_flat:k(a,A+16+28),nquad_smooth:k(a,A+16+32),nquad_flat_uv:k(a,A+16+36),nquad_smooth_uv:k(a,A+16+40)};A+=B.header_bytes;H=B.vertex_index_bytes;M=B.vertex_index_bytes*2;V=B.vertex_index_bytes*3;L=B.vertex_index_bytes*3+B.material_index_bytes;W=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes;N=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*2;O=B.vertex_index_bytes;$=B.vertex_index_bytes*2;Y=B.vertex_index_bytes*3;P=B.vertex_index_bytes*
-4;o=B.vertex_index_bytes*4+B.material_index_bytes;U=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes;Q=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*2;aa=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*3;T=B.uv_index_bytes;J=B.uv_index_bytes*2;ra=B.uv_index_bytes;pa=B.uv_index_bytes*2;na=B.uv_index_bytes*3;b=B.vertex_index_bytes*3+B.material_index_bytes;Z=B.vertex_index_bytes*4+B.material_index_bytes;qa=B.ntri_flat*b;ja=B.ntri_smooth*(b+B.normal_index_bytes*
-3);la=B.ntri_flat_uv*(b+B.uv_index_bytes*3);ea=B.ntri_smooth_uv*(b+B.normal_index_bytes*3+B.uv_index_bytes*3);ca=B.nquad_flat*Z;b=B.nquad_smooth*(Z+B.normal_index_bytes*4);Z=B.nquad_flat_uv*(Z+B.uv_index_bytes*4);A+=function(b){for(var e,h,k,l=B.vertex_coordinate_bytes*3,n=b+B.nvertices*l;b<n;b+=l)e=c(a,b),h=c(a,b+B.vertex_coordinate_bytes),k=c(a,b+B.vertex_coordinate_bytes*2),C.vertices.push(new THREE.Vertex(new THREE.Vector3(e,h,k)));return B.nvertices*l}(A);A+=function(b){for(var c,e,h,f=B.normal_coordinate_bytes*
-3,k=b+B.nnormals*f;b<k;b+=f)c=u(a,b),e=u(a,b+B.normal_coordinate_bytes),h=u(a,b+B.normal_coordinate_bytes*2),D.push(c/127,e/127,h/127);return B.nnormals*f}(A);A+=function(b){for(var e,h,k=B.uv_coordinate_bytes*2,l=b+B.nuvs*k;b<l;b+=k)e=c(a,b),h=c(a,b+B.uv_coordinate_bytes),K.push(e,h);return B.nuvs*k}(A);qa=A+qa;ja=qa+ja;la=ja+la;ea=la+ea;ca=ea+ca;b=ca+b;Z=b+Z;(function(a){var b,c=B.vertex_index_bytes*3+B.material_index_bytes,e=c+B.uv_index_bytes*3,h=a+B.ntri_flat_uv*e;for(b=a;b<h;b+=e)p(b),x(b+c);
+H,M,V,L,W,N,O,Z,Y,P,o,U,Q,aa,T,J,ra,pa,na,qa,ja,la,ea,ca,$;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(C,e,b);B={signature:a.substr(A,8),header_bytes:t(a,A+8),vertex_coordinate_bytes:t(a,A+9),normal_coordinate_bytes:t(a,A+10),uv_coordinate_bytes:t(a,A+11),vertex_index_bytes:t(a,A+12),normal_index_bytes:t(a,A+13),uv_index_bytes:t(a,A+14),material_index_bytes:t(a,A+15),nvertices:k(a,A+16),nnormals:k(a,A+16+4),nuvs:k(a,A+16+8),ntri_flat:k(a,A+16+12),ntri_smooth:k(a,A+16+16),ntri_flat_uv:k(a,
+A+16+20),ntri_smooth_uv:k(a,A+16+24),nquad_flat:k(a,A+16+28),nquad_smooth:k(a,A+16+32),nquad_flat_uv:k(a,A+16+36),nquad_smooth_uv:k(a,A+16+40)};A+=B.header_bytes;H=B.vertex_index_bytes;M=B.vertex_index_bytes*2;V=B.vertex_index_bytes*3;L=B.vertex_index_bytes*3+B.material_index_bytes;W=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes;N=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*2;O=B.vertex_index_bytes;Z=B.vertex_index_bytes*2;Y=B.vertex_index_bytes*3;P=B.vertex_index_bytes*
+4;o=B.vertex_index_bytes*4+B.material_index_bytes;U=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes;Q=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*2;aa=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*3;T=B.uv_index_bytes;J=B.uv_index_bytes*2;ra=B.uv_index_bytes;pa=B.uv_index_bytes*2;na=B.uv_index_bytes*3;b=B.vertex_index_bytes*3+B.material_index_bytes;$=B.vertex_index_bytes*4+B.material_index_bytes;qa=B.ntri_flat*b;ja=B.ntri_smooth*(b+B.normal_index_bytes*
+3);la=B.ntri_flat_uv*(b+B.uv_index_bytes*3);ea=B.ntri_smooth_uv*(b+B.normal_index_bytes*3+B.uv_index_bytes*3);ca=B.nquad_flat*$;b=B.nquad_smooth*($+B.normal_index_bytes*4);$=B.nquad_flat_uv*($+B.uv_index_bytes*4);A+=function(b){for(var e,h,k,l=B.vertex_coordinate_bytes*3,n=b+B.nvertices*l;b<n;b+=l)e=c(a,b),h=c(a,b+B.vertex_coordinate_bytes),k=c(a,b+B.vertex_coordinate_bytes*2),C.vertices.push(new THREE.Vertex(new THREE.Vector3(e,h,k)));return B.nvertices*l}(A);A+=function(b){for(var c,e,h,f=B.normal_coordinate_bytes*
+3,k=b+B.nnormals*f;b<k;b+=f)c=u(a,b),e=u(a,b+B.normal_coordinate_bytes),h=u(a,b+B.normal_coordinate_bytes*2),D.push(c/127,e/127,h/127);return B.nnormals*f}(A);A+=function(b){for(var e,h,k=B.uv_coordinate_bytes*2,l=b+B.nuvs*k;b<l;b+=k)e=c(a,b),h=c(a,b+B.uv_coordinate_bytes),K.push(e,h);return B.nuvs*k}(A);qa=A+qa;ja=qa+ja;la=ja+la;ea=la+ea;ca=ea+ca;b=ca+b;$=b+$;(function(a){var b,c=B.vertex_index_bytes*3+B.material_index_bytes,e=c+B.uv_index_bytes*3,h=a+B.ntri_flat_uv*e;for(b=a;b<h;b+=e)p(b),x(b+c);
 return h-a})(ja);(function(a){var b,c=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*3,e=c+B.uv_index_bytes*3,h=a+B.ntri_smooth_uv*e;for(b=a;b<h;b+=e)w(b),x(b+c);return h-a})(la);(function(a){var b,c=B.vertex_index_bytes*4+B.material_index_bytes,e=c+B.uv_index_bytes*4,h=a+B.nquad_flat_uv*e;for(b=a;b<h;b+=e)v(b),y(b+c);return h-a})(b);(function(a){var b,c=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*4,e=c+B.uv_index_bytes*4,h=a+B.nquad_smooth_uv*e;for(b=a;b<
-h;b+=e)z(b),y(b+c);return h-a})(Z);(function(a){var b,c=B.vertex_index_bytes*3+B.material_index_bytes,e=a+B.ntri_flat*c;for(b=a;b<e;b+=c)p(b);return e-a})(A);(function(a){var b,c=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*3,e=a+B.ntri_smooth*c;for(b=a;b<e;b+=c)w(b);return e-a})(qa);(function(a){var b,c=B.vertex_index_bytes*4+B.material_index_bytes,e=a+B.nquad_flat*c;for(b=a;b<e;b+=c)v(b);return e-a})(ea);(function(a){var b,c=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*
+h;b+=e)z(b),y(b+c);return h-a})($);(function(a){var b,c=B.vertex_index_bytes*3+B.material_index_bytes,e=a+B.ntri_flat*c;for(b=a;b<e;b+=c)p(b);return e-a})(A);(function(a){var b,c=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*3,e=a+B.ntri_smooth*c;for(b=a;b<e;b+=c)w(b);return e-a})(qa);(function(a){var b,c=B.vertex_index_bytes*4+B.material_index_bytes,e=a+B.nquad_flat*c;for(b=a;b<e;b+=c)v(b);return e-a})(ea);(function(a){var b,c=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*
 4,e=a+B.nquad_smooth*c;for(b=a;b<e;b+=c)z(b);return e-a})(ca);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};k.prototype=new THREE.Geometry;k.prototype.constructor=k;c(new k(b))};
-THREE.ColladaLoader=function(){function a(a,e,k){ja=a;e=e||ca;k!==void 0&&(a=k.split("/"),a.pop(),Ea=a.length<1?"":a.join("/")+"/");ga=c("//dae:library_images/dae:image",f,"image");ka=c("//dae:library_materials/dae:material",V,"material");sa=c("//dae:library_effects/dae:effect",$,"effect");ma=c("//dae:library_geometries/dae:geometry",y,"geometry");oa=c("//dae:library_controllers/dae:controller",l,"controller");ha=c("//dae:library_animations/dae:animation",P,"animation");Da=c(".//dae:library_visual_scenes/dae:visual_scene",
+THREE.ColladaLoader=function(){function a(a,e,k){ja=a;e=e||ca;k!==void 0&&(a=k.split("/"),a.pop(),Ea=a.length<1?"":a.join("/")+"/");ga=c("//dae:library_images/dae:image",f,"image");ka=c("//dae:library_materials/dae:material",V,"material");sa=c("//dae:library_effects/dae:effect",Z,"effect");ma=c("//dae:library_geometries/dae:geometry",y,"geometry");oa=c("//dae:library_controllers/dae:controller",l,"controller");ha=c("//dae:library_animations/dae:animation",P,"animation");Da=c(".//dae:library_visual_scenes/dae:visual_scene",
 t,"visual_scene");Ca=[];Fa=[];(a=ja.evaluate(".//dae:scene/dae:instance_visual_scene",ja,aa,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),ea=Da[a]):ea=null;la=new THREE.Object3D;for(a=0;a<ea.nodes.length;a++)la.add(h(ea.nodes[a]));b();for(var n in ha);n={scene:la,morphs:Ca,skins:Fa,dae:{images:ga,materials:ka,effects:sa,geometries:ma,controllers:oa,animations:ha,visualScenes:Da,scene:ea}};e&&e(n);return n}function c(a,b,c){for(var a=ja.evaluate(a,
 ja,aa,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),e={},h=a.iterateNext(),f=0;h;){h=(new b).parse(h);if(h.id.length==0)h.id=c+f++;e[h.id]=h;h=a.iterateNext()}return e}function b(){var a=1E6,b=-a,c=0,e;for(e in ha)for(var h=ha[e],f=0;f<h.sampler.length;f++){var k=h.sampler[f];k.create();a=Math.min(a,k.startTime);b=Math.max(b,k.endTime);c=Math.max(c,k.input.length)}return{start:a,end:b,frames:c}}function e(a,b,c,h){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)}h&&a.world.multiply(h,a.world);b.push(a);for(h=0;h<a.nodes.length;h++)e(a.nodes[h],b,c,a.world)}function k(a,c,h){var f=oa[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 k=b(),c=ea.getChildById(c.skeleton[0],!0)||ea.getChildBySid(c.skeleton[0],!0),l,n,o,p,u=new THREE.Vector3,
@@ -573,10 +576,10 @@ else{p=p.morph;for(u=0;u<p.targets.length;u++){var w=ma[p.targets[u]];if(w.mesh&
 b.scale);for(f=0;f<a.nodes.length;f++)b.add(h(a.nodes[f],a));return b}function f(){this.init_from=this.id=""}function l(){this.type=this.name=this.id="";this.morph=this.skin=null}function n(){this.weights=this.targets=this.source=this.method=null}function u(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];this.joints=[];this.weights=[]}function t(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function p(){this.sid=this.name=this.id="";this.nodes=[];this.controllers=
 [];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function w(){this.type=this.sid="";this.data=[];this.matrix=new THREE.Matrix4}function v(){this.url="";this.skeleton=[];this.instance_material=[]}function z(){this.target=this.symbol=""}function x(){this.url="";this.instance_material=[]}function y(){this.id="";this.mesh=null}function C(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function A(){}function B(){this.material="";this.count=
 0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function D(){this.source="";this.stride=this.count=0;this.params=[]}function K(){this.input={}}function H(){this.semantic="";this.offset=0;this.source="";this.set=0}function M(a){this.id=a;this.type=null}function V(){this.name=this.id="";this.instance_effect=null}function L(){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 W(a,
-b){this.type=a;this.effect=b;this.material=null}function N(a){this.effect=a;this.format=this.init_from=null}function O(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function $(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function Y(){this.url=""}function P(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function o(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=
-this.dotSyntax=this.sid=null}function U(a){this.id="";this.animation=a;this.inputs=[];this.endTime=this.startTime=this.interpolation=this.output=this.input=null;this.duration=0}function Q(a){var b=a.getAttribute("id");if(Z[b]!=void 0)return Z[b];Z[b]=(new M(b)).parse(a);return Z[b]}function aa(a){if(a=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function T(a){for(var a=ra(a),b=[],c=0;c<a.length;c++)b.push(parseFloat(a[c]));return b}function J(a){for(var a=ra(a),b=[],c=0;c<
+b){this.type=a;this.effect=b;this.material=null}function N(a){this.effect=a;this.format=this.init_from=null}function O(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function Z(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function Y(){this.url=""}function P(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function o(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=
+this.dotSyntax=this.sid=null}function U(a){this.id="";this.animation=a;this.inputs=[];this.endTime=this.startTime=this.interpolation=this.output=this.input=null;this.duration=0}function Q(a){var b=a.getAttribute("id");if($[b]!=void 0)return $[b];$[b]=(new M(b)).parse(a);return $[b]}function aa(a){if(a=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function T(a){for(var a=ra(a),b=[],c=0;c<a.length;c++)b.push(parseFloat(a[c]));return b}function J(a){for(var a=ra(a),b=[],c=0;c<
 a.length;c++)b.push(parseInt(a[c],10));return b}function ra(a){return a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/)}function pa(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function na(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 qa(a,b){var c="";c+=na(a.x,b)+",";c+=na(a.y,b)+",";c+=na(a.z,b);return c}var ja=null,la=null,ea,ca=
-null,Z={},ga={},ha={},oa={},ma={},ka={},sa={},Da,Ea,Ca,Fa,za=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};l.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 u).parse(c);this.type=
+null,$={},ga={},ha={},oa={},ma={},ka={},sa={},Da,Ea,Ca,Fa,za=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};l.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 u).parse(c);this.type=
 c.nodeName;break;case "morph":this.morph=(new n).parse(c),this.type=c.nodeName}}return this};n.prototype.parse=function(a){var b={},c=[],e;this.method=a.getAttribute("method");this.source=a.getAttribute("source").replace(/^#/,"");for(e=0;e<a.childNodes.length;e++){var h=a.childNodes[e];if(h.nodeType==1)switch(h.nodeName){case "source":h=(new M).parse(h);b[h.id]=h;break;case "targets":c=this.parseInputs(h);break;default:console.log(h.nodeName)}}for(e=0;e<c.length;e++)switch(a=c[e],h=b[a.source],a.semantic){case "MORPH_TARGET":this.targets=
 h.read();break;case "MORPH_WEIGHT":this.weights=h.read()}return this};n.prototype.parseInputs=function(a){for(var b=[],c=0;c<a.childNodes.length;c++){var e=a.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "input":b.push((new H).parse(e))}}return b};u.prototype.parse=function(a){var b={},c,e;this.source=a.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var h=0;h<a.childNodes.length;h++){var f=a.childNodes[h];if(f.nodeType==1)switch(f.nodeName){case "bind_shape_matrix":f=
 T(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 M).parse(f);b[f.id]=f;break;case "joints":c=f;break;case "vertex_weights":e=f;break;default:console.log(f.nodeName)}}this.parseJoints(c,b);this.parseWeights(e,b);return this};u.prototype.parseJoints=function(a,b){for(var c=0;c<a.childNodes.length;c++){var e=a.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "input":var e=
@@ -593,9 +596,9 @@ w.prototype.updateMatrix=function(){var a=0;this.matrix.identity();switch(this.t
 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};v.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=ja.evaluate(".//dae:instance_material",c,aa,XPathResult.ORDERED_NODE_ITERATOR_TYPE,
 null))for(var e=c.iterateNext();e;)this.instance_material.push((new z).parse(e)),e=c.iterateNext()}}return this};z.prototype.parse=function(a){this.symbol=a.getAttribute("symbol");this.target=a.getAttribute("target").replace(/^#/,"");return this};x.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=ja.evaluate(".//dae:instance_material",
 c,aa,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(b=a.iterateNext();b;)this.instance_material.push((new z).parse(b)),b=a.iterateNext();break}}return this};y.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 C(this)).parse(c)}}return this};C.prototype.parse=function(a){function b(a,c){var e=qa(a.position);h[e]===void 0&&(h[e]={v:a,index:c});return h[e]}this.primitives=[];var c;for(c=
-0;c<a.childNodes.length;c++){var e=a.childNodes[c];switch(e.nodeName){case "source":Q(e);break;case "vertices":this.vertices=(new K).parse(e);break;case "triangles":this.primitives.push((new B).parse(e));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new A).parse(e))}}var h={};this.geometry3js=new THREE.Geometry;e=Z[this.vertices.input.POSITION.source].data;for(a=c=0;c<e.length;c+=3,a++){var f=new THREE.Vertex(new THREE.Vector3(e[c],e[c+
+0;c<a.childNodes.length;c++){var e=a.childNodes[c];switch(e.nodeName){case "source":Q(e);break;case "vertices":this.vertices=(new K).parse(e);break;case "triangles":this.primitives.push((new B).parse(e));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new A).parse(e))}}var h={};this.geometry3js=new THREE.Geometry;e=$[this.vertices.input.POSITION.source].data;for(a=c=0;c<e.length;c+=3,a++){var f=new THREE.Vertex(new THREE.Vector3(e[c],e[c+
 1],e[c+2]));b(f,a);this.geometry3js.vertices.push(f)}for(c=0;c<this.primitives.length;c++)primitive=this.primitives[c],primitive.setVertices(this.vertices),this.handlePrimitive(primitive,this.geometry3js,h);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();return this};C.prototype.handlePrimitive=function(a,b,c){var e=0,h,f,k=a.p,l=a.inputs,n,o,p,u=0,t=3,v=[];for(h=0;h<l.length;h++)switch(n=l[h],
-n.semantic){case "TEXCOORD":v.push(n.set)}for(;e<k.length;){var w=[],x=[],y={},z=[];a.vcount&&(t=a.vcount[u++]);for(h=0;h<t;h++)for(f=0;f<l.length;f++)switch(n=l[f],source=Z[n.source],o=k[e+h*l.length+n.offset],numParams=source.accessor.params.length,p=o*numParams,n.semantic){case "VERTEX":n=qa(b.vertices[o].position);w.push(c[n].index);break;case "NORMAL":x.push(new THREE.Vector3(source.data[p],source.data[p+1],source.data[p+2]));break;case "TEXCOORD":y[n.set]===void 0&&(y[n.set]=[]);y[n.set].push(new THREE.UV(source.data[p],
+n.semantic){case "TEXCOORD":v.push(n.set)}for(;e<k.length;){var w=[],x=[],y={},z=[];a.vcount&&(t=a.vcount[u++]);for(h=0;h<t;h++)for(f=0;f<l.length;f++)switch(n=l[f],source=$[n.source],o=k[e+h*l.length+n.offset],numParams=source.accessor.params.length,p=o*numParams,n.semantic){case "VERTEX":n=qa(b.vertices[o].position);w.push(c[n].index);break;case "NORMAL":x.push(new THREE.Vector3(source.data[p],source.data[p+1],source.data[p+2]));break;case "TEXCOORD":y[n.set]===void 0&&(y[n.set]=[]);y[n.set].push(new THREE.UV(source.data[p],
 source.data[p+1]));break;case "COLOR":z.push((new THREE.Color).setRGB(source.data[p],source.data[p+1],source.data[p+2]))}var A;t==3?A=new THREE.Face3(w[0],w[1],w[2],[x[0],x[1],x[2]],z.length?z:new THREE.Color):t==4&&(A=new THREE.Face4(w[0],w[1],w[2],w[3],[x[0],x[1],x[2],x[3]],z.length?z:new THREE.Color));A.daeMaterial=a.material;b.faces.push(A);for(f=0;f<v.length;f++)h=y[v[f]],b.faceVertexUvs[f].push([h[0],h[1],h[2]]);e+=l.length*t}};A.prototype=new B;A.prototype.constructor=A;B.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};B.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=pa(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 H).parse(a.childNodes[b]));break;case "vcount":this.vcount=J(c.textContent);break;case "p":this.p=J(c.textContent)}}return this};D.prototype.parse=
 function(a){this.params=[];this.source=a.getAttribute("source");this.count=pa(a,"count",0);this.stride=pa(a,"stride",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeName=="param"){var e={};e.name=c.getAttribute("name");e.type=c.getAttribute("type");this.params.push(e)}}return this};K.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++)a.childNodes[b].nodeName=="input"&&(input=(new H).parse(a.childNodes[b]),this.input[input.semantic]=
@@ -607,9 +610,9 @@ this.texcoord=c.getAttribute("texcoord")}}return this};W.prototype.parse=functio
 e=f;e.length>0&&(this[c.nodeName]=parseFloat(e[0].textContent))}}this.create();return this};W.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 e=this[c];if(e instanceof L)if(e.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(e=ga[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(Ea+e.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=e.color.getHex():b||(a[c]=e.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=za;return this.material=new THREE.MeshLambertMaterial(a)};N.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};O.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};$.prototype.create=function(){if(this.shader==null)return null};$.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};$.prototype.parseNewparam=
-function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var e=a.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "surface":this.surface=(new N(this)).parse(e);this.surface.sid=b;break;case "sampler2D":this.sampler=(new O(this)).parse(e);this.sampler.sid=b;break;case "extra":break;default:console.log(e.nodeName)}}};$.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var e=a.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "profile_COMMON":this.parseProfileCOMMON(e);
-break;case "technique":b=e;break;case "newparam":this.parseNewparam(e);break;case "extra":break;default:console.log(e.nodeName)}}return b};$.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 W(c.nodeName,this)).parse(c)}}};Y.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};P.prototype.parse=function(a){this.id=a.getAttribute("id");
+break;case "wrap_t":this.wrap_t=c.textContent;break;default:console.log("unhandled Sampler2D prop: "+c.nodeName)}}return this};Z.prototype.create=function(){if(this.shader==null)return null};Z.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};Z.prototype.parseNewparam=
+function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var e=a.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "surface":this.surface=(new N(this)).parse(e);this.surface.sid=b;break;case "sampler2D":this.sampler=(new O(this)).parse(e);this.sampler.sid=b;break;case "extra":break;default:console.log(e.nodeName)}}};Z.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var e=a.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "profile_COMMON":this.parseProfileCOMMON(e);
+break;case "technique":b=e;break;case "newparam":this.parseNewparam(e);break;case "extra":break;default:console.log(e.nodeName)}}return b};Z.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 W(c.nodeName,this)).parse(c)}}};Y.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};P.prototype.parse=function(a){this.id=a.getAttribute("id");
 this.name=a.getAttribute("name");this.source={};for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "source":c=(new M).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new U(this)).parse(c));break;case "channel":this.channel.push((new o(this)).parse(c))}}return this};o.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,e=a.indexOf("(")>=0,h,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(e){h=a.split("(");a=h.shift();for(b=0;b<h.length;b++)h[b]=parseInt(h[b].replace(/\)/,""))}this.sid=a;this.dotSyntax=c;this.arrSyntax=e;this.arrIndices=h;this.member=f;return this};U.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 H).parse(c))}}return this};
 U.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=
@@ -626,17 +629,17 @@ THREE.SceneLoader.prototype={load:function(a,c){var b=this,e=new Worker(a);e.pos
 s=A.scale;q=0;W.length==0&&(W=new THREE.MeshFaceMaterial);W.length>1&&(W=new THREE.MeshFaceMaterial);object=new THREE.Mesh(H,W);object.name=v;object.position.set(B[0],B[1],B[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible;Q.scene.add(object);Q.objects[v]=object;A.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),Q.scene.collisions.colliders.push(a));if(A.castsShadow)a=
 new THREE.ShadowVolume(H),Q.scene.add(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;A.trigger&&A.trigger.toLowerCase()!="none"&&(a={type:A.trigger,object:A},Q.triggers[object.name]=a)}}else B=A.position,r=A.rotation,q=A.quaternion,s=A.scale,q=0,object=new THREE.Object3D,object.name=v,object.position.set(B[0],B[1],B[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],s[1],s[2]),object.visible=
 A.visible!==void 0?A.visible:!1,Q.scene.add(object),Q.objects[v]=object,Q.empties[v]=object,A.trigger&&A.trigger.toLowerCase()!="none"&&(a={type:A.trigger,object:A},Q.triggers[object.name]=a)}function n(a){return function(c){Q.geometries[a]=c;l();Y-=1;b.onLoadComplete();t()}}function u(a){return function(b){Q.geometries[a]=b}}function t(){b.callbackProgress({totalModels:o,totalTextures:U,loadedModels:o-Y,loadedTextures:U-P},Q);b.onLoadProgress();Y==0&&P==0&&c(Q)}var p,w,v,z,x,y,C,A,B,D,K,H,M,V,L,
-W,N,O,$,Y,P,o,U,Q;O=a.data;L=new THREE.BinaryLoader;$=new THREE.JSONLoader;P=Y=0;Q={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(v in O.objects)if(A=O.objects[v],A.meshCollider){a=!0;break}if(a)Q.scene.collisions=new THREE.CollisionSystem;if(O.transform){a=O.transform.position;D=O.transform.rotation;var aa=O.transform.scale;a&&Q.scene.position.set(a[0],a[1],a[2]);D&&Q.scene.rotation.set(D[0],D[1],D[2]);aa&&Q.scene.scale.set(aa[0],
+W,N,O,Z,Y,P,o,U,Q;O=a.data;L=new THREE.BinaryLoader;Z=new THREE.JSONLoader;P=Y=0;Q={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(v in O.objects)if(A=O.objects[v],A.meshCollider){a=!0;break}if(a)Q.scene.collisions=new THREE.CollisionSystem;if(O.transform){a=O.transform.position;D=O.transform.rotation;var aa=O.transform.scale;a&&Q.scene.position.set(a[0],a[1],a[2]);D&&Q.scene.rotation.set(D[0],D[1],D[2]);aa&&Q.scene.scale.set(aa[0],
 aa[1],aa[2]);(a||D||aa)&&Q.scene.updateMatrix()}a=function(){P-=1;t();b.onLoadComplete()};for(x in O.cameras)D=O.cameras[x],D.type=="perspective"?M=new THREE.PerspectiveCamera(D.fov,D.aspect,D.near,D.far):D.type=="ortho"&&(M=new THREE.OrthographicCamera(D.left,D.right,D.top,D.bottom,D.near,D.far)),B=D.position,D=D.target,M.position.set(B[0],B[1],B[2]),M.target=new THREE.Vector3(D[0],D[1],D[2]),Q.cameras[x]=M;for(z in O.lights)x=O.lights[z],M=x.color!==void 0?x.color:16777215,D=x.intensity!==void 0?
 x.intensity:1,x.type=="directional"?(B=x.direction,N=new THREE.DirectionalLight(M,D),N.position.set(B[0],B[1],B[2]),N.position.normalize()):x.type=="point"?(B=x.position,d=x.distance,N=new THREE.PointLight(M,D,d),N.position.set(B[0],B[1],B[2])):x.type=="ambient"&&(N=new THREE.AmbientLight(M)),Q.scene.add(N),Q.lights[z]=N;for(y in O.fogs)z=O.fogs[y],z.type=="linear"?V=new THREE.Fog(0,z.near,z.far):z.type=="exp2"&&(V=new THREE.FogExp2(0,z.density)),D=z.color,V.color.setRGB(D[0],D[1],D[2]),Q.fogs[y]=
 V;if(Q.cameras&&O.defaults.camera)Q.currentCamera=Q.cameras[O.defaults.camera];if(Q.fogs&&O.defaults.fog)Q.scene.fog=Q.fogs[O.defaults.fog];D=O.defaults.bgcolor;Q.bgColor=new THREE.Color;Q.bgColor.setRGB(D[0],D[1],D[2]);Q.bgColorAlpha=O.defaults.bgalpha;for(p in O.geometries)if(y=O.geometries[p],y.type=="bin_mesh"||y.type=="ascii_mesh")Y+=1,b.onLoadStart();o=Y;for(p in O.geometries)y=O.geometries[p],y.type=="cube"?(H=new THREE.CubeGeometry(y.width,y.height,y.depth,y.segmentsWidth,y.segmentsHeight,
 y.segmentsDepth,null,y.flipped,y.sides),Q.geometries[p]=H):y.type=="plane"?(H=new THREE.PlaneGeometry(y.width,y.height,y.segmentsWidth,y.segmentsHeight),Q.geometries[p]=H):y.type=="sphere"?(H=new THREE.SphereGeometry(y.radius,y.segmentsWidth,y.segmentsHeight),Q.geometries[p]=H):y.type=="cylinder"?(H=new THREE.CylinderGeometry(y.topRad,y.botRad,y.height,y.radSegs,y.heightSegs),Q.geometries[p]=H):y.type=="torus"?(H=new THREE.TorusGeometry(y.radius,y.tube,y.segmentsR,y.segmentsT),Q.geometries[p]=H):
-y.type=="icosahedron"?(H=new THREE.IcosahedronGeometry(y.subdivisions),Q.geometries[p]=H):y.type=="bin_mesh"?L.load(e(y.url,O.urlBaseType),n(p)):y.type=="ascii_mesh"?$.load(e(y.url,O.urlBaseType),n(p)):y.type=="embedded_mesh"&&(y=O.embeds[y.id])&&$.createModel(y,u(p),"");for(C in O.textures)if(p=O.textures[C],p.url instanceof Array){P+=p.url.length;for(L=0;L<p.url.length;L++)b.onLoadStart()}else P+=1,b.onLoadStart();U=P;for(C in O.textures){p=O.textures[C];if(p.mapping!=void 0&&THREE[p.mapping]!=
+y.type=="icosahedron"?(H=new THREE.IcosahedronGeometry(y.subdivisions),Q.geometries[p]=H):y.type=="bin_mesh"?L.load(e(y.url,O.urlBaseType),n(p)):y.type=="ascii_mesh"?Z.load(e(y.url,O.urlBaseType),n(p)):y.type=="embedded_mesh"&&(y=O.embeds[y.id])&&Z.createModel(y,u(p),"");for(C in O.textures)if(p=O.textures[C],p.url instanceof Array){P+=p.url.length;for(L=0;L<p.url.length;L++)b.onLoadStart()}else P+=1,b.onLoadStart();U=P;for(C in O.textures){p=O.textures[C];if(p.mapping!=void 0&&THREE[p.mapping]!=
 void 0)p.mapping=new THREE[p.mapping];if(p.url instanceof Array){L=[];for(var T=0;T<p.url.length;T++)L[T]=e(p.url[T],O.urlBaseType);L=THREE.ImageUtils.loadTextureCube(L,p.mapping,a)}else{L=THREE.ImageUtils.loadTexture(e(p.url,O.urlBaseType),p.mapping,a);if(THREE[p.minFilter]!=void 0)L.minFilter=THREE[p.minFilter];if(THREE[p.magFilter]!=void 0)L.magFilter=THREE[p.magFilter];if(p.repeat){L.repeat.set(p.repeat[0],p.repeat[1]);if(p.repeat[0]!=1)L.wrapS=THREE.RepeatWrapping;if(p.repeat[1]!=1)L.wrapT=THREE.RepeatWrapping}p.offset&&
-L.offset.set(p.offset[0],p.offset[1]);if(p.wrap){$={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if($[p.wrap[0]]!==void 0)L.wrapS=$[p.wrap[0]];if($[p.wrap[1]]!==void 0)L.wrapT=$[p.wrap[1]]}}Q.textures[C]=L}for(w in O.materials){C=O.materials[w];for(K in C.parameters)if(K=="envMap"||K=="map"||K=="lightMap")C.parameters[K]=Q.textures[C.parameters[K]];else if(K=="shading")C.parameters[K]=C.parameters[K]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(K=="blending")C.parameters[K]=
+L.offset.set(p.offset[0],p.offset[1]);if(p.wrap){Z={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(Z[p.wrap[0]]!==void 0)L.wrapS=Z[p.wrap[0]];if(Z[p.wrap[1]]!==void 0)L.wrapT=Z[p.wrap[1]]}}Q.textures[C]=L}for(w in O.materials){C=O.materials[w];for(K in C.parameters)if(K=="envMap"||K=="map"||K=="lightMap")C.parameters[K]=Q.textures[C.parameters[K]];else if(K=="shading")C.parameters[K]=C.parameters[K]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(K=="blending")C.parameters[K]=
 THREE[C.parameters[K]]?THREE[C.parameters[K]]:THREE.NormalBlending;else if(K=="combine")C.parameters[K]=C.parameters[K]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(K=="vertexColors")if(C.parameters[K]=="face")C.parameters[K]=THREE.FaceColors;else if(C.parameters[K])C.parameters[K]=THREE.VertexColors;if(C.parameters.opacity!==void 0&&C.parameters.opacity<1)C.parameters.transparent=!0;if(C.parameters.normalMap){p=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(p.uniforms);
-L=C.parameters.color;$=C.parameters.specular;y=C.parameters.ambient;V=C.parameters.shininess;a.tNormal.texture=Q.textures[C.parameters.normalMap];if(C.parameters.normalMapFactor)a.uNormalScale.value=C.parameters.normalMapFactor;if(C.parameters.map)a.tDiffuse.texture=C.parameters.map,a.enableDiffuse.value=!0;if(C.parameters.lightMap)a.tAO.texture=C.parameters.lightMap,a.enableAO.value=!0;if(C.parameters.specularMap)a.tSpecular.texture=Q.textures[C.parameters.specularMap],a.enableSpecular.value=!0;
-a.uDiffuseColor.value.setHex(L);a.uSpecularColor.value.setHex($);a.uAmbientColor.value.setHex(y);a.uShininess.value=V;if(C.parameters.opacity)a.uOpacity.value=C.parameters.opacity;C=new THREE.ShaderMaterial({fragmentShader:p.fragmentShader,vertexShader:p.vertexShader,uniforms:a,lights:!0,fog:!0})}else C=new THREE[C.type](C.parameters);Q.materials[w]=C}l();b.callbackSync(Q);t()}},constructor:THREE.SceneLoader};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;
+L=C.parameters.color;Z=C.parameters.specular;y=C.parameters.ambient;V=C.parameters.shininess;a.tNormal.texture=Q.textures[C.parameters.normalMap];if(C.parameters.normalMapFactor)a.uNormalScale.value=C.parameters.normalMapFactor;if(C.parameters.map)a.tDiffuse.texture=C.parameters.map,a.enableDiffuse.value=!0;if(C.parameters.lightMap)a.tAO.texture=C.parameters.lightMap,a.enableAO.value=!0;if(C.parameters.specularMap)a.tSpecular.texture=Q.textures[C.parameters.specularMap],a.enableSpecular.value=!0;
+a.uDiffuseColor.value.setHex(L);a.uSpecularColor.value.setHex(Z);a.uAmbientColor.value.setHex(y);a.uShininess.value=V;if(C.parameters.opacity)a.uOpacity.value=C.parameters.opacity;C=new THREE.ShaderMaterial({fragmentShader:p.fragmentShader,vertexShader:p.vertexShader,uniforms:a,lights:!0,fog:!0})}else C=new THREE[C.type](C.parameters);Q.materials[w]=C}l();b.callbackSync(Q);t()}},constructor:THREE.SceneLoader};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 e=new XMLHttpRequest,k=b.scale!==void 0?b.scale:1,h=b.offsetX!==void 0?b.offsetX:0,f=b.offsetY!==void 0?b.offsetY:0,l=b.offsetZ!==void 0?b.offsetZ:0;e.onreadystatechange=function(){e.readyState==4?e.status==200||e.status==0?THREE.UTF8Loader.prototype.createModel(e.responseText,
 c,k,h,f,l):alert("Couldn't load ["+a+"] ["+e.status+"]"):e.readyState!=3&&e.readyState==2&&e.getResponseHeader("Content-Length")};e.open("GET",a,!0);e.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),e=1,k=0;k<8;k++){for(var h=0,f=0;f<c;++f){var l=a.charCodeAt(f+e);h+=l>>1^-(l&1);b[8*f+k]=h}e+=c}c=a.length-e;h=new Uint16Array(c);for(k=f=0;k<c;k++)l=a.charCodeAt(k+e),h[k]=f-l,l==0&&f++;return[b,h]};
@@ -700,7 +703,7 @@ THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionU
 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);var c=this,b=this.setSize,e=this.render,k=new THREE.PerspectiveCamera,h=new THREE.PerspectiveCamera,f=new THREE.Matrix4,l=new THREE.Matrix4,n,u,t;k.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},p=new THREE.WebGLRenderTarget(512,512,a),w=new THREE.WebGLRenderTarget(512,512,a),v=new THREE.PerspectiveCamera(53,1,1,1E4);v.position.z=
 2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:p},mapRight:{type:"t",value:1,texture:w}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});
-var z=new THREE.Scene;z.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){b.call(c,a,e);p.width=a;p.height=e;w.width=a;w.height=e};this.render=function(a,b){b.update(null,!0);if(n!==b.aspect||u!==b.near||t!==b.fov){n=b.aspect;u=b.near;t=b.fov;var C=b.projectionMatrix.clone(),A=125/30*0.5,B=A*u/125,D=u*Math.tan(t*Math.PI/360),K;f.n14=A;l.n14=-A;A=-D*n+B;K=D*n+B;C.n11=2*u/(K-A);C.n13=(K+A)/(K-A);k.projectionMatrix=C.clone();A=-D*n-B;K=D*n-B;C.n11=2*u/(K-A);C.n13=
-(K+A)/(K-A);h.projectionMatrix=C.clone()}k.matrix=b.matrixWorld.clone().multiplySelf(l);k.update(null,!0);k.position.copy(b.position);k.near=u;k.far=b.far;e.call(c,a,k,p,!0);h.matrix=b.matrixWorld.clone().multiplySelf(f);h.update(null,!0);h.position.copy(b.position);h.near=u;h.far=b.far;e.call(c,a,h,w,!0);e.call(c,z,v)}};
+var z=new THREE.Scene;z.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){b.call(c,a,e);p.width=a;p.height=e;w.width=a;w.height=e};this.render=function(a,b){if(n!==b.aspect||u!==b.near||t!==b.fov){n=b.aspect;u=b.near;t=b.fov;var C=b.projectionMatrix.clone(),A=125/30*0.5,B=A*u/125,D=u*Math.tan(t*Math.PI/360),K;f.n14=A;l.n14=-A;A=-D*n+B;K=D*n+B;C.n11=2*u/(K-A);C.n13=(K+A)/(K-A);k.projectionMatrix=C.clone();A=-D*n-B;K=D*n-B;C.n11=2*u/(K-A);C.n13=(K+A)/(K-A);h.projectionMatrix=
+C.clone()}k.matrix=b.matrixWorld.clone().multiplySelf(l);k.position.copy(b.position);k.near=u;k.far=b.far;e.call(c,a,k,p,!0);h.matrix=b.matrixWorld.clone().multiplySelf(f);h.position.copy(b.position);h.near=u;h.far=b.far;e.call(c,a,h,w,!0);e.call(c,z,v)}};
 if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,e=this.render,k,h,f=new THREE.PerspectiveCamera;f.target=new THREE.Vector3(0,0,0);var l=new THREE.PerspectiveCamera;l.target=new THREE.Vector3(0,0,0);c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;this.setSize=function(a,e){b.call(c,a,e);k=a/2;h=e};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);l.projectionMatrix=f.projectionMatrix;l.position.copy(b.position);l.target.copy(b.target);l.translateX(-c.separation);l.lookAt(l.target);this.setViewport(0,0,k,h);e.call(c,a,f);this.setViewport(k,0,k,h);e.call(c,a,l,!1)}};

+ 7 - 5
build/custom/ThreeCanvas.js

@@ -50,9 +50,9 @@ THREE.Matrix4.makeOrtho=function(a,b,c,d,f,e){var g,h,l,m;g=new THREE.Matrix4;h=
 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)},remove:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},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;
+-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=e[f]=e[f]||new THREE.RenderableVertex;f++;return a}function b(a,b){return b.z-a.z}function c(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 d,f,e=[],g,h,l=[],m,j=[],i,o,n=[],p,k,u=[],x={objects:[],sprites:[],lights:[],elements:[]};
 new THREE.Vector3;var E=new THREE.Vector4,G=new THREE.Matrix4,M=new THREE.Matrix4,I=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],N=new THREE.Vector4,L=new THREE.Vector4;this.computeFrustum=function(a){I[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);I[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);I[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);I[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);I[4].set(a.n41-
 a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);I[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=I[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);G.multiply(b.projectionMatrix,b.matrixWorldInverse);G.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);G.multiply(b.matrixWorld,b.projectionMatrixInverse);G.multiplyVector3(a);
@@ -70,7 +70,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo
 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}};
-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.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.0010)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};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
@@ -119,7 +119,9 @@ THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material
 this.geometry.morphTargets.length;c++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[c].name]=c}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
 THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(this.morphTargetDictionary[a]!==void 0)return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var d,f=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<f;d++)a=this.children[d],a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}else for(d=0;d<f;d++)this.children[d].update(this.skinMatrix,
-b,c)};THREE.Bone.prototype.add=function(a){if(this.children.indexOf(a)===-1&&(a.parent!==void 0&&a.parent.removeChild(a),a.parent=this,this.children.push(a),!(a instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
+b,c)};THREE.Bone.prototype.add=function(a){if(this.children.indexOf(a)===-1&&(a.parent!==void 0&&a.parent.removeChild(a),a.parent=this,this.children.push(a),!(a instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};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(E!=a)k.globalAlpha=E=a}function c(a){if(G!=a){switch(a){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}G=a}}function d(a){if(M!=a)k.strokeStyle=M=a}function f(a){if(I!=a)k.fillStyle=I=a}var e=this,g,h,l,m=new THREE.Projector,a=a||{},j=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
 i,o,n,p,k=j.getContext("2d"),u=new THREE.Color(0),x=0,E=1,G=0,M=null,I=null,N=null,L=null,K=null,s,y,J,S,T=new THREE.RenderableVertex,P=new THREE.RenderableVertex,t,z,r,D,w,H,F,U,Z,ca,ga,da,v=new THREE.Color,A=new THREE.Color,B=new THREE.Color,C=new THREE.Color,O=new THREE.Color,wa=[],ea,fa,ba,Y,Aa,Ba,Ca,Da,Ea,Fa,ka=new THREE.Rectangle,W=new THREE.Rectangle,V=new THREE.Rectangle,xa=!1,X=new THREE.Color,ra=new THREE.Color,sa=new THREE.Color,Q=new THREE.Vector3,oa,pa,ya,$,qa,ta,a=16;oa=document.createElement("canvas");
 oa.width=oa.height=2;pa=oa.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);ya=pa.getImageData(0,0,2,2);$=ya.data;qa=document.createElement("canvas");qa.width=qa.height=a;ta=qa.getContext("2d");ta.translate(-a/2,-a/2);ta.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;o=b;n=Math.floor(i/2);p=Math.floor(o/2);j.width=i;j.height=o;ka.set(-n,-p,n,p);W.set(-n,-p,n,p);E=1;G=0;K=

+ 7 - 5
build/custom/ThreeDOM.js

@@ -50,9 +50,9 @@ THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,h,k,l;f=new THREE.Matrix4;h=
 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)},remove:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c<d;c++){e=this.children[c];if(e.name===a)return e;if(b&&(e=e.getChildByName(a,b),e!==void 0))return e}},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;
+-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,e;c=0;for(d=this.children.length;c<d;c++){e=this.children[c];if(e.name===a)return e;
+if(b&&(e=e.getChildByName(a,b),e!==void 0))return e}},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.RenderableVertex;e++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,f=a.z+a.w,e=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return f>=0&&e>=0&&g>=0&&h>=0?!0:f<0&&e<0||g<0&&h<0?!1:(f<0?c=Math.max(c,f/(f-e)):e<0&&(d=Math.min(d,f/(f-e))),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 d,e,g=[],f,h,k=[],l,i=[],j,n,m=[],o,p,r=[],t={objects:[],sprites:[],lights:[],elements:[]};
 new THREE.Vector3;var w=new THREE.Vector4,B=new THREE.Matrix4,I=new THREE.Matrix4,s=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],E=new THREE.Vector4,F=new THREE.Vector4;this.computeFrustum=function(a){s[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);s[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);s[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);s[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);s[4].set(a.n41-
 a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);s[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=s[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);B.multiply(b.projectionMatrix,b.matrixWorldInverse);B.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);B.multiply(b.matrixWorld,b.projectionMatrixInverse);B.multiplyVector3(a);
@@ -70,7 +70,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo
 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,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,k=this.w,l=k*c+f*e-h*d,i=k*d+h*c-g*e,j=k*e+g*d-f*c,c=-g*
 c-f*d-h*e;b.x=l*k+c*-g+i*-h-j*-f;b.y=i*k+c*-f+j*-g-l*-h;b.z=j*k+c*-h+l*-f-i*-g;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;e<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<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)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;e<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
@@ -81,6 +81,8 @@ THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!
 THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
 this.far)};THREE.ParticleDOMMaterial=function(a){THREE.Material.call(this);this.domElement=a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++)a=this.children[d],a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
-b,c)};THREE.Bone.prototype.add=function(a){if(this.children.indexOf(a)===-1&&(a.parent!==void 0&&a.parent.removeChild(a),a.parent=this,this.children.push(a),!(a instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
+b,c)};THREE.Bone.prototype.add=function(a){if(this.children.indexOf(a)===-1&&(a.parent!==void 0&&a.parent.removeChild(a),a.parent=this,this.children.push(a),!(a instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};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.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,e,g;this.domElement=document.createElement("div");this.setSize=function(a,b){c=a;d=b;e=c/2;g=d/2};this.render=function(c,d){var k,l,i,j,n,m,o,p;a=b.projectScene(c,d);k=0;for(l=a.length;k<l;k++)if(n=a[k],n instanceof THREE.RenderableParticle){o=n.x*e+e;p=n.y*g+g;i=0;for(j=n.material.length;i<j;i++)if(m=n.material[i],m instanceof THREE.ParticleDOMMaterial)m=m.domElement,m.style.left=o+"px",m.style.top=p+"px"}}};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};

+ 6 - 6
build/custom/ThreeExtras.js

@@ -93,7 +93,7 @@ this.cameraNY,e);e.activeCubeFace=4;a.render(b,this.cameraPZ,e);e.activeCubeFace
 THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(a,c,b,e,g,h,f){THREE.Camera.call(this);this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,c/2,c/-2,h,f);this.cameraP=new THREE.PerspectiveCamera(b,a/c,e,g);this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera;
 THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.projectionMatrix=this.cameraP.projectionMatrix};THREE.CombinedCamera.prototype.toOrthographic=function(){this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix};THREE.CombinedCamera.prototype.setFov=function(a){this.cameraP.fov=a;this.cameraP.updateProjectionMatrix();this.toPerspective()};
 THREE.CombinedCamera.prototype.setLens=function(a,c){c||(c=43.25);var b=2*Math.atan(c/(a*2));b*=180/Math.PI;this.setFov(b);return b};
-THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
+THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
 0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=
 !0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=
 function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=
@@ -103,14 +103,14 @@ this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b)
 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 e(a,b){return function(){b.apply(a,arguments)}}function g(a,b,e,c){var f={name:e,fps:0.6,length:c,hierarchy:[]},h,g=b.getControlPointsArray(),k=b.getLength(),p=g.length,y=0;h=p-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[h]={time:c,pos:g[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<p-1;h++)y=c*k.chunks[h]/k.total,b.keys[h]={time:y,pos:g[h]};f.hierarchy[0]=
 b;THREE.AnimationHandler.add(f);return new THREE.Animation(a,e,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function h(a,b){var e,c,f=new THREE.Geometry;for(e=0;e<a.points.length*b;e++)c=e/(a.points.length*b),c=a.getPoint(c),f.vertices[e]=new THREE.Vertex(new THREE.Vector3(c.x,c.y,c.z));return f}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=
+new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=
 this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var f=Math.PI*2,k=Math.PI/180;this.update=function(a){var e;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)*k;this.theta=this.lon*k;a=this.phi%f;this.phi=a>=0?a:a+f;e=this.verticalAngleMap.srcRange;
 a=this.verticalAngleMap.dstRange;e=THREE.Math.mapLinear(this.phi,e[0],e[1],a[0],a[1]);var c=a[1]-a[0];this.phi=b((e-a[0])/c)*c+a[0];e=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;e=THREE.Math.mapLinear(this.theta,e[0],e[1],a[0],a[1]);c=a[1]-a[0];this.theta=b((e-a[0])/c)*c+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=
 function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}),
 c=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(f,b);a.position.set(0,10,0);this.animation=g(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=g(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a=
 this.debugPath,b=this.spline,c=h(b,10),f=h(b,10),k=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(c,k);particleObj=new THREE.ParticleSystem(f,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);a.add(lineObj);particleObj.scale.set(1,1,1);a.add(particleObj);f=new THREE.SphereGeometry(1,16,8);k=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<b.points.length;i++)c=new THREE.Mesh(f,k),c.position.copy(b.points[i]),a.add(c)}this.domElement.addEventListener("mousemove",
 e(this,this.onMouseMove),!1)}};THREE.PathControlsIdCounter=0;
-THREE.FlyControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=c!==void 0?c:document;c&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
+THREE.FlyControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=c!==void 0?c:document;c&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
 0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=
 1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=
 0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
@@ -154,7 +154,7 @@ THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THRE
 THREE.IcosahedronGeometry=function(a){function c(a,b,c){var e=Math.sqrt(a*a+b*b+c*c);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(a/e,b/e,c/e)))-1}function b(a,b,c,e){e.faces.push(new THREE.Face3(a,b,c))}function e(a,b){var e=g.vertices[a].position,f=g.vertices[b].position;return c((e.x+f.x)/2,(e.y+f.y)/2,(e.z+f.z)/2)}var g=this,h=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,h);b(0,5,1,h);b(0,1,7,h);b(0,7,10,h);b(0,10,11,h);b(1,5,9,h);b(5,11,4,h);b(11,10,2,h);b(10,7,6,h);b(7,1,8,h);b(3,9,4,h);b(3,4,2,h);b(3,2,6,h);b(3,6,8,h);b(3,8,9,h);b(4,9,5,h);b(2,4,11,h);b(6,2,10,h);b(8,6,7,h);b(9,8,1,h);for(var f=0;f<this.subdivisions;f++){var a=new THREE.Geometry,k;for(k in h.faces){var l=e(h.faces[k].a,h.faces[k].b),m=e(h.faces[k].b,h.faces[k].c),n=e(h.faces[k].c,h.faces[k].a);b(h.faces[k].a,l,n,a);b(h.faces[k].b,m,
 l,a);b(h.faces[k].c,n,m,a);b(l,m,n,a)}h.faces=a.faces}g.faces=h.faces;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
-THREE.LatheGeometry=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;for(var c=this.angle/this.steps,b=[],e=[],g=[],h=[],f=(new THREE.Matrix4).setRotationZ(c),k=0;k<a.length;k++)this.vertices.push(new THREE.Vertex(a[k])),b[k]=a[k].clone(),e[k]=this.vertices.length-1;for(var l=0;l<=this.angle+0.001;l+=c){for(k=0;k<b.length;k++)l<this.angle?(b[k]=f.multiplyVector3(b[k].clone()),this.vertices.push(new THREE.Vertex(b[k])),g[k]=this.vertices.length-1):g=h;l==0&&(h=e);
+THREE.LatheGeometry=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;for(var c=this.angle/this.steps,b=[],e=[],g=[],h=[],f=(new THREE.Matrix4).setRotationZ(c),k=0;k<a.length;k++)this.vertices.push(new THREE.Vertex(a[k])),b[k]=a[k].clone(),e[k]=this.vertices.length-1;for(var l=0;l<=this.angle+0.0010;l+=c){for(k=0;k<b.length;k++)l<this.angle?(b[k]=f.multiplyVector3(b[k].clone()),this.vertices.push(new THREE.Vertex(b[k])),g[k]=this.vertices.length-1):g=h;l==0&&(h=e);
 for(k=0;k<e.length-1;k++)this.faces.push(new THREE.Face4(g[k],g[k+1],e[k+1],e[k])),this.faceVertexUvs[0].push([new THREE.UV(1-l/this.angle,k/a.length),new THREE.UV(1-l/this.angle,(k+1)/a.length),new THREE.UV(1-(l-c)/this.angle,(k+1)/a.length),new THREE.UV(1-(l-c)/this.angle,k/a.length)]);e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
 THREE.OctahedronGeometry=function(a,c){function b(b){var c=b.clone().normalize(),c=new THREE.Vertex(c.clone().multiplyScalar(a));c.index=f.vertices.push(c)-1;c.uv=new THREE.UV(Math.atan2(b.z,-b.x)/2/Math.PI+0.5,Math.atan2(-b.y,Math.sqrt(b.x*b.x+b.z*b.z))/Math.PI+0.5);return c}function e(a,b,c,k){k<1?(k=new THREE.Face3(a.index,b.index,c.index,[a.position,b.position,c.position]),k.centroid.addSelf(a.position).addSelf(b.position).addSelf(c.position).divideScalar(3),k.normal=k.centroid.clone().normalize(),
 f.faces.push(k),k=Math.atan2(k.centroid.z,-k.centroid.x),f.faceVertexUvs[0].push([h(a.uv,a.position,k),h(b.uv,b.position,k),h(c.uv,c.position,k)])):(k-=1,e(a,g(a,b),g(a,c),k),e(g(a,b),b,g(b,c),k),e(g(a,c),g(b,c),c,k),e(g(a,b),g(b,c),g(a,c),k))}function g(a,c){k[a.index]||(k[a.index]=[]);k[c.index]||(k[c.index]=[]);var e=k[a.index][c.index];e===void 0&&(k[a.index][c.index]=k[c.index][a.index]=e=b((new THREE.Vector3).add(a.position,c.position).divideScalar(2)));return e}function h(a,b,c){c<0&&a.u===
@@ -352,7 +352,7 @@ THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionU
 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);var c=this,b=this.setSize,e=this.render,g=new THREE.PerspectiveCamera,h=new THREE.PerspectiveCamera,f=new THREE.Matrix4,k=new THREE.Matrix4,l,m,n;g.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},o=new THREE.WebGLRenderTarget(512,512,a),t=new THREE.WebGLRenderTarget(512,512,a),u=new THREE.PerspectiveCamera(53,1,1,1E4);u.position.z=
 2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:o},mapRight:{type:"t",value:1,texture:t}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});
-var z=new THREE.Scene;z.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){b.call(c,a,e);o.width=a;o.height=e;t.width=a;t.height=e};this.render=function(a,b){b.update(null,!0);if(l!==b.aspect||m!==b.near||n!==b.fov){l=b.aspect;m=b.near;n=b.fov;var y=b.projectionMatrix.clone(),x=125/30*0.5,w=x*m/125,A=m*Math.tan(n*Math.PI/360),D;f.n14=x;k.n14=-x;x=-A*l+w;D=A*l+w;y.n11=2*m/(D-x);y.n13=(D+x)/(D-x);g.projectionMatrix=y.clone();x=-A*l-w;D=A*l-w;y.n11=2*m/(D-x);y.n13=
-(D+x)/(D-x);h.projectionMatrix=y.clone()}g.matrix=b.matrixWorld.clone().multiplySelf(k);g.update(null,!0);g.position.copy(b.position);g.near=m;g.far=b.far;e.call(c,a,g,o,!0);h.matrix=b.matrixWorld.clone().multiplySelf(f);h.update(null,!0);h.position.copy(b.position);h.near=m;h.far=b.far;e.call(c,a,h,t,!0);e.call(c,z,u)}};
+var z=new THREE.Scene;z.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){b.call(c,a,e);o.width=a;o.height=e;t.width=a;t.height=e};this.render=function(a,b){if(l!==b.aspect||m!==b.near||n!==b.fov){l=b.aspect;m=b.near;n=b.fov;var y=b.projectionMatrix.clone(),x=125/30*0.5,w=x*m/125,A=m*Math.tan(n*Math.PI/360),D;f.n14=x;k.n14=-x;x=-A*l+w;D=A*l+w;y.n11=2*m/(D-x);y.n13=(D+x)/(D-x);g.projectionMatrix=y.clone();x=-A*l-w;D=A*l-w;y.n11=2*m/(D-x);y.n13=(D+x)/(D-x);h.projectionMatrix=
+y.clone()}g.matrix=b.matrixWorld.clone().multiplySelf(k);g.position.copy(b.position);g.near=m;g.far=b.far;e.call(c,a,g,o,!0);h.matrix=b.matrixWorld.clone().multiplySelf(f);h.position.copy(b.position);h.near=m;h.far=b.far;e.call(c,a,h,t,!0);e.call(c,z,u)}};
 if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,e=this.render,g,h,f=new THREE.PerspectiveCamera;f.target=new THREE.Vector3(0,0,0);var k=new THREE.PerspectiveCamera;k.target=new THREE.Vector3(0,0,0);c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;this.setSize=function(a,e){b.call(c,a,e);g=a/2;h=e};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);k.projectionMatrix=f.projectionMatrix;k.position.copy(b.position);k.target.copy(b.target);k.translateX(-c.separation);k.lookAt(k.target);this.setViewport(0,0,g,h);e.call(c,a,f);this.setViewport(g,0,g,h);e.call(c,a,k,!1)}};

+ 7 - 5
build/custom/ThreeSVG.js

@@ -50,9 +50,9 @@ THREE.Matrix4.makeOrtho=function(a,b,c,d,f,e){var g,h,i,n;g=new THREE.Matrix4;h=
 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)},remove:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},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;
+-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=e[f]=e[f]||new THREE.RenderableVertex;f++;return a}function b(a,b){return b.z-a.z}function c(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 d,f,e=[],g,h,i=[],n,k=[],j,o,l=[],q,r,v=[],y={objects:[],sprites:[],lights:[],elements:[]};
 new THREE.Vector3;var w=new THREE.Vector4,D=new THREE.Matrix4,t=new THREE.Matrix4,u=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],G=new THREE.Vector4,E=new THREE.Vector4;this.computeFrustum=function(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(a=0;a<6;a++){var b=u[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);
@@ -70,7 +70,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo
 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,i=this.w,n=i*c+g*f-h*d,k=i*d+h*c-e*f,j=i*f+e*d-g*c,c=-e*
 c-g*d-h*f;b.x=n*i+c*-e+k*-h-j*-g;b.y=k*i+c*-g+j*-e-n*-h;b.z=j*i+c*-h+n*-g-k*-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.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.0010)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};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
@@ -114,7 +114,9 @@ THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material
 this.geometry.morphTargets.length;c++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[c].name]=c}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
 THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(this.morphTargetDictionary[a]!==void 0)return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var d,f=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<f;d++)a=this.children[d],a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}else for(d=0;d<f;d++)this.children[d].update(this.skinMatrix,
-b,c)};THREE.Bone.prototype.add=function(a){if(this.children.indexOf(a)===-1&&(a.parent!==void 0&&a.parent.removeChild(a),a.parent=this,this.children.push(a),!(a instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
+b,c)};THREE.Bone.prototype.add=function(a){if(this.children.indexOf(a)===-1&&(a.parent!==void 0&&a.parent.removeChild(a),a.parent=this,this.children.push(a),!(a instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};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.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,h,j,i;e=0;for(f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(j=g.matrixWorld.getPosition(),i=c.dot(j),i<=0||(i*=g.intensity,d.r+=h.r*i,d.g+=h.g*i,d.b+=h.b*i)):g instanceof THREE.PointLight&&(j=g.matrixWorld.getPosition(),i=c.dot(A.sub(j,b).normalize()),i<=0||(i*=g.distance==0?1:1-Math.min(b.distanceTo(j)/g.distance,1),i!=0&&(i*=g.intensity,d.r+=h.r*i,d.g+=h.g*i,d.b+=h.b*i)))}function b(a){F[a]==null&&(F[a]=document.createElementNS("http://www.w3.org/2000/svg",
 "path"),z==0&&F[a].setAttribute("shape-rendering","crispEdges"));return F[a]}function c(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var d=this,f,e,g,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,k,j,o,l,q,r,v,y=new THREE.Rectangle,w=new THREE.Rectangle,D=!1,t=new THREE.Color,u=new THREE.Color,G=new THREE.Color,E=new THREE.Color,L,A=new THREE.Vector3,F=[],M=[],B,K,H,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){n=a;k=b;j=n/2;o=k/2;i.setAttribute("viewBox",-j+" "+-o+" "+n+" "+k);i.setAttribute("width",n);i.setAttribute("height",k);y.set(-j,-o,j,o)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,n){var C,A,s,p;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;f=h.projectScene(k,n,this.sortElements);e=f.elements;

+ 71 - 69
build/custom/ThreeWebGL.js

@@ -26,9 +26,9 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=
 THREE.Matrix4=function(a,b,c,e,h,f,i,j,n,l,o,k,r,v,z,B){this.set(a!==void 0?a:1,b||0,c||0,e||0,h||0,f!==void 0?f:1,i||0,j||0,n||0,l||0,o!==void 0?o:1,k||0,r||0,v||0,z||0,B!==void 0?B:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,e,h,f,i,j,n,l,o,k,r,v,z,B){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=h;this.n22=f;this.n23=i;this.n24=j;this.n31=n;this.n32=l;this.n33=o;this.n34=k;this.n41=r;this.n42=v;this.n43=z;this.n44=B;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 e=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(f.length()===0)f.z=1;e.cross(c,f).normalize();e.length()===0&&(f.x+=1.0E-4,e.cross(c,f).normalize());h.cross(f,e).normalize();this.n11=e.x;this.n12=h.x;this.n13=f.x;this.n21=e.y;this.n22=h.y;this.n23=f.y;this.n31=e.z;this.n32=h.z;this.n33=f.z;return this},multiply:function(a,b){var c=a.n11,e=a.n12,h=a.n13,f=a.n14,i=a.n21,j=a.n22,n=a.n23,l=a.n24,o=a.n31,k=a.n32,r=a.n33,v=a.n34,z=a.n41,B=a.n42,F=a.n43,
-E=a.n44,fa=b.n11,ia=b.n12,ra=b.n13,O=b.n14,I=b.n21,T=b.n22,ta=b.n23,U=b.n24,la=b.n31,pa=b.n32,ma=b.n33,R=b.n34,K=b.n41,A=b.n42,d=b.n43,C=b.n44;this.n11=c*fa+e*I+h*la+f*K;this.n12=c*ia+e*T+h*pa+f*A;this.n13=c*ra+e*ta+h*ma+f*d;this.n14=c*O+e*U+h*R+f*C;this.n21=i*fa+j*I+n*la+l*K;this.n22=i*ia+j*T+n*pa+l*A;this.n23=i*ra+j*ta+n*ma+l*d;this.n24=i*O+j*U+n*R+l*C;this.n31=o*fa+k*I+r*la+v*K;this.n32=o*ia+k*T+r*pa+v*A;this.n33=o*ra+k*ta+r*ma+v*d;this.n34=o*O+k*U+r*R+v*C;this.n41=z*fa+B*I+F*la+E*K;this.n42=z*
-ia+B*T+F*pa+E*A;this.n43=z*ra+B*ta+F*ma+E*d;this.n44=z*O+B*U+F*R+E*C;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,e=a.z,h=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*c+this.n13*
+E=a.n44,fa=b.n11,ia=b.n12,ra=b.n13,O=b.n14,I=b.n21,T=b.n22,ta=b.n23,U=b.n24,ma=b.n31,pa=b.n32,X=b.n33,R=b.n34,K=b.n41,A=b.n42,d=b.n43,C=b.n44;this.n11=c*fa+e*I+h*ma+f*K;this.n12=c*ia+e*T+h*pa+f*A;this.n13=c*ra+e*ta+h*X+f*d;this.n14=c*O+e*U+h*R+f*C;this.n21=i*fa+j*I+n*ma+l*K;this.n22=i*ia+j*T+n*pa+l*A;this.n23=i*ra+j*ta+n*X+l*d;this.n24=i*O+j*U+n*R+l*C;this.n31=o*fa+k*I+r*ma+v*K;this.n32=o*ia+k*T+r*pa+v*A;this.n33=o*ra+k*ta+r*X+v*d;this.n34=o*O+k*U+r*R+v*C;this.n41=z*fa+B*I+F*ma+E*K;this.n42=z*ia+
+B*T+F*pa+E*A;this.n43=z*ra+B*ta+F*X+E*d;this.n44=z*O+B*U+F*R+E*C;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,e=a.z,h=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*c+this.n13*
 e+this.n14*h;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*h;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*h;return a},rotateAxis:function(a){var b=a.x,c=a.y,e=a.z;a.x=b*this.n11+c*this.n12+e*this.n13;a.y=b*this.n21+c*this.n22+e*this.n23;a.z=b*this.n31+c*this.n32+e*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,e=this.n14,h=this.n21,f=this.n22,i=this.n23,j=this.n24,n=this.n31,l=this.n32,o=this.n33,k=this.n34,r=this.n41,v=this.n42,z=this.n43,B=this.n44;return e*i*l*r-c*j*l*r-e*f*o*r+b*j*o*r+c*f*k*r-b*i*k*r-e*i*n*v+c*j*n*v+e*h*o*v-a*j*o*v-c*h*k*v+a*i*k*v+e*f*n*z-b*j*n*z-e*h*l*z+a*j*l*z+b*h*k*z-a*f*k*z-c*f*n*B+b*i*n*B+
 c*h*l*B-a*i*l*B-b*h*o*B+a*f*o*B},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;
@@ -50,27 +50,27 @@ THREE.Matrix4.makeOrtho=function(a,b,c,e,h,f){var i,j,n,l;i=new THREE.Matrix4;j=
 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)},remove:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,e,h;c=0;for(e=this.children.length;c<e;c++){h=this.children[c];if(h.name===a)return h;if(b&&(h=h.getChildByName(a,b),h!==void 0))return h}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,
-this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},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;
+-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,e,h;c=0;for(e=this.children.length;c<e;c++){h=this.children[c];if(h.name===a)return h;
+if(b&&(h=h.getChildByName(a,b),h!==void 0))return h}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&&
+this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)}};THREE.Object3DCount=0;
 THREE.Projector=function(){function a(){var a=f[h]=f[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,e=1,f=a.z+a.w,h=b.z+b.w,i=-a.z+a.w,j=-b.z+b.w;return f>=0&&h>=0&&i>=0&&j>=0?!0:f<0&&h<0||i<0&&j<0?!1:(f<0?c=Math.max(c,f/(f-h)):h<0&&(e=Math.min(e,f/(f-h))),i<0?c=Math.max(c,i/(i-j)):j<0&&(e=Math.min(e,i/(i-j))),e<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-e),!0))}var e,h,f=[],i,j,n=[],l,o=[],k,r,v=[],z,B,F=[],E={objects:[],sprites:[],lights:[],elements:[]};
 new THREE.Vector3;var fa=new THREE.Vector4,ia=new THREE.Matrix4,ra=new THREE.Matrix4,O=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],I=new THREE.Vector4,T=new THREE.Vector4;this.computeFrustum=function(a){O[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);O[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);O[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);O[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);
 O[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);O[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=O[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);ia.multiply(b.projectionMatrix,b.matrixWorldInverse);ia.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);ia.multiply(b.matrixWorld,b.projectionMatrixInverse);
 ia.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(a){E.objects.length=0;E.sprites.length=0;E.lights.length=0;var b=function(a){if(a.visible!=!1){var c;if(c=a instanceof THREE.Mesh)if(!(c=a.frustumCulled==!1))a:{for(var e=a.matrixWorld,f=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)),
-h=0;h<6;h++)if(c=O[h].x*e.n14+O[h].y*e.n24+O[h].z*e.n34+O[h].w,c<=f){c=!1;break a}c=!0}c?E.objects.push(a):a instanceof THREE.Line?E.objects.push(a):a instanceof THREE.Sprite||a instanceof THREE.Particle?E.sprites.push(a):a instanceof THREE.Light&&E.lights.push(a);c=0;for(e=a.children.length;c<e;c++)b(a.children[c])}};b(a);return E};this.projectScene=function(O,U,la){var pa=U.near,ma=U.far,R,K,A,d,C,S,W,Q,N,Aa,va,Ha,La,wa,Ba,ya;B=r=l=j=0;E.elements.length=0;U.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),
-O.add(U));O.updateMatrixWorld();U.matrixWorldInverse.getInverse(U.matrixWorld);ia.multiply(U.projectionMatrix,U.matrixWorldInverse);this.computeFrustum(ia);E=this.projectGraph(O);O=0;for(R=E.objects.length;O<R;O++)if(N=E.objects[O],Aa=N.matrixWorld,Ha=N.material,h=0,N instanceof THREE.Mesh){va=N.geometry;La=N.geometry.materials;d=va.vertices;wa=va.faces;Ba=va.faceVertexUvs;va=N.matrixRotationWorld.extractRotation(Aa);K=0;for(A=d.length;K<A;K++)e=a(),e.positionWorld.copy(d[K].position),Aa.multiplyVector3(e.positionWorld),
-e.positionScreen.copy(e.positionWorld),ia.multiplyVector4(e.positionScreen),e.positionScreen.x/=e.positionScreen.w,e.positionScreen.y/=e.positionScreen.w,e.visible=e.positionScreen.z>pa&&e.positionScreen.z<ma;d=0;for(K=wa.length;d<K;d++){A=wa[d];if(A instanceof THREE.Face3)if(C=f[A.a],S=f[A.b],W=f[A.c],C.visible&&S.visible&&W.visible&&(N.doubleSided||N.flipSided!=(W.positionScreen.x-C.positionScreen.x)*(S.positionScreen.y-C.positionScreen.y)-(W.positionScreen.y-C.positionScreen.y)*(S.positionScreen.x-
+h=0;h<6;h++)if(c=O[h].x*e.n14+O[h].y*e.n24+O[h].z*e.n34+O[h].w,c<=f){c=!1;break a}c=!0}c?E.objects.push(a):a instanceof THREE.Line?E.objects.push(a):a instanceof THREE.Sprite||a instanceof THREE.Particle?E.sprites.push(a):a instanceof THREE.Light&&E.lights.push(a);c=0;for(e=a.children.length;c<e;c++)b(a.children[c])}};b(a);return E};this.projectScene=function(O,U,ma){var pa=U.near,X=U.far,R,K,A,d,C,S,W,Q,N,Aa,va,Ga,Ka,wa,Ba,ya;B=r=l=j=0;E.elements.length=0;U.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),
+O.add(U));O.updateMatrixWorld();U.matrixWorldInverse.getInverse(U.matrixWorld);ia.multiply(U.projectionMatrix,U.matrixWorldInverse);this.computeFrustum(ia);E=this.projectGraph(O);O=0;for(R=E.objects.length;O<R;O++)if(N=E.objects[O],Aa=N.matrixWorld,Ga=N.material,h=0,N instanceof THREE.Mesh){va=N.geometry;Ka=N.geometry.materials;d=va.vertices;wa=va.faces;Ba=va.faceVertexUvs;va=N.matrixRotationWorld.extractRotation(Aa);K=0;for(A=d.length;K<A;K++)e=a(),e.positionWorld.copy(d[K].position),Aa.multiplyVector3(e.positionWorld),
+e.positionScreen.copy(e.positionWorld),ia.multiplyVector4(e.positionScreen),e.positionScreen.x/=e.positionScreen.w,e.positionScreen.y/=e.positionScreen.w,e.visible=e.positionScreen.z>pa&&e.positionScreen.z<X;d=0;for(K=wa.length;d<K;d++){A=wa[d];if(A instanceof THREE.Face3)if(C=f[A.a],S=f[A.b],W=f[A.c],C.visible&&S.visible&&W.visible&&(N.doubleSided||N.flipSided!=(W.positionScreen.x-C.positionScreen.x)*(S.positionScreen.y-C.positionScreen.y)-(W.positionScreen.y-C.positionScreen.y)*(S.positionScreen.x-
 C.positionScreen.x)<0))Q=n[j]=n[j]||new THREE.RenderableFace3,j++,i=Q,i.v1.copy(C),i.v2.copy(S),i.v3.copy(W);else continue;else if(A instanceof THREE.Face4)if(C=f[A.a],S=f[A.b],W=f[A.c],Q=f[A.d],C.visible&&S.visible&&W.visible&&Q.visible&&(N.doubleSided||N.flipSided!=((Q.positionScreen.x-C.positionScreen.x)*(S.positionScreen.y-C.positionScreen.y)-(Q.positionScreen.y-C.positionScreen.y)*(S.positionScreen.x-C.positionScreen.x)<0||(S.positionScreen.x-W.positionScreen.x)*(Q.positionScreen.y-W.positionScreen.y)-
 (S.positionScreen.y-W.positionScreen.y)*(Q.positionScreen.x-W.positionScreen.x)<0)))ya=o[l]=o[l]||new THREE.RenderableFace4,l++,i=ya,i.v1.copy(C),i.v2.copy(S),i.v3.copy(W),i.v4.copy(Q);else continue;i.normalWorld.copy(A.normal);va.multiplyVector3(i.normalWorld);i.centroidWorld.copy(A.centroid);Aa.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);ia.multiplyVector3(i.centroidScreen);W=A.vertexNormals;C=0;for(S=W.length;C<S;C++)Q=i.vertexNormalsWorld[C],Q.copy(W[C]),va.multiplyVector3(Q);
-C=0;for(S=Ba.length;C<S;C++)if(ya=Ba[C][d]){W=0;for(Q=ya.length;W<Q;W++)i.uvs[C][W]=ya[W]}i.material=Ha;i.faceMaterial=A.materialIndex!==null?La[A.materialIndex]:null;i.z=i.centroidScreen.z;E.elements.push(i)}}else if(N instanceof THREE.Line){ra.multiply(ia,Aa);d=N.geometry.vertices;C=a();C.positionScreen.copy(d[0].position);ra.multiplyVector4(C.positionScreen);K=1;for(A=d.length;K<A;K++)if(C=a(),C.positionScreen.copy(d[K].position),ra.multiplyVector4(C.positionScreen),S=f[h-2],I.copy(C.positionScreen),
-T.copy(S.positionScreen),c(I,T))I.multiplyScalar(1/I.w),T.multiplyScalar(1/T.w),N=v[r]=v[r]||new THREE.RenderableLine,r++,k=N,k.v1.positionScreen.copy(I),k.v2.positionScreen.copy(T),k.z=Math.max(I.z,T.z),k.material=Ha,E.elements.push(k)}O=0;for(R=E.sprites.length;O<R;O++)if(N=E.sprites[O],Aa=N.matrixWorld,N instanceof THREE.Particle&&(fa.set(Aa.n14,Aa.n24,Aa.n34,1),ia.multiplyVector4(fa),fa.z/=fa.w,fa.z>0&&fa.z<1))pa=F[B]=F[B]||new THREE.RenderableParticle,B++,z=pa,z.x=fa.x/fa.w,z.y=fa.y/fa.w,z.z=
-fa.z,z.rotation=N.rotation.z,z.scale.x=N.scale.x*Math.abs(z.x-(fa.x+U.projectionMatrix.n11)/(fa.w+U.projectionMatrix.n14)),z.scale.y=N.scale.y*Math.abs(z.y-(fa.y+U.projectionMatrix.n22)/(fa.w+U.projectionMatrix.n24)),z.material=N.material,E.elements.push(z);la&&E.elements.sort(b);return E}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==void 0?e:1)};
+C=0;for(S=Ba.length;C<S;C++)if(ya=Ba[C][d]){W=0;for(Q=ya.length;W<Q;W++)i.uvs[C][W]=ya[W]}i.material=Ga;i.faceMaterial=A.materialIndex!==null?Ka[A.materialIndex]:null;i.z=i.centroidScreen.z;E.elements.push(i)}}else if(N instanceof THREE.Line){ra.multiply(ia,Aa);d=N.geometry.vertices;C=a();C.positionScreen.copy(d[0].position);ra.multiplyVector4(C.positionScreen);K=1;for(A=d.length;K<A;K++)if(C=a(),C.positionScreen.copy(d[K].position),ra.multiplyVector4(C.positionScreen),S=f[h-2],I.copy(C.positionScreen),
+T.copy(S.positionScreen),c(I,T))I.multiplyScalar(1/I.w),T.multiplyScalar(1/T.w),N=v[r]=v[r]||new THREE.RenderableLine,r++,k=N,k.v1.positionScreen.copy(I),k.v2.positionScreen.copy(T),k.z=Math.max(I.z,T.z),k.material=Ga,E.elements.push(k)}O=0;for(R=E.sprites.length;O<R;O++)if(N=E.sprites[O],Aa=N.matrixWorld,N instanceof THREE.Particle&&(fa.set(Aa.n14,Aa.n24,Aa.n34,1),ia.multiplyVector4(fa),fa.z/=fa.w,fa.z>0&&fa.z<1))pa=F[B]=F[B]||new THREE.RenderableParticle,B++,z=pa,z.x=fa.x/fa.w,z.y=fa.y/fa.w,z.z=
+fa.z,z.rotation=N.rotation.z,z.scale.x=N.scale.x*Math.abs(z.x-(fa.x+U.projectionMatrix.n11)/(fa.w+U.projectionMatrix.n14)),z.scale.y=N.scale.y*Math.abs(z.y-(fa.y+U.projectionMatrix.n22)/(fa.w+U.projectionMatrix.n24)),z.material=N.material,E.elements.push(z);ma&&E.elements.sort(b);return E}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==void 0?e:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;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,e=a.y*b,h=a.z*b,a=Math.cos(e),e=Math.sin(e),b=Math.cos(-h),h=Math.sin(-h),f=Math.cos(c),c=Math.sin(c),i=a*b,j=e*h;this.w=i*f-j*c;this.x=i*c+j*f;this.y=e*b*f+a*h*c;this.z=a*h*f-e*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,e=Math.sin(c);
 this.x=a.x*e;this.y=a.y*e;this.z=a.z*e;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,e=this.z,h=this.w,f=a.x,i=a.y,j=a.z,a=a.w;this.x=b*a+h*f+c*j-e*i;this.y=c*a+h*i+e*f-b*j;this.z=e*a+h*j+b*i-c*f;this.w=h*a-b*f-c*i-e*j;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,e=a.y,h=a.z,f=this.x,i=this.y,j=this.z,n=this.w,l=n*c+i*h-j*e,o=n*e+j*c-f*h,k=n*h+f*e-i*c,c=-f*
 c-i*e-j*h;b.x=l*n+c*-f+o*-j-k*-i;b.y=o*n+c*-i+k*-f-l*-j;b.z=k*n+c*-j+l*-i-o*-f;return b}};
-THREE.Quaternion.slerp=function(a,b,c,e){var h=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;h<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,h=-h):c.copy(b);if(Math.abs(h)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(h),h=Math.sqrt(1-h*h);if(Math.abs(h)<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-e)*f)/h;e=Math.sin(e*f)/h;c.w=a.w*b+c.w*e;c.x=a.x*b+c.x*e;c.y=a.y*b+c.y*e;c.z=a.z*b+c.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,e){var h=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;h<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,h=-h):c.copy(b);if(Math.abs(h)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(h),h=Math.sqrt(1-h*h);if(Math.abs(h)<0.0010)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-e)*f)/h;e=Math.sin(e*f)/h;c.w=a.w*b+c.w*e;c.x=a.x*b+c.x*e;c.y=a.y*b+c.y*e;c.z=a.z*b+c.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,e,h,f){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,e,h,f,i){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=i;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
@@ -80,9 +80,9 @@ b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid
 c,e,h,f,i,j=new THREE.Vector3,n=new THREE.Vector3;e=0;for(h=this.faces.length;e<h;e++){f=this.faces[e];if(a&&f.vertexNormals.length){j.set(0,0,0);b=0;for(c=f.vertexNormals.length;b<c;b++)j.addSelf(f.vertexNormals[b]);j.divideScalar(3)}else b=this.vertices[f.a],c=this.vertices[f.b],i=this.vertices[f.c],j.sub(i.position,c.position),n.sub(b.position,c.position),j.crossSelf(n);j.isZero()||j.normalize();f.normal.copy(j)}},computeVertexNormals:function(){var a,b,c,e;if(this.__tmpVertices===void 0){e=this.__tmpVertices=
 Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[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{e=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof
 THREE.Face3?(e[c.a].addSelf(c.normal),e[c.b].addSelf(c.normal),e[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(e[c.a].addSelf(c.normal),e[c.b].addSelf(c.normal),e[c.c].addSelf(c.normal),e[c.d].addSelf(c.normal));a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(e[c.a]),c.vertexNormals[1].copy(e[c.b]),c.vertexNormals[2].copy(e[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(e[c.a]),
-c.vertexNormals[1].copy(e[c.b]),c.vertexNormals[2].copy(e[c.c]),c.vertexNormals[3].copy(e[c.d]))},computeTangents:function(){function a(a,d,b,c,e,f,h){j=a.vertices[d].position;n=a.vertices[b].position;l=a.vertices[c].position;o=i[e];k=i[f];r=i[h];v=n.x-j.x;z=l.x-j.x;B=n.y-j.y;F=l.y-j.y;E=n.z-j.z;fa=l.z-j.z;ia=k.u-o.u;ra=r.u-o.u;O=k.v-o.v;I=r.v-o.v;T=1/(ia*I-ra*O);pa.set((I*v-O*z)*T,(I*B-O*F)*T,(I*E-O*fa)*T);ma.set((ia*z-ra*v)*T,(ia*F-ra*B)*T,(ia*fa-ra*E)*T);U[d].addSelf(pa);U[b].addSelf(pa);U[c].addSelf(pa);
-la[d].addSelf(ma);la[b].addSelf(ma);la[c].addSelf(ma)}var b,c,e,h,f,i,j,n,l,o,k,r,v,z,B,F,E,fa,ia,ra,O,I,T,ta,U=[],la=[],pa=new THREE.Vector3,ma=new THREE.Vector3,R=new THREE.Vector3,K=new THREE.Vector3,A=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)U[b]=new THREE.Vector3,la[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],i=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,
-f.b,f.d,0,1,3));var d=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(e=0;e<f.vertexNormals.length;e++)A.copy(f.vertexNormals[e]),h=f[d[e]],ta=U[h],R.copy(ta),R.subSelf(A.multiplyScalar(A.dot(ta))).normalize(),K.cross(f.vertexNormals[e],ta),h=K.dot(la[h]),h=h<0?-1:1,f.vertexTangents[e]=new THREE.Vector4(R.x,R.y,R.z,h)}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],
+c.vertexNormals[1].copy(e[c.b]),c.vertexNormals[2].copy(e[c.c]),c.vertexNormals[3].copy(e[c.d]))},computeTangents:function(){function a(a,d,b,c,e,f,h){j=a.vertices[d].position;n=a.vertices[b].position;l=a.vertices[c].position;o=i[e];k=i[f];r=i[h];v=n.x-j.x;z=l.x-j.x;B=n.y-j.y;F=l.y-j.y;E=n.z-j.z;fa=l.z-j.z;ia=k.u-o.u;ra=r.u-o.u;O=k.v-o.v;I=r.v-o.v;T=1/(ia*I-ra*O);pa.set((I*v-O*z)*T,(I*B-O*F)*T,(I*E-O*fa)*T);X.set((ia*z-ra*v)*T,(ia*F-ra*B)*T,(ia*fa-ra*E)*T);U[d].addSelf(pa);U[b].addSelf(pa);U[c].addSelf(pa);
+ma[d].addSelf(X);ma[b].addSelf(X);ma[c].addSelf(X)}var b,c,e,h,f,i,j,n,l,o,k,r,v,z,B,F,E,fa,ia,ra,O,I,T,ta,U=[],ma=[],pa=new THREE.Vector3,X=new THREE.Vector3,R=new THREE.Vector3,K=new THREE.Vector3,A=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)U[b]=new THREE.Vector3,ma[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],i=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,
+f.d,0,1,3));var d=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(e=0;e<f.vertexNormals.length;e++)A.copy(f.vertexNormals[e]),h=f[d[e]],ta=U[h],R.copy(ta),R.subSelf(A.multiplyScalar(A.dot(ta))).normalize(),K.cross(f.vertexNormals[e],ta),h=K.dot(ma[h]),h=h<0?-1:1,f.vertexTangents[e]=new THREE.Vector4(R.x,R.y,R.z,h)}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=[],e,h=Math.pow(10,4),f,i;f=0;for(i=this.vertices.length;f<i;f++)e=this.vertices[f].position,e=[Math.round(e.x*h),Math.round(e.y*h),Math.round(e.z*h)].join("_"),
 a[e]===void 0?(a[e]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[e]];f=0;for(i=this.faces.length;f<i;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
@@ -140,10 +140,12 @@ THREE.Sprite=function(a){THREE.Object3D.call(this);this.color=a.color!==void 0?n
 !this.useScreenCoordinates;this.scaleByViewport=a.scaleByViewport!==void 0?a.scaleByViewport:!this.affectedByDistance;this.alignment=a.alignment instanceof THREE.Vector2?a.alignment:THREE.SpriteAlignment.center;this.rotation3d=this.rotation;this.rotation=0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=new THREE.Vector2(1,1)};THREE.Sprite.prototype=new THREE.Object3D;THREE.Sprite.prototype.constructor=THREE.Sprite;THREE.Sprite.prototype.supr=THREE.Object3D.prototype;
 THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(this.scale.x!==1||this.scale.y!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);
 THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.centerLeft=new THREE.Vector2(1,0);THREE.SpriteAlignment.center=new THREE.Vector2(0,0);THREE.SpriteAlignment.centerRight=new THREE.Vector2(-1,0);THREE.SpriteAlignment.bottomLeft=new THREE.Vector2(1,1);THREE.SpriteAlignment.bottomCenter=new THREE.Vector2(0,1);THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);
-THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b!==void 0?b:1;this.far=c!==void 0?c:1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b!==void 0?b:2.5E-4};
-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",
+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.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b!==void 0?b:1;this.far=c!==void 0?c:1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b!==void 0?b:2.5E-4};
+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",
 lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_lambert_pars_vertex:"uniform vec3 ambient;\nuniform vec3 diffuse;\nuniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif",
 lights_lambert_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n}\n#endif\nvLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;\n}",
@@ -175,8 +177,8 @@ THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.lights_phong_fragment,THR
 THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,
 THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,
 THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask  = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}};
-THREE.WebGLRenderer=function(a){function b(a,d){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;else if(d.materialIndex>=0)return a.geometry.materials[d.materialIndex]}function c(a,b,c){var e,f,h,i=a.vertices,u=i.length,p=a.colors,q=p.length,j=a.__vertexArray,xa=a.__colorArray,za=a.__sortArray,P=a.__dirtyVertices,o=a.__dirtyColors,n=a.__webglCustomAttributesList,k;if(n){h=0;for(e=n.length;h<e;h++)n[h].offset=0}if(c.sortParticles){Ca.multiplySelf(c.matrixWorld);for(e=
-0;e<u;e++)f=i[e].position,Ia.copy(f),Ca.multiplyVector3(Ia),za[e]=[Ia.z,e];za.sort(function(a,d){return d[0]-a[0]});for(e=0;e<u;e++)f=i[za[e][1]].position,h=e*3,j[h]=f.x,j[h+1]=f.y,j[h+2]=f.z;for(e=0;e<q;e++)h=e*3,color=p[za[e][1]],xa[h]=color.r,xa[h+1]=color.g,xa[h+2]=color.b;if(n){h=0;for(e=n.length;h<e;h++){u=n[h];q=u.value.length;for(p=0;p<q;p++){index=za[p][1];i=u.offset;if(u.size===1){if(u.boundTo===void 0||u.boundTo==="vertices")u.array[i]=u.value[index]}else{if(u.boundTo===void 0||u.boundTo===
+THREE.WebGLRenderer=function(a){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 c(a,b,c){var e,f,h,i=a.vertices,u=i.length,p=a.colors,q=p.length,j=a.__vertexArray,xa=a.__colorArray,za=a.__sortArray,P=a.__dirtyVertices,o=a.__dirtyColors,n=a.__webglCustomAttributesList,k;if(n){h=0;for(e=n.length;h<e;h++)n[h].offset=0}if(c.sortParticles){Ca.multiplySelf(c.matrixWorld);for(e=
+0;e<u;e++)f=i[e].position,Ha.copy(f),Ca.multiplyVector3(Ha),za[e]=[Ha.z,e];za.sort(function(a,b){return b[0]-a[0]});for(e=0;e<u;e++)f=i[za[e][1]].position,h=e*3,j[h]=f.x,j[h+1]=f.y,j[h+2]=f.z;for(e=0;e<q;e++)h=e*3,color=p[za[e][1]],xa[h]=color.r,xa[h+1]=color.g,xa[h+2]=color.b;if(n){h=0;for(e=n.length;h<e;h++){u=n[h];q=u.value.length;for(p=0;p<q;p++){index=za[p][1];i=u.offset;if(u.size===1){if(u.boundTo===void 0||u.boundTo==="vertices")u.array[i]=u.value[index]}else{if(u.boundTo===void 0||u.boundTo===
 "vertices")k=u.value[index];u.size===2?(u.array[i]=k.x,u.array[i+1]=k.y):u.size===3?u.type==="c"?(u.array[i]=k.r,u.array[i+1]=k.g,u.array[i+2]=k.b):(u.array[i]=k.x,u.array[i+1]=k.y,u.array[i+2]=k.z):(u.array[i]=k.x,u.array[i+1]=k.y,u.array[i+2]=k.z,u.array[i+3]=k.w)}u.offset+=u.size}}}}else{if(P)for(e=0;e<u;e++)f=i[e].position,h=e*3,j[h]=f.x,j[h+1]=f.y,j[h+2]=f.z;if(o)for(e=0;e<q;e++)color=p[e],h=e*3,xa[h]=color.r,xa[h+1]=color.g,xa[h+2]=color.b;if(n){h=0;for(e=n.length;h<e;h++)if(u=n[h],u.__original.needsUpdate){q=
 u.value.length;for(p=0;p<q;p++){i=u.offset;if(u.size===1){if(u.boundTo===void 0||u.boundTo==="vertices")u.array[i]=u.value[p]}else{if(u.boundTo===void 0||u.boundTo==="vertices")k=u.value[p];u.size===2?(u.array[i]=k.x,u.array[i+1]=k.y):u.size===3?u.type==="c"?(u.array[i]=k.r,u.array[i+1]=k.g,u.array[i+2]=k.b):(u.array[i]=k.x,u.array[i+1]=k.y,u.array[i+2]=k.z):(u.array[i]=k.x,u.array[i+1]=k.y,u.array[i+2]=k.z,u.array[i+3]=k.w)}u.offset+=u.size}}}}if(P||c.sortParticles)d.bindBuffer(d.ARRAY_BUFFER,a.__webglVertexBuffer),
 d.bufferData(d.ARRAY_BUFFER,j,b);if(o||c.sortParticles)d.bindBuffer(d.ARRAY_BUFFER,a.__webglColorBuffer),d.bufferData(d.ARRAY_BUFFER,xa,b);if(n){h=0;for(e=n.length;h<e;h++)if(u=n[h],u.__original.needsUpdate||c.sortParticles)d.bindBuffer(d.ARRAY_BUFFER,u.buffer),d.bufferData(d.ARRAY_BUFFER,u.array,b)}}function e(a,b,c,e,h){e.program||A.initMaterial(e,b,c,h);if(e.morphTargets&&!h.__webglMorphTargetInfluences){h.__webglMorphTargetInfluences=new Float32Array(A.maxMorphTargets);for(var f=0,i=A.maxMorphTargets;f<
@@ -201,37 +203,37 @@ d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),d.vertex
 d.UNSIGNED_SHORT,0)):(b&&d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),d.drawElements(d.TRIANGLES,f.__webglFaceCount,d.UNSIGNED_SHORT,0)),A.info.render.calls++,A.info.render.vertices+=f.__webglFaceCount,A.info.render.faces+=f.__webglFaceCount/3):i instanceof THREE.Line?(i=i.type===THREE.LineStrip?d.LINE_STRIP:d.LINES,d.lineWidth(h.linewidth),d.drawArrays(i,0,f.__webglLineCount),A.info.render.calls++):i instanceof THREE.ParticleSystem?(d.drawArrays(d.POINTS,0,f.__webglParticleCount),A.info.render.calls++):
 i instanceof THREE.Ribbon&&(d.drawArrays(d.TRIANGLE_STRIP,0,f.__webglVertexCount),A.info.render.calls++)}}function f(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=d.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=d.createBuffer();a.hasPos&&(d.bindBuffer(d.ARRAY_BUFFER,a.__webglVertexBuffer),d.bufferData(d.ARRAY_BUFFER,a.positionArray,d.DYNAMIC_DRAW),d.enableVertexAttribArray(b.attributes.position),d.vertexAttribPointer(b.attributes.position,3,d.FLOAT,!1,0,0));if(a.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,
 a.__webglNormalBuffer);if(c===THREE.FlatShading){var e,f,h,i,j,p,q,k,n,o,l=a.count*3;for(o=0;o<l;o+=9)c=a.normalArray,e=c[o],f=c[o+1],h=c[o+2],i=c[o+3],p=c[o+4],k=c[o+5],j=c[o+6],q=c[o+7],n=c[o+8],e=(e+i+j)/3,f=(f+p+q)/3,h=(h+k+n)/3,c[o]=e,c[o+1]=f,c[o+2]=h,c[o+3]=e,c[o+4]=f,c[o+5]=h,c[o+6]=e,c[o+7]=f,c[o+8]=h}d.bufferData(d.ARRAY_BUFFER,a.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(b.attributes.normal);d.vertexAttribPointer(b.attributes.normal,3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,
-0,a.count);a.count=0}function i(a){if(va!==a.doubleSided)a.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE),va=a.doubleSided;if(Ha!==a.flipSided)a.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW),Ha=a.flipSided}function j(a){wa!==a&&(a?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST),wa=a)}function n(a){Ba!==a&&(d.depthMask(a),Ba=a)}function l(a,b,c){ya!==a&&(a?d.enable(d.POLYGON_OFFSET_FILL):d.disable(d.POLYGON_OFFSET_FILL),ya=a);if(a&&($a!==b||ab!==c))d.polygonOffset(b,c),$a=b,ab=c}function o(a){Z[0].set(a.n41-
+0,a.count);a.count=0}function i(a){if(va!==a.doubleSided)a.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE),va=a.doubleSided;if(Ga!==a.flipSided)a.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW),Ga=a.flipSided}function j(a){wa!==a&&(a?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST),wa=a)}function n(a){Ba!==a&&(d.depthMask(a),Ba=a)}function l(a,b,c){ya!==a&&(a?d.enable(d.POLYGON_OFFSET_FILL):d.disable(d.POLYGON_OFFSET_FILL),ya=a);if(a&&($a!==b||ab!==c))d.polygonOffset(b,c),$a=b,ab=c}function o(a){Z[0].set(a.n41-
 a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);Z[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);Z[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);Z[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);Z[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);Z[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=Z[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function k(a){for(var b=a.matrixWorld,d=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,
 Math.max(a.scale.y,a.scale.z)),c=0;c<6;c++)if(a=Z[c].x*b.n14+Z[c].y*b.n24+Z[c].z*b.n34+Z[c].w,a<=d)return!1;return!0}function r(a){var b=a.object.material;b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function v(a){var b=a.object,d=a.buffer,c;c=b.material;if(c instanceof THREE.MeshFaceMaterial){if(d=d.materialIndex,d>=0)b=b.geometry.materials[d],b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}else if(b=c)b.transparent?(a.transparent=b,
-a.opaque=null):(a.opaque=b,a.transparent=null)}function z(a,b){return b.z-a.z}function B(a){var b,c,n,sa=0,J,l,u,p,q=a.lights;X||(X=new THREE.PerspectiveCamera(A.shadowCameraFov,A.shadowMapWidth/A.shadowMapHeight,A.shadowCameraNear,A.shadowCameraFar));b=0;for(c=q.length;b<c;b++)if(n=q[b],n instanceof THREE.SpotLight&&n.castShadow){Q=-1;A.shadowMap[sa]||(A.shadowMap[sa]=new THREE.WebGLRenderTarget(A.shadowMapWidth,A.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));
-Ra[sa]||(Ra[sa]=new THREE.Matrix4);J=A.shadowMap[sa];l=Ra[sa];X.position.copy(n.position);X.lookAt(n.target.position);X.update(void 0,!0);a.update(void 0,!1,X);l.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);l.multiplySelf(X.projectionMatrix);l.multiplySelf(X.matrixWorldInverse);X.matrixWorldInverse.flattenToArray(Ua);X.projectionMatrix.flattenToArray(Ta);Ca.multiply(X.projectionMatrix,X.matrixWorldInverse);o(Ca);la(J);d.clearColor(1,1,1,1);A.clear();d.clearColor(ga.r,ga.g,ga.b,Ea);l=a.__webglObjects.length;
-n=a.__webglObjectsImmediate.length;for(J=0;J<l;J++)u=a.__webglObjects[J],p=u.object,p.visible&&p.castShadow?!(p instanceof THREE.Mesh)||!p.frustumCulled||k(p)?(p.matrixWorld.flattenToArray(p._objectMatrixArray),E(p,X,!1),u.render=!0):u.render=!1:u.render=!1;j(!0);I(THREE.NormalBlending);for(J=0;J<l;J++)if(u=a.__webglObjects[J],u.render)p=u.object,buffer=u.buffer,i(p),u=p.customDepthMaterial?p.customDepthMaterial:p.geometry.morphTargets.length?bb:Va,h(X,q,null,u,buffer,p);for(J=0;J<n;J++)u=a.__webglObjectsImmediate[J],
-p=u.object,p.visible&&p.castShadow&&(p.matrixAutoUpdate&&p.matrixWorld.flattenToArray(p._objectMatrixArray),N=-1,E(p,X,!1),i(p),program=e(X,q,null,Va,p),p.immediateRenderCallback?p.immediateRenderCallback(program,d,Z):p.render(function(a){f(a,program,Va.shading)}));sa++}}function F(a,b){var c,e,f;c=t.attributes;var h=t.uniforms,i=Ja/Sa,j,p=[],q=Sa*0.5,k=Ja*0.5,n=!0;d.useProgram(t.program);S=t.program;N=wa=La=-1;cb||(d.enableVertexAttribArray(t.attributes.position),d.enableVertexAttribArray(t.attributes.uv),
-cb=!0);d.disable(d.CULL_FACE);d.enable(d.BLEND);d.depthMask(!0);d.bindBuffer(d.ARRAY_BUFFER,t.vertexBuffer);d.vertexAttribPointer(c.position,2,d.FLOAT,!1,16,0);d.vertexAttribPointer(c.uv,2,d.FLOAT,!1,16,8);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,t.elementBuffer);d.uniformMatrix4fv(h.projectionMatrix,!1,Ta);d.activeTexture(d.TEXTURE0);d.uniform1i(h.map,0);c=0;for(e=a.__webglSprites.length;c<e;c++)if(f=a.__webglSprites[c],f.visible&&f.opacity!==0)f.useScreenCoordinates?f.z=-f.position.z:(f._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,
-f.matrixWorld,f._modelViewMatrixArray),f.z=-f._modelViewMatrix.n34);a.__webglSprites.sort(z);c=0;for(e=a.__webglSprites.length;c<e;c++)f=a.__webglSprites[c],f.visible&&f.opacity!==0&&f.map&&f.map.image&&f.map.image.width&&(f.useScreenCoordinates?(d.uniform1i(h.useScreenCoordinates,1),d.uniform3f(h.screenPosition,(f.position.x-q)/q,(k-f.position.y)/k,Math.max(0,Math.min(1,f.position.z)))):(d.uniform1i(h.useScreenCoordinates,0),d.uniform1i(h.affectedByDistance,f.affectedByDistance?1:0),d.uniformMatrix4fv(h.modelViewMatrix,
-!1,f._modelViewMatrixArray)),j=f.map.image.width/(f.scaleByViewport?Ja:1),p[0]=j*i*f.scale.x,p[1]=j*f.scale.y,d.uniform2f(h.uvScale,f.uvScale.x,f.uvScale.y),d.uniform2f(h.uvOffset,f.uvOffset.x,f.uvOffset.y),d.uniform2f(h.alignment,f.alignment.x,f.alignment.y),d.uniform1f(h.opacity,f.opacity),d.uniform3f(h.color,f.color.r,f.color.g,f.color.b),d.uniform1f(h.rotation,f.rotation),d.uniform2fv(h.scale,p),f.mergeWith3D&&!n?(d.enable(d.DEPTH_TEST),n=!0):!f.mergeWith3D&&n&&(d.disable(d.DEPTH_TEST),n=!1),
-I(f.blending),ta(f.map,0),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0));d.enable(d.CULL_FACE);d.enable(d.DEPTH_TEST);d.depthMask(Ba)}function E(a,b,c){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(a._modelViewMatrix).transposeIntoArray(a._normalMatrixArray)}function fa(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function ia(a){for(var b in a.attributes)a.attributes[b].needsUpdate=
-!1}function ra(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function O(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function I(a){if(a!==La){switch(a){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE);break;case THREE.SubtractiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ZERO,d.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ZERO,d.SRC_COLOR);break;default:d.blendEquationSeparate(d.FUNC_ADD,
-d.FUNC_ADD),d.blendFuncSeparate(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA)}La=a}}function T(a,b,c){(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(d.texParameteri(a,d.TEXTURE_WRAP_S,K(b.wrapS)),d.texParameteri(a,d.TEXTURE_WRAP_T,K(b.wrapT)),d.texParameteri(a,d.TEXTURE_MAG_FILTER,K(b.magFilter)),d.texParameteri(a,d.TEXTURE_MIN_FILTER,K(b.minFilter)),d.generateMipmap(a)):(d.texParameteri(a,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(a,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),
-d.texParameteri(a,d.TEXTURE_MAG_FILTER,R(b.magFilter)),d.texParameteri(a,d.TEXTURE_MIN_FILTER,R(b.minFilter)))}function ta(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=d.createTexture(),A.info.memory.textures++;d.activeTexture(d.TEXTURE0+b);d.bindTexture(d.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?d.texImage2D(d.TEXTURE_2D,0,K(a.format),a.image.width,a.image.height,0,K(a.format),d.UNSIGNED_BYTE,a.image.data):d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,
-d.UNSIGNED_BYTE,a.image);T(d.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else d.activeTexture(d.TEXTURE0+b),d.bindTexture(d.TEXTURE_2D,a.__webglTexture)}function U(a,b){d.bindRenderbuffer(d.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,b.width,b.height),d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_STENCIL,b.width,b.height),d.framebufferRenderbuffer(d.FRAMEBUFFER,
-d.DEPTH_STENCIL_ATTACHMENT,d.RENDERBUFFER,a)):d.renderbufferStorage(d.RENDERBUFFER,d.RGBA4,b.width,b.height)}function la(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=d.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];d.bindTexture(d.TEXTURE_CUBE_MAP,a.__webglTexture);T(d.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=
-d.createFramebuffer();a.__webglRenderbuffer[c]=d.createRenderbuffer();d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,K(a.format),a.width,a.height,0,K(a.format),K(a.type),null);var e=a,f=d.TEXTURE_CUBE_MAP_POSITIVE_X+c;d.bindFramebuffer(d.FRAMEBUFFER,a.__webglFramebuffer[c]);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,f,e.__webglTexture,0);U(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=d.createFramebuffer(),a.__webglRenderbuffer=d.createRenderbuffer(),d.bindTexture(d.TEXTURE_2D,
-a.__webglTexture),T(d.TEXTURE_2D,a,a),d.texImage2D(d.TEXTURE_2D,0,K(a.format),a.width,a.height,0,K(a.format),K(a.type),null),c=d.TEXTURE_2D,d.bindFramebuffer(d.FRAMEBUFFER,a.__webglFramebuffer),d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,c,a.__webglTexture,0),d.bindRenderbuffer(d.RENDERBUFFER,a.__webglRenderbuffer),U(a.__webglRenderbuffer,a);b?d.bindTexture(d.TEXTURE_CUBE_MAP,null):d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,
-null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=e=0):(b=null,c=Sa,a=Ja,e=Wa,f=Xa);b!==W&&(d.bindFramebuffer(d.FRAMEBUFFER,b),d.viewport(e,f,c,a),W=b)}function pa(a){a instanceof THREE.WebGLRenderTargetCube?(d.bindTexture(d.TEXTURE_CUBE_MAP,a.__webglTexture),d.generateMipmap(d.TEXTURE_CUBE_MAP),d.bindTexture(d.TEXTURE_CUBE_MAP,null)):(d.bindTexture(d.TEXTURE_2D,a.__webglTexture),d.generateMipmap(d.TEXTURE_2D),d.bindTexture(d.TEXTURE_2D,null))}function ma(a,
-b){var c;a==="fragment"?c=d.createShader(d.FRAGMENT_SHADER):a==="vertex"&&(c=d.createShader(d.VERTEX_SHADER));d.shaderSource(c,b);d.compileShader(c);if(!d.getShaderParameter(c,d.COMPILE_STATUS))return console.error(d.getShaderInfoLog(c)),console.error(b),null;return c}function R(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return d.NEAREST;default:return d.LINEAR}}function K(a){switch(a){case THREE.RepeatWrapping:return d.REPEAT;
-case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE;
-case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var A=this,d,C=[],S=null,
-W=null,Q=-1,N=null,Aa=0,va=null,Ha=null,La=null,wa=null,Ba=null,ya=null,$a=null,ab=null,Wa=0,Xa=0,Sa=0,Ja=0,Z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ca=new THREE.Matrix4,Ta=new Float32Array(16),Ua=new Float32Array(16),Ia=new THREE.Vector4,Za={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},Da=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
+a.opaque=null):(a.opaque=b,a.transparent=null)}function z(a,b){return b.z-a.z}function B(a){var b,c,n,sa=0,J,l,u,p,q=a.lights;ja||(ja=new THREE.PerspectiveCamera(A.shadowCameraFov,A.shadowMapWidth/A.shadowMapHeight,A.shadowCameraNear,A.shadowCameraFar));b=0;for(c=q.length;b<c;b++)if(n=q[b],n instanceof THREE.SpotLight&&n.castShadow){Q=-1;A.shadowMap[sa]||(A.shadowMap[sa]=new THREE.WebGLRenderTarget(A.shadowMapWidth,A.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));
+Ra[sa]||(Ra[sa]=new THREE.Matrix4);J=A.shadowMap[sa];l=Ra[sa];ja.position.copy(n.position);ja.lookAt(n.target.position);ja.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),a.add(ja));a.updateMatrixWorld();ja.matrixWorldInverse.getInverse(ja.matrixWorld);l.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);l.multiplySelf(ja.projectionMatrix);l.multiplySelf(ja.matrixWorldInverse);ja.matrixWorldInverse.flattenToArray(Ua);ja.projectionMatrix.flattenToArray(Ta);Ca.multiply(ja.projectionMatrix,
+ja.matrixWorldInverse);o(Ca);ma(J);d.clearColor(1,1,1,1);A.clear();d.clearColor(ga.r,ga.g,ga.b,Ea);l=a.__webglObjects.length;n=a.__webglObjectsImmediate.length;for(J=0;J<l;J++)u=a.__webglObjects[J],p=u.object,p.visible&&p.castShadow?!(p instanceof THREE.Mesh)||!p.frustumCulled||k(p)?(p.matrixWorld.flattenToArray(p._objectMatrixArray),E(p,ja,!1),u.render=!0):u.render=!1:u.render=!1;j(!0);I(THREE.NormalBlending);for(J=0;J<l;J++)if(u=a.__webglObjects[J],u.render)p=u.object,buffer=u.buffer,i(p),u=p.customDepthMaterial?
+p.customDepthMaterial:p.geometry.morphTargets.length?bb:Va,h(ja,q,null,u,buffer,p);for(J=0;J<n;J++)u=a.__webglObjectsImmediate[J],p=u.object,p.visible&&p.castShadow&&(p.matrixAutoUpdate&&p.matrixWorld.flattenToArray(p._objectMatrixArray),N=-1,E(p,ja,!1),i(p),program=e(ja,q,null,Va,p),p.immediateRenderCallback?p.immediateRenderCallback(program,d,Z):p.render(function(a){f(a,program,Va.shading)}));sa++}}function F(a,b){var c,e,f;c=t.attributes;var h=t.uniforms,i=Ia/Sa,j,p=[],q=Sa*0.5,k=Ia*0.5,n=!0;d.useProgram(t.program);
+S=t.program;N=wa=Ka=-1;cb||(d.enableVertexAttribArray(t.attributes.position),d.enableVertexAttribArray(t.attributes.uv),cb=!0);d.disable(d.CULL_FACE);d.enable(d.BLEND);d.depthMask(!0);d.bindBuffer(d.ARRAY_BUFFER,t.vertexBuffer);d.vertexAttribPointer(c.position,2,d.FLOAT,!1,16,0);d.vertexAttribPointer(c.uv,2,d.FLOAT,!1,16,8);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,t.elementBuffer);d.uniformMatrix4fv(h.projectionMatrix,!1,Ta);d.activeTexture(d.TEXTURE0);d.uniform1i(h.map,0);c=0;for(e=a.__webglSprites.length;c<
+e;c++)if(f=a.__webglSprites[c],f.visible&&f.opacity!==0)f.useScreenCoordinates?f.z=-f.position.z:(f._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray),f.z=-f._modelViewMatrix.n34);a.__webglSprites.sort(z);c=0;for(e=a.__webglSprites.length;c<e;c++)f=a.__webglSprites[c],f.visible&&f.opacity!==0&&f.map&&f.map.image&&f.map.image.width&&(f.useScreenCoordinates?(d.uniform1i(h.useScreenCoordinates,1),d.uniform3f(h.screenPosition,(f.position.x-q)/q,(k-f.position.y)/
+k,Math.max(0,Math.min(1,f.position.z)))):(d.uniform1i(h.useScreenCoordinates,0),d.uniform1i(h.affectedByDistance,f.affectedByDistance?1:0),d.uniformMatrix4fv(h.modelViewMatrix,!1,f._modelViewMatrixArray)),j=f.map.image.width/(f.scaleByViewport?Ia:1),p[0]=j*i*f.scale.x,p[1]=j*f.scale.y,d.uniform2f(h.uvScale,f.uvScale.x,f.uvScale.y),d.uniform2f(h.uvOffset,f.uvOffset.x,f.uvOffset.y),d.uniform2f(h.alignment,f.alignment.x,f.alignment.y),d.uniform1f(h.opacity,f.opacity),d.uniform3f(h.color,f.color.r,f.color.g,
+f.color.b),d.uniform1f(h.rotation,f.rotation),d.uniform2fv(h.scale,p),f.mergeWith3D&&!n?(d.enable(d.DEPTH_TEST),n=!0):!f.mergeWith3D&&n&&(d.disable(d.DEPTH_TEST),n=!1),I(f.blending),ta(f.map,0),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0));d.enable(d.CULL_FACE);d.enable(d.DEPTH_TEST);d.depthMask(Ba)}function E(a,b,c){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(a._modelViewMatrix).transposeIntoArray(a._normalMatrixArray)}
+function fa(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function ia(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function ra(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function O(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function I(a){if(a!==Ka){switch(a){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE);break;case THREE.SubtractiveBlending:d.blendEquation(d.FUNC_ADD);
+d.blendFunc(d.ZERO,d.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ZERO,d.SRC_COLOR);break;default:d.blendEquationSeparate(d.FUNC_ADD,d.FUNC_ADD),d.blendFuncSeparate(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA)}Ka=a}}function T(a,b,c){(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(d.texParameteri(a,d.TEXTURE_WRAP_S,K(b.wrapS)),d.texParameteri(a,d.TEXTURE_WRAP_T,K(b.wrapT)),d.texParameteri(a,d.TEXTURE_MAG_FILTER,K(b.magFilter)),
+d.texParameteri(a,d.TEXTURE_MIN_FILTER,K(b.minFilter)),d.generateMipmap(a)):(d.texParameteri(a,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(a,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(a,d.TEXTURE_MAG_FILTER,R(b.magFilter)),d.texParameteri(a,d.TEXTURE_MIN_FILTER,R(b.minFilter)))}function ta(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=d.createTexture(),A.info.memory.textures++;d.activeTexture(d.TEXTURE0+b);d.bindTexture(d.TEXTURE_2D,a.__webglTexture);a instanceof
+THREE.DataTexture?d.texImage2D(d.TEXTURE_2D,0,K(a.format),a.image.width,a.image.height,0,K(a.format),d.UNSIGNED_BYTE,a.image.data):d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,a.image);T(d.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else d.activeTexture(d.TEXTURE0+b),d.bindTexture(d.TEXTURE_2D,a.__webglTexture)}function U(a,b){d.bindRenderbuffer(d.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,b.width,b.height),d.framebufferRenderbuffer(d.FRAMEBUFFER,
+d.DEPTH_ATTACHMENT,d.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_STENCIL,b.width,b.height),d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_STENCIL_ATTACHMENT,d.RENDERBUFFER,a)):d.renderbufferStorage(d.RENDERBUFFER,d.RGBA4,b.width,b.height)}function ma(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=d.createTexture();
+if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];d.bindTexture(d.TEXTURE_CUBE_MAP,a.__webglTexture);T(d.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=d.createFramebuffer();a.__webglRenderbuffer[c]=d.createRenderbuffer();d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,K(a.format),a.width,a.height,0,K(a.format),K(a.type),null);var e=a,f=d.TEXTURE_CUBE_MAP_POSITIVE_X+c;d.bindFramebuffer(d.FRAMEBUFFER,a.__webglFramebuffer[c]);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,
+f,e.__webglTexture,0);U(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=d.createFramebuffer(),a.__webglRenderbuffer=d.createRenderbuffer(),d.bindTexture(d.TEXTURE_2D,a.__webglTexture),T(d.TEXTURE_2D,a,a),d.texImage2D(d.TEXTURE_2D,0,K(a.format),a.width,a.height,0,K(a.format),K(a.type),null),c=d.TEXTURE_2D,d.bindFramebuffer(d.FRAMEBUFFER,a.__webglFramebuffer),d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,c,a.__webglTexture,0),d.bindRenderbuffer(d.RENDERBUFFER,a.__webglRenderbuffer),
+U(a.__webglRenderbuffer,a);b?d.bindTexture(d.TEXTURE_CUBE_MAP,null):d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=e=0):(b=null,c=Sa,a=Ia,e=Wa,f=Xa);b!==W&&(d.bindFramebuffer(d.FRAMEBUFFER,b),d.viewport(e,f,c,a),W=b)}function pa(a){a instanceof THREE.WebGLRenderTargetCube?(d.bindTexture(d.TEXTURE_CUBE_MAP,a.__webglTexture),d.generateMipmap(d.TEXTURE_CUBE_MAP),
+d.bindTexture(d.TEXTURE_CUBE_MAP,null)):(d.bindTexture(d.TEXTURE_2D,a.__webglTexture),d.generateMipmap(d.TEXTURE_2D),d.bindTexture(d.TEXTURE_2D,null))}function X(a,b){var c;a==="fragment"?c=d.createShader(d.FRAGMENT_SHADER):a==="vertex"&&(c=d.createShader(d.VERTEX_SHADER));d.shaderSource(c,b);d.compileShader(c);if(!d.getShaderParameter(c,d.COMPILE_STATUS))return console.error(d.getShaderInfoLog(c)),console.error(b),null;return c}function R(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return d.NEAREST;
+default:return d.LINEAR}}function K(a){switch(a){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;
+case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}
+var A=this,d,C=[],S=null,W=null,Q=-1,N=null,Aa=0,va=null,Ga=null,Ka=null,wa=null,Ba=null,ya=null,$a=null,ab=null,Wa=0,Xa=0,Sa=0,Ia=0,Z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ca=new THREE.Matrix4,Ta=new Float32Array(16),Ua=new Float32Array(16),Ha=new THREE.Vector4,Za={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},Da=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
 H=a.stencil!==void 0?a.stencil:!0,fb=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,gb=a.antialias!==void 0?a.antialias:!1,ga=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),Ea=a.clearAlpha!==void 0?a.clearAlpha:0,Ya=a.maxLights!==void 0?a.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Da;this.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;var X,Ra=[],a=THREE.ShaderLib.depthRGBA,db=THREE.UniformsUtils.clone(a.uniforms),Va=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,
+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;var ja,Ra=[],a=THREE.ShaderLib.depthRGBA,db=THREE.UniformsUtils.clone(a.uniforms),Va=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,
 vertexShader:a.vertexShader,uniforms:db}),bb=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:db,morphTargets:!0});Va._shadowPass=!0;bb._shadowPass=!0;try{if(!(d=Da.getContext("experimental-webgl",{antialias:gb,stencil:H,preserveDrawingBuffer:fb})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+d.getParameter(d.VERSION)+" | "+d.getParameter(d.VENDOR)+" | "+d.getParameter(d.RENDERER)+" | "+d.getParameter(d.SHADING_LANGUAGE_VERSION))}catch(hb){console.error(hb)}d.clearColor(0,
 0,0,1);d.clearDepth(1);d.clearStencil(0);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA);d.clearColor(ga.r,ga.g,ga.b,Ea);this.context=d;var eb=d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,t={};t.vertices=new Float32Array(16);t.faces=new Uint16Array(6);H=0;t.vertices[H++]=-1;t.vertices[H++]=-1;t.vertices[H++]=0;t.vertices[H++]=1;t.vertices[H++]=
 1;t.vertices[H++]=-1;t.vertices[H++]=1;t.vertices[H++]=1;t.vertices[H++]=1;t.vertices[H++]=1;t.vertices[H++]=1;t.vertices[H++]=0;t.vertices[H++]=-1;t.vertices[H++]=1;t.vertices[H++]=0;H=t.vertices[H++]=0;t.faces[H++]=0;t.faces[H++]=1;t.faces[H++]=2;t.faces[H++]=0;t.faces[H++]=2;t.faces[H++]=3;t.vertexBuffer=d.createBuffer();t.elementBuffer=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,t.vertexBuffer);d.bufferData(d.ARRAY_BUFFER,t.vertices,d.STATIC_DRAW);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,t.elementBuffer);
-d.bufferData(d.ELEMENT_ARRAY_BUFFER,t.faces,d.STATIC_DRAW);t.program=d.createProgram();d.attachShader(t.program,ma("fragment",THREE.ShaderLib.sprite.fragmentShader));d.attachShader(t.program,ma("vertex",THREE.ShaderLib.sprite.vertexShader));d.linkProgram(t.program);t.attributes={};t.uniforms={};t.attributes.position=d.getAttribLocation(t.program,"position");t.attributes.uv=d.getAttribLocation(t.program,"uv");t.uniforms.uvOffset=d.getUniformLocation(t.program,"uvOffset");t.uniforms.uvScale=d.getUniformLocation(t.program,
+d.bufferData(d.ELEMENT_ARRAY_BUFFER,t.faces,d.STATIC_DRAW);t.program=d.createProgram();d.attachShader(t.program,X("fragment",THREE.ShaderLib.sprite.fragmentShader));d.attachShader(t.program,X("vertex",THREE.ShaderLib.sprite.vertexShader));d.linkProgram(t.program);t.attributes={};t.uniforms={};t.attributes.position=d.getAttribLocation(t.program,"position");t.attributes.uv=d.getAttribLocation(t.program,"uv");t.uniforms.uvOffset=d.getUniformLocation(t.program,"uvOffset");t.uniforms.uvScale=d.getUniformLocation(t.program,
 "uvScale");t.uniforms.rotation=d.getUniformLocation(t.program,"rotation");t.uniforms.scale=d.getUniformLocation(t.program,"scale");t.uniforms.alignment=d.getUniformLocation(t.program,"alignment");t.uniforms.color=d.getUniformLocation(t.program,"color");t.uniforms.map=d.getUniformLocation(t.program,"map");t.uniforms.opacity=d.getUniformLocation(t.program,"opacity");t.uniforms.useScreenCoordinates=d.getUniformLocation(t.program,"useScreenCoordinates");t.uniforms.affectedByDistance=d.getUniformLocation(t.program,
-"affectedByDistance");t.uniforms.screenPosition=d.getUniformLocation(t.program,"screenPosition");t.uniforms.modelViewMatrix=d.getUniformLocation(t.program,"modelViewMatrix");t.uniforms.projectionMatrix=d.getUniformLocation(t.program,"projectionMatrix");var cb=!1;this.setSize=function(a,b){Da.width=a;Da.height=b;this.setViewport(0,0,Da.width,Da.height)};this.setViewport=function(a,b,c,e){Wa=a;Xa=b;Sa=c;Ja=e;d.viewport(Wa,Xa,Sa,Ja)};this.setScissor=function(a,b,c,e){d.scissor(a,b,c,e)};this.enableScissorTest=
+"affectedByDistance");t.uniforms.screenPosition=d.getUniformLocation(t.program,"screenPosition");t.uniforms.modelViewMatrix=d.getUniformLocation(t.program,"modelViewMatrix");t.uniforms.projectionMatrix=d.getUniformLocation(t.program,"projectionMatrix");var cb=!1;this.setSize=function(a,b){Da.width=a;Da.height=b;this.setViewport(0,0,Da.width,Da.height)};this.setViewport=function(a,b,c,e){Wa=a;Xa=b;Sa=c;Ia=e;d.viewport(Wa,Xa,Sa,Ia)};this.setScissor=function(a,b,c,e){d.scissor(a,b,c,e)};this.enableScissorTest=
 function(a){a?d.enable(d.SCISSOR_TEST):d.disable(d.SCISSOR_TEST)};this.setClearColorHex=function(a,b){ga.setHex(a);Ea=b;d.clearColor(ga.r,ga.g,ga.b,Ea)};this.setClearColor=function(a,b){ga.copy(a);Ea=b;d.clearColor(ga.r,ga.g,ga.b,Ea)};this.getClearColor=function(){return ga};this.getClearAlpha=function(){return Ea};this.clear=function(a,b,c){var e=0;if(a===void 0||a)e|=d.COLOR_BUFFER_BIT;if(b===void 0||b)e|=d.DEPTH_BUFFER_BIT;if(c===void 0||c)e|=d.STENCIL_BUFFER_BIT;d.clear(e)};this.getContext=function(){return 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(g in a.geometry.geometryGroups){var b=a.geometry.geometryGroups[g];d.deleteBuffer(b.__webglVertexBuffer);d.deleteBuffer(b.__webglNormalBuffer);d.deleteBuffer(b.__webglTangentBuffer);d.deleteBuffer(b.__webglColorBuffer);d.deleteBuffer(b.__webglUVBuffer);d.deleteBuffer(b.__webglUV2Buffer);d.deleteBuffer(b.__webglSkinVertexABuffer);
 d.deleteBuffer(b.__webglSkinVertexBBuffer);d.deleteBuffer(b.__webglSkinIndicesBuffer);d.deleteBuffer(b.__webglSkinWeightsBuffer);d.deleteBuffer(b.__webglFaceBuffer);d.deleteBuffer(b.__webglLineBuffer);if(b.numMorphTargets)for(var c=0,e=b.numMorphTargets;c<e;c++)d.deleteBuffer(b.__webglMorphTargetsBuffers[c]);A.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,d.deleteBuffer(a.__webglVertexBuffer),d.deleteBuffer(a.__webglColorBuffer),A.info.memory.geometries--;else if(a instanceof
@@ -242,16 +244,16 @@ sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTarget
 for(e=C.length;r<e;r++)if(C[r].code===j){l=C[r].program;break a}r=d.createProgram();e=[eb?"#define VERTEX_TEXTURES":"",A.gammaInput?"#define GAMMA_INPUT":"",A.gammaOutput?"#define GAMMA_OUTPUT":"",A.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.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");
 i=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",A.gammaInput?"#define GAMMA_INPUT":"",A.gammaOutput?"#define GAMMA_OUTPUT":"",A.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");d.attachShader(r,ma("fragment",i+q));d.attachShader(r,
-ma("vertex",e+k));d.linkProgram(r);d.getProgramParameter(r,d.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+d.getProgramParameter(r,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");r.uniforms={};r.attributes={};var v,e=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(v in p)e.push(v);v=e;e=0;for(p=v.length;e<p;e++)q=v[e],r.uniforms[q]=d.getUniformLocation(r,
+"",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");d.attachShader(r,X("fragment",i+q));d.attachShader(r,
+X("vertex",e+k));d.linkProgram(r);d.getProgramParameter(r,d.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+d.getProgramParameter(r,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");r.uniforms={};r.attributes={};var v,e=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(v in p)e.push(v);v=e;e=0;for(p=v.length;e<p;e++)q=v[e],r.uniforms[q]=d.getUniformLocation(r,
 q);e=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(v=0;v<c.maxMorphTargets;v++)e.push("morphTarget"+v);for(l in b)e.push(l);l=e;v=0;for(b=l.length;v<b;v++)c=l[v],r.attributes[c]=d.getAttribLocation(r,c);r.id=C.length;C.push({program:r,code:j});A.info.memory.programs=C.length;l=r}a.program=l;l=a.program.attributes;l.position>=0&&d.enableVertexAttribArray(l.position);l.color>=0&&d.enableVertexAttribArray(l.color);l.normal>=0&&d.enableVertexAttribArray(l.normal);
 l.tangent>=0&&d.enableVertexAttribArray(l.tangent);a.skinning&&l.skinVertexA>=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0&&(d.enableVertexAttribArray(l.skinVertexA),d.enableVertexAttribArray(l.skinVertexB),d.enableVertexAttribArray(l.skinIndex),d.enableVertexAttribArray(l.skinWeight));if(a.attributes)for(h in a.attributes)l[h]!==void 0&&l[h]>=0&&d.enableVertexAttribArray(l[h]);if(a.morphTargets)for(h=a.numSupportedMorphTargets=0;h<this.maxMorphTargets;h++)v="morphTarget"+h,l[v]>=0&&(d.enableVertexAttribArray(l[v]),
-a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,b,c,d){la(a);this.clear(b,c,d)};this.updateShadowMap=function(a,b){B(a,b)};this.render=function(a,b,c,t){var sa,J,Fa,u,p,q,Qa,xa=a.lights,za=a.fog;Q=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&B(a,b);A.info.render.calls=0;A.info.render.vertices=0;A.info.render.faces=0;if(b.matrixAutoUpdate){for(Fa=b;Fa.parent;)Fa=
-Fa.parent;Fa.update(void 0,!0)}a.update(void 0,!1,b);b.matrixWorldInverse.flattenToArray(Ua);b.projectionMatrix.flattenToArray(Ta);Ca.multiply(b.projectionMatrix,b.matrixWorldInverse);o(Ca);la(c);(this.autoClear||t)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);Fa=a.__webglObjects.length;for(t=0;t<Fa;t++)if(p=a.__webglObjects[t],q=p.object,q.visible)if(!(q instanceof THREE.Mesh)||!q.frustumCulled||k(q)){if(q.matrixWorld.flattenToArray(q._objectMatrixArray),E(q,b,!0),v(p),
-p.render=!0,this.sortObjects)q.renderDepth?p.z=q.renderDepth:(Ia.copy(q.position),Ca.multiplyVector3(Ia),p.z=Ia.z)}else p.render=!1;else p.render=!1;this.sortObjects&&a.__webglObjects.sort(z);u=a.__webglObjectsImmediate.length;for(t=0;t<u;t++)p=a.__webglObjectsImmediate[t],q=p.object,q.visible&&(q.matrixAutoUpdate&&q.matrixWorld.flattenToArray(q._objectMatrixArray),E(q,b,!0),r(p));if(a.overrideMaterial){j(a.overrideMaterial.depthTest);I(a.overrideMaterial.blending);for(t=0;t<Fa;t++)if(p=a.__webglObjects[t],
-p.render)q=p.object,Qa=p.buffer,i(q),h(b,xa,za,a.overrideMaterial,Qa,q);for(t=0;t<u;t++)p=a.__webglObjectsImmediate[t],q=p.object,q.visible&&(N=-1,i(q),sa=e(b,xa,za,a.overrideMaterial,q),q.immediateRenderCallback?q.immediateRenderCallback(sa,d,Z):q.render(function(b){f(b,sa,a.overrideMaterial.shading)}))}else{I(THREE.NormalBlending);for(t=Fa-1;t>=0;t--)if(p=a.__webglObjects[t],p.render&&(q=p.object,Qa=p.buffer,J=p.opaque))i(q),j(J.depthTest),n(J.depthWrite),l(J.polygonOffset,J.polygonOffsetFactor,
-J.polygonOffsetUnits),h(b,xa,za,J,Qa,q);for(t=0;t<u;t++)if(p=a.__webglObjectsImmediate[t],q=p.object,q.visible&&(N=-1,J=p.opaque))i(q),j(J.depthTest),n(J.depthWrite),l(J.polygonOffset,J.polygonOffsetFactor,J.polygonOffsetUnits),sa=e(b,xa,za,J,q),q.immediateRenderCallback?q.immediateRenderCallback(sa,d,Z):q.render(function(a){f(a,sa,J.shading)});for(t=0;t<Fa;t++)if(p=a.__webglObjects[t],p.render&&(q=p.object,Qa=p.buffer,J=p.transparent))i(q),I(J.blending),j(J.depthTest),n(J.depthWrite),l(J.polygonOffset,
-J.polygonOffsetFactor,J.polygonOffsetUnits),h(b,xa,za,J,Qa,q);for(t=0;t<u;t++)if(p=a.__webglObjectsImmediate[t],q=p.object,q.visible&&(N=-1,J=p.transparent))i(q),I(J.blending),j(J.depthTest),n(J.depthWrite),l(J.polygonOffset,J.polygonOffsetFactor,J.polygonOffsetUnits),sa=e(b,xa,za,J,q),q.immediateRenderCallback?q.immediateRenderCallback(sa,d,Z):q.render(function(a){f(a,sa,J.shading)})}a.__webglSprites.length&&F(a,b);c&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&pa(c)};this.initWebGLObjects=
+a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,b,c,d){ma(a);this.clear(b,c,d)};this.updateShadowMap=function(a,b){B(a,b)};this.render=function(a,b,c,t){var sa,J,Qa,u,p,q,Pa,xa=a.lights,za=a.fog;Q=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&B(a,b);A.info.render.calls=0;A.info.render.vertices=0;A.info.render.faces=0;b.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),
+a.add(b));a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(Ua);b.projectionMatrix.flattenToArray(Ta);Ca.multiply(b.projectionMatrix,b.matrixWorldInverse);o(Ca);ma(c);(this.autoClear||t)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);Qa=a.__webglObjects.length;for(t=0;t<Qa;t++)if(p=a.__webglObjects[t],q=p.object,q.visible)if(!(q instanceof THREE.Mesh)||!q.frustumCulled||k(q)){if(q.matrixWorld.flattenToArray(q._objectMatrixArray),
+E(q,b,!0),v(p),p.render=!0,this.sortObjects)q.renderDepth?p.z=q.renderDepth:(Ha.copy(q.position),Ca.multiplyVector3(Ha),p.z=Ha.z)}else p.render=!1;else p.render=!1;this.sortObjects&&a.__webglObjects.sort(z);u=a.__webglObjectsImmediate.length;for(t=0;t<u;t++)p=a.__webglObjectsImmediate[t],q=p.object,q.visible&&(q.matrixAutoUpdate&&q.matrixWorld.flattenToArray(q._objectMatrixArray),E(q,b,!0),r(p));if(a.overrideMaterial){j(a.overrideMaterial.depthTest);I(a.overrideMaterial.blending);for(t=0;t<Qa;t++)if(p=
+a.__webglObjects[t],p.render)q=p.object,Pa=p.buffer,i(q),h(b,xa,za,a.overrideMaterial,Pa,q);for(t=0;t<u;t++)p=a.__webglObjectsImmediate[t],q=p.object,q.visible&&(N=-1,i(q),sa=e(b,xa,za,a.overrideMaterial,q),q.immediateRenderCallback?q.immediateRenderCallback(sa,d,Z):q.render(function(b){f(b,sa,a.overrideMaterial.shading)}))}else{I(THREE.NormalBlending);for(t=Qa-1;t>=0;t--)if(p=a.__webglObjects[t],p.render&&(q=p.object,Pa=p.buffer,J=p.opaque))i(q),j(J.depthTest),n(J.depthWrite),l(J.polygonOffset,J.polygonOffsetFactor,
+J.polygonOffsetUnits),h(b,xa,za,J,Pa,q);for(t=0;t<u;t++)if(p=a.__webglObjectsImmediate[t],q=p.object,q.visible&&(N=-1,J=p.opaque))i(q),j(J.depthTest),n(J.depthWrite),l(J.polygonOffset,J.polygonOffsetFactor,J.polygonOffsetUnits),sa=e(b,xa,za,J,q),q.immediateRenderCallback?q.immediateRenderCallback(sa,d,Z):q.render(function(a){f(a,sa,J.shading)});for(t=0;t<Qa;t++)if(p=a.__webglObjects[t],p.render&&(q=p.object,Pa=p.buffer,J=p.transparent))i(q),I(J.blending),j(J.depthTest),n(J.depthWrite),l(J.polygonOffset,
+J.polygonOffsetFactor,J.polygonOffsetUnits),h(b,xa,za,J,Pa,q);for(t=0;t<u;t++)if(p=a.__webglObjectsImmediate[t],q=p.object,q.visible&&(N=-1,J=p.transparent))i(q),I(J.blending),j(J.depthTest),n(J.depthWrite),l(J.polygonOffset,J.polygonOffsetFactor,J.polygonOffsetUnits),sa=e(b,xa,za,J,q),q.immediateRenderCallback?q.immediateRenderCallback(sa,d,Z):q.render(function(a){f(a,sa,J.shading)})}a.__webglSprites.length&&F(a,b);c&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&pa(c)};this.initWebGLObjects=
 function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[];for(;a.__objectsAdded.length;){var e=a.__objectsAdded[0],f=a,h=void 0,i=void 0,j=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){i=e.geometry;if(i.geometryGroups===
 void 0){var j=i,k=void 0,n=void 0,p=void 0,q=void 0,l=p=void 0,o=void 0,r={},t=j.morphTargets.length;j.geometryGroups={};k=0;for(n=j.faces.length;k<n;k++)p=j.faces[k],q=p.materialIndex,l=q!==void 0?q:-1,r[l]===void 0&&(r[l]={hash:l,counter:0}),o=r[l].hash+"_"+r[l].counter,j.geometryGroups[o]===void 0&&(j.geometryGroups[o]={faces:[],materialIndex:q,vertices:0,numMorphTargets:t}),p=p instanceof THREE.Face3?3:4,j.geometryGroups[o].vertices+p>65535&&(r[l].counter+=1,o=r[l].hash+"_"+r[l].counter,j.geometryGroups[o]===
 void 0&&(j.geometryGroups[o]={faces:[],materialIndex:q,vertices:0,numMorphTargets:t})),j.geometryGroups[o].faces.push(k),j.geometryGroups[o].vertices+=p;j.geometryGroupsList=[];k=void 0;for(k in j.geometryGroups)j.geometryGroups[k].id=Aa++,j.geometryGroupsList.push(j.geometryGroups[k])}for(h in i.geometryGroups)if(j=i.geometryGroups[h],!j.__webglVertexBuffer){k=j;k.__webglVertexBuffer=d.createBuffer();k.__webglNormalBuffer=d.createBuffer();k.__webglTangentBuffer=d.createBuffer();k.__webglColorBuffer=
@@ -266,26 +268,26 @@ j.__webglColorBuffer=d.createBuffer(),A.info.memory.geometries++,j=i,k=j.vertice
 attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(k*size),attribute.buffer=d.createBuffer(),attribute.buffer.belongsToAttribute=q,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;j.__webglCustomAttributesList.push(attribute)}}i.__dirtyVertices=!0;i.__dirtyColors=!0}if(!e.__webglActive){if(e instanceof THREE.Mesh)for(h in i=e.geometry,i.geometryGroups)j=i.geometryGroups[h],O(f.__webglObjects,j,e);else e instanceof THREE.Ribbon||e instanceof THREE.Line||
 e instanceof THREE.ParticleSystem?(i=e.geometry,O(f.__webglObjects,i,e)):THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes||e.immediateRenderCallback?f.__webglObjectsImmediate.push({object:e,opaque:null,transparent:null}):e instanceof THREE.Sprite&&f.__webglSprites.push(e);e.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){e=a.__objectsRemoved[0];f=a;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)ra(f.__webglObjects,
 e);else if(e instanceof THREE.Sprite){f=f.__webglSprites;h=e;for(i=f.length-1;i>=0;i--)f[i]===h&&f.splice(i,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&ra(f.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(f=a.__webglObjects.length;e<f;e++)if(i=a.__webglObjects[e].object,h=i.geometry,j=l=q=void 0,i instanceof THREE.Mesh){k=0;for(n=h.geometryGroupsList.length;k<n;k++)if(q=h.geometryGroupsList[k],j=b(i,q),l=j.attributes&&fa(j),h.__dirtyVertices||
-h.__dirtyMorphTargets||h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||l)if(l=d.DYNAMIC_DRAW,o=!h.dynamic,q.__inittedArrays){var C=t=r=void 0,y=void 0,F=C=void 0,E=void 0,K=void 0,N=void 0,U=v=B=z=p=void 0,G=void 0,L=void 0,M=void 0,H=void 0,w=y=N=y=K=E=void 0,D=void 0,s=D=w=E=void 0,m=void 0,s=D=w=C=C=F=D=w=y=s=D=w=m=s=D=w=m=s=D=w=void 0,ha=0,I=0,T=0,W=0,S=0,Q=0,Y=0,R=0,ja=0,x=0,ka=0,V=s=0,V=void 0,na=q.__vertexArray,la=q.__uvArray,ma=q.__uv2Array,X=q.__normalArray,
-$=q.__tangentArray,oa=q.__colorArray,aa=q.__skinVertexAArray,ca=q.__skinVertexBArray,da=q.__skinIndexArray,ea=q.__skinWeightArray,pa=q.__morphTargetsArrays,Z=q.__webglCustomAttributesList,m=void 0,ga=q.__faceArray,ua=q.__lineArray,ta=q.__needsSmoothNormals,z=q.__vertexColorType,p=q.__uvType,B=q.__normalType,qa=i.geometry,va=qa.__dirtyVertices,ya=qa.__dirtyElements,wa=qa.__dirtyUvs,Ba=qa.__dirtyNormals,Ca=qa.__dirtyTangents,Da=qa.__dirtyColors,Ea=qa.__dirtyMorphTargets,Ma=qa.vertices,Ha=q.faces,La=
-qa.faces,Ia=qa.faceVertexUvs[0],Ja=qa.faceVertexUvs[1],Na=qa.skinVerticesA,Oa=qa.skinVerticesB,Pa=qa.skinIndices,Ka=qa.skinWeights,Ga=qa.morphTargets;if(Z){w=0;for(D=Z.length;w<D;w++)Z[w].offset=0,Z[w].offsetSrc=0}r=0;for(t=Ha.length;r<t;r++)if(C=Ha[r],y=La[C],Ia&&(v=Ia[C]),Ja&&(U=Ja[C]),C=y.vertexNormals,F=y.normal,E=y.vertexColors,K=y.color,N=y.vertexTangents,y instanceof THREE.Face3){if(va)G=Ma[y.a].position,L=Ma[y.b].position,M=Ma[y.c].position,na[I]=G.x,na[I+1]=G.y,na[I+2]=G.z,na[I+3]=L.x,na[I+
+h.__dirtyMorphTargets||h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||l)if(l=d.DYNAMIC_DRAW,o=!h.dynamic,q.__inittedArrays){var C=t=r=void 0,y=void 0,F=C=void 0,E=void 0,K=void 0,N=void 0,U=v=B=z=p=void 0,G=void 0,L=void 0,M=void 0,H=void 0,w=y=N=y=K=E=void 0,D=void 0,s=D=w=E=void 0,m=void 0,s=D=w=C=C=F=D=w=y=s=D=w=m=s=D=w=m=s=D=w=void 0,ha=0,I=0,T=0,W=0,S=0,Q=0,Y=0,R=0,ka=0,x=0,la=0,V=s=0,V=void 0,na=q.__vertexArray,ja=q.__uvArray,ma=q.__uv2Array,X=q.__normalArray,
+$=q.__tangentArray,oa=q.__colorArray,aa=q.__skinVertexAArray,ca=q.__skinVertexBArray,da=q.__skinIndexArray,ea=q.__skinWeightArray,pa=q.__morphTargetsArrays,Z=q.__webglCustomAttributesList,m=void 0,ga=q.__faceArray,ua=q.__lineArray,ta=q.__needsSmoothNormals,z=q.__vertexColorType,p=q.__uvType,B=q.__normalType,qa=i.geometry,va=qa.__dirtyVertices,ya=qa.__dirtyElements,wa=qa.__dirtyUvs,Ba=qa.__dirtyNormals,Ca=qa.__dirtyTangents,Da=qa.__dirtyColors,Ea=qa.__dirtyMorphTargets,La=qa.vertices,Ga=q.faces,Ka=
+qa.faces,Ha=qa.faceVertexUvs[0],Ia=qa.faceVertexUvs[1],Ma=qa.skinVerticesA,Na=qa.skinVerticesB,Oa=qa.skinIndices,Ja=qa.skinWeights,Fa=qa.morphTargets;if(Z){w=0;for(D=Z.length;w<D;w++)Z[w].offset=0,Z[w].offsetSrc=0}r=0;for(t=Ga.length;r<t;r++)if(C=Ga[r],y=Ka[C],Ha&&(v=Ha[C]),Ia&&(U=Ia[C]),C=y.vertexNormals,F=y.normal,E=y.vertexColors,K=y.color,N=y.vertexTangents,y instanceof THREE.Face3){if(va)G=La[y.a].position,L=La[y.b].position,M=La[y.c].position,na[I]=G.x,na[I+1]=G.y,na[I+2]=G.z,na[I+3]=L.x,na[I+
 4]=L.y,na[I+5]=L.z,na[I+6]=M.x,na[I+7]=M.y,na[I+8]=M.z,I+=9;if(Z){w=0;for(D=Z.length;w<D;w++)if(m=Z[w],m.__original.needsUpdate)s=m.offset,V=m.offsetSrc,m.size===1?(m.boundTo===void 0||m.boundTo==="vertices"?(m.array[s]=m.value[y.a],m.array[s+1]=m.value[y.b],m.array[s+2]=m.value[y.c]):m.boundTo==="faces"?(V=m.value[V],m.array[s]=V,m.array[s+1]=V,m.array[s+2]=V,m.offsetSrc++):m.boundTo==="faceVertices"&&(m.array[s]=m.value[V],m.array[s+1]=m.value[V+1],m.array[s+2]=m.value[V+2],m.offsetSrc+=3),m.offset+=
 3):(m.boundTo===void 0||m.boundTo==="vertices"?(G=m.value[y.a],L=m.value[y.b],M=m.value[y.c]):m.boundTo==="faces"?(M=L=G=V=m.value[V],m.offsetSrc++):m.boundTo==="faceVertices"&&(G=m.value[V],L=m.value[V+1],M=m.value[V+2],m.offsetSrc+=3),m.size===2?(m.array[s]=G.x,m.array[s+1]=G.y,m.array[s+2]=L.x,m.array[s+3]=L.y,m.array[s+4]=M.x,m.array[s+5]=M.y,m.offset+=6):m.size===3?(m.type==="c"?(m.array[s]=G.r,m.array[s+1]=G.g,m.array[s+2]=G.b,m.array[s+3]=L.r,m.array[s+4]=L.g,m.array[s+5]=L.b,m.array[s+6]=
-M.r,m.array[s+7]=M.g,m.array[s+8]=M.b):(m.array[s]=G.x,m.array[s+1]=G.y,m.array[s+2]=G.z,m.array[s+3]=L.x,m.array[s+4]=L.y,m.array[s+5]=L.z,m.array[s+6]=M.x,m.array[s+7]=M.y,m.array[s+8]=M.z),m.offset+=9):(m.array[s]=G.x,m.array[s+1]=G.y,m.array[s+2]=G.z,m.array[s+3]=G.w,m.array[s+4]=L.x,m.array[s+5]=L.y,m.array[s+6]=L.z,m.array[s+7]=L.w,m.array[s+8]=M.x,m.array[s+9]=M.y,m.array[s+10]=M.z,m.array[s+11]=M.w,m.offset+=12))}if(Ea){w=0;for(D=Ga.length;w<D;w++)G=Ga[w].vertices[y.a].position,L=Ga[w].vertices[y.b].position,
-M=Ga[w].vertices[y.c].position,s=pa[w],s[ka]=G.x,s[ka+1]=G.y,s[ka+2]=G.z,s[ka+3]=L.x,s[ka+4]=L.y,s[ka+5]=L.z,s[ka+6]=M.x,s[ka+7]=M.y,s[ka+8]=M.z;ka+=9}if(Ka.length)w=Ka[y.a],D=Ka[y.b],s=Ka[y.c],ea[x]=w.x,ea[x+1]=w.y,ea[x+2]=w.z,ea[x+3]=w.w,ea[x+4]=D.x,ea[x+5]=D.y,ea[x+6]=D.z,ea[x+7]=D.w,ea[x+8]=s.x,ea[x+9]=s.y,ea[x+10]=s.z,ea[x+11]=s.w,w=Pa[y.a],D=Pa[y.b],s=Pa[y.c],da[x]=w.x,da[x+1]=w.y,da[x+2]=w.z,da[x+3]=w.w,da[x+4]=D.x,da[x+5]=D.y,da[x+6]=D.z,da[x+7]=D.w,da[x+8]=s.x,da[x+9]=s.y,da[x+10]=s.z,da[x+
-11]=s.w,w=Na[y.a],D=Na[y.b],s=Na[y.c],aa[x]=w.x,aa[x+1]=w.y,aa[x+2]=w.z,aa[x+3]=1,aa[x+4]=D.x,aa[x+5]=D.y,aa[x+6]=D.z,aa[x+7]=1,aa[x+8]=s.x,aa[x+9]=s.y,aa[x+10]=s.z,aa[x+11]=1,w=Oa[y.a],D=Oa[y.b],s=Oa[y.c],ca[x]=w.x,ca[x+1]=w.y,ca[x+2]=w.z,ca[x+3]=1,ca[x+4]=D.x,ca[x+5]=D.y,ca[x+6]=D.z,ca[x+7]=1,ca[x+8]=s.x,ca[x+9]=s.y,ca[x+10]=s.z,ca[x+11]=1,x+=12;if(Da&&z)E.length===3&&z===THREE.VertexColors?(y=E[0],w=E[1],D=E[2]):D=w=y=K,oa[ja]=y.r,oa[ja+1]=y.g,oa[ja+2]=y.b,oa[ja+3]=w.r,oa[ja+4]=w.g,oa[ja+5]=w.b,
-oa[ja+6]=D.r,oa[ja+7]=D.g,oa[ja+8]=D.b,ja+=9;if(Ca&&qa.hasTangents)E=N[0],K=N[1],y=N[2],$[Y]=E.x,$[Y+1]=E.y,$[Y+2]=E.z,$[Y+3]=E.w,$[Y+4]=K.x,$[Y+5]=K.y,$[Y+6]=K.z,$[Y+7]=K.w,$[Y+8]=y.x,$[Y+9]=y.y,$[Y+10]=y.z,$[Y+11]=y.w,Y+=12;if(Ba&&B)if(C.length===3&&ta)for(w=0;w<3;w++)F=C[w],X[Q]=F.x,X[Q+1]=F.y,X[Q+2]=F.z,Q+=3;else for(w=0;w<3;w++)X[Q]=F.x,X[Q+1]=F.y,X[Q+2]=F.z,Q+=3;if(wa&&v!==void 0&&p)for(w=0;w<3;w++)C=v[w],la[T]=C.u,la[T+1]=C.v,T+=2;if(wa&&U!==void 0&&p)for(w=0;w<3;w++)C=U[w],ma[W]=C.u,ma[W+
-1]=C.v,W+=2;ya&&(ga[S]=ha,ga[S+1]=ha+1,ga[S+2]=ha+2,S+=3,ua[R]=ha,ua[R+1]=ha+1,ua[R+2]=ha,ua[R+3]=ha+2,ua[R+4]=ha+1,ua[R+5]=ha+2,R+=6,ha+=3)}else if(y instanceof THREE.Face4){if(va)G=Ma[y.a].position,L=Ma[y.b].position,M=Ma[y.c].position,H=Ma[y.d].position,na[I]=G.x,na[I+1]=G.y,na[I+2]=G.z,na[I+3]=L.x,na[I+4]=L.y,na[I+5]=L.z,na[I+6]=M.x,na[I+7]=M.y,na[I+8]=M.z,na[I+9]=H.x,na[I+10]=H.y,na[I+11]=H.z,I+=12;if(Z){w=0;for(D=Z.length;w<D;w++)if(m=Z[w],m.__original.needsUpdate)s=m.offset,V=m.offsetSrc,m.size===
+M.r,m.array[s+7]=M.g,m.array[s+8]=M.b):(m.array[s]=G.x,m.array[s+1]=G.y,m.array[s+2]=G.z,m.array[s+3]=L.x,m.array[s+4]=L.y,m.array[s+5]=L.z,m.array[s+6]=M.x,m.array[s+7]=M.y,m.array[s+8]=M.z),m.offset+=9):(m.array[s]=G.x,m.array[s+1]=G.y,m.array[s+2]=G.z,m.array[s+3]=G.w,m.array[s+4]=L.x,m.array[s+5]=L.y,m.array[s+6]=L.z,m.array[s+7]=L.w,m.array[s+8]=M.x,m.array[s+9]=M.y,m.array[s+10]=M.z,m.array[s+11]=M.w,m.offset+=12))}if(Ea){w=0;for(D=Fa.length;w<D;w++)G=Fa[w].vertices[y.a].position,L=Fa[w].vertices[y.b].position,
+M=Fa[w].vertices[y.c].position,s=pa[w],s[la]=G.x,s[la+1]=G.y,s[la+2]=G.z,s[la+3]=L.x,s[la+4]=L.y,s[la+5]=L.z,s[la+6]=M.x,s[la+7]=M.y,s[la+8]=M.z;la+=9}if(Ja.length)w=Ja[y.a],D=Ja[y.b],s=Ja[y.c],ea[x]=w.x,ea[x+1]=w.y,ea[x+2]=w.z,ea[x+3]=w.w,ea[x+4]=D.x,ea[x+5]=D.y,ea[x+6]=D.z,ea[x+7]=D.w,ea[x+8]=s.x,ea[x+9]=s.y,ea[x+10]=s.z,ea[x+11]=s.w,w=Oa[y.a],D=Oa[y.b],s=Oa[y.c],da[x]=w.x,da[x+1]=w.y,da[x+2]=w.z,da[x+3]=w.w,da[x+4]=D.x,da[x+5]=D.y,da[x+6]=D.z,da[x+7]=D.w,da[x+8]=s.x,da[x+9]=s.y,da[x+10]=s.z,da[x+
+11]=s.w,w=Ma[y.a],D=Ma[y.b],s=Ma[y.c],aa[x]=w.x,aa[x+1]=w.y,aa[x+2]=w.z,aa[x+3]=1,aa[x+4]=D.x,aa[x+5]=D.y,aa[x+6]=D.z,aa[x+7]=1,aa[x+8]=s.x,aa[x+9]=s.y,aa[x+10]=s.z,aa[x+11]=1,w=Na[y.a],D=Na[y.b],s=Na[y.c],ca[x]=w.x,ca[x+1]=w.y,ca[x+2]=w.z,ca[x+3]=1,ca[x+4]=D.x,ca[x+5]=D.y,ca[x+6]=D.z,ca[x+7]=1,ca[x+8]=s.x,ca[x+9]=s.y,ca[x+10]=s.z,ca[x+11]=1,x+=12;if(Da&&z)E.length===3&&z===THREE.VertexColors?(y=E[0],w=E[1],D=E[2]):D=w=y=K,oa[ka]=y.r,oa[ka+1]=y.g,oa[ka+2]=y.b,oa[ka+3]=w.r,oa[ka+4]=w.g,oa[ka+5]=w.b,
+oa[ka+6]=D.r,oa[ka+7]=D.g,oa[ka+8]=D.b,ka+=9;if(Ca&&qa.hasTangents)E=N[0],K=N[1],y=N[2],$[Y]=E.x,$[Y+1]=E.y,$[Y+2]=E.z,$[Y+3]=E.w,$[Y+4]=K.x,$[Y+5]=K.y,$[Y+6]=K.z,$[Y+7]=K.w,$[Y+8]=y.x,$[Y+9]=y.y,$[Y+10]=y.z,$[Y+11]=y.w,Y+=12;if(Ba&&B)if(C.length===3&&ta)for(w=0;w<3;w++)F=C[w],X[Q]=F.x,X[Q+1]=F.y,X[Q+2]=F.z,Q+=3;else for(w=0;w<3;w++)X[Q]=F.x,X[Q+1]=F.y,X[Q+2]=F.z,Q+=3;if(wa&&v!==void 0&&p)for(w=0;w<3;w++)C=v[w],ja[T]=C.u,ja[T+1]=C.v,T+=2;if(wa&&U!==void 0&&p)for(w=0;w<3;w++)C=U[w],ma[W]=C.u,ma[W+
+1]=C.v,W+=2;ya&&(ga[S]=ha,ga[S+1]=ha+1,ga[S+2]=ha+2,S+=3,ua[R]=ha,ua[R+1]=ha+1,ua[R+2]=ha,ua[R+3]=ha+2,ua[R+4]=ha+1,ua[R+5]=ha+2,R+=6,ha+=3)}else if(y instanceof THREE.Face4){if(va)G=La[y.a].position,L=La[y.b].position,M=La[y.c].position,H=La[y.d].position,na[I]=G.x,na[I+1]=G.y,na[I+2]=G.z,na[I+3]=L.x,na[I+4]=L.y,na[I+5]=L.z,na[I+6]=M.x,na[I+7]=M.y,na[I+8]=M.z,na[I+9]=H.x,na[I+10]=H.y,na[I+11]=H.z,I+=12;if(Z){w=0;for(D=Z.length;w<D;w++)if(m=Z[w],m.__original.needsUpdate)s=m.offset,V=m.offsetSrc,m.size===
 1?(m.boundTo===void 0||m.boundTo==="vertices"?(m.array[s]=m.value[y.a],m.array[s+1]=m.value[y.b],m.array[s+2]=m.value[y.c],m.array[s+3]=m.value[y.d]):m.boundTo==="faces"?(V=m.value[V],m.array[s]=V,m.array[s+1]=V,m.array[s+2]=V,m.array[s+3]=V,m.offsetSrc++):m.boundTo==="faceVertices"&&(m.array[s]=m.value[V],m.array[s+1]=m.value[V+1],m.array[s+2]=m.value[V+2],m.array[s+3]=m.value[V+3],m.offsetSrc+=4),m.offset+=4):(m.boundTo===void 0||m.boundTo==="vertices"?(G=m.value[y.a],L=m.value[y.b],M=m.value[y.c],
 H=m.value[y.d]):m.boundTo==="faces"?(H=M=L=G=V=m.value[V],m.offsetSrc++):m.boundTo==="faceVertices"&&(G=m.value[V],L=m.value[V+1],M=m.value[V+2],H=m.value[V+3],m.offsetSrc+=4),m.size===2?(m.array[s]=G.x,m.array[s+1]=G.y,m.array[s+2]=L.x,m.array[s+3]=L.y,m.array[s+4]=M.x,m.array[s+5]=M.y,m.array[s+6]=H.x,m.array[s+7]=H.y,m.offset+=8):m.size===3?(m.type==="c"?(m.array[s]=G.r,m.array[s+1]=G.g,m.array[s+2]=G.b,m.array[s+3]=L.r,m.array[s+4]=L.g,m.array[s+5]=L.b,m.array[s+6]=M.r,m.array[s+7]=M.g,m.array[s+
 8]=M.b,m.array[s+9]=H.r,m.array[s+10]=H.g,m.array[s+11]=H.b):(m.array[s]=G.x,m.array[s+1]=G.y,m.array[s+2]=G.z,m.array[s+3]=L.x,m.array[s+4]=L.y,m.array[s+5]=L.z,m.array[s+6]=M.x,m.array[s+7]=M.y,m.array[s+8]=M.z,m.array[s+9]=H.x,m.array[s+10]=H.y,m.array[s+11]=H.z),m.offset+=12):(m.array[s]=G.x,m.array[s+1]=G.y,m.array[s+2]=G.z,m.array[s+3]=G.w,m.array[s+4]=L.x,m.array[s+5]=L.y,m.array[s+6]=L.z,m.array[s+7]=L.w,m.array[s+8]=M.x,m.array[s+9]=M.y,m.array[s+10]=M.z,m.array[s+11]=M.w,m.array[s+12]=H.x,
-m.array[s+13]=H.y,m.array[s+14]=H.z,m.array[s+15]=H.w,m.offset+=16))}if(Ea){w=0;for(D=Ga.length;w<D;w++)G=Ga[w].vertices[y.a].position,L=Ga[w].vertices[y.b].position,M=Ga[w].vertices[y.c].position,H=Ga[w].vertices[y.d].position,s=pa[w],s[ka]=G.x,s[ka+1]=G.y,s[ka+2]=G.z,s[ka+3]=L.x,s[ka+4]=L.y,s[ka+5]=L.z,s[ka+6]=M.x,s[ka+7]=M.y,s[ka+8]=M.z,s[ka+9]=H.x,s[ka+10]=H.y,s[ka+11]=H.z;ka+=12}if(Ka.length)w=Ka[y.a],D=Ka[y.b],s=Ka[y.c],m=Ka[y.d],ea[x]=w.x,ea[x+1]=w.y,ea[x+2]=w.z,ea[x+3]=w.w,ea[x+4]=D.x,ea[x+
-5]=D.y,ea[x+6]=D.z,ea[x+7]=D.w,ea[x+8]=s.x,ea[x+9]=s.y,ea[x+10]=s.z,ea[x+11]=s.w,ea[x+12]=m.x,ea[x+13]=m.y,ea[x+14]=m.z,ea[x+15]=m.w,w=Pa[y.a],D=Pa[y.b],s=Pa[y.c],m=Pa[y.d],da[x]=w.x,da[x+1]=w.y,da[x+2]=w.z,da[x+3]=w.w,da[x+4]=D.x,da[x+5]=D.y,da[x+6]=D.z,da[x+7]=D.w,da[x+8]=s.x,da[x+9]=s.y,da[x+10]=s.z,da[x+11]=s.w,da[x+12]=m.x,da[x+13]=m.y,da[x+14]=m.z,da[x+15]=m.w,w=Na[y.a],D=Na[y.b],s=Na[y.c],m=Na[y.d],aa[x]=w.x,aa[x+1]=w.y,aa[x+2]=w.z,aa[x+3]=1,aa[x+4]=D.x,aa[x+5]=D.y,aa[x+6]=D.z,aa[x+7]=1,aa[x+
-8]=s.x,aa[x+9]=s.y,aa[x+10]=s.z,aa[x+11]=1,aa[x+12]=m.x,aa[x+13]=m.y,aa[x+14]=m.z,aa[x+15]=1,w=Oa[y.a],D=Oa[y.b],s=Oa[y.c],y=Oa[y.d],ca[x]=w.x,ca[x+1]=w.y,ca[x+2]=w.z,ca[x+3]=1,ca[x+4]=D.x,ca[x+5]=D.y,ca[x+6]=D.z,ca[x+7]=1,ca[x+8]=s.x,ca[x+9]=s.y,ca[x+10]=s.z,ca[x+11]=1,ca[x+12]=y.x,ca[x+13]=y.y,ca[x+14]=y.z,ca[x+15]=1,x+=16;if(Da&&z)E.length===4&&z===THREE.VertexColors?(y=E[0],w=E[1],D=E[2],E=E[3]):E=D=w=y=K,oa[ja]=y.r,oa[ja+1]=y.g,oa[ja+2]=y.b,oa[ja+3]=w.r,oa[ja+4]=w.g,oa[ja+5]=w.b,oa[ja+6]=D.r,
-oa[ja+7]=D.g,oa[ja+8]=D.b,oa[ja+9]=E.r,oa[ja+10]=E.g,oa[ja+11]=E.b,ja+=12;if(Ca&&qa.hasTangents)E=N[0],K=N[1],y=N[2],N=N[3],$[Y]=E.x,$[Y+1]=E.y,$[Y+2]=E.z,$[Y+3]=E.w,$[Y+4]=K.x,$[Y+5]=K.y,$[Y+6]=K.z,$[Y+7]=K.w,$[Y+8]=y.x,$[Y+9]=y.y,$[Y+10]=y.z,$[Y+11]=y.w,$[Y+12]=N.x,$[Y+13]=N.y,$[Y+14]=N.z,$[Y+15]=N.w,Y+=16;if(Ba&&B)if(C.length===4&&ta)for(w=0;w<4;w++)F=C[w],X[Q]=F.x,X[Q+1]=F.y,X[Q+2]=F.z,Q+=3;else for(w=0;w<4;w++)X[Q]=F.x,X[Q+1]=F.y,X[Q+2]=F.z,Q+=3;if(wa&&v!==void 0&&p)for(w=0;w<4;w++)C=v[w],la[T]=
-C.u,la[T+1]=C.v,T+=2;if(wa&&U!==void 0&&p)for(w=0;w<4;w++)C=U[w],ma[W]=C.u,ma[W+1]=C.v,W+=2;ya&&(ga[S]=ha,ga[S+1]=ha+1,ga[S+2]=ha+3,ga[S+3]=ha+1,ga[S+4]=ha+2,ga[S+5]=ha+3,S+=6,ua[R]=ha,ua[R+1]=ha+1,ua[R+2]=ha,ua[R+3]=ha+3,ua[R+4]=ha+1,ua[R+5]=ha+2,ua[R+6]=ha+2,ua[R+7]=ha+3,R+=8,ha+=4)}va&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglVertexBuffer),d.bufferData(d.ARRAY_BUFFER,na,l));if(Z){w=0;for(D=Z.length;w<D;w++)m=Z[w],m.__original.needsUpdate&&(d.bindBuffer(d.ARRAY_BUFFER,m.buffer),d.bufferData(d.ARRAY_BUFFER,
-m.array,l))}if(Ea){w=0;for(D=Ga.length;w<D;w++)d.bindBuffer(d.ARRAY_BUFFER,q.__webglMorphTargetsBuffers[w]),d.bufferData(d.ARRAY_BUFFER,pa[w],l)}Da&&ja>0&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglColorBuffer),d.bufferData(d.ARRAY_BUFFER,oa,l));Ba&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglNormalBuffer),d.bufferData(d.ARRAY_BUFFER,X,l));Ca&&qa.hasTangents&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglTangentBuffer),d.bufferData(d.ARRAY_BUFFER,$,l));wa&&T>0&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglUVBuffer),d.bufferData(d.ARRAY_BUFFER,
-la,l));wa&&W>0&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglUV2Buffer),d.bufferData(d.ARRAY_BUFFER,ma,l));ya&&(d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webglFaceBuffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,ga,l),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webglLineBuffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,ua,l));x>0&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglSkinVertexABuffer),d.bufferData(d.ARRAY_BUFFER,aa,l),d.bindBuffer(d.ARRAY_BUFFER,q.__webglSkinVertexBBuffer),d.bufferData(d.ARRAY_BUFFER,ca,l),d.bindBuffer(d.ARRAY_BUFFER,
+m.array[s+13]=H.y,m.array[s+14]=H.z,m.array[s+15]=H.w,m.offset+=16))}if(Ea){w=0;for(D=Fa.length;w<D;w++)G=Fa[w].vertices[y.a].position,L=Fa[w].vertices[y.b].position,M=Fa[w].vertices[y.c].position,H=Fa[w].vertices[y.d].position,s=pa[w],s[la]=G.x,s[la+1]=G.y,s[la+2]=G.z,s[la+3]=L.x,s[la+4]=L.y,s[la+5]=L.z,s[la+6]=M.x,s[la+7]=M.y,s[la+8]=M.z,s[la+9]=H.x,s[la+10]=H.y,s[la+11]=H.z;la+=12}if(Ja.length)w=Ja[y.a],D=Ja[y.b],s=Ja[y.c],m=Ja[y.d],ea[x]=w.x,ea[x+1]=w.y,ea[x+2]=w.z,ea[x+3]=w.w,ea[x+4]=D.x,ea[x+
+5]=D.y,ea[x+6]=D.z,ea[x+7]=D.w,ea[x+8]=s.x,ea[x+9]=s.y,ea[x+10]=s.z,ea[x+11]=s.w,ea[x+12]=m.x,ea[x+13]=m.y,ea[x+14]=m.z,ea[x+15]=m.w,w=Oa[y.a],D=Oa[y.b],s=Oa[y.c],m=Oa[y.d],da[x]=w.x,da[x+1]=w.y,da[x+2]=w.z,da[x+3]=w.w,da[x+4]=D.x,da[x+5]=D.y,da[x+6]=D.z,da[x+7]=D.w,da[x+8]=s.x,da[x+9]=s.y,da[x+10]=s.z,da[x+11]=s.w,da[x+12]=m.x,da[x+13]=m.y,da[x+14]=m.z,da[x+15]=m.w,w=Ma[y.a],D=Ma[y.b],s=Ma[y.c],m=Ma[y.d],aa[x]=w.x,aa[x+1]=w.y,aa[x+2]=w.z,aa[x+3]=1,aa[x+4]=D.x,aa[x+5]=D.y,aa[x+6]=D.z,aa[x+7]=1,aa[x+
+8]=s.x,aa[x+9]=s.y,aa[x+10]=s.z,aa[x+11]=1,aa[x+12]=m.x,aa[x+13]=m.y,aa[x+14]=m.z,aa[x+15]=1,w=Na[y.a],D=Na[y.b],s=Na[y.c],y=Na[y.d],ca[x]=w.x,ca[x+1]=w.y,ca[x+2]=w.z,ca[x+3]=1,ca[x+4]=D.x,ca[x+5]=D.y,ca[x+6]=D.z,ca[x+7]=1,ca[x+8]=s.x,ca[x+9]=s.y,ca[x+10]=s.z,ca[x+11]=1,ca[x+12]=y.x,ca[x+13]=y.y,ca[x+14]=y.z,ca[x+15]=1,x+=16;if(Da&&z)E.length===4&&z===THREE.VertexColors?(y=E[0],w=E[1],D=E[2],E=E[3]):E=D=w=y=K,oa[ka]=y.r,oa[ka+1]=y.g,oa[ka+2]=y.b,oa[ka+3]=w.r,oa[ka+4]=w.g,oa[ka+5]=w.b,oa[ka+6]=D.r,
+oa[ka+7]=D.g,oa[ka+8]=D.b,oa[ka+9]=E.r,oa[ka+10]=E.g,oa[ka+11]=E.b,ka+=12;if(Ca&&qa.hasTangents)E=N[0],K=N[1],y=N[2],N=N[3],$[Y]=E.x,$[Y+1]=E.y,$[Y+2]=E.z,$[Y+3]=E.w,$[Y+4]=K.x,$[Y+5]=K.y,$[Y+6]=K.z,$[Y+7]=K.w,$[Y+8]=y.x,$[Y+9]=y.y,$[Y+10]=y.z,$[Y+11]=y.w,$[Y+12]=N.x,$[Y+13]=N.y,$[Y+14]=N.z,$[Y+15]=N.w,Y+=16;if(Ba&&B)if(C.length===4&&ta)for(w=0;w<4;w++)F=C[w],X[Q]=F.x,X[Q+1]=F.y,X[Q+2]=F.z,Q+=3;else for(w=0;w<4;w++)X[Q]=F.x,X[Q+1]=F.y,X[Q+2]=F.z,Q+=3;if(wa&&v!==void 0&&p)for(w=0;w<4;w++)C=v[w],ja[T]=
+C.u,ja[T+1]=C.v,T+=2;if(wa&&U!==void 0&&p)for(w=0;w<4;w++)C=U[w],ma[W]=C.u,ma[W+1]=C.v,W+=2;ya&&(ga[S]=ha,ga[S+1]=ha+1,ga[S+2]=ha+3,ga[S+3]=ha+1,ga[S+4]=ha+2,ga[S+5]=ha+3,S+=6,ua[R]=ha,ua[R+1]=ha+1,ua[R+2]=ha,ua[R+3]=ha+3,ua[R+4]=ha+1,ua[R+5]=ha+2,ua[R+6]=ha+2,ua[R+7]=ha+3,R+=8,ha+=4)}va&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglVertexBuffer),d.bufferData(d.ARRAY_BUFFER,na,l));if(Z){w=0;for(D=Z.length;w<D;w++)m=Z[w],m.__original.needsUpdate&&(d.bindBuffer(d.ARRAY_BUFFER,m.buffer),d.bufferData(d.ARRAY_BUFFER,
+m.array,l))}if(Ea){w=0;for(D=Fa.length;w<D;w++)d.bindBuffer(d.ARRAY_BUFFER,q.__webglMorphTargetsBuffers[w]),d.bufferData(d.ARRAY_BUFFER,pa[w],l)}Da&&ka>0&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglColorBuffer),d.bufferData(d.ARRAY_BUFFER,oa,l));Ba&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglNormalBuffer),d.bufferData(d.ARRAY_BUFFER,X,l));Ca&&qa.hasTangents&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglTangentBuffer),d.bufferData(d.ARRAY_BUFFER,$,l));wa&&T>0&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglUVBuffer),d.bufferData(d.ARRAY_BUFFER,
+ja,l));wa&&W>0&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglUV2Buffer),d.bufferData(d.ARRAY_BUFFER,ma,l));ya&&(d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webglFaceBuffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,ga,l),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,q.__webglLineBuffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,ua,l));x>0&&(d.bindBuffer(d.ARRAY_BUFFER,q.__webglSkinVertexABuffer),d.bufferData(d.ARRAY_BUFFER,aa,l),d.bindBuffer(d.ARRAY_BUFFER,q.__webglSkinVertexBBuffer),d.bufferData(d.ARRAY_BUFFER,ca,l),d.bindBuffer(d.ARRAY_BUFFER,
 q.__webglSkinIndicesBuffer),d.bufferData(d.ARRAY_BUFFER,da,l),d.bindBuffer(d.ARRAY_BUFFER,q.__webglSkinWeightsBuffer),d.bufferData(d.ARRAY_BUFFER,ea,l));o&&(delete q.__inittedArrays,delete q.__colorArray,delete q.__normalArray,delete q.__tangentArray,delete q.__uvArray,delete q.__uv2Array,delete q.__faceArray,delete q.__vertexArray,delete q.__lineArray,delete q.__skinVertexAArray,delete q.__skinVertexBArray,delete q.__skinIndexArray,delete q.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=
 !1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyColors=!1;h.__dirtyTangents=!1;j.attributes&&ia(j)}else if(i instanceof THREE.Ribbon){if(h.__dirtyVertices||h.__dirtyColors){i=h;j=d.DYNAMIC_DRAW;k=r=o=o=void 0;t=i.vertices;n=i.colors;p=t.length;q=n.length;z=i.__vertexArray;l=i.__colorArray;B=i.__dirtyColors;if(i.__dirtyVertices){for(o=0;o<p;o++)r=t[o].position,k=o*3,z[k]=r.x,z[k+1]=r.y,z[k+2]=r.z;d.bindBuffer(d.ARRAY_BUFFER,i.__webglVertexBuffer);d.bufferData(d.ARRAY_BUFFER,z,
 j)}if(B){for(o=0;o<q;o++)color=n[o],k=o*3,l[k]=color.r,l[k+1]=color.g,l[k+2]=color.b;d.bindBuffer(d.ARRAY_BUFFER,i.__webglColorBuffer);d.bufferData(d.ARRAY_BUFFER,l,j)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(i instanceof THREE.Line){if(h.__dirtyVertices||h.__dirtyColors){i=h;j=d.DYNAMIC_DRAW;k=r=o=o=void 0;t=i.vertices;n=i.colors;p=t.length;q=n.length;z=i.__vertexArray;l=i.__colorArray;B=i.__dirtyColors;if(i.__dirtyVertices){for(o=0;o<p;o++)r=t[o].position,k=o*3,z[k]=r.x,z[k+1]=r.y,z[k+2]=

+ 2 - 2
examples/webgl_geometry_text.html

@@ -527,8 +527,8 @@
 
 				updatePermalink();
 
-				scene.remove( textMesh1 );
-				if ( mirror ) scene.remove( textMesh2 );
+				parent.remove( textMesh1 );
+				if ( mirror ) parent.remove( textMesh2 );
 
 				if ( !text ) return;
 

+ 0 - 2
examples/webgl_interactive_cubes.html

@@ -130,8 +130,6 @@
 
 				// find intersections
 
-				camera.update();
-
 				var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
 				projector.unprojectVector( vector, camera );
 

+ 32 - 0
src/core/Object3D.js

@@ -110,6 +110,22 @@ THREE.Object3D.prototype = {
 			object.parent = this;
 			this.children.push( object );
 
+			// add to scene
+
+			var scene = this;
+
+			while ( scene.parent !== undefined ) {
+
+				scene = scene.parent;
+
+			}
+
+			if ( scene !== undefined && scene instanceof THREE.Scene )  {
+
+				scene.addObject( object );
+
+			}
+
 		}
 
 	},
@@ -123,6 +139,22 @@ THREE.Object3D.prototype = {
 			object.parent = undefined;
 			this.children.splice( index, 1 );
 
+			// remove from scene
+
+			var scene = this;
+
+			while ( scene.parent !== undefined ) {
+
+				scene = scene.parent;
+
+			}
+
+			if ( scene !== undefined && scene instanceof THREE.Scene ) {
+
+				scene.removeObject( object );
+
+			}
+
 		}
 
 	},

+ 3 - 3
src/extras/renderers/AnaglyphWebGLRenderer.js

@@ -98,7 +98,7 @@ if ( THREE.WebGLRenderer ) {
 
 		this.render = function ( scene, camera, renderTarget, forceClear ) {
 
-			camera.update( null, true );
+			//camera.update( null, true );
 
 			var hasCameraChanged = aspect !== camera.aspect || near !== camera.near || fov !== camera.fov;
 
@@ -138,14 +138,14 @@ if ( THREE.WebGLRenderer ) {
 			}
 
 			_cameraL.matrix = camera.matrixWorld.clone().multiplySelf( eyeLeft );
-			_cameraL.update( null, true );
+			//_cameraL.update( null, true );
 			_cameraL.position.copy( camera.position );
 			_cameraL.near = near;
 			_cameraL.far = camera.far;
 			_render.call( _this, scene, _cameraL, _renderTargetL, true );
 
 			_cameraR.matrix = camera.matrixWorld.clone().multiplySelf( eyeRight );
-			_cameraR.update( null, true );
+			//_cameraR.update( null, true );
 			_cameraR.position.copy( camera.position );
 			_cameraR.near = near;
 			_cameraR.far = camera.far;

+ 3 - 3
src/extras/renderers/ParallaxBarrierWebGLRenderer.js

@@ -100,7 +100,7 @@ if ( THREE.WebGLRenderer ) {
 
 		this.render = function ( scene, camera, renderTarget, forceClear ) {
 
-			camera.update( null, true );
+			//camera.update( null, true );
 
 			var hasCameraChanged = aspect !== camera.aspect || near !== camera.near || fov !== camera.fov;
 
@@ -140,14 +140,14 @@ if ( THREE.WebGLRenderer ) {
 			}
 
 			_cameraL.matrix = camera.matrixWorld.clone().multiplySelf( eyeLeft );
-			_cameraL.update( null, true );
+			//_cameraL.update( null, true );
 			_cameraL.position.copy( camera.position );
 			_cameraL.near = near;
 			_cameraL.far = camera.far;
 			_render.call( _this, scene, _cameraL, _renderTargetL, true );
 
 			_cameraR.matrix = camera.matrixWorld.clone().multiplySelf( eyeRight );
-			_cameraR.update( null, true );
+			//_cameraR.update( null, true );
 			_cameraR.position.copy( camera.position );
 			_cameraR.near = near;
 			_cameraR.far = camera.far;

+ 15 - 15
src/renderers/WebGLRenderer.js

@@ -3609,9 +3609,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 				_cameraLight.position.copy( light.position );
 				_cameraLight.lookAt( light.target.position );
 
-				_cameraLight.update( undefined, true );
+				if ( _cameraLight.parent == null ) {
 
-				scene.update( undefined, false, _cameraLight );
+					console.warn( "Camera is not on the Scene. Adding it..." );
+					scene.add( _cameraLight );
+
+				}
+
+				scene.updateMatrixWorld();
+
+				_cameraLight.matrixWorldInverse.getInverse( _cameraLight.matrixWorld );
 
 				// compute shadow matrix
 
@@ -3790,23 +3797,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 		_this.info.render.vertices = 0;
 		_this.info.render.faces = 0;
 
-		// hack: find parent of camera.
-
-		if ( camera.matrixAutoUpdate ) {
-
-			var parent = camera;
+		if ( camera.parent == null ) {
 
-			while ( parent.parent ) {
-
-				parent = parent.parent;
-
-			}
-
-			parent.update( undefined, true );
+			console.warn( "Camera is not on the Scene. Adding it..." );
+			scene.add( camera );
 
 		}
 
-		scene.update( undefined, false, camera );
+		scene.updateMatrixWorld();
+
+		camera.matrixWorldInverse.getInverse( camera.matrixWorld );
 
 		camera.matrixWorldInverse.flattenToArray( _viewMatrixArray );
 		camera.projectionMatrix.flattenToArray( _projectionMatrixArray );

+ 88 - 0
src/scenes/Scene.js

@@ -11,7 +11,95 @@ THREE.Scene = function () {
 
 	this.matrixAutoUpdate = false;
 
+	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 ( object ) {
+
+	if ( object instanceof THREE.Light ) {
+
+		if ( this.lights.indexOf( object ) === - 1 ) {
+
+			this.lights.push( object );
+
+		}
+
+	} else if ( !( object instanceof THREE.Camera || object instanceof THREE.Bone ) ) {
+
+		if ( this.objects.indexOf( object ) === - 1 ) {
+
+			this.objects.push( object );
+			this.__objectsAdded.push( object );
+
+			// check if previously removed
+
+			var i = this.__objectsRemoved.indexOf( object );
+
+			if ( i !== -1 ) {
+
+				this.__objectsRemoved.splice( i, 1 );
+
+			}
+
+		}
+
+	}
+
+	for ( var c = 0; c < object.children.length; c ++ ) {
+
+		this.addObject( object.children[ c ] );
+
+	}
+
+};
+
+THREE.Scene.prototype.removeObject = function ( object ) {
+
+	if ( object instanceof THREE.Light ) {
+
+		var i = this.lights.indexOf( object );
+
+		if ( i !== -1 ) {
+
+			this.lights.splice( i, 1 );
+
+		}
+
+	} else if ( !( object instanceof THREE.Camera ) ) {
+
+		var i = this.objects.indexOf( object );
+
+		if( i !== -1 ) {
+
+			this.objects.splice( i, 1 );
+			this.__objectsRemoved.push( object );
+
+			// check if previously added
+
+			var ai = this.__objectsAdded.indexOf( object );
+
+			if ( ai !== -1 ) {
+
+				this.__objectsAdded.splice( ai, 1 );
+
+			}
+
+		}
+
+	}
+
+	for ( var c = 0; c < object.children.length; c ++ ) {
+
+		this.removeObject( object.children[ c ] );
+
+	}
+
+};