Răsfoiți Sursa

Got skinning working again.

Code is a horrible mess but at least it works. Anyways, some day we should revisit GPU accelerated skinning with a proper pipeline.
alteredq 13 ani în urmă
părinte
comite
b2b7282fcd

+ 51 - 52
build/Three.js

@@ -127,15 +127,14 @@ THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.da
 THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,c,b){THREE.Object3D.call(this);this.geometry=a;this.material=c;this.type=b!=void 0?b:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
 THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,c,b){THREE.Object3D.call(this);this.geometry=a;this.material=c;this.type=b!=void 0?b:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
 THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.material=c;if(c instanceof Array)console.warn("DEPRECATE: Material array is no longer supported. Using material 0..."),this.material=c[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var b=0;b<
 THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.material=c;if(c instanceof Array)console.warn("DEPRECATE: Material array is no longer supported. Using material 0..."),this.material=c[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var b=0;b<
 this.geometry.morphTargets.length;b++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[b].name]=b}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
 this.geometry.morphTargets.length;b++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[b].name]=b}};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,c,b){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var e,k=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<k;e++)a=this.children[e],a instanceof THREE.Bone?a.update(this.skinMatrix,c,b):a.update(this.matrixWorld,!0,b)}else for(e=0;e<k;e++)this.children[e].update(this.skinMatrix,
-c,b)};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.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};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,c){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var b,e=this.children.length;for(b=0;b<e;b++)this.children[b].update(this.skinMatrix,c)};
 THREE.SkinnedMesh=function(a,c){THREE.Mesh.call(this,a,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var b,e,k,h,f,l;if(this.geometry.bones!==void 0){for(b=0;b<this.geometry.bones.length;b++)k=this.geometry.bones[b],h=k.pos,f=k.rotq,l=k.scl,e=this.addBone(),e.name=k.name,e.position.set(h[0],h[1],h[2]),e.quaternion.set(f[0],f[1],f[2],f[3]),e.useQuaternion=!0,l!==void 0?e.scale.set(l[0],l[1],l[2]):e.scale.set(1,1,1);for(b=0;b<this.bones.length;b++)k=this.geometry.bones[b],
 THREE.SkinnedMesh=function(a,c){THREE.Mesh.call(this,a,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var b,e,k,h,f,l;if(this.geometry.bones!==void 0){for(b=0;b<this.geometry.bones.length;b++)k=this.geometry.bones[b],h=k.pos,f=k.rotq,l=k.scl,e=this.addBone(),e.name=k.name,e.position.set(h[0],h[1],h[2]),e.quaternion.set(f[0],f[1],f[2],f[3]),e.useQuaternion=!0,l!==void 0?e.scale.set(l[0],l[1],l[2]):e.scale.set(1,1,1);for(b=0;b<this.bones.length;b++)k=this.geometry.bones[b],
-e=this.bones[b],k.parent===-1?this.add(e):this.bones[k.parent].add(e);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
-THREE.SkinnedMesh.prototype.update=function(a,c,b){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var e,k=this.children.length;for(e=0;e<k;e++)a=this.children[e],a instanceof THREE.Bone?a.update(this.identityMatrix,!1,b):a.update(this.matrixWorld,c,b);b=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(c=0;c<b;c++)ba[c].skinMatrix.flattenToArrayOffset(bm,
-c*16)}};THREE.SkinnedMesh.prototype.addBone=function(a){a===void 0&&(a=new THREE.Bone(this));this.bones.push(a);return a};
-THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var a,c=[],b=0;b<this.bones.length;b++)a=this.bones[b],c.push(THREE.Matrix4.makeInvert(a.skinMatrix)),a.skinMatrix.flattenToArrayOffset(this.boneMatrices,b*16);if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(a=0;a<this.geometry.skinIndices.length;a++){var b=this.geometry.vertices[a].position,k=this.geometry.skinIndices[a].x,h=this.geometry.skinIndices[a].y;e=new THREE.Vector3(b.x,
-b.y,b.z);this.geometry.skinVerticesA.push(c[k].multiplyVector3(e));e=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesB.push(c[h].multiplyVector3(e));this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1&&(b=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5,this.geometry.skinWeights[a].x+=b,this.geometry.skinWeights[a].y+=b)}}};
+e=this.bones[b],k.parent===-1?this.add(e):this.bones[k.parent].add(e);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;THREE.SkinnedMesh.prototype.addBone=function(a){a===void 0&&(a=new THREE.Bone(this));this.bones.push(a);return a};
+THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1;for(var a=0,c=this.children.length;a<c;a++){var b=this.children[a];b instanceof THREE.Bone?b.update(this.identityMatrix,!1):b.updateMatrixWorld(!0)}c=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(a=0;a<c;a++)ba[a].skinMatrix.flattenToArrayOffset(bm,
+a*16)};
+THREE.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(!0);for(var a,c=[],b=0;b<this.bones.length;b++){a=this.bones[b];var e=new THREE.Matrix4;e.getInverse(a.skinMatrix);c.push(e);a.skinMatrix.flattenToArrayOffset(this.boneMatrices,b*16)}if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];for(a=0;a<this.geometry.skinIndices.length;a++){var b=this.geometry.vertices[a].position,k=this.geometry.skinIndices[a].x,h=this.geometry.skinIndices[a].y,e=
+new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesA.push(c[k].multiplyVector3(e));e=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesB.push(c[h].multiplyVector3(e));this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1&&(b=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5,this.geometry.skinWeights[a].x+=b,this.geometry.skinWeights[a].y+=b)}}};
 THREE.MorphAnimMesh=function(a,c){THREE.Mesh.call(this,a,c);this.duration=1E3;this.mirroredLoop=!1;this.currentKeyframe=this.lastKeyframe=this.time=0;this.direction=1;this.directionBackwards=!1};THREE.MorphAnimMesh.prototype=new THREE.Mesh;THREE.MorphAnimMesh.prototype.constructor=THREE.MorphAnimMesh;
 THREE.MorphAnimMesh=function(a,c){THREE.Mesh.call(this,a,c);this.duration=1E3;this.mirroredLoop=!1;this.currentKeyframe=this.lastKeyframe=this.time=0;this.direction=1;this.directionBackwards=!1};THREE.MorphAnimMesh.prototype=new THREE.Mesh;THREE.MorphAnimMesh.prototype.constructor=THREE.MorphAnimMesh;
 THREE.MorphAnimMesh.prototype.updateAnimation=function(a){var c=this.duration/(this.geometry.morphTargets.length-1);this.time+=this.direction*a;if(this.mirroredLoop){if(this.time>this.duration||this.time<0){this.direction*=-1;if(this.time>this.duration)this.time=this.duration,this.directionBackwards=!0;if(this.time<0)this.time=0,this.directionBackwards=!1}}else this.time%=this.duration;a=THREE.Math.clamp(Math.floor(this.time/c),0,this.geometry.morphTargets.length-1);if(a!=this.currentKeyframe)this.morphTargetInfluences[this.lastKeyframe]=
 THREE.MorphAnimMesh.prototype.updateAnimation=function(a){var c=this.duration/(this.geometry.morphTargets.length-1);this.time+=this.direction*a;if(this.mirroredLoop){if(this.time>this.duration||this.time<0){this.direction*=-1;if(this.time>this.duration)this.time=this.duration,this.directionBackwards=!0;if(this.time<0)this.time=0,this.directionBackwards=!1}}else this.time%=this.duration;a=THREE.Math.clamp(Math.floor(this.time/c),0,this.geometry.morphTargets.length-1);if(a!=this.currentKeyframe)this.morphTargetInfluences[this.lastKeyframe]=
 0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[a]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=a;c=this.time%c/c;this.directionBackwards&&(c=1-c);this.morphTargetInfluences[this.currentKeyframe]=c;this.morphTargetInfluences[this.lastKeyframe]=1-c};THREE.Ribbon=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.material=c};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
 0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[a]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=a;c=this.time%c/c;this.directionBackwards&&(c=1-c);this.morphTargetInfluences[this.currentKeyframe]=c;this.morphTargetInfluences[this.lastKeyframe]=1-c};THREE.Ribbon=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.material=c};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
@@ -225,32 +224,32 @@ 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.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.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.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask  = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}};
-THREE.WebGLRenderer=function(a){function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;else if(b.materialIndex>=0)return a.geometry.materials[b.materialIndex]}function b(a,b,c){var e,f,k,h=a.vertices,l=h.length,n=a.colors,v=n.length,p=a.__vertexArray,u=a.__colorArray,t=a.__sortArray,x=a.__dirtyVertices,w=a.__dirtyColors,F=a.__webglCustomAttributesList,y;if(F){k=0;for(e=F.length;k<e;k++)F[k].offset=0}if(c.sortParticles){sa.multiplySelf(c.matrixWorld);for(e=
-0;e<l;e++)f=h[e].position,Ca.copy(f),sa.multiplyVector3(Ca),t[e]=[Ca.z,e];t.sort(function(a,b){return b[0]-a[0]});for(e=0;e<l;e++)f=h[t[e][1]].position,k=e*3,p[k]=f.x,p[k+1]=f.y,p[k+2]=f.z;for(e=0;e<v;e++)k=e*3,color=n[t[e][1]],u[k]=color.r,u[k+1]=color.g,u[k+2]=color.b;if(F){k=0;for(e=F.length;k<e;k++){l=F[k];v=l.value.length;for(n=0;n<v;n++){index=t[n][1];h=l.offset;if(l.size===1){if(l.boundTo===void 0||l.boundTo==="vertices")l.array[h]=l.value[index]}else{if(l.boundTo===void 0||l.boundTo==="vertices")y=
-l.value[index];l.size===2?(l.array[h]=y.x,l.array[h+1]=y.y):l.size===3?l.type==="c"?(l.array[h]=y.r,l.array[h+1]=y.g,l.array[h+2]=y.b):(l.array[h]=y.x,l.array[h+1]=y.y,l.array[h+2]=y.z):(l.array[h]=y.x,l.array[h+1]=y.y,l.array[h+2]=y.z,l.array[h+3]=y.w)}l.offset+=l.size}}}}else{if(x)for(e=0;e<l;e++)f=h[e].position,k=e*3,p[k]=f.x,p[k+1]=f.y,p[k+2]=f.z;if(w)for(e=0;e<v;e++)color=n[e],k=e*3,u[k]=color.r,u[k+1]=color.g,u[k+2]=color.b;if(F){k=0;for(e=F.length;k<e;k++)if(l=F[k],l.__original.needsUpdate){v=
-l.value.length;for(n=0;n<v;n++){h=l.offset;if(l.size===1){if(l.boundTo===void 0||l.boundTo==="vertices")l.array[h]=l.value[n]}else{if(l.boundTo===void 0||l.boundTo==="vertices")y=l.value[n];l.size===2?(l.array[h]=y.x,l.array[h+1]=y.y):l.size===3?l.type==="c"?(l.array[h]=y.r,l.array[h+1]=y.g,l.array[h+2]=y.b):(l.array[h]=y.x,l.array[h+1]=y.y,l.array[h+2]=y.z):(l.array[h]=y.x,l.array[h+1]=y.y,l.array[h+2]=y.z,l.array[h+3]=y.w)}l.offset+=l.size}}}}if(x||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,a.__webglVertexBuffer),
-o.bufferData(o.ARRAY_BUFFER,p,b);if(w||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,a.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,u,b);if(F){k=0;for(e=F.length;k<e;k++)if(l=F[k],l.__original.needsUpdate||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,l.buffer),o.bufferData(o.ARRAY_BUFFER,l.array,b)}}function e(a,b,c,e,f){e.program||P.initMaterial(e,b,c,f);if(e.morphTargets&&!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=new Float32Array(P.maxMorphTargets);for(var k=0,h=P.maxMorphTargets;k<
-h;k++)f.__webglMorphTargetInfluences[k]=0}var l=!1,k=e.program,h=k.uniforms,n=e.uniforms;k!==Q&&(o.useProgram(k),Q=k,l=!0);if(e.id!==T)T=e.id,l=!0;if(l){o.uniformMatrix4fv(h.projectionMatrix,!1,Da);if(c&&e.fog)if(n.fogColor.value=c.color,c instanceof THREE.Fog)n.fogNear.value=c.near,n.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)n.fogDensity.value=c.density;if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e.lights){for(var v,p,u=0,t=0,x=0,w,F,y,z=Fa,ia=z.directional.colors,
+THREE.WebGLRenderer=function(a){function c(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 b(a,b,c){var e,f,h,k=a.vertices,l=k.length,n=a.colors,v=n.length,p=a.__vertexArray,u=a.__colorArray,t=a.__sortArray,x=a.__dirtyVertices,w=a.__dirtyColors,F=a.__webglCustomAttributesList,y;if(F){h=0;for(e=F.length;h<e;h++)F[h].offset=0}if(c.sortParticles){sa.multiplySelf(c.matrixWorld);for(e=
+0;e<l;e++)f=k[e].position,Ca.copy(f),sa.multiplyVector3(Ca),t[e]=[Ca.z,e];t.sort(function(a,b){return b[0]-a[0]});for(e=0;e<l;e++)f=k[t[e][1]].position,h=e*3,p[h]=f.x,p[h+1]=f.y,p[h+2]=f.z;for(e=0;e<v;e++)h=e*3,color=n[t[e][1]],u[h]=color.r,u[h+1]=color.g,u[h+2]=color.b;if(F){h=0;for(e=F.length;h<e;h++){l=F[h];v=l.value.length;for(n=0;n<v;n++){index=t[n][1];k=l.offset;if(l.size===1){if(l.boundTo===void 0||l.boundTo==="vertices")l.array[k]=l.value[index]}else{if(l.boundTo===void 0||l.boundTo==="vertices")y=
+l.value[index];l.size===2?(l.array[k]=y.x,l.array[k+1]=y.y):l.size===3?l.type==="c"?(l.array[k]=y.r,l.array[k+1]=y.g,l.array[k+2]=y.b):(l.array[k]=y.x,l.array[k+1]=y.y,l.array[k+2]=y.z):(l.array[k]=y.x,l.array[k+1]=y.y,l.array[k+2]=y.z,l.array[k+3]=y.w)}l.offset+=l.size}}}}else{if(x)for(e=0;e<l;e++)f=k[e].position,h=e*3,p[h]=f.x,p[h+1]=f.y,p[h+2]=f.z;if(w)for(e=0;e<v;e++)color=n[e],h=e*3,u[h]=color.r,u[h+1]=color.g,u[h+2]=color.b;if(F){h=0;for(e=F.length;h<e;h++)if(l=F[h],l.__original.needsUpdate){v=
+l.value.length;for(n=0;n<v;n++){k=l.offset;if(l.size===1){if(l.boundTo===void 0||l.boundTo==="vertices")l.array[k]=l.value[n]}else{if(l.boundTo===void 0||l.boundTo==="vertices")y=l.value[n];l.size===2?(l.array[k]=y.x,l.array[k+1]=y.y):l.size===3?l.type==="c"?(l.array[k]=y.r,l.array[k+1]=y.g,l.array[k+2]=y.b):(l.array[k]=y.x,l.array[k+1]=y.y,l.array[k+2]=y.z):(l.array[k]=y.x,l.array[k+1]=y.y,l.array[k+2]=y.z,l.array[k+3]=y.w)}l.offset+=l.size}}}}if(x||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,a.__webglVertexBuffer),
+o.bufferData(o.ARRAY_BUFFER,p,b);if(w||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,a.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,u,b);if(F){h=0;for(e=F.length;h<e;h++)if(l=F[h],l.__original.needsUpdate||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,l.buffer),o.bufferData(o.ARRAY_BUFFER,l.array,b)}}function e(a,b,c,e,f){e.program||P.initMaterial(e,b,c,f);if(e.morphTargets&&!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=new Float32Array(P.maxMorphTargets);for(var h=0,k=P.maxMorphTargets;h<
+k;h++)f.__webglMorphTargetInfluences[h]=0}var l=!1,h=e.program,k=h.uniforms,n=e.uniforms;h!==Q&&(o.useProgram(h),Q=h,l=!0);if(e.id!==T)T=e.id,l=!0;if(l){o.uniformMatrix4fv(k.projectionMatrix,!1,Da);if(c&&e.fog)if(n.fogColor.value=c.color,c instanceof THREE.Fog)n.fogNear.value=c.near,n.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)n.fogDensity.value=c.density;if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e.lights){for(var v,p,u=0,t=0,x=0,w,F,y,z=Fa,ia=z.directional.colors,
 fa=z.directional.positions,A=z.point.colors,B=z.point.positions,C=z.point.distances,D=0,G=0,c=v=y=0,l=b.length;c<l;c++)if(v=b[c],p=v.color,w=v.position,F=v.intensity,y=v.distance,v instanceof THREE.AmbientLight)P.gammaInput?(u+=p.r*p.r,t+=p.g*p.g,x+=p.b*p.b):(u+=p.r,t+=p.g,x+=p.b);else if(v instanceof THREE.DirectionalLight)y=D*3,P.gammaInput?(ia[y]=p.r*p.r*F*F,ia[y+1]=p.g*p.g*F*F,ia[y+2]=p.b*p.b*F*F):(ia[y]=p.r*F,ia[y+1]=p.g*F,ia[y+2]=p.b*F),fa[y]=w.x,fa[y+1]=w.y,fa[y+2]=w.z,D+=1;else if(v instanceof
 fa=z.directional.positions,A=z.point.colors,B=z.point.positions,C=z.point.distances,D=0,G=0,c=v=y=0,l=b.length;c<l;c++)if(v=b[c],p=v.color,w=v.position,F=v.intensity,y=v.distance,v instanceof THREE.AmbientLight)P.gammaInput?(u+=p.r*p.r,t+=p.g*p.g,x+=p.b*p.b):(u+=p.r,t+=p.g,x+=p.b);else if(v instanceof THREE.DirectionalLight)y=D*3,P.gammaInput?(ia[y]=p.r*p.r*F*F,ia[y+1]=p.g*p.g*F*F,ia[y+2]=p.b*p.b*F*F):(ia[y]=p.r*F,ia[y+1]=p.g*F,ia[y+2]=p.b*F),fa[y]=w.x,fa[y+1]=w.y,fa[y+2]=w.z,D+=1;else if(v instanceof
 THREE.SpotLight)y=D*3,P.gammaInput?(ia[y]=p.r*p.r*F*F,ia[y+1]=p.g*p.g*F*F,ia[y+2]=p.b*p.b*F*F):(ia[y]=p.r*F,ia[y+1]=p.g*F,ia[y+2]=p.b*F),p=1/w.length(),fa[y]=w.x*p,fa[y+1]=w.y*p,fa[y+2]=w.z*p,D+=1;else if(v instanceof THREE.PointLight)v=G*3,P.gammaInput?(A[v]=p.r*p.r*F*F,A[v+1]=p.g*p.g*F*F,A[v+2]=p.b*p.b*F*F):(A[v]=p.r*F,A[v+1]=p.g*F,A[v+2]=p.b*F),B[v]=w.x,B[v+1]=w.y,B[v+2]=w.z,C[G]=y,G+=1;c=D*3;for(l=ia.length;c<l;c++)ia[c]=0;c=G*3;for(l=A.length;c<l;c++)A[c]=0;z.point.length=G;z.directional.length=
 THREE.SpotLight)y=D*3,P.gammaInput?(ia[y]=p.r*p.r*F*F,ia[y+1]=p.g*p.g*F*F,ia[y+2]=p.b*p.b*F*F):(ia[y]=p.r*F,ia[y+1]=p.g*F,ia[y+2]=p.b*F),p=1/w.length(),fa[y]=w.x*p,fa[y+1]=w.y*p,fa[y+2]=w.z*p,D+=1;else if(v instanceof THREE.PointLight)v=G*3,P.gammaInput?(A[v]=p.r*p.r*F*F,A[v+1]=p.g*p.g*F*F,A[v+2]=p.b*p.b*F*F):(A[v]=p.r*F,A[v+1]=p.g*F,A[v+2]=p.b*F),B[v]=w.x,B[v+1]=w.y,B[v+2]=w.z,C[G]=y,G+=1;c=D*3;for(l=ia.length;c<l;c++)ia[c]=0;c=G*3;for(l=A.length;c<l;c++)A[c]=0;z.point.length=G;z.directional.length=
 D;z.ambient[0]=u;z.ambient[1]=t;z.ambient[2]=x;b=Fa;n.enableLighting.value=b.directional.length+b.point.length;n.ambientLightColor.value=b.ambient;n.directionalLightColor.value=b.directional.colors;n.directionalLightDirection.value=b.directional.positions;n.pointLightColor.value=b.point.colors;n.pointLightPosition.value=b.point.positions;n.pointLightDistance.value=b.point.distances}if(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial)n.opacity.value=
 D;z.ambient[0]=u;z.ambient[1]=t;z.ambient[2]=x;b=Fa;n.enableLighting.value=b.directional.length+b.point.length;n.ambientLightColor.value=b.ambient;n.directionalLightColor.value=b.directional.colors;n.directionalLightDirection.value=b.directional.positions;n.pointLightColor.value=b.point.colors;n.pointLightPosition.value=b.point.positions;n.pointLightDistance.value=b.point.distances}if(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial)n.opacity.value=
 e.opacity,P.gammaInput?n.diffuse.value.copyGammaToLinear(e.color):n.diffuse.value=e.color,(n.map.texture=e.map)&&n.offsetRepeat.value.set(e.map.offset.x,e.map.offset.y,e.map.repeat.x,e.map.repeat.y),n.lightMap.texture=e.lightMap,n.envMap.texture=e.envMap,n.flipEnvMap.value=e.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,n.reflectivity.value=e.reflectivity,n.refractionRatio.value=e.refractionRatio,n.combine.value=e.combine,n.useRefract.value=e.envMap&&e.envMap.mapping instanceof THREE.CubeRefractionMapping;
 e.opacity,P.gammaInput?n.diffuse.value.copyGammaToLinear(e.color):n.diffuse.value=e.color,(n.map.texture=e.map)&&n.offsetRepeat.value.set(e.map.offset.x,e.map.offset.y,e.map.repeat.x,e.map.repeat.y),n.lightMap.texture=e.lightMap,n.envMap.texture=e.envMap,n.flipEnvMap.value=e.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,n.reflectivity.value=e.reflectivity,n.refractionRatio.value=e.refractionRatio,n.combine.value=e.combine,n.useRefract.value=e.envMap&&e.envMap.mapping instanceof THREE.CubeRefractionMapping;
 if(e instanceof THREE.LineBasicMaterial)n.diffuse.value=e.color,n.opacity.value=e.opacity;else if(e instanceof THREE.ParticleBasicMaterial)n.psColor.value=e.color,n.opacity.value=e.opacity,n.size.value=e.size,n.scale.value=za.height/2,n.map.texture=e.map;else if(e instanceof THREE.MeshPhongMaterial)n.shininess.value=e.shininess,P.gammaInput?(n.ambient.value.copyGammaToLinear(e.ambient),n.specular.value.copyGammaToLinear(e.specular)):(n.ambient.value=e.ambient,n.specular.value=e.specular);else if(e instanceof
 if(e instanceof THREE.LineBasicMaterial)n.diffuse.value=e.color,n.opacity.value=e.opacity;else if(e instanceof THREE.ParticleBasicMaterial)n.psColor.value=e.color,n.opacity.value=e.opacity,n.size.value=e.size,n.scale.value=za.height/2,n.map.texture=e.map;else if(e instanceof THREE.MeshPhongMaterial)n.shininess.value=e.shininess,P.gammaInput?(n.ambient.value.copyGammaToLinear(e.ambient),n.specular.value.copyGammaToLinear(e.specular)):(n.ambient.value=e.ambient,n.specular.value=e.specular);else if(e instanceof
 THREE.MeshLambertMaterial)P.gammaInput?n.ambient.value.copyGammaToLinear(e.ambient):n.ambient.value=e.ambient;else if(e instanceof THREE.MeshDepthMaterial)n.mNear.value=a.near,n.mFar.value=a.far,n.opacity.value=e.opacity;else if(e instanceof THREE.MeshNormalMaterial)n.opacity.value=e.opacity;if(f.receiveShadow&&!e._shadowPass&&n.shadowMatrix){for(b=0;b<ta.length;b++)n.shadowMatrix.value[b]=ta[b],n.shadowMap.texture[b]=P.shadowMap[b];n.shadowDarkness.value=P.shadowMapDarkness;n.shadowBias.value=P.shadowMapBias}b=
 THREE.MeshLambertMaterial)P.gammaInput?n.ambient.value.copyGammaToLinear(e.ambient):n.ambient.value=e.ambient;else if(e instanceof THREE.MeshDepthMaterial)n.mNear.value=a.near,n.mFar.value=a.far,n.opacity.value=e.opacity;else if(e instanceof THREE.MeshNormalMaterial)n.opacity.value=e.opacity;if(f.receiveShadow&&!e._shadowPass&&n.shadowMatrix){for(b=0;b<ta.length;b++)n.shadowMatrix.value[b]=ta[b],n.shadowMap.texture[b]=P.shadowMap[b];n.shadowDarkness.value=P.shadowMapDarkness;n.shadowBias.value=P.shadowMapBias}b=
-e.uniformsList;n=0;for(c=b.length;n<c;n++)if(t=k.uniforms[b[n][1]])if(u=b[n][0],x=u.type,l=u.value,x==="i")o.uniform1i(t,l);else if(x==="f")o.uniform1f(t,l);else if(x==="v2")o.uniform2f(t,l.x,l.y);else if(x==="v3")o.uniform3f(t,l.x,l.y,l.z);else if(x==="v4")o.uniform4f(t,l.x,l.y,l.z,l.w);else if(x==="c")o.uniform3f(t,l.r,l.g,l.b);else if(x==="fv1")o.uniform1fv(t,l);else if(x==="fv")o.uniform3fv(t,l);else if(x==="v3v"){if(!u._array)u._array=new Float32Array(3*l.length);x=0;for(w=l.length;x<w;x++)z=
+e.uniformsList;n=0;for(c=b.length;n<c;n++)if(t=h.uniforms[b[n][1]])if(u=b[n][0],x=u.type,l=u.value,x==="i")o.uniform1i(t,l);else if(x==="f")o.uniform1f(t,l);else if(x==="v2")o.uniform2f(t,l.x,l.y);else if(x==="v3")o.uniform3f(t,l.x,l.y,l.z);else if(x==="v4")o.uniform4f(t,l.x,l.y,l.z,l.w);else if(x==="c")o.uniform3f(t,l.r,l.g,l.b);else if(x==="fv1")o.uniform1fv(t,l);else if(x==="fv")o.uniform3fv(t,l);else if(x==="v3v"){if(!u._array)u._array=new Float32Array(3*l.length);x=0;for(w=l.length;x<w;x++)z=
 x*3,u._array[z]=l[x].x,u._array[z+1]=l[x].y,u._array[z+2]=l[x].z;o.uniform3fv(t,u._array)}else if(x==="m4"){if(!u._array)u._array=new Float32Array(16);l.flattenToArray(u._array);o.uniformMatrix4fv(t,!1,u._array)}else if(x==="m4v"){if(!u._array)u._array=new Float32Array(16*l.length);x=0;for(w=l.length;x<w;x++)l[x].flattenToArrayOffset(u._array,x*16);o.uniformMatrix4fv(t,!1,u._array)}else if(x==="t"){if(o.uniform1i(t,l),t=u.texture)if(t.image instanceof Array&&t.image.length===6){if(u=t,u.image.length===
 x*3,u._array[z]=l[x].x,u._array[z+1]=l[x].y,u._array[z+2]=l[x].z;o.uniform3fv(t,u._array)}else if(x==="m4"){if(!u._array)u._array=new Float32Array(16);l.flattenToArray(u._array);o.uniformMatrix4fv(t,!1,u._array)}else if(x==="m4v"){if(!u._array)u._array=new Float32Array(16*l.length);x=0;for(w=l.length;x<w;x++)l[x].flattenToArrayOffset(u._array,x*16);o.uniformMatrix4fv(t,!1,u._array)}else if(x==="t"){if(o.uniform1i(t,l),t=u.texture)if(t.image instanceof Array&&t.image.length===6){if(u=t,u.image.length===
 6)if(u.needsUpdate){if(!u.image.__webglTextureCube)u.image.__webglTextureCube=o.createTexture();o.activeTexture(o.TEXTURE0+l);o.bindTexture(o.TEXTURE_CUBE_MAP,u.image.__webglTextureCube);for(l=0;l<6;l++)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,u.image[l]);M(o.TEXTURE_CUBE_MAP,u,u.image[0]);u.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+l),o.bindTexture(o.TEXTURE_CUBE_MAP,u.image.__webglTextureCube)}else t instanceof THREE.WebGLRenderTargetCube?(u=t,o.activeTexture(o.TEXTURE0+
 6)if(u.needsUpdate){if(!u.image.__webglTextureCube)u.image.__webglTextureCube=o.createTexture();o.activeTexture(o.TEXTURE0+l);o.bindTexture(o.TEXTURE_CUBE_MAP,u.image.__webglTextureCube);for(l=0;l<6;l++)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,u.image[l]);M(o.TEXTURE_CUBE_MAP,u,u.image[0]);u.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+l),o.bindTexture(o.TEXTURE_CUBE_MAP,u.image.__webglTextureCube)}else t instanceof THREE.WebGLRenderTargetCube?(u=t,o.activeTexture(o.TEXTURE0+
-l),o.bindTexture(o.TEXTURE_CUBE_MAP,u.__webglTexture)):V(t,l)}else if(x==="tv"){if(!u._array){u._array=[];x=0;for(w=u.texture.length;x<w;x++)u._array[x]=l+x}o.uniform1iv(t,u._array);x=0;for(w=u.texture.length;x<w;x++)(t=u.texture[x])&&V(t,u._array[x])}(e instanceof THREE.ShaderMaterial||e instanceof THREE.MeshPhongMaterial||e.envMap)&&h.cameraPosition!==null&&o.uniform3f(h.cameraPosition,a.position.x,a.position.y,a.position.z);(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||
-e instanceof THREE.ShaderMaterial||e.skinning)&&h.viewMatrix!==null&&o.uniformMatrix4fv(h.viewMatrix,!1,Ea);e.skinning&&(o.uniformMatrix4fv(h.cameraInverseMatrix,!1,Ea),o.uniformMatrix4fv(h.boneGlobalMatrices,!1,f.boneMatrices))}o.uniformMatrix4fv(h.modelViewMatrix,!1,f._modelViewMatrixArray);h.normalMatrix&&o.uniformMatrix3fv(h.normalMatrix,!1,f._normalMatrixArray);(e instanceof THREE.ShaderMaterial||e.envMap||e.skinning||f.receiveShadow)&&h.objectMatrix!==null&&o.uniformMatrix4fv(h.objectMatrix,
-!1,f._objectMatrixArray);return k}function k(a,b,c,f,h,k){if(f.opacity!==0){var l,n,c=e(a,b,c,f,k),a=c.attributes,b=!1,c=h.id*16777215+c.id*2+(f.wireframe?1:0);c!==J&&(J=c,b=!0);if(!f.morphTargets&&a.position>=0)b&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(a.position,3,o.FLOAT,!1,0,0));else if(k.morphTargetBase){c=f.program.attributes;k.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[k.morphTargetBase]),o.vertexAttribPointer(c.position,
-3,o.FLOAT,!1,0,0)):c.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(c.position,3,o.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length){l=0;var v=k.morphTargetForcedOrder;for(n=k.morphTargetInfluences;l<f.numSupportedMorphTargets&&l<v.length;)o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[v[l]]),o.vertexAttribPointer(c["morphTarget"+l],3,o.FLOAT,!1,0,0),k.__webglMorphTargetInfluences[l]=n[v[l]],l++}else{var v=[],p=-1,u=0;n=k.morphTargetInfluences;var t,
-x=n.length;l=0;for(k.morphTargetBase!==-1&&(v[k.morphTargetBase]=!0);l<f.numSupportedMorphTargets;){for(t=0;t<x;t++)!v[t]&&n[t]>p&&(u=t,p=n[u]);o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[u]);o.vertexAttribPointer(c["morphTarget"+l],3,o.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[l]=p;v[u]=1;p=-1;l++}}f.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(f.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(b){if(h.__webglCustomAttributesList){l=0;for(n=
-h.__webglCustomAttributesList.length;l<n;l++)c=h.__webglCustomAttributesList[l],a[c.buffer.belongsToAttribute]>=0&&(o.bindBuffer(o.ARRAY_BUFFER,c.buffer),o.vertexAttribPointer(a[c.buffer.belongsToAttribute],c.size,o.FLOAT,!1,0,0))}a.color>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglColorBuffer),o.vertexAttribPointer(a.color,3,o.FLOAT,!1,0,0));a.normal>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglNormalBuffer),o.vertexAttribPointer(a.normal,3,o.FLOAT,!1,0,0));a.tangent>=0&&(o.bindBuffer(o.ARRAY_BUFFER,
-h.__webglTangentBuffer),o.vertexAttribPointer(a.tangent,4,o.FLOAT,!1,0,0));a.uv>=0&&(h.__webglUVBuffer?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglUVBuffer),o.vertexAttribPointer(a.uv,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(a.uv)):o.disableVertexAttribArray(a.uv));a.uv2>=0&&(h.__webglUV2Buffer?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglUV2Buffer),o.vertexAttribPointer(a.uv2,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(a.uv2)):o.disableVertexAttribArray(a.uv2));f.skinning&&a.skinVertexA>=0&&a.skinVertexB>=
-0&&a.skinIndex>=0&&a.skinWeight>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinVertexABuffer),o.vertexAttribPointer(a.skinVertexA,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),o.vertexAttribPointer(a.skinVertexB,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),o.vertexAttribPointer(a.skinIndex,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),o.vertexAttribPointer(a.skinWeight,4,o.FLOAT,!1,0,0))}k instanceof THREE.Mesh?(f.wireframe?
-(o.lineWidth(f.wireframeLinewidth),b&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),o.drawElements(o.LINES,h.__webglLineCount,o.UNSIGNED_SHORT,0)):(b&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),o.drawElements(o.TRIANGLES,h.__webglFaceCount,o.UNSIGNED_SHORT,0)),P.info.render.calls++,P.info.render.vertices+=h.__webglFaceCount,P.info.render.faces+=h.__webglFaceCount/3):k instanceof THREE.Line?(k=k.type===THREE.LineStrip?o.LINE_STRIP:o.LINES,o.lineWidth(f.linewidth),o.drawArrays(k,
-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,
+l),o.bindTexture(o.TEXTURE_CUBE_MAP,u.__webglTexture)):V(t,l)}else if(x==="tv"){if(!u._array){u._array=[];x=0;for(w=u.texture.length;x<w;x++)u._array[x]=l+x}o.uniform1iv(t,u._array);x=0;for(w=u.texture.length;x<w;x++)(t=u.texture[x])&&V(t,u._array[x])}(e instanceof THREE.ShaderMaterial||e instanceof THREE.MeshPhongMaterial||e.envMap)&&k.cameraPosition!==null&&o.uniform3f(k.cameraPosition,a.position.x,a.position.y,a.position.z);(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||
+e instanceof THREE.ShaderMaterial||e.skinning)&&k.viewMatrix!==null&&o.uniformMatrix4fv(k.viewMatrix,!1,Ea);e.skinning&&(o.uniformMatrix4fv(k.cameraInverseMatrix,!1,Ea),o.uniformMatrix4fv(k.boneGlobalMatrices,!1,f.boneMatrices))}o.uniformMatrix4fv(k.modelViewMatrix,!1,f._modelViewMatrixArray);k.normalMatrix&&o.uniformMatrix3fv(k.normalMatrix,!1,f._normalMatrixArray);(e instanceof THREE.ShaderMaterial||e.envMap||e.skinning||f.receiveShadow)&&k.objectMatrix!==null&&o.uniformMatrix4fv(k.objectMatrix,
+!1,f._objectMatrixArray);return h}function k(a,b,c,f,k,h){if(f.opacity!==0){var l,n,c=e(a,b,c,f,h),a=c.attributes,b=!1,c=k.id*16777215+c.id*2+(f.wireframe?1:0);c!==J&&(J=c,b=!0);if(!f.morphTargets&&a.position>=0)b&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer),o.vertexAttribPointer(a.position,3,o.FLOAT,!1,0,0));else if(h.morphTargetBase){c=f.program.attributes;h.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[h.morphTargetBase]),o.vertexAttribPointer(c.position,
+3,o.FLOAT,!1,0,0)):c.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer),o.vertexAttribPointer(c.position,3,o.FLOAT,!1,0,0));if(h.morphTargetForcedOrder.length){l=0;var v=h.morphTargetForcedOrder;for(n=h.morphTargetInfluences;l<f.numSupportedMorphTargets&&l<v.length;)o.bindBuffer(o.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[v[l]]),o.vertexAttribPointer(c["morphTarget"+l],3,o.FLOAT,!1,0,0),h.__webglMorphTargetInfluences[l]=n[v[l]],l++}else{var v=[],p=-1,u=0;n=h.morphTargetInfluences;var t,
+x=n.length;l=0;for(h.morphTargetBase!==-1&&(v[h.morphTargetBase]=!0);l<f.numSupportedMorphTargets;){for(t=0;t<x;t++)!v[t]&&n[t]>p&&(u=t,p=n[u]);o.bindBuffer(o.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[u]);o.vertexAttribPointer(c["morphTarget"+l],3,o.FLOAT,!1,0,0);h.__webglMorphTargetInfluences[l]=p;v[u]=1;p=-1;l++}}f.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(f.program.uniforms.morphTargetInfluences,h.__webglMorphTargetInfluences)}if(b){if(k.__webglCustomAttributesList){l=0;for(n=
+k.__webglCustomAttributesList.length;l<n;l++)c=k.__webglCustomAttributesList[l],a[c.buffer.belongsToAttribute]>=0&&(o.bindBuffer(o.ARRAY_BUFFER,c.buffer),o.vertexAttribPointer(a[c.buffer.belongsToAttribute],c.size,o.FLOAT,!1,0,0))}a.color>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglColorBuffer),o.vertexAttribPointer(a.color,3,o.FLOAT,!1,0,0));a.normal>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglNormalBuffer),o.vertexAttribPointer(a.normal,3,o.FLOAT,!1,0,0));a.tangent>=0&&(o.bindBuffer(o.ARRAY_BUFFER,
+k.__webglTangentBuffer),o.vertexAttribPointer(a.tangent,4,o.FLOAT,!1,0,0));a.uv>=0&&(k.__webglUVBuffer?(o.bindBuffer(o.ARRAY_BUFFER,k.__webglUVBuffer),o.vertexAttribPointer(a.uv,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(a.uv)):o.disableVertexAttribArray(a.uv));a.uv2>=0&&(k.__webglUV2Buffer?(o.bindBuffer(o.ARRAY_BUFFER,k.__webglUV2Buffer),o.vertexAttribPointer(a.uv2,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(a.uv2)):o.disableVertexAttribArray(a.uv2));f.skinning&&a.skinVertexA>=0&&a.skinVertexB>=
+0&&a.skinIndex>=0&&a.skinWeight>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinVertexABuffer),o.vertexAttribPointer(a.skinVertexA,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinVertexBBuffer),o.vertexAttribPointer(a.skinVertexB,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinIndicesBuffer),o.vertexAttribPointer(a.skinIndex,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinWeightsBuffer),o.vertexAttribPointer(a.skinWeight,4,o.FLOAT,!1,0,0))}h instanceof THREE.Mesh?(f.wireframe?
+(o.lineWidth(f.wireframeLinewidth),b&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,k.__webglLineBuffer),o.drawElements(o.LINES,k.__webglLineCount,o.UNSIGNED_SHORT,0)):(b&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,k.__webglFaceBuffer),o.drawElements(o.TRIANGLES,k.__webglFaceCount,o.UNSIGNED_SHORT,0)),P.info.render.calls++,P.info.render.vertices+=k.__webglFaceCount,P.info.render.faces+=k.__webglFaceCount/3):h instanceof THREE.Line?(h=h.type===THREE.LineStrip?o.LINE_STRIP:o.LINES,o.lineWidth(f.linewidth),o.drawArrays(h,
+0,k.__webglLineCount),P.info.render.calls++):h instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,k.__webglParticleCount),P.info.render.calls++):h instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,0,k.__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,k,h,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],k=c[t+2],h=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+h+l)/3,f=(f+n+v)/3,k=(k+p+u)/3,c[t]=e,c[t+1]=f,c[t+2]=k,c[t+3]=e,c[t+4]=f,c[t+5]=k,c[t+6]=e,c[t+7]=f,c[t+8]=k}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)}
 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||$!==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+
 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=
 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=
@@ -258,10 +257,10 @@ c.materialIndex,c>=0)b=b.geometry.materials[c],b.transparent?(a.transparent=b,a.
 -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,
 -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),
 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,
 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,
+o,ka):F.render(function(a){h(a,program,Ga.shading)}));v++}}function y(a,b){var c,e,f;c=X.attributes;var k=X.uniforms,h=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(k.projectionMatrix,!1,Da);o.activeTexture(o.TEXTURE0);o.uniform1i(k.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(k.useScreenCoordinates,1),o.uniform3f(k.screenPosition,(f.position.x-v)/v,(u-f.position.y)/u,Math.max(0,Math.min(1,f.position.z)))):(o.uniform1i(k.useScreenCoordinates,0),o.uniform1i(k.affectedByDistance,f.affectedByDistance?1:0),o.uniformMatrix4fv(k.modelViewMatrix,!1,f._modelViewMatrixArray)),l=f.map.image.width/(f.scaleByViewport?ma:1),n[0]=l*h*f.scale.x,n[1]=l*f.scale.y,o.uniform2f(k.uvScale,f.uvScale.x,
+f.uvScale.y),o.uniform2f(k.uvOffset,f.uvOffset.x,f.uvOffset.y),o.uniform2f(k.alignment,f.alignment.x,f.alignment.y),o.uniform1f(k.opacity,f.opacity),o.uniform3f(k.color,f.color.r,f.color.g,f.color.b),o.uniform1f(k.rotation,f.rotation),o.uniform2fv(k.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})}
 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-
 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=
 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=
@@ -286,38 +285,38 @@ o.linkProgram(X.program);X.attributes={};X.uniforms={};X.attributes.position=o.g
 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=
 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=
 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),
 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,
+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,k,h,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++)h=b[v],h instanceof THREE.SpotLight&&u++,h instanceof THREE.DirectionalLight&&u++,h instanceof THREE.PointLight&&n++;n+u<=ua?v=u:(v=Math.ceil(ua*u/(n+u)),n=ua-v);h={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:h.directional,maxPointLights:h.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 "+
 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.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,
+h=["#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",h+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,
 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);
 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]),
+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(k in a.attributes)x[k]!==void 0&&x[k]>=0&&o.enableVertexAttribArray(x[k]);if(a.morphTargets)for(k=a.numSupportedMorphTargets=0;k<this.maxMorphTargets;k++)w="morphTarget"+k,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;b.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),
 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),
 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=
 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.__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.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&&
 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;
-if(k.geometryGroups===void 0){var l=k,n=void 0,v=void 0,u=void 0,p=void 0,t=u=void 0,F=void 0,x={},w=l.morphTargets.length;l.geometryGroups={};n=0;for(v=l.faces.length;n<v;n++)u=l.faces[n],p=u.materialIndex,t=p!==void 0?p:-1,x[t]===void 0&&(x[t]={hash:t,counter:0}),F=x[t].hash+"_"+x[t].counter,l.geometryGroups[F]===void 0&&(l.geometryGroups[F]={faces:[],materialIndex:p,vertices:0,numMorphTargets:w}),u=u instanceof THREE.Face3?3:4,l.geometryGroups[F].vertices+u>65535&&(x[t].counter+=1,F=x[t].hash+
-"_"+x[t].counter,l.geometryGroups[F]===void 0&&(l.geometryGroups[F]={faces:[],materialIndex:p,vertices:0,numMorphTargets:w})),l.geometryGroups[F].faces.push(n),l.geometryGroups[F].vertices+=u;l.geometryGroupsList=[];n=void 0;for(n in l.geometryGroups)l.geometryGroups[n].id=ra++,l.geometryGroupsList.push(l.geometryGroups[n])}for(h in k.geometryGroups)if(l=k.geometryGroups[h],!l.__webglVertexBuffer){n=l;n.__webglVertexBuffer=o.createBuffer();n.__webglNormalBuffer=o.createBuffer();n.__webglTangentBuffer=
+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,k=void 0,h=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){h=e.geometry;
+if(h.geometryGroups===void 0){var l=h,n=void 0,v=void 0,u=void 0,p=void 0,t=u=void 0,F=void 0,x={},w=l.morphTargets.length;l.geometryGroups={};n=0;for(v=l.faces.length;n<v;n++)u=l.faces[n],p=u.materialIndex,t=p!==void 0?p:-1,x[t]===void 0&&(x[t]={hash:t,counter:0}),F=x[t].hash+"_"+x[t].counter,l.geometryGroups[F]===void 0&&(l.geometryGroups[F]={faces:[],materialIndex:p,vertices:0,numMorphTargets:w}),u=u instanceof THREE.Face3?3:4,l.geometryGroups[F].vertices+u>65535&&(x[t].counter+=1,F=x[t].hash+
+"_"+x[t].counter,l.geometryGroups[F]===void 0&&(l.geometryGroups[F]={faces:[],materialIndex:p,vertices:0,numMorphTargets:w})),l.geometryGroups[F].faces.push(n),l.geometryGroups[F].vertices+=u;l.geometryGroupsList=[];n=void 0;for(n in l.geometryGroups)l.geometryGroups[n].id=ra++,l.geometryGroupsList.push(l.geometryGroups[n])}for(k in h.geometryGroups)if(l=h.geometryGroups[k],!l.__webglVertexBuffer){n=l;n.__webglVertexBuffer=o.createBuffer();n.__webglNormalBuffer=o.createBuffer();n.__webglTangentBuffer=
 o.createBuffer();n.__webglColorBuffer=o.createBuffer();n.__webglUVBuffer=o.createBuffer();n.__webglUV2Buffer=o.createBuffer();n.__webglSkinVertexABuffer=o.createBuffer();n.__webglSkinVertexBBuffer=o.createBuffer();n.__webglSkinIndicesBuffer=o.createBuffer();n.__webglSkinWeightsBuffer=o.createBuffer();n.__webglFaceBuffer=o.createBuffer();n.__webglLineBuffer=o.createBuffer();if(n.numMorphTargets){p=v=void 0;n.__webglMorphTargetsBuffers=[];v=0;for(p=n.numMorphTargets;v<p;v++)n.__webglMorphTargetsBuffers.push(o.createBuffer())}P.info.memory.geometries++;
 o.createBuffer();n.__webglColorBuffer=o.createBuffer();n.__webglUVBuffer=o.createBuffer();n.__webglUV2Buffer=o.createBuffer();n.__webglSkinVertexABuffer=o.createBuffer();n.__webglSkinVertexBBuffer=o.createBuffer();n.__webglSkinIndicesBuffer=o.createBuffer();n.__webglSkinWeightsBuffer=o.createBuffer();n.__webglFaceBuffer=o.createBuffer();n.__webglLineBuffer=o.createBuffer();if(n.numMorphTargets){p=v=void 0;n.__webglMorphTargetsBuffers=[];v=0;for(p=n.numMorphTargets;v<p;v++)n.__webglMorphTargetsBuffers.push(o.createBuffer())}P.info.memory.geometries++;
 for(var p=e,y=u=x=void 0,t=y=w=y=void 0,F=t=n=0,z=u=void 0,ia=void 0,u=v=w=x=void 0,w=p.geometry,z=w.faces,ia=l.faces,x=0,u=ia.length;x<u;x++)y=ia[x],y=z[y],y instanceof THREE.Face3?(n+=3,t+=1,F+=3):y instanceof THREE.Face4&&(n+=4,t+=2,F+=4);x=c(p,l);u=x.map||x.lightMap||x instanceof THREE.ShaderMaterial?!0:!1;ia=x instanceof THREE.MeshBasicMaterial&&!x.envMap||x instanceof THREE.MeshDepthMaterial?!1:x&&x.shading!==void 0&&x.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;z=x.vertexColors?
 for(var p=e,y=u=x=void 0,t=y=w=y=void 0,F=t=n=0,z=u=void 0,ia=void 0,u=v=w=x=void 0,w=p.geometry,z=w.faces,ia=l.faces,x=0,u=ia.length;x<u;x++)y=ia[x],y=z[y],y instanceof THREE.Face3?(n+=3,t+=1,F+=3):y instanceof THREE.Face4&&(n+=4,t+=2,F+=4);x=c(p,l);u=x.map||x.lightMap||x instanceof THREE.ShaderMaterial?!0:!1;ia=x instanceof THREE.MeshBasicMaterial&&!x.envMap||x instanceof THREE.MeshDepthMaterial?!1:x&&x.shading!==void 0&&x.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;z=x.vertexColors?
 x.vertexColors:!1;l.__vertexArray=new Float32Array(n*3);if(ia)l.__normalArray=new Float32Array(n*3);if(w.hasTangents)l.__tangentArray=new Float32Array(n*4);if(z)l.__colorArray=new Float32Array(n*3);if(u){if(w.faceUvs.length>0||w.faceVertexUvs.length>0)l.__uvArray=new Float32Array(n*2);if(w.faceUvs.length>1||w.faceVertexUvs.length>1)l.__uv2Array=new Float32Array(n*2)}if(p.geometry.skinWeights.length&&p.geometry.skinIndices.length)l.__skinVertexAArray=new Float32Array(n*4),l.__skinVertexBArray=new Float32Array(n*
 x.vertexColors:!1;l.__vertexArray=new Float32Array(n*3);if(ia)l.__normalArray=new Float32Array(n*3);if(w.hasTangents)l.__tangentArray=new Float32Array(n*4);if(z)l.__colorArray=new Float32Array(n*3);if(u){if(w.faceUvs.length>0||w.faceVertexUvs.length>0)l.__uvArray=new Float32Array(n*2);if(w.faceUvs.length>1||w.faceVertexUvs.length>1)l.__uv2Array=new Float32Array(n*2)}if(p.geometry.skinWeights.length&&p.geometry.skinIndices.length)l.__skinVertexAArray=new Float32Array(n*4),l.__skinVertexBArray=new Float32Array(n*
 4),l.__skinIndexArray=new Float32Array(n*4),l.__skinWeightArray=new Float32Array(n*4);l.__faceArray=new Uint16Array(t*3);l.__lineArray=new Uint16Array(F*2);if(l.numMorphTargets){l.__morphTargetsArrays=[];w=0;for(y=l.numMorphTargets;w<y;w++)l.__morphTargetsArrays.push(new Float32Array(n*3))}l.__needsSmoothNormals=ia===THREE.SmoothShading;l.__uvType=u;l.__vertexColorType=z;l.__normalType=ia;l.__webglFaceCount=t*3;l.__webglLineCount=F*2;if(x.attributes){if(l.__webglCustomAttributesList===void 0)l.__webglCustomAttributesList=
 4),l.__skinIndexArray=new Float32Array(n*4),l.__skinWeightArray=new Float32Array(n*4);l.__faceArray=new Uint16Array(t*3);l.__lineArray=new Uint16Array(F*2);if(l.numMorphTargets){l.__morphTargetsArrays=[];w=0;for(y=l.numMorphTargets;w<y;w++)l.__morphTargetsArrays.push(new Float32Array(n*3))}l.__needsSmoothNormals=ia===THREE.SmoothShading;l.__uvType=u;l.__vertexColorType=z;l.__normalType=ia;l.__webglFaceCount=t*3;l.__webglLineCount=F*2;if(x.attributes){if(l.__webglCustomAttributesList===void 0)l.__webglCustomAttributesList=
-[];p=void 0;for(p in x.attributes){u=x.attributes[p];w={};for(v in u)w[v]=u[v];if(!w.__webglInitialized||w.createUniqueBuffers)w.__webglInitialized=!0,t=1,w.type==="v2"?t=2:w.type==="v3"?t=3:w.type==="v4"?t=4:w.type==="c"&&(t=3),w.size=t,w.array=new Float32Array(n*t),w.buffer=o.createBuffer(),w.buffer.belongsToAttribute=p,u.needsUpdate=!0,w.__original=u;l.__webglCustomAttributesList.push(w)}}l.__inittedArrays=!0;k.__dirtyVertices=!0;k.__dirtyMorphTargets=!0;k.__dirtyElements=!0;k.__dirtyUvs=!0;k.__dirtyNormals=
-!0;k.__dirtyTangents=!0;k.__dirtyColors=!0}}else if(e instanceof THREE.Ribbon){if(k=e.geometry,!k.__webglVertexBuffer)l=k,l.__webglVertexBuffer=o.createBuffer(),l.__webglColorBuffer=o.createBuffer(),P.info.memory.geometries++,l=k,n=l.vertices.length,l.__vertexArray=new Float32Array(n*3),l.__colorArray=new Float32Array(n*3),l.__webglVertexCount=n,k.__dirtyVertices=!0,k.__dirtyColors=!0}else if(e instanceof THREE.Line){if(k=e.geometry,!k.__webglVertexBuffer)l=k,l.__webglVertexBuffer=o.createBuffer(),
-l.__webglColorBuffer=o.createBuffer(),P.info.memory.geometries++,l=k,n=l.vertices.length,l.__vertexArray=new Float32Array(n*3),l.__colorArray=new Float32Array(n*3),l.__webglLineCount=n,k.__dirtyVertices=!0,k.__dirtyColors=!0}else if(e instanceof THREE.ParticleSystem&&(k=e.geometry,!k.__webglVertexBuffer)){l=k;l.__webglVertexBuffer=o.createBuffer();l.__webglColorBuffer=o.createBuffer();P.info.geometries++;l=k;v=e;n=l.vertices.length;l.__vertexArray=new Float32Array(n*3);l.__colorArray=new Float32Array(n*
+[];p=void 0;for(p in x.attributes){u=x.attributes[p];w={};for(v in u)w[v]=u[v];if(!w.__webglInitialized||w.createUniqueBuffers)w.__webglInitialized=!0,t=1,w.type==="v2"?t=2:w.type==="v3"?t=3:w.type==="v4"?t=4:w.type==="c"&&(t=3),w.size=t,w.array=new Float32Array(n*t),w.buffer=o.createBuffer(),w.buffer.belongsToAttribute=p,u.needsUpdate=!0,w.__original=u;l.__webglCustomAttributesList.push(w)}}l.__inittedArrays=!0;h.__dirtyVertices=!0;h.__dirtyMorphTargets=!0;h.__dirtyElements=!0;h.__dirtyUvs=!0;h.__dirtyNormals=
+!0;h.__dirtyTangents=!0;h.__dirtyColors=!0}}else if(e instanceof THREE.Ribbon){if(h=e.geometry,!h.__webglVertexBuffer)l=h,l.__webglVertexBuffer=o.createBuffer(),l.__webglColorBuffer=o.createBuffer(),P.info.memory.geometries++,l=h,n=l.vertices.length,l.__vertexArray=new Float32Array(n*3),l.__colorArray=new Float32Array(n*3),l.__webglVertexCount=n,h.__dirtyVertices=!0,h.__dirtyColors=!0}else if(e instanceof THREE.Line){if(h=e.geometry,!h.__webglVertexBuffer)l=h,l.__webglVertexBuffer=o.createBuffer(),
+l.__webglColorBuffer=o.createBuffer(),P.info.memory.geometries++,l=h,n=l.vertices.length,l.__vertexArray=new Float32Array(n*3),l.__colorArray=new Float32Array(n*3),l.__webglLineCount=n,h.__dirtyVertices=!0,h.__dirtyColors=!0}else if(e instanceof THREE.ParticleSystem&&(h=e.geometry,!h.__webglVertexBuffer)){l=h;l.__webglVertexBuffer=o.createBuffer();l.__webglColorBuffer=o.createBuffer();P.info.geometries++;l=h;v=e;n=l.vertices.length;l.__vertexArray=new Float32Array(n*3);l.__colorArray=new Float32Array(n*
 3);l.__sortArray=[];l.__webglParticleCount=n;v=v.material;if(v.attributes){if(l.__webglCustomAttributesList===void 0)l.__webglCustomAttributesList=[];p=void 0;for(p in v.attributes){originalAttribute=v.attributes[p];attribute={};for(property in originalAttribute)attribute[property]=originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=4:
 3);l.__sortArray=[];l.__webglParticleCount=n;v=v.material;if(v.attributes){if(l.__webglCustomAttributesList===void 0)l.__webglCustomAttributesList=[];p=void 0;for(p in v.attributes){originalAttribute=v.attributes[p];attribute={};for(property in originalAttribute)attribute[property]=originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=4:
-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,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,
+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)}}h.__dirtyVertices=!0;h.__dirtyColors=!0}if(!e.__webglActive){if(e instanceof THREE.Mesh)for(k in h=e.geometry,h.geometryGroups)l=h.geometryGroups[k],K(f.__webglObjects,l,e);else e instanceof THREE.Ribbon||e instanceof THREE.Line||
+e instanceof THREE.ParticleSystem?(h=e.geometry,K(f.__webglObjects,h,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;k=e;for(h=f.length-1;h>=0;h--)f[h]===k&&f.splice(h,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(h=a.__webglObjects[e].object,k=h.geometry,l=t=p=void 0,h instanceof THREE.Mesh){n=0;for(v=k.geometryGroupsList.length;n<v;n++)if(p=k.geometryGroupsList[n],l=c(h,p),t=l.attributes&&A(l),k.__dirtyVertices||
+k.__dirtyMorphTargets||k.__dirtyElements||k.__dirtyUvs||k.__dirtyNormals||k.__dirtyColors||k.__dirtyTangents||t)if(t=o.DYNAMIC_DRAW,F=!k.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=h.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,
 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+
 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]=
 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]=
@@ -337,10 +336,10 @@ 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[
 (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.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,
 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,$,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
-THREE.ParticleSystem)l=c(k,p),t=l.attributes&&A(l),(h.__dirtyVertices||h.__dirtyColors||k.sortParticles||t)&&b(h,o.DYNAMIC_DRAW,k),h.__dirtyVertices=!1,h.__dirtyColors=!1,l.attributes&&B(l)};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?o.frontFace(o.CCW):o.frontFace(o.CW),a==="back"?o.cullFace(o.BACK):a==="front"?o.cullFace(o.FRONT):o.cullFace(o.FRONT_AND_BACK),o.enable(o.CULL_FACE)):o.disable(o.CULL_FACE)};this.supportsVertexTextures=function(){return ya}};
+delete p.__faceArray,delete p.__vertexArray,delete p.__lineArray,delete p.__skinVertexAArray,delete p.__skinVertexBArray,delete p.__skinIndexArray,delete p.__skinWeightArray)}k.__dirtyVertices=!1;k.__dirtyMorphTargets=!1;k.__dirtyElements=!1;k.__dirtyUvs=!1;k.__dirtyNormals=!1;k.__dirtyColors=!1;k.__dirtyTangents=!1;l.attributes&&B(l)}else if(h instanceof THREE.Ribbon){if(k.__dirtyVertices||k.__dirtyColors){h=k;l=o.DYNAMIC_DRAW;n=x=F=F=void 0;w=h.vertices;v=h.colors;u=w.length;p=v.length;z=h.__vertexArray;
+t=h.__colorArray;ia=h.__dirtyColors;if(h.__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,h.__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,h.__webglColorBuffer);o.bufferData(o.ARRAY_BUFFER,t,l)}}k.__dirtyVertices=!1;k.__dirtyColors=!1}else if(h instanceof THREE.Line){if(k.__dirtyVertices||k.__dirtyColors){h=k;l=o.DYNAMIC_DRAW;
+n=x=F=F=void 0;w=h.vertices;v=h.colors;u=w.length;p=v.length;z=h.__vertexArray;t=h.__colorArray;ia=h.__dirtyColors;if(h.__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,h.__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,h.__webglColorBuffer);o.bufferData(o.ARRAY_BUFFER,t,l)}}k.__dirtyVertices=!1;k.__dirtyColors=!1}else if(h instanceof
+THREE.ParticleSystem)l=c(h,p),t=l.attributes&&A(l),(k.__dirtyVertices||k.__dirtyColors||h.sortParticles||t)&&b(k,o.DYNAMIC_DRAW,h),k.__dirtyVertices=!1,k.__dirtyColors=!1,l.attributes&&B(l)};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?o.frontFace(o.CCW):o.frontFace(o.CW),a==="back"?o.cullFace(o.BACK):a==="front"?o.cullFace(o.FRONT):o.cullFace(o.FRONT_AND_BACK),o.enable(o.CULL_FACE)):o.disable(o.CULL_FACE)};this.supportsVertexTextures=function(){return ya}};
 THREE.WebGLRenderTarget=function(a,c,b){this.width=a;this.height=c;b=b||{};this.wrapS=b.wrapS!==void 0?b.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=b.wrapT!==void 0?b.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=b.magFilter!==void 0?b.magFilter:THREE.LinearFilter;this.minFilter=b.minFilter!==void 0?b.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=b.format!==void 0?b.format:THREE.RGBAFormat;this.type=b.type!==void 0?b.type:
 THREE.WebGLRenderTarget=function(a,c,b){this.width=a;this.height=c;b=b||{};this.wrapS=b.wrapS!==void 0?b.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=b.wrapT!==void 0?b.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=b.magFilter!==void 0?b.magFilter:THREE.LinearFilter;this.minFilter=b.minFilter!==void 0?b.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=b.format!==void 0?b.format:THREE.RGBAFormat;this.type=b.type!==void 0?b.type:
 THREE.UnsignedByteType;this.depthBuffer=b.depthBuffer!==void 0?b.depthBuffer:!0;this.stencilBuffer=b.stencilBuffer!==void 0?b.stencilBuffer:!0};
 THREE.UnsignedByteType;this.depthBuffer=b.depthBuffer!==void 0?b.depthBuffer:!0;this.stencilBuffer=b.stencilBuffer!==void 0?b.stencilBuffer:!0};
 THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,c,b){THREE.WebGLRenderTarget.call(this,a,c,b);this.activeCubeFace=0};
 THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,c,b){THREE.WebGLRenderTarget.call(this,a,c,b);this.activeCubeFace=0};
@@ -430,7 +429,7 @@ THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","ro
 !1):(a.matrix=t[v][u],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var x=0;x<3;x++){b=c[x];f=n.prevKey[b];l=n.nextKey[b];if(l.time<=w){if(p<w)if(this.loop){f=this.data.hierarchy[v].keys[0];for(l=this.getNextKeyWith(b,v,1);l.time<p;)f=l,l=this.getNextKeyWith(b,v,l.index+1)}else{this.stop();return}else{do f=l,l=this.getNextKeyWith(b,v,l.index+1);while(l.time<
 !1):(a.matrix=t[v][u],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var x=0;x<3;x++){b=c[x];f=n.prevKey[b];l=n.nextKey[b];if(l.time<=w){if(p<w)if(this.loop){f=this.data.hierarchy[v].keys[0];for(l=this.getNextKeyWith(b,v,1);l.time<p;)f=l,l=this.getNextKeyWith(b,v,l.index+1)}else{this.stop();return}else{do f=l,l=this.getNextKeyWith(b,v,l.index+1);while(l.time<
 p)}n.prevKey[b]=f;n.nextKey[b]=l}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(p-f.time)/(l.time-f.time);k=f[b];h=l[b];if(e<0||e>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+v),e=e<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=k[0]+(h[0]-k[0])*e,b.y=k[1]+(h[1]-k[1])*e,b.z=k[2]+(h[2]-k[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
 p)}n.prevKey[b]=f;n.nextKey[b]=l}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(p-f.time)/(l.time-f.time);k=f[b];h=l[b];if(e<0||e>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+v),e=e<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=k[0]+(h[0]-k[0])*e,b.y=k[1]+(h[1]-k[1])*e,b.z=k[2]+(h[2]-k[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
 this.getPrevKeyWith("pos",v,f.index-1).pos,this.points[1]=k,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",v,l.index+1).pos,e=e*0.33+0.33,k=this.interpolateCatmullRom(this.points,e),b.x=k[0],b.y=k[1],b.z=k[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(b===
 this.getPrevKeyWith("pos",v,f.index-1).pos,this.points[1]=k,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",v,l.index+1).pos,e=e*0.33+0.33,k=this.interpolateCatmullRom(this.points,e),b.x=k[0],b.y=k[1],b.z=k[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(b===
-"rot")THREE.Quaternion.slerp(k,h,a.quaternion,e);else if(b==="scl")b=a.scale,b.x=k[0]+(h[0]-k[0])*e,b.y=k[1]+(h[1]-k[1])*e,b.z=k[2]+(h[2]-k[2])*e}}if(this.JITCompile&&t[0][u]===void 0){this.hierarchy[0].update(void 0,!0);for(v=0;v<this.hierarchy.length;v++)t[v][u]=this.hierarchy[v]instanceof THREE.Bone?this.hierarchy[v].skinMatrix.clone():this.hierarchy[v].matrix.clone()}}};
+"rot")THREE.Quaternion.slerp(k,h,a.quaternion,e);else if(b==="scl")b=a.scale,b.x=k[0]+(h[0]-k[0])*e,b.y=k[1]+(h[1]-k[1])*e,b.z=k[2]+(h[2]-k[2])*e}}if(this.JITCompile&&t[0][u]===void 0){this.hierarchy[0].update(null,!0);for(v=0;v<this.hierarchy.length;v++)t[v][u]=this.hierarchy[v]instanceof THREE.Bone?this.hierarchy[v].skinMatrix.clone():this.hierarchy[v].matrix.clone()}}};
 THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],e=[],k,h,f,l,n,u;k=(a.length-1)*c;h=Math.floor(k);k-=h;b[0]=h===0?h:h-1;b[1]=h;b[2]=h>a.length-2?h:h+1;b[3]=h>a.length-3?h:h+2;h=a[b[0]];l=a[b[1]];n=a[b[2]];u=a[b[3]];b=k*k;f=k*b;e[0]=this.interpolate(h[0],l[0],n[0],u[0],k,b,f);e[1]=this.interpolate(h[1],l[1],n[1],u[1],k,b,f);e[2]=this.interpolate(h[2],l[2],n[2],u[2],k,b,f);return e};
 THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],e=[],k,h,f,l,n,u;k=(a.length-1)*c;h=Math.floor(k);k-=h;b[0]=h===0?h:h-1;b[1]=h;b[2]=h>a.length-2?h:h+1;b[3]=h>a.length-3?h:h+2;h=a[b[0]];l=a[b[1]];n=a[b[2]];u=a[b[3]];b=k*k;f=k*b;e[0]=this.interpolate(h[0],l[0],n[0],u[0],k,b,f);e[1]=this.interpolate(h[1],l[1],n[1],u[1],k,b,f);e[2]=this.interpolate(h[2],l[2],n[2],u[2],k,b,f);return e};
 THREE.Animation.prototype.interpolate=function(a,c,b,e,k,h,f){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*f+(-3*(c-b)-2*a-e)*h+a*k+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b<e.length-1?b:e.length-1:b%=e.length;b<e.length;b++)if(e[b][a]!==void 0)return e[b];return this.data.hierarchy[c].keys[0]};
 THREE.Animation.prototype.interpolate=function(a,c,b,e,k,h,f){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*f+(-3*(c-b)-2*a-e)*h+a*k+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b<e.length-1?b:e.length-1:b%=e.length;b<e.length;b++)if(e[b][a]!==void 0)return e[b];return this.data.hierarchy[c].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){for(var e=this.data.hierarchy[c].keys,b=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b>0?b:0:b>=0?b:b+e.length;b>=0;b--)if(e[b][a]!==void 0)return e[b];return this.data.hierarchy[c].keys[e.length-1]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){for(var e=this.data.hierarchy[c].keys,b=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b>0?b:0:b>=0?b:b+e.length;b>=0;b--)if(e[b][a]!==void 0)return e[b];return this.data.hierarchy[c].keys[e.length-1]};

+ 3 - 3
build/custom/ThreeCanvas.js

@@ -117,9 +117,9 @@ THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat
 THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
 THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;if(b instanceof Array)console.warn("DEPRECATE: Material array is no longer supported. Using material 0..."),this.material=b[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c<
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;if(b instanceof Array)console.warn("DEPRECATE: Material array is no longer supported. Using material 0..."),this.material=b[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c<
 this.geometry.morphTargets.length;c++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[c].name]=c}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
 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;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
+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};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
+THREE.Bone.prototype.update=function(a,b){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var c,d=this.children.length;for(c=0;c<d;c++)this.children[c].update(this.skinMatrix,b)};
+THREE.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.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.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"),
 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"),

+ 3 - 3
build/custom/ThreeDOM.js

@@ -79,9 +79,9 @@ THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,thi
 THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
 THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
 THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
 THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
 THREE.PerspectiveCamera.prototype.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,
 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;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
+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};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
+THREE.Bone.prototype.update=function(a,b){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var c,d=this.children.length;for(c=0;c<d;c++)this.children[c].update(this.skinMatrix,b)};
+THREE.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.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.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.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"}}};

+ 1 - 1
build/custom/ThreeExtras.js

@@ -81,7 +81,7 @@ THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","ro
 !1):(a.matrix=n[u][m],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var v=0;v<3;v++){b=c[v];f=l.prevKey[b];k=l.nextKey[b];if(k.time<=t){if(o<t)if(this.loop){f=this.data.hierarchy[u].keys[0];for(k=this.getNextKeyWith(b,u,1);k.time<o;)f=k,k=this.getNextKeyWith(b,u,k.index+1)}else{this.stop();return}else{do f=k,k=this.getNextKeyWith(b,u,k.index+1);while(k.time<
 !1):(a.matrix=n[u][m],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var v=0;v<3;v++){b=c[v];f=l.prevKey[b];k=l.nextKey[b];if(k.time<=t){if(o<t)if(this.loop){f=this.data.hierarchy[u].keys[0];for(k=this.getNextKeyWith(b,u,1);k.time<o;)f=k,k=this.getNextKeyWith(b,u,k.index+1)}else{this.stop();return}else{do f=k,k=this.getNextKeyWith(b,u,k.index+1);while(k.time<
 o)}l.prevKey[b]=f;l.nextKey[b]=k}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(o-f.time)/(k.time-f.time);g=f[b];h=k[b];if(e<0||e>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+u),e=e<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=g[0]+(h[0]-g[0])*e,b.y=g[1]+(h[1]-g[1])*e,b.z=g[2]+(h[2]-g[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
 o)}l.prevKey[b]=f;l.nextKey[b]=k}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(o-f.time)/(k.time-f.time);g=f[b];h=k[b];if(e<0||e>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+u),e=e<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=g[0]+(h[0]-g[0])*e,b.y=g[1]+(h[1]-g[1])*e,b.z=g[2]+(h[2]-g[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
 this.getPrevKeyWith("pos",u,f.index-1).pos,this.points[1]=g,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos,e=e*0.33+0.33,g=this.interpolateCatmullRom(this.points,e),b.x=g[0],b.y=g[1],b.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(b===
 this.getPrevKeyWith("pos",u,f.index-1).pos,this.points[1]=g,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos,e=e*0.33+0.33,g=this.interpolateCatmullRom(this.points,e),b.x=g[0],b.y=g[1],b.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(b===
-"rot")THREE.Quaternion.slerp(g,h,a.quaternion,e);else if(b==="scl")b=a.scale,b.x=g[0]+(h[0]-g[0])*e,b.y=g[1]+(h[1]-g[1])*e,b.z=g[2]+(h[2]-g[2])*e}}if(this.JITCompile&&n[0][m]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;u<this.hierarchy.length;u++)n[u][m]=this.hierarchy[u]instanceof THREE.Bone?this.hierarchy[u].skinMatrix.clone():this.hierarchy[u].matrix.clone()}}};
+"rot")THREE.Quaternion.slerp(g,h,a.quaternion,e);else if(b==="scl")b=a.scale,b.x=g[0]+(h[0]-g[0])*e,b.y=g[1]+(h[1]-g[1])*e,b.z=g[2]+(h[2]-g[2])*e}}if(this.JITCompile&&n[0][m]===void 0){this.hierarchy[0].update(null,!0);for(u=0;u<this.hierarchy.length;u++)n[u][m]=this.hierarchy[u]instanceof THREE.Bone?this.hierarchy[u].skinMatrix.clone():this.hierarchy[u].matrix.clone()}}};
 THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],e=[],g,h,f,k,l,m;g=(a.length-1)*c;h=Math.floor(g);g-=h;b[0]=h===0?h:h-1;b[1]=h;b[2]=h>a.length-2?h:h+1;b[3]=h>a.length-3?h:h+2;h=a[b[0]];k=a[b[1]];l=a[b[2]];m=a[b[3]];b=g*g;f=g*b;e[0]=this.interpolate(h[0],k[0],l[0],m[0],g,b,f);e[1]=this.interpolate(h[1],k[1],l[1],m[1],g,b,f);e[2]=this.interpolate(h[2],k[2],l[2],m[2],g,b,f);return e};
 THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],e=[],g,h,f,k,l,m;g=(a.length-1)*c;h=Math.floor(g);g-=h;b[0]=h===0?h:h-1;b[1]=h;b[2]=h>a.length-2?h:h+1;b[3]=h>a.length-3?h:h+2;h=a[b[0]];k=a[b[1]];l=a[b[2]];m=a[b[3]];b=g*g;f=g*b;e[0]=this.interpolate(h[0],k[0],l[0],m[0],g,b,f);e[1]=this.interpolate(h[1],k[1],l[1],m[1],g,b,f);e[2]=this.interpolate(h[2],k[2],l[2],m[2],g,b,f);return e};
 THREE.Animation.prototype.interpolate=function(a,c,b,e,g,h,f){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*f+(-3*(c-b)-2*a-e)*h+a*g+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b<e.length-1?b:e.length-1:b%=e.length;b<e.length;b++)if(e[b][a]!==void 0)return e[b];return this.data.hierarchy[c].keys[0]};
 THREE.Animation.prototype.interpolate=function(a,c,b,e,g,h,f){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*f+(-3*(c-b)-2*a-e)*h+a*g+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b<e.length-1?b:e.length-1:b%=e.length;b<e.length;b++)if(e[b][a]!==void 0)return e[b];return this.data.hierarchy[c].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){for(var e=this.data.hierarchy[c].keys,b=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b>0?b:0:b>=0?b:b+e.length;b>=0;b--)if(e[b][a]!==void 0)return e[b];return this.data.hierarchy[c].keys[e.length-1]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){for(var e=this.data.hierarchy[c].keys,b=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b>0?b:0:b>=0?b:b+e.length;b>=0;b--)if(e[b][a]!==void 0)return e[b];return this.data.hierarchy[c].keys[e.length-1]};

+ 3 - 3
build/custom/ThreeSVG.js

@@ -112,9 +112,9 @@ THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this
 THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=b;this.type=c!=void 0?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
 THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=b;this.type=c!=void 0?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;if(b instanceof Array)console.warn("DEPRECATE: Material array is no longer supported. Using material 0..."),this.material=b[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c<
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;if(b instanceof Array)console.warn("DEPRECATE: Material array is no longer supported. Using material 0..."),this.material=b[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c<
 this.geometry.morphTargets.length;c++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[c].name]=c}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
 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;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
+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};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
+THREE.Bone.prototype.update=function(a,b){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var c,d=this.children.length;for(c=0;c<d;c++)this.children[c].update(this.skinMatrix,b)};
+THREE.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.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.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",
 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",

+ 77 - 78
build/custom/ThreeWebGL.js

@@ -1,7 +1,7 @@
 // ThreeWebGL.js r46dev - http://github.com/mrdoob/three.js
 // ThreeWebGL.js r46dev - http://github.com/mrdoob/three.js
 var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
 var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;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,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var e,h,f;if(c===0)this.r=this.g=this.b=0;else switch(e=Math.floor(a*6),h=a*6-e,a=c*(1-b),f=c*(1-
-b*h),b=c*(1-b*(1-h)),e){case 1:this.r=f;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=f;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=f;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+
+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,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var e,f,h;if(c===0)this.r=this.g=this.b=0;else switch(e=Math.floor(a*6),f=a*6-e,a=c*(1-b),h=c*(1-
+b*f),b=c*(1-b*(1-f)),e){case 1:this.r=h;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=h;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=h;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(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,b){this.x=a||0;this.y=b||0};
 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,b){this.x=a||0;this.y=b||0};
 THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},
 THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},
 divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)},
 divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)},
@@ -15,85 +15,85 @@ THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,e){this.x=
 b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
 b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.children)},intersectObjects:function(a){var b,c,e=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(e,this.intersectObject(a[b]));e.sort(function(a,b){return a.distance-b.distance});return e},intersectObject:function(a){function b(a,b,c){var e;e=c.clone().subSelf(a).dot(b);if(e<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(e));return c.distanceTo(a)}function c(a,b,c,e){var e=e.clone().subSelf(b),
 THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.children)},intersectObjects:function(a){var b,c,e=[];b=0;for(c=a.length;b<c;b++)Array.prototype.push.apply(e,this.intersectObject(a[b]));e.sort(function(a,b){return a.distance-b.distance});return e},intersectObject:function(a){function b(a,b,c){var e;e=c.clone().subSelf(a).dot(b);if(e<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(e));return c.distanceTo(a)}function c(a,b,c,e){var e=e.clone().subSelf(b),
-c=c.clone().subSelf(b),h=a.clone().subSelf(b),a=e.dot(e),b=e.dot(c),e=e.dot(h),f=c.dot(c),c=c.dot(h),h=1/(a*f-b*b),f=(f*e-b*c)*h,a=(a*c-b*e)*h;return f>0&&a>0&&f+a<1}for(var e,h=[],f=0,i=a.children.length;f<i;f++)Array.prototype.push.apply(h,this.intersectObject(a.children[f]));if(a instanceof THREE.Particle){f=b(this.origin,this.direction,a.matrixWorld.getPosition());if(f===null||f>a.scale.x)return[];e={distance:f,point:a.position,face:null,object:a};h.push(e)}else if(a instanceof THREE.Mesh){f=
-b(this.origin,this.direction,a.matrixWorld.getPosition());if(f===null||f>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return h;var j,n,l,o,k,r,v,z,B=a.geometry,F=B.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);f=0;for(i=B.faces.length;f<i;f++)if(e=B.faces[f],v=this.origin.clone(),z=this.direction.clone(),o=a.matrixWorld,j=o.multiplyVector3(e.centroid.clone()).subSelf(v),r=j.dot(z),!(r<=0)&&(j=o.multiplyVector3(F[e.a].position.clone()),n=o.multiplyVector3(F[e.b].position.clone()),
-l=o.multiplyVector3(F[e.c].position.clone()),o=e instanceof THREE.Face4?o.multiplyVector3(F[e.d].position.clone()):null,k=a.matrixRotationWorld.multiplyVector3(e.normal.clone()),r=z.dot(k),a.doubleSided||(a.flipSided?r>0:r<0)))if(r=k.dot((new THREE.Vector3).sub(j,v))/r,v=v.addSelf(z.multiplyScalar(r)),e instanceof THREE.Face3)c(v,j,n,l)&&(e={distance:this.origin.distanceTo(v),point:v,face:e,object:a},h.push(e));else if(e instanceof THREE.Face4&&(c(v,j,n,o)||c(v,n,l,o)))e={distance:this.origin.distanceTo(v),
-point:v,face:e,object:a},h.push(e)}return h}};
-THREE.Rectangle=function(){function a(){f=e-b;i=h-c}var b,c,e,h,f,i,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return i};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(f,i,o,k){j=!1;b=f;c=i;e=o;h=k;a()};this.addPoint=function(f,i){j?(j=!1,b=f,c=i,e=f,h=i):(b=b<f?b:f,c=c<i?c:i,e=e>f?e:f,h=h>i?h:i);a()};this.add3Points=
-function(f,i,o,k,r,v){j?(j=!1,b=f<o?f<r?f:r:o<r?o:r,c=i<k?i<v?i:v:k<v?k:v,e=f>o?f>r?f:r:o>r?o:r,h=i>k?i>v?i:v:k>v?k:v):(b=f<o?f<r?f<b?f:b:r<b?r:b:o<r?o<b?o:b:r<b?r:b,c=i<k?i<v?i<c?i:c:v<c?v:c:k<v?k<c?k:c:v<c?v:c,e=f>o?f>r?f>e?f:e:r>e?r:e:o>r?o>e?o:e:r>e?r:e,h=i>k?i>v?i>h?i:h:v>h?v:h:k>v?k>h?k:h:v>h?v:h);a()};this.addRectangle=function(f){j?(j=!1,b=f.getLeft(),c=f.getTop(),e=f.getRight(),h=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),e=e>f.getRight()?e:f.getRight(),h=h>
-f.getBottom()?h:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;e+=f;h+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();e=e<f.getRight()?e:f.getRight();h=h<f.getBottom()?h:f.getBottom();a()};this.intersects=function(a){return Math.min(e,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(h,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){j=!0;h=e=c=b=0;a()};this.isEmpty=function(){return j}};THREE.Matrix3=function(){this.m=[]};
+c=c.clone().subSelf(b),f=a.clone().subSelf(b),a=e.dot(e),b=e.dot(c),e=e.dot(f),h=c.dot(c),c=c.dot(f),f=1/(a*h-b*b),h=(h*e-b*c)*f,a=(a*c-b*e)*f;return h>0&&a>0&&h+a<1}for(var e,f=[],h=0,i=a.children.length;h<i;h++)Array.prototype.push.apply(f,this.intersectObject(a.children[h]));if(a instanceof THREE.Particle){h=b(this.origin,this.direction,a.matrixWorld.getPosition());if(h===null||h>a.scale.x)return[];e={distance:h,point:a.position,face:null,object:a};f.push(e)}else if(a instanceof THREE.Mesh){h=
+b(this.origin,this.direction,a.matrixWorld.getPosition());if(h===null||h>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return f;var j,n,l,o,k,r,v,z,B=a.geometry,F=B.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);h=0;for(i=B.faces.length;h<i;h++)if(e=B.faces[h],v=this.origin.clone(),z=this.direction.clone(),o=a.matrixWorld,j=o.multiplyVector3(e.centroid.clone()).subSelf(v),r=j.dot(z),!(r<=0)&&(j=o.multiplyVector3(F[e.a].position.clone()),n=o.multiplyVector3(F[e.b].position.clone()),
+l=o.multiplyVector3(F[e.c].position.clone()),o=e instanceof THREE.Face4?o.multiplyVector3(F[e.d].position.clone()):null,k=a.matrixRotationWorld.multiplyVector3(e.normal.clone()),r=z.dot(k),a.doubleSided||(a.flipSided?r>0:r<0)))if(r=k.dot((new THREE.Vector3).sub(j,v))/r,v=v.addSelf(z.multiplyScalar(r)),e instanceof THREE.Face3)c(v,j,n,l)&&(e={distance:this.origin.distanceTo(v),point:v,face:e,object:a},f.push(e));else if(e instanceof THREE.Face4&&(c(v,j,n,o)||c(v,n,l,o)))e={distance:this.origin.distanceTo(v),
+point:v,face:e,object:a},f.push(e)}return f}};
+THREE.Rectangle=function(){function a(){h=e-b;i=f-c}var b,c,e,f,h,i,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return i};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(h,i,o,k){j=!1;b=h;c=i;e=o;f=k;a()};this.addPoint=function(h,i){j?(j=!1,b=h,c=i,e=h,f=i):(b=b<h?b:h,c=c<i?c:i,e=e>h?e:h,f=f>i?f:i);a()};this.add3Points=
+function(h,i,o,k,r,v){j?(j=!1,b=h<o?h<r?h:r:o<r?o:r,c=i<k?i<v?i:v:k<v?k:v,e=h>o?h>r?h:r:o>r?o:r,f=i>k?i>v?i:v:k>v?k:v):(b=h<o?h<r?h<b?h:b:r<b?r:b:o<r?o<b?o:b:r<b?r:b,c=i<k?i<v?i<c?i:c:v<c?v:c:k<v?k<c?k:c:v<c?v:c,e=h>o?h>r?h>e?h:e:r>e?r:e:o>r?o>e?o:e:r>e?r:e,f=i>k?i>v?i>f?i:f:v>f?v:f:k>v?k>f?k:f:v>f?v:f);a()};this.addRectangle=function(h){j?(j=!1,b=h.getLeft(),c=h.getTop(),e=h.getRight(),f=h.getBottom()):(b=b<h.getLeft()?b:h.getLeft(),c=c<h.getTop()?c:h.getTop(),e=e>h.getRight()?e:h.getRight(),f=f>
+h.getBottom()?f:h.getBottom());a()};this.inflate=function(h){b-=h;c-=h;e+=h;f+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();e=e<h.getRight()?e:h.getRight();f=f<h.getBottom()?f:h.getBottom();a()};this.intersects=function(a){return Math.min(e,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){j=!0;f=e=c=b=0;a()};this.isEmpty=function(){return j}};THREE.Matrix3=function(){this.m=[]};
 THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
 THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,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,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+
+THREE.Matrix4=function(a,b,c,e,f,h,i,j,n,l,o,k,r,v,z,B){this.set(a!==void 0?a:1,b||0,c||0,e||0,f||0,h!==void 0?h: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,f,h,i,j,n,l,o,k,r,v,z,B){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=f;this.n22=h;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,f=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;e.cross(c,h).normalize();e.length()===0&&(h.x+=1.0E-4,e.cross(c,h).normalize());f.cross(h,e).normalize();this.n11=e.x;this.n12=f.x;this.n13=h.x;this.n21=e.y;this.n22=f.y;this.n23=h.y;this.n31=e.z;this.n32=f.z;this.n33=h.z;return this},multiply:function(a,b){var c=a.n11,e=a.n12,f=a.n13,h=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,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+f*ma+h*K;this.n12=c*ia+e*T+f*pa+h*A;this.n13=c*ra+e*ta+f*X+h*d;this.n14=c*O+e*U+f*R+h*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;
 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;
+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,f=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)*f;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*
+e+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*f;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,f=this.n21,h=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*h*o*r+b*j*o*r+c*h*k*r-b*i*k*r-e*i*n*v+c*j*n*v+e*f*o*v-a*j*o*v-c*f*k*v+a*i*k*v+e*h*n*z-b*j*n*z-e*f*l*z+a*j*l*z+b*f*k*z-a*h*k*z-c*h*n*B+b*i*n*B+
+c*f*l*B-a*i*l*B-b*f*o*B+a*h*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;
 a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=
 a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=
 this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=
 this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=
 this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,
 this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,
-0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),h=1-c,f=a.x,i=a.y,j=a.z,n=h*f,l=h*i;this.set(n*f+c,n*i-e*j,n*j+e*i,0,n*i+e*j,l*i+c,l*j-e*f,0,n*j-e*i,l*j+e*f,h*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,
-this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,e=a.n13,h=a.n14,f=a.n21,i=a.n22,j=a.n23,n=a.n24,l=a.n31,o=a.n32,k=a.n33,r=a.n34,v=a.n41,z=a.n42,B=a.n43,F=a.n44;this.n11=j*r*z-n*k*z+n*o*B-i*r*B-j*o*F+i*k*F;this.n12=h*k*z-e*r*z-h*o*B+c*r*B+e*o*F-c*k*F;this.n13=e*n*z-h*j*z+h*i*B-c*n*B-e*i*F+c*j*F;this.n14=h*j*o-e*n*o-h*i*k+c*n*k+e*i*r-c*j*r;this.n21=n*k*v-j*r*v-n*l*B+f*r*B+j*l*F-f*k*F;this.n22=e*r*v-h*k*v+
-h*l*B-b*r*B-e*l*F+b*k*F;this.n23=h*j*v-e*n*v-h*f*B+b*n*B+e*f*F-b*j*F;this.n24=e*n*l-h*j*l+h*f*k-b*n*k-e*f*r+b*j*r;this.n31=i*r*v-n*o*v+n*l*z-f*r*z-i*l*F+f*o*F;this.n32=h*o*v-c*r*v-h*l*z+b*r*z+c*l*F-b*o*F;this.n33=e*n*v-h*i*v+h*f*z-b*n*z-c*f*F+b*i*F;this.n34=h*i*l-c*n*l-h*f*o+b*n*o+c*f*r-b*i*r;this.n41=j*o*v-i*k*v-j*l*z+f*k*z+i*l*B-f*o*B;this.n42=c*k*v-e*o*v+e*l*z-b*k*z-c*l*B+b*o*B;this.n43=e*i*v-c*j*v-e*f*z+b*j*z+c*f*B-b*i*B;this.n44=c*j*l-e*i*l+e*f*o-b*j*o-c*f*k+b*i*k;this.multiplyScalar(1/a.determinant());
-return this},setRotationFromEuler:function(a,b){var c=a.x,e=a.y,h=a.z,f=Math.cos(c),c=Math.sin(c),i=Math.cos(e),e=Math.sin(e),j=Math.cos(h),h=Math.sin(h);switch(b){case "YXZ":var n=i*j,l=i*h,o=e*j,k=e*h;this.n11=n+k*c;this.n12=o*c-l;this.n13=f*e;this.n21=f*h;this.n22=f*j;this.n23=-c;this.n31=l*c-o;this.n32=k+n*c;this.n33=f*i;break;case "ZXY":n=i*j;l=i*h;o=e*j;k=e*h;this.n11=n-k*c;this.n12=-f*h;this.n13=o+l*c;this.n21=l+o*c;this.n22=f*j;this.n23=k-n*c;this.n31=-f*e;this.n32=c;this.n33=f*i;break;case "ZYX":n=
-f*j;l=f*h;o=c*j;k=c*h;this.n11=i*j;this.n12=o*e-l;this.n13=n*e+k;this.n21=i*h;this.n22=k*e+n;this.n23=l*e-o;this.n31=-e;this.n32=c*i;this.n33=f*i;break;case "YZX":n=f*i;l=f*e;o=c*i;k=c*e;this.n11=i*j;this.n12=k-n*h;this.n13=o*h+l;this.n21=h;this.n22=f*j;this.n23=-c*j;this.n31=-e*j;this.n32=l*h+o;this.n33=n-k*h;break;case "XZY":n=f*i;l=f*e;o=c*i;k=c*e;this.n11=i*j;this.n12=-h;this.n13=e*j;this.n21=n*h+k;this.n22=f*j;this.n23=l*h-o;this.n31=o*h-l;this.n32=c*j;this.n33=k*h+n;break;default:n=f*j,l=f*
-h,o=c*j,k=c*h,this.n11=i*j,this.n12=-i*h,this.n13=e,this.n21=l+o*e,this.n22=n-k*e,this.n23=-c*i,this.n31=k-n*e,this.n32=o+l*e,this.n33=f*i}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,e=a.z,h=a.w,f=b+b,i=c+c,j=e+e,a=b*f,n=b*i;b*=j;var l=c*i;c*=j;e*=j;f*=h;i*=h;h*=j;this.n11=1-(l+e);this.n12=n-h;this.n13=b+i;this.n21=n+h;this.n22=1-(a+e);this.n23=c-f;this.n31=b-i;this.n32=c+f;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=
-a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var e=THREE.Matrix4.__m1,h=THREE.Matrix4.__m2;e.identity();e.setRotationFromQuaternion(b);h.setScale(c.x,c.y,c.z);this.multiply(e,h);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var e=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;e.set(this.n11,this.n21,this.n31);h.set(this.n12,this.n22,this.n32);f.set(this.n13,
-this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=e.length();c.y=h.length();c.z=f.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;e=THREE.Matrix4.__m1;e.copy(this);e.n11/=c.x;e.n21/=c.x;e.n31/=c.x;e.n12/=c.y;e.n22/=c.y;e.n32/=c.y;e.n13/=c.z;e.n23/=c.z;e.n33/=c.z;b.setFromRotationMatrix(e);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
+0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),f=1-c,h=a.x,i=a.y,j=a.z,n=f*h,l=f*i;this.set(n*h+c,n*i-e*j,n*j+e*i,0,n*i+e*j,l*i+c,l*j-e*h,0,n*j-e*i,l*j+e*h,f*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,
+this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,e=a.n13,f=a.n14,h=a.n21,i=a.n22,j=a.n23,n=a.n24,l=a.n31,o=a.n32,k=a.n33,r=a.n34,v=a.n41,z=a.n42,B=a.n43,F=a.n44;this.n11=j*r*z-n*k*z+n*o*B-i*r*B-j*o*F+i*k*F;this.n12=f*k*z-e*r*z-f*o*B+c*r*B+e*o*F-c*k*F;this.n13=e*n*z-f*j*z+f*i*B-c*n*B-e*i*F+c*j*F;this.n14=f*j*o-e*n*o-f*i*k+c*n*k+e*i*r-c*j*r;this.n21=n*k*v-j*r*v-n*l*B+h*r*B+j*l*F-h*k*F;this.n22=e*r*v-f*k*v+
+f*l*B-b*r*B-e*l*F+b*k*F;this.n23=f*j*v-e*n*v-f*h*B+b*n*B+e*h*F-b*j*F;this.n24=e*n*l-f*j*l+f*h*k-b*n*k-e*h*r+b*j*r;this.n31=i*r*v-n*o*v+n*l*z-h*r*z-i*l*F+h*o*F;this.n32=f*o*v-c*r*v-f*l*z+b*r*z+c*l*F-b*o*F;this.n33=e*n*v-f*i*v+f*h*z-b*n*z-c*h*F+b*i*F;this.n34=f*i*l-c*n*l-f*h*o+b*n*o+c*h*r-b*i*r;this.n41=j*o*v-i*k*v-j*l*z+h*k*z+i*l*B-h*o*B;this.n42=c*k*v-e*o*v+e*l*z-b*k*z-c*l*B+b*o*B;this.n43=e*i*v-c*j*v-e*h*z+b*j*z+c*h*B-b*i*B;this.n44=c*j*l-e*i*l+e*h*o-b*j*o-c*h*k+b*i*k;this.multiplyScalar(1/a.determinant());
+return this},setRotationFromEuler:function(a,b){var c=a.x,e=a.y,f=a.z,h=Math.cos(c),c=Math.sin(c),i=Math.cos(e),e=Math.sin(e),j=Math.cos(f),f=Math.sin(f);switch(b){case "YXZ":var n=i*j,l=i*f,o=e*j,k=e*f;this.n11=n+k*c;this.n12=o*c-l;this.n13=h*e;this.n21=h*f;this.n22=h*j;this.n23=-c;this.n31=l*c-o;this.n32=k+n*c;this.n33=h*i;break;case "ZXY":n=i*j;l=i*f;o=e*j;k=e*f;this.n11=n-k*c;this.n12=-h*f;this.n13=o+l*c;this.n21=l+o*c;this.n22=h*j;this.n23=k-n*c;this.n31=-h*e;this.n32=c;this.n33=h*i;break;case "ZYX":n=
+h*j;l=h*f;o=c*j;k=c*f;this.n11=i*j;this.n12=o*e-l;this.n13=n*e+k;this.n21=i*f;this.n22=k*e+n;this.n23=l*e-o;this.n31=-e;this.n32=c*i;this.n33=h*i;break;case "YZX":n=h*i;l=h*e;o=c*i;k=c*e;this.n11=i*j;this.n12=k-n*f;this.n13=o*f+l;this.n21=f;this.n22=h*j;this.n23=-c*j;this.n31=-e*j;this.n32=l*f+o;this.n33=n-k*f;break;case "XZY":n=h*i;l=h*e;o=c*i;k=c*e;this.n11=i*j;this.n12=-f;this.n13=e*j;this.n21=n*f+k;this.n22=h*j;this.n23=l*f-o;this.n31=o*f-l;this.n32=c*j;this.n33=k*f+n;break;default:n=h*j,l=h*
+f,o=c*j,k=c*f,this.n11=i*j,this.n12=-i*f,this.n13=e,this.n21=l+o*e,this.n22=n-k*e,this.n23=-c*i,this.n31=k-n*e,this.n32=o+l*e,this.n33=h*i}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,e=a.z,f=a.w,h=b+b,i=c+c,j=e+e,a=b*h,n=b*i;b*=j;var l=c*i;c*=j;e*=j;h*=f;i*=f;f*=j;this.n11=1-(l+e);this.n12=n-f;this.n13=b+i;this.n21=n+f;this.n22=1-(a+e);this.n23=c-h;this.n31=b-i;this.n32=c+h;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=
+a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var e=THREE.Matrix4.__m1,f=THREE.Matrix4.__m2;e.identity();e.setRotationFromQuaternion(b);f.setScale(c.x,c.y,c.z);this.multiply(e,f);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var e=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;e.set(this.n11,this.n21,this.n31);f.set(this.n12,this.n22,this.n32);h.set(this.n13,
+this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=e.length();c.y=f.length();c.z=h.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;e=THREE.Matrix4.__m1;e.copy(this);e.n11/=c.x;e.n21/=c.x;e.n31/=c.x;e.n12/=c.y;e.n22/=c.y;e.n32/=c.y;e.n13/=c.z;e.n23/=c.z;e.n33/=c.z;b.setFromRotationMatrix(e);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
 return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),e=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*e;this.n22=a.n22*e;this.n32=a.n32*e;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this}};
 return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),e=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*e;this.n22=a.n22*e;this.n32=a.n32*e;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this}};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,h=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,i=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,n=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,o=-a.n23*a.n11+a.n21*a.n13,k=a.n22*a.n11-a.n21*a.n12,a=a.n11*e+a.n21*i+a.n31*l;a===0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*e;c[1]=a*h;c[2]=a*f;c[3]=a*i;c[4]=a*j;c[5]=a*n;c[6]=a*l;c[7]=a*o;c[8]=a*k;return b};
-THREE.Matrix4.makeFrustum=function(a,b,c,e,h,f){var i;i=new THREE.Matrix4;i.n11=2*h/(b-a);i.n12=0;i.n13=(b+a)/(b-a);i.n14=0;i.n21=0;i.n22=2*h/(e-c);i.n23=(e+c)/(e-c);i.n24=0;i.n31=0;i.n32=0;i.n33=-(f+h)/(f-h);i.n34=-2*f*h/(f-h);i.n41=0;i.n42=0;i.n43=-1;i.n44=0;return i};THREE.Matrix4.makePerspective=function(a,b,c,e){var h,a=c*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,c,e)};
-THREE.Matrix4.makeOrtho=function(a,b,c,e,h,f){var i,j,n,l;i=new THREE.Matrix4;j=b-a;n=c-e;l=f-h;i.n11=2/j;i.n12=0;i.n13=0;i.n14=-((b+a)/j);i.n21=0;i.n22=2/n;i.n23=0;i.n24=-((c+e)/n);i.n31=0;i.n32=0;i.n33=-2/l;i.n34=-((f+h)/l);i.n41=0;i.n42=0;i.n43=0;i.n44=1;return i};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,i=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,n=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,o=-a.n23*a.n11+a.n21*a.n13,k=a.n22*a.n11-a.n21*a.n12,a=a.n11*e+a.n21*i+a.n31*l;a===0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*e;c[1]=a*f;c[2]=a*h;c[3]=a*i;c[4]=a*j;c[5]=a*n;c[6]=a*l;c[7]=a*o;c[8]=a*k;return b};
+THREE.Matrix4.makeFrustum=function(a,b,c,e,f,h){var i;i=new THREE.Matrix4;i.n11=2*f/(b-a);i.n12=0;i.n13=(b+a)/(b-a);i.n14=0;i.n21=0;i.n22=2*f/(e-c);i.n23=(e+c)/(e-c);i.n24=0;i.n31=0;i.n32=0;i.n33=-(h+f)/(h-f);i.n34=-2*h*f/(h-f);i.n41=0;i.n42=0;i.n43=-1;i.n44=0;return i};THREE.Matrix4.makePerspective=function(a,b,c,e){var f,a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,e)};
+THREE.Matrix4.makeOrtho=function(a,b,c,e,f,h){var i,j,n,l;i=new THREE.Matrix4;j=b-a;n=c-e;l=h-f;i.n11=2/j;i.n12=0;i.n13=0;i.n14=-((b+a)/j);i.n21=0;i.n22=2/n;i.n23=0;i.n24=-((c+e)/n);i.n31=0;i.n32=0;i.n33=-2/l;i.n34=-((h+f)/l);i.n41=0;i.n42=0;i.n43=0;i.n44=1;return i};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
 THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
 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};
 !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)===
 THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(a){if(this.children.indexOf(a)===
--1){a.parent!==void 0&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addObject(a)}},remove:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=void 0;this.children.splice(b,1);for(b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.removeObject(a)}},getChildByName:function(a,b){var c,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&&
+-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,f;c=0;for(e=this.children.length;c<e;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;
 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:[]};
+THREE.Projector=function(){function a(){var a=h[f]=h[f]||new THREE.RenderableVertex;f++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,e=1,h=a.z+a.w,f=b.z+b.w,i=-a.z+a.w,j=-b.z+b.w;return h>=0&&f>=0&&i>=0&&j>=0?!0:h<0&&f<0||i<0&&j<0?!1:(h<0?c=Math.max(c,h/(h-f)):f<0&&(e=Math.min(e,h/(h-f))),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,f,h=[],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);
 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);
 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,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)-
+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,h=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)),
+f=0;f<6;f++)if(c=O[f].x*e.n14+O[f].y*e.n24+O[f].z*e.n34+O[f].w,c<=h){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,f=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=h[A.a],S=h[A.b],W=h[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=h[A.a],S=h[A.b],W=h[A.c],Q=h[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);
 (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=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),
+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=h[f-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=
 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)};
 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);
+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,f=a.z*b,a=Math.cos(e),e=Math.sin(e),b=Math.cos(-f),f=Math.sin(-f),h=Math.cos(c),c=Math.sin(c),i=a*b,j=e*f;this.w=i*h-j*c;this.x=i*c+j*h;this.y=e*b*h+a*f*c;this.z=a*f*h-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.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.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.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};
+this.x,c=this.y,e=this.z,f=this.w,h=a.x,i=a.y,j=a.z,a=a.w;this.x=b*a+f*h+c*j-e*i;this.y=c*a+f*i+e*h-b*j;this.z=e*a+f*j+b*i-c*h;this.w=f*a-b*h-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,f=a.z,h=this.x,i=this.y,j=this.z,n=this.w,l=n*c+i*f-j*e,o=n*e+j*c-h*f,k=n*f+h*e-i*c,c=-h*
+c-i*e-j*f;b.x=l*n+c*-h+o*-j-k*-i;b.y=o*n+c*-i+k*-h-l*-j;b.z=k*n+c*-j+l*-i-o*-h;return b}};
+THREE.Quaternion.slerp=function(a,b,c,e){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 h=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-e)*h)/f;e=Math.sin(e*h)/f;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,f,h){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=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3};
+THREE.Face4=function(a,b,c,e,f,h,i){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];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)}};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
 THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
 THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
-THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a,new THREE.Vector3(1,1,1));for(var c=0,e=this.vertices.length;c<e;c++)a.multiplyVector3(this.vertices[c].position);c=0;for(e=this.faces.length;c<e;c++){var h=this.faces[c];b.multiplyVector3(h.normal);for(var f=0,i=h.vertexNormals.length;f<i;f++)b.multiplyVector3(h.vertexNormals[f]);a.multiplyVector3(h.centroid)}},computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<
+THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a,new THREE.Vector3(1,1,1));for(var c=0,e=this.vertices.length;c<e;c++)a.multiplyVector3(this.vertices[c].position);c=0;for(e=this.faces.length;c<e;c++){var f=this.faces[c];b.multiplyVector3(f.normal);for(var h=0,i=f.vertexNormals.length;h<i;h++)b.multiplyVector3(f.vertexNormals[h]);a.multiplyVector3(f.centroid)}},computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<
 b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(a){var b,
 b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(a){var b,
-c,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=
+c,e,f,h,i,j=new THREE.Vector3,n=new THREE.Vector3;e=0;for(f=this.faces.length;e<f;e++){h=this.faces[e];if(a&&h.vertexNormals.length){j.set(0,0,0);b=0;for(c=h.vertexNormals.length;b<c;b++)j.addSelf(h.vertexNormals[b]);j.divideScalar(3)}else b=this.vertices[h.a],c=this.vertices[h.b],i=this.vertices[h.c],j.sub(i.position,c.position),n.sub(b.position,c.position),j.crossSelf(n);j.isZero()||j.normalize();h.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
 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]),
 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);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],
+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,h,f){j=a.vertices[d].position;n=a.vertices[b].position;l=a.vertices[c].position;o=i[e];k=i[h];r=i[f];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,f,h,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++)h=this.faces[b],i=this.faceVertexUvs[0][b],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 d=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];for(e=0;e<h.vertexNormals.length;e++)A.copy(h.vertexNormals[e]),f=h[d[e]],ta=U[f],R.copy(ta),R.subSelf(A.multiplyScalar(A.dot(ta))).normalize(),K.cross(h.vertexNormals[e],ta),f=K.dot(ma[f]),f=f<0?-1:1,h.vertexTangents[e]=new THREE.Vector4(R.x,R.y,R.z,f)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],
 y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<
 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;
-THREE.Spline=function(a){function b(a,b,c,e,f,h,i){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*i+(-3*(b-c)-2*a-e)*h+a*f+b}this.points=a;var c=[],e={x:0,y:0,z:0},h,f,i,j,n,l,o,k,r;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){h=(this.points.length-1)*a;f=Math.floor(h);i=h-f;c[0]=f===0?f:f-1;c[1]=f;c[2]=f>this.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;l=this.points[c[0]];o=this.points[c[1]];
-k=this.points[c[2]];r=this.points[c[3]];j=i*i;n=i*j;e.x=b(l.x,o.x,k.x,r.x,i,j,n);e.y=b(l.y,o.y,k.y,r.y,i,j,n);e.z=b(l.z,o.z,k.z,r.z,i,j,n);return e};this.getControlPointsArray=function(){var a,b,c=this.points.length,e=[];for(a=0;a<c;a++)b=this.points[a],e[a]=[b.x,b.y,b.z];return e};this.getLength=function(a){var b,c,e=b=b=0,f=new THREE.Vector3,h=new THREE.Vector3,i=[],j=0;i[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,position=this.getPoint(b),h.copy(position),
-j+=h.distanceTo(f),f.copy(position),b*=this.points.length-1,b=Math.floor(b),b!=e&&(i[b]=j,e=b);i[i.length]=j;return{chunks:i,total:j}};this.reparametrizeByArcLength=function(a){var b,c,e,f,h,i,j=[],o=new THREE.Vector3,n=this.getLength();j.push(o.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=n.chunks[b]-n.chunks[b-1];i=Math.ceil(a*c/n.total);f=(b-1)/(this.points.length-1);h=b/(this.points.length-1);for(c=1;c<i-1;c++)e=f+c*(1/i)*(h-f),position=this.getPoint(e),j.push(o.copy(position).clone());
+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,f=Math.pow(10,4),h,i;h=0;for(i=this.vertices.length;h<i;h++)e=this.vertices[h].position,e=[Math.round(e.x*f),Math.round(e.y*f),Math.round(e.z*f)].join("_"),
+a[e]===void 0?(a[e]=h,b.push(this.vertices[h]),c[h]=b.length-1):c[h]=c[a[e]];h=0;for(i=this.faces.length;h<i;h++)if(a=this.faces[h],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
+THREE.Spline=function(a){function b(a,b,c,e,h,f,i){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*i+(-3*(b-c)-2*a-e)*f+a*h+b}this.points=a;var c=[],e={x:0,y:0,z:0},f,h,i,j,n,l,o,k,r;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){f=(this.points.length-1)*a;h=Math.floor(f);i=f-h;c[0]=h===0?h:h-1;c[1]=h;c[2]=h>this.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;l=this.points[c[0]];o=this.points[c[1]];
+k=this.points[c[2]];r=this.points[c[3]];j=i*i;n=i*j;e.x=b(l.x,o.x,k.x,r.x,i,j,n);e.y=b(l.y,o.y,k.y,r.y,i,j,n);e.z=b(l.z,o.z,k.z,r.z,i,j,n);return e};this.getControlPointsArray=function(){var a,b,c=this.points.length,e=[];for(a=0;a<c;a++)b=this.points[a],e[a]=[b.x,b.y,b.z];return e};this.getLength=function(a){var b,c,e=b=b=0,h=new THREE.Vector3,f=new THREE.Vector3,i=[],j=0;i[0]=0;a||(a=100);c=this.points.length*a;h.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,position=this.getPoint(b),f.copy(position),
+j+=f.distanceTo(h),h.copy(position),b*=this.points.length-1,b=Math.floor(b),b!=e&&(i[b]=j,e=b);i[i.length]=j;return{chunks:i,total:j}};this.reparametrizeByArcLength=function(a){var b,c,e,h,f,i,j=[],o=new THREE.Vector3,n=this.getLength();j.push(o.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=n.chunks[b]-n.chunks[b-1];i=Math.ceil(a*c/n.total);h=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<i-1;c++)e=h+c*(1/i)*(f-h),position=this.getPoint(e),j.push(o.copy(position).clone());
 j.push(o.copy(this.points[b]).clone())}this.points=j}};THREE.Edge=function(a,b,c,e){this.vertices=[a,b];this.vertexIndices=[c,e];this.faces=[];this.faceIndices=[]};
 j.push(o.copy(this.points[b]).clone())}this.points=j}};THREE.Edge=function(a,b,c,e){this.vertices=[a,b];this.vertexIndices=[c,e];this.faces=[];this.faceIndices=[]};
 THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
 THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
-THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,e,h,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=e;this.near=h!==void 0?h:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;
+THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,e,f,h){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=e;this.near=f!==void 0?f:0.1;this.far=h!==void 0?h:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;
 THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,e){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=e!==void 0?e:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
 THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,e){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=e!==void 0?e:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
-THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,e,h,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=e;this.width=h;this.height=f;this.updateProjectionMatrix()};
+THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,e,f,h){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=e;this.width=f;this.height=h;this.updateProjectionMatrix()};
 THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,e=a*c,a=Math.abs(a*b-e),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(e+this.x*a/this.fullWidth,e+(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,
 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,e=a*c,a=Math.abs(a*b-e),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(e+this.x*a/this.fullWidth,e+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
 this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.PointLight.prototype=new THREE.Light;
 THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.PointLight.prototype=new THREE.Light;
@@ -116,24 +116,23 @@ THREE.MeshShaderMaterial=function(a){console.warn("DEPRECATED: MeshShaderMateria
 THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.size=a.size!==void 0?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==void 0?a.sizeAttenuation:!0;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.fog=a.fog!==void 0?a.fog:!0};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
 THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.size=a.size!==void 0?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==void 0?a.sizeAttenuation:!0;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.fog=a.fog!==void 0?a.fog:!0};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
 THREE.ShaderMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.fragmentShader=a.fragmentShader!==void 0?a.fragmentShader:"void main() {}";this.vertexShader=a.vertexShader!==void 0?a.vertexShader:"void main() {}";this.uniforms=a.uniforms!==void 0?a.uniforms:{};this.attributes=a.attributes;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.fog=a.fog!==
 THREE.ShaderMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.fragmentShader=a.fragmentShader!==void 0?a.fragmentShader:"void main() {}";this.vertexShader=a.vertexShader!==void 0?a.vertexShader:"void main() {}";this.uniforms=a.uniforms!==void 0?a.uniforms:{};this.attributes=a.attributes;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.fog=a.fog!==
 void 0?a.fog:!1;this.lights=a.lights!==void 0?a.lights:!1;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.skinning=a.skinning!==void 0?a.skinning:!1;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:!1};THREE.ShaderMaterial.prototype=new THREE.Material;THREE.ShaderMaterial.prototype.constructor=THREE.ShaderMaterial;
 void 0?a.fog:!1;this.lights=a.lights!==void 0?a.lights:!1;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.skinning=a.skinning!==void 0?a.skinning:!1;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:!1};THREE.ShaderMaterial.prototype=new THREE.Material;THREE.ShaderMaterial.prototype.constructor=THREE.ShaderMaterial;
-THREE.Texture=function(a,b,c,e,h,f){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=e!==void 0?e:THREE.ClampToEdgeWrapping;this.magFilter=h!==void 0?h:THREE.LinearFilter;this.minFilter=f!==void 0?f:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
+THREE.Texture=function(a,b,c,e,f,h){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=e!==void 0?e:THREE.ClampToEdgeWrapping;this.magFilter=f!==void 0?f:THREE.LinearFilter;this.minFilter=h!==void 0?h:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
 THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;
-THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(a,b,c,e,h,f,i,j,n){THREE.Texture.call(this,null,h,f,i,j,n);this.image={data:a,width:b,height:c};this.format=e!==void 0?e:THREE.RGBAFormat};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
+THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(a,b,c,e,f,h,i,j,n){THREE.Texture.call(this,null,f,h,i,j,n);this.image={data:a,width:b,height:c};this.format=e!==void 0?e:THREE.RGBAFormat};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
 THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.data.slice(0),this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;this.sortParticles=!1};
 THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.data.slice(0),this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;this.sortParticles=!1};
 THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=b;this.type=c!=void 0?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
 THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=b;this.type=c!=void 0?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;if(b instanceof Array)console.warn("DEPRECATE: Material array is no longer supported. Using material 0..."),this.material=b[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c<
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;if(b instanceof Array)console.warn("DEPRECATE: Material array is no longer supported. Using material 0..."),this.material=b[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c<
 this.geometry.morphTargets.length;c++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[c].name]=c}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
 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 e,h=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<h;e++)a=this.children[e],a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}else for(e=0;e<h;e++)this.children[e].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.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,e,h,f,i,j;if(this.geometry.bones!==void 0){for(c=0;c<this.geometry.bones.length;c++)h=this.geometry.bones[c],f=h.pos,i=h.rotq,j=h.scl,e=this.addBone(),e.name=h.name,e.position.set(f[0],f[1],f[2]),e.quaternion.set(i[0],i[1],i[2],i[3]),e.useQuaternion=!0,j!==void 0?e.scale.set(j[0],j[1],j[2]):e.scale.set(1,1,1);for(c=0;c<this.bones.length;c++)h=this.geometry.bones[c],
-e=this.bones[c],h.parent===-1?this.add(e):this.bones[h.parent].add(e);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
-THREE.SkinnedMesh.prototype.update=function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var e,h=this.children.length;for(e=0;e<h;e++)a=this.children[e],a instanceof THREE.Bone?a.update(this.identityMatrix,!1,c):a.update(this.matrixWorld,b,c);c=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(b=0;b<c;b++)ba[b].skinMatrix.flattenToArrayOffset(bm,
-b*16)}};THREE.SkinnedMesh.prototype.addBone=function(a){a===void 0&&(a=new THREE.Bone(this));this.bones.push(a);return a};
-THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var a,b=[],c=0;c<this.bones.length;c++)a=this.bones[c],b.push(THREE.Matrix4.makeInvert(a.skinMatrix)),a.skinMatrix.flattenToArrayOffset(this.boneMatrices,c*16);if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(a=0;a<this.geometry.skinIndices.length;a++){var c=this.geometry.vertices[a].position,h=this.geometry.skinIndices[a].x,f=this.geometry.skinIndices[a].y;e=new THREE.Vector3(c.x,
-c.y,c.z);this.geometry.skinVerticesA.push(b[h].multiplyVector3(e));e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[f].multiplyVector3(e));this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1&&(c=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5,this.geometry.skinWeights[a].x+=c,this.geometry.skinWeights[a].y+=c)}}};THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b};THREE.Ribbon.prototype=new THREE.Object3D;
-THREE.Ribbon.prototype.constructor=THREE.Ribbon;THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.addLevel=function(a,b){b===void 0&&(b=0);for(var b=Math.abs(b),c=0;c<this.LODs.length;c++)if(b<this.LODs[c].visibleAtDistance)break;this.LODs.splice(c,0,{visibleAtDistance:b,object3D:a});this.add(a)};
+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};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
+THREE.Bone.prototype.update=function(a,b){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var c,e=this.children.length;for(c=0;c<e;c++)this.children[c].update(this.skinMatrix,b)};
+THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,e,f,h,i,j;if(this.geometry.bones!==void 0){for(c=0;c<this.geometry.bones.length;c++)f=this.geometry.bones[c],h=f.pos,i=f.rotq,j=f.scl,e=this.addBone(),e.name=f.name,e.position.set(h[0],h[1],h[2]),e.quaternion.set(i[0],i[1],i[2],i[3]),e.useQuaternion=!0,j!==void 0?e.scale.set(j[0],j[1],j[2]):e.scale.set(1,1,1);for(c=0;c<this.bones.length;c++)f=this.geometry.bones[c],
+e=this.bones[c],f.parent===-1?this.add(e):this.bones[f.parent].add(e);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;THREE.SkinnedMesh.prototype.addBone=function(a){a===void 0&&(a=new THREE.Bone(this));this.bones.push(a);return a};
+THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1;for(var a=0,b=this.children.length;a<b;a++){var c=this.children[a];c instanceof THREE.Bone?c.update(this.identityMatrix,!1):c.updateMatrixWorld(!0)}b=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(a=0;a<b;a++)ba[a].skinMatrix.flattenToArrayOffset(bm,
+a*16)};
+THREE.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];var e=new THREE.Matrix4;e.getInverse(a.skinMatrix);b.push(e);a.skinMatrix.flattenToArrayOffset(this.boneMatrices,c*16)}if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];for(a=0;a<this.geometry.skinIndices.length;a++){var c=this.geometry.vertices[a].position,f=this.geometry.skinIndices[a].x,h=this.geometry.skinIndices[a].y,e=
+new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[f].multiplyVector3(e));e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[h].multiplyVector3(e));this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1&&(c=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5,this.geometry.skinWeights[a].x+=c,this.geometry.skinWeights[a].y+=c)}}};THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b};
+THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.addLevel=function(a,b){b===void 0&&(b=0);for(var b=Math.abs(b),c=0;c<this.LODs.length;c++)if(b<this.LODs[c].visibleAtDistance)break;this.LODs.splice(c,0,{visibleAtDistance:b,object3D:a});this.add(a)};
 THREE.LOD.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;if(this.LODs.length>1){a=c.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var e=1;e<this.LODs.length;e++)if(a>=this.LODs[e].visibleAtDistance)this.LODs[e-1].object3D.visible=!1,
 THREE.LOD.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;if(this.LODs.length>1){a=c.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var e=1;e<this.LODs.length;e++)if(a>=this.LODs[e].visibleAtDistance)this.LODs[e-1].object3D.visible=!1,
 this.LODs[e].object3D.visible=!0;else break;for(;e<this.LODs.length;e++)this.LODs[e].object3D.visible=!1}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};
 this.LODs[e].object3D.visible=!0;else break;for(;e<this.LODs.length;e++)this.LODs[e].object3D.visible=!1}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};
 THREE.Sprite=function(a){THREE.Object3D.call(this);this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map instanceof THREE.Texture?a.map:THREE.ImageUtils.loadTexture(a.map);this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.useScreenCoordinates=a.useScreenCoordinates!==void 0?a.useScreenCoordinates:!0;this.mergeWith3D=a.mergeWith3D!==void 0?a.mergeWith3D:!this.useScreenCoordinates;this.affectedByDistance=a.affectedByDistance!==void 0?a.affectedByDistance:
 THREE.Sprite=function(a){THREE.Object3D.call(this);this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map instanceof THREE.Texture?a.map:THREE.ImageUtils.loadTexture(a.map);this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.useScreenCoordinates=a.useScreenCoordinates!==void 0?a.useScreenCoordinates:!0;this.mergeWith3D=a.mergeWith3D!==void 0?a.mergeWith3D:!this.useScreenCoordinates;this.affectedByDistance=a.affectedByDistance!==void 0?a.affectedByDistance:
@@ -157,7 +156,7 @@ morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInflu
 default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform float shadowDarkness;\nuniform float shadowBias;\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",
 default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform float shadowDarkness;\nuniform float shadowBias;\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",
 shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_SOFT\nconst float xPixelOffset = 1.0 / SHADOWMAP_WIDTH;\nconst float yPixelOffset = 1.0 / SHADOWMAP_HEIGHT;\n#endif\nvec3 shadowColor = vec3( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nshadowCoord.z += shadowBias;\nif ( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( shadowDarkness );\n#endif\n}\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif",
 shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_SOFT\nconst float xPixelOffset = 1.0 / SHADOWMAP_WIDTH;\nconst float yPixelOffset = 1.0 / SHADOWMAP_HEIGHT;\n#endif\nvec3 shadowColor = vec3( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nshadowCoord.z += shadowBias;\nif ( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( shadowDarkness );\n#endif\n}\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif",
 shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"};
 shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"};
-THREE.UniformsUtils={merge:function(a){var b,c,e,h={};for(b=0;b<a.length;b++)for(c in e=this.clone(a[b]),e)h[c]=e[c];return h},clone:function(a){var b,c,e,h={};for(b in a)for(c in h[b]={},a[b])e=a[b][c],h[b][c]=e instanceof THREE.Color||e instanceof THREE.Vector2||e instanceof THREE.Vector3||e instanceof THREE.Vector4||e instanceof THREE.Matrix4||e instanceof THREE.Texture?e.clone():e instanceof Array?e.slice():e;return h}};
+THREE.UniformsUtils={merge:function(a){var b,c,e,f={};for(b=0;b<a.length;b++)for(c in e=this.clone(a[b]),e)f[c]=e[c];return f},clone:function(a){var b,c,e,f={};for(b in a)for(c in f[b]={},a[b])e=a[b][c],f[b][c]=e instanceof THREE.Color||e instanceof THREE.Vector2||e instanceof THREE.Vector3||e instanceof THREE.Vector4||e instanceof THREE.Matrix4||e instanceof THREE.Texture?e.clone():e instanceof Array?e.slice():e;return f}};
 THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},flipEnvMap:{type:"f",value:-1},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},morphTargetInfluences:{type:"f",value:0}},fog:{fogDensity:{type:"f",
 THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},flipEnvMap:{type:"f",value:-1},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},morphTargetInfluences:{type:"f",value:0}},fog:{fogDensity:{type:"f",
 value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",
 value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",
 value:1},scale:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},shadowmap:{shadowMap:{type:"tv",value:6,texture:[]},shadowMatrix:{type:"m4v",value:[]},shadowBias:{type:"f",value:0.0039},shadowDarkness:{type:"f",value:0.2}}};
 value:1},scale:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},shadowmap:{shadowMap:{type:"tv",value:6,texture:[]},shadowMatrix:{type:"m4v",value:[]},shadowBias:{type:"f",value:0.0039},shadowDarkness:{type:"f",value:0.2}}};
@@ -177,11 +176,11 @@ 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.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.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.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask  = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}};
-THREE.WebGLRenderer=function(a){function b(a,b){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=
+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,h,f,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){f=0;for(e=n.length;f<e;f++)n[f].offset=0}if(c.sortParticles){Ca.multiplySelf(c.matrixWorld);for(e=
+0;e<u;e++)h=i[e].position,Ha.copy(h),Ca.multiplyVector3(Ha),za[e]=[Ha.z,e];za.sort(function(a,b){return b[0]-a[0]});for(e=0;e<u;e++)h=i[za[e][1]].position,f=e*3,j[f]=h.x,j[f+1]=h.y,j[f+2]=h.z;for(e=0;e<q;e++)f=e*3,color=p[za[e][1]],xa[f]=color.r,xa[f+1]=color.g,xa[f+2]=color.b;if(n){f=0;for(e=n.length;f<e;f++){u=n[f];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++)h=i[e].position,f=e*3,j[f]=h.x,j[f+1]=h.y,j[f+2]=h.z;if(o)for(e=0;e<q;e++)color=p[e],f=e*3,xa[f]=color.r,xa[f+1]=color.g,xa[f+2]=color.b;if(n){f=0;for(e=n.length;f<e;f++)if(u=n[f],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),
 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<
+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){f=0;for(e=n.length;f<e;f++)if(u=n[f],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<
 i;f++)h.__webglMorphTargetInfluences[f]=0}var u=!1,f=e.program,i=f.uniforms,p=e.uniforms;f!==S&&(d.useProgram(f),S=f,u=!0);if(e.id!==Q)Q=e.id,u=!0;if(u){d.uniformMatrix4fv(i.projectionMatrix,!1,Ta);if(c&&e.fog)if(p.fogColor.value=c.color,c instanceof THREE.Fog)p.fogNear.value=c.near,p.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)p.fogDensity.value=c.density;if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e.lights){for(var q,j,k=0,n=0,P=0,o,l,r,v=Za,y=v.directional.colors,
 i;f++)h.__webglMorphTargetInfluences[f]=0}var u=!1,f=e.program,i=f.uniforms,p=e.uniforms;f!==S&&(d.useProgram(f),S=f,u=!0);if(e.id!==Q)Q=e.id,u=!0;if(u){d.uniformMatrix4fv(i.projectionMatrix,!1,Ta);if(c&&e.fog)if(p.fogColor.value=c.color,c instanceof THREE.Fog)p.fogNear.value=c.near,p.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)p.fogDensity.value=c.density;if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e.lights){for(var q,j,k=0,n=0,P=0,o,l,r,v=Za,y=v.directional.colors,
 t=v.directional.positions,z=v.point.colors,B=v.point.positions,C=v.point.distances,O=0,G=0,c=q=r=0,u=b.length;c<u;c++)if(q=b[c],j=q.color,o=q.position,l=q.intensity,r=q.distance,q instanceof THREE.AmbientLight)A.gammaInput?(k+=j.r*j.r,n+=j.g*j.g,P+=j.b*j.b):(k+=j.r,n+=j.g,P+=j.b);else if(q instanceof THREE.DirectionalLight)r=O*3,A.gammaInput?(y[r]=j.r*j.r*l*l,y[r+1]=j.g*j.g*l*l,y[r+2]=j.b*j.b*l*l):(y[r]=j.r*l,y[r+1]=j.g*l,y[r+2]=j.b*l),t[r]=o.x,t[r+1]=o.y,t[r+2]=o.z,O+=1;else if(q instanceof THREE.SpotLight)r=
 t=v.directional.positions,z=v.point.colors,B=v.point.positions,C=v.point.distances,O=0,G=0,c=q=r=0,u=b.length;c<u;c++)if(q=b[c],j=q.color,o=q.position,l=q.intensity,r=q.distance,q instanceof THREE.AmbientLight)A.gammaInput?(k+=j.r*j.r,n+=j.g*j.g,P+=j.b*j.b):(k+=j.r,n+=j.g,P+=j.b);else if(q instanceof THREE.DirectionalLight)r=O*3,A.gammaInput?(y[r]=j.r*j.r*l*l,y[r+1]=j.g*j.g*l*l,y[r+2]=j.b*j.b*l*l):(y[r]=j.r*l,y[r+1]=j.g*l,y[r+2]=j.b*l),t[r]=o.x,t[r+1]=o.y,t[r+2]=o.z,O+=1;else if(q instanceof THREE.SpotLight)r=
 O*3,A.gammaInput?(y[r]=j.r*j.r*l*l,y[r+1]=j.g*j.g*l*l,y[r+2]=j.b*j.b*l*l):(y[r]=j.r*l,y[r+1]=j.g*l,y[r+2]=j.b*l),j=1/o.length(),t[r]=o.x*j,t[r+1]=o.y*j,t[r+2]=o.z*j,O+=1;else if(q instanceof THREE.PointLight)q=G*3,A.gammaInput?(z[q]=j.r*j.r*l*l,z[q+1]=j.g*j.g*l*l,z[q+2]=j.b*j.b*l*l):(z[q]=j.r*l,z[q+1]=j.g*l,z[q+2]=j.b*l),B[q]=o.x,B[q+1]=o.y,B[q+2]=o.z,C[G]=r,G+=1;c=O*3;for(u=y.length;c<u;c++)y[c]=0;c=G*3;for(u=z.length;c<u;c++)z[c]=0;v.point.length=G;v.directional.length=O;v.ambient[0]=k;v.ambient[1]=
 O*3,A.gammaInput?(y[r]=j.r*j.r*l*l,y[r+1]=j.g*j.g*l*l,y[r+2]=j.b*j.b*l*l):(y[r]=j.r*l,y[r+1]=j.g*l,y[r+2]=j.b*l),j=1/o.length(),t[r]=o.x*j,t[r+1]=o.y*j,t[r+2]=o.z*j,O+=1;else if(q instanceof THREE.PointLight)q=G*3,A.gammaInput?(z[q]=j.r*j.r*l*l,z[q+1]=j.g*j.g*l*l,z[q+2]=j.b*j.b*l*l):(z[q]=j.r*l,z[q+1]=j.g*l,z[q+2]=j.b*l),B[q]=o.x,B[q+1]=o.y,B[q+2]=o.z,C[G]=r,G+=1;c=O*3;for(u=y.length;c<u;c++)y[c]=0;c=G*3;for(u=z.length;c<u;c++)z[c]=0;v.point.length=G;v.directional.length=O;v.ambient[0]=k;v.ambient[1]=
@@ -193,7 +192,7 @@ b.length;p<c;p++)if(n=f.uniforms[b[p][1]])if(k=b[p][0],P=k.type,u=k.value,P==="i
 1]=u[P].y,k._array[v+2]=u[P].z;d.uniform3fv(n,k._array)}else if(P==="m4"){if(!k._array)k._array=new Float32Array(16);u.flattenToArray(k._array);d.uniformMatrix4fv(n,!1,k._array)}else if(P==="m4v"){if(!k._array)k._array=new Float32Array(16*u.length);P=0;for(o=u.length;P<o;P++)u[P].flattenToArrayOffset(k._array,P*16);d.uniformMatrix4fv(n,!1,k._array)}else if(P==="t"){if(d.uniform1i(n,u),n=k.texture)if(n.image instanceof Array&&n.image.length===6){if(k=n,k.image.length===6)if(k.needsUpdate){if(!k.image.__webglTextureCube)k.image.__webglTextureCube=
 1]=u[P].y,k._array[v+2]=u[P].z;d.uniform3fv(n,k._array)}else if(P==="m4"){if(!k._array)k._array=new Float32Array(16);u.flattenToArray(k._array);d.uniformMatrix4fv(n,!1,k._array)}else if(P==="m4v"){if(!k._array)k._array=new Float32Array(16*u.length);P=0;for(o=u.length;P<o;P++)u[P].flattenToArrayOffset(k._array,P*16);d.uniformMatrix4fv(n,!1,k._array)}else if(P==="t"){if(d.uniform1i(n,u),n=k.texture)if(n.image instanceof Array&&n.image.length===6){if(k=n,k.image.length===6)if(k.needsUpdate){if(!k.image.__webglTextureCube)k.image.__webglTextureCube=
 d.createTexture();d.activeTexture(d.TEXTURE0+u);d.bindTexture(d.TEXTURE_CUBE_MAP,k.image.__webglTextureCube);for(u=0;u<6;u++)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,k.image[u]);T(d.TEXTURE_CUBE_MAP,k,k.image[0]);k.needsUpdate=!1}else d.activeTexture(d.TEXTURE0+u),d.bindTexture(d.TEXTURE_CUBE_MAP,k.image.__webglTextureCube)}else n instanceof THREE.WebGLRenderTargetCube?(k=n,d.activeTexture(d.TEXTURE0+u),d.bindTexture(d.TEXTURE_CUBE_MAP,k.__webglTexture)):ta(n,u)}else if(P===
 d.createTexture();d.activeTexture(d.TEXTURE0+u);d.bindTexture(d.TEXTURE_CUBE_MAP,k.image.__webglTextureCube);for(u=0;u<6;u++)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,k.image[u]);T(d.TEXTURE_CUBE_MAP,k,k.image[0]);k.needsUpdate=!1}else d.activeTexture(d.TEXTURE0+u),d.bindTexture(d.TEXTURE_CUBE_MAP,k.image.__webglTextureCube)}else n instanceof THREE.WebGLRenderTargetCube?(k=n,d.activeTexture(d.TEXTURE0+u),d.bindTexture(d.TEXTURE_CUBE_MAP,k.__webglTexture)):ta(n,u)}else if(P===
 "tv"){if(!k._array){k._array=[];P=0;for(o=k.texture.length;P<o;P++)k._array[P]=u+P}d.uniform1iv(n,k._array);P=0;for(o=k.texture.length;P<o;P++)(n=k.texture[P])&&ta(n,k._array[P])}(e instanceof THREE.ShaderMaterial||e instanceof THREE.MeshPhongMaterial||e.envMap)&&i.cameraPosition!==null&&d.uniform3f(i.cameraPosition,a.position.x,a.position.y,a.position.z);(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.ShaderMaterial||e.skinning)&&i.viewMatrix!==null&&
 "tv"){if(!k._array){k._array=[];P=0;for(o=k.texture.length;P<o;P++)k._array[P]=u+P}d.uniform1iv(n,k._array);P=0;for(o=k.texture.length;P<o;P++)(n=k.texture[P])&&ta(n,k._array[P])}(e instanceof THREE.ShaderMaterial||e instanceof THREE.MeshPhongMaterial||e.envMap)&&i.cameraPosition!==null&&d.uniform3f(i.cameraPosition,a.position.x,a.position.y,a.position.z);(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.ShaderMaterial||e.skinning)&&i.viewMatrix!==null&&
-d.uniformMatrix4fv(i.viewMatrix,!1,Ua);e.skinning&&(d.uniformMatrix4fv(i.cameraInverseMatrix,!1,Ua),d.uniformMatrix4fv(i.boneGlobalMatrices,!1,h.boneMatrices))}d.uniformMatrix4fv(i.modelViewMatrix,!1,h._modelViewMatrixArray);i.normalMatrix&&d.uniformMatrix3fv(i.normalMatrix,!1,h._normalMatrixArray);(e instanceof THREE.ShaderMaterial||e.envMap||e.skinning||h.receiveShadow)&&i.objectMatrix!==null&&d.uniformMatrix4fv(i.objectMatrix,!1,h._objectMatrixArray);return f}function h(a,b,c,h,f,i){if(h.opacity!==
+d.uniformMatrix4fv(i.viewMatrix,!1,Ua);e.skinning&&(d.uniformMatrix4fv(i.cameraInverseMatrix,!1,Ua),d.uniformMatrix4fv(i.boneGlobalMatrices,!1,h.boneMatrices))}d.uniformMatrix4fv(i.modelViewMatrix,!1,h._modelViewMatrixArray);i.normalMatrix&&d.uniformMatrix3fv(i.normalMatrix,!1,h._normalMatrixArray);(e instanceof THREE.ShaderMaterial||e.envMap||e.skinning||h.receiveShadow)&&i.objectMatrix!==null&&d.uniformMatrix4fv(i.objectMatrix,!1,h._objectMatrixArray);return f}function f(a,b,c,h,f,i){if(h.opacity!==
 0){var j,u,c=e(a,b,c,h,i),a=c.attributes,b=!1,c=f.id*16777215+c.id*2+(h.wireframe?1:0);c!==N&&(N=c,b=!0);if(!h.morphTargets&&a.position>=0)b&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglVertexBuffer),d.vertexAttribPointer(a.position,3,d.FLOAT,!1,0,0));else if(i.morphTargetBase){c=h.program.attributes;i.morphTargetBase!==-1?(d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[i.morphTargetBase]),d.vertexAttribPointer(c.position,3,d.FLOAT,!1,0,0)):c.position>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglVertexBuffer),
 0){var j,u,c=e(a,b,c,h,i),a=c.attributes,b=!1,c=f.id*16777215+c.id*2+(h.wireframe?1:0);c!==N&&(N=c,b=!0);if(!h.morphTargets&&a.position>=0)b&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglVertexBuffer),d.vertexAttribPointer(a.position,3,d.FLOAT,!1,0,0));else if(i.morphTargetBase){c=h.program.attributes;i.morphTargetBase!==-1?(d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[i.morphTargetBase]),d.vertexAttribPointer(c.position,3,d.FLOAT,!1,0,0)):c.position>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglVertexBuffer),
 d.vertexAttribPointer(c.position,3,d.FLOAT,!1,0,0));if(i.morphTargetForcedOrder.length){j=0;var p=i.morphTargetForcedOrder;for(u=i.morphTargetInfluences;j<h.numSupportedMorphTargets&&j<p.length;)d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[p[j]]),d.vertexAttribPointer(c["morphTarget"+j],3,d.FLOAT,!1,0,0),i.__webglMorphTargetInfluences[j]=u[p[j]],j++}else{var p=[],q=-1,k=0;u=i.morphTargetInfluences;var n,o=u.length;j=0;for(i.morphTargetBase!==-1&&(p[i.morphTargetBase]=!0);j<h.numSupportedMorphTargets;){for(n=
 d.vertexAttribPointer(c.position,3,d.FLOAT,!1,0,0));if(i.morphTargetForcedOrder.length){j=0;var p=i.morphTargetForcedOrder;for(u=i.morphTargetInfluences;j<h.numSupportedMorphTargets&&j<p.length;)d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[p[j]]),d.vertexAttribPointer(c["morphTarget"+j],3,d.FLOAT,!1,0,0),i.__webglMorphTargetInfluences[j]=u[p[j]],j++}else{var p=[],q=-1,k=0;u=i.morphTargetInfluences;var n,o=u.length;j=0;for(i.morphTargetBase!==-1&&(p[i.morphTargetBase]=!0);j<h.numSupportedMorphTargets;){for(n=
 0;n<o;n++)!p[n]&&u[n]>q&&(k=n,q=u[k]);d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[k]);d.vertexAttribPointer(c["morphTarget"+j],3,d.FLOAT,!1,0,0);i.__webglMorphTargetInfluences[j]=q;p[k]=1;q=-1;j++}}h.program.uniforms.morphTargetInfluences!==null&&d.uniform1fv(h.program.uniforms.morphTargetInfluences,i.__webglMorphTargetInfluences)}if(b){if(f.__webglCustomAttributesList){j=0;for(u=f.__webglCustomAttributesList.length;j<u;j++)c=f.__webglCustomAttributesList[j],a[c.buffer.belongsToAttribute]>=
 0;n<o;n++)!p[n]&&u[n]>q&&(k=n,q=u[k]);d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[k]);d.vertexAttribPointer(c["morphTarget"+j],3,d.FLOAT,!1,0,0);i.__webglMorphTargetInfluences[j]=q;p[k]=1;q=-1;j++}}h.program.uniforms.morphTargetInfluences!==null&&d.uniform1fv(h.program.uniforms.morphTargetInfluences,i.__webglMorphTargetInfluences)}if(b){if(f.__webglCustomAttributesList){j=0;for(u=f.__webglCustomAttributesList.length;j<u;j++)c=f.__webglCustomAttributesList[j],a[c.buffer.belongsToAttribute]>=
@@ -201,7 +200,7 @@ d.vertexAttribPointer(c.position,3,d.FLOAT,!1,0,0));if(i.morphTargetForcedOrder.
 f.__webglUVBuffer),d.vertexAttribPointer(a.uv,2,d.FLOAT,!1,0,0),d.enableVertexAttribArray(a.uv)):d.disableVertexAttribArray(a.uv));a.uv2>=0&&(f.__webglUV2Buffer?(d.bindBuffer(d.ARRAY_BUFFER,f.__webglUV2Buffer),d.vertexAttribPointer(a.uv2,2,d.FLOAT,!1,0,0),d.enableVertexAttribArray(a.uv2)):d.disableVertexAttribArray(a.uv2));h.skinning&&a.skinVertexA>=0&&a.skinVertexB>=0&&a.skinIndex>=0&&a.skinWeight>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinVertexABuffer),d.vertexAttribPointer(a.skinVertexA,4,
 f.__webglUVBuffer),d.vertexAttribPointer(a.uv,2,d.FLOAT,!1,0,0),d.enableVertexAttribArray(a.uv)):d.disableVertexAttribArray(a.uv));a.uv2>=0&&(f.__webglUV2Buffer?(d.bindBuffer(d.ARRAY_BUFFER,f.__webglUV2Buffer),d.vertexAttribPointer(a.uv2,2,d.FLOAT,!1,0,0),d.enableVertexAttribArray(a.uv2)):d.disableVertexAttribArray(a.uv2));h.skinning&&a.skinVertexA>=0&&a.skinVertexB>=0&&a.skinIndex>=0&&a.skinWeight>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinVertexABuffer),d.vertexAttribPointer(a.skinVertexA,4,
 d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),d.vertexAttribPointer(a.skinVertexB,4,d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),d.vertexAttribPointer(a.skinIndex,4,d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),d.vertexAttribPointer(a.skinWeight,4,d.FLOAT,!1,0,0))}i instanceof THREE.Mesh?(h.wireframe?(d.lineWidth(h.wireframeLinewidth),b&&d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),d.drawElements(d.LINES,f.__webglLineCount,
 d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),d.vertexAttribPointer(a.skinVertexB,4,d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),d.vertexAttribPointer(a.skinIndex,4,d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),d.vertexAttribPointer(a.skinWeight,4,d.FLOAT,!1,0,0))}i instanceof THREE.Mesh?(h.wireframe?(d.lineWidth(h.wireframeLinewidth),b&&d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),d.drawElements(d.LINES,f.__webglLineCount,
 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++):
 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,
+i instanceof THREE.Ribbon&&(d.drawArrays(d.TRIANGLE_STRIP,0,f.__webglVertexCount),A.info.render.calls++)}}function h(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,
 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(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-
 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,
 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,
@@ -209,7 +208,7 @@ 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
 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}));
 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,
 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?
 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);
+p.customDepthMaterial:p.geometry.morphTargets.length?bb:Va,f(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){h(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<
 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)/
 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,
 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,
@@ -251,9 +250,9 @@ l.tangent>=0&&d.enableVertexAttribArray(l.tangent);a.skinning&&l.skinVertexA>=0&
 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.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),
 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=
 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=
+a.__webglObjects[t],p.render)q=p.object,Pa=p.buffer,i(q),f(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){h(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),f(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){h(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),f(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){h(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===
 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){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=
 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=

+ 119 - 1
examples/webgl_animation_skinning.html

@@ -39,8 +39,126 @@
 		click to start animation
 		click to start animation
 		</div>
 		</div>
 
 
-
+<!--
 		<script src="../build/Three.js"></script>
 		<script src="../build/Three.js"></script>
+-->
+		<script type="text/javascript" src="../src/Three.js"></script>
+		<script type="text/javascript" src="../src/core/Clock.js"></script>
+		<script type="text/javascript" src="../src/core/Color.js"></script>
+		<script type="text/javascript" src="../src/core/Vector2.js"></script>
+		<script type="text/javascript" src="../src/core/Vector3.js"></script>
+		<script type="text/javascript" src="../src/core/Vector4.js"></script>
+		<script type="text/javascript" src="../src/core/Ray.js"></script>
+		<script type="text/javascript" src="../src/core/Rectangle.js"></script>
+		<script type="text/javascript" src="../src/core/Math.js"></script>
+		<script type="text/javascript" src="../src/core/Matrix3.js"></script>
+		<script type="text/javascript" src="../src/core/Matrix4.js"></script>
+		<script type="text/javascript" src="../src/core/Object3D.js"></script>
+		<script type="text/javascript" src="../src/core/Projector.js"></script>
+		<script type="text/javascript" src="../src/core/Quaternion.js"></script>
+		<script type="text/javascript" src="../src/core/Vertex.js"></script>
+		<script type="text/javascript" src="../src/core/Face3.js"></script>
+		<script type="text/javascript" src="../src/core/Face4.js"></script>
+		<script type="text/javascript" src="../src/core/UV.js"></script>
+		<script type="text/javascript" src="../src/core/Geometry.js"></script>
+		<script type="text/javascript" src="../src/core/Spline.js"></script>
+		<script type="text/javascript" src="../src/core/Edge.js"></script>
+		<script type="text/javascript" src="../src/cameras/Camera.js"></script>
+		<script type="text/javascript" src="../src/cameras/OrthographicCamera.js"></script>
+		<script type="text/javascript" src="../src/cameras/PerspectiveCamera.js"></script>
+		<script type="text/javascript" src="../src/lights/Light.js"></script>
+		<script type="text/javascript" src="../src/lights/AmbientLight.js"></script>
+		<script type="text/javascript" src="../src/lights/DirectionalLight.js"></script>
+		<script type="text/javascript" src="../src/lights/PointLight.js"></script>
+		<script type="text/javascript" src="../src/lights/SpotLight.js"></script>
+		<script type="text/javascript" src="../src/materials/Material.js"></script>
+		<script type="text/javascript" src="../src/materials/LineBasicMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshBasicMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshLambertMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshDepthMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshNormalMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshShaderMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ParticleBasicMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ParticleCanvasMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ParticleDOMMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ShaderMaterial.js"></script>
+		<script type="text/javascript" src="../src/textures/Texture.js"></script>
+		<script type="text/javascript" src="../src/textures/DataTexture.js"></script>
+		<script type="text/javascript" src="../src/objects/Particle.js"></script>
+		<script type="text/javascript" src="../src/objects/ParticleSystem.js"></script>
+		<script type="text/javascript" src="../src/objects/Line.js"></script>
+		<script type="text/javascript" src="../src/objects/Mesh.js"></script>
+		<script type="text/javascript" src="../src/objects/Bone.js"></script>
+		<script type="text/javascript" src="../src/objects/SkinnedMesh.js"></script>
+		<script type="text/javascript" src="../src/objects/MorphAnimMesh.js"></script>
+		<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
+		<script type="text/javascript" src="../src/objects/LOD.js"></script>
+		<script type="text/javascript" src="../src/objects/Sprite.js"></script>
+		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
+		<script type="text/javascript" src="../src/scenes/Fog.js"></script>
+		<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
+		<script type="text/javascript" src="../src/renderers/DOMRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLShaders.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLRenderTarget.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLRenderTargetCube.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableVertex.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace3.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace4.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
+		<script type="text/javascript" src="../src/extras/ColorUtils.js"></script>
+		<script type="text/javascript" src="../src/extras/GeometryUtils.js"></script>
+		<script type="text/javascript" src="../src/extras/ImageUtils.js"></script>
+		<script type="text/javascript" src="../src/extras/SceneUtils.js"></script>
+		<script type="text/javascript" src="../src/extras/ShaderUtils.js"></script>
+		<script type="text/javascript" src="../src/extras/core/Curve.js"></script>
+		<script type="text/javascript" src="../src/extras/core/CurvePath.js"></script>
+		<script type="text/javascript" src="../src/extras/core/Path.js"></script>
+		<script type="text/javascript" src="../src/extras/core/Shape.js"></script>
+		<script type="text/javascript" src="../src/extras/core/TextPath.js"></script>
+		<script type="text/javascript" src="../src/extras/animation/AnimationHandler.js"></script>
+		<script type="text/javascript" src="../src/extras/animation/Animation.js"></script>
+		<script type="text/javascript" src="../src/extras/cameras/CubeCamera.js"></script>
+		<script type="text/javascript" src="../src/extras/cameras/FirstPersonCamera.js"></script>
+		<script type="text/javascript" src="../src/extras/cameras/PathCamera.js"></script>
+		<script type="text/javascript" src="../src/extras/cameras/FlyCamera.js"></script>
+		<script type="text/javascript" src="../src/extras/cameras/RollCamera.js"></script>
+		<script type="text/javascript" src="../src/extras/cameras/TrackballCamera.js"></script>
+		<script type="text/javascript" src="../src/extras/cameras/CombinedCamera.js"></script>
+		<script type="text/javascript" src="../src/extras/controls/FirstPersonControls.js"></script>
+		<script type="text/javascript" src="../src/extras/controls/PathControls.js"></script>
+		<script type="text/javascript" src="../src/extras/controls/FlyControls.js"></script>
+		<script type="text/javascript" src="../src/extras/controls/RollControls.js"></script>
+		<script type="text/javascript" src="../src/extras/controls/TrackballControls.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/CubeGeometry.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/CylinderGeometry.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/ExtrudeGeometry.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/IcosahedronGeometry.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/LatheGeometry.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/OctahedronGeometry.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/PlaneGeometry.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/SphereGeometry.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/TextGeometry.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/TorusGeometry.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/TorusKnotGeometry.js"></script>
+		<script type="text/javascript" src="../src/extras/modifiers/SubdivisionModifier.js"></script>
+		<script type="text/javascript" src="../src/extras/loaders/Loader.js"></script>
+		<script type="text/javascript" src="../src/extras/loaders/BinaryLoader.js"></script>
+		<script type="text/javascript" src="../src/extras/loaders/ColladaLoader.js"></script>
+		<script type="text/javascript" src="../src/extras/loaders/JSONLoader.js"></script>
+		<script type="text/javascript" src="../src/extras/loaders/SceneLoader.js"></script>
+		<script type="text/javascript" src="../src/extras/loaders/UTF8Loader.js"></script>
+		<script type="text/javascript" src="../src/extras/objects/Axes.js"></script>
+		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
+		<script type="text/javascript" src="../src/extras/physics/Collisions.js"></script>
+		<script type="text/javascript" src="../src/extras/physics/CollisionUtils.js"></script>
+		<script type="text/javascript" src="../src/extras/renderers/AnaglyphWebGLRenderer.js"></script>
+		<script type="text/javascript" src="../src/extras/renderers/CrosseyedWebGLRenderer.js"></script>
 
 
 		<script src="js/RequestAnimationFrame.js"></script>
 		<script src="js/RequestAnimationFrame.js"></script>
 		<script src="js/Detector.js"></script>
 		<script src="js/Detector.js"></script>

+ 1 - 1
src/extras/animation/Animation.js

@@ -361,7 +361,7 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) {
 
 
 		if ( JIThierarchy[ 0 ][ frame ] === undefined ) {
 		if ( JIThierarchy[ 0 ][ frame ] === undefined ) {
 
 
-			this.hierarchy[ 0 ].update( undefined, true );
+			this.hierarchy[ 0 ].update( null, true );
 
 
 			for ( var h = 0; h < this.hierarchy.length; h++ ) {
 			for ( var h = 0; h < this.hierarchy.length; h++ ) {
 
 

+ 4 - 64
src/objects/Bone.js

@@ -1,5 +1,6 @@
 /**
 /**
  * @author mikael emtinger / http://gomo.se/
  * @author mikael emtinger / http://gomo.se/
+ * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
 THREE.Bone = function( belongsToSkin ) {
 THREE.Bone = function( belongsToSkin ) {
@@ -8,7 +9,6 @@ THREE.Bone = function( belongsToSkin ) {
 
 
 	this.skin = belongsToSkin;
 	this.skin = belongsToSkin;
 	this.skinMatrix = new THREE.Matrix4();
 	this.skinMatrix = new THREE.Matrix4();
-	this.hasNoneBoneChildren = false;
 
 
 };
 };
 
 
@@ -17,11 +17,7 @@ THREE.Bone.prototype.constructor = THREE.Bone;
 THREE.Bone.prototype.supr = THREE.Object3D.prototype;
 THREE.Bone.prototype.supr = THREE.Object3D.prototype;
 
 
 
 
-/*
- * Update
- */
-
-THREE.Bone.prototype.update = function( parentSkinMatrix, forceUpdate, camera ) {
+THREE.Bone.prototype.update = function( parentSkinMatrix, forceUpdate ) {
 
 
 	// update local
 	// update local
 
 
@@ -54,67 +50,11 @@ THREE.Bone.prototype.update = function( parentSkinMatrix, forceUpdate, camera )
 
 
 	var child, i, l = this.children.length;
 	var child, i, l = this.children.length;
 
 
-	if ( this.hasNoneBoneChildren ) {
-
-		this.matrixWorld.multiply( this.skin.matrixWorld, this.skinMatrix );
-
-
-		for ( i = 0; i < l; i ++ ) {
-
-			child = this.children[ i ];
-
-			if ( ! ( child instanceof THREE.Bone ) ) {
-
-				child.update( this.matrixWorld, true, camera );
-
-			} else {
-
-				child.update( this.skinMatrix, forceUpdate, camera );
-
-			}
-
-		}
-
-	} else {
-
-		for ( i = 0; i < l; i ++ ) {
-
-			this.children[ i ].update( this.skinMatrix, forceUpdate, camera );
-
-		}
-
-	}
-
-};
-
-
-/*
- * Add child
- */
-
-THREE.Bone.prototype.add = function( child ) {
-
-	if ( this.children.indexOf( child ) === - 1 ) {
+	for ( i = 0; i < l; i ++ ) {
 
 
-		if ( child.parent !== undefined ) {
-
-			child.parent.removeChild( child );
-
-		}
-
-		child.parent = this;
-		this.children.push( child );
-
-		if ( ! ( child instanceof THREE.Bone ) ) {
-
-			this.hasNoneBoneChildren = true;
-
-		}
+		this.children[ i ].update( this.skinMatrix, forceUpdate );
 
 
 	}
 	}
 
 
 };
 };
 
 
-/*
- * TODO: Remove Children: see if any remaining are none-Bone
- */

+ 39 - 60
src/objects/SkinnedMesh.js

@@ -1,5 +1,6 @@
 /**
 /**
  * @author mikael emtinger / http://gomo.se/
  * @author mikael emtinger / http://gomo.se/
+ * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
 THREE.SkinnedMesh = function( geometry, material ) {
 THREE.SkinnedMesh = function( geometry, material ) {
@@ -9,6 +10,7 @@ THREE.SkinnedMesh = function( geometry, material ) {
 	// init bones
 	// init bones
 
 
 	this.identityMatrix = new THREE.Matrix4();
 	this.identityMatrix = new THREE.Matrix4();
+
 	this.bones = [];
 	this.bones = [];
 	this.boneMatrices = [];
 	this.boneMatrices = [];
 
 
@@ -71,100 +73,74 @@ THREE.SkinnedMesh = function( geometry, material ) {
 THREE.SkinnedMesh.prototype = new THREE.Mesh();
 THREE.SkinnedMesh.prototype = new THREE.Mesh();
 THREE.SkinnedMesh.prototype.constructor = THREE.SkinnedMesh;
 THREE.SkinnedMesh.prototype.constructor = THREE.SkinnedMesh;
 
 
+THREE.SkinnedMesh.prototype.addBone = function( bone ) {
 
 
-/*
- * Update
- */
-
-THREE.SkinnedMesh.prototype.update = function ( parentMatrixWorld, forceUpdate, camera ) {
-
-	// visible?
-
-	if ( this.visible ) {
+	if ( bone === undefined ) {
 
 
-		// update local
+		bone = new THREE.Bone( this );
 
 
-		if ( this.matrixAutoUpdate ) {
+	}
 
 
-			forceUpdate |= this.updateMatrix();
+	this.bones.push( bone );
 
 
-		}
+	return bone;
 
 
+};
 
 
-		// update global
+THREE.SkinnedMesh.prototype.updateMatrixWorld = function ( force ) {
 
 
-		if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
+	this.matrixAutoUpdate && this.updateMatrix();
 
 
-			if ( parentMatrixWorld ) {
+	// update matrixWorld
 
 
-				this.matrixWorld.multiply( parentMatrixWorld, this.matrix );
+	if ( this.matrixWorldNeedsUpdate || force ) {
 
 
-			} else {
+		if ( this.parent ) {
 
 
-				this.matrixWorld.copy( this.matrix );
+			this.matrixWorld.multiply( this.parent.matrixWorld, this.matrix );
 
 
-			}
+		} else {
 
 
-			this.matrixWorldNeedsUpdate = false;
-			forceUpdate = true;
+			this.matrixWorld.copy( this.matrix );
 
 
 		}
 		}
 
 
+		this.matrixWorldNeedsUpdate = false;
 
 
-		// update children
-
-		var child, i, l = this.children.length;
-
-		for ( i = 0; i < l; i ++ ) {
-
-			child = this.children[ i ];
-
-			if ( child instanceof THREE.Bone ) {
+		force = true;
 
 
-				child.update( this.identityMatrix, false, camera );
-
-			} else {
-
-				child.update( this.matrixWorld, forceUpdate, camera );
+	}
 
 
-			}
+	// update children
 
 
-		}
+	for ( var i = 0, l = this.children.length; i < l; i ++ ) {
 
 
+		var child = this.children[ i ];
 
 
-		// flatten to array
+		if ( child instanceof THREE.Bone ) {
 
 
-		var b, bl = this.bones.length;
-			ba = this.bones;
-			bm = this.boneMatrices;
+			child.update( this.identityMatrix, false );
 
 
-		for ( b = 0; b < bl; b ++ ) {
+		} else {
 
 
-			ba[ b ].skinMatrix.flattenToArrayOffset( bm, b * 16 );
+			child.updateMatrixWorld( true );
 
 
 		}
 		}
 
 
 	}
 	}
 
 
-};
+	// flatten bone matrices to array
 
 
+	var b, bl = this.bones.length;
+		ba = this.bones;
+		bm = this.boneMatrices;
 
 
-/*
- * Add
- */
+	for ( b = 0; b < bl; b ++ ) {
 
 
-THREE.SkinnedMesh.prototype.addBone = function( bone ) {
-
-	if ( bone === undefined ) {
-
-		bone = new THREE.Bone( this );
+		ba[ b ].skinMatrix.flattenToArrayOffset( bm, b * 16 );
 
 
 	}
 	}
 
 
-	this.bones.push( bone );
-
-	return bone;
-
 };
 };
 
 
 /*
 /*
@@ -173,7 +149,7 @@ THREE.SkinnedMesh.prototype.addBone = function( bone ) {
 
 
 THREE.SkinnedMesh.prototype.pose = function() {
 THREE.SkinnedMesh.prototype.pose = function() {
 
 
-	this.update( undefined, true );
+	this.updateMatrixWorld( true );
 
 
 	var bim, bone, boneInverses = [];
 	var bim, bone, boneInverses = [];
 
 
@@ -181,7 +157,10 @@ THREE.SkinnedMesh.prototype.pose = function() {
 
 
 		bone = this.bones[ b ];
 		bone = this.bones[ b ];
 
 
-		boneInverses.push( THREE.Matrix4.makeInvert( bone.skinMatrix ) );
+		var inverseMatrix = new THREE.Matrix4();
+		inverseMatrix.getInverse( bone.skinMatrix );
+
+		boneInverses.push( inverseMatrix );
 
 
 		bone.skinMatrix.flattenToArrayOffset( this.boneMatrices, b * 16 );
 		bone.skinMatrix.flattenToArrayOffset( this.boneMatrices, b * 16 );
 
 
@@ -215,7 +194,7 @@ THREE.SkinnedMesh.prototype.pose = function() {
 
 
 			if ( this.geometry.skinWeights[ i ].x + this.geometry.skinWeights[ i ].y !== 1 ) {
 			if ( this.geometry.skinWeights[ i ].x + this.geometry.skinWeights[ i ].y !== 1 ) {
 
 
-				var len = ( 1.0 - ( this.geometry.skinWeights[ i ].x + this.geometry.skinWeights[ i ].y )) * 0.5;
+				var len = ( 1.0 - ( this.geometry.skinWeights[ i ].x + this.geometry.skinWeights[ i ].y ) ) * 0.5;
 				this.geometry.skinWeights[ i ].x += len;
 				this.geometry.skinWeights[ i ].x += len;
 				this.geometry.skinWeights[ i ].y += len;
 				this.geometry.skinWeights[ i ].y += len;