Mr.doob 13 éve
szülő
commit
459ff535b8
4 módosított fájl, 200 hozzáadás és 197 törlés
  1. 11 10
      build/Three.js
  2. 109 108
      build/custom/ThreeCanvas.js
  3. 1 1
      build/custom/ThreeExtras.js
  4. 79 78
      build/custom/ThreeWebGL.js

+ 11 - 10
build/Three.js

@@ -29,10 +29,11 @@ THREE.EventTarget=function(){var a={};this.addEventListener=function(b,c){a[b]==
 THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes,d=a.elements,a=d[0];b=d[1];var e=d[2],f=d[3],g=d[4],h=d[5],i=d[6],j=d[7],l=d[8],o=d[9],m=d[10],p=d[11],r=d[12],n=d[13],q=d[14],d=d[15];c[0].set(f-a,j-g,p-l,d-r);c[1].set(f+a,j+g,p+l,d+r);c[2].set(f+b,j+h,p+o,d+n);c[3].set(f-b,j-h,p-o,d-n);c[4].set(f-e,j-i,p-m,d-q);c[5].set(f+e,j+i,p+m,d+q);for(a=0;a<6;a++){b=c[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};
 THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=c.elements,c=-a.geometry.boundingSphere.radius*c.getMaxScaleOnAxis(),e=0;e<6;e++){a=b[e].x*d[12]+b[e].y*d[13]+b[e].z*d[14]+b[e].w;if(a<=c)return false}return true};THREE.Frustum.__v1=new THREE.Vector3;
 THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3,l=new THREE.Vector3,o=new THREE.Vector3,m=new THREE.Vector3,p=function(a,b){return a.distance-b.distance},r=new THREE.Vector3,n=new THREE.Vector3,q=new THREE.Vector3,t,u,w,s=function(a,b,c){r.sub(c,a);t=r.dot(b);u=n.add(a,q.copy(b).multiplyScalar(t));
-return w=c.distanceTo(u)},x,F,C,z,v,H,I,N,R=function(a,b,c,d){r.sub(d,b);n.sub(c,b);q.sub(a,b);x=r.dot(r);F=r.dot(n);C=r.dot(q);z=n.dot(n);v=n.dot(q);H=1/(x*z-F*F);I=(z*C-F*v)*H;N=(x*v-F*C)*H;return I>=0&&N>=0&&I+N<1},Y=1.0E-4;this.setPrecision=function(a){Y=a};this.intersectObject=function(a){var b,c=[];if(a instanceof THREE.Particle){w=s(this.origin,this.direction,a.matrixWorld.getPosition());if(w>a.scale.x)return[];b={distance:w,point:a.position,face:null,object:a};c.push(b)}else if(a instanceof
-THREE.Mesh){var d=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length()),d=a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z));w=s(this.origin,this.direction,a.matrixWorld.getPosition());if(w>d)return c;var k,n,r,q=a.geometry,t=q.vertices,u;a.matrixRotationWorld.extractRotation(a.matrixWorld);d=0;for(k=q.faces.length;d<k;d++){b=q.faces[d];i.copy(this.origin);j.copy(this.direction);u=a.matrixWorld;l=u.multiplyVector3(l.copy(b.centroid)).subSelf(i);
-o=a.matrixRotationWorld.multiplyVector3(o.copy(b.normal));n=j.dot(o);if(!(Math.abs(n)<Y)){r=o.dot(l)/n;if(!(r<0)&&(a.doubleSided||(a.flipSided?n>0:n<0))){m.add(i,j.multiplyScalar(r));w=i.distanceTo(m);if(!(w<this.near)&&!(w>this.far))if(b instanceof THREE.Face3){e=u.multiplyVector3(e.copy(t[b.a]));f=u.multiplyVector3(f.copy(t[b.b]));g=u.multiplyVector3(g.copy(t[b.c]));if(R(m,e,f,g)){b={distance:w,point:m.clone(),face:b,object:a};c.push(b)}}else if(b instanceof THREE.Face4){e=u.multiplyVector3(e.copy(t[b.a]));
-f=u.multiplyVector3(f.copy(t[b.b]));g=u.multiplyVector3(g.copy(t[b.c]));h=u.multiplyVector3(h.copy(t[b.d]));if(R(m,e,f,h)||R(m,f,g,h)){b={distance:w,point:m.clone(),face:b,object:a};c.push(b)}}}}}}c.sort(p);return c};this.intersectObjects=function(a){for(var b=[],c=0,d=a.length;c<d;c++)Array.prototype.push.apply(b,this.intersectObject(a[c]));b.sort(p);return b}};
+return w=c.distanceTo(u)},x,F,C,z,v,H,I,N,R=function(a,b,c,d){r.sub(d,b);n.sub(c,b);q.sub(a,b);x=r.dot(r);F=r.dot(n);C=r.dot(q);z=n.dot(n);v=n.dot(q);H=1/(x*z-F*F);I=(z*C-F*v)*H;N=(x*v-F*C)*H;return I>=0&&N>=0&&I+N<1},Y=1.0E-4;this.setPrecision=function(a){Y=a};this.intersectObject=function(a,b){var c,d=[];if(b===true)for(var k=0,n=a.children.length;k<n;k++)Array.prototype.push.apply(d,this.intersectObject(a.children[k],b));if(a instanceof THREE.Particle){w=s(this.origin,this.direction,a.matrixWorld.getPosition());
+if(w>a.scale.x)return[];c={distance:w,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){k=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());k=a.geometry.boundingSphere.radius*Math.max(k.x,Math.max(k.y,k.z));w=s(this.origin,this.direction,a.matrixWorld.getPosition());if(w>k)return d;var r,q,t=a.geometry,u=t.vertices,v;a.matrixRotationWorld.extractRotation(a.matrixWorld);k=0;for(n=t.faces.length;k<
+n;k++){c=t.faces[k];i.copy(this.origin);j.copy(this.direction);v=a.matrixWorld;l=v.multiplyVector3(l.copy(c.centroid)).subSelf(i);o=a.matrixRotationWorld.multiplyVector3(o.copy(c.normal));r=j.dot(o);if(!(Math.abs(r)<Y)){q=o.dot(l)/r;if(!(q<0)&&(a.doubleSided||(a.flipSided?r>0:r<0))){m.add(i,j.multiplyScalar(q));w=i.distanceTo(m);if(!(w<this.near)&&!(w>this.far))if(c instanceof THREE.Face3){e=v.multiplyVector3(e.copy(u[c.a]));f=v.multiplyVector3(f.copy(u[c.b]));g=v.multiplyVector3(g.copy(u[c.c]));
+if(R(m,e,f,g)){c={distance:w,point:m.clone(),face:c,object:a};d.push(c)}}else if(c instanceof THREE.Face4){e=v.multiplyVector3(e.copy(u[c.a]));f=v.multiplyVector3(f.copy(u[c.b]));g=v.multiplyVector3(g.copy(u[c.c]));h=v.multiplyVector3(h.copy(u[c.d]));if(R(m,e,f,h)||R(m,f,g,h)){c={distance:w,point:m.clone(),face:c,object:a};d.push(c)}}}}}}d.sort(p);return d};this.intersectObjects=function(a,b){for(var c=[],d=0,e=a.length;d<e;d++)Array.prototype.push.apply(c,this.intersectObject(a[d],b));c.sort(p);
+return c}};
 THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,l,o){h=false;b=f;c=g;d=l;e=o;a()};this.addPoint=function(f,g){if(h){h=false;b=f;c=g;d=f;e=g}else{b=b<f?b:f;c=c<g?c:g;d=d>f?d:f;e=e>g?
 e:g}a()};this.add3Points=function(f,g,l,o,m,p){if(h){h=false;b=f<l?f<m?f:m:l<m?l:m;c=g<o?g<p?g:p:o<p?o:p;d=f>l?f>m?f:m:l>m?l:m;e=g>o?g>p?g:p:o>p?o:p}else{b=f<l?f<m?f<b?f:b:m<b?m:b:l<m?l<b?l:b:m<b?m:b;c=g<o?g<p?g<c?g:c:p<c?p:c:o<p?o<c?o:c:p<c?p:c;d=f>l?f>m?f>d?f:d:m>d?m:d:l>m?l>d?l:d:m>d?m:d;e=g>o?g>p?g>e?g:e:p>e?p:e:o>p?o>e?o:e:p>e?p:e}a()};this.addRectangle=function(f){if(h){h=false;b=f.getLeft();c=f.getTop();d=f.getRight();e=f.getBottom()}else{b=b<f.getLeft()?b:f.getLeft();c=c<f.getTop()?c:f.getTop();
 d=d>f.getRight()?d:f.getRight();e=e>f.getBottom()?e:f.getBottom()}a()};this.inflate=function(f){b=b-f;c=c-f;d=d+f;e=e+f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||e<a.getTop()||c>a.getBottom()?false:true};this.empty=function(){h=true;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
@@ -309,9 +310,9 @@ var i=a.colors,j=i.length,l=a.__vertexArray,m=a.__colorArray,n=a.__sortArray,o=a
 if(h.boundTo===void 0||h.boundTo==="vertices"){f=0;e=h.value.length;if(h.size===1)for(d=0;d<e;d++){g=n[d][1];h.array[d]=h.value[g]}else if(h.size===2)for(d=0;d<e;d++){g=n[d][1];g=h.value[g];h.array[f]=g.x;h.array[f+1]=g.y;f=f+2}else if(h.size===3)if(h.type==="c")for(d=0;d<e;d++){g=n[d][1];g=h.value[g];h.array[f]=g.r;h.array[f+1]=g.g;h.array[f+2]=g.b;f=f+3}else for(d=0;d<e;d++){g=n[d][1];g=h.value[g];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;f=f+3}else if(h.size===4)for(d=0;d<e;d++){g=n[d][1];
 g=h.value[g];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;h.array[f+3]=g.w;f=f+4}}}}}else{if(o)for(d=0;d<g;d++){e=h[d];f=d*3;l[f]=e.x;l[f+1]=e.y;l[f+2]=e.z}if(p)for(d=0;d<j;d++){e=i[d];f=d*3;m[f]=e.r;m[f+1]=e.g;m[f+2]=e.b}if(r){i=0;for(j=r.length;i<j;i++){h=r[i];if(h.needsUpdate&&(h.boundTo===void 0||h.boundTo==="vertices")){e=h.value.length;f=0;if(h.size===1)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(h.size===2)for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.x;h.array[f+1]=g.y;f=f+2}else if(h.size===
 3)if(h.type==="c")for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.r;h.array[f+1]=g.g;h.array[f+2]=g.b;f=f+3}else for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;f=f+3}else if(h.size===4)for(d=0;d<e;d++){g=h.value[d];h.array[f]=g.x;h.array[f+1]=g.y;h.array[f+2]=g.z;h.array[f+3]=g.w;f=f+4}}}}}if(o||c.sortParticles){k.bindBuffer(k.ARRAY_BUFFER,a.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,l,b)}if(p||c.sortParticles){k.bindBuffer(k.ARRAY_BUFFER,a.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,
-m,b)}if(r){i=0;for(j=r.length;i<j;i++){h=r[i];if(h.needsUpdate||c.sortParticles){k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.bufferData(k.ARRAY_BUFFER,h.array,b)}}}}function g(a,b){return b.z-a.z}function h(a,b){return b[1]-a[1]}function i(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++){fa=S=null;K=ca=$=Z=oa=Na=X=-1;la=true;a[d].render(b,c,ab,Ba);fa=S=null;K=ca=$=Z=oa=Na=X=-1;la=true}}function j(a,b,c,d,e,f,g,h){var i,k,j,l;if(b){k=a.length-1;l=b=-1}else{k=0;b=a.length;l=1}for(var m=k;m!==b;m=m+l){i=
-a[m];if(i.render){k=i.object;j=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;g&&D.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);D.setDepthTest(i.depthTest);D.setDepthWrite(i.depthWrite);u(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}D.setObjectFaces(k);j instanceof THREE.BufferGeometry?D.renderBufferDirect(d,e,f,i,j,k):D.renderBuffer(d,e,f,i,j,k)}}}function l(a,b,c,d,e,f,g){for(var h,i,k=0,j=a.length;k<j;k++){h=a[k];i=h.object;if(i.visible){if(g)h=g;else{h=h[b];if(!h)continue;
-f&&D.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);D.setDepthTest(h.depthTest);D.setDepthWrite(h.depthWrite);u(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}D.renderImmediateObject(c,d,e,h,i)}}}function o(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function m(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function p(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function r(a,b){for(var c=a.length-
+m,b)}if(r){i=0;for(j=r.length;i<j;i++){h=r[i];if(h.needsUpdate||c.sortParticles){k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.bufferData(k.ARRAY_BUFFER,h.array,b)}}}}function g(a,b){return b.z-a.z}function h(a,b){return b[1]-a[1]}function i(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++){fa=S=null;K=ca=$=Z=oa=Na=X=-1;la=true;a[d].render(b,c,ab,Ba);fa=S=null;K=ca=$=Z=oa=Na=X=-1;la=true}}function j(a,b,c,d,e,f,g,h){var k,i,j,l;if(b){i=a.length-1;l=b=-1}else{i=0;b=a.length;l=1}for(var m=i;m!==b;m=m+l){k=
+a[m];if(k.render){i=k.object;j=k.buffer;if(h)k=h;else{k=k[c];if(!k)continue;g&&D.setBlending(k.blending,k.blendEquation,k.blendSrc,k.blendDst);D.setDepthTest(k.depthTest);D.setDepthWrite(k.depthWrite);u(k.polygonOffset,k.polygonOffsetFactor,k.polygonOffsetUnits)}D.setObjectFaces(i);j instanceof THREE.BufferGeometry?D.renderBufferDirect(d,e,f,k,j,i):D.renderBuffer(d,e,f,k,j,i)}}}function l(a,b,c,d,e,f,g){for(var h,k,i=0,j=a.length;i<j;i++){h=a[i];k=h.object;if(k.visible){if(g)h=g;else{h=h[b];if(!h)continue;
+f&&D.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);D.setDepthTest(h.depthTest);D.setDepthWrite(h.depthWrite);u(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}D.renderImmediateObject(c,d,e,h,k)}}}function o(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function m(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function p(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function r(a,b){for(var c=a.length-
 1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,e){if(d.needsUpdate){d.program&&D.deallocateMaterial(d);D.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences)e.__webglMorphTargetInfluences=new Float32Array(D.maxMorphTargets);var f=false,g=d.program,h=g.uniforms,i=d.uniforms;if(g!==S){k.useProgram(g);S=g;f=true}if(d.id!==K){K=d.id;f=true}if(f||a!==fa){k.uniformMatrix4fv(h.projectionMatrix,
 false,a._projectionMatrixArray);a!==fa&&(fa=a)}if(f){if(c&&d.fog){i.fogColor.value=c.color;if(c instanceof THREE.Fog){i.fogNear.value=c.near;i.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)i.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(la){for(var j,l=0,m=0,n=0,o,p,r,q=ob,t=q.directional.colors,u=q.directional.positions,v=q.point.colors,w=q.point.positions,x=q.point.distances,F=q.spot.colors,B=q.spot.positions,H=q.spot.distances,
 Z=q.spot.directions,I=q.spot.angles,G=q.spot.exponents,N=0,M=0,X=0,O=r=0,c=O=0,f=b.length;c<f;c++){j=b[c];if(!j.onlyShadow&&j.visible){o=j.color;p=j.intensity;r=j.distance;if(j instanceof THREE.AmbientLight)if(D.gammaInput){l=l+o.r*o.r;m=m+o.g*o.g;n=n+o.b*o.b}else{l=l+o.r;m=m+o.g;n=n+o.b}else if(j instanceof THREE.DirectionalLight){r=N*3;if(D.gammaInput){t[r]=o.r*o.r*p*p;t[r+1]=o.g*o.g*p*p;t[r+2]=o.b*o.b*p*p}else{t[r]=o.r*p;t[r+1]=o.g*p;t[r+2]=o.b*p}Da.copy(j.matrixWorld.getPosition());Da.subSelf(j.target.matrixWorld.getPosition());
@@ -368,8 +369,8 @@ s;p.opaque=null}else{p.opaque=s;p.transparent=null}}}else if(s)if(s.transparent)
 null}}}if(a.overrideMaterial){d=a.overrideMaterial;this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst);this.setDepthTest(d.depthTest);this.setDepthWrite(d.depthWrite);u(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits);j(a.__webglObjects,false,"",b,n,o,true,d);l(a.__webglObjectsImmediate,"",b,n,o,false,d)}else{this.setBlending(THREE.NormalBlending);j(a.__webglObjects,true,"opaque",b,n,o,false);l(a.__webglObjectsImmediate,"opaque",b,n,o,false);j(a.__webglObjects,false,"transparent",
 b,n,o,true);l(a.__webglObjectsImmediate,"transparent",b,n,o,true)}i(this.renderPluginsPost,a,b);if(c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter)if(c instanceof THREE.WebGLRenderTargetCube){k.bindTexture(k.TEXTURE_CUBE_MAP,c.__webglTexture);k.generateMipmap(k.TEXTURE_CUBE_MAP);k.bindTexture(k.TEXTURE_CUBE_MAP,null)}else{k.bindTexture(k.TEXTURE_2D,c.__webglTexture);k.generateMipmap(k.TEXTURE_2D);k.bindTexture(k.TEXTURE_2D,null)}this.setDepthTest(true);this.setDepthWrite(true)};
 this.renderImmediateObject=function(a,b,c,d,e){var f=q(a,b,c,d,e);ca=-1;D.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,k,ya):e.render(function(a){D.renderBufferImmediate(a,f,d)})};this.initWebGLObjects=function(a){if(!a.__webglObjects){a.__webglObjects=[];a.__webglObjectsImmediate=[];a.__webglSprites=[];a.__webglFlares=[]}for(;a.__objectsAdded.length;){var g=a.__objectsAdded[0],h=a,i=void 0,j=void 0,l=void 0;if(!g.__webglInit){g.__webglInit=true;g._modelViewMatrix=new THREE.Matrix4;
-g._normalMatrix=new THREE.Matrix3;if(g instanceof THREE.Mesh){j=g.geometry;if(j instanceof THREE.Geometry){if(j.geometryGroups===void 0){var q=j,s=void 0,t=void 0,u=void 0,v=void 0,w=void 0,x=void 0,z=void 0,F={},C=q.morphTargets.length,B=q.morphNormals.length;q.geometryGroups={};s=0;for(t=q.faces.length;s<t;s++){u=q.faces[s];v=u.materialIndex;x=v!==void 0?v:-1;F[x]===void 0&&(F[x]={hash:x,counter:0});z=F[x].hash+"_"+F[x].counter;q.geometryGroups[z]===void 0&&(q.geometryGroups[z]={faces3:[],faces4:[],
-materialIndex:v,vertices:0,numMorphTargets:C,numMorphNormals:B});w=u instanceof THREE.Face3?3:4;if(q.geometryGroups[z].vertices+w>65535){F[x].counter=F[x].counter+1;z=F[x].hash+"_"+F[x].counter;q.geometryGroups[z]===void 0&&(q.geometryGroups[z]={faces3:[],faces4:[],materialIndex:v,vertices:0,numMorphTargets:C,numMorphNormals:B})}u instanceof THREE.Face3?q.geometryGroups[z].faces3.push(s):q.geometryGroups[z].faces4.push(s);q.geometryGroups[z].vertices=q.geometryGroups[z].vertices+w}q.geometryGroupsList=
+g._normalMatrix=new THREE.Matrix3;if(g instanceof THREE.Mesh){j=g.geometry;if(j instanceof THREE.Geometry){if(j.geometryGroups===void 0){var q=j,s=void 0,t=void 0,v=void 0,u=void 0,w=void 0,x=void 0,z=void 0,F={},C=q.morphTargets.length,B=q.morphNormals.length;q.geometryGroups={};s=0;for(t=q.faces.length;s<t;s++){v=q.faces[s];u=v.materialIndex;x=u!==void 0?u:-1;F[x]===void 0&&(F[x]={hash:x,counter:0});z=F[x].hash+"_"+F[x].counter;q.geometryGroups[z]===void 0&&(q.geometryGroups[z]={faces3:[],faces4:[],
+materialIndex:u,vertices:0,numMorphTargets:C,numMorphNormals:B});w=v instanceof THREE.Face3?3:4;if(q.geometryGroups[z].vertices+w>65535){F[x].counter=F[x].counter+1;z=F[x].hash+"_"+F[x].counter;q.geometryGroups[z]===void 0&&(q.geometryGroups[z]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:C,numMorphNormals:B})}v instanceof THREE.Face3?q.geometryGroups[z].faces3.push(s):q.geometryGroups[z].faces4.push(s);q.geometryGroups[z].vertices=q.geometryGroups[z].vertices+w}q.geometryGroupsList=
 [];var H=void 0;for(H in q.geometryGroups){q.geometryGroups[H].id=O++;q.geometryGroupsList.push(q.geometryGroups[H])}}for(i in j.geometryGroups){l=j.geometryGroups[i];if(!l.__webglVertexBuffer){var K=l;K.__webglVertexBuffer=k.createBuffer();K.__webglNormalBuffer=k.createBuffer();K.__webglTangentBuffer=k.createBuffer();K.__webglColorBuffer=k.createBuffer();K.__webglUVBuffer=k.createBuffer();K.__webglUV2Buffer=k.createBuffer();K.__webglSkinVertexABuffer=k.createBuffer();K.__webglSkinVertexBBuffer=k.createBuffer();
 K.__webglSkinIndicesBuffer=k.createBuffer();K.__webglSkinWeightsBuffer=k.createBuffer();K.__webglFaceBuffer=k.createBuffer();K.__webglLineBuffer=k.createBuffer();var Z=void 0,I=void 0;if(K.numMorphTargets){K.__webglMorphTargetsBuffers=[];Z=0;for(I=K.numMorphTargets;Z<I;Z++)K.__webglMorphTargetsBuffers.push(k.createBuffer())}if(K.numMorphNormals){K.__webglMorphNormalsBuffers=[];Z=0;for(I=K.numMorphNormals;Z<I;Z++)K.__webglMorphNormalsBuffers.push(k.createBuffer())}D.info.memory.geometries++;var G=
 l,N=g,X=N.geometry,M=G.faces3,$=G.faces4,S=M.length*3+$.length*4,Q=M.length*1+$.length*2,R=M.length*3+$.length*4,P=c(N,G),aa=e(P),Y=d(P),fa=P.vertexColors?P.vertexColors:false;G.__vertexArray=new Float32Array(S*3);if(Y)G.__normalArray=new Float32Array(S*3);if(X.hasTangents)G.__tangentArray=new Float32Array(S*4);if(fa)G.__colorArray=new Float32Array(S*3);if(aa){if(X.faceUvs.length>0||X.faceVertexUvs.length>0)G.__uvArray=new Float32Array(S*2);if(X.faceUvs.length>1||X.faceVertexUvs.length>1)G.__uv2Array=
@@ -464,7 +465,7 @@ w.vertexNormals[2].copy(g);s.vertexNormals[0].copy(f);s.vertexNormals[3].copy(g)
 f.lerpSelf(e.vertexNormals[2],0.5);g=e.vertexNormals[3].clone();g.lerpSelf(e.vertexNormals[0],0.5);w.vertexNormals[2].copy(f);w.vertexNormals[3].copy(g);s.vertexNormals[0].copy(g);s.vertexNormals[1].copy(f)}if(e.vertexColors.length===4){f=e.vertexColors[1].clone();f.lerpSelf(e.vertexColors[2],0.5);g=e.vertexColors[3].clone();g.lerpSelf(e.vertexColors[0],0.5);w.vertexColors[2].copy(f);w.vertexColors[3].copy(g);s.vertexColors[0].copy(g);s.vertexColors[1].copy(f)}e=1}x.push(w,s);a.vertices.push(p,l);
 f=0;for(g=a.faceVertexUvs.length;f<g;f++)if(a.faceVertexUvs[f].length){j=a.faceVertexUvs[f][c];s=j[0];h=j[1];w=j[2];j=j[3];if(e===0){l=s.clone();l.lerpSelf(h,0.5);o=w.clone();o.lerpSelf(j,0.5);s=[s.clone(),l.clone(),o.clone(),j.clone()];h=[l.clone(),h.clone(),w.clone(),o.clone()]}else{l=h.clone();l.lerpSelf(w,0.5);o=j.clone();o.lerpSelf(s,0.5);s=[s.clone(),h.clone(),l.clone(),o.clone()];h=[o.clone(),l.clone(),w.clone(),j.clone()]}F[f].push(s,h)}}else{x.push(e);f=0;for(g=a.faceVertexUvs.length;f<g;f++)F[f].push(a.faceVertexUvs[f][c])}}}a.faces=
 x;a.faceVertexUvs=F}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
-THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(a,b,c,d){var e=new THREE.Texture(void 0,b),b=new THREE.ImageLoader;b.addEventListener("load",function(a){e.image=a.content;e.needsUpdate=true;c&&c()});b.addEventListener("error",function(a){d&&d(a.message)});b.crossOrigin=this.crossOrigin;b.load(a);return e},loadTextureCube:function(a,b,c){var d,e=[],f=new THREE.Texture(e,b),b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=new Image;e[b].onload=function(){e.loadCount=e.loadCount+1;if(e.loadCount===
+THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(a,b,c,d){var e=new THREE.Texture(void 0,b),b=new THREE.ImageLoader;b.addEventListener("load",function(a){e.image=a.content;e.needsUpdate=true;c&&c(e)});b.addEventListener("error",function(a){d&&d(a.message)});b.crossOrigin=this.crossOrigin;b.load(a);return e},loadTextureCube:function(a,b,c){var d,e=[],f=new THREE.Texture(e,b),b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=new Image;e[b].onload=function(){e.loadCount=e.loadCount+1;if(e.loadCount===
 6){f.needsUpdate=true;c&&c()}};e[b].crossOrigin=this.crossOrigin;e[b].src=a[b]}return f},getNormalMap:function(a,b){var c=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),j=i.data,l=0;l<d;l++)for(var o=0;o<e;o++){var m=o-1<0?0:o-1,p=o+1>e-1?e-1:o+1,r=l-1<0?0:l-1,n=l+1>d-
 1?d-1:l+1,q=[],t=[0,0,h[(o*d+l)*4]/255*b];q.push([-1,0,h[(o*d+r)*4]/255*b]);q.push([-1,-1,h[(m*d+r)*4]/255*b]);q.push([0,-1,h[(m*d+l)*4]/255*b]);q.push([1,-1,h[(m*d+n)*4]/255*b]);q.push([1,0,h[(o*d+n)*4]/255*b]);q.push([1,1,h[(p*d+n)*4]/255*b]);q.push([0,1,h[(p*d+l)*4]/255*b]);q.push([-1,1,h[(p*d+r)*4]/255*b]);m=[];r=q.length;for(p=0;p<r;p++){var n=q[p],u=q[(p+1)%r],n=[n[0]-t[0],n[1]-t[1],n[2]-t[2]],u=[u[0]-t[0],u[1]-t[1],u[2]-t[2]];m.push(c([n[1]*u[2]-n[2]*u[1],n[2]*u[0]-n[0]*u[2],n[0]*u[1]-n[1]*
 u[0]]))}q=[0,0,0];for(p=0;p<m.length;p++){q[0]=q[0]+m[p][0];q[1]=q[1]+m[p][1];q[2]=q[2]+m[p][2]}q[0]=q[0]/m.length;q[1]=q[1]/m.length;q[2]=q[2]/m.length;t=(o*d+l)*4;j[t]=(q[0]+1)/2*255|0;j[t+1]=(q[1]+1)/2*255|0;j[t+2]=q[2]*255|0;j[t+3]=255}g.putImageData(i,0,0);return f},generateDataTexture:function(a,b,c){for(var d=a*b,e=new Uint8Array(3*d),f=Math.floor(c.r*255),g=Math.floor(c.g*255),c=Math.floor(c.b*255),h=0;h<d;h++){e[h*3]=f;e[h*3+1]=g;e[h*3+2]=c}a=new THREE.DataTexture(e,a,b,THREE.RGBFormat);

+ 109 - 108
build/custom/ThreeCanvas.js

@@ -13,54 +13,55 @@ THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a;
 a;this.z=this.z+a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x=this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x=this.x*a.x;this.y=this.y*a.y;this.z=this.z*a.z;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;return this},divideSelf:function(a){this.x=this.x/a.x;this.y=
 this.y/a.y;this.z=this.z/a.z;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a}else this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},
 setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x=this.x+(a.x-this.x)*b;this.y=this.y+(a.y-this.y)*b;this.z=this.z+(a.z-this.z)*b;return this},cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this,
-a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,f=d[0],e=d[4],g=d[8],m=d[1],k=d[5],l=d[9],h=d[2],n=d[6],d=d[10];switch(b||"XYZ"){case "YXZ":this.x=Math.asin(-c(l));if(Math.abs(l)<0.99999){this.y=Math.atan2(g,d);this.z=Math.atan2(m,k)}else{this.y=Math.atan2(-h,f);this.z=0}break;case "ZXY":this.x=Math.asin(c(n));if(Math.abs(n)<
-0.99999){this.y=Math.atan2(-h,d);this.z=Math.atan2(-e,k)}else{this.y=0;this.z=Math.atan2(g,f)}break;case "ZYX":this.y=Math.asin(-c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(n,d);this.z=Math.atan2(m,f)}else{this.x=0;this.z=Math.atan2(-e,k)}break;case "YZX":this.z=Math.asin(c(m));if(Math.abs(m)<0.99999){this.x=Math.atan2(-l,k);this.y=Math.atan2(-h,f)}else{this.x=0;this.y=Math.atan2(h,d)}break;case "XZY":this.z=Math.asin(-c(e));if(Math.abs(e)<0.99999){this.x=Math.atan2(n,k);this.y=Math.atan2(g,f)}else{this.x=
-Math.atan2(-g,d);this.y=0}break;default:this.y=Math.asin(c(g));if(Math.abs(g)<0.99999){this.x=Math.atan2(-l,d);this.z=Math.atan2(-e,f)}else{this.x=Math.atan2(m,k);this.z=0}}return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,f=a.y*a.y,e=a.z*a.z,g=a.w*a.w;switch(b){case "YXZ":this.x=Math.asin(c(2*(a.x*a.w-a.y*a.z)));this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),g-d-f+e);this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g-d+f-e);break;case "ZXY":this.x=Math.asin(c(2*
+a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,f=d[0],e=d[4],g=d[8],m=d[1],k=d[5],j=d[9],h=d[2],n=d[6],d=d[10];switch(b||"XYZ"){case "YXZ":this.x=Math.asin(-c(j));if(Math.abs(j)<0.99999){this.y=Math.atan2(g,d);this.z=Math.atan2(m,k)}else{this.y=Math.atan2(-h,f);this.z=0}break;case "ZXY":this.x=Math.asin(c(n));if(Math.abs(n)<
+0.99999){this.y=Math.atan2(-h,d);this.z=Math.atan2(-e,k)}else{this.y=0;this.z=Math.atan2(g,f)}break;case "ZYX":this.y=Math.asin(-c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(n,d);this.z=Math.atan2(m,f)}else{this.x=0;this.z=Math.atan2(-e,k)}break;case "YZX":this.z=Math.asin(c(m));if(Math.abs(m)<0.99999){this.x=Math.atan2(-j,k);this.y=Math.atan2(-h,f)}else{this.x=0;this.y=Math.atan2(h,d)}break;case "XZY":this.z=Math.asin(-c(e));if(Math.abs(e)<0.99999){this.x=Math.atan2(n,k);this.y=Math.atan2(g,f)}else{this.x=
+Math.atan2(-g,d);this.y=0}break;default:this.y=Math.asin(c(g));if(Math.abs(g)<0.99999){this.x=Math.atan2(-j,d);this.z=Math.atan2(-e,f)}else{this.x=Math.atan2(m,k);this.z=0}}return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,f=a.y*a.y,e=a.z*a.z,g=a.w*a.w;switch(b){case "YXZ":this.x=Math.asin(c(2*(a.x*a.w-a.y*a.z)));this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),g-d-f+e);this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g-d+f-e);break;case "ZXY":this.x=Math.asin(c(2*
 (a.x*a.w+a.y*a.z)));this.y=Math.atan2(2*(a.y*a.w-a.z*a.x),g-d-f+e);this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g-d+f-e);break;case "ZYX":this.x=Math.atan2(2*(a.x*a.w+a.z*a.y),g-d-f+e);this.y=Math.asin(c(2*(a.y*a.w-a.x*a.z)));this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g+d-f-e);break;case "YZX":this.x=Math.atan2(2*(a.x*a.w-a.z*a.y),g-d+f-e);this.y=Math.atan2(2*(a.y*a.w-a.x*a.z),g+d-f-e);this.z=Math.asin(c(2*(a.x*a.y+a.z*a.w)));break;case "XZY":this.x=Math.atan2(2*(a.x*a.w+a.y*a.z),g-d+f-e);this.y=Math.atan2(2*
 (a.x*a.z+a.y*a.w),g+d-f-e);this.z=Math.asin(c(2*(a.z*a.w-a.x*a.y)));break;default:this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),g-d-f+e);this.y=Math.asin(c(2*(a.x*a.z+a.y*a.w)));this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g+d-f-e)}return this},getScaleFromMatrix:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(),a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x=b;this.y=c;this.z=a},equals:function(a){return a.x===
 this.x&&a.y===this.y&&a.z===this.z},isZero:function(){return this.lengthSq()<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1};
 THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x=this.x+a.x;this.y=this.y+a.y;this.z=this.z+a.z;this.w=this.w+a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x=
 this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;this.w=this.w-a.w;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;this.w=this.w*a;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a;this.w=this.w/a}else{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=this.x+(a.x-this.x)*b;this.y=this.y+(a.y-this.y)*b;this.z=this.z+(a.z-this.z)*b;this.w=this.w+(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);if(b<1.0E-4){this.x=1;this.z=this.y=0}else{this.x=a.x/b;this.y=
-a.y/b;this.z=a.z/b}return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,f=a[0];d=a[4];var e=a[8],g=a[1],m=a[5],k=a[9];c=a[2];b=a[6];var l=a[10];if(Math.abs(d-g)<0.01&&Math.abs(e-c)<0.01&&Math.abs(k-b)<0.01){if(Math.abs(d+g)<0.1&&Math.abs(e+c)<0.1&&Math.abs(k+b)<0.1&&Math.abs(f+m+l-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;f=(f+1)/2;m=(m+1)/2;l=(l+1)/2;d=(d+g)/4;e=(e+c)/4;k=(k+b)/4;if(f>m&&f>l)if(f<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(f);c=d/b;d=e/b}else if(m>
-l)if(m<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(m);b=d/c;d=k/c}else if(l<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(l);b=e/d;c=k/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(e-c)*(e-c)+(g-d)*(g-d));Math.abs(a)<0.0010&&(a=1);this.x=(b-k)/a;this.y=(e-c)/a;this.z=(g-d)/a;this.w=Math.acos((f+m+l-1)/2);return this}};
+a.y/b;this.z=a.z/b}return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,f=a[0];d=a[4];var e=a[8],g=a[1],m=a[5],k=a[9];c=a[2];b=a[6];var j=a[10];if(Math.abs(d-g)<0.01&&Math.abs(e-c)<0.01&&Math.abs(k-b)<0.01){if(Math.abs(d+g)<0.1&&Math.abs(e+c)<0.1&&Math.abs(k+b)<0.1&&Math.abs(f+m+j-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;f=(f+1)/2;m=(m+1)/2;j=(j+1)/2;d=(d+g)/4;e=(e+c)/4;k=(k+b)/4;if(f>m&&f>j)if(f<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(f);c=d/b;d=e/b}else if(m>
+j)if(m<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(m);b=d/c;d=k/c}else if(j<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(j);b=e/d;c=k/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(e-c)*(e-c)+(g-d)*(g-d));Math.abs(a)<0.0010&&(a=1);this.x=(b-k)/a;this.y=(e-c)/a;this.z=(g-d)/a;this.w=Math.acos((f+m+j-1)/2);return this}};
 THREE.EventTarget=function(){var a={};this.addEventListener=function(b,c){a[b]===void 0&&(a[b]=[]);a[b].indexOf(c)===-1&&a[b].push(c)};this.dispatchEvent=function(b){for(var c in a[b.type])a[b.type][c](b)};this.removeEventListener=function(b,c){var d=a[b].indexOf(c);d!==-1&&a[b].splice(d,1)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
-THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes,d=a.elements,a=d[0];b=d[1];var f=d[2],e=d[3],g=d[4],m=d[5],k=d[6],l=d[7],h=d[8],n=d[9],j=d[10],o=d[11],q=d[12],i=d[13],p=d[14],d=d[15];c[0].set(e-a,l-g,o-h,d-q);c[1].set(e+a,l+g,o+h,d+q);c[2].set(e+b,l+m,o+n,d+i);c[3].set(e-b,l-m,o-n,d-i);c[4].set(e-f,l-k,o-j,d-p);c[5].set(e+f,l+k,o+j,d+p);for(a=0;a<6;a++){b=c[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};
+THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes,d=a.elements,a=d[0];b=d[1];var f=d[2],e=d[3],g=d[4],m=d[5],k=d[6],j=d[7],h=d[8],n=d[9],i=d[10],o=d[11],q=d[12],l=d[13],p=d[14],d=d[15];c[0].set(e-a,j-g,o-h,d-q);c[1].set(e+a,j+g,o+h,d+q);c[2].set(e+b,j+m,o+n,d+l);c[3].set(e-b,j-m,o-n,d-l);c[4].set(e-f,j-k,o-i,d-p);c[5].set(e+f,j+k,o+i,d+p);for(a=0;a<6;a++){b=c[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};
 THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=c.elements,c=-a.geometry.boundingSphere.radius*c.getMaxScaleOnAxis(),f=0;f<6;f++){a=b[f].x*d[12]+b[f].y*d[13]+b[f].z*d[14]+b[f].w;if(a<=c)return false}return true};THREE.Frustum.__v1=new THREE.Vector3;
-THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var f=new THREE.Vector3,e=new THREE.Vector3,g=new THREE.Vector3,m=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3,j=new THREE.Vector3,o=function(a,b){return a.distance-b.distance},q=new THREE.Vector3,i=new THREE.Vector3,p=new THREE.Vector3,r,s,v,A=function(a,b,c){q.sub(c,a);r=q.dot(b);s=i.add(a,p.copy(b).multiplyScalar(r));
-return v=c.distanceTo(s)},w,B,x,F,u,z,D,H,P=function(a,b,c,d){q.sub(d,b);i.sub(c,b);p.sub(a,b);w=q.dot(q);B=q.dot(i);x=q.dot(p);F=i.dot(i);u=i.dot(p);z=1/(w*F-B*B);D=(F*x-B*u)*z;H=(w*u-B*x)*z;return D>=0&&H>=0&&D+H<1},M=1.0E-4;this.setPrecision=function(a){M=a};this.intersectObject=function(a){var b,c=[];if(a instanceof THREE.Particle){v=A(this.origin,this.direction,a.matrixWorld.getPosition());if(v>a.scale.x)return[];b={distance:v,point:a.position,face:null,object:a};c.push(b)}else if(a instanceof
-THREE.Mesh){var d=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length()),d=a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z));v=A(this.origin,this.direction,a.matrixWorld.getPosition());if(v>d)return c;var i,q,y,S=a.geometry,p=S.vertices,r;a.matrixRotationWorld.extractRotation(a.matrixWorld);d=0;for(i=S.faces.length;d<i;d++){b=S.faces[d];k.copy(this.origin);l.copy(this.direction);r=a.matrixWorld;h=r.multiplyVector3(h.copy(b.centroid)).subSelf(k);
-n=a.matrixRotationWorld.multiplyVector3(n.copy(b.normal));q=l.dot(n);if(!(Math.abs(q)<M)){y=n.dot(h)/q;if(!(y<0)&&(a.doubleSided||(a.flipSided?q>0:q<0))){j.add(k,l.multiplyScalar(y));v=k.distanceTo(j);if(!(v<this.near)&&!(v>this.far))if(b instanceof THREE.Face3){f=r.multiplyVector3(f.copy(p[b.a]));e=r.multiplyVector3(e.copy(p[b.b]));g=r.multiplyVector3(g.copy(p[b.c]));if(P(j,f,e,g)){b={distance:v,point:j.clone(),face:b,object:a};c.push(b)}}else if(b instanceof THREE.Face4){f=r.multiplyVector3(f.copy(p[b.a]));
-e=r.multiplyVector3(e.copy(p[b.b]));g=r.multiplyVector3(g.copy(p[b.c]));m=r.multiplyVector3(m.copy(p[b.d]));if(P(j,f,e,m)||P(j,e,g,m)){b={distance:v,point:j.clone(),face:b,object:a};c.push(b)}}}}}}c.sort(o);return c};this.intersectObjects=function(a){for(var b=[],c=0,d=a.length;c<d;c++)Array.prototype.push.apply(b,this.intersectObject(a[c]));b.sort(o);return b}};
+THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var f=new THREE.Vector3,e=new THREE.Vector3,g=new THREE.Vector3,m=new THREE.Vector3,k=new THREE.Vector3,j=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3,i=new THREE.Vector3,o=function(a,b){return a.distance-b.distance},q=new THREE.Vector3,l=new THREE.Vector3,p=new THREE.Vector3,r,s,v,A=function(a,b,c){q.sub(c,a);r=q.dot(b);s=l.add(a,p.copy(b).multiplyScalar(r));
+return v=c.distanceTo(s)},w,B,x,F,u,z,D,H,P=function(a,b,c,d){q.sub(d,b);l.sub(c,b);p.sub(a,b);w=q.dot(q);B=q.dot(l);x=q.dot(p);F=l.dot(l);u=l.dot(p);z=1/(w*F-B*B);D=(F*x-B*u)*z;H=(w*u-B*x)*z;return D>=0&&H>=0&&D+H<1},M=1.0E-4;this.setPrecision=function(a){M=a};this.intersectObject=function(a,b){var c,d=[];if(b===true)for(var l=0,q=a.children.length;l<q;l++)Array.prototype.push.apply(d,this.intersectObject(a.children[l],b));if(a instanceof THREE.Particle){v=A(this.origin,this.direction,a.matrixWorld.getPosition());
+if(v>a.scale.x)return[];c={distance:v,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){l=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());l=a.geometry.boundingSphere.radius*Math.max(l.x,Math.max(l.y,l.z));v=A(this.origin,this.direction,a.matrixWorld.getPosition());if(v>l)return d;var y,S,p=a.geometry,r=p.vertices,s;a.matrixRotationWorld.extractRotation(a.matrixWorld);l=0;for(q=p.faces.length;l<
+q;l++){c=p.faces[l];k.copy(this.origin);j.copy(this.direction);s=a.matrixWorld;h=s.multiplyVector3(h.copy(c.centroid)).subSelf(k);n=a.matrixRotationWorld.multiplyVector3(n.copy(c.normal));y=j.dot(n);if(!(Math.abs(y)<M)){S=n.dot(h)/y;if(!(S<0)&&(a.doubleSided||(a.flipSided?y>0:y<0))){i.add(k,j.multiplyScalar(S));v=k.distanceTo(i);if(!(v<this.near)&&!(v>this.far))if(c instanceof THREE.Face3){f=s.multiplyVector3(f.copy(r[c.a]));e=s.multiplyVector3(e.copy(r[c.b]));g=s.multiplyVector3(g.copy(r[c.c]));
+if(P(i,f,e,g)){c={distance:v,point:i.clone(),face:c,object:a};d.push(c)}}else if(c instanceof THREE.Face4){f=s.multiplyVector3(f.copy(r[c.a]));e=s.multiplyVector3(e.copy(r[c.b]));g=s.multiplyVector3(g.copy(r[c.c]));m=s.multiplyVector3(m.copy(r[c.d]));if(P(i,f,e,m)||P(i,e,g,m)){c={distance:v,point:i.clone(),face:c,object:a};d.push(c)}}}}}}d.sort(o);return d};this.intersectObjects=function(a,b){for(var c=[],d=0,e=a.length;d<e;d++)Array.prototype.push.apply(c,this.intersectObject(a[d],b));c.sort(o);
+return c}};
 THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b,c,d,f,e,g,m=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,h,n){m=false;b=e;c=g;d=h;f=n;a()};this.addPoint=function(e,g){if(m){m=false;b=e;c=g;d=e;f=g}else{b=b<e?b:e;c=c<g?c:g;d=d>e?d:e;f=f>g?
-f:g}a()};this.add3Points=function(e,g,h,n,j,o){if(m){m=false;b=e<h?e<j?e:j:h<j?h:j;c=g<n?g<o?g:o:n<o?n:o;d=e>h?e>j?e:j:h>j?h:j;f=g>n?g>o?g:o:n>o?n:o}else{b=e<h?e<j?e<b?e:b:j<b?j:b:h<j?h<b?h:b:j<b?j:b;c=g<n?g<o?g<c?g:c:o<c?o:c:n<o?n<c?n:c:o<c?o:c;d=e>h?e>j?e>d?e:d:j>d?j:d:h>j?h>d?h:d:j>d?j:d;f=g>n?g>o?g>f?g:f:o>f?o:f:n>o?n>f?n:f:o>f?o:f}a()};this.addRectangle=function(e){if(m){m=false;b=e.getLeft();c=e.getTop();d=e.getRight();f=e.getBottom()}else{b=b<e.getLeft()?b:e.getLeft();c=c<e.getTop()?c:e.getTop();
+f:g}a()};this.add3Points=function(e,g,h,n,i,o){if(m){m=false;b=e<h?e<i?e:i:h<i?h:i;c=g<n?g<o?g:o:n<o?n:o;d=e>h?e>i?e:i:h>i?h:i;f=g>n?g>o?g:o:n>o?n:o}else{b=e<h?e<i?e<b?e:b:i<b?i:b:h<i?h<b?h:b:i<b?i:b;c=g<n?g<o?g<c?g:c:o<c?o:c:n<o?n<c?n:c:o<c?o:c;d=e>h?e>i?e>d?e:d:i>d?i:d:h>i?h>d?h:d:i>d?i:d;f=g>n?g>o?g>f?g:f:o>f?o:f:n>o?n>f?n:f:o>f?o:f}a()};this.addRectangle=function(e){if(m){m=false;b=e.getLeft();c=e.getTop();d=e.getRight();f=e.getBottom()}else{b=b<e.getLeft()?b:e.getLeft();c=c<e.getTop()?c:e.getTop();
 d=d>e.getRight()?d:e.getRight();f=f>e.getBottom()?f:e.getBottom()}a()};this.inflate=function(e){b=b-e;c=c-e;d=d+e;f=f+e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d<e.getRight()?d:e.getRight();f=f<e.getBottom()?f:e.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||f<a.getTop()||c>a.getBottom()?false:true};this.empty=function(){m=true;f=d=c=b=0;a()};this.isEmpty=function(){return m}};
 THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,f){return d+(a-b)*(f-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())},sign:function(a){return a<0?-1:a>0?1:0}};THREE.Matrix3=function(){this.elements=new Float32Array(9)};
-THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],f=-b[10]*b[4]+b[6]*b[8],e=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],m=b[9]*b[4]-b[5]*b[8],k=-b[9]*b[0]+b[1]*b[8],l=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*f+b[2]*m;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,h=this.elements;h[0]=b*a;h[1]=b*c;h[2]=b*d;h[3]=b*f;h[4]=b*e;h[5]=b*g;h[6]=b*m;h[7]=b*k;h[8]=b*l;return this},
-transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,e,g,m,k,l,h,n,j,o,q,i){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,g||0,m||0,k||0,l||0,h!==void 0?h:1,n||0,j||0,o||0,q||0,i!==void 0?i:1)};
-THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,g,m,k,l,h,n,j,o,q,i){var p=this.elements;p[0]=a;p[4]=b;p[8]=c;p[12]=d;p[1]=f;p[5]=e;p[9]=g;p[13]=m;p[2]=k;p[6]=l;p[10]=h;p[14]=n;p[3]=j;p[7]=o;p[11]=q;p[15]=i;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements,
-f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;f.cross(c,g).normalize();if(f.length()===0){g.x=g.x+1.0E-4;f.cross(c,g).normalize()}e.cross(g,f);d[0]=f.x;d[4]=e.x;d[8]=g.x;d[1]=f.y;d[5]=e.y;d[9]=g.y;d[2]=f.z;d[6]=e.z;d[10]=g.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,f=this.elements,e=c[0],g=c[4],m=c[8],k=c[12],l=c[1],h=c[5],n=c[9],j=c[13],o=c[2],q=c[6],i=c[10],p=c[14],r=c[3],s=c[7],v=c[11],c=c[15],A=d[0],w=d[4],
-B=d[8],x=d[12],F=d[1],u=d[5],z=d[9],D=d[13],H=d[2],P=d[6],M=d[10],t=d[14],E=d[3],G=d[7],N=d[11],d=d[15];f[0]=e*A+g*F+m*H+k*E;f[4]=e*w+g*u+m*P+k*G;f[8]=e*B+g*z+m*M+k*N;f[12]=e*x+g*D+m*t+k*d;f[1]=l*A+h*F+n*H+j*E;f[5]=l*w+h*u+n*P+j*G;f[9]=l*B+h*z+n*M+j*N;f[13]=l*x+h*D+n*t+j*d;f[2]=o*A+q*F+i*H+p*E;f[6]=o*w+q*u+i*P+p*G;f[10]=o*B+q*z+i*M+p*N;f[14]=o*x+q*D+i*t+p*d;f[3]=r*A+s*F+v*H+c*E;f[7]=r*w+s*u+v*P+c*G;f[11]=r*B+s*z+v*M+c*N;f[15]=r*x+s*D+v*t+c*d;return this},multiplySelf:function(a){return this.multiply(this,
+THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],f=-b[10]*b[4]+b[6]*b[8],e=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],m=b[9]*b[4]-b[5]*b[8],k=-b[9]*b[0]+b[1]*b[8],j=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*f+b[2]*m;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,h=this.elements;h[0]=b*a;h[1]=b*c;h[2]=b*d;h[3]=b*f;h[4]=b*e;h[5]=b*g;h[6]=b*m;h[7]=b*k;h[8]=b*j;return this},
+transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,e,g,m,k,j,h,n,i,o,q,l){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,g||0,m||0,k||0,j||0,h!==void 0?h:1,n||0,i||0,o||0,q||0,l!==void 0?l:1)};
+THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,g,m,k,j,h,n,i,o,q,l){var p=this.elements;p[0]=a;p[4]=b;p[8]=c;p[12]=d;p[1]=f;p[5]=e;p[9]=g;p[13]=m;p[2]=k;p[6]=j;p[10]=h;p[14]=n;p[3]=i;p[7]=o;p[11]=q;p[15]=l;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){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements,
+f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;f.cross(c,g).normalize();if(f.length()===0){g.x=g.x+1.0E-4;f.cross(c,g).normalize()}e.cross(g,f);d[0]=f.x;d[4]=e.x;d[8]=g.x;d[1]=f.y;d[5]=e.y;d[9]=g.y;d[2]=f.z;d[6]=e.z;d[10]=g.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,f=this.elements,e=c[0],g=c[4],m=c[8],k=c[12],j=c[1],h=c[5],n=c[9],i=c[13],o=c[2],q=c[6],l=c[10],p=c[14],r=c[3],s=c[7],v=c[11],c=c[15],A=d[0],w=d[4],
+B=d[8],x=d[12],F=d[1],u=d[5],z=d[9],D=d[13],H=d[2],P=d[6],M=d[10],t=d[14],E=d[3],G=d[7],N=d[11],d=d[15];f[0]=e*A+g*F+m*H+k*E;f[4]=e*w+g*u+m*P+k*G;f[8]=e*B+g*z+m*M+k*N;f[12]=e*x+g*D+m*t+k*d;f[1]=j*A+h*F+n*H+i*E;f[5]=j*w+h*u+n*P+i*G;f[9]=j*B+h*z+n*M+i*N;f[13]=j*x+h*D+n*t+i*d;f[2]=o*A+q*F+l*H+p*E;f[6]=o*w+q*u+l*P+p*G;f[10]=o*B+q*z+l*M+p*N;f[14]=o*x+q*D+l*t+p*d;f[3]=r*A+s*F+v*H+c*E;f[7]=r*w+s*u+v*P+c*G;f[11]=r*B+s*z+v*M+c*N;f[15]=r*x+s*D+v*t+c*d;return this},multiplySelf:function(a){return this.multiply(this,
 a)},multiplyToArray:function(a,b,c){var d=this.elements;this.multiply(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]=b[0]*a;b[4]=b[4]*a;b[8]=b[8]*a;b[12]=b[12]*a;b[1]=b[1]*a;b[5]=b[5]*a;b[9]=b[9]*a;b[13]=b[13]*a;b[2]=b[2]*a;b[6]=b[6]*a;b[10]=b[10]*a;b[14]=b[14]*a;b[3]=b[3]*a;b[7]=b[7]*a;b[11]=b[11]*a;b[15]=
 b[15]*a;return this},multiplyVector3:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=1/(b[3]*c+b[7]*d+b[11]*f+b[15]);a.x=(b[0]*c+b[4]*d+b[8]*f+b[12])*e;a.y=(b[1]*c+b[5]*d+b[9]*f+b[13])*e;a.z=(b[2]*c+b[6]*d+b[10]*f+b[14])*e;return a},multiplyVector4:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=a.w;a.x=b[0]*c+b[4]*d+b[8]*f+b[12]*e;a.y=b[1]*c+b[5]*d+b[9]*f+b[13]*e;a.z=b[2]*c+b[6]*d+b[10]*f+b[14]*e;a.w=b[3]*c+b[7]*d+b[11]*f+b[15]*e;return a},rotateAxis:function(a){var b=this.elements,c=a.x,
-d=a.y,f=a.z;a.x=c*b[0]+d*b[4]+f*b[8];a.y=c*b[1]+d*b[5]+f*b[9];a.z=c*b[2]+d*b[6]+f*b[10];a.normalize();return a},crossVector:function(a){var b=this.elements,c=new THREE.Vector4;c.x=b[0]*a.x+b[4]*a.y+b[8]*a.z+b[12]*a.w;c.y=b[1]*a.x+b[5]*a.y+b[9]*a.z+b[13]*a.w;c.z=b[2]*a.x+b[6]*a.y+b[10]*a.z+b[14]*a.w;c.w=a.w?b[3]*a.x+b[7]*a.y+b[11]*a.z+b[15]*a.w:1;return c},determinant:function(){var a=this.elements,b=a[0],c=a[4],d=a[8],f=a[12],e=a[1],g=a[5],m=a[9],k=a[13],l=a[2],h=a[6],n=a[10],j=a[14],o=a[3],q=a[7],
-i=a[11],a=a[15];return f*m*h*o-d*k*h*o-f*g*n*o+c*k*n*o+d*g*j*o-c*m*j*o-f*m*l*q+d*k*l*q+f*e*n*q-b*k*n*q-d*e*j*q+b*m*j*q+f*g*l*i-c*k*l*i-f*e*h*i+b*k*h*i+c*e*j*i-b*g*j*i-d*g*l*a+c*m*l*a+d*e*h*a-b*m*h*a-c*e*n*a+b*g*n*a},transpose:function(){var a=this.elements,b;b=a[1];a[1]=a[4];a[4]=b;b=a[2];a[2]=a[8];a[8]=b;b=a[6];a[6]=a[9];a[9]=b;b=a[3];a[3]=a[12];a[12]=b;b=a[7];a[7]=a[13];a[13]=b;b=a[11];a[11]=a[14];a[14]=b;return this},flattenToArray:function(a){var b=this.elements;a[0]=b[0];a[1]=b[1];a[2]=b[2];
+d=a.y,f=a.z;a.x=c*b[0]+d*b[4]+f*b[8];a.y=c*b[1]+d*b[5]+f*b[9];a.z=c*b[2]+d*b[6]+f*b[10];a.normalize();return a},crossVector:function(a){var b=this.elements,c=new THREE.Vector4;c.x=b[0]*a.x+b[4]*a.y+b[8]*a.z+b[12]*a.w;c.y=b[1]*a.x+b[5]*a.y+b[9]*a.z+b[13]*a.w;c.z=b[2]*a.x+b[6]*a.y+b[10]*a.z+b[14]*a.w;c.w=a.w?b[3]*a.x+b[7]*a.y+b[11]*a.z+b[15]*a.w:1;return c},determinant:function(){var a=this.elements,b=a[0],c=a[4],d=a[8],f=a[12],e=a[1],g=a[5],m=a[9],k=a[13],j=a[2],h=a[6],n=a[10],i=a[14],o=a[3],q=a[7],
+l=a[11],a=a[15];return f*m*h*o-d*k*h*o-f*g*n*o+c*k*n*o+d*g*i*o-c*m*i*o-f*m*j*q+d*k*j*q+f*e*n*q-b*k*n*q-d*e*i*q+b*m*i*q+f*g*j*l-c*k*j*l-f*e*h*l+b*k*h*l+c*e*i*l-b*g*i*l-d*g*j*a+c*m*j*a+d*e*h*a-b*m*h*a-c*e*n*a+b*g*n*a},transpose:function(){var a=this.elements,b;b=a[1];a[1]=a[4];a[4]=b;b=a[2];a[2]=a[8];a[8]=b;b=a[6];a[6]=a[9];a[9]=b;b=a[3];a[3]=a[12];a[12]=b;b=a[7];a[7]=a[13];a[13]=b;b=a[11];a[11]=a[14];a[14]=b;return this},flattenToArray:function(a){var b=this.elements;a[0]=b[0];a[1]=b[1];a[2]=b[2];
 a[3]=b[3];a[4]=b[4];a[5]=b[5];a[6]=b[6];a[7]=b[7];a[8]=b[8];a[9]=b[9];a[10]=b[10];a[11]=b[11];a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15];return a},flattenToArrayOffset:function(a,b){var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a},getPosition:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[12],a[13],
-a[14])},setPosition:function(a){var b=this.elements;b[12]=a.x;b[13]=a.y;b[14]=a.z;return this},getColumnX:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[0],a[1],a[2])},getColumnY:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[4],a[5],a[6])},getColumnZ:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[8],a[9],a[10])},getInverse:function(a){var b=this.elements,c=a.elements,d=c[0],f=c[4],e=c[8],g=c[12],m=c[1],k=c[5],l=c[9],h=c[13],n=c[2],j=c[6],o=c[10],q=
-c[14],i=c[3],p=c[7],r=c[11],c=c[15];b[0]=l*q*p-h*o*p+h*j*r-k*q*r-l*j*c+k*o*c;b[4]=g*o*p-e*q*p-g*j*r+f*q*r+e*j*c-f*o*c;b[8]=e*h*p-g*l*p+g*k*r-f*h*r-e*k*c+f*l*c;b[12]=g*l*j-e*h*j-g*k*o+f*h*o+e*k*q-f*l*q;b[1]=h*o*i-l*q*i-h*n*r+m*q*r+l*n*c-m*o*c;b[5]=e*q*i-g*o*i+g*n*r-d*q*r-e*n*c+d*o*c;b[9]=g*l*i-e*h*i-g*m*r+d*h*r+e*m*c-d*l*c;b[13]=e*h*n-g*l*n+g*m*o-d*h*o-e*m*q+d*l*q;b[2]=k*q*i-h*j*i+h*n*p-m*q*p-k*n*c+m*j*c;b[6]=g*j*i-f*q*i-g*n*p+d*q*p+f*n*c-d*j*c;b[10]=f*h*i-g*k*i+g*m*p-d*h*p-f*m*c+d*k*c;b[14]=g*k*n-
-f*h*n-g*m*j+d*h*j+f*m*q-d*k*q;b[3]=l*j*i-k*o*i-l*n*p+m*o*p+k*n*r-m*j*r;b[7]=f*o*i-e*j*i+e*n*p-d*o*p-f*n*r+d*j*r;b[11]=e*k*i-f*l*i-e*m*p+d*l*p+f*m*r-d*k*r;b[15]=f*l*n-e*k*n+e*m*j-d*l*j-f*m*o+d*k*o;this.multiplyScalar(1/a.determinant());return this},setRotationFromEuler:function(a,b){var c=this.elements,d=a.x,f=a.y,e=a.z,g=Math.cos(d),d=Math.sin(d),m=Math.cos(f),f=Math.sin(f),k=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var l=m*k,h=m*e,n=f*k,j=f*e;c[0]=l+j*d;c[4]=n*d-h;c[8]=g*f;c[1]=g*e;c[5]=g*
-k;c[9]=-d;c[2]=h*d-n;c[6]=j+l*d;c[10]=g*m;break;case "ZXY":l=m*k;h=m*e;n=f*k;j=f*e;c[0]=l-j*d;c[4]=-g*e;c[8]=n+h*d;c[1]=h+n*d;c[5]=g*k;c[9]=j-l*d;c[2]=-g*f;c[6]=d;c[10]=g*m;break;case "ZYX":l=g*k;h=g*e;n=d*k;j=d*e;c[0]=m*k;c[4]=n*f-h;c[8]=l*f+j;c[1]=m*e;c[5]=j*f+l;c[9]=h*f-n;c[2]=-f;c[6]=d*m;c[10]=g*m;break;case "YZX":l=g*m;h=g*f;n=d*m;j=d*f;c[0]=m*k;c[4]=j-l*e;c[8]=n*e+h;c[1]=e;c[5]=g*k;c[9]=-d*k;c[2]=-f*k;c[6]=h*e+n;c[10]=l-j*e;break;case "XZY":l=g*m;h=g*f;n=d*m;j=d*f;c[0]=m*k;c[4]=-e;c[8]=f*k;
-c[1]=l*e+j;c[5]=g*k;c[9]=h*e-n;c[2]=n*e-h;c[6]=d*k;c[10]=j*e+l;break;default:l=g*k;h=g*e;n=d*k;j=d*e;c[0]=m*k;c[4]=-m*e;c[8]=f;c[1]=h+n*f;c[5]=l-j*f;c[9]=-d*m;c[2]=j-l*f;c[6]=n+h*f;c[10]=g*m}return this},setRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=a.w,g=c+c,m=d+d,k=f+f,a=c*g,l=c*m,c=c*k,h=d*m,d=d*k,f=f*k,g=e*g,m=e*m,e=e*k;b[0]=1-(h+f);b[4]=l-e;b[8]=c+m;b[1]=l+e;b[5]=1-(a+f);b[9]=d-g;b[2]=c-m;b[6]=d+g;b[10]=1-(a+h);return this},compose:function(a,b,c){var d=this.elements,
+a[14])},setPosition:function(a){var b=this.elements;b[12]=a.x;b[13]=a.y;b[14]=a.z;return this},getColumnX:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[0],a[1],a[2])},getColumnY:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[4],a[5],a[6])},getColumnZ:function(){var a=this.elements;return THREE.Matrix4.__v1.set(a[8],a[9],a[10])},getInverse:function(a){var b=this.elements,c=a.elements,d=c[0],f=c[4],e=c[8],g=c[12],m=c[1],k=c[5],j=c[9],h=c[13],n=c[2],i=c[6],o=c[10],q=
+c[14],l=c[3],p=c[7],r=c[11],c=c[15];b[0]=j*q*p-h*o*p+h*i*r-k*q*r-j*i*c+k*o*c;b[4]=g*o*p-e*q*p-g*i*r+f*q*r+e*i*c-f*o*c;b[8]=e*h*p-g*j*p+g*k*r-f*h*r-e*k*c+f*j*c;b[12]=g*j*i-e*h*i-g*k*o+f*h*o+e*k*q-f*j*q;b[1]=h*o*l-j*q*l-h*n*r+m*q*r+j*n*c-m*o*c;b[5]=e*q*l-g*o*l+g*n*r-d*q*r-e*n*c+d*o*c;b[9]=g*j*l-e*h*l-g*m*r+d*h*r+e*m*c-d*j*c;b[13]=e*h*n-g*j*n+g*m*o-d*h*o-e*m*q+d*j*q;b[2]=k*q*l-h*i*l+h*n*p-m*q*p-k*n*c+m*i*c;b[6]=g*i*l-f*q*l-g*n*p+d*q*p+f*n*c-d*i*c;b[10]=f*h*l-g*k*l+g*m*p-d*h*p-f*m*c+d*k*c;b[14]=g*k*n-
+f*h*n-g*m*i+d*h*i+f*m*q-d*k*q;b[3]=j*i*l-k*o*l-j*n*p+m*o*p+k*n*r-m*i*r;b[7]=f*o*l-e*i*l+e*n*p-d*o*p-f*n*r+d*i*r;b[11]=e*k*l-f*j*l-e*m*p+d*j*p+f*m*r-d*k*r;b[15]=f*j*n-e*k*n+e*m*i-d*j*i-f*m*o+d*k*o;this.multiplyScalar(1/a.determinant());return this},setRotationFromEuler:function(a,b){var c=this.elements,d=a.x,f=a.y,e=a.z,g=Math.cos(d),d=Math.sin(d),m=Math.cos(f),f=Math.sin(f),k=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var j=m*k,h=m*e,n=f*k,i=f*e;c[0]=j+i*d;c[4]=n*d-h;c[8]=g*f;c[1]=g*e;c[5]=g*
+k;c[9]=-d;c[2]=h*d-n;c[6]=i+j*d;c[10]=g*m;break;case "ZXY":j=m*k;h=m*e;n=f*k;i=f*e;c[0]=j-i*d;c[4]=-g*e;c[8]=n+h*d;c[1]=h+n*d;c[5]=g*k;c[9]=i-j*d;c[2]=-g*f;c[6]=d;c[10]=g*m;break;case "ZYX":j=g*k;h=g*e;n=d*k;i=d*e;c[0]=m*k;c[4]=n*f-h;c[8]=j*f+i;c[1]=m*e;c[5]=i*f+j;c[9]=h*f-n;c[2]=-f;c[6]=d*m;c[10]=g*m;break;case "YZX":j=g*m;h=g*f;n=d*m;i=d*f;c[0]=m*k;c[4]=i-j*e;c[8]=n*e+h;c[1]=e;c[5]=g*k;c[9]=-d*k;c[2]=-f*k;c[6]=h*e+n;c[10]=j-i*e;break;case "XZY":j=g*m;h=g*f;n=d*m;i=d*f;c[0]=m*k;c[4]=-e;c[8]=f*k;
+c[1]=j*e+i;c[5]=g*k;c[9]=h*e-n;c[2]=n*e-h;c[6]=d*k;c[10]=i*e+j;break;default:j=g*k;h=g*e;n=d*k;i=d*e;c[0]=m*k;c[4]=-m*e;c[8]=f;c[1]=h+n*f;c[5]=j-i*f;c[9]=-d*m;c[2]=i-j*f;c[6]=n+h*f;c[10]=g*m}return this},setRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=a.w,g=c+c,m=d+d,k=f+f,a=c*g,j=c*m,c=c*k,h=d*m,d=d*k,f=f*k,g=e*g,m=e*m,e=e*k;b[0]=1-(h+f);b[4]=j-e;b[8]=c+m;b[1]=j+e;b[5]=1-(a+f);b[9]=d-g;b[2]=c-m;b[6]=d+g;b[10]=1-(a+h);return this},compose:function(a,b,c){var d=this.elements,
 f=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;f.identity();f.setRotationFromQuaternion(b);e.makeScale(c.x,c.y,c.z);this.multiply(f,e);d[12]=a.x;d[13]=a.y;d[14]=a.z;return this},decompose:function(a,b,c){var d=this.elements,f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;f.set(d[0],d[1],d[2]);e.set(d[4],d[5],d[6]);g.set(d[8],d[9],d[10]);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=f.length();c.y=e.length();c.z=g.length();a.x=d[12];a.y=d[13];a.z=d[14];d=THREE.Matrix4.__m1;d.copy(this);d.elements[0]=d.elements[0]/c.x;d.elements[1]=d.elements[1]/c.x;d.elements[2]=d.elements[2]/c.x;d.elements[4]=d.elements[4]/c.y;d.elements[5]=d.elements[5]/c.y;d.elements[6]=d.elements[6]/c.y;d.elements[8]=d.elements[8]/c.z;d.elements[9]=d.elements[9]/c.z;d.elements[10]=d.elements[10]/c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){var b=this.elements,a=a.elements;
 b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractRotation:function(a){var b=this.elements,a=a.elements,c=THREE.Matrix4.__v1,d=1/c.set(a[0],a[1],a[2]).length(),f=1/c.set(a[4],a[5],a[6]).length(),c=1/c.set(a[8],a[9],a[10]).length();b[0]=a[0]*d;b[1]=a[1]*d;b[2]=a[2]*d;b[4]=a[4]*f;b[5]=a[5]*f;b[6]=a[6]*f;b[8]=a[8]*c;b[9]=a[9]*c;b[10]=a[10]*c;return this},translate:function(a){var b=this.elements,c=a.x,d=a.y,a=a.z;b[12]=b[0]*c+b[4]*d+b[8]*a+b[12];b[13]=b[1]*c+b[5]*d+b[9]*a+b[13];b[14]=b[2]*c+b[6]*
-d+b[10]*a+b[14];b[15]=b[3]*c+b[7]*d+b[11]*a+b[15];return this},rotateX:function(a){var b=this.elements,c=b[4],d=b[5],f=b[6],e=b[7],g=b[8],m=b[9],k=b[10],l=b[11],h=Math.cos(a),a=Math.sin(a);b[4]=h*c+a*g;b[5]=h*d+a*m;b[6]=h*f+a*k;b[7]=h*e+a*l;b[8]=h*g-a*c;b[9]=h*m-a*d;b[10]=h*k-a*f;b[11]=h*l-a*e;return this},rotateY:function(a){var b=this.elements,c=b[0],d=b[1],f=b[2],e=b[3],g=b[8],m=b[9],k=b[10],l=b[11],h=Math.cos(a),a=Math.sin(a);b[0]=h*c-a*g;b[1]=h*d-a*m;b[2]=h*f-a*k;b[3]=h*e-a*l;b[8]=h*g+a*c;b[9]=
-h*m+a*d;b[10]=h*k+a*f;b[11]=h*l+a*e;return this},rotateZ:function(a){var b=this.elements,c=b[0],d=b[1],f=b[2],e=b[3],g=b[4],m=b[5],k=b[6],l=b[7],h=Math.cos(a),a=Math.sin(a);b[0]=h*c+a*g;b[1]=h*d+a*m;b[2]=h*f+a*k;b[3]=h*e+a*l;b[4]=h*g-a*c;b[5]=h*m-a*d;b[6]=h*k-a*f;b[7]=h*l-a*e;return this},rotateByAxis:function(a,b){var c=this.elements;if(a.x===1&&a.y===0&&a.z===0)return this.rotateX(b);if(a.x===0&&a.y===1&&a.z===0)return this.rotateY(b);if(a.x===0&&a.y===0&&a.z===1)return this.rotateZ(b);var d=a.x,
-f=a.y,e=a.z,g=Math.sqrt(d*d+f*f+e*e),d=d/g,f=f/g,e=e/g,g=d*d,m=f*f,k=e*e,l=Math.cos(b),h=Math.sin(b),n=1-l,j=d*f*n,o=d*e*n,n=f*e*n,d=d*h,q=f*h,h=e*h,e=g+(1-g)*l,g=j+h,f=o-q,j=j-h,m=m+(1-m)*l,h=n+d,o=o+q,n=n-d,k=k+(1-k)*l,l=c[0],d=c[1],q=c[2],i=c[3],p=c[4],r=c[5],s=c[6],v=c[7],A=c[8],w=c[9],B=c[10],x=c[11];c[0]=e*l+g*p+f*A;c[1]=e*d+g*r+f*w;c[2]=e*q+g*s+f*B;c[3]=e*i+g*v+f*x;c[4]=j*l+m*p+h*A;c[5]=j*d+m*r+h*w;c[6]=j*q+m*s+h*B;c[7]=j*i+m*v+h*x;c[8]=o*l+n*p+k*A;c[9]=o*d+n*r+k*w;c[10]=o*q+n*s+k*B;c[11]=
-o*i+n*v+k*x;return this},scale:function(a){var b=this.elements,c=a.x,d=a.y,a=a.z;b[0]=b[0]*c;b[4]=b[4]*d;b[8]=b[8]*a;b[1]=b[1]*c;b[5]=b[5]*d;b[9]=b[9]*a;b[2]=b[2]*c;b[6]=b[6]*d;b[10]=b[10]*a;b[3]=b[3]*c;b[7]=b[7]*d;b[11]=b[11]*a;return this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],Math.max(a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10])))},makeTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},
-makeRotationX: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},makeRotationY: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},makeRotationZ: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},makeRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,e=a.x,g=a.y,m=a.z,k=f*e,l=f*g;this.set(k*e+c,k*g-d*m,k*m+d*g,0,k*g+d*m,l*g+c,l*m-d*e,0,k*m-
-d*g,l*m+d*e,f*m*m+c,0,0,0,0,1);return this},makeScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},makeFrustum:function(a,b,c,d,f,e){var g=this.elements;g[0]=2*f/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*f/(d-c);g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(e+f)/(e-f);g[14]=-2*e*f/(e-f);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makePerspective:function(a,b,c,d){var a=c*Math.tan(a*Math.PI/360),f=-a;return this.makeFrustum(f*b,a*b,f,a,c,d)},makeOrthographic:function(a,
-b,c,d,f,e){var g=this.elements,m=b-a,k=c-d,l=e-f;g[0]=2/m;g[4]=0;g[8]=0;g[12]=-((b+a)/m);g[1]=0;g[5]=2/k;g[9]=0;g[13]=-((c+d)/k);g[2]=0;g[6]=0;g[10]=-2/l;g[14]=-((e+f)/l);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},clone:function(){var a=this.elements;return new THREE.Matrix4(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15])}};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;
+d+b[10]*a+b[14];b[15]=b[3]*c+b[7]*d+b[11]*a+b[15];return this},rotateX:function(a){var b=this.elements,c=b[4],d=b[5],f=b[6],e=b[7],g=b[8],m=b[9],k=b[10],j=b[11],h=Math.cos(a),a=Math.sin(a);b[4]=h*c+a*g;b[5]=h*d+a*m;b[6]=h*f+a*k;b[7]=h*e+a*j;b[8]=h*g-a*c;b[9]=h*m-a*d;b[10]=h*k-a*f;b[11]=h*j-a*e;return this},rotateY:function(a){var b=this.elements,c=b[0],d=b[1],f=b[2],e=b[3],g=b[8],m=b[9],k=b[10],j=b[11],h=Math.cos(a),a=Math.sin(a);b[0]=h*c-a*g;b[1]=h*d-a*m;b[2]=h*f-a*k;b[3]=h*e-a*j;b[8]=h*g+a*c;b[9]=
+h*m+a*d;b[10]=h*k+a*f;b[11]=h*j+a*e;return this},rotateZ:function(a){var b=this.elements,c=b[0],d=b[1],f=b[2],e=b[3],g=b[4],m=b[5],k=b[6],j=b[7],h=Math.cos(a),a=Math.sin(a);b[0]=h*c+a*g;b[1]=h*d+a*m;b[2]=h*f+a*k;b[3]=h*e+a*j;b[4]=h*g-a*c;b[5]=h*m-a*d;b[6]=h*k-a*f;b[7]=h*j-a*e;return this},rotateByAxis:function(a,b){var c=this.elements;if(a.x===1&&a.y===0&&a.z===0)return this.rotateX(b);if(a.x===0&&a.y===1&&a.z===0)return this.rotateY(b);if(a.x===0&&a.y===0&&a.z===1)return this.rotateZ(b);var d=a.x,
+f=a.y,e=a.z,g=Math.sqrt(d*d+f*f+e*e),d=d/g,f=f/g,e=e/g,g=d*d,m=f*f,k=e*e,j=Math.cos(b),h=Math.sin(b),n=1-j,i=d*f*n,o=d*e*n,n=f*e*n,d=d*h,q=f*h,h=e*h,e=g+(1-g)*j,g=i+h,f=o-q,i=i-h,m=m+(1-m)*j,h=n+d,o=o+q,n=n-d,k=k+(1-k)*j,j=c[0],d=c[1],q=c[2],l=c[3],p=c[4],r=c[5],s=c[6],v=c[7],A=c[8],w=c[9],B=c[10],x=c[11];c[0]=e*j+g*p+f*A;c[1]=e*d+g*r+f*w;c[2]=e*q+g*s+f*B;c[3]=e*l+g*v+f*x;c[4]=i*j+m*p+h*A;c[5]=i*d+m*r+h*w;c[6]=i*q+m*s+h*B;c[7]=i*l+m*v+h*x;c[8]=o*j+n*p+k*A;c[9]=o*d+n*r+k*w;c[10]=o*q+n*s+k*B;c[11]=
+o*l+n*v+k*x;return this},scale:function(a){var b=this.elements,c=a.x,d=a.y,a=a.z;b[0]=b[0]*c;b[4]=b[4]*d;b[8]=b[8]*a;b[1]=b[1]*c;b[5]=b[5]*d;b[9]=b[9]*a;b[2]=b[2]*c;b[6]=b[6]*d;b[10]=b[10]*a;b[3]=b[3]*c;b[7]=b[7]*d;b[11]=b[11]*a;return this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],Math.max(a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10])))},makeTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},
+makeRotationX: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},makeRotationY: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},makeRotationZ: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},makeRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,e=a.x,g=a.y,m=a.z,k=f*e,j=f*g;this.set(k*e+c,k*g-d*m,k*m+d*g,0,k*g+d*m,j*g+c,j*m-d*e,0,k*m-
+d*g,j*m+d*e,f*m*m+c,0,0,0,0,1);return this},makeScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},makeFrustum:function(a,b,c,d,f,e){var g=this.elements;g[0]=2*f/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*f/(d-c);g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(e+f)/(e-f);g[14]=-2*e*f/(e-f);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makePerspective:function(a,b,c,d){var a=c*Math.tan(a*Math.PI/360),f=-a;return this.makeFrustum(f*b,a*b,f,a,c,d)},makeOrthographic:function(a,
+b,c,d,f,e){var g=this.elements,m=b-a,k=c-d,j=e-f;g[0]=2/m;g[4]=0;g[8]=0;g[12]=-((b+a)/m);g[1]=0;g[5]=2/k;g[9]=0;g[13]=-((c+d)/k);g[2]=0;g[6]=0;g[10]=-2/j;g[14]=-((e+f)/j);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},clone:function(){var a=this.elements;return new THREE.Matrix4(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15])}};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;
 THREE.Matrix4.__m2=new THREE.Matrix4;
 THREE.Object3D=function(){this.id=THREE.Object3DCount++;this.name="";this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=false;this.renderDepth=null;this.rotationAutoUpdate=true;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
 true;this.quaternion=new THREE.Quaternion;this.useQuaternion=false;this.boundRadius=0;this.boundRadiusScale=1;this.visible=true;this.receiveShadow=this.castShadow=false;this.frustumCulled=true;this._vector=new THREE.Vector3};
@@ -69,24 +70,24 @@ this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.s
 b.parent;b!==void 0&&b instanceof THREE.Scene&&b.__addObject(a)}},remove:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=void 0;this.children.splice(b,1);for(b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.__removeObject(a)}},getChildByName:function(a,b){var c,d,f;c=0;for(d=this.children.length;c<d;c++){f=this.children[c];if(f.name===a)return f;if(b){f=f.getChildByName(a,b);if(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=true},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=false;a=true}for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)},worldToLocal:function(a){return THREE.Object3D.__m1.getInverse(this.matrixWorld).multiplyVector3(a)},localToWorld:function(a){return this.matrixWorld.multiplyVector3(a)}};THREE.Object3D.__m1=new THREE.Matrix4;THREE.Object3DCount=0;
-THREE.Projector=function(){function a(){var a=g[e]=g[e]||new THREE.RenderableObject;e++;return a}function b(){var a=l[k]=l[k]||new THREE.RenderableVertex;k++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,g=b.z+b.w,f=-a.z+a.w,h=-b.z+b.w;if(e>=0&&g>=0&&f>=0&&h>=0)return true;if(e<0&&g<0||f<0&&h<0)return false;e<0?c=Math.max(c,e/(e-g)):g<0&&(d=Math.min(d,e/(e-g)));f<0?c=Math.max(c,f/(f-h)):h<0&&(d=Math.min(d,f/(f-h)));if(d<c)return false;a.lerpSelf(b,c);b.lerpSelf(a,1-
-d);return true}var f,e,g=[],m,k,l=[],h,n,j=[],o,q=[],i,p,r=[],s,v,A=[],w={objects:[],sprites:[],lights:[],elements:[]},B=new THREE.Vector3,x=new THREE.Vector4,F=new THREE.Matrix4,u=new THREE.Matrix4,z=new THREE.Frustum,D=new THREE.Vector4,H=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);F.multiply(b.projectionMatrix,b.matrixWorldInverse);F.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);
+THREE.Projector=function(){function a(){var a=g[e]=g[e]||new THREE.RenderableObject;e++;return a}function b(){var a=j[k]=j[k]||new THREE.RenderableVertex;k++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,g=b.z+b.w,f=-a.z+a.w,h=-b.z+b.w;if(e>=0&&g>=0&&f>=0&&h>=0)return true;if(e<0&&g<0||f<0&&h<0)return false;e<0?c=Math.max(c,e/(e-g)):g<0&&(d=Math.min(d,e/(e-g)));f<0?c=Math.max(c,f/(f-h)):h<0&&(d=Math.min(d,f/(f-h)));if(d<c)return false;a.lerpSelf(b,c);b.lerpSelf(a,1-
+d);return true}var f,e,g=[],m,k,j=[],h,n,i=[],o,q=[],l,p,r=[],s,v,A=[],w={objects:[],sprites:[],lights:[],elements:[]},B=new THREE.Vector3,x=new THREE.Vector4,F=new THREE.Matrix4,u=new THREE.Matrix4,z=new THREE.Frustum,D=new THREE.Vector4,H=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);F.multiply(b.projectionMatrix,b.matrixWorldInverse);F.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);
 F.multiply(b.matrixWorld,b.projectionMatrixInverse);F.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){e=0;w.objects.length=0;w.sprites.length=0;w.lights.length=0;var g=function(b){if(b.visible!==false){if((b instanceof THREE.Mesh||b instanceof THREE.Line)&&(b.frustumCulled===false||z.contains(b))){B.copy(b.matrixWorld.getPosition());
 F.multiplyVector3(B);f=a();f.object=b;f.z=B.z;w.objects.push(f)}else if(b instanceof THREE.Sprite||b instanceof THREE.Particle){B.copy(b.matrixWorld.getPosition());F.multiplyVector3(B);f=a();f.object=b;f.z=B.z;w.sprites.push(f)}else b instanceof THREE.Light&&w.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&w.objects.sort(c);return w};this.projectScene=function(a,e,g){var f=e.near,G=e.far,B=false,Q,O,y,S,L,U,T,W,C,J,I,K,R,ja,da;v=p=o=n=0;w.elements.length=0;if(e.parent===
 void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(e)}a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);F.multiply(e.projectionMatrix,e.matrixWorldInverse);z.setFromMatrix(F);w=this.projectGraph(a,false);a=0;for(Q=w.objects.length;a<Q;a++){C=w.objects[a].object;J=C.matrixWorld;k=0;if(C instanceof THREE.Mesh){I=C.geometry;K=C.geometry.materials;S=I.vertices;R=I.faces;ja=I.faceVertexUvs;I=C.matrixRotationWorld.extractRotation(J);O=0;for(y=
-S.length;O<y;O++){m=b();m.positionWorld.copy(S[O]);J.multiplyVector3(m.positionWorld);m.positionScreen.copy(m.positionWorld);F.multiplyVector4(m.positionScreen);m.positionScreen.x=m.positionScreen.x/m.positionScreen.w;m.positionScreen.y=m.positionScreen.y/m.positionScreen.w;m.visible=m.positionScreen.z>f&&m.positionScreen.z<G}S=0;for(O=R.length;S<O;S++){y=R[S];if(y instanceof THREE.Face3){L=l[y.a];U=l[y.b];T=l[y.c];if(L.visible&&U.visible&&T.visible){B=(T.positionScreen.x-L.positionScreen.x)*(U.positionScreen.y-
-L.positionScreen.y)-(T.positionScreen.y-L.positionScreen.y)*(U.positionScreen.x-L.positionScreen.x)<0;if(C.doubleSided||B!=C.flipSided){W=j[n]=j[n]||new THREE.RenderableFace3;n++;h=W;h.v1.copy(L);h.v2.copy(U);h.v3.copy(T)}else continue}else continue}else if(y instanceof THREE.Face4){L=l[y.a];U=l[y.b];T=l[y.c];W=l[y.d];if(L.visible&&U.visible&&T.visible&&W.visible){B=(W.positionScreen.x-L.positionScreen.x)*(U.positionScreen.y-L.positionScreen.y)-(W.positionScreen.y-L.positionScreen.y)*(U.positionScreen.x-
+S.length;O<y;O++){m=b();m.positionWorld.copy(S[O]);J.multiplyVector3(m.positionWorld);m.positionScreen.copy(m.positionWorld);F.multiplyVector4(m.positionScreen);m.positionScreen.x=m.positionScreen.x/m.positionScreen.w;m.positionScreen.y=m.positionScreen.y/m.positionScreen.w;m.visible=m.positionScreen.z>f&&m.positionScreen.z<G}S=0;for(O=R.length;S<O;S++){y=R[S];if(y instanceof THREE.Face3){L=j[y.a];U=j[y.b];T=j[y.c];if(L.visible&&U.visible&&T.visible){B=(T.positionScreen.x-L.positionScreen.x)*(U.positionScreen.y-
+L.positionScreen.y)-(T.positionScreen.y-L.positionScreen.y)*(U.positionScreen.x-L.positionScreen.x)<0;if(C.doubleSided||B!=C.flipSided){W=i[n]=i[n]||new THREE.RenderableFace3;n++;h=W;h.v1.copy(L);h.v2.copy(U);h.v3.copy(T)}else continue}else continue}else if(y instanceof THREE.Face4){L=j[y.a];U=j[y.b];T=j[y.c];W=j[y.d];if(L.visible&&U.visible&&T.visible&&W.visible){B=(W.positionScreen.x-L.positionScreen.x)*(U.positionScreen.y-L.positionScreen.y)-(W.positionScreen.y-L.positionScreen.y)*(U.positionScreen.x-
 L.positionScreen.x)<0||(U.positionScreen.x-T.positionScreen.x)*(W.positionScreen.y-T.positionScreen.y)-(U.positionScreen.y-T.positionScreen.y)*(W.positionScreen.x-T.positionScreen.x)<0;if(C.doubleSided||B!=C.flipSided){da=q[o]=q[o]||new THREE.RenderableFace4;o++;h=da;h.v1.copy(L);h.v2.copy(U);h.v3.copy(T);h.v4.copy(W)}else continue}else continue}h.normalWorld.copy(y.normal);!B&&(C.flipSided||C.doubleSided)&&h.normalWorld.negate();I.multiplyVector3(h.normalWorld);h.centroidWorld.copy(y.centroid);J.multiplyVector3(h.centroidWorld);
 h.centroidScreen.copy(h.centroidWorld);F.multiplyVector3(h.centroidScreen);T=y.vertexNormals;L=0;for(U=T.length;L<U;L++){W=h.vertexNormalsWorld[L];W.copy(T[L]);!B&&(C.flipSided||C.doubleSided)&&W.negate();I.multiplyVector3(W)}L=0;for(U=ja.length;L<U;L++)if(da=ja[L][S]){T=0;for(W=da.length;T<W;T++)h.uvs[L][T]=da[T]}h.material=C.material;h.faceMaterial=y.materialIndex!==null?K[y.materialIndex]:null;h.z=h.centroidScreen.z;w.elements.push(h)}}else if(C instanceof THREE.Line){u.multiply(F,J);S=C.geometry.vertices;
-L=b();L.positionScreen.copy(S[0]);u.multiplyVector4(L.positionScreen);J=C.type===THREE.LinePieces?2:1;O=1;for(y=S.length;O<y;O++){L=b();L.positionScreen.copy(S[O]);u.multiplyVector4(L.positionScreen);if(!((O+1)%J>0)){U=l[k-2];D.copy(L.positionScreen);H.copy(U.positionScreen);if(d(D,H)){D.multiplyScalar(1/D.w);H.multiplyScalar(1/H.w);K=r[p]=r[p]||new THREE.RenderableLine;p++;i=K;i.v1.positionScreen.copy(D);i.v2.positionScreen.copy(H);i.z=Math.max(D.z,H.z);i.material=C.material;w.elements.push(i)}}}}}a=
+L=b();L.positionScreen.copy(S[0]);u.multiplyVector4(L.positionScreen);J=C.type===THREE.LinePieces?2:1;O=1;for(y=S.length;O<y;O++){L=b();L.positionScreen.copy(S[O]);u.multiplyVector4(L.positionScreen);if(!((O+1)%J>0)){U=j[k-2];D.copy(L.positionScreen);H.copy(U.positionScreen);if(d(D,H)){D.multiplyScalar(1/D.w);H.multiplyScalar(1/H.w);K=r[p]=r[p]||new THREE.RenderableLine;p++;l=K;l.v1.positionScreen.copy(D);l.v2.positionScreen.copy(H);l.z=Math.max(D.z,H.z);l.material=C.material;w.elements.push(l)}}}}}a=
 0;for(Q=w.sprites.length;a<Q;a++){C=w.sprites[a].object;J=C.matrixWorld;if(C instanceof THREE.Particle){x.set(J.elements[12],J.elements[13],J.elements[14],1);F.multiplyVector4(x);x.z=x.z/x.w;if(x.z>0&&x.z<1){f=A[v]=A[v]||new THREE.RenderableParticle;v++;s=f;s.x=x.x/x.w;s.y=x.y/x.w;s.z=x.z;s.rotation=C.rotation.z;s.scale.x=C.scale.x*Math.abs(s.x-(x.x+e.projectionMatrix.elements[0])/(x.w+e.projectionMatrix.elements[12]));s.scale.y=C.scale.y*Math.abs(s.y-(x.y+e.projectionMatrix.elements[5])/(x.w+e.projectionMatrix.elements[13]));
 s.material=C.material;w.elements.push(s)}}}g&&w.elements.sort(c);return w}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a,b){var c=b||"XYZ",d=Math.cos(a.x/2),f=Math.cos(a.y/2),e=Math.cos(a.z/2),g=Math.sin(a.x/2),m=Math.sin(a.y/2),k=Math.sin(a.z/2);switch(c){case "YXZ":this.x=g*f*e+d*m*k;this.y=d*m*e-g*f*k;this.z=d*f*k-g*m*e;this.w=d*f*e+g*m*k;break;case "ZXY":this.x=g*f*e-d*m*k;this.y=d*m*e+g*f*
 k;this.z=d*f*k+g*m*e;this.w=d*f*e-g*m*k;break;case "ZYX":this.x=g*f*e-d*m*k;this.y=d*m*e+g*f*k;this.z=d*f*k-g*m*e;this.w=d*f*e+g*m*k;break;case "YZX":this.x=g*f*e+d*m*k;this.y=d*m*e+g*f*k;this.z=d*f*k-g*m*e;this.w=d*f*e-g*m*k;break;case "XZY":this.x=g*f*e-d*m*k;this.y=d*m*e-g*f*k;this.z=d*f*k+g*m*e;this.w=d*f*e+g*m*k;break;default:this.x=g*f*e+d*m*k;this.y=d*m*e-g*f*k;this.z=d*f*k+g*m*e;this.w=d*f*e-g*m*k}return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*
-d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],f=b[1],e=b[5],g=b[9],m=b[2],k=b[6],b=b[10],l=c+e+b;if(l>0){c=0.5/Math.sqrt(l+1);this.w=0.25/c;this.x=(k-g)*c;this.y=(d-m)*c;this.z=(f-a)*c}else if(c>e&&c>b){c=2*Math.sqrt(1+c-e-b);this.w=(k-g)/c;this.x=0.25*c;this.y=(a+f)/c;this.z=(d+m)/c}else if(e>b){c=2*Math.sqrt(1+e-c-b);this.w=(d-m)/c;this.x=(a+f)/c;this.y=0.25*c;this.z=(g+k)/c}else{c=2*Math.sqrt(1+b-c-e);this.w=(f-a)/c;this.x=
+d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],f=b[1],e=b[5],g=b[9],m=b[2],k=b[6],b=b[10],j=c+e+b;if(j>0){c=0.5/Math.sqrt(j+1);this.w=0.25/c;this.x=(k-g)*c;this.y=(d-m)*c;this.z=(f-a)*c}else if(c>e&&c>b){c=2*Math.sqrt(1+c-e-b);this.w=(k-g)/c;this.x=0.25*c;this.y=(a+f)/c;this.z=(d+m)/c}else if(e>b){c=2*Math.sqrt(1+e-c-b);this.w=(d-m)/c;this.x=(a+f)/c;this.y=0.25*c;this.z=(g+k)/c}else{c=2*Math.sqrt(1+b-c-e);this.w=(f-a)/c;this.x=
 (d+m)/c;this.y=(g+k)/c;this.z=0.25*c}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=this.x*-1;this.y=this.y*-1;this.z=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);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y=
 this.y*a;this.z=this.z*a;this.w=this.w*a}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},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,m=a.z,a=a.w;this.x=b*a+f*e+c*m-d*g;this.y=c*a+f*g+d*e-b*m;this.z=d*a+f*m+b*g-c*e;this.w=f*a-b*e-c*g-d*m;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,
-e=this.x,g=this.y,m=this.z,k=this.w,l=k*c+g*f-m*d,h=k*d+m*c-e*f,n=k*f+e*d-g*c,c=-e*c-g*d-m*f;b.x=l*k+c*-e+h*-m-n*-g;b.y=h*k+c*-g+n*-e-l*-m;b.z=n*k+c*-m+l*-g-h*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,g=e*a.w+c*a.x+d*a.y+f*a.z;if(g<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;g=-g}else this.copy(a);if(g>=1){this.w=e;this.x=c;this.y=d;this.z=f;return this}var m=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.0010){this.w=0.5*(e+this.w);this.x=0.5*(c+this.x);
+e=this.x,g=this.y,m=this.z,k=this.w,j=k*c+g*f-m*d,h=k*d+m*c-e*f,n=k*f+e*d-g*c,c=-e*c-g*d-m*f;b.x=j*k+c*-e+h*-m-n*-g;b.y=h*k+c*-g+n*-e-j*-m;b.z=n*k+c*-m+j*-g-h*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,g=e*a.w+c*a.x+d*a.y+f*a.z;if(g<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;g=-g}else this.copy(a);if(g>=1){this.w=e;this.x=c;this.y=d;this.z=f;return this}var m=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.0010){this.w=0.5*(e+this.w);this.x=0.5*(c+this.x);
 this.y=0.5*(d+this.y);this.z=0.5*(f+this.z);return this}g=Math.sin((1-b)*m)/k;m=Math.sin(b*m)/k;this.w=e*g+this.w*m;this.x=c*g+this.x*m;this.y=d*g+this.y*m;this.z=f*g+this.z*m;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
 THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(f<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;f=-f}else c.copy(b);if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.0010){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}f=Math.sin((1-d)*b)/e;d=Math.sin(d*b)/e;c.w=a.w*f+c.w*d;c.x=a.x*f+c.x*d;c.y=a.y*f+c.y*d;c.z=a.z*f+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")};
 THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3};
@@ -101,9 +102,9 @@ b;a++){c=this.faces[a];d=this.vertices[c.a];f=this.vertices[c.b];e=this.vertices
 else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;
 for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeMorphNormals:function(){var a,b,c,d,f;c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];f.__originalFaceNormal?
 f.__originalFaceNormal.copy(f.normal):f.__originalFaceNormal=f.normal.clone();if(!f.__originalVertexNormals)f.__originalVertexNormals=[];a=0;for(b=f.vertexNormals.length;a<b;a++)f.__originalVertexNormals[a]?f.__originalVertexNormals[a].copy(f.vertexNormals[a]):f.__originalVertexNormals[a]=f.vertexNormals[a].clone()}var e=new THREE.Geometry;e.faces=this.faces;a=0;for(b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]={};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=
-[];var g=this.morphNormals[a].faceNormals,m=this.morphNormals[a].vertexNormals,k,l;c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];k=new THREE.Vector3;l=f instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3};g.push(k);m.push(l)}}g=this.morphNormals[a];e.vertices=this.morphTargets[a].vertices;e.computeFaceNormals();e.computeVertexNormals();c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];
-k=g.faceNormals[c];l=g.vertexNormals[c];k.copy(f.normal);if(f instanceof THREE.Face3){l.a.copy(f.vertexNormals[0]);l.b.copy(f.vertexNormals[1]);l.c.copy(f.vertexNormals[2])}else{l.a.copy(f.vertexNormals[0]);l.b.copy(f.vertexNormals[1]);l.c.copy(f.vertexNormals[2]);l.d.copy(f.vertexNormals[3])}}}c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];f.normal=f.__originalFaceNormal;f.vertexNormals=f.__originalVertexNormals}},computeTangents:function(){function a(a,b,c,d,e,f,L){m=a.vertices[b];k=a.vertices[c];
-l=a.vertices[d];h=g[e];n=g[f];j=g[L];o=k.x-m.x;q=l.x-m.x;i=k.y-m.y;p=l.y-m.y;r=k.z-m.z;s=l.z-m.z;v=n.u-h.u;A=j.u-h.u;w=n.v-h.v;B=j.v-h.v;x=1/(v*B-A*w);D.set((B*o-w*q)*x,(B*i-w*p)*x,(B*r-w*s)*x);H.set((v*q-A*o)*x,(v*p-A*i)*x,(v*s-A*r)*x);u[b].addSelf(D);u[c].addSelf(D);u[d].addSelf(D);z[b].addSelf(H);z[c].addSelf(H);z[d].addSelf(H)}var b,c,d,f,e,g,m,k,l,h,n,j,o,q,i,p,r,s,v,A,w,B,x,F,u=[],z=[],D=new THREE.Vector3,H=new THREE.Vector3,P=new THREE.Vector3,M=new THREE.Vector3,t=new THREE.Vector3;b=0;for(c=
+[];var g=this.morphNormals[a].faceNormals,m=this.morphNormals[a].vertexNormals,k,j;c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];k=new THREE.Vector3;j=f instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3};g.push(k);m.push(j)}}g=this.morphNormals[a];e.vertices=this.morphTargets[a].vertices;e.computeFaceNormals();e.computeVertexNormals();c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];
+k=g.faceNormals[c];j=g.vertexNormals[c];k.copy(f.normal);if(f instanceof THREE.Face3){j.a.copy(f.vertexNormals[0]);j.b.copy(f.vertexNormals[1]);j.c.copy(f.vertexNormals[2])}else{j.a.copy(f.vertexNormals[0]);j.b.copy(f.vertexNormals[1]);j.c.copy(f.vertexNormals[2]);j.d.copy(f.vertexNormals[3])}}}c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];f.normal=f.__originalFaceNormal;f.vertexNormals=f.__originalVertexNormals}},computeTangents:function(){function a(a,b,c,d,e,f,L){m=a.vertices[b];k=a.vertices[c];
+j=a.vertices[d];h=g[e];n=g[f];i=g[L];o=k.x-m.x;q=j.x-m.x;l=k.y-m.y;p=j.y-m.y;r=k.z-m.z;s=j.z-m.z;v=n.u-h.u;A=i.u-h.u;w=n.v-h.v;B=i.v-h.v;x=1/(v*B-A*w);D.set((B*o-w*q)*x,(B*l-w*p)*x,(B*r-w*s)*x);H.set((v*q-A*o)*x,(v*p-A*l)*x,(v*s-A*r)*x);u[b].addSelf(D);u[c].addSelf(D);u[d].addSelf(D);z[b].addSelf(H);z[c].addSelf(H);z[d].addSelf(H)}var b,c,d,f,e,g,m,k,j,h,n,i,o,q,l,p,r,s,v,A,w,B,x,F,u=[],z=[],D=new THREE.Vector3,H=new THREE.Vector3,P=new THREE.Vector3,M=new THREE.Vector3,t=new THREE.Vector3;b=0;for(c=
 this.vertices.length;b<c;b++){u[b]=new THREE.Vector3;z[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){e=this.faces[b];g=this.faceVertexUvs[0][b];if(e instanceof THREE.Face3)a(this,e.a,e.b,e.c,0,1,2);else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.d,0,1,3);a(this,e.b,e.c,e.d,1,2,3)}}var E=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){e=this.faces[b];for(d=0;d<e.vertexNormals.length;d++){t.copy(e.vertexNormals[d]);f=e[E[d]];F=u[f];P.copy(F);P.subSelf(t.multiplyScalar(t.dot(F))).normalize();
 M.cross(e.vertexNormals[d],F);f=M.dot(z[f]);f=f<0?-1:1;e.vertexTangents[d]=new THREE.Vector4(P.x,P.y,P.z,f)}}this.hasTangents=true},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(this.vertices.length>0){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,f=this.vertices.length;d<f;d++){a=this.vertices[d];if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=
 a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}else{this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;c<d;c++){a=this.vertices[c].length();a>b&&(b=a)}this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,g,m;e=0;for(g=this.vertices.length;e<g;e++){d=this.vertices[e];d=[Math.round(d.x*
@@ -120,61 +121,61 @@ THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THRE
 THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:"anonymous",addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ",b=a.total?b+((100*a.loaded/
 a.total).toFixed(0)+"%"):b+((a.loaded/1E3).toFixed(2)+" KB");this.statusDomElement.innerHTML=b},extractUrlBase:function(a){a=a.split("/");a.pop();return(a.length<1?".":a.join("/"))+"/"},initMaterials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(b[d],c)},hasNormals:function(a){var b,c,d=a.materials.length;for(c=0;c<d;c++){b=a.materials[c];if(b instanceof THREE.ShaderMaterial)return true}return false},createMaterial:function(a,b){function c(a){a=
 Math.log(a)/Math.LN2;return Math.floor(a)==a}function d(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))}function f(a,b){var e=new Image;e.onload=function(){if(!c(this.width)||!c(this.height)){var b=d(this.width),e=d(this.height);a.image.width=b;a.image.height=e;a.image.getContext("2d").drawImage(this,0,0,b,e)}else a.image=this;a.needsUpdate=true};e.crossOrigin=m.crossOrigin;e.src=b}function e(a,c,d,e,g,h){var m=document.createElement("canvas");a[c]=new THREE.Texture(m);a[c].sourceFile=
-d;if(e){a[c].repeat.set(e[0],e[1]);if(e[0]!=1)a[c].wrapS=THREE.RepeatWrapping;if(e[1]!=1)a[c].wrapT=THREE.RepeatWrapping}g&&a[c].offset.set(g[0],g[1]);if(h){e={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(e[h[0]]!==void 0)a[c].wrapS=e[h[0]];if(e[h[1]]!==void 0)a[c].wrapT=e[h[1]]}f(a[c],b+"/"+d)}function g(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255}var m=this,k="MeshLambertMaterial",l={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};
-if(a.shading){var h=a.shading.toLowerCase();h==="phong"?k="MeshPhongMaterial":h==="basic"&&(k="MeshBasicMaterial")}if(a.blending!==void 0&&THREE[a.blending]!==void 0)l.blending=THREE[a.blending];if(a.transparent!==void 0||a.opacity<1)l.transparent=a.transparent;if(a.depthTest!==void 0)l.depthTest=a.depthTest;if(a.depthWrite!==void 0)l.depthWrite=a.depthWrite;if(a.vertexColors!==void 0)if(a.vertexColors=="face")l.vertexColors=THREE.FaceColors;else if(a.vertexColors)l.vertexColors=THREE.VertexColors;
-if(a.colorDiffuse)l.color=g(a.colorDiffuse);else if(a.DbgColor)l.color=a.DbgColor;if(a.colorSpecular)l.specular=g(a.colorSpecular);if(a.colorAmbient)l.ambient=g(a.colorAmbient);if(a.transparency)l.opacity=a.transparency;if(a.specularCoef)l.shininess=a.specularCoef;a.mapDiffuse&&b&&e(l,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&e(l,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&e(l,"normalMap",a.mapNormal,a.mapNormalRepeat,
-a.mapNormalOffset,a.mapNormalWrap);a.mapSpecular&&b&&e(l,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){k=THREE.ShaderUtils.lib.normal;h=THREE.UniformsUtils.clone(k.uniforms);h.tNormal.texture=l.normalMap;if(a.mapNormalFactor)h.uNormalScale.value=a.mapNormalFactor;if(l.map){h.tDiffuse.texture=l.map;h.enableDiffuse.value=true}if(l.specularMap){h.tSpecular.texture=l.specularMap;h.enableSpecular.value=true}if(l.lightMap){h.tAO.texture=l.lightMap;
-h.enableAO.value=true}h.uDiffuseColor.value.setHex(l.color);h.uSpecularColor.value.setHex(l.specular);h.uAmbientColor.value.setHex(l.ambient);h.uShininess.value=l.shininess;if(l.opacity!==void 0)h.uOpacity.value=l.opacity;l=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,vertexShader:k.vertexShader,uniforms:h,lights:true,fog:true})}else l=new THREE[k](l);if(a.DbgName!==void 0)l.name=a.DbgName;return l}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};
+d;if(e){a[c].repeat.set(e[0],e[1]);if(e[0]!=1)a[c].wrapS=THREE.RepeatWrapping;if(e[1]!=1)a[c].wrapT=THREE.RepeatWrapping}g&&a[c].offset.set(g[0],g[1]);if(h){e={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(e[h[0]]!==void 0)a[c].wrapS=e[h[0]];if(e[h[1]]!==void 0)a[c].wrapT=e[h[1]]}f(a[c],b+"/"+d)}function g(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255}var m=this,k="MeshLambertMaterial",j={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};
+if(a.shading){var h=a.shading.toLowerCase();h==="phong"?k="MeshPhongMaterial":h==="basic"&&(k="MeshBasicMaterial")}if(a.blending!==void 0&&THREE[a.blending]!==void 0)j.blending=THREE[a.blending];if(a.transparent!==void 0||a.opacity<1)j.transparent=a.transparent;if(a.depthTest!==void 0)j.depthTest=a.depthTest;if(a.depthWrite!==void 0)j.depthWrite=a.depthWrite;if(a.vertexColors!==void 0)if(a.vertexColors=="face")j.vertexColors=THREE.FaceColors;else if(a.vertexColors)j.vertexColors=THREE.VertexColors;
+if(a.colorDiffuse)j.color=g(a.colorDiffuse);else if(a.DbgColor)j.color=a.DbgColor;if(a.colorSpecular)j.specular=g(a.colorSpecular);if(a.colorAmbient)j.ambient=g(a.colorAmbient);if(a.transparency)j.opacity=a.transparency;if(a.specularCoef)j.shininess=a.specularCoef;a.mapDiffuse&&b&&e(j,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&e(j,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&e(j,"normalMap",a.mapNormal,a.mapNormalRepeat,
+a.mapNormalOffset,a.mapNormalWrap);a.mapSpecular&&b&&e(j,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){k=THREE.ShaderUtils.lib.normal;h=THREE.UniformsUtils.clone(k.uniforms);h.tNormal.texture=j.normalMap;if(a.mapNormalFactor)h.uNormalScale.value=a.mapNormalFactor;if(j.map){h.tDiffuse.texture=j.map;h.enableDiffuse.value=true}if(j.specularMap){h.tSpecular.texture=j.specularMap;h.enableSpecular.value=true}if(j.lightMap){h.tAO.texture=j.lightMap;
+h.enableAO.value=true}h.uDiffuseColor.value.setHex(j.color);h.uSpecularColor.value.setHex(j.specular);h.uAmbientColor.value.setHex(j.ambient);h.uShininess.value=j.shininess;if(j.opacity!==void 0)h.uOpacity.value=j.opacity;j=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,vertexShader:k.vertexShader,uniforms:h,lights:true,fog:true})}else j=new THREE[k](j);if(a.DbgName!==void 0)j.name=a.DbgName;return j}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};
 THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.load=function(a,b,c,d){var c=c?c:this.extractUrlBase(a),d=d?d:this.extractUrlBase(a),f=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,f)};
 THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,f,e){var g=new XMLHttpRequest;g.onreadystatechange=function(){if(g.readyState==4)if(g.status==200||g.status==0){var m=JSON.parse(g.responseText);a.loadAjaxBuffers(m,c,f,d,e)}else console.error("THREE.BinaryLoader: Couldn't load ["+b+"] ["+g.status+"]")};g.open("GET",b,true);g.overrideMimeType&&g.overrideMimeType("text/plain; charset=x-user-defined");g.setRequestHeader("Content-Type","text/plain");g.send(null)};
 THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,f){var e=new XMLHttpRequest,g=c+"/"+a.buffers,m=0;e.onreadystatechange=function(){if(e.readyState==4)e.status==200||e.status==0?THREE.BinaryLoader.prototype.createBinModel(e.response,b,d,a.materials):console.error("THREE.BinaryLoader: Couldn't load ["+g+"] ["+e.status+"]");else if(e.readyState==3){if(f){m==0&&(m=e.getResponseHeader("Content-Length"));f({total:m,loaded:e.responseText.length})}}else e.readyState==2&&(m=e.getResponseHeader("Content-Length"))};
 e.open("GET",g,true);e.responseType="arraybuffer";e.send(null)};
-THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var f=function(b){var c,f,k,l,h,n,j,o,q,i,p,r,s,v,A;function w(a){return a%4?4-a%4:0}function B(a,b){return(new Uint8Array(a,b,1))[0]}function x(a,b){return(new Uint32Array(a,b,1))[0]}function F(b,c){var d,e,f,g,h,m,l,k,i=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=i[d*3];f=i[d*3+1];g=i[d*3+2];h=G[e*2];e=G[e*2+1];m=G[f*2];l=G[f*2+1];f=G[g*2];k=G[g*2+1];g=M.faceVertexUvs[0];var j=[];j.push(new THREE.UV(h,e));j.push(new THREE.UV(m,l));j.push(new THREE.UV(f,
-k));g.push(j)}}function u(b,c){var d,e,f,g,h,m,l,k,i,j,n=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=n[d*4];f=n[d*4+1];g=n[d*4+2];h=n[d*4+3];m=G[e*2];e=G[e*2+1];l=G[f*2];i=G[f*2+1];k=G[g*2];j=G[g*2+1];g=G[h*2];f=G[h*2+1];h=M.faceVertexUvs[0];var o=[];o.push(new THREE.UV(m,e));o.push(new THREE.UV(l,i));o.push(new THREE.UV(k,j));o.push(new THREE.UV(g,f));h.push(o)}}function z(b,c,d){for(var e,f,g,h,c=new Uint32Array(a,c,3*b),m=new Uint16Array(a,d,b),d=0;d<b;d++){e=c[d*3];f=c[d*3+1];g=c[d*3+2];h=m[d];
-M.faces.push(new THREE.Face3(e,f,g,null,null,h))}}function D(b,c,d){for(var e,f,g,h,m,c=new Uint32Array(a,c,4*b),l=new Uint16Array(a,d,b),d=0;d<b;d++){e=c[d*4];f=c[d*4+1];g=c[d*4+2];h=c[d*4+3];m=l[d];M.faces.push(new THREE.Face4(e,f,g,h,null,null,m))}}function H(b,c,d,e){for(var f,g,h,m,l,k,i,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),j=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[e*3];g=c[e*3+1];h=c[e*3+2];l=d[e*3];k=d[e*3+1];i=d[e*3+2];m=j[e];var n=E[k*3],o=E[k*3+1];k=E[k*3+2];var p=E[i*3],
-q=E[i*3+1];i=E[i*3+2];M.faces.push(new THREE.Face3(f,g,h,[new THREE.Vector3(E[l*3],E[l*3+1],E[l*3+2]),new THREE.Vector3(n,o,k),new THREE.Vector3(p,q,i)],null,m))}}function P(b,c,d,e){for(var f,g,h,m,l,k,i,j,n,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),o=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[e*4];g=c[e*4+1];h=c[e*4+2];m=c[e*4+3];k=d[e*4];i=d[e*4+1];j=d[e*4+2];n=d[e*4+3];l=o[e];var p=E[i*3],q=E[i*3+1];i=E[i*3+2];var r=E[j*3],t=E[j*3+1];j=E[j*3+2];var s=E[n*3],z=E[n*3+1];n=E[n*3+2];M.faces.push(new THREE.Face4(f,
-g,h,m,[new THREE.Vector3(E[k*3],E[k*3+1],E[k*3+2]),new THREE.Vector3(p,q,i),new THREE.Vector3(r,t,j),new THREE.Vector3(s,z,n)],null,l))}}var M=this,t=0,E=[],G=[],N,Q,O;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(M,d,b);(function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",e=0;e<c;e++)d=d+String.fromCharCode(a[b+e]);return d})(a,t,12);c=B(a,t+12);B(a,t+13);B(a,t+14);B(a,t+15);f=B(a,t+16);k=B(a,t+17);l=B(a,t+18);h=B(a,t+19);n=x(a,t+20);j=x(a,t+20+4);o=x(a,t+20+8);b=x(a,t+20+12);q=
-x(a,t+20+16);i=x(a,t+20+20);p=x(a,t+20+24);r=x(a,t+20+28);s=x(a,t+20+32);v=x(a,t+20+36);A=x(a,t+20+40);t=t+c;c=f*3+h;O=f*4+h;N=b*c;Q=q*(c+k*3);f=i*(c+l*3);h=p*(c+k*3+l*3);c=r*O;k=s*(O+k*4);l=v*(O+l*4);t=t+function(b){var b=new Float32Array(a,b,n*3),c,d,e,f;for(c=0;c<n;c++){d=b[c*3];e=b[c*3+1];f=b[c*3+2];M.vertices.push(new THREE.Vector3(d,e,f))}return n*3*Float32Array.BYTES_PER_ELEMENT}(t);t=t+function(b){if(j){var b=new Int8Array(a,b,j*3),c,d,e,f;for(c=0;c<j;c++){d=b[c*3];e=b[c*3+1];f=b[c*3+2];E.push(d/
-127,e/127,f/127)}}return j*3*Int8Array.BYTES_PER_ELEMENT}(t);t=t+w(j*3);t=t+function(b){if(o){var b=new Float32Array(a,b,o*2),c,d,e;for(c=0;c<o;c++){d=b[c*2];e=b[c*2+1];G.push(d,e)}}return o*2*Float32Array.BYTES_PER_ELEMENT}(t);N=t+N+w(b*2);Q=N+Q+w(q*2);f=Q+f+w(i*2);h=f+h+w(p*2);c=h+c+w(r*2);k=c+k+w(s*2);l=k+l+w(v*2);(function(a){if(i){var b=a+i*Uint32Array.BYTES_PER_ELEMENT*3;z(i,a,b+i*Uint32Array.BYTES_PER_ELEMENT*3);F(i,b)}})(Q);(function(a){if(p){var b=a+p*Uint32Array.BYTES_PER_ELEMENT*3,c=b+
-p*Uint32Array.BYTES_PER_ELEMENT*3;H(p,a,b,c+p*Uint32Array.BYTES_PER_ELEMENT*3);F(p,c)}})(f);(function(a){if(v){var b=a+v*Uint32Array.BYTES_PER_ELEMENT*4;D(v,a,b+v*Uint32Array.BYTES_PER_ELEMENT*4);u(v,b)}})(k);(function(a){if(A){var b=a+A*Uint32Array.BYTES_PER_ELEMENT*4,c=b+A*Uint32Array.BYTES_PER_ELEMENT*4;P(A,a,b,c+A*Uint32Array.BYTES_PER_ELEMENT*4);u(A,c)}})(l);b&&z(b,t,t+b*Uint32Array.BYTES_PER_ELEMENT*3);(function(a){if(q){var b=a+q*Uint32Array.BYTES_PER_ELEMENT*3;H(q,a,b,b+q*Uint32Array.BYTES_PER_ELEMENT*
+THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var f=function(b){var c,f,k,j,h,n,i,o,q,l,p,r,s,v,A;function w(a){return a%4?4-a%4:0}function B(a,b){return(new Uint8Array(a,b,1))[0]}function x(a,b){return(new Uint32Array(a,b,1))[0]}function F(b,c){var d,e,f,g,h,m,j,k,l=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=l[d*3];f=l[d*3+1];g=l[d*3+2];h=G[e*2];e=G[e*2+1];m=G[f*2];j=G[f*2+1];f=G[g*2];k=G[g*2+1];g=M.faceVertexUvs[0];var i=[];i.push(new THREE.UV(h,e));i.push(new THREE.UV(m,j));i.push(new THREE.UV(f,
+k));g.push(i)}}function u(b,c){var d,e,f,g,h,m,j,k,l,i,n=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=n[d*4];f=n[d*4+1];g=n[d*4+2];h=n[d*4+3];m=G[e*2];e=G[e*2+1];j=G[f*2];l=G[f*2+1];k=G[g*2];i=G[g*2+1];g=G[h*2];f=G[h*2+1];h=M.faceVertexUvs[0];var o=[];o.push(new THREE.UV(m,e));o.push(new THREE.UV(j,l));o.push(new THREE.UV(k,i));o.push(new THREE.UV(g,f));h.push(o)}}function z(b,c,d){for(var e,f,g,h,c=new Uint32Array(a,c,3*b),m=new Uint16Array(a,d,b),d=0;d<b;d++){e=c[d*3];f=c[d*3+1];g=c[d*3+2];h=m[d];
+M.faces.push(new THREE.Face3(e,f,g,null,null,h))}}function D(b,c,d){for(var e,f,g,h,m,c=new Uint32Array(a,c,4*b),j=new Uint16Array(a,d,b),d=0;d<b;d++){e=c[d*4];f=c[d*4+1];g=c[d*4+2];h=c[d*4+3];m=j[d];M.faces.push(new THREE.Face4(e,f,g,h,null,null,m))}}function H(b,c,d,e){for(var f,g,h,m,j,k,l,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),i=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[e*3];g=c[e*3+1];h=c[e*3+2];j=d[e*3];k=d[e*3+1];l=d[e*3+2];m=i[e];var n=E[k*3],o=E[k*3+1];k=E[k*3+2];var p=E[l*3],
+q=E[l*3+1];l=E[l*3+2];M.faces.push(new THREE.Face3(f,g,h,[new THREE.Vector3(E[j*3],E[j*3+1],E[j*3+2]),new THREE.Vector3(n,o,k),new THREE.Vector3(p,q,l)],null,m))}}function P(b,c,d,e){for(var f,g,h,m,j,k,l,i,n,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),o=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[e*4];g=c[e*4+1];h=c[e*4+2];m=c[e*4+3];k=d[e*4];l=d[e*4+1];i=d[e*4+2];n=d[e*4+3];j=o[e];var p=E[l*3],q=E[l*3+1];l=E[l*3+2];var r=E[i*3],s=E[i*3+1];i=E[i*3+2];var t=E[n*3],z=E[n*3+1];n=E[n*3+2];M.faces.push(new THREE.Face4(f,
+g,h,m,[new THREE.Vector3(E[k*3],E[k*3+1],E[k*3+2]),new THREE.Vector3(p,q,l),new THREE.Vector3(r,s,i),new THREE.Vector3(t,z,n)],null,j))}}var M=this,t=0,E=[],G=[],N,Q,O;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(M,d,b);(function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",e=0;e<c;e++)d=d+String.fromCharCode(a[b+e]);return d})(a,t,12);c=B(a,t+12);B(a,t+13);B(a,t+14);B(a,t+15);f=B(a,t+16);k=B(a,t+17);j=B(a,t+18);h=B(a,t+19);n=x(a,t+20);i=x(a,t+20+4);o=x(a,t+20+8);b=x(a,t+20+12);q=
+x(a,t+20+16);l=x(a,t+20+20);p=x(a,t+20+24);r=x(a,t+20+28);s=x(a,t+20+32);v=x(a,t+20+36);A=x(a,t+20+40);t=t+c;c=f*3+h;O=f*4+h;N=b*c;Q=q*(c+k*3);f=l*(c+j*3);h=p*(c+k*3+j*3);c=r*O;k=s*(O+k*4);j=v*(O+j*4);t=t+function(b){var b=new Float32Array(a,b,n*3),c,d,e,f;for(c=0;c<n;c++){d=b[c*3];e=b[c*3+1];f=b[c*3+2];M.vertices.push(new THREE.Vector3(d,e,f))}return n*3*Float32Array.BYTES_PER_ELEMENT}(t);t=t+function(b){if(i){var b=new Int8Array(a,b,i*3),c,d,e,f;for(c=0;c<i;c++){d=b[c*3];e=b[c*3+1];f=b[c*3+2];E.push(d/
+127,e/127,f/127)}}return i*3*Int8Array.BYTES_PER_ELEMENT}(t);t=t+w(i*3);t=t+function(b){if(o){var b=new Float32Array(a,b,o*2),c,d,e;for(c=0;c<o;c++){d=b[c*2];e=b[c*2+1];G.push(d,e)}}return o*2*Float32Array.BYTES_PER_ELEMENT}(t);N=t+N+w(b*2);Q=N+Q+w(q*2);f=Q+f+w(l*2);h=f+h+w(p*2);c=h+c+w(r*2);k=c+k+w(s*2);j=k+j+w(v*2);(function(a){if(l){var b=a+l*Uint32Array.BYTES_PER_ELEMENT*3;z(l,a,b+l*Uint32Array.BYTES_PER_ELEMENT*3);F(l,b)}})(Q);(function(a){if(p){var b=a+p*Uint32Array.BYTES_PER_ELEMENT*3,c=b+
+p*Uint32Array.BYTES_PER_ELEMENT*3;H(p,a,b,c+p*Uint32Array.BYTES_PER_ELEMENT*3);F(p,c)}})(f);(function(a){if(v){var b=a+v*Uint32Array.BYTES_PER_ELEMENT*4;D(v,a,b+v*Uint32Array.BYTES_PER_ELEMENT*4);u(v,b)}})(k);(function(a){if(A){var b=a+A*Uint32Array.BYTES_PER_ELEMENT*4,c=b+A*Uint32Array.BYTES_PER_ELEMENT*4;P(A,a,b,c+A*Uint32Array.BYTES_PER_ELEMENT*4);u(A,c)}})(j);b&&z(b,t,t+b*Uint32Array.BYTES_PER_ELEMENT*3);(function(a){if(q){var b=a+q*Uint32Array.BYTES_PER_ELEMENT*3;H(q,a,b,b+q*Uint32Array.BYTES_PER_ELEMENT*
 3)}})(N);r&&D(r,h,h+r*Uint32Array.BYTES_PER_ELEMENT*4);(function(a){if(s){var b=a+s*Uint32Array.BYTES_PER_ELEMENT*4;P(s,a,b,b+s*Uint32Array.BYTES_PER_ELEMENT*4)}})(c);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))};THREE.ImageLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
 THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){b.dispatchEvent({type:"load",content:c})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;
 THREE.JSONLoader.prototype.load=function(a,b,c){c=c?c:this.extractUrlBase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)};
 THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,f){var e=new XMLHttpRequest,g=0;e.onreadystatechange=function(){if(e.readyState===e.DONE)if(e.status===200||e.status===0){if(e.responseText){var m=JSON.parse(e.responseText);a.createModel(m,c,d)}else console.warn("THREE.JSONLoader: ["+b+"] seems to be unreachable or file there is empty");a.onLoadComplete()}else console.error("THREE.JSONLoader: Couldn't load ["+b+"] ["+e.status+"]");else if(e.readyState===e.LOADING){if(f){g===0&&(g=e.getResponseHeader("Content-Length"));
 f({total:g,loaded:e.responseText.length})}}else e.readyState===e.HEADERS_RECEIVED&&(g=e.getResponseHeader("Content-Length"))};e.open("GET",b,true);e.overrideMimeType&&e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)};
-THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;this.initMaterials(d,a.materials,c);(function(b){var c,f,k,l,h,n,j,o,q,i,p,r,s,v,A=a.faces;n=a.vertices;var w=a.normals,B=a.colors,x=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&x++;for(c=0;c<x;c++){d.faceUvs[c]=[];d.faceVertexUvs[c]=[]}l=0;for(h=n.length;l<h;){j=new THREE.Vector3;j.x=n[l++]*b;j.y=n[l++]*b;j.z=n[l++]*b;d.vertices.push(j)}l=0;for(h=A.length;l<h;){b=A[l++];n=b&1;k=b&2;c=b&
-4;f=b&8;o=b&16;j=b&32;i=b&64;b=b&128;if(n){p=new THREE.Face4;p.a=A[l++];p.b=A[l++];p.c=A[l++];p.d=A[l++];n=4}else{p=new THREE.Face3;p.a=A[l++];p.b=A[l++];p.c=A[l++];n=3}if(k){k=A[l++];p.materialIndex=k}k=d.faces.length;if(c)for(c=0;c<x;c++){r=a.uvs[c];q=A[l++];v=r[q*2];q=r[q*2+1];d.faceUvs[c][k]=new THREE.UV(v,q)}if(f)for(c=0;c<x;c++){r=a.uvs[c];s=[];for(f=0;f<n;f++){q=A[l++];v=r[q*2];q=r[q*2+1];s[f]=new THREE.UV(v,q)}d.faceVertexUvs[c][k]=s}if(o){o=A[l++]*3;f=new THREE.Vector3;f.x=w[o++];f.y=w[o++];
-f.z=w[o];p.normal=f}if(j)for(c=0;c<n;c++){o=A[l++]*3;f=new THREE.Vector3;f.x=w[o++];f.y=w[o++];f.z=w[o];p.vertexNormals.push(f)}if(i){j=A[l++];j=new THREE.Color(B[j]);p.color=j}if(b)for(c=0;c<n;c++){j=A[l++];j=new THREE.Color(B[j]);p.vertexColors.push(j)}d.faces.push(p)}})(f);(function(){var b,c,f,k;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b=b+2){f=a.skinWeights[b];k=a.skinWeights[b+1];d.skinWeights.push(new THREE.Vector4(f,k,0,0))}}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b=
-b+2){f=a.skinIndices[b];k=a.skinIndices[b+1];d.skinIndices.push(new THREE.Vector4(f,k,0,0))}}d.bones=a.bones;d.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,f,k,l,h,n;c=0;for(f=a.morphTargets.length;c<f;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];h=d.morphTargets[c].vertices;n=a.morphTargets[c].vertices;k=0;for(l=n.length;k<l;k=k+3){var j=new THREE.Vector3;j.x=n[k]*b;j.y=n[k+1]*b;j.z=n[k+2]*b;h.push(j)}}}if(a.morphColors!==
-void 0){c=0;for(f=a.morphColors.length;c<f;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];l=d.morphColors[c].colors;h=a.morphColors[c].colors;b=0;for(k=h.length;b<k;b=b+3){n=new THREE.Color(16755200);n.setRGB(h[b],h[b+1],h[b+2]);l.push(n)}}}})(f);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&d.computeTangents();b(d)};THREE.GeometryLoader=function(){THREE.EventTarget.call(this);this.path=this.crossOrigin=null};
+THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;this.initMaterials(d,a.materials,c);(function(b){var c,f,k,j,h,n,i,o,q,l,p,r,s,v,A=a.faces;n=a.vertices;var w=a.normals,B=a.colors,x=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&x++;for(c=0;c<x;c++){d.faceUvs[c]=[];d.faceVertexUvs[c]=[]}j=0;for(h=n.length;j<h;){i=new THREE.Vector3;i.x=n[j++]*b;i.y=n[j++]*b;i.z=n[j++]*b;d.vertices.push(i)}j=0;for(h=A.length;j<h;){b=A[j++];n=b&1;k=b&2;c=b&
+4;f=b&8;o=b&16;i=b&32;l=b&64;b=b&128;if(n){p=new THREE.Face4;p.a=A[j++];p.b=A[j++];p.c=A[j++];p.d=A[j++];n=4}else{p=new THREE.Face3;p.a=A[j++];p.b=A[j++];p.c=A[j++];n=3}if(k){k=A[j++];p.materialIndex=k}k=d.faces.length;if(c)for(c=0;c<x;c++){r=a.uvs[c];q=A[j++];v=r[q*2];q=r[q*2+1];d.faceUvs[c][k]=new THREE.UV(v,q)}if(f)for(c=0;c<x;c++){r=a.uvs[c];s=[];for(f=0;f<n;f++){q=A[j++];v=r[q*2];q=r[q*2+1];s[f]=new THREE.UV(v,q)}d.faceVertexUvs[c][k]=s}if(o){o=A[j++]*3;f=new THREE.Vector3;f.x=w[o++];f.y=w[o++];
+f.z=w[o];p.normal=f}if(i)for(c=0;c<n;c++){o=A[j++]*3;f=new THREE.Vector3;f.x=w[o++];f.y=w[o++];f.z=w[o];p.vertexNormals.push(f)}if(l){i=A[j++];i=new THREE.Color(B[i]);p.color=i}if(b)for(c=0;c<n;c++){i=A[j++];i=new THREE.Color(B[i]);p.vertexColors.push(i)}d.faces.push(p)}})(f);(function(){var b,c,f,k;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b=b+2){f=a.skinWeights[b];k=a.skinWeights[b+1];d.skinWeights.push(new THREE.Vector4(f,k,0,0))}}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b=
+b+2){f=a.skinIndices[b];k=a.skinIndices[b+1];d.skinIndices.push(new THREE.Vector4(f,k,0,0))}}d.bones=a.bones;d.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,f,k,j,h,n;c=0;for(f=a.morphTargets.length;c<f;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];h=d.morphTargets[c].vertices;n=a.morphTargets[c].vertices;k=0;for(j=n.length;k<j;k=k+3){var i=new THREE.Vector3;i.x=n[k]*b;i.y=n[k+1]*b;i.z=n[k+2]*b;h.push(i)}}}if(a.morphColors!==
+void 0){c=0;for(f=a.morphColors.length;c<f;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];j=d.morphColors[c].colors;h=a.morphColors[c].colors;b=0;for(k=h.length;b<k;b=b+3){n=new THREE.Color(16755200);n.setRGB(h[b],h[b+1],h[b+2]);j.push(n)}}}})(f);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&d.computeTangents();b(d)};THREE.GeometryLoader=function(){THREE.EventTarget.call(this);this.path=this.crossOrigin=null};
 THREE.GeometryLoader.prototype={constructor:THREE.GeometryLoader,load:function(a){var b=this,c=null;if(b.path===null){var d=a.split("/");d.pop();b.path=d.length<1?".":d.join("/")}d=new XMLHttpRequest;d.addEventListener("load",function(d){d.target.responseText?c=b.parse(JSON.parse(d.target.responseText),f):b.dispatchEvent({type:"error",message:"Invalid file ["+a+"]"})},false);d.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);d.open("GET",
-a,true);d.send(null);var f=new THREE.LoadingMonitor;f.addEventListener("load",function(){b.dispatchEvent({type:"load",content:c})});f.add(d)},parse:function(a,b){var c=this,d=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;if(a.materials){d.materials=[];for(var e=0;e<a.materials.length;++e){var g=a.materials[e],m=function(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==a},k=function(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))},l=function(a,d,e,f,g,h){a[d]=new THREE.Texture;a[d].sourceFile=
-e;if(f){a[d].repeat.set(f[0],f[1]);if(f[0]!=1)a[d].wrapS=THREE.RepeatWrapping;if(f[1]!=1)a[d].wrapT=THREE.RepeatWrapping}g&&a[d].offset.set(g[0],g[1]);if(h){f={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(f[h[0]]!==void 0)a[d].wrapS=f[h[0]];if(f[h[1]]!==void 0)a[d].wrapT=f[h[1]]}var l=a[d],a=new THREE.ImageLoader;a.addEventListener("load",function(a){a=a.content;if(!m(a.width)||!m(a.height)){var b=k(a.width),c=k(a.height);l.image=document.createElement("canvas");l.image.width=
-b;l.image.height=c;l.image.getContext("2d").drawImage(a,0,0,b,c)}else l.image=a;l.needsUpdate=true});a.crossOrigin=c.crossOrigin;a.load(c.path+"/"+e);b&&b.add(a)},h=function(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255},n="MeshLambertMaterial",j={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:g.wireframe};if(g.shading){var o=g.shading.toLowerCase();o==="phong"?n="MeshPhongMaterial":o==="basic"&&(n="MeshBasicMaterial")}if(g.blending!==void 0&&THREE[g.blending]!==void 0)j.blending=
-THREE[g.blending];if(g.transparent!==void 0||g.opacity<1)j.transparent=g.transparent;if(g.depthTest!==void 0)j.depthTest=g.depthTest;if(g.depthWrite!==void 0)j.depthWrite=g.depthWrite;if(g.vertexColors!==void 0)if(g.vertexColors=="face")j.vertexColors=THREE.FaceColors;else if(g.vertexColors)j.vertexColors=THREE.VertexColors;if(g.colorDiffuse)j.color=h(g.colorDiffuse);else if(g.DbgColor)j.color=g.DbgColor;if(g.colorSpecular)j.specular=h(g.colorSpecular);if(g.colorAmbient)j.ambient=h(g.colorAmbient);
-if(g.transparency)j.opacity=g.transparency;if(g.specularCoef)j.shininess=g.specularCoef;g.mapDiffuse&&l(j,"map",g.mapDiffuse,g.mapDiffuseRepeat,g.mapDiffuseOffset,g.mapDiffuseWrap);g.mapLight&&l(j,"lightMap",g.mapLight,g.mapLightRepeat,g.mapLightOffset,g.mapLightWrap);g.mapNormal&&l(j,"normalMap",g.mapNormal,g.mapNormalRepeat,g.mapNormalOffset,g.mapNormalWrap);g.mapSpecular&&l(j,"specularMap",g.mapSpecular,g.mapSpecularRepeat,g.mapSpecularOffset,g.mapSpecularWrap);if(g.mapNormal){l=THREE.ShaderUtils.lib.normal;
-h=THREE.UniformsUtils.clone(l.uniforms);h.tNormal.texture=j.normalMap;if(g.mapNormalFactor)h.uNormalScale.value=g.mapNormalFactor;if(j.map){h.tDiffuse.texture=j.map;h.enableDiffuse.value=true}if(j.specularMap){h.tSpecular.texture=j.specularMap;h.enableSpecular.value=true}if(j.lightMap){h.tAO.texture=j.lightMap;h.enableAO.value=true}h.uDiffuseColor.value.setHex(j.color);h.uSpecularColor.value.setHex(j.specular);h.uAmbientColor.value.setHex(j.ambient);h.uShininess.value=j.shininess;if(j.opacity!==void 0)h.uOpacity.value=
-j.opacity;j=new THREE.ShaderMaterial({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:h,lights:true,fog:true})}else j=new THREE[n](j);if(g.DbgName!==void 0)j.name=g.DbgName;d.materials[e]=j}}var g=a.faces,q=a.vertices,j=a.normals,l=a.colors,h=0;if(a.uvs)for(e=0;e<a.uvs.length;e++)a.uvs[e].length&&h++;for(e=0;e<h;e++){d.faceUvs[e]=[];d.faceVertexUvs[e]=[]}n=0;for(o=q.length;n<o;){var i=new THREE.Vector3;i.x=q[n++]*f;i.y=q[n++]*f;i.z=q[n++]*f;d.vertices.push(i)}n=0;for(o=g.length;n<
-o;){var p=g[n++],r=p&2,e=p&4,s=p&8,v=p&16,q=p&32,A=p&64,i=p&128;if(p&1){p=new THREE.Face4;p.a=g[n++];p.b=g[n++];p.c=g[n++];p.d=g[n++];var w=4}else{p=new THREE.Face3;p.a=g[n++];p.b=g[n++];p.c=g[n++];w=3}if(r){r=g[n++];p.materialIndex=r}var B=d.faces.length;if(e)for(e=0;e<h;e++){var x=a.uvs[e],r=g[n++],F=x[r*2],r=x[r*2+1];d.faceUvs[e][B]=new THREE.UV(F,r)}if(s)for(e=0;e<h;e++){for(var x=a.uvs[e],s=[],u=0;u<w;u++){r=g[n++];F=x[r*2];r=x[r*2+1];s[u]=new THREE.UV(F,r)}d.faceVertexUvs[e][B]=s}if(v){v=g[n++]*
-3;r=new THREE.Vector3;r.x=j[v++];r.y=j[v++];r.z=j[v];p.normal=r}if(q)for(e=0;e<w;e++){v=g[n++]*3;r=new THREE.Vector3;r.x=j[v++];r.y=j[v++];r.z=j[v];p.vertexNormals.push(r)}if(A){q=g[n++];p.color=new THREE.Color(l[q])}if(i)for(e=0;e<w;e++){q=g[n++];p.vertexColors.push(new THREE.Color(l[q]))}d.faces.push(p)}if(a.skinWeights){e=0;for(g=a.skinWeights.length;e<g;e=e+2)d.skinWeights.push(new THREE.Vector4(a.skinWeights[e],a.skinWeights[e+1],0,0))}if(a.skinIndices){e=0;for(g=a.skinIndices.length;e<g;e=e+
-2){j=0;d.skinIndices.push(new THREE.Vector4(a.skinIndices[e],a.skinIndices[e+1],j,0))}}d.bones=a.bones;d.animation=a.animation;if(a.morphTargets){e=0;for(g=a.morphTargets.length;e<g;e++){d.morphTargets[e]={};d.morphTargets[e].name=a.morphTargets[e].name;d.morphTargets[e].vertices=[];j=d.morphTargets[e].vertices;l=a.morphTargets[e].vertices;r=0;for(h=l.length;r<h;r=r+3){i=new THREE.Vector3;i.x=l[r]*f;i.y=l[r+1]*f;i.z=l[r+2]*f;j.push(i)}}}if(a.morphColors){e=0;for(g=a.morphColors.length;e<g;e++){d.morphColors[e]=
-{};d.morphColors[e].name=a.morphColors[e].name;d.morphColors[e].colors=[];f=d.morphColors[e].colors;l=a.morphColors[e].colors;j=0;for(h=l.length;j<h;j=j+3){n=new THREE.Color(16755200);n.setRGB(l[j],l[j+1],l[j+2]);f.push(n)}}}d.computeCentroids();d.computeFaceNormals();return d}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
+a,true);d.send(null);var f=new THREE.LoadingMonitor;f.addEventListener("load",function(){b.dispatchEvent({type:"load",content:c})});f.add(d)},parse:function(a,b){var c=this,d=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;if(a.materials){d.materials=[];for(var e=0;e<a.materials.length;++e){var g=a.materials[e],m=function(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==a},k=function(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))},j=function(a,d,e,f,g,h){a[d]=new THREE.Texture;a[d].sourceFile=
+e;if(f){a[d].repeat.set(f[0],f[1]);if(f[0]!=1)a[d].wrapS=THREE.RepeatWrapping;if(f[1]!=1)a[d].wrapT=THREE.RepeatWrapping}g&&a[d].offset.set(g[0],g[1]);if(h){f={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(f[h[0]]!==void 0)a[d].wrapS=f[h[0]];if(f[h[1]]!==void 0)a[d].wrapT=f[h[1]]}var j=a[d],a=new THREE.ImageLoader;a.addEventListener("load",function(a){a=a.content;if(!m(a.width)||!m(a.height)){var b=k(a.width),c=k(a.height);j.image=document.createElement("canvas");j.image.width=
+b;j.image.height=c;j.image.getContext("2d").drawImage(a,0,0,b,c)}else j.image=a;j.needsUpdate=true});a.crossOrigin=c.crossOrigin;a.load(c.path+"/"+e);b&&b.add(a)},h=function(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255},n="MeshLambertMaterial",i={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:g.wireframe};if(g.shading){var o=g.shading.toLowerCase();o==="phong"?n="MeshPhongMaterial":o==="basic"&&(n="MeshBasicMaterial")}if(g.blending!==void 0&&THREE[g.blending]!==void 0)i.blending=
+THREE[g.blending];if(g.transparent!==void 0||g.opacity<1)i.transparent=g.transparent;if(g.depthTest!==void 0)i.depthTest=g.depthTest;if(g.depthWrite!==void 0)i.depthWrite=g.depthWrite;if(g.vertexColors!==void 0)if(g.vertexColors=="face")i.vertexColors=THREE.FaceColors;else if(g.vertexColors)i.vertexColors=THREE.VertexColors;if(g.colorDiffuse)i.color=h(g.colorDiffuse);else if(g.DbgColor)i.color=g.DbgColor;if(g.colorSpecular)i.specular=h(g.colorSpecular);if(g.colorAmbient)i.ambient=h(g.colorAmbient);
+if(g.transparency)i.opacity=g.transparency;if(g.specularCoef)i.shininess=g.specularCoef;g.mapDiffuse&&j(i,"map",g.mapDiffuse,g.mapDiffuseRepeat,g.mapDiffuseOffset,g.mapDiffuseWrap);g.mapLight&&j(i,"lightMap",g.mapLight,g.mapLightRepeat,g.mapLightOffset,g.mapLightWrap);g.mapNormal&&j(i,"normalMap",g.mapNormal,g.mapNormalRepeat,g.mapNormalOffset,g.mapNormalWrap);g.mapSpecular&&j(i,"specularMap",g.mapSpecular,g.mapSpecularRepeat,g.mapSpecularOffset,g.mapSpecularWrap);if(g.mapNormal){j=THREE.ShaderUtils.lib.normal;
+h=THREE.UniformsUtils.clone(j.uniforms);h.tNormal.texture=i.normalMap;if(g.mapNormalFactor)h.uNormalScale.value=g.mapNormalFactor;if(i.map){h.tDiffuse.texture=i.map;h.enableDiffuse.value=true}if(i.specularMap){h.tSpecular.texture=i.specularMap;h.enableSpecular.value=true}if(i.lightMap){h.tAO.texture=i.lightMap;h.enableAO.value=true}h.uDiffuseColor.value.setHex(i.color);h.uSpecularColor.value.setHex(i.specular);h.uAmbientColor.value.setHex(i.ambient);h.uShininess.value=i.shininess;if(i.opacity!==void 0)h.uOpacity.value=
+i.opacity;i=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:h,lights:true,fog:true})}else i=new THREE[n](i);if(g.DbgName!==void 0)i.name=g.DbgName;d.materials[e]=i}}var g=a.faces,q=a.vertices,i=a.normals,j=a.colors,h=0;if(a.uvs)for(e=0;e<a.uvs.length;e++)a.uvs[e].length&&h++;for(e=0;e<h;e++){d.faceUvs[e]=[];d.faceVertexUvs[e]=[]}n=0;for(o=q.length;n<o;){var l=new THREE.Vector3;l.x=q[n++]*f;l.y=q[n++]*f;l.z=q[n++]*f;d.vertices.push(l)}n=0;for(o=g.length;n<
+o;){var p=g[n++],r=p&2,e=p&4,s=p&8,v=p&16,q=p&32,A=p&64,l=p&128;if(p&1){p=new THREE.Face4;p.a=g[n++];p.b=g[n++];p.c=g[n++];p.d=g[n++];var w=4}else{p=new THREE.Face3;p.a=g[n++];p.b=g[n++];p.c=g[n++];w=3}if(r){r=g[n++];p.materialIndex=r}var B=d.faces.length;if(e)for(e=0;e<h;e++){var x=a.uvs[e],r=g[n++],F=x[r*2],r=x[r*2+1];d.faceUvs[e][B]=new THREE.UV(F,r)}if(s)for(e=0;e<h;e++){for(var x=a.uvs[e],s=[],u=0;u<w;u++){r=g[n++];F=x[r*2];r=x[r*2+1];s[u]=new THREE.UV(F,r)}d.faceVertexUvs[e][B]=s}if(v){v=g[n++]*
+3;r=new THREE.Vector3;r.x=i[v++];r.y=i[v++];r.z=i[v];p.normal=r}if(q)for(e=0;e<w;e++){v=g[n++]*3;r=new THREE.Vector3;r.x=i[v++];r.y=i[v++];r.z=i[v];p.vertexNormals.push(r)}if(A){q=g[n++];p.color=new THREE.Color(j[q])}if(l)for(e=0;e<w;e++){q=g[n++];p.vertexColors.push(new THREE.Color(j[q]))}d.faces.push(p)}if(a.skinWeights){e=0;for(g=a.skinWeights.length;e<g;e=e+2)d.skinWeights.push(new THREE.Vector4(a.skinWeights[e],a.skinWeights[e+1],0,0))}if(a.skinIndices){e=0;for(g=a.skinIndices.length;e<g;e=e+
+2){i=0;d.skinIndices.push(new THREE.Vector4(a.skinIndices[e],a.skinIndices[e+1],i,0))}}d.bones=a.bones;d.animation=a.animation;if(a.morphTargets){e=0;for(g=a.morphTargets.length;e<g;e++){d.morphTargets[e]={};d.morphTargets[e].name=a.morphTargets[e].name;d.morphTargets[e].vertices=[];i=d.morphTargets[e].vertices;j=a.morphTargets[e].vertices;r=0;for(h=j.length;r<h;r=r+3){l=new THREE.Vector3;l.x=j[r]*f;l.y=j[r+1]*f;l.z=j[r+2]*f;i.push(l)}}}if(a.morphColors){e=0;for(g=a.morphColors.length;e<g;e++){d.morphColors[e]=
+{};d.morphColors[e].name=a.morphColors[e].name;d.morphColors[e].colors=[];f=d.morphColors[e].colors;j=a.morphColors[e].colors;i=0;for(h=j.length;i<h;i=i+3){n=new THREE.Color(16755200);n.setRGB(j[i],j[i+1],j[i+2]);f.push(n)}}}d.computeCentroids();d.computeFaceNormals();return d}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
 THREE.SceneLoader.prototype.constructor=THREE.SceneLoader;
 THREE.SceneLoader.prototype.load=function(a,b){var c=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(d.readyState===4)if(d.status===200||d.status===0){var f=JSON.parse(d.responseText);c.createScene(f,b,a)}else console.error("THREE.SceneLoader: Couldn't load ["+a+"] ["+d.status+"]")};d.open("GET",a,true);d.overrideMimeType&&d.overrideMimeType("text/plain; charset=x-user-defined");d.setRequestHeader("Content-Type","text/plain");d.send(null)};
-THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:l+"/"+a}function f(){var a;for(j in t.objects)if(!y.objects[j]){r=t.objects[j];if(r.geometry!==void 0){if(D=y.geometries[r.geometry]){a=false;H=y.materials[r.materials[0]];(a=H instanceof THREE.ShaderMaterial)&&D.computeTangents();w=r.position;B=r.rotation;x=r.quaternion;F=r.scale;s=r.matrix;x=0;r.materials.length==0&&(H=new THREE.MeshFaceMaterial);r.materials.length>1&&(H=new THREE.MeshFaceMaterial);
-a=new THREE.Mesh(D,H);a.name=j;if(s){a.matrixAutoUpdate=false;a.matrix.set(s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11],s[12],s[13],s[14],s[15])}else{a.position.set(w[0],w[1],w[2]);if(x){a.quaternion.set(x[0],x[1],x[2],x[3]);a.useQuaternion=true}else a.rotation.set(B[0],B[1],B[2]);a.scale.set(F[0],F[1],F[2])}a.visible=r.visible;a.doubleSided=r.doubleSided;a.castShadow=r.castShadow;a.receiveShadow=r.receiveShadow;y.scene.add(a);y.objects[j]=a}}else{w=r.position;B=r.rotation;x=r.quaternion;
-F=r.scale;x=0;a=new THREE.Object3D;a.name=j;a.position.set(w[0],w[1],w[2]);if(x){a.quaternion.set(x[0],x[1],x[2],x[3]);a.useQuaternion=true}else a.rotation.set(B[0],B[1],B[2]);a.scale.set(F[0],F[1],F[2]);a.visible=r.visible!==void 0?r.visible:false;y.scene.add(a);y.objects[j]=a;y.empties[j]=a}}}function e(a){return function(b){y.geometries[a]=b;f();G=G-1;k.onLoadComplete();m()}}function g(a){return function(b){y.geometries[a]=b}}function m(){k.callbackProgress({totalModels:Q,totalTextures:O,loadedModels:Q-
-G,loadedTextures:O-N},y);k.onLoadProgress();G===0&&N===0&&b(y)}var k=this,l=THREE.Loader.prototype.extractUrlBase(c),h,n,j,o,q,i,p,r,s,v,A,w,B,x,F,u,z,D,H,P,M,t,E,G,N,Q,O,y;t=a;c=new THREE.BinaryLoader;E=new THREE.JSONLoader;N=G=0;y={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(t.transform){a=t.transform.position;v=t.transform.rotation;u=t.transform.scale;a&&y.scene.position.set(a[0],a[1],a[2]);v&&y.scene.rotation.set(v[0],v[1],
+THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:j+"/"+a}function f(){var a;for(i in t.objects)if(!y.objects[i]){r=t.objects[i];if(r.geometry!==void 0){if(D=y.geometries[r.geometry]){a=false;H=y.materials[r.materials[0]];(a=H instanceof THREE.ShaderMaterial)&&D.computeTangents();w=r.position;B=r.rotation;x=r.quaternion;F=r.scale;s=r.matrix;x=0;r.materials.length==0&&(H=new THREE.MeshFaceMaterial);r.materials.length>1&&(H=new THREE.MeshFaceMaterial);
+a=new THREE.Mesh(D,H);a.name=i;if(s){a.matrixAutoUpdate=false;a.matrix.set(s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11],s[12],s[13],s[14],s[15])}else{a.position.set(w[0],w[1],w[2]);if(x){a.quaternion.set(x[0],x[1],x[2],x[3]);a.useQuaternion=true}else a.rotation.set(B[0],B[1],B[2]);a.scale.set(F[0],F[1],F[2])}a.visible=r.visible;a.doubleSided=r.doubleSided;a.castShadow=r.castShadow;a.receiveShadow=r.receiveShadow;y.scene.add(a);y.objects[i]=a}}else{w=r.position;B=r.rotation;x=r.quaternion;
+F=r.scale;x=0;a=new THREE.Object3D;a.name=i;a.position.set(w[0],w[1],w[2]);if(x){a.quaternion.set(x[0],x[1],x[2],x[3]);a.useQuaternion=true}else a.rotation.set(B[0],B[1],B[2]);a.scale.set(F[0],F[1],F[2]);a.visible=r.visible!==void 0?r.visible:false;y.scene.add(a);y.objects[i]=a;y.empties[i]=a}}}function e(a){return function(b){y.geometries[a]=b;f();G=G-1;k.onLoadComplete();m()}}function g(a){return function(b){y.geometries[a]=b}}function m(){k.callbackProgress({totalModels:Q,totalTextures:O,loadedModels:Q-
+G,loadedTextures:O-N},y);k.onLoadProgress();G===0&&N===0&&b(y)}var k=this,j=THREE.Loader.prototype.extractUrlBase(c),h,n,i,o,q,l,p,r,s,v,A,w,B,x,F,u,z,D,H,P,M,t,E,G,N,Q,O,y;t=a;c=new THREE.BinaryLoader;E=new THREE.JSONLoader;N=G=0;y={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(t.transform){a=t.transform.position;v=t.transform.rotation;u=t.transform.scale;a&&y.scene.position.set(a[0],a[1],a[2]);v&&y.scene.rotation.set(v[0],v[1],
 v[2]);u&&y.scene.scale.set(u[0],u[1],u[2]);if(a||v||u){y.scene.updateMatrix();y.scene.updateMatrixWorld()}}a=function(a){return function(){N=N-a;m();k.onLoadComplete()}};for(q in t.cameras){u=t.cameras[q];u.type==="perspective"?P=new THREE.PerspectiveCamera(u.fov,u.aspect,u.near,u.far):u.type==="ortho"&&(P=new THREE.OrthographicCamera(u.left,u.right,u.top,u.bottom,u.near,u.far));w=u.position;v=u.target;u=u.up;P.position.set(w[0],w[1],w[2]);P.target=new THREE.Vector3(v[0],v[1],v[2]);u&&P.up.set(u[0],
-u[1],u[2]);y.cameras[q]=P}for(o in t.lights){v=t.lights[o];q=v.color!==void 0?v.color:16777215;P=v.intensity!==void 0?v.intensity:1;if(v.type==="directional"){w=v.direction;A=new THREE.DirectionalLight(q,P);A.position.set(w[0],w[1],w[2]);A.position.normalize()}else if(v.type==="point"){w=v.position;A=v.distance;A=new THREE.PointLight(q,P,A);A.position.set(w[0],w[1],w[2])}else v.type==="ambient"&&(A=new THREE.AmbientLight(q));y.scene.add(A);y.lights[o]=A}for(i in t.fogs){o=t.fogs[i];o.type==="linear"?
-M=new THREE.Fog(0,o.near,o.far):o.type==="exp2"&&(M=new THREE.FogExp2(0,o.density));u=o.color;M.color.setRGB(u[0],u[1],u[2]);y.fogs[i]=M}if(y.cameras&&t.defaults.camera)y.currentCamera=y.cameras[t.defaults.camera];if(y.fogs&&t.defaults.fog)y.scene.fog=y.fogs[t.defaults.fog];u=t.defaults.bgcolor;y.bgColor=new THREE.Color;y.bgColor.setRGB(u[0],u[1],u[2]);y.bgColorAlpha=t.defaults.bgalpha;for(h in t.geometries){i=t.geometries[h];if(i.type=="bin_mesh"||i.type=="ascii_mesh"){G=G+1;k.onLoadStart()}}Q=G;
-for(h in t.geometries){i=t.geometries[h];if(i.type==="cube"){D=new THREE.CubeGeometry(i.width,i.height,i.depth,i.segmentsWidth,i.segmentsHeight,i.segmentsDepth,null,i.flipped,i.sides);y.geometries[h]=D}else if(i.type==="plane"){D=new THREE.PlaneGeometry(i.width,i.height,i.segmentsWidth,i.segmentsHeight);y.geometries[h]=D}else if(i.type==="sphere"){D=new THREE.SphereGeometry(i.radius,i.segmentsWidth,i.segmentsHeight);y.geometries[h]=D}else if(i.type==="cylinder"){D=new THREE.CylinderGeometry(i.topRad,
-i.botRad,i.height,i.radSegs,i.heightSegs);y.geometries[h]=D}else if(i.type==="torus"){D=new THREE.TorusGeometry(i.radius,i.tube,i.segmentsR,i.segmentsT);y.geometries[h]=D}else if(i.type==="icosahedron"){D=new THREE.IcosahedronGeometry(i.radius,i.subdivisions);y.geometries[h]=D}else if(i.type==="bin_mesh")c.load(d(i.url,t.urlBaseType),e(h));else if(i.type==="ascii_mesh")E.load(d(i.url,t.urlBaseType),e(h));else if(i.type==="embedded_mesh"){i=t.embeds[i.id];i.metadata=t.metadata;i&&E.createModel(i,g(h),
-"")}}for(p in t.textures){h=t.textures[p];if(h.url instanceof Array){N=N+h.url.length;for(i=0;i<h.url.length;i++)k.onLoadStart()}else{N=N+1;k.onLoadStart()}}O=N;for(p in t.textures){h=t.textures[p];if(h.mapping!==void 0&&THREE[h.mapping]!==void 0)h.mapping=new THREE[h.mapping];if(h.url instanceof Array){i=h.url.length;M=[];for(c=0;c<i;c++)M[c]=d(h.url[c],t.urlBaseType);i=THREE.ImageUtils.loadTextureCube(M,h.mapping,a(i))}else{i=THREE.ImageUtils.loadTexture(d(h.url,t.urlBaseType),h.mapping,a(1));if(THREE[h.minFilter]!==
-void 0)i.minFilter=THREE[h.minFilter];if(THREE[h.magFilter]!==void 0)i.magFilter=THREE[h.magFilter];if(h.repeat){i.repeat.set(h.repeat[0],h.repeat[1]);if(h.repeat[0]!==1)i.wrapS=THREE.RepeatWrapping;if(h.repeat[1]!==1)i.wrapT=THREE.RepeatWrapping}h.offset&&i.offset.set(h.offset[0],h.offset[1]);if(h.wrap){M={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(M[h.wrap[0]]!==void 0)i.wrapS=M[h.wrap[0]];if(M[h.wrap[1]]!==void 0)i.wrapT=M[h.wrap[1]]}}y.textures[p]=i}for(n in t.materials){s=
+u[1],u[2]);y.cameras[q]=P}for(o in t.lights){v=t.lights[o];q=v.color!==void 0?v.color:16777215;P=v.intensity!==void 0?v.intensity:1;if(v.type==="directional"){w=v.direction;A=new THREE.DirectionalLight(q,P);A.position.set(w[0],w[1],w[2]);A.position.normalize()}else if(v.type==="point"){w=v.position;A=v.distance;A=new THREE.PointLight(q,P,A);A.position.set(w[0],w[1],w[2])}else v.type==="ambient"&&(A=new THREE.AmbientLight(q));y.scene.add(A);y.lights[o]=A}for(l in t.fogs){o=t.fogs[l];o.type==="linear"?
+M=new THREE.Fog(0,o.near,o.far):o.type==="exp2"&&(M=new THREE.FogExp2(0,o.density));u=o.color;M.color.setRGB(u[0],u[1],u[2]);y.fogs[l]=M}if(y.cameras&&t.defaults.camera)y.currentCamera=y.cameras[t.defaults.camera];if(y.fogs&&t.defaults.fog)y.scene.fog=y.fogs[t.defaults.fog];u=t.defaults.bgcolor;y.bgColor=new THREE.Color;y.bgColor.setRGB(u[0],u[1],u[2]);y.bgColorAlpha=t.defaults.bgalpha;for(h in t.geometries){l=t.geometries[h];if(l.type=="bin_mesh"||l.type=="ascii_mesh"){G=G+1;k.onLoadStart()}}Q=G;
+for(h in t.geometries){l=t.geometries[h];if(l.type==="cube"){D=new THREE.CubeGeometry(l.width,l.height,l.depth,l.segmentsWidth,l.segmentsHeight,l.segmentsDepth,null,l.flipped,l.sides);y.geometries[h]=D}else if(l.type==="plane"){D=new THREE.PlaneGeometry(l.width,l.height,l.segmentsWidth,l.segmentsHeight);y.geometries[h]=D}else if(l.type==="sphere"){D=new THREE.SphereGeometry(l.radius,l.segmentsWidth,l.segmentsHeight);y.geometries[h]=D}else if(l.type==="cylinder"){D=new THREE.CylinderGeometry(l.topRad,
+l.botRad,l.height,l.radSegs,l.heightSegs);y.geometries[h]=D}else if(l.type==="torus"){D=new THREE.TorusGeometry(l.radius,l.tube,l.segmentsR,l.segmentsT);y.geometries[h]=D}else if(l.type==="icosahedron"){D=new THREE.IcosahedronGeometry(l.radius,l.subdivisions);y.geometries[h]=D}else if(l.type==="bin_mesh")c.load(d(l.url,t.urlBaseType),e(h));else if(l.type==="ascii_mesh")E.load(d(l.url,t.urlBaseType),e(h));else if(l.type==="embedded_mesh"){l=t.embeds[l.id];l.metadata=t.metadata;l&&E.createModel(l,g(h),
+"")}}for(p in t.textures){h=t.textures[p];if(h.url instanceof Array){N=N+h.url.length;for(l=0;l<h.url.length;l++)k.onLoadStart()}else{N=N+1;k.onLoadStart()}}O=N;for(p in t.textures){h=t.textures[p];if(h.mapping!==void 0&&THREE[h.mapping]!==void 0)h.mapping=new THREE[h.mapping];if(h.url instanceof Array){l=h.url.length;M=[];for(c=0;c<l;c++)M[c]=d(h.url[c],t.urlBaseType);l=THREE.ImageUtils.loadTextureCube(M,h.mapping,a(l))}else{l=THREE.ImageUtils.loadTexture(d(h.url,t.urlBaseType),h.mapping,a(1));if(THREE[h.minFilter]!==
+void 0)l.minFilter=THREE[h.minFilter];if(THREE[h.magFilter]!==void 0)l.magFilter=THREE[h.magFilter];if(h.repeat){l.repeat.set(h.repeat[0],h.repeat[1]);if(h.repeat[0]!==1)l.wrapS=THREE.RepeatWrapping;if(h.repeat[1]!==1)l.wrapT=THREE.RepeatWrapping}h.offset&&l.offset.set(h.offset[0],h.offset[1]);if(h.wrap){M={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(M[h.wrap[0]]!==void 0)l.wrapS=M[h.wrap[0]];if(M[h.wrap[1]]!==void 0)l.wrapT=M[h.wrap[1]]}}y.textures[p]=l}for(n in t.materials){s=
 t.materials[n];for(z in s.parameters)if(z==="envMap"||z==="map"||z==="lightMap")s.parameters[z]=y.textures[s.parameters[z]];else if(z==="shading")s.parameters[z]=s.parameters[z]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(z==="blending")s.parameters[z]=s.parameters[z]in THREE?THREE[s.parameters[z]]:THREE.NormalBlending;else if(z==="combine")s.parameters[z]=s.parameters[z]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(z==="vertexColors")if(s.parameters[z]=="face")s.parameters[z]=
-THREE.FaceColors;else if(s.parameters[z])s.parameters[z]=THREE.VertexColors;if(s.parameters.opacity!==void 0&&s.parameters.opacity<1)s.parameters.transparent=true;if(s.parameters.normalMap){p=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(p.uniforms);h=s.parameters.color;i=s.parameters.specular;M=s.parameters.ambient;c=s.parameters.shininess;a.tNormal.texture=y.textures[s.parameters.normalMap];if(s.parameters.normalMapFactor)a.uNormalScale.value=s.parameters.normalMapFactor;if(s.parameters.map){a.tDiffuse.texture=
-s.parameters.map;a.enableDiffuse.value=true}if(s.parameters.lightMap){a.tAO.texture=s.parameters.lightMap;a.enableAO.value=true}if(s.parameters.specularMap){a.tSpecular.texture=y.textures[s.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(h);a.uSpecularColor.value.setHex(i);a.uAmbientColor.value.setHex(M);a.uShininess.value=c;if(s.parameters.opacity)a.uOpacity.value=s.parameters.opacity;H=new THREE.ShaderMaterial({fragmentShader:p.fragmentShader,vertexShader:p.vertexShader,
+THREE.FaceColors;else if(s.parameters[z])s.parameters[z]=THREE.VertexColors;if(s.parameters.opacity!==void 0&&s.parameters.opacity<1)s.parameters.transparent=true;if(s.parameters.normalMap){p=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(p.uniforms);h=s.parameters.color;l=s.parameters.specular;M=s.parameters.ambient;c=s.parameters.shininess;a.tNormal.texture=y.textures[s.parameters.normalMap];if(s.parameters.normalMapFactor)a.uNormalScale.value=s.parameters.normalMapFactor;if(s.parameters.map){a.tDiffuse.texture=
+s.parameters.map;a.enableDiffuse.value=true}if(s.parameters.lightMap){a.tAO.texture=s.parameters.lightMap;a.enableAO.value=true}if(s.parameters.specularMap){a.tSpecular.texture=y.textures[s.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(h);a.uSpecularColor.value.setHex(l);a.uAmbientColor.value.setHex(M);a.uShininess.value=c;if(s.parameters.opacity)a.uOpacity.value=s.parameters.opacity;H=new THREE.ShaderMaterial({fragmentShader:p.fragmentShader,vertexShader:p.vertexShader,
 uniforms:a,lights:true,fog:true})}else H=new THREE[s.type](s.parameters);y.materials[n]=H}f();k.callbackSync(y);m()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
 THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=true;b.dispatchEvent({type:"load",content:a})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}};
 THREE.Material=function(a){a=a||{};this.id=THREE.MaterialCount++;this.name="";this.opacity=a.opacity!==void 0?a.opacity:1;this.transparent=a.transparent!==void 0?a.transparent:false;this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.blendSrc=a.blendSrc!==void 0?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=a.blendDst!==void 0?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=a.blendEquation!==void 0?a.blendEquation:THREE.AddEquation;this.depthTest=a.depthTest!==void 0?
@@ -198,7 +199,7 @@ THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;TH
 THREE.Texture=function(a,b,c,d,f,e,g,m){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=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=f!==void 0?f:THREE.LinearFilter;this.minFilter=e!==void 0?e:THREE.LinearMipMapLinearFilter;this.format=g!==void 0?g:THREE.RGBAFormat;this.type=m!==void 0?m:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps=
 true;this.needsUpdate=this.premultiplyAlpha=false;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.UVMapping=function(){};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=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.UnsignedByteType=9;THREE.ByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;
-THREE.UnsignedShort4444Type=16;THREE.UnsignedShort5551Type=17;THREE.UnsignedShort565Type=18;THREE.AlphaFormat=19;THREE.RGBFormat=20;THREE.RGBAFormat=21;THREE.LuminanceFormat=22;THREE.LuminanceAlphaFormat=23;THREE.DataTexture=function(a,b,c,d,f,e,g,m,k,l){THREE.Texture.call(this,null,e,g,m,k,l,d,f);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
+THREE.UnsignedShort4444Type=16;THREE.UnsignedShort5551Type=17;THREE.UnsignedShort565Type=18;THREE.AlphaFormat=19;THREE.RGBFormat=20;THREE.RGBAFormat=21;THREE.LuminanceFormat=22;THREE.LuminanceAlphaFormat=23;THREE.DataTexture=function(a,b,c,d,f,e,g,m,k,j){THREE.Texture.call(this,null,e,g,m,k,j,d,f);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
 THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
 THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=b!==void 0?b:new THREE.LineBasicMaterial({color:Math.random()*16777215});this.type=c!==void 0?c:THREE.LineStrip;this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b!==void 0?b:new THREE.MeshBasicMaterial({color:Math.random()*16777215,wireframe:true});if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius;if(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);
@@ -211,35 +212,35 @@ THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topC
 THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=false;this.__objects=[];this.__lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
 THREE.Scene.prototype.__addObject=function(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 if(!(a instanceof THREE.Camera)){b=this.__objects.indexOf(a);if(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(s!=a)i.globalAlpha=s=a}function c(a){if(v!=a){switch(a){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}v=a}}function d(a){if(A!=a)i.strokeStyle=A=a}function f(a){if(w!=a)i.fillStyle=w=a}console.log("THREE.CanvasRenderer",THREE.REVISION);var a=a||{},e=this,g,m,k,l=new THREE.Projector,h=a.canvas!==
-void 0?a.canvas:document.createElement("canvas"),n,j,o,q,i=h.getContext("2d"),p=new THREE.Color(0),r=0,s=1,v=0,A=null,w=null,B=null,x=null,F=null,u,z,D,H,P=new THREE.RenderableVertex,M=new THREE.RenderableVertex,t,E,G,N,Q,O,y,S,L,U,T,W,C=new THREE.Color,J=new THREE.Color,I=new THREE.Color,K=new THREE.Color,R=new THREE.Color,ja=[],da=[],ea,fa,ca,ka,za,Aa,Ba,Ca,Da,Ea,la=new THREE.Rectangle,$=new THREE.Rectangle,Z=new THREE.Rectangle,xa=false,Y=new THREE.Color,ma=new THREE.Color,na=new THREE.Color,V=
-new THREE.Vector3,ra,sa,ya,aa,ta,ua,a=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);ya=sa.getImageData(0,0,2,2);aa=ya.data;ta=document.createElement("canvas");ta.width=ta.height=a;ua=ta.getContext("2d");ua.translate(-a/2,-a/2);ua.scale(a,a);a--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){n=a;j=b;o=Math.floor(n/2);q=Math.floor(j/
-2);h.width=n;h.height=j;la.set(-o,-q,o,q);$.set(-o,-q,o,q);s=1;v=0;F=x=B=w=A=null};this.setClearColor=function(a,b){p.copy(a);r=b!==void 0?b:1;$.set(-o,-q,o,q)};this.setClearColorHex=function(a,b){p.setHex(a);r=b!==void 0?b:1;$.set(-o,-q,o,q)};this.clear=function(){i.setTransform(1,0,0,-1,o,q);if(!$.isEmpty()){$.minSelf(la);$.inflate(2);r<1&&i.clearRect(Math.floor($.getX()),Math.floor($.getY()),Math.floor($.getWidth()),Math.floor($.getHeight()));if(r>0){c(THREE.NormalBlending);b(1);f("rgba("+Math.floor(p.r*
-255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+r+")");i.fillRect(Math.floor($.getX()),Math.floor($.getY()),Math.floor($.getWidth()),Math.floor($.getHeight()))}$.empty()}};this.render=function(a,h){function j(a){var b,c,d,e;Y.setRGB(0,0,0);ma.setRGB(0,0,0);na.setRGB(0,0,0);b=0;for(c=a.length;b<c;b++){d=a[b];e=d.color;if(d instanceof THREE.AmbientLight){Y.r=Y.r+e.r;Y.g=Y.g+e.g;Y.b=Y.b+e.b}else if(d instanceof THREE.DirectionalLight){ma.r=ma.r+e.r;ma.g=ma.g+e.g;ma.b=ma.b+e.b}else if(d instanceof
-THREE.PointLight){na.r=na.r+e.r;na.g=na.g+e.g;na.b=na.b+e.b}}}function n(a,b,c,d){var e,f,g,h,l,k;e=0;for(f=a.length;e<f;e++){g=a[e];h=g.color;if(g instanceof THREE.DirectionalLight){l=g.matrixWorld.getPosition();k=c.dot(l);if(!(k<=0)){k=k*g.intensity;d.r=d.r+h.r*k;d.g=d.g+h.g*k;d.b=d.b+h.b*k}}else if(g instanceof THREE.PointLight){l=g.matrixWorld.getPosition();k=c.dot(V.sub(l,b).normalize());if(!(k<=0)){k=k*(g.distance==0?1:1-Math.min(b.distanceTo(l)/g.distance,1));if(k!=0){k=k*g.intensity;d.r=d.r+
-h.r*k;d.g=d.g+h.g*k;d.b=d.b+h.b*k}}}}}function p(a,e,g){b(g.opacity);c(g.blending);var h,k,l,m,j,n;if(g instanceof THREE.ParticleBasicMaterial){if(g.map){m=g.map.image;j=m.width>>1;n=m.height>>1;g=e.scale.x*o;l=e.scale.y*q;h=g*j;k=l*n;Z.set(a.x-h,a.y-k,a.x+h,a.y+k);if(la.intersects(Z)){i.save();i.translate(a.x,a.y);i.rotate(-e.rotation);i.scale(g,-l);i.translate(-j,-n);i.drawImage(m,0,0);i.restore()}}}else if(g instanceof THREE.ParticleCanvasMaterial){h=e.scale.x*o;k=e.scale.y*q;Z.set(a.x-h,a.y-k,
-a.x+h,a.y+k);if(la.intersects(Z)){d(g.color.getContextStyle());f(g.color.getContextStyle());i.save();i.translate(a.x,a.y);i.rotate(-e.rotation);i.scale(h,k);g.program(i);i.restore()}}}function r(a,e,f,g){b(g.opacity);c(g.blending);i.beginPath();i.moveTo(a.positionScreen.x,a.positionScreen.y);i.lineTo(e.positionScreen.x,e.positionScreen.y);i.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(B!=a)i.lineWidth=B=a;a=g.linecap;if(x!=a)i.lineCap=x=a;a=g.linejoin;if(F!=a)i.lineJoin=F=
-a;d(g.color.getContextStyle());i.stroke();Z.inflate(g.linewidth*2)}}function s(a,d,f,g,l,m,i,j){e.info.render.vertices=e.info.render.vertices+3;e.info.render.faces++;b(j.opacity);c(j.blending);t=a.positionScreen.x;E=a.positionScreen.y;G=d.positionScreen.x;N=d.positionScreen.y;Q=f.positionScreen.x;O=f.positionScreen.y;v(t,E,G,N,Q,O);if(j instanceof THREE.MeshBasicMaterial)if(j.map){if(j.map.mapping instanceof THREE.UVMapping){ka=i.uvs[0];Fa(t,E,G,N,Q,O,ka[g].u,ka[g].v,ka[l].u,ka[l].v,ka[m].u,ka[m].v,
-j.map)}}else if(j.envMap){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping){a=h.matrixWorldInverse;V.copy(i.vertexNormalsWorld[g]);za=(V.x*a.elements[0]+V.y*a.elements[4]+V.z*a.elements[8])*0.5+0.5;Aa=-(V.x*a.elements[1]+V.y*a.elements[5]+V.z*a.elements[9])*0.5+0.5;V.copy(i.vertexNormalsWorld[l]);Ba=(V.x*a.elements[0]+V.y*a.elements[4]+V.z*a.elements[8])*0.5+0.5;Ca=-(V.x*a.elements[1]+V.y*a.elements[5]+V.z*a.elements[9])*0.5+0.5;V.copy(i.vertexNormalsWorld[m]);Da=(V.x*a.elements[0]+
-V.y*a.elements[4]+V.z*a.elements[8])*0.5+0.5;Ea=-(V.x*a.elements[1]+V.y*a.elements[5]+V.z*a.elements[9])*0.5+0.5;Fa(t,E,G,N,Q,O,za,Aa,Ba,Ca,Da,Ea,j.envMap)}}else j.wireframe?ha(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color);else if(j instanceof THREE.MeshLambertMaterial)if(xa)if(!j.wireframe&&j.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==3){J.r=I.r=K.r=Y.r;J.g=I.g=K.g=Y.g;J.b=I.b=K.b=Y.b;n(k,i.v1.positionWorld,i.vertexNormalsWorld[0],J);n(k,i.v2.positionWorld,
-i.vertexNormalsWorld[1],I);n(k,i.v3.positionWorld,i.vertexNormalsWorld[2],K);J.r=Math.max(0,Math.min(j.color.r*J.r,1));J.g=Math.max(0,Math.min(j.color.g*J.g,1));J.b=Math.max(0,Math.min(j.color.b*J.b,1));I.r=Math.max(0,Math.min(j.color.r*I.r,1));I.g=Math.max(0,Math.min(j.color.g*I.g,1));I.b=Math.max(0,Math.min(j.color.b*I.b,1));K.r=Math.max(0,Math.min(j.color.r*K.r,1));K.g=Math.max(0,Math.min(j.color.g*K.g,1));K.b=Math.max(0,Math.min(j.color.b*K.b,1));R.r=(I.r+K.r)*0.5;R.g=(I.g+K.g)*0.5;R.b=(I.b+K.b)*
-0.5;ca=va(J,I,K,R);pa(t,E,G,N,Q,O,0,0,1,0,0,1,ca)}else{C.r=Y.r;C.g=Y.g;C.b=Y.b;n(k,i.centroidWorld,i.normalWorld,C);C.r=Math.max(0,Math.min(j.color.r*C.r,1));C.g=Math.max(0,Math.min(j.color.g*C.g,1));C.b=Math.max(0,Math.min(j.color.b*C.b,1));j.wireframe?ha(C,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(C)}else j.wireframe?ha(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color);else if(j instanceof THREE.MeshDepthMaterial){ea=h.near;fa=h.far;J.r=J.g=J.b=
-1-oa(a.positionScreen.z,ea,fa);I.r=I.g=I.b=1-oa(d.positionScreen.z,ea,fa);K.r=K.g=K.b=1-oa(f.positionScreen.z,ea,fa);R.r=(I.r+K.r)*0.5;R.g=(I.g+K.g)*0.5;R.b=(I.b+K.b)*0.5;ca=va(J,I,K,R);pa(t,E,G,N,Q,O,0,0,1,0,0,1,ca)}else if(j instanceof THREE.MeshNormalMaterial){C.r=qa(i.normalWorld.x);C.g=qa(i.normalWorld.y);C.b=qa(i.normalWorld.z);j.wireframe?ha(C,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(C)}}function w(a,d,f,g,l,m,j,i,o){e.info.render.vertices=e.info.render.vertices+4;e.info.render.faces++;
-b(i.opacity);c(i.blending);if(i.map||i.envMap){s(a,d,g,0,1,3,j,i,o);s(l,f,m,1,2,3,j,i,o)}else{t=a.positionScreen.x;E=a.positionScreen.y;G=d.positionScreen.x;N=d.positionScreen.y;Q=f.positionScreen.x;O=f.positionScreen.y;y=g.positionScreen.x;S=g.positionScreen.y;L=l.positionScreen.x;U=l.positionScreen.y;T=m.positionScreen.x;W=m.positionScreen.y;if(i instanceof THREE.MeshBasicMaterial){A(t,E,G,N,Q,O,y,S);i.wireframe?ha(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color)}else if(i instanceof
-THREE.MeshLambertMaterial)if(xa)if(!i.wireframe&&i.shading==THREE.SmoothShading&&j.vertexNormalsWorld.length==4){J.r=I.r=K.r=R.r=Y.r;J.g=I.g=K.g=R.g=Y.g;J.b=I.b=K.b=R.b=Y.b;n(k,j.v1.positionWorld,j.vertexNormalsWorld[0],J);n(k,j.v2.positionWorld,j.vertexNormalsWorld[1],I);n(k,j.v4.positionWorld,j.vertexNormalsWorld[3],K);n(k,j.v3.positionWorld,j.vertexNormalsWorld[2],R);J.r=Math.max(0,Math.min(i.color.r*J.r,1));J.g=Math.max(0,Math.min(i.color.g*J.g,1));J.b=Math.max(0,Math.min(i.color.b*J.b,1));I.r=
+THREE.CanvasRenderer=function(a){function b(a){if(s!=a)l.globalAlpha=s=a}function c(a){if(v!=a){switch(a){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}v=a}}function d(a){if(A!=a)l.strokeStyle=A=a}function f(a){if(w!=a)l.fillStyle=w=a}console.log("THREE.CanvasRenderer",THREE.REVISION);var a=a||{},e=this,g,m,k,j=new THREE.Projector,h=a.canvas!==
+void 0?a.canvas:document.createElement("canvas"),n,i,o,q,l=h.getContext("2d"),p=new THREE.Color(0),r=0,s=1,v=0,A=null,w=null,B=null,x=null,F=null,u,z,D,H,P=new THREE.RenderableVertex,M=new THREE.RenderableVertex,t,E,G,N,Q,O,y,S,L,U,T,W,C=new THREE.Color,J=new THREE.Color,I=new THREE.Color,K=new THREE.Color,R=new THREE.Color,ja=[],da=[],ea,fa,ca,ka,za,Aa,Ba,Ca,Da,Ea,la=new THREE.Rectangle,$=new THREE.Rectangle,Z=new THREE.Rectangle,xa=false,Y=new THREE.Color,ma=new THREE.Color,na=new THREE.Color,V=
+new THREE.Vector3,ra,sa,ya,aa,ta,ua,a=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);ya=sa.getImageData(0,0,2,2);aa=ya.data;ta=document.createElement("canvas");ta.width=ta.height=a;ua=ta.getContext("2d");ua.translate(-a/2,-a/2);ua.scale(a,a);a--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){n=a;i=b;o=Math.floor(n/2);q=Math.floor(i/
+2);h.width=n;h.height=i;la.set(-o,-q,o,q);$.set(-o,-q,o,q);s=1;v=0;F=x=B=w=A=null};this.setClearColor=function(a,b){p.copy(a);r=b!==void 0?b:1;$.set(-o,-q,o,q)};this.setClearColorHex=function(a,b){p.setHex(a);r=b!==void 0?b:1;$.set(-o,-q,o,q)};this.clear=function(){l.setTransform(1,0,0,-1,o,q);if(!$.isEmpty()){$.minSelf(la);$.inflate(2);r<1&&l.clearRect(Math.floor($.getX()),Math.floor($.getY()),Math.floor($.getWidth()),Math.floor($.getHeight()));if(r>0){c(THREE.NormalBlending);b(1);f("rgba("+Math.floor(p.r*
+255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+r+")");l.fillRect(Math.floor($.getX()),Math.floor($.getY()),Math.floor($.getWidth()),Math.floor($.getHeight()))}$.empty()}};this.render=function(a,h){function i(a){var b,c,d,e;Y.setRGB(0,0,0);ma.setRGB(0,0,0);na.setRGB(0,0,0);b=0;for(c=a.length;b<c;b++){d=a[b];e=d.color;if(d instanceof THREE.AmbientLight){Y.r=Y.r+e.r;Y.g=Y.g+e.g;Y.b=Y.b+e.b}else if(d instanceof THREE.DirectionalLight){ma.r=ma.r+e.r;ma.g=ma.g+e.g;ma.b=ma.b+e.b}else if(d instanceof
+THREE.PointLight){na.r=na.r+e.r;na.g=na.g+e.g;na.b=na.b+e.b}}}function n(a,b,c,d){var e,f,g,h,j,k;e=0;for(f=a.length;e<f;e++){g=a[e];h=g.color;if(g instanceof THREE.DirectionalLight){j=g.matrixWorld.getPosition();k=c.dot(j);if(!(k<=0)){k=k*g.intensity;d.r=d.r+h.r*k;d.g=d.g+h.g*k;d.b=d.b+h.b*k}}else if(g instanceof THREE.PointLight){j=g.matrixWorld.getPosition();k=c.dot(V.sub(j,b).normalize());if(!(k<=0)){k=k*(g.distance==0?1:1-Math.min(b.distanceTo(j)/g.distance,1));if(k!=0){k=k*g.intensity;d.r=d.r+
+h.r*k;d.g=d.g+h.g*k;d.b=d.b+h.b*k}}}}}function p(a,e,g){b(g.opacity);c(g.blending);var h,k,j,m,i,n;if(g instanceof THREE.ParticleBasicMaterial){if(g.map){m=g.map.image;i=m.width>>1;n=m.height>>1;g=e.scale.x*o;j=e.scale.y*q;h=g*i;k=j*n;Z.set(a.x-h,a.y-k,a.x+h,a.y+k);if(la.intersects(Z)){l.save();l.translate(a.x,a.y);l.rotate(-e.rotation);l.scale(g,-j);l.translate(-i,-n);l.drawImage(m,0,0);l.restore()}}}else if(g instanceof THREE.ParticleCanvasMaterial){h=e.scale.x*o;k=e.scale.y*q;Z.set(a.x-h,a.y-k,
+a.x+h,a.y+k);if(la.intersects(Z)){d(g.color.getContextStyle());f(g.color.getContextStyle());l.save();l.translate(a.x,a.y);l.rotate(-e.rotation);l.scale(h,k);g.program(l);l.restore()}}}function r(a,e,f,g){b(g.opacity);c(g.blending);l.beginPath();l.moveTo(a.positionScreen.x,a.positionScreen.y);l.lineTo(e.positionScreen.x,e.positionScreen.y);l.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(B!=a)l.lineWidth=B=a;a=g.linecap;if(x!=a)l.lineCap=x=a;a=g.linejoin;if(F!=a)l.lineJoin=F=
+a;d(g.color.getContextStyle());l.stroke();Z.inflate(g.linewidth*2)}}function s(a,d,f,g,j,m,l,i){e.info.render.vertices=e.info.render.vertices+3;e.info.render.faces++;b(i.opacity);c(i.blending);t=a.positionScreen.x;E=a.positionScreen.y;G=d.positionScreen.x;N=d.positionScreen.y;Q=f.positionScreen.x;O=f.positionScreen.y;v(t,E,G,N,Q,O);if(i instanceof THREE.MeshBasicMaterial)if(i.map){if(i.map.mapping instanceof THREE.UVMapping){ka=l.uvs[0];Fa(t,E,G,N,Q,O,ka[g].u,ka[g].v,ka[j].u,ka[j].v,ka[m].u,ka[m].v,
+i.map)}}else if(i.envMap){if(i.envMap.mapping instanceof THREE.SphericalReflectionMapping){a=h.matrixWorldInverse;V.copy(l.vertexNormalsWorld[g]);za=(V.x*a.elements[0]+V.y*a.elements[4]+V.z*a.elements[8])*0.5+0.5;Aa=-(V.x*a.elements[1]+V.y*a.elements[5]+V.z*a.elements[9])*0.5+0.5;V.copy(l.vertexNormalsWorld[j]);Ba=(V.x*a.elements[0]+V.y*a.elements[4]+V.z*a.elements[8])*0.5+0.5;Ca=-(V.x*a.elements[1]+V.y*a.elements[5]+V.z*a.elements[9])*0.5+0.5;V.copy(l.vertexNormalsWorld[m]);Da=(V.x*a.elements[0]+
+V.y*a.elements[4]+V.z*a.elements[8])*0.5+0.5;Ea=-(V.x*a.elements[1]+V.y*a.elements[5]+V.z*a.elements[9])*0.5+0.5;Fa(t,E,G,N,Q,O,za,Aa,Ba,Ca,Da,Ea,i.envMap)}}else i.wireframe?ha(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color);else if(i instanceof THREE.MeshLambertMaterial)if(xa)if(!i.wireframe&&i.shading==THREE.SmoothShading&&l.vertexNormalsWorld.length==3){J.r=I.r=K.r=Y.r;J.g=I.g=K.g=Y.g;J.b=I.b=K.b=Y.b;n(k,l.v1.positionWorld,l.vertexNormalsWorld[0],J);n(k,l.v2.positionWorld,
+l.vertexNormalsWorld[1],I);n(k,l.v3.positionWorld,l.vertexNormalsWorld[2],K);J.r=Math.max(0,Math.min(i.color.r*J.r,1));J.g=Math.max(0,Math.min(i.color.g*J.g,1));J.b=Math.max(0,Math.min(i.color.b*J.b,1));I.r=Math.max(0,Math.min(i.color.r*I.r,1));I.g=Math.max(0,Math.min(i.color.g*I.g,1));I.b=Math.max(0,Math.min(i.color.b*I.b,1));K.r=Math.max(0,Math.min(i.color.r*K.r,1));K.g=Math.max(0,Math.min(i.color.g*K.g,1));K.b=Math.max(0,Math.min(i.color.b*K.b,1));R.r=(I.r+K.r)*0.5;R.g=(I.g+K.g)*0.5;R.b=(I.b+K.b)*
+0.5;ca=va(J,I,K,R);pa(t,E,G,N,Q,O,0,0,1,0,0,1,ca)}else{C.r=Y.r;C.g=Y.g;C.b=Y.b;n(k,l.centroidWorld,l.normalWorld,C);C.r=Math.max(0,Math.min(i.color.r*C.r,1));C.g=Math.max(0,Math.min(i.color.g*C.g,1));C.b=Math.max(0,Math.min(i.color.b*C.b,1));i.wireframe?ha(C,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(C)}else i.wireframe?ha(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color);else if(i instanceof THREE.MeshDepthMaterial){ea=h.near;fa=h.far;J.r=J.g=J.b=
+1-oa(a.positionScreen.z,ea,fa);I.r=I.g=I.b=1-oa(d.positionScreen.z,ea,fa);K.r=K.g=K.b=1-oa(f.positionScreen.z,ea,fa);R.r=(I.r+K.r)*0.5;R.g=(I.g+K.g)*0.5;R.b=(I.b+K.b)*0.5;ca=va(J,I,K,R);pa(t,E,G,N,Q,O,0,0,1,0,0,1,ca)}else if(i instanceof THREE.MeshNormalMaterial){C.r=qa(l.normalWorld.x);C.g=qa(l.normalWorld.y);C.b=qa(l.normalWorld.z);i.wireframe?ha(C,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(C)}}function w(a,d,f,g,j,m,l,i,o){e.info.render.vertices=e.info.render.vertices+4;e.info.render.faces++;
+b(i.opacity);c(i.blending);if(i.map||i.envMap){s(a,d,g,0,1,3,l,i,o);s(j,f,m,1,2,3,l,i,o)}else{t=a.positionScreen.x;E=a.positionScreen.y;G=d.positionScreen.x;N=d.positionScreen.y;Q=f.positionScreen.x;O=f.positionScreen.y;y=g.positionScreen.x;S=g.positionScreen.y;L=j.positionScreen.x;U=j.positionScreen.y;T=m.positionScreen.x;W=m.positionScreen.y;if(i instanceof THREE.MeshBasicMaterial){A(t,E,G,N,Q,O,y,S);i.wireframe?ha(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color)}else if(i instanceof
+THREE.MeshLambertMaterial)if(xa)if(!i.wireframe&&i.shading==THREE.SmoothShading&&l.vertexNormalsWorld.length==4){J.r=I.r=K.r=R.r=Y.r;J.g=I.g=K.g=R.g=Y.g;J.b=I.b=K.b=R.b=Y.b;n(k,l.v1.positionWorld,l.vertexNormalsWorld[0],J);n(k,l.v2.positionWorld,l.vertexNormalsWorld[1],I);n(k,l.v4.positionWorld,l.vertexNormalsWorld[3],K);n(k,l.v3.positionWorld,l.vertexNormalsWorld[2],R);J.r=Math.max(0,Math.min(i.color.r*J.r,1));J.g=Math.max(0,Math.min(i.color.g*J.g,1));J.b=Math.max(0,Math.min(i.color.b*J.b,1));I.r=
 Math.max(0,Math.min(i.color.r*I.r,1));I.g=Math.max(0,Math.min(i.color.g*I.g,1));I.b=Math.max(0,Math.min(i.color.b*I.b,1));K.r=Math.max(0,Math.min(i.color.r*K.r,1));K.g=Math.max(0,Math.min(i.color.g*K.g,1));K.b=Math.max(0,Math.min(i.color.b*K.b,1));R.r=Math.max(0,Math.min(i.color.r*R.r,1));R.g=Math.max(0,Math.min(i.color.g*R.g,1));R.b=Math.max(0,Math.min(i.color.b*R.b,1));ca=va(J,I,K,R);v(t,E,G,N,y,S);pa(t,E,G,N,y,S,0,0,1,0,0,1,ca);v(L,U,Q,O,T,W);pa(L,U,Q,O,T,W,1,0,1,1,0,1,ca)}else{C.r=Y.r;C.g=Y.g;
-C.b=Y.b;n(k,j.centroidWorld,j.normalWorld,C);C.r=Math.max(0,Math.min(i.color.r*C.r,1));C.g=Math.max(0,Math.min(i.color.g*C.g,1));C.b=Math.max(0,Math.min(i.color.b*C.b,1));A(t,E,G,N,Q,O,y,S);i.wireframe?ha(C,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(C)}else{A(t,E,G,N,Q,O,y,S);i.wireframe?ha(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color)}else if(i instanceof THREE.MeshNormalMaterial){C.r=qa(j.normalWorld.x);C.g=qa(j.normalWorld.y);C.b=qa(j.normalWorld.z);
-A(t,E,G,N,Q,O,y,S);i.wireframe?ha(C,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(C)}else if(i instanceof THREE.MeshDepthMaterial){ea=h.near;fa=h.far;J.r=J.g=J.b=1-oa(a.positionScreen.z,ea,fa);I.r=I.g=I.b=1-oa(d.positionScreen.z,ea,fa);K.r=K.g=K.b=1-oa(g.positionScreen.z,ea,fa);R.r=R.g=R.b=1-oa(f.positionScreen.z,ea,fa);ca=va(J,I,K,R);v(t,E,G,N,y,S);pa(t,E,G,N,y,S,0,0,1,0,0,1,ca);v(L,U,Q,O,T,W);pa(L,U,Q,O,T,W,1,0,1,1,0,1,ca)}}}function v(a,b,c,d,e,f){i.beginPath();i.moveTo(a,b);
-i.lineTo(c,d);i.lineTo(e,f);i.lineTo(a,b)}function A(a,b,c,d,e,f,g,h){i.beginPath();i.moveTo(a,b);i.lineTo(c,d);i.lineTo(e,f);i.lineTo(g,h);i.lineTo(a,b)}function ha(a,b,c,e){if(B!=b)i.lineWidth=B=b;if(x!=c)i.lineCap=x=c;if(F!=e)i.lineJoin=F=e;d(a.getContextStyle());i.stroke();Z.inflate(b*2)}function ga(a){f(a.getContextStyle());i.fill()}function Fa(a,b,c,d,e,g,h,k,l,j,m,n,o){if(!(o.image===void 0||o.image.width===0)){if(o.needsUpdate===true||ja[o.id]===void 0){var p=o.wrapS==THREE.RepeatWrapping,
-q=o.wrapT==THREE.RepeatWrapping;ja[o.id]=i.createPattern(o.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");o.needsUpdate=false}f(ja[o.id]);var p=o.offset.x/o.repeat.x,q=o.offset.y/o.repeat.y,r=o.image.width*o.repeat.x,s=o.image.height*o.repeat.y,h=(h+p)*r,k=(k+q)*s,c=c-a,d=d-b,e=e-a,g=g-b,l=(l+p)*r-h,j=(j+q)*s-k,m=(m+p)*r-h,n=(n+q)*s-k,p=l*n-m*j;if(p==0){if(da[o.id]===void 0){b=document.createElement("canvas");b.width=o.image.width;b.height=o.image.height;b=b.getContext("2d");b.drawImage(o.image,
-0,0);da[o.id]=b.getImageData(0,0,o.image.width,o.image.height).data}b=da[o.id];h=(Math.floor(h)+Math.floor(k)*o.image.width)*4;C.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);ga(C)}else{p=1/p;o=(n*c-j*e)*p;j=(n*d-j*g)*p;c=(l*e-m*c)*p;d=(l*g-m*d)*p;a=a-o*h-c*k;h=b-j*h-d*k;i.save();i.transform(o,j,c,d,a,h);i.fill();i.restore()}}}function pa(a,b,c,d,e,f,g,h,k,j,l,m,n){var o,p;o=n.width-1;p=n.height-1;g=g*o;h=h*p;c=c-a;d=d-b;e=e-a;f=f-b;k=k*o-g;j=j*p-h;l=l*o-g;m=m*p-h;p=1/(k*m-l*j);o=(m*c-j*e)*p;j=(m*d-j*f)*
-p;c=(k*e-l*c)*p;d=(k*f-l*d)*p;a=a-o*g-c*h;b=b-j*g-d*h;i.save();i.transform(o,j,c,d,a,b);i.clip();i.drawImage(n,0,0);i.restore()}function va(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);aa[0]=e<0?0:e>255?255:e;aa[1]=f<0?0:f>255?255:f;aa[2]=a<0?0:a>255?255:a;aa[4]=g<0?0:g>255?255:g;aa[5]=h<0?0:h>255?255:h;aa[6]=b<0?0:b>255?255:b;aa[8]=i<0?0:i>255?255:i;aa[9]=j<0?0:
-j>255?255:j;aa[10]=c<0?0:c>255?255:c;aa[12]=k<0?0:k>255?255:k;aa[13]=l<0?0:l>255?255:l;aa[14]=d<0?0:d>255?255:d;sa.putImageData(ya,0,0);ua.drawImage(ra,0,0);return ta}function oa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function qa(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ia(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;if(e!=0){e=1/Math.sqrt(e);c=c*e;d=d*e;b.x=b.x+c;b.y=b.y+d;a.x=a.x-c;a.y=a.y-d}}var wa,Ga,X,ba;this.autoClear?this.clear():i.setTransform(1,0,0,-1,o,q);e.info.render.vertices=0;e.info.render.faces=
-0;g=l.projectScene(a,h,this.sortElements);m=g.elements;k=g.lights;(xa=k.length>0)&&j(k);wa=0;for(Ga=m.length;wa<Ga;wa++){X=m[wa];ba=X.material;ba=ba instanceof THREE.MeshFaceMaterial?X.faceMaterial:ba;if(!(ba===void 0||ba.visible===false)){Z.empty();if(X instanceof THREE.RenderableParticle){u=X;u.x=u.x*o;u.y=u.y*q;p(u,X,ba,a)}else if(X instanceof THREE.RenderableLine){u=X.v1;z=X.v2;u.positionScreen.x=u.positionScreen.x*o;u.positionScreen.y=u.positionScreen.y*q;z.positionScreen.x=z.positionScreen.x*
+C.b=Y.b;n(k,l.centroidWorld,l.normalWorld,C);C.r=Math.max(0,Math.min(i.color.r*C.r,1));C.g=Math.max(0,Math.min(i.color.g*C.g,1));C.b=Math.max(0,Math.min(i.color.b*C.b,1));A(t,E,G,N,Q,O,y,S);i.wireframe?ha(C,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(C)}else{A(t,E,G,N,Q,O,y,S);i.wireframe?ha(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color)}else if(i instanceof THREE.MeshNormalMaterial){C.r=qa(l.normalWorld.x);C.g=qa(l.normalWorld.y);C.b=qa(l.normalWorld.z);
+A(t,E,G,N,Q,O,y,S);i.wireframe?ha(C,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(C)}else if(i instanceof THREE.MeshDepthMaterial){ea=h.near;fa=h.far;J.r=J.g=J.b=1-oa(a.positionScreen.z,ea,fa);I.r=I.g=I.b=1-oa(d.positionScreen.z,ea,fa);K.r=K.g=K.b=1-oa(g.positionScreen.z,ea,fa);R.r=R.g=R.b=1-oa(f.positionScreen.z,ea,fa);ca=va(J,I,K,R);v(t,E,G,N,y,S);pa(t,E,G,N,y,S,0,0,1,0,0,1,ca);v(L,U,Q,O,T,W);pa(L,U,Q,O,T,W,1,0,1,1,0,1,ca)}}}function v(a,b,c,d,e,f){l.beginPath();l.moveTo(a,b);
+l.lineTo(c,d);l.lineTo(e,f);l.lineTo(a,b)}function A(a,b,c,d,e,f,g,h){l.beginPath();l.moveTo(a,b);l.lineTo(c,d);l.lineTo(e,f);l.lineTo(g,h);l.lineTo(a,b)}function ha(a,b,c,e){if(B!=b)l.lineWidth=B=b;if(x!=c)l.lineCap=x=c;if(F!=e)l.lineJoin=F=e;d(a.getContextStyle());l.stroke();Z.inflate(b*2)}function ga(a){f(a.getContextStyle());l.fill()}function Fa(a,b,c,d,e,g,h,i,k,j,m,n,o){if(!(o.image===void 0||o.image.width===0)){if(o.needsUpdate===true||ja[o.id]===void 0){var p=o.wrapS==THREE.RepeatWrapping,
+q=o.wrapT==THREE.RepeatWrapping;ja[o.id]=l.createPattern(o.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");o.needsUpdate=false}f(ja[o.id]);var p=o.offset.x/o.repeat.x,q=o.offset.y/o.repeat.y,r=o.image.width*o.repeat.x,s=o.image.height*o.repeat.y,h=(h+p)*r,i=(i+q)*s,c=c-a,d=d-b,e=e-a,g=g-b,k=(k+p)*r-h,j=(j+q)*s-i,m=(m+p)*r-h,n=(n+q)*s-i,p=k*n-m*j;if(p==0){if(da[o.id]===void 0){b=document.createElement("canvas");b.width=o.image.width;b.height=o.image.height;b=b.getContext("2d");b.drawImage(o.image,
+0,0);da[o.id]=b.getImageData(0,0,o.image.width,o.image.height).data}b=da[o.id];h=(Math.floor(h)+Math.floor(i)*o.image.width)*4;C.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);ga(C)}else{p=1/p;o=(n*c-j*e)*p;j=(n*d-j*g)*p;c=(k*e-m*c)*p;d=(k*g-m*d)*p;a=a-o*h-c*i;h=b-j*h-d*i;l.save();l.transform(o,j,c,d,a,h);l.fill();l.restore()}}}function pa(a,b,c,d,e,f,g,h,i,j,k,m,n){var o,p;o=n.width-1;p=n.height-1;g=g*o;h=h*p;c=c-a;d=d-b;e=e-a;f=f-b;i=i*o-g;j=j*p-h;k=k*o-g;m=m*p-h;p=1/(i*m-k*j);o=(m*c-j*e)*p;j=(m*d-j*f)*
+p;c=(i*e-k*c)*p;d=(i*f-k*d)*p;a=a-o*g-c*h;b=b-j*g-d*h;l.save();l.transform(o,j,c,d,a,b);l.clip();l.drawImage(n,0,0);l.restore()}function va(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);aa[0]=e<0?0:e>255?255:e;aa[1]=f<0?0:f>255?255:f;aa[2]=a<0?0:a>255?255:a;aa[4]=g<0?0:g>255?255:g;aa[5]=h<0?0:h>255?255:h;aa[6]=b<0?0:b>255?255:b;aa[8]=i<0?0:i>255?255:i;aa[9]=j<0?0:
+j>255?255:j;aa[10]=c<0?0:c>255?255:c;aa[12]=k<0?0:k>255?255:k;aa[13]=l<0?0:l>255?255:l;aa[14]=d<0?0:d>255?255:d;sa.putImageData(ya,0,0);ua.drawImage(ra,0,0);return ta}function oa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function qa(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ia(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;if(e!=0){e=1/Math.sqrt(e);c=c*e;d=d*e;b.x=b.x+c;b.y=b.y+d;a.x=a.x-c;a.y=a.y-d}}var wa,Ga,X,ba;this.autoClear?this.clear():l.setTransform(1,0,0,-1,o,q);e.info.render.vertices=0;e.info.render.faces=
+0;g=j.projectScene(a,h,this.sortElements);m=g.elements;k=g.lights;(xa=k.length>0)&&i(k);wa=0;for(Ga=m.length;wa<Ga;wa++){X=m[wa];ba=X.material;ba=ba instanceof THREE.MeshFaceMaterial?X.faceMaterial:ba;if(!(ba===void 0||ba.visible===false)){Z.empty();if(X instanceof THREE.RenderableParticle){u=X;u.x=u.x*o;u.y=u.y*q;p(u,X,ba,a)}else if(X instanceof THREE.RenderableLine){u=X.v1;z=X.v2;u.positionScreen.x=u.positionScreen.x*o;u.positionScreen.y=u.positionScreen.y*q;z.positionScreen.x=z.positionScreen.x*
 o;z.positionScreen.y=z.positionScreen.y*q;Z.addPoint(u.positionScreen.x,u.positionScreen.y);Z.addPoint(z.positionScreen.x,z.positionScreen.y);la.intersects(Z)&&r(u,z,X,ba,a)}else if(X instanceof THREE.RenderableFace3){u=X.v1;z=X.v2;D=X.v3;u.positionScreen.x=u.positionScreen.x*o;u.positionScreen.y=u.positionScreen.y*q;z.positionScreen.x=z.positionScreen.x*o;z.positionScreen.y=z.positionScreen.y*q;D.positionScreen.x=D.positionScreen.x*o;D.positionScreen.y=D.positionScreen.y*q;if(ba.overdraw){ia(u.positionScreen,
 z.positionScreen);ia(z.positionScreen,D.positionScreen);ia(D.positionScreen,u.positionScreen)}Z.add3Points(u.positionScreen.x,u.positionScreen.y,z.positionScreen.x,z.positionScreen.y,D.positionScreen.x,D.positionScreen.y);la.intersects(Z)&&s(u,z,D,0,1,2,X,ba,a)}else if(X instanceof THREE.RenderableFace4){u=X.v1;z=X.v2;D=X.v3;H=X.v4;u.positionScreen.x=u.positionScreen.x*o;u.positionScreen.y=u.positionScreen.y*q;z.positionScreen.x=z.positionScreen.x*o;z.positionScreen.y=z.positionScreen.y*q;D.positionScreen.x=
 D.positionScreen.x*o;D.positionScreen.y=D.positionScreen.y*q;H.positionScreen.x=H.positionScreen.x*o;H.positionScreen.y=H.positionScreen.y*q;P.positionScreen.copy(z.positionScreen);M.positionScreen.copy(H.positionScreen);if(ba.overdraw){ia(u.positionScreen,z.positionScreen);ia(z.positionScreen,H.positionScreen);ia(H.positionScreen,u.positionScreen);ia(D.positionScreen,P.positionScreen);ia(D.positionScreen,M.positionScreen)}Z.addPoint(u.positionScreen.x,u.positionScreen.y);Z.addPoint(z.positionScreen.x,
-z.positionScreen.y);Z.addPoint(D.positionScreen.x,D.positionScreen.y);Z.addPoint(H.positionScreen.x,H.positionScreen.y);la.intersects(Z)&&w(u,z,D,H,P,M,X,ba,a)}$.addRectangle(Z)}}i.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=true};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
+z.positionScreen.y);Z.addPoint(D.positionScreen.x,D.positionScreen.y);Z.addPoint(H.positionScreen.x,H.positionScreen.y);la.intersects(Z)&&w(u,z,D,H,P,M,X,ba,a)}$.addRectangle(Z)}}l.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=true};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};

+ 1 - 1
build/custom/ThreeExtras.js

@@ -21,7 +21,7 @@ b.vertices.length+1;v=e.clone();p=e.clone();m>=o&&m>=q&&m>=r||q>=o&&q>=m&&q>=r?(
 f.lerpSelf(e.vertexColors[1],0.5),g=e.vertexColors[2].clone(),g.lerpSelf(e.vertexColors[3],0.5),v.vertexColors[1].copy(f),v.vertexColors[2].copy(g),p.vertexColors[0].copy(f),p.vertexColors[3].copy(g)),e=0):(m=l.clone(),m.lerpSelf(n,0.5),l=k.clone(),l.lerpSelf(j,0.5),v.a=f,v.b=g,v.c=s,v.d=t,p.a=t,p.b=s,p.c=h,p.d=i,4===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(),f.lerpSelf(e.vertexNormals[2],0.5),g=e.vertexNormals[3].clone(),g.lerpSelf(e.vertexNormals[0],0.5),v.vertexNormals[2].copy(f),v.vertexNormals[3].copy(g),
 p.vertexNormals[0].copy(g),p.vertexNormals[1].copy(f)),4===e.vertexColors.length&&(f=e.vertexColors[1].clone(),f.lerpSelf(e.vertexColors[2],0.5),g=e.vertexColors[3].clone(),g.lerpSelf(e.vertexColors[0],0.5),v.vertexColors[2].copy(f),v.vertexColors[3].copy(g),p.vertexColors[0].copy(g),p.vertexColors[1].copy(f)),e=1);x.push(v,p);b.vertices.push(m,l);f=0;for(g=b.faceVertexUvs.length;f<g;f++)b.faceVertexUvs[f].length&&(j=b.faceVertexUvs[f][c],p=j[0],h=j[1],v=j[2],j=j[3],0===e?(l=p.clone(),l.lerpSelf(h,
 0.5),n=v.clone(),n.lerpSelf(j,0.5),p=[p.clone(),l.clone(),n.clone(),j.clone()],h=[l.clone(),h.clone(),v.clone(),n.clone()]):(l=h.clone(),l.lerpSelf(v,0.5),n=j.clone(),n.lerpSelf(p,0.5),p=[p.clone(),h.clone(),l.clone(),n.clone()],h=[n.clone(),l.clone(),v.clone(),j.clone()]),z[f].push(p,h))}else{x.push(e);f=0;for(g=b.faceVertexUvs.length;f<g;f++)z[f].push(b.faceVertexUvs[f][c])}b.faces=x;b.faceVertexUvs=z}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
-THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(b,a,c,d){var e=new THREE.Texture(void 0,a),a=new THREE.ImageLoader;a.addEventListener("load",function(a){e.image=a.content;e.needsUpdate=!0;c&&c()});a.addEventListener("error",function(a){d&&d(a.message)});a.crossOrigin=this.crossOrigin;a.load(b);return e},loadTextureCube:function(b,a,c){var d,e=[],f=new THREE.Texture(e,a),a=e.loadCount=0;for(d=b.length;a<d;++a)e[a]=new Image,e[a].onload=function(){e.loadCount+=1;6===e.loadCount&&(f.needsUpdate=
+THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(b,a,c,d){var e=new THREE.Texture(void 0,a),a=new THREE.ImageLoader;a.addEventListener("load",function(a){e.image=a.content;e.needsUpdate=!0;c&&c(e)});a.addEventListener("error",function(a){d&&d(a.message)});a.crossOrigin=this.crossOrigin;a.load(b);return e},loadTextureCube:function(b,a,c){var d,e=[],f=new THREE.Texture(e,a),a=e.loadCount=0;for(d=b.length;a<d;++a)e[a]=new Image,e[a].onload=function(){e.loadCount+=1;6===e.loadCount&&(f.needsUpdate=
 !0,c&&c())},e[a].crossOrigin=this.crossOrigin,e[a].src=b[a];return f},getNormalMap:function(b,a){var c=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},a=a|1,d=b.width,e=b.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(b,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),j=i.data,l=0;l<d;l++)for(var n=0;n<e;n++){var k=0>n-1?0:n-1,m=n+1>e-1?e-1:n+1,o=0>l-1?0:l-1,q=l+1>d-1?d-1:l+1,r=[],s=[0,
 0,h[4*(n*d+l)]/255*a];r.push([-1,0,h[4*(n*d+o)]/255*a]);r.push([-1,-1,h[4*(k*d+o)]/255*a]);r.push([0,-1,h[4*(k*d+l)]/255*a]);r.push([1,-1,h[4*(k*d+q)]/255*a]);r.push([1,0,h[4*(n*d+q)]/255*a]);r.push([1,1,h[4*(m*d+q)]/255*a]);r.push([0,1,h[4*(m*d+l)]/255*a]);r.push([-1,1,h[4*(m*d+o)]/255*a]);k=[];o=r.length;for(m=0;m<o;m++){var q=r[m],t=r[(m+1)%o],q=[q[0]-s[0],q[1]-s[1],q[2]-s[2]],t=[t[0]-s[0],t[1]-s[1],t[2]-s[2]];k.push(c([q[1]*t[2]-q[2]*t[1],q[2]*t[0]-q[0]*t[2],q[0]*t[1]-q[1]*t[0]]))}r=[0,0,0];for(m=
 0;m<k.length;m++)r[0]+=k[m][0],r[1]+=k[m][1],r[2]+=k[m][2];r[0]/=k.length;r[1]/=k.length;r[2]/=k.length;s=4*(n*d+l);j[s]=255*((r[0]+1)/2)|0;j[s+1]=255*((r[1]+1)/2)|0;j[s+2]=255*r[2]|0;j[s+3]=255}g.putImageData(i,0,0);return f},generateDataTexture:function(b,a,c){for(var d=b*a,e=new Uint8Array(3*d),f=Math.floor(255*c.r),g=Math.floor(255*c.g),c=Math.floor(255*c.b),h=0;h<d;h++)e[3*h]=f,e[3*h+1]=g,e[3*h+2]=c;b=new THREE.DataTexture(e,b,a,THREE.RGBFormat);b.needsUpdate=!0;return b}};

+ 79 - 78
build/custom/ThreeWebGL.js

@@ -27,11 +27,12 @@ k)if(l<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(l);b=d/c;d=m/c}els
 THREE.EventTarget=function(){var a={};this.addEventListener=function(b,c){a[b]===void 0&&(a[b]=[]);a[b].indexOf(c)===-1&&a[b].push(c)};this.dispatchEvent=function(b){for(var c in a[b.type])a[b.type][c](b)};this.removeEventListener=function(b,c){var d=a[b].indexOf(c);d!==-1&&a[b].splice(d,1)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
 THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes,d=a.elements,a=d[0];b=d[1];var f=d[2],e=d[3],h=d[4],l=d[5],m=d[6],k=d[7],i=d[8],o=d[9],j=d[10],w=d[11],r=d[12],n=d[13],q=d[14],d=d[15];c[0].set(e-a,k-h,w-i,d-r);c[1].set(e+a,k+h,w+i,d+r);c[2].set(e+b,k+l,w+o,d+n);c[3].set(e-b,k-l,w-o,d-n);c[4].set(e-f,k-m,w-j,d-q);c[5].set(e+f,k+m,w+j,d+q);for(a=0;a<6;a++){b=c[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};
 THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=c.elements,c=-a.geometry.boundingSphere.radius*c.getMaxScaleOnAxis(),f=0;f<6;f++){a=b[f].x*d[12]+b[f].y*d[13]+b[f].z*d[14]+b[f].w;if(a<=c)return false}return true};THREE.Frustum.__v1=new THREE.Vector3;
-THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var f=new THREE.Vector3,e=new THREE.Vector3,h=new THREE.Vector3,l=new THREE.Vector3,m=new THREE.Vector3,k=new THREE.Vector3,i=new THREE.Vector3,o=new THREE.Vector3,j=new THREE.Vector3,w=function(a,b){return a.distance-b.distance},r=new THREE.Vector3,n=new THREE.Vector3,q=new THREE.Vector3,p,s,B,A=function(a,b,c){r.sub(c,a);p=r.dot(b);s=n.add(a,q.copy(b).multiplyScalar(p));
-return B=c.distanceTo(s)},u,J,D,M,E,Q,G,R,T=function(a,b,c,d){r.sub(d,b);n.sub(c,b);q.sub(a,b);u=r.dot(r);J=r.dot(n);D=r.dot(q);M=n.dot(n);E=n.dot(q);Q=1/(u*M-J*J);G=(M*D-J*E)*Q;R=(u*E-J*D)*Q;return G>=0&&R>=0&&G+R<1},S=1.0E-4;this.setPrecision=function(a){S=a};this.intersectObject=function(a){var b,c=[];if(a instanceof THREE.Particle){B=A(this.origin,this.direction,a.matrixWorld.getPosition());if(B>a.scale.x)return[];b={distance:B,point:a.position,face:null,object:a};c.push(b)}else if(a instanceof
-THREE.Mesh){var d=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length()),d=a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z));B=A(this.origin,this.direction,a.matrixWorld.getPosition());if(B>d)return c;var g,n,r,q=a.geometry,p=q.vertices,s;a.matrixRotationWorld.extractRotation(a.matrixWorld);d=0;for(g=q.faces.length;d<g;d++){b=q.faces[d];m.copy(this.origin);k.copy(this.direction);s=a.matrixWorld;i=s.multiplyVector3(i.copy(b.centroid)).subSelf(m);
-o=a.matrixRotationWorld.multiplyVector3(o.copy(b.normal));n=k.dot(o);if(!(Math.abs(n)<S)){r=o.dot(i)/n;if(!(r<0)&&(a.doubleSided||(a.flipSided?n>0:n<0))){j.add(m,k.multiplyScalar(r));B=m.distanceTo(j);if(!(B<this.near)&&!(B>this.far))if(b instanceof THREE.Face3){f=s.multiplyVector3(f.copy(p[b.a]));e=s.multiplyVector3(e.copy(p[b.b]));h=s.multiplyVector3(h.copy(p[b.c]));if(T(j,f,e,h)){b={distance:B,point:j.clone(),face:b,object:a};c.push(b)}}else if(b instanceof THREE.Face4){f=s.multiplyVector3(f.copy(p[b.a]));
-e=s.multiplyVector3(e.copy(p[b.b]));h=s.multiplyVector3(h.copy(p[b.c]));l=s.multiplyVector3(l.copy(p[b.d]));if(T(j,f,e,l)||T(j,e,h,l)){b={distance:B,point:j.clone(),face:b,object:a};c.push(b)}}}}}}c.sort(w);return c};this.intersectObjects=function(a){for(var b=[],c=0,d=a.length;c<d;c++)Array.prototype.push.apply(b,this.intersectObject(a[c]));b.sort(w);return b}};
+THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var f=new THREE.Vector3,e=new THREE.Vector3,h=new THREE.Vector3,l=new THREE.Vector3,m=new THREE.Vector3,k=new THREE.Vector3,i=new THREE.Vector3,o=new THREE.Vector3,j=new THREE.Vector3,w=function(a,b){return a.distance-b.distance},r=new THREE.Vector3,n=new THREE.Vector3,q=new THREE.Vector3,p,u,B,A=function(a,b,c){r.sub(c,a);p=r.dot(b);u=n.add(a,q.copy(b).multiplyScalar(p));
+return B=c.distanceTo(u)},s,J,D,M,E,Q,G,R,T=function(a,b,c,d){r.sub(d,b);n.sub(c,b);q.sub(a,b);s=r.dot(r);J=r.dot(n);D=r.dot(q);M=n.dot(n);E=n.dot(q);Q=1/(s*M-J*J);G=(M*D-J*E)*Q;R=(s*E-J*D)*Q;return G>=0&&R>=0&&G+R<1},S=1.0E-4;this.setPrecision=function(a){S=a};this.intersectObject=function(a,b){var c,d=[];if(b===true)for(var g=0,n=a.children.length;g<n;g++)Array.prototype.push.apply(d,this.intersectObject(a.children[g],b));if(a instanceof THREE.Particle){B=A(this.origin,this.direction,a.matrixWorld.getPosition());
+if(B>a.scale.x)return[];c={distance:B,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){g=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());g=a.geometry.boundingSphere.radius*Math.max(g.x,Math.max(g.y,g.z));B=A(this.origin,this.direction,a.matrixWorld.getPosition());if(B>g)return d;var r,q,p=a.geometry,u=p.vertices,s;a.matrixRotationWorld.extractRotation(a.matrixWorld);g=0;for(n=p.faces.length;g<
+n;g++){c=p.faces[g];m.copy(this.origin);k.copy(this.direction);s=a.matrixWorld;i=s.multiplyVector3(i.copy(c.centroid)).subSelf(m);o=a.matrixRotationWorld.multiplyVector3(o.copy(c.normal));r=k.dot(o);if(!(Math.abs(r)<S)){q=o.dot(i)/r;if(!(q<0)&&(a.doubleSided||(a.flipSided?r>0:r<0))){j.add(m,k.multiplyScalar(q));B=m.distanceTo(j);if(!(B<this.near)&&!(B>this.far))if(c instanceof THREE.Face3){f=s.multiplyVector3(f.copy(u[c.a]));e=s.multiplyVector3(e.copy(u[c.b]));h=s.multiplyVector3(h.copy(u[c.c]));
+if(T(j,f,e,h)){c={distance:B,point:j.clone(),face:c,object:a};d.push(c)}}else if(c instanceof THREE.Face4){f=s.multiplyVector3(f.copy(u[c.a]));e=s.multiplyVector3(e.copy(u[c.b]));h=s.multiplyVector3(h.copy(u[c.c]));l=s.multiplyVector3(l.copy(u[c.d]));if(T(j,f,e,l)||T(j,e,h,l)){c={distance:B,point:j.clone(),face:c,object:a};d.push(c)}}}}}}d.sort(w);return d};this.intersectObjects=function(a,b){for(var c=[],d=0,g=a.length;d<g;d++)Array.prototype.push.apply(c,this.intersectObject(a[d],b));c.sort(w);
+return c}};
 THREE.Rectangle=function(){function a(){e=d-b;h=f-c}var b,c,d,f,e,h,l=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,h,i,o){l=false;b=e;c=h;d=i;f=o;a()};this.addPoint=function(e,h){if(l){l=false;b=e;c=h;d=e;f=h}else{b=b<e?b:e;c=c<h?c:h;d=d>e?d:e;f=f>h?
 f:h}a()};this.add3Points=function(e,h,i,o,j,w){if(l){l=false;b=e<i?e<j?e:j:i<j?i:j;c=h<o?h<w?h:w:o<w?o:w;d=e>i?e>j?e:j:i>j?i:j;f=h>o?h>w?h:w:o>w?o:w}else{b=e<i?e<j?e<b?e:b:j<b?j:b:i<j?i<b?i:b:j<b?j:b;c=h<o?h<w?h<c?h:c:w<c?w:c:o<w?o<c?o:c:w<c?w:c;d=e>i?e>j?e>d?e:d:j>d?j:d:i>j?i>d?i:d:j>d?j:d;f=h>o?h>w?h>f?h:f:w>f?w:f:o>w?o>f?o:f:w>f?w:f}a()};this.addRectangle=function(e){if(l){l=false;b=e.getLeft();c=e.getTop();d=e.getRight();f=e.getBottom()}else{b=b<e.getLeft()?b:e.getLeft();c=c<e.getTop()?c:e.getTop();
 d=d>e.getRight()?d:e.getRight();f=f>e.getBottom()?f:e.getBottom()}a()};this.inflate=function(e){b=b-e;c=c-e;d=d+e;f=f+e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d<e.getRight()?d:e.getRight();f=f<e.getBottom()?f:e.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||f<a.getTop()||c>a.getBottom()?false:true};this.empty=function(){l=true;f=d=c=b=0;a()};this.isEmpty=function(){return l}};
@@ -39,8 +40,8 @@ THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b
 THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],f=-b[10]*b[4]+b[6]*b[8],e=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],m=-b[9]*b[0]+b[1]*b[8],k=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*f+b[2]*l;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,i=this.elements;i[0]=b*a;i[1]=b*c;i[2]=b*d;i[3]=b*f;i[4]=b*e;i[5]=b*h;i[6]=b*l;i[7]=b*m;i[8]=b*k;return this},
 transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,e,h,l,m,k,i,o,j,w,r,n){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,h||0,l||0,m||0,k||0,i!==void 0?i:1,o||0,j||0,w||0,r||0,n!==void 0?n:1)};
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,h,l,m,k,i,o,j,w,r,n){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=f;q[5]=e;q[9]=h;q[13]=l;q[2]=m;q[6]=k;q[10]=i;q[14]=o;q[3]=j;q[7]=w;q[11]=r;q[15]=n;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements,
-f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x=h.x+1.0E-4;f.cross(c,h).normalize()}e.cross(h,f);d[0]=f.x;d[4]=e.x;d[8]=h.x;d[1]=f.y;d[5]=e.y;d[9]=h.y;d[2]=f.z;d[6]=e.z;d[10]=h.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,f=this.elements,e=c[0],h=c[4],l=c[8],m=c[12],k=c[1],i=c[5],o=c[9],j=c[13],w=c[2],r=c[6],n=c[10],q=c[14],p=c[3],s=c[7],B=c[11],c=c[15],A=d[0],u=d[4],
-J=d[8],D=d[12],M=d[1],E=d[5],Q=d[9],G=d[13],R=d[2],T=d[6],S=d[10],y=d[14],L=d[3],Z=d[7],F=d[11],d=d[15];f[0]=e*A+h*M+l*R+m*L;f[4]=e*u+h*E+l*T+m*Z;f[8]=e*J+h*Q+l*S+m*F;f[12]=e*D+h*G+l*y+m*d;f[1]=k*A+i*M+o*R+j*L;f[5]=k*u+i*E+o*T+j*Z;f[9]=k*J+i*Q+o*S+j*F;f[13]=k*D+i*G+o*y+j*d;f[2]=w*A+r*M+n*R+q*L;f[6]=w*u+r*E+n*T+q*Z;f[10]=w*J+r*Q+n*S+q*F;f[14]=w*D+r*G+n*y+q*d;f[3]=p*A+s*M+B*R+c*L;f[7]=p*u+s*E+B*T+c*Z;f[11]=p*J+s*Q+B*S+c*F;f[15]=p*D+s*G+B*y+c*d;return this},multiplySelf:function(a){return this.multiply(this,
+f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x=h.x+1.0E-4;f.cross(c,h).normalize()}e.cross(h,f);d[0]=f.x;d[4]=e.x;d[8]=h.x;d[1]=f.y;d[5]=e.y;d[9]=h.y;d[2]=f.z;d[6]=e.z;d[10]=h.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,f=this.elements,e=c[0],h=c[4],l=c[8],m=c[12],k=c[1],i=c[5],o=c[9],j=c[13],w=c[2],r=c[6],n=c[10],q=c[14],p=c[3],u=c[7],B=c[11],c=c[15],A=d[0],s=d[4],
+J=d[8],D=d[12],M=d[1],E=d[5],Q=d[9],G=d[13],R=d[2],T=d[6],S=d[10],y=d[14],L=d[3],Z=d[7],F=d[11],d=d[15];f[0]=e*A+h*M+l*R+m*L;f[4]=e*s+h*E+l*T+m*Z;f[8]=e*J+h*Q+l*S+m*F;f[12]=e*D+h*G+l*y+m*d;f[1]=k*A+i*M+o*R+j*L;f[5]=k*s+i*E+o*T+j*Z;f[9]=k*J+i*Q+o*S+j*F;f[13]=k*D+i*G+o*y+j*d;f[2]=w*A+r*M+n*R+q*L;f[6]=w*s+r*E+n*T+q*Z;f[10]=w*J+r*Q+n*S+q*F;f[14]=w*D+r*G+n*y+q*d;f[3]=p*A+u*M+B*R+c*L;f[7]=p*s+u*E+B*T+c*Z;f[11]=p*J+u*Q+B*S+c*F;f[15]=p*D+u*G+B*y+c*d;return this},multiplySelf:function(a){return this.multiply(this,
 a)},multiplyToArray:function(a,b,c){var d=this.elements;this.multiply(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]=b[0]*a;b[4]=b[4]*a;b[8]=b[8]*a;b[12]=b[12]*a;b[1]=b[1]*a;b[5]=b[5]*a;b[9]=b[9]*a;b[13]=b[13]*a;b[2]=b[2]*a;b[6]=b[6]*a;b[10]=b[10]*a;b[14]=b[14]*a;b[3]=b[3]*a;b[7]=b[7]*a;b[11]=b[11]*a;b[15]=
 b[15]*a;return this},multiplyVector3:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=1/(b[3]*c+b[7]*d+b[11]*f+b[15]);a.x=(b[0]*c+b[4]*d+b[8]*f+b[12])*e;a.y=(b[1]*c+b[5]*d+b[9]*f+b[13])*e;a.z=(b[2]*c+b[6]*d+b[10]*f+b[14])*e;return a},multiplyVector4:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=a.w;a.x=b[0]*c+b[4]*d+b[8]*f+b[12]*e;a.y=b[1]*c+b[5]*d+b[9]*f+b[13]*e;a.z=b[2]*c+b[6]*d+b[10]*f+b[14]*e;a.w=b[3]*c+b[7]*d+b[11]*f+b[15]*e;return a},rotateAxis:function(a){var b=this.elements,c=a.x,
 d=a.y,f=a.z;a.x=c*b[0]+d*b[4]+f*b[8];a.y=c*b[1]+d*b[5]+f*b[9];a.z=c*b[2]+d*b[6]+f*b[10];a.normalize();return a},crossVector:function(a){var b=this.elements,c=new THREE.Vector4;c.x=b[0]*a.x+b[4]*a.y+b[8]*a.z+b[12]*a.w;c.y=b[1]*a.x+b[5]*a.y+b[9]*a.z+b[13]*a.w;c.z=b[2]*a.x+b[6]*a.y+b[10]*a.z+b[14]*a.w;c.w=a.w?b[3]*a.x+b[7]*a.y+b[11]*a.z+b[15]*a.w:1;return c},determinant:function(){var a=this.elements,b=a[0],c=a[4],d=a[8],f=a[12],e=a[1],h=a[5],l=a[9],m=a[13],k=a[2],i=a[6],o=a[10],j=a[14],w=a[3],r=a[7],
@@ -56,7 +57,7 @@ c.x=f.length();c.y=e.length();c.z=h.length();a.x=d[12];a.y=d[13];a.z=d[14];d=THR
 b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractRotation:function(a){var b=this.elements,a=a.elements,c=THREE.Matrix4.__v1,d=1/c.set(a[0],a[1],a[2]).length(),f=1/c.set(a[4],a[5],a[6]).length(),c=1/c.set(a[8],a[9],a[10]).length();b[0]=a[0]*d;b[1]=a[1]*d;b[2]=a[2]*d;b[4]=a[4]*f;b[5]=a[5]*f;b[6]=a[6]*f;b[8]=a[8]*c;b[9]=a[9]*c;b[10]=a[10]*c;return this},translate:function(a){var b=this.elements,c=a.x,d=a.y,a=a.z;b[12]=b[0]*c+b[4]*d+b[8]*a+b[12];b[13]=b[1]*c+b[5]*d+b[9]*a+b[13];b[14]=b[2]*c+b[6]*
 d+b[10]*a+b[14];b[15]=b[3]*c+b[7]*d+b[11]*a+b[15];return this},rotateX:function(a){var b=this.elements,c=b[4],d=b[5],f=b[6],e=b[7],h=b[8],l=b[9],m=b[10],k=b[11],i=Math.cos(a),a=Math.sin(a);b[4]=i*c+a*h;b[5]=i*d+a*l;b[6]=i*f+a*m;b[7]=i*e+a*k;b[8]=i*h-a*c;b[9]=i*l-a*d;b[10]=i*m-a*f;b[11]=i*k-a*e;return this},rotateY:function(a){var b=this.elements,c=b[0],d=b[1],f=b[2],e=b[3],h=b[8],l=b[9],m=b[10],k=b[11],i=Math.cos(a),a=Math.sin(a);b[0]=i*c-a*h;b[1]=i*d-a*l;b[2]=i*f-a*m;b[3]=i*e-a*k;b[8]=i*h+a*c;b[9]=
 i*l+a*d;b[10]=i*m+a*f;b[11]=i*k+a*e;return this},rotateZ:function(a){var b=this.elements,c=b[0],d=b[1],f=b[2],e=b[3],h=b[4],l=b[5],m=b[6],k=b[7],i=Math.cos(a),a=Math.sin(a);b[0]=i*c+a*h;b[1]=i*d+a*l;b[2]=i*f+a*m;b[3]=i*e+a*k;b[4]=i*h-a*c;b[5]=i*l-a*d;b[6]=i*m-a*f;b[7]=i*k-a*e;return this},rotateByAxis:function(a,b){var c=this.elements;if(a.x===1&&a.y===0&&a.z===0)return this.rotateX(b);if(a.x===0&&a.y===1&&a.z===0)return this.rotateY(b);if(a.x===0&&a.y===0&&a.z===1)return this.rotateZ(b);var d=a.x,
-f=a.y,e=a.z,h=Math.sqrt(d*d+f*f+e*e),d=d/h,f=f/h,e=e/h,h=d*d,l=f*f,m=e*e,k=Math.cos(b),i=Math.sin(b),o=1-k,j=d*f*o,w=d*e*o,o=f*e*o,d=d*i,r=f*i,i=e*i,e=h+(1-h)*k,h=j+i,f=w-r,j=j-i,l=l+(1-l)*k,i=o+d,w=w+r,o=o-d,m=m+(1-m)*k,k=c[0],d=c[1],r=c[2],n=c[3],q=c[4],p=c[5],s=c[6],B=c[7],A=c[8],u=c[9],J=c[10],D=c[11];c[0]=e*k+h*q+f*A;c[1]=e*d+h*p+f*u;c[2]=e*r+h*s+f*J;c[3]=e*n+h*B+f*D;c[4]=j*k+l*q+i*A;c[5]=j*d+l*p+i*u;c[6]=j*r+l*s+i*J;c[7]=j*n+l*B+i*D;c[8]=w*k+o*q+m*A;c[9]=w*d+o*p+m*u;c[10]=w*r+o*s+m*J;c[11]=
+f=a.y,e=a.z,h=Math.sqrt(d*d+f*f+e*e),d=d/h,f=f/h,e=e/h,h=d*d,l=f*f,m=e*e,k=Math.cos(b),i=Math.sin(b),o=1-k,j=d*f*o,w=d*e*o,o=f*e*o,d=d*i,r=f*i,i=e*i,e=h+(1-h)*k,h=j+i,f=w-r,j=j-i,l=l+(1-l)*k,i=o+d,w=w+r,o=o-d,m=m+(1-m)*k,k=c[0],d=c[1],r=c[2],n=c[3],q=c[4],p=c[5],u=c[6],B=c[7],A=c[8],s=c[9],J=c[10],D=c[11];c[0]=e*k+h*q+f*A;c[1]=e*d+h*p+f*s;c[2]=e*r+h*u+f*J;c[3]=e*n+h*B+f*D;c[4]=j*k+l*q+i*A;c[5]=j*d+l*p+i*s;c[6]=j*r+l*u+i*J;c[7]=j*n+l*B+i*D;c[8]=w*k+o*q+m*A;c[9]=w*d+o*p+m*s;c[10]=w*r+o*u+m*J;c[11]=
 w*n+o*B+m*D;return this},scale:function(a){var b=this.elements,c=a.x,d=a.y,a=a.z;b[0]=b[0]*c;b[4]=b[4]*d;b[8]=b[8]*a;b[1]=b[1]*c;b[5]=b[5]*d;b[9]=b[9]*a;b[2]=b[2]*c;b[6]=b[6]*d;b[10]=b[10]*a;b[3]=b[3]*c;b[7]=b[7]*d;b[11]=b[11]*a;return this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],Math.max(a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10])))},makeTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},
 makeRotationX: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},makeRotationY: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},makeRotationZ: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},makeRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,e=a.x,h=a.y,l=a.z,m=f*e,k=f*h;this.set(m*e+c,m*h-d*l,m*l+d*h,0,m*h+d*l,k*h+c,k*l-d*e,0,m*l-
 d*h,k*l+d*e,f*l*l+c,0,0,0,0,1);return this},makeScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},makeFrustum:function(a,b,c,d,f,e){var h=this.elements;h[0]=2*f/(b-a);h[4]=0;h[8]=(b+a)/(b-a);h[12]=0;h[1]=0;h[5]=2*f/(d-c);h[9]=(d+c)/(d-c);h[13]=0;h[2]=0;h[6]=0;h[10]=-(e+f)/(e-f);h[14]=-2*e*f/(e-f);h[3]=0;h[7]=0;h[11]=-1;h[15]=0;return this},makePerspective:function(a,b,c,d){var a=c*Math.tan(a*Math.PI/360),f=-a;return this.makeFrustum(f*b,a*b,f,a,c,d)},makeOrthographic:function(a,
@@ -70,17 +71,17 @@ b.parent;b!==void 0&&b instanceof THREE.Scene&&b.__addObject(a)}},remove:functio
 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=true},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=false;a=true}for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)},worldToLocal:function(a){return THREE.Object3D.__m1.getInverse(this.matrixWorld).multiplyVector3(a)},localToWorld:function(a){return this.matrixWorld.multiplyVector3(a)}};THREE.Object3D.__m1=new THREE.Matrix4;THREE.Object3DCount=0;
 THREE.Projector=function(){function a(){var a=h[e]=h[e]||new THREE.RenderableObject;e++;return a}function b(){var a=k[m]=k[m]||new THREE.RenderableVertex;m++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(e>=0&&f>=0&&g>=0&&h>=0)return true;if(e<0&&f<0||g<0&&h<0)return false;e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f)));g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h)));if(d<c)return false;a.lerpSelf(b,c);b.lerpSelf(a,1-
-d);return true}var f,e,h=[],l,m,k=[],i,o,j=[],w,r=[],n,q,p=[],s,B,A=[],u={objects:[],sprites:[],lights:[],elements:[]},J=new THREE.Vector3,D=new THREE.Vector4,M=new THREE.Matrix4,E=new THREE.Matrix4,Q=new THREE.Frustum,G=new THREE.Vector4,R=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);M.multiply(b.projectionMatrix,b.matrixWorldInverse);M.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);
-M.multiply(b.matrixWorld,b.projectionMatrixInverse);M.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){e=0;u.objects.length=0;u.sprites.length=0;u.lights.length=0;var h=function(b){if(b.visible!==false){if((b instanceof THREE.Mesh||b instanceof THREE.Line)&&(b.frustumCulled===false||Q.contains(b))){J.copy(b.matrixWorld.getPosition());
-M.multiplyVector3(J);f=a();f.object=b;f.z=J.z;u.objects.push(f)}else if(b instanceof THREE.Sprite||b instanceof THREE.Particle){J.copy(b.matrixWorld.getPosition());M.multiplyVector3(J);f=a();f.object=b;f.z=J.z;u.sprites.push(f)}else b instanceof THREE.Light&&u.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)h(b.children[c])}};h(b);d&&u.objects.sort(c);return u};this.projectScene=function(a,e,f){var h=e.near,J=e.far,F=false,g,W,I,za,H,na,ca,ga,oa,Ba,Ha,Ia,Sa,Ua,Na;B=q=w=o=0;u.elements.length=
-0;if(e.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(e)}a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);M.multiply(e.projectionMatrix,e.matrixWorldInverse);Q.setFromMatrix(M);u=this.projectGraph(a,false);a=0;for(g=u.objects.length;a<g;a++){oa=u.objects[a].object;Ba=oa.matrixWorld;m=0;if(oa instanceof THREE.Mesh){Ha=oa.geometry;Ia=oa.geometry.materials;za=Ha.vertices;Sa=Ha.faces;Ua=Ha.faceVertexUvs;Ha=oa.matrixRotationWorld.extractRotation(Ba);
+d);return true}var f,e,h=[],l,m,k=[],i,o,j=[],w,r=[],n,q,p=[],u,B,A=[],s={objects:[],sprites:[],lights:[],elements:[]},J=new THREE.Vector3,D=new THREE.Vector4,M=new THREE.Matrix4,E=new THREE.Matrix4,Q=new THREE.Frustum,G=new THREE.Vector4,R=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);M.multiply(b.projectionMatrix,b.matrixWorldInverse);M.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);
+M.multiply(b.matrixWorld,b.projectionMatrixInverse);M.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){e=0;s.objects.length=0;s.sprites.length=0;s.lights.length=0;var h=function(b){if(b.visible!==false){if((b instanceof THREE.Mesh||b instanceof THREE.Line)&&(b.frustumCulled===false||Q.contains(b))){J.copy(b.matrixWorld.getPosition());
+M.multiplyVector3(J);f=a();f.object=b;f.z=J.z;s.objects.push(f)}else if(b instanceof THREE.Sprite||b instanceof THREE.Particle){J.copy(b.matrixWorld.getPosition());M.multiplyVector3(J);f=a();f.object=b;f.z=J.z;s.sprites.push(f)}else b instanceof THREE.Light&&s.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)h(b.children[c])}};h(b);d&&s.objects.sort(c);return s};this.projectScene=function(a,e,f){var h=e.near,J=e.far,F=false,g,W,I,za,H,na,ca,ga,oa,Ba,Ha,Ia,Sa,Ua,Na;B=q=w=o=0;s.elements.length=
+0;if(e.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(e)}a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);M.multiply(e.projectionMatrix,e.matrixWorldInverse);Q.setFromMatrix(M);s=this.projectGraph(a,false);a=0;for(g=s.objects.length;a<g;a++){oa=s.objects[a].object;Ba=oa.matrixWorld;m=0;if(oa instanceof THREE.Mesh){Ha=oa.geometry;Ia=oa.geometry.materials;za=Ha.vertices;Sa=Ha.faces;Ua=Ha.faceVertexUvs;Ha=oa.matrixRotationWorld.extractRotation(Ba);
 W=0;for(I=za.length;W<I;W++){l=b();l.positionWorld.copy(za[W]);Ba.multiplyVector3(l.positionWorld);l.positionScreen.copy(l.positionWorld);M.multiplyVector4(l.positionScreen);l.positionScreen.x=l.positionScreen.x/l.positionScreen.w;l.positionScreen.y=l.positionScreen.y/l.positionScreen.w;l.visible=l.positionScreen.z>h&&l.positionScreen.z<J}za=0;for(W=Sa.length;za<W;za++){I=Sa[za];if(I instanceof THREE.Face3){H=k[I.a];na=k[I.b];ca=k[I.c];if(H.visible&&na.visible&&ca.visible){F=(ca.positionScreen.x-
 H.positionScreen.x)*(na.positionScreen.y-H.positionScreen.y)-(ca.positionScreen.y-H.positionScreen.y)*(na.positionScreen.x-H.positionScreen.x)<0;if(oa.doubleSided||F!=oa.flipSided){ga=j[o]=j[o]||new THREE.RenderableFace3;o++;i=ga;i.v1.copy(H);i.v2.copy(na);i.v3.copy(ca)}else continue}else continue}else if(I instanceof THREE.Face4){H=k[I.a];na=k[I.b];ca=k[I.c];ga=k[I.d];if(H.visible&&na.visible&&ca.visible&&ga.visible){F=(ga.positionScreen.x-H.positionScreen.x)*(na.positionScreen.y-H.positionScreen.y)-
 (ga.positionScreen.y-H.positionScreen.y)*(na.positionScreen.x-H.positionScreen.x)<0||(na.positionScreen.x-ca.positionScreen.x)*(ga.positionScreen.y-ca.positionScreen.y)-(na.positionScreen.y-ca.positionScreen.y)*(ga.positionScreen.x-ca.positionScreen.x)<0;if(oa.doubleSided||F!=oa.flipSided){Na=r[w]=r[w]||new THREE.RenderableFace4;w++;i=Na;i.v1.copy(H);i.v2.copy(na);i.v3.copy(ca);i.v4.copy(ga)}else continue}else continue}i.normalWorld.copy(I.normal);!F&&(oa.flipSided||oa.doubleSided)&&i.normalWorld.negate();
 Ha.multiplyVector3(i.normalWorld);i.centroidWorld.copy(I.centroid);Ba.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);M.multiplyVector3(i.centroidScreen);ca=I.vertexNormals;H=0;for(na=ca.length;H<na;H++){ga=i.vertexNormalsWorld[H];ga.copy(ca[H]);!F&&(oa.flipSided||oa.doubleSided)&&ga.negate();Ha.multiplyVector3(ga)}H=0;for(na=Ua.length;H<na;H++)if(Na=Ua[H][za]){ca=0;for(ga=Na.length;ca<ga;ca++)i.uvs[H][ca]=Na[ca]}i.material=oa.material;i.faceMaterial=I.materialIndex!==null?
-Ia[I.materialIndex]:null;i.z=i.centroidScreen.z;u.elements.push(i)}}else if(oa instanceof THREE.Line){E.multiply(M,Ba);za=oa.geometry.vertices;H=b();H.positionScreen.copy(za[0]);E.multiplyVector4(H.positionScreen);Ba=oa.type===THREE.LinePieces?2:1;W=1;for(I=za.length;W<I;W++){H=b();H.positionScreen.copy(za[W]);E.multiplyVector4(H.positionScreen);if(!((W+1)%Ba>0)){na=k[m-2];G.copy(H.positionScreen);R.copy(na.positionScreen);if(d(G,R)){G.multiplyScalar(1/G.w);R.multiplyScalar(1/R.w);Ia=p[q]=p[q]||new THREE.RenderableLine;
-q++;n=Ia;n.v1.positionScreen.copy(G);n.v2.positionScreen.copy(R);n.z=Math.max(G.z,R.z);n.material=oa.material;u.elements.push(n)}}}}}a=0;for(g=u.sprites.length;a<g;a++){oa=u.sprites[a].object;Ba=oa.matrixWorld;if(oa instanceof THREE.Particle){D.set(Ba.elements[12],Ba.elements[13],Ba.elements[14],1);M.multiplyVector4(D);D.z=D.z/D.w;if(D.z>0&&D.z<1){h=A[B]=A[B]||new THREE.RenderableParticle;B++;s=h;s.x=D.x/D.w;s.y=D.y/D.w;s.z=D.z;s.rotation=oa.rotation.z;s.scale.x=oa.scale.x*Math.abs(s.x-(D.x+e.projectionMatrix.elements[0])/
-(D.w+e.projectionMatrix.elements[12]));s.scale.y=oa.scale.y*Math.abs(s.y-(D.y+e.projectionMatrix.elements[5])/(D.w+e.projectionMatrix.elements[13]));s.material=oa.material;u.elements.push(s)}}}f&&u.elements.sort(c);return u}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1};
+Ia[I.materialIndex]:null;i.z=i.centroidScreen.z;s.elements.push(i)}}else if(oa instanceof THREE.Line){E.multiply(M,Ba);za=oa.geometry.vertices;H=b();H.positionScreen.copy(za[0]);E.multiplyVector4(H.positionScreen);Ba=oa.type===THREE.LinePieces?2:1;W=1;for(I=za.length;W<I;W++){H=b();H.positionScreen.copy(za[W]);E.multiplyVector4(H.positionScreen);if(!((W+1)%Ba>0)){na=k[m-2];G.copy(H.positionScreen);R.copy(na.positionScreen);if(d(G,R)){G.multiplyScalar(1/G.w);R.multiplyScalar(1/R.w);Ia=p[q]=p[q]||new THREE.RenderableLine;
+q++;n=Ia;n.v1.positionScreen.copy(G);n.v2.positionScreen.copy(R);n.z=Math.max(G.z,R.z);n.material=oa.material;s.elements.push(n)}}}}}a=0;for(g=s.sprites.length;a<g;a++){oa=s.sprites[a].object;Ba=oa.matrixWorld;if(oa instanceof THREE.Particle){D.set(Ba.elements[12],Ba.elements[13],Ba.elements[14],1);M.multiplyVector4(D);D.z=D.z/D.w;if(D.z>0&&D.z<1){h=A[B]=A[B]||new THREE.RenderableParticle;B++;u=h;u.x=D.x/D.w;u.y=D.y/D.w;u.z=D.z;u.rotation=oa.rotation.z;u.scale.x=oa.scale.x*Math.abs(u.x-(D.x+e.projectionMatrix.elements[0])/
+(D.w+e.projectionMatrix.elements[12]));u.scale.y=oa.scale.y*Math.abs(u.y-(D.y+e.projectionMatrix.elements[5])/(D.w+e.projectionMatrix.elements[13]));u.material=oa.material;s.elements.push(u)}}}f&&s.elements.sort(c);return s}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a,b){var c=b||"XYZ",d=Math.cos(a.x/2),f=Math.cos(a.y/2),e=Math.cos(a.z/2),h=Math.sin(a.x/2),l=Math.sin(a.y/2),m=Math.sin(a.z/2);switch(c){case "YXZ":this.x=h*f*e+d*l*m;this.y=d*l*e-h*f*m;this.z=d*f*m-h*l*e;this.w=d*f*e+h*l*m;break;case "ZXY":this.x=h*f*e-d*l*m;this.y=d*l*e+h*f*
 m;this.z=d*f*m+h*l*e;this.w=d*f*e-h*l*m;break;case "ZYX":this.x=h*f*e-d*l*m;this.y=d*l*e+h*f*m;this.z=d*f*m-h*l*e;this.w=d*f*e+h*l*m;break;case "YZX":this.x=h*f*e+d*l*m;this.y=d*l*e+h*f*m;this.z=d*f*m-h*l*e;this.w=d*f*e-h*l*m;break;case "XZY":this.x=h*f*e-d*l*m;this.y=d*l*e-h*f*m;this.z=d*f*m+h*l*e;this.w=d*f*e+h*l*m;break;default:this.x=h*f*e+d*l*m;this.y=d*l*e-h*f*m;this.z=d*f*m+h*l*e;this.w=d*f*e-h*l*m}return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*
 d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],f=b[1],e=b[5],h=b[9],l=b[2],m=b[6],b=b[10],k=c+e+b;if(k>0){c=0.5/Math.sqrt(k+1);this.w=0.25/c;this.x=(m-h)*c;this.y=(d-l)*c;this.z=(f-a)*c}else if(c>e&&c>b){c=2*Math.sqrt(1+c-e-b);this.w=(m-h)/c;this.x=0.25*c;this.y=(a+f)/c;this.z=(d+l)/c}else if(e>b){c=2*Math.sqrt(1+e-c-b);this.w=(d-l)/c;this.x=(a+f)/c;this.y=0.25*c;this.z=(h+m)/c}else{c=2*Math.sqrt(1+b-c-e);this.w=(f-a)/c;this.x=
@@ -103,7 +104,7 @@ for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;
 f.__originalFaceNormal.copy(f.normal):f.__originalFaceNormal=f.normal.clone();if(!f.__originalVertexNormals)f.__originalVertexNormals=[];a=0;for(b=f.vertexNormals.length;a<b;a++)f.__originalVertexNormals[a]?f.__originalVertexNormals[a].copy(f.vertexNormals[a]):f.__originalVertexNormals[a]=f.vertexNormals[a].clone()}var e=new THREE.Geometry;e.faces=this.faces;a=0;for(b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]={};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=
 [];var h=this.morphNormals[a].faceNormals,l=this.morphNormals[a].vertexNormals,m,k;c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];m=new THREE.Vector3;k=f instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3};h.push(m);l.push(k)}}h=this.morphNormals[a];e.vertices=this.morphTargets[a].vertices;e.computeFaceNormals();e.computeVertexNormals();c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];
 m=h.faceNormals[c];k=h.vertexNormals[c];m.copy(f.normal);if(f instanceof THREE.Face3){k.a.copy(f.vertexNormals[0]);k.b.copy(f.vertexNormals[1]);k.c.copy(f.vertexNormals[2])}else{k.a.copy(f.vertexNormals[0]);k.b.copy(f.vertexNormals[1]);k.c.copy(f.vertexNormals[2]);k.d.copy(f.vertexNormals[3])}}}c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];f.normal=f.__originalFaceNormal;f.vertexNormals=f.__originalVertexNormals}},computeTangents:function(){function a(a,b,c,d,e,f,y){l=a.vertices[b];m=a.vertices[c];
-k=a.vertices[d];i=h[e];o=h[f];j=h[y];w=m.x-l.x;r=k.x-l.x;n=m.y-l.y;q=k.y-l.y;p=m.z-l.z;s=k.z-l.z;B=o.u-i.u;A=j.u-i.u;u=o.v-i.v;J=j.v-i.v;D=1/(B*J-A*u);G.set((J*w-u*r)*D,(J*n-u*q)*D,(J*p-u*s)*D);R.set((B*r-A*w)*D,(B*q-A*n)*D,(B*s-A*p)*D);E[b].addSelf(G);E[c].addSelf(G);E[d].addSelf(G);Q[b].addSelf(R);Q[c].addSelf(R);Q[d].addSelf(R)}var b,c,d,f,e,h,l,m,k,i,o,j,w,r,n,q,p,s,B,A,u,J,D,M,E=[],Q=[],G=new THREE.Vector3,R=new THREE.Vector3,T=new THREE.Vector3,S=new THREE.Vector3,y=new THREE.Vector3;b=0;for(c=
+k=a.vertices[d];i=h[e];o=h[f];j=h[y];w=m.x-l.x;r=k.x-l.x;n=m.y-l.y;q=k.y-l.y;p=m.z-l.z;u=k.z-l.z;B=o.u-i.u;A=j.u-i.u;s=o.v-i.v;J=j.v-i.v;D=1/(B*J-A*s);G.set((J*w-s*r)*D,(J*n-s*q)*D,(J*p-s*u)*D);R.set((B*r-A*w)*D,(B*q-A*n)*D,(B*u-A*p)*D);E[b].addSelf(G);E[c].addSelf(G);E[d].addSelf(G);Q[b].addSelf(R);Q[c].addSelf(R);Q[d].addSelf(R)}var b,c,d,f,e,h,l,m,k,i,o,j,w,r,n,q,p,u,B,A,s,J,D,M,E=[],Q=[],G=new THREE.Vector3,R=new THREE.Vector3,T=new THREE.Vector3,S=new THREE.Vector3,y=new THREE.Vector3;b=0;for(c=
 this.vertices.length;b<c;b++){E[b]=new THREE.Vector3;Q[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){e=this.faces[b];h=this.faceVertexUvs[0][b];if(e instanceof THREE.Face3)a(this,e.a,e.b,e.c,0,1,2);else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.d,0,1,3);a(this,e.b,e.c,e.d,1,2,3)}}var L=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){e=this.faces[b];for(d=0;d<e.vertexNormals.length;d++){y.copy(e.vertexNormals[d]);f=e[L[d]];M=E[f];T.copy(M);T.subSelf(y.multiplyScalar(y.dot(M))).normalize();
 S.cross(e.vertexNormals[d],M);f=S.dot(Q[f]);f=f<0?-1:1;e.vertexTangents[d]=new THREE.Vector4(T.x,T.y,T.z,f)}}this.hasTangents=true},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(this.vertices.length>0){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,f=this.vertices.length;d<f;d++){a=this.vertices[d];if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=
 a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}else{this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;c<d;c++){a=this.vertices[c].length();a>b&&(b=a)}this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,f=Math.pow(10,4),e,h,l;e=0;for(h=this.vertices.length;e<h;e++){d=this.vertices[e];d=[Math.round(d.x*
@@ -135,22 +136,22 @@ THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.const
 THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,f,e){var h=new XMLHttpRequest;h.onreadystatechange=function(){if(h.readyState==4)if(h.status==200||h.status==0){var l=JSON.parse(h.responseText);a.loadAjaxBuffers(l,c,f,d,e)}else console.error("THREE.BinaryLoader: Couldn't load ["+b+"] ["+h.status+"]")};h.open("GET",b,true);h.overrideMimeType&&h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)};
 THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,f){var e=new XMLHttpRequest,h=c+"/"+a.buffers,l=0;e.onreadystatechange=function(){if(e.readyState==4)e.status==200||e.status==0?THREE.BinaryLoader.prototype.createBinModel(e.response,b,d,a.materials):console.error("THREE.BinaryLoader: Couldn't load ["+h+"] ["+e.status+"]");else if(e.readyState==3){if(f){l==0&&(l=e.getResponseHeader("Content-Length"));f({total:l,loaded:e.responseText.length})}}else e.readyState==2&&(l=e.getResponseHeader("Content-Length"))};
 e.open("GET",h,true);e.responseType="arraybuffer";e.send(null)};
-THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var f=function(b){var c,f,m,k,i,o,j,w,r,n,q,p,s,B,A;function u(a){return a%4?4-a%4:0}function J(a,b){return(new Uint8Array(a,b,1))[0]}function D(a,b){return(new Uint32Array(a,b,1))[0]}function M(b,c){var d,g,e,f,h,i,l,j,k=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){g=k[d*3];e=k[d*3+1];f=k[d*3+2];h=Z[g*2];g=Z[g*2+1];i=Z[e*2];l=Z[e*2+1];e=Z[f*2];j=Z[f*2+1];f=S.faceVertexUvs[0];var m=[];m.push(new THREE.UV(h,g));m.push(new THREE.UV(i,l));m.push(new THREE.UV(e,
+THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var f=function(b){var c,f,m,k,i,o,j,w,r,n,q,p,u,B,A;function s(a){return a%4?4-a%4:0}function J(a,b){return(new Uint8Array(a,b,1))[0]}function D(a,b){return(new Uint32Array(a,b,1))[0]}function M(b,c){var d,g,e,f,h,i,l,j,k=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){g=k[d*3];e=k[d*3+1];f=k[d*3+2];h=Z[g*2];g=Z[g*2+1];i=Z[e*2];l=Z[e*2+1];e=Z[f*2];j=Z[f*2+1];f=S.faceVertexUvs[0];var m=[];m.push(new THREE.UV(h,g));m.push(new THREE.UV(i,l));m.push(new THREE.UV(e,
 j));f.push(m)}}function E(b,c){var d,g,e,f,h,i,l,j,k,m,o=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){g=o[d*4];e=o[d*4+1];f=o[d*4+2];h=o[d*4+3];i=Z[g*2];g=Z[g*2+1];l=Z[e*2];k=Z[e*2+1];j=Z[f*2];m=Z[f*2+1];f=Z[h*2];e=Z[h*2+1];h=S.faceVertexUvs[0];var n=[];n.push(new THREE.UV(i,g));n.push(new THREE.UV(l,k));n.push(new THREE.UV(j,m));n.push(new THREE.UV(f,e));h.push(n)}}function Q(b,c,d){for(var g,e,f,h,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++){g=c[d*3];e=c[d*3+1];f=c[d*3+2];h=i[d];
 S.faces.push(new THREE.Face3(g,e,f,null,null,h))}}function G(b,c,d){for(var g,e,f,h,i,c=new Uint32Array(a,c,4*b),l=new Uint16Array(a,d,b),d=0;d<b;d++){g=c[d*4];e=c[d*4+1];f=c[d*4+2];h=c[d*4+3];i=l[d];S.faces.push(new THREE.Face4(g,e,f,h,null,null,i))}}function R(b,c,d,g){for(var e,f,h,i,l,j,k,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),m=new Uint16Array(a,g,b),g=0;g<b;g++){e=c[g*3];f=c[g*3+1];h=c[g*3+2];l=d[g*3];j=d[g*3+1];k=d[g*3+2];i=m[g];var o=L[j*3],n=L[j*3+1];j=L[j*3+2];var q=L[k*3],
-r=L[k*3+1];k=L[k*3+2];S.faces.push(new THREE.Face3(e,f,h,[new THREE.Vector3(L[l*3],L[l*3+1],L[l*3+2]),new THREE.Vector3(o,n,j),new THREE.Vector3(q,r,k)],null,i))}}function T(b,c,d,g){for(var e,f,h,i,l,j,k,m,o,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),n=new Uint16Array(a,g,b),g=0;g<b;g++){e=c[g*4];f=c[g*4+1];h=c[g*4+2];i=c[g*4+3];j=d[g*4];k=d[g*4+1];m=d[g*4+2];o=d[g*4+3];l=n[g];var q=L[k*3],r=L[k*3+1];k=L[k*3+2];var p=L[m*3],s=L[m*3+1];m=L[m*3+2];var w=L[o*3],u=L[o*3+1];o=L[o*3+2];S.faces.push(new THREE.Face4(e,
-f,h,i,[new THREE.Vector3(L[j*3],L[j*3+1],L[j*3+2]),new THREE.Vector3(q,r,k),new THREE.Vector3(p,s,m),new THREE.Vector3(w,u,o)],null,l))}}var S=this,y=0,L=[],Z=[],F,g,W;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(S,d,b);(function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",g=0;g<c;g++)d=d+String.fromCharCode(a[b+g]);return d})(a,y,12);c=J(a,y+12);J(a,y+13);J(a,y+14);J(a,y+15);f=J(a,y+16);m=J(a,y+17);k=J(a,y+18);i=J(a,y+19);o=D(a,y+20);j=D(a,y+20+4);w=D(a,y+20+8);b=D(a,y+20+12);r=
-D(a,y+20+16);n=D(a,y+20+20);q=D(a,y+20+24);p=D(a,y+20+28);s=D(a,y+20+32);B=D(a,y+20+36);A=D(a,y+20+40);y=y+c;c=f*3+i;W=f*4+i;F=b*c;g=r*(c+m*3);f=n*(c+k*3);i=q*(c+m*3+k*3);c=p*W;m=s*(W+m*4);k=B*(W+k*4);y=y+function(b){var b=new Float32Array(a,b,o*3),c,d,g,e;for(c=0;c<o;c++){d=b[c*3];g=b[c*3+1];e=b[c*3+2];S.vertices.push(new THREE.Vector3(d,g,e))}return o*3*Float32Array.BYTES_PER_ELEMENT}(y);y=y+function(b){if(j){var b=new Int8Array(a,b,j*3),c,d,g,e;for(c=0;c<j;c++){d=b[c*3];g=b[c*3+1];e=b[c*3+2];L.push(d/
-127,g/127,e/127)}}return j*3*Int8Array.BYTES_PER_ELEMENT}(y);y=y+u(j*3);y=y+function(b){if(w){var b=new Float32Array(a,b,w*2),c,d,g;for(c=0;c<w;c++){d=b[c*2];g=b[c*2+1];Z.push(d,g)}}return w*2*Float32Array.BYTES_PER_ELEMENT}(y);F=y+F+u(b*2);g=F+g+u(r*2);f=g+f+u(n*2);i=f+i+u(q*2);c=i+c+u(p*2);m=c+m+u(s*2);k=m+k+u(B*2);(function(a){if(n){var b=a+n*Uint32Array.BYTES_PER_ELEMENT*3;Q(n,a,b+n*Uint32Array.BYTES_PER_ELEMENT*3);M(n,b)}})(g);(function(a){if(q){var b=a+q*Uint32Array.BYTES_PER_ELEMENT*3,c=b+
+r=L[k*3+1];k=L[k*3+2];S.faces.push(new THREE.Face3(e,f,h,[new THREE.Vector3(L[l*3],L[l*3+1],L[l*3+2]),new THREE.Vector3(o,n,j),new THREE.Vector3(q,r,k)],null,i))}}function T(b,c,d,g){for(var e,f,h,i,l,j,k,m,o,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),n=new Uint16Array(a,g,b),g=0;g<b;g++){e=c[g*4];f=c[g*4+1];h=c[g*4+2];i=c[g*4+3];j=d[g*4];k=d[g*4+1];m=d[g*4+2];o=d[g*4+3];l=n[g];var q=L[k*3],r=L[k*3+1];k=L[k*3+2];var p=L[m*3],u=L[m*3+1];m=L[m*3+2];var w=L[o*3],s=L[o*3+1];o=L[o*3+2];S.faces.push(new THREE.Face4(e,
+f,h,i,[new THREE.Vector3(L[j*3],L[j*3+1],L[j*3+2]),new THREE.Vector3(q,r,k),new THREE.Vector3(p,u,m),new THREE.Vector3(w,s,o)],null,l))}}var S=this,y=0,L=[],Z=[],F,g,W;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(S,d,b);(function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",g=0;g<c;g++)d=d+String.fromCharCode(a[b+g]);return d})(a,y,12);c=J(a,y+12);J(a,y+13);J(a,y+14);J(a,y+15);f=J(a,y+16);m=J(a,y+17);k=J(a,y+18);i=J(a,y+19);o=D(a,y+20);j=D(a,y+20+4);w=D(a,y+20+8);b=D(a,y+20+12);r=
+D(a,y+20+16);n=D(a,y+20+20);q=D(a,y+20+24);p=D(a,y+20+28);u=D(a,y+20+32);B=D(a,y+20+36);A=D(a,y+20+40);y=y+c;c=f*3+i;W=f*4+i;F=b*c;g=r*(c+m*3);f=n*(c+k*3);i=q*(c+m*3+k*3);c=p*W;m=u*(W+m*4);k=B*(W+k*4);y=y+function(b){var b=new Float32Array(a,b,o*3),c,d,g,e;for(c=0;c<o;c++){d=b[c*3];g=b[c*3+1];e=b[c*3+2];S.vertices.push(new THREE.Vector3(d,g,e))}return o*3*Float32Array.BYTES_PER_ELEMENT}(y);y=y+function(b){if(j){var b=new Int8Array(a,b,j*3),c,d,g,e;for(c=0;c<j;c++){d=b[c*3];g=b[c*3+1];e=b[c*3+2];L.push(d/
+127,g/127,e/127)}}return j*3*Int8Array.BYTES_PER_ELEMENT}(y);y=y+s(j*3);y=y+function(b){if(w){var b=new Float32Array(a,b,w*2),c,d,g;for(c=0;c<w;c++){d=b[c*2];g=b[c*2+1];Z.push(d,g)}}return w*2*Float32Array.BYTES_PER_ELEMENT}(y);F=y+F+s(b*2);g=F+g+s(r*2);f=g+f+s(n*2);i=f+i+s(q*2);c=i+c+s(p*2);m=c+m+s(u*2);k=m+k+s(B*2);(function(a){if(n){var b=a+n*Uint32Array.BYTES_PER_ELEMENT*3;Q(n,a,b+n*Uint32Array.BYTES_PER_ELEMENT*3);M(n,b)}})(g);(function(a){if(q){var b=a+q*Uint32Array.BYTES_PER_ELEMENT*3,c=b+
 q*Uint32Array.BYTES_PER_ELEMENT*3;R(q,a,b,c+q*Uint32Array.BYTES_PER_ELEMENT*3);M(q,c)}})(f);(function(a){if(B){var b=a+B*Uint32Array.BYTES_PER_ELEMENT*4;G(B,a,b+B*Uint32Array.BYTES_PER_ELEMENT*4);E(B,b)}})(m);(function(a){if(A){var b=a+A*Uint32Array.BYTES_PER_ELEMENT*4,c=b+A*Uint32Array.BYTES_PER_ELEMENT*4;T(A,a,b,c+A*Uint32Array.BYTES_PER_ELEMENT*4);E(A,c)}})(k);b&&Q(b,y,y+b*Uint32Array.BYTES_PER_ELEMENT*3);(function(a){if(r){var b=a+r*Uint32Array.BYTES_PER_ELEMENT*3;R(r,a,b,b+r*Uint32Array.BYTES_PER_ELEMENT*
-3)}})(F);p&&G(p,i,i+p*Uint32Array.BYTES_PER_ELEMENT*4);(function(a){if(s){var b=a+s*Uint32Array.BYTES_PER_ELEMENT*4;T(s,a,b,b+s*Uint32Array.BYTES_PER_ELEMENT*4)}})(c);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))};THREE.ImageLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
+3)}})(F);p&&G(p,i,i+p*Uint32Array.BYTES_PER_ELEMENT*4);(function(a){if(u){var b=a+u*Uint32Array.BYTES_PER_ELEMENT*4;T(u,a,b,b+u*Uint32Array.BYTES_PER_ELEMENT*4)}})(c);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))};THREE.ImageLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
 THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){b.dispatchEvent({type:"load",content:c})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;
 THREE.JSONLoader.prototype.load=function(a,b,c){c=c?c:this.extractUrlBase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)};
 THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,f){var e=new XMLHttpRequest,h=0;e.onreadystatechange=function(){if(e.readyState===e.DONE)if(e.status===200||e.status===0){if(e.responseText){var l=JSON.parse(e.responseText);a.createModel(l,c,d)}else console.warn("THREE.JSONLoader: ["+b+"] seems to be unreachable or file there is empty");a.onLoadComplete()}else console.error("THREE.JSONLoader: Couldn't load ["+b+"] ["+e.status+"]");else if(e.readyState===e.LOADING){if(f){h===0&&(h=e.getResponseHeader("Content-Length"));
 f({total:h,loaded:e.responseText.length})}}else e.readyState===e.HEADERS_RECEIVED&&(h=e.getResponseHeader("Content-Length"))};e.open("GET",b,true);e.overrideMimeType&&e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)};
-THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;this.initMaterials(d,a.materials,c);(function(b){var c,f,m,k,i,o,j,w,r,n,q,p,s,B,A=a.faces;o=a.vertices;var u=a.normals,J=a.colors,D=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&D++;for(c=0;c<D;c++){d.faceUvs[c]=[];d.faceVertexUvs[c]=[]}k=0;for(i=o.length;k<i;){j=new THREE.Vector3;j.x=o[k++]*b;j.y=o[k++]*b;j.z=o[k++]*b;d.vertices.push(j)}k=0;for(i=A.length;k<i;){b=A[k++];o=b&1;m=b&2;c=b&
-4;f=b&8;w=b&16;j=b&32;n=b&64;b=b&128;if(o){q=new THREE.Face4;q.a=A[k++];q.b=A[k++];q.c=A[k++];q.d=A[k++];o=4}else{q=new THREE.Face3;q.a=A[k++];q.b=A[k++];q.c=A[k++];o=3}if(m){m=A[k++];q.materialIndex=m}m=d.faces.length;if(c)for(c=0;c<D;c++){p=a.uvs[c];r=A[k++];B=p[r*2];r=p[r*2+1];d.faceUvs[c][m]=new THREE.UV(B,r)}if(f)for(c=0;c<D;c++){p=a.uvs[c];s=[];for(f=0;f<o;f++){r=A[k++];B=p[r*2];r=p[r*2+1];s[f]=new THREE.UV(B,r)}d.faceVertexUvs[c][m]=s}if(w){w=A[k++]*3;f=new THREE.Vector3;f.x=u[w++];f.y=u[w++];
-f.z=u[w];q.normal=f}if(j)for(c=0;c<o;c++){w=A[k++]*3;f=new THREE.Vector3;f.x=u[w++];f.y=u[w++];f.z=u[w];q.vertexNormals.push(f)}if(n){j=A[k++];j=new THREE.Color(J[j]);q.color=j}if(b)for(c=0;c<o;c++){j=A[k++];j=new THREE.Color(J[j]);q.vertexColors.push(j)}d.faces.push(q)}})(f);(function(){var b,c,f,m;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b=b+2){f=a.skinWeights[b];m=a.skinWeights[b+1];d.skinWeights.push(new THREE.Vector4(f,m,0,0))}}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b=
+THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;this.initMaterials(d,a.materials,c);(function(b){var c,f,m,k,i,o,j,w,r,n,q,p,u,B,A=a.faces;o=a.vertices;var s=a.normals,J=a.colors,D=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&D++;for(c=0;c<D;c++){d.faceUvs[c]=[];d.faceVertexUvs[c]=[]}k=0;for(i=o.length;k<i;){j=new THREE.Vector3;j.x=o[k++]*b;j.y=o[k++]*b;j.z=o[k++]*b;d.vertices.push(j)}k=0;for(i=A.length;k<i;){b=A[k++];o=b&1;m=b&2;c=b&
+4;f=b&8;w=b&16;j=b&32;n=b&64;b=b&128;if(o){q=new THREE.Face4;q.a=A[k++];q.b=A[k++];q.c=A[k++];q.d=A[k++];o=4}else{q=new THREE.Face3;q.a=A[k++];q.b=A[k++];q.c=A[k++];o=3}if(m){m=A[k++];q.materialIndex=m}m=d.faces.length;if(c)for(c=0;c<D;c++){p=a.uvs[c];r=A[k++];B=p[r*2];r=p[r*2+1];d.faceUvs[c][m]=new THREE.UV(B,r)}if(f)for(c=0;c<D;c++){p=a.uvs[c];u=[];for(f=0;f<o;f++){r=A[k++];B=p[r*2];r=p[r*2+1];u[f]=new THREE.UV(B,r)}d.faceVertexUvs[c][m]=u}if(w){w=A[k++]*3;f=new THREE.Vector3;f.x=s[w++];f.y=s[w++];
+f.z=s[w];q.normal=f}if(j)for(c=0;c<o;c++){w=A[k++]*3;f=new THREE.Vector3;f.x=s[w++];f.y=s[w++];f.z=s[w];q.vertexNormals.push(f)}if(n){j=A[k++];j=new THREE.Color(J[j]);q.color=j}if(b)for(c=0;c<o;c++){j=A[k++];j=new THREE.Color(J[j]);q.vertexColors.push(j)}d.faces.push(q)}})(f);(function(){var b,c,f,m;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b=b+2){f=a.skinWeights[b];m=a.skinWeights[b+1];d.skinWeights.push(new THREE.Vector4(f,m,0,0))}}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b=
 b+2){f=a.skinIndices[b];m=a.skinIndices[b+1];d.skinIndices.push(new THREE.Vector4(f,m,0,0))}}d.bones=a.bones;d.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,f,m,k,i,o;c=0;for(f=a.morphTargets.length;c<f;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];i=d.morphTargets[c].vertices;o=a.morphTargets[c].vertices;m=0;for(k=o.length;m<k;m=m+3){var j=new THREE.Vector3;j.x=o[m]*b;j.y=o[m+1]*b;j.z=o[m+2]*b;i.push(j)}}}if(a.morphColors!==
 void 0){c=0;for(f=a.morphColors.length;c<f;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];k=d.morphColors[c].colors;i=a.morphColors[c].colors;b=0;for(m=i.length;b<m;b=b+3){o=new THREE.Color(16755200);o.setRGB(i[b],i[b+1],i[b+2]);k.push(o)}}}})(f);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&d.computeTangents();b(d)};THREE.GeometryLoader=function(){THREE.EventTarget.call(this);this.path=this.crossOrigin=null};
 THREE.GeometryLoader.prototype={constructor:THREE.GeometryLoader,load:function(a){var b=this,c=null;if(b.path===null){var d=a.split("/");d.pop();b.path=d.length<1?".":d.join("/")}d=new XMLHttpRequest;d.addEventListener("load",function(d){d.target.responseText?c=b.parse(JSON.parse(d.target.responseText),f):b.dispatchEvent({type:"error",message:"Invalid file ["+a+"]"})},false);d.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);d.open("GET",
@@ -161,27 +162,27 @@ THREE[h.blending];if(h.transparent!==void 0||h.opacity<1)j.transparent=h.transpa
 if(h.transparency)j.opacity=h.transparency;if(h.specularCoef)j.shininess=h.specularCoef;h.mapDiffuse&&k(j,"map",h.mapDiffuse,h.mapDiffuseRepeat,h.mapDiffuseOffset,h.mapDiffuseWrap);h.mapLight&&k(j,"lightMap",h.mapLight,h.mapLightRepeat,h.mapLightOffset,h.mapLightWrap);h.mapNormal&&k(j,"normalMap",h.mapNormal,h.mapNormalRepeat,h.mapNormalOffset,h.mapNormalWrap);h.mapSpecular&&k(j,"specularMap",h.mapSpecular,h.mapSpecularRepeat,h.mapSpecularOffset,h.mapSpecularWrap);if(h.mapNormal){k=THREE.ShaderUtils.lib.normal;
 i=THREE.UniformsUtils.clone(k.uniforms);i.tNormal.texture=j.normalMap;if(h.mapNormalFactor)i.uNormalScale.value=h.mapNormalFactor;if(j.map){i.tDiffuse.texture=j.map;i.enableDiffuse.value=true}if(j.specularMap){i.tSpecular.texture=j.specularMap;i.enableSpecular.value=true}if(j.lightMap){i.tAO.texture=j.lightMap;i.enableAO.value=true}i.uDiffuseColor.value.setHex(j.color);i.uSpecularColor.value.setHex(j.specular);i.uAmbientColor.value.setHex(j.ambient);i.uShininess.value=j.shininess;if(j.opacity!==void 0)i.uOpacity.value=
 j.opacity;j=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,vertexShader:k.vertexShader,uniforms:i,lights:true,fog:true})}else j=new THREE[o](j);if(h.DbgName!==void 0)j.name=h.DbgName;d.materials[e]=j}}var h=a.faces,r=a.vertices,j=a.normals,k=a.colors,i=0;if(a.uvs)for(e=0;e<a.uvs.length;e++)a.uvs[e].length&&i++;for(e=0;e<i;e++){d.faceUvs[e]=[];d.faceVertexUvs[e]=[]}o=0;for(w=r.length;o<w;){var n=new THREE.Vector3;n.x=r[o++]*f;n.y=r[o++]*f;n.z=r[o++]*f;d.vertices.push(n)}o=0;for(w=h.length;o<
-w;){var q=h[o++],p=q&2,e=q&4,s=q&8,B=q&16,r=q&32,A=q&64,n=q&128;if(q&1){q=new THREE.Face4;q.a=h[o++];q.b=h[o++];q.c=h[o++];q.d=h[o++];var u=4}else{q=new THREE.Face3;q.a=h[o++];q.b=h[o++];q.c=h[o++];u=3}if(p){p=h[o++];q.materialIndex=p}var J=d.faces.length;if(e)for(e=0;e<i;e++){var D=a.uvs[e],p=h[o++],M=D[p*2],p=D[p*2+1];d.faceUvs[e][J]=new THREE.UV(M,p)}if(s)for(e=0;e<i;e++){for(var D=a.uvs[e],s=[],E=0;E<u;E++){p=h[o++];M=D[p*2];p=D[p*2+1];s[E]=new THREE.UV(M,p)}d.faceVertexUvs[e][J]=s}if(B){B=h[o++]*
-3;p=new THREE.Vector3;p.x=j[B++];p.y=j[B++];p.z=j[B];q.normal=p}if(r)for(e=0;e<u;e++){B=h[o++]*3;p=new THREE.Vector3;p.x=j[B++];p.y=j[B++];p.z=j[B];q.vertexNormals.push(p)}if(A){r=h[o++];q.color=new THREE.Color(k[r])}if(n)for(e=0;e<u;e++){r=h[o++];q.vertexColors.push(new THREE.Color(k[r]))}d.faces.push(q)}if(a.skinWeights){e=0;for(h=a.skinWeights.length;e<h;e=e+2)d.skinWeights.push(new THREE.Vector4(a.skinWeights[e],a.skinWeights[e+1],0,0))}if(a.skinIndices){e=0;for(h=a.skinIndices.length;e<h;e=e+
+w;){var q=h[o++],p=q&2,e=q&4,u=q&8,B=q&16,r=q&32,A=q&64,n=q&128;if(q&1){q=new THREE.Face4;q.a=h[o++];q.b=h[o++];q.c=h[o++];q.d=h[o++];var s=4}else{q=new THREE.Face3;q.a=h[o++];q.b=h[o++];q.c=h[o++];s=3}if(p){p=h[o++];q.materialIndex=p}var J=d.faces.length;if(e)for(e=0;e<i;e++){var D=a.uvs[e],p=h[o++],M=D[p*2],p=D[p*2+1];d.faceUvs[e][J]=new THREE.UV(M,p)}if(u)for(e=0;e<i;e++){for(var D=a.uvs[e],u=[],E=0;E<s;E++){p=h[o++];M=D[p*2];p=D[p*2+1];u[E]=new THREE.UV(M,p)}d.faceVertexUvs[e][J]=u}if(B){B=h[o++]*
+3;p=new THREE.Vector3;p.x=j[B++];p.y=j[B++];p.z=j[B];q.normal=p}if(r)for(e=0;e<s;e++){B=h[o++]*3;p=new THREE.Vector3;p.x=j[B++];p.y=j[B++];p.z=j[B];q.vertexNormals.push(p)}if(A){r=h[o++];q.color=new THREE.Color(k[r])}if(n)for(e=0;e<s;e++){r=h[o++];q.vertexColors.push(new THREE.Color(k[r]))}d.faces.push(q)}if(a.skinWeights){e=0;for(h=a.skinWeights.length;e<h;e=e+2)d.skinWeights.push(new THREE.Vector4(a.skinWeights[e],a.skinWeights[e+1],0,0))}if(a.skinIndices){e=0;for(h=a.skinIndices.length;e<h;e=e+
 2){j=0;d.skinIndices.push(new THREE.Vector4(a.skinIndices[e],a.skinIndices[e+1],j,0))}}d.bones=a.bones;d.animation=a.animation;if(a.morphTargets){e=0;for(h=a.morphTargets.length;e<h;e++){d.morphTargets[e]={};d.morphTargets[e].name=a.morphTargets[e].name;d.morphTargets[e].vertices=[];j=d.morphTargets[e].vertices;k=a.morphTargets[e].vertices;p=0;for(i=k.length;p<i;p=p+3){n=new THREE.Vector3;n.x=k[p]*f;n.y=k[p+1]*f;n.z=k[p+2]*f;j.push(n)}}}if(a.morphColors){e=0;for(h=a.morphColors.length;e<h;e++){d.morphColors[e]=
 {};d.morphColors[e].name=a.morphColors[e].name;d.morphColors[e].colors=[];f=d.morphColors[e].colors;k=a.morphColors[e].colors;j=0;for(i=k.length;j<i;j=j+3){o=new THREE.Color(16755200);o.setRGB(k[j],k[j+1],k[j+2]);f.push(o)}}}d.computeCentroids();d.computeFaceNormals();return d}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
 THREE.SceneLoader.prototype.constructor=THREE.SceneLoader;
 THREE.SceneLoader.prototype.load=function(a,b){var c=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(d.readyState===4)if(d.status===200||d.status===0){var f=JSON.parse(d.responseText);c.createScene(f,b,a)}else console.error("THREE.SceneLoader: Couldn't load ["+a+"] ["+d.status+"]")};d.open("GET",a,true);d.overrideMimeType&&d.overrideMimeType("text/plain; charset=x-user-defined");d.setRequestHeader("Content-Type","text/plain");d.send(null)};
-THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:k+"/"+a}function f(){var a;for(j in y.objects)if(!I.objects[j]){p=y.objects[j];if(p.geometry!==void 0){if(G=I.geometries[p.geometry]){a=false;R=I.materials[p.materials[0]];(a=R instanceof THREE.ShaderMaterial)&&G.computeTangents();u=p.position;J=p.rotation;D=p.quaternion;M=p.scale;s=p.matrix;D=0;p.materials.length==0&&(R=new THREE.MeshFaceMaterial);p.materials.length>1&&(R=new THREE.MeshFaceMaterial);
-a=new THREE.Mesh(G,R);a.name=j;if(s){a.matrixAutoUpdate=false;a.matrix.set(s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11],s[12],s[13],s[14],s[15])}else{a.position.set(u[0],u[1],u[2]);if(D){a.quaternion.set(D[0],D[1],D[2],D[3]);a.useQuaternion=true}else a.rotation.set(J[0],J[1],J[2]);a.scale.set(M[0],M[1],M[2])}a.visible=p.visible;a.doubleSided=p.doubleSided;a.castShadow=p.castShadow;a.receiveShadow=p.receiveShadow;I.scene.add(a);I.objects[j]=a}}else{u=p.position;J=p.rotation;D=p.quaternion;
-M=p.scale;D=0;a=new THREE.Object3D;a.name=j;a.position.set(u[0],u[1],u[2]);if(D){a.quaternion.set(D[0],D[1],D[2],D[3]);a.useQuaternion=true}else a.rotation.set(J[0],J[1],J[2]);a.scale.set(M[0],M[1],M[2]);a.visible=p.visible!==void 0?p.visible:false;I.scene.add(a);I.objects[j]=a;I.empties[j]=a}}}function e(a){return function(b){I.geometries[a]=b;f();Z=Z-1;m.onLoadComplete();l()}}function h(a){return function(b){I.geometries[a]=b}}function l(){m.callbackProgress({totalModels:g,totalTextures:W,loadedModels:g-
-Z,loadedTextures:W-F},I);m.onLoadProgress();Z===0&&F===0&&b(I)}var m=this,k=THREE.Loader.prototype.extractUrlBase(c),i,o,j,w,r,n,q,p,s,B,A,u,J,D,M,E,Q,G,R,T,S,y,L,Z,F,g,W,I;y=a;c=new THREE.BinaryLoader;L=new THREE.JSONLoader;F=Z=0;I={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(y.transform){a=y.transform.position;B=y.transform.rotation;E=y.transform.scale;a&&I.scene.position.set(a[0],a[1],a[2]);B&&I.scene.rotation.set(B[0],B[1],
-B[2]);E&&I.scene.scale.set(E[0],E[1],E[2]);if(a||B||E){I.scene.updateMatrix();I.scene.updateMatrixWorld()}}a=function(a){return function(){F=F-a;l();m.onLoadComplete()}};for(r in y.cameras){E=y.cameras[r];E.type==="perspective"?T=new THREE.PerspectiveCamera(E.fov,E.aspect,E.near,E.far):E.type==="ortho"&&(T=new THREE.OrthographicCamera(E.left,E.right,E.top,E.bottom,E.near,E.far));u=E.position;B=E.target;E=E.up;T.position.set(u[0],u[1],u[2]);T.target=new THREE.Vector3(B[0],B[1],B[2]);E&&T.up.set(E[0],
-E[1],E[2]);I.cameras[r]=T}for(w in y.lights){B=y.lights[w];r=B.color!==void 0?B.color:16777215;T=B.intensity!==void 0?B.intensity:1;if(B.type==="directional"){u=B.direction;A=new THREE.DirectionalLight(r,T);A.position.set(u[0],u[1],u[2]);A.position.normalize()}else if(B.type==="point"){u=B.position;A=B.distance;A=new THREE.PointLight(r,T,A);A.position.set(u[0],u[1],u[2])}else B.type==="ambient"&&(A=new THREE.AmbientLight(r));I.scene.add(A);I.lights[w]=A}for(n in y.fogs){w=y.fogs[n];w.type==="linear"?
+THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:k+"/"+a}function f(){var a;for(j in y.objects)if(!I.objects[j]){p=y.objects[j];if(p.geometry!==void 0){if(G=I.geometries[p.geometry]){a=false;R=I.materials[p.materials[0]];(a=R instanceof THREE.ShaderMaterial)&&G.computeTangents();s=p.position;J=p.rotation;D=p.quaternion;M=p.scale;u=p.matrix;D=0;p.materials.length==0&&(R=new THREE.MeshFaceMaterial);p.materials.length>1&&(R=new THREE.MeshFaceMaterial);
+a=new THREE.Mesh(G,R);a.name=j;if(u){a.matrixAutoUpdate=false;a.matrix.set(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15])}else{a.position.set(s[0],s[1],s[2]);if(D){a.quaternion.set(D[0],D[1],D[2],D[3]);a.useQuaternion=true}else a.rotation.set(J[0],J[1],J[2]);a.scale.set(M[0],M[1],M[2])}a.visible=p.visible;a.doubleSided=p.doubleSided;a.castShadow=p.castShadow;a.receiveShadow=p.receiveShadow;I.scene.add(a);I.objects[j]=a}}else{s=p.position;J=p.rotation;D=p.quaternion;
+M=p.scale;D=0;a=new THREE.Object3D;a.name=j;a.position.set(s[0],s[1],s[2]);if(D){a.quaternion.set(D[0],D[1],D[2],D[3]);a.useQuaternion=true}else a.rotation.set(J[0],J[1],J[2]);a.scale.set(M[0],M[1],M[2]);a.visible=p.visible!==void 0?p.visible:false;I.scene.add(a);I.objects[j]=a;I.empties[j]=a}}}function e(a){return function(b){I.geometries[a]=b;f();Z=Z-1;m.onLoadComplete();l()}}function h(a){return function(b){I.geometries[a]=b}}function l(){m.callbackProgress({totalModels:g,totalTextures:W,loadedModels:g-
+Z,loadedTextures:W-F},I);m.onLoadProgress();Z===0&&F===0&&b(I)}var m=this,k=THREE.Loader.prototype.extractUrlBase(c),i,o,j,w,r,n,q,p,u,B,A,s,J,D,M,E,Q,G,R,T,S,y,L,Z,F,g,W,I;y=a;c=new THREE.BinaryLoader;L=new THREE.JSONLoader;F=Z=0;I={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(y.transform){a=y.transform.position;B=y.transform.rotation;E=y.transform.scale;a&&I.scene.position.set(a[0],a[1],a[2]);B&&I.scene.rotation.set(B[0],B[1],
+B[2]);E&&I.scene.scale.set(E[0],E[1],E[2]);if(a||B||E){I.scene.updateMatrix();I.scene.updateMatrixWorld()}}a=function(a){return function(){F=F-a;l();m.onLoadComplete()}};for(r in y.cameras){E=y.cameras[r];E.type==="perspective"?T=new THREE.PerspectiveCamera(E.fov,E.aspect,E.near,E.far):E.type==="ortho"&&(T=new THREE.OrthographicCamera(E.left,E.right,E.top,E.bottom,E.near,E.far));s=E.position;B=E.target;E=E.up;T.position.set(s[0],s[1],s[2]);T.target=new THREE.Vector3(B[0],B[1],B[2]);E&&T.up.set(E[0],
+E[1],E[2]);I.cameras[r]=T}for(w in y.lights){B=y.lights[w];r=B.color!==void 0?B.color:16777215;T=B.intensity!==void 0?B.intensity:1;if(B.type==="directional"){s=B.direction;A=new THREE.DirectionalLight(r,T);A.position.set(s[0],s[1],s[2]);A.position.normalize()}else if(B.type==="point"){s=B.position;A=B.distance;A=new THREE.PointLight(r,T,A);A.position.set(s[0],s[1],s[2])}else B.type==="ambient"&&(A=new THREE.AmbientLight(r));I.scene.add(A);I.lights[w]=A}for(n in y.fogs){w=y.fogs[n];w.type==="linear"?
 S=new THREE.Fog(0,w.near,w.far):w.type==="exp2"&&(S=new THREE.FogExp2(0,w.density));E=w.color;S.color.setRGB(E[0],E[1],E[2]);I.fogs[n]=S}if(I.cameras&&y.defaults.camera)I.currentCamera=I.cameras[y.defaults.camera];if(I.fogs&&y.defaults.fog)I.scene.fog=I.fogs[y.defaults.fog];E=y.defaults.bgcolor;I.bgColor=new THREE.Color;I.bgColor.setRGB(E[0],E[1],E[2]);I.bgColorAlpha=y.defaults.bgalpha;for(i in y.geometries){n=y.geometries[i];if(n.type=="bin_mesh"||n.type=="ascii_mesh"){Z=Z+1;m.onLoadStart()}}g=Z;
 for(i in y.geometries){n=y.geometries[i];if(n.type==="cube"){G=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides);I.geometries[i]=G}else if(n.type==="plane"){G=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight);I.geometries[i]=G}else if(n.type==="sphere"){G=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight);I.geometries[i]=G}else if(n.type==="cylinder"){G=new THREE.CylinderGeometry(n.topRad,
 n.botRad,n.height,n.radSegs,n.heightSegs);I.geometries[i]=G}else if(n.type==="torus"){G=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT);I.geometries[i]=G}else if(n.type==="icosahedron"){G=new THREE.IcosahedronGeometry(n.radius,n.subdivisions);I.geometries[i]=G}else if(n.type==="bin_mesh")c.load(d(n.url,y.urlBaseType),e(i));else if(n.type==="ascii_mesh")L.load(d(n.url,y.urlBaseType),e(i));else if(n.type==="embedded_mesh"){n=y.embeds[n.id];n.metadata=y.metadata;n&&L.createModel(n,h(i),
 "")}}for(q in y.textures){i=y.textures[q];if(i.url instanceof Array){F=F+i.url.length;for(n=0;n<i.url.length;n++)m.onLoadStart()}else{F=F+1;m.onLoadStart()}}W=F;for(q in y.textures){i=y.textures[q];if(i.mapping!==void 0&&THREE[i.mapping]!==void 0)i.mapping=new THREE[i.mapping];if(i.url instanceof Array){n=i.url.length;S=[];for(c=0;c<n;c++)S[c]=d(i.url[c],y.urlBaseType);n=THREE.ImageUtils.loadTextureCube(S,i.mapping,a(n))}else{n=THREE.ImageUtils.loadTexture(d(i.url,y.urlBaseType),i.mapping,a(1));if(THREE[i.minFilter]!==
-void 0)n.minFilter=THREE[i.minFilter];if(THREE[i.magFilter]!==void 0)n.magFilter=THREE[i.magFilter];if(i.repeat){n.repeat.set(i.repeat[0],i.repeat[1]);if(i.repeat[0]!==1)n.wrapS=THREE.RepeatWrapping;if(i.repeat[1]!==1)n.wrapT=THREE.RepeatWrapping}i.offset&&n.offset.set(i.offset[0],i.offset[1]);if(i.wrap){S={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(S[i.wrap[0]]!==void 0)n.wrapS=S[i.wrap[0]];if(S[i.wrap[1]]!==void 0)n.wrapT=S[i.wrap[1]]}}I.textures[q]=n}for(o in y.materials){s=
-y.materials[o];for(Q in s.parameters)if(Q==="envMap"||Q==="map"||Q==="lightMap")s.parameters[Q]=I.textures[s.parameters[Q]];else if(Q==="shading")s.parameters[Q]=s.parameters[Q]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(Q==="blending")s.parameters[Q]=s.parameters[Q]in THREE?THREE[s.parameters[Q]]:THREE.NormalBlending;else if(Q==="combine")s.parameters[Q]=s.parameters[Q]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(Q==="vertexColors")if(s.parameters[Q]=="face")s.parameters[Q]=
-THREE.FaceColors;else if(s.parameters[Q])s.parameters[Q]=THREE.VertexColors;if(s.parameters.opacity!==void 0&&s.parameters.opacity<1)s.parameters.transparent=true;if(s.parameters.normalMap){q=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(q.uniforms);i=s.parameters.color;n=s.parameters.specular;S=s.parameters.ambient;c=s.parameters.shininess;a.tNormal.texture=I.textures[s.parameters.normalMap];if(s.parameters.normalMapFactor)a.uNormalScale.value=s.parameters.normalMapFactor;if(s.parameters.map){a.tDiffuse.texture=
-s.parameters.map;a.enableDiffuse.value=true}if(s.parameters.lightMap){a.tAO.texture=s.parameters.lightMap;a.enableAO.value=true}if(s.parameters.specularMap){a.tSpecular.texture=I.textures[s.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(i);a.uSpecularColor.value.setHex(n);a.uAmbientColor.value.setHex(S);a.uShininess.value=c;if(s.parameters.opacity)a.uOpacity.value=s.parameters.opacity;R=new THREE.ShaderMaterial({fragmentShader:q.fragmentShader,vertexShader:q.vertexShader,
-uniforms:a,lights:true,fog:true})}else R=new THREE[s.type](s.parameters);I.materials[o]=R}f();m.callbackSync(I);l()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
+void 0)n.minFilter=THREE[i.minFilter];if(THREE[i.magFilter]!==void 0)n.magFilter=THREE[i.magFilter];if(i.repeat){n.repeat.set(i.repeat[0],i.repeat[1]);if(i.repeat[0]!==1)n.wrapS=THREE.RepeatWrapping;if(i.repeat[1]!==1)n.wrapT=THREE.RepeatWrapping}i.offset&&n.offset.set(i.offset[0],i.offset[1]);if(i.wrap){S={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(S[i.wrap[0]]!==void 0)n.wrapS=S[i.wrap[0]];if(S[i.wrap[1]]!==void 0)n.wrapT=S[i.wrap[1]]}}I.textures[q]=n}for(o in y.materials){u=
+y.materials[o];for(Q in u.parameters)if(Q==="envMap"||Q==="map"||Q==="lightMap")u.parameters[Q]=I.textures[u.parameters[Q]];else if(Q==="shading")u.parameters[Q]=u.parameters[Q]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(Q==="blending")u.parameters[Q]=u.parameters[Q]in THREE?THREE[u.parameters[Q]]:THREE.NormalBlending;else if(Q==="combine")u.parameters[Q]=u.parameters[Q]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(Q==="vertexColors")if(u.parameters[Q]=="face")u.parameters[Q]=
+THREE.FaceColors;else if(u.parameters[Q])u.parameters[Q]=THREE.VertexColors;if(u.parameters.opacity!==void 0&&u.parameters.opacity<1)u.parameters.transparent=true;if(u.parameters.normalMap){q=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(q.uniforms);i=u.parameters.color;n=u.parameters.specular;S=u.parameters.ambient;c=u.parameters.shininess;a.tNormal.texture=I.textures[u.parameters.normalMap];if(u.parameters.normalMapFactor)a.uNormalScale.value=u.parameters.normalMapFactor;if(u.parameters.map){a.tDiffuse.texture=
+u.parameters.map;a.enableDiffuse.value=true}if(u.parameters.lightMap){a.tAO.texture=u.parameters.lightMap;a.enableAO.value=true}if(u.parameters.specularMap){a.tSpecular.texture=I.textures[u.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(i);a.uSpecularColor.value.setHex(n);a.uAmbientColor.value.setHex(S);a.uShininess.value=c;if(u.parameters.opacity)a.uOpacity.value=u.parameters.opacity;R=new THREE.ShaderMaterial({fragmentShader:q.fragmentShader,vertexShader:q.vertexShader,
+uniforms:a,lights:true,fog:true})}else R=new THREE[u.type](u.parameters);I.materials[o]=R}f();m.callbackSync(I);l()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
 THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=true;b.dispatchEvent({type:"load",content:a})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}};
 THREE.Material=function(a){a=a||{};this.id=THREE.MaterialCount++;this.name="";this.opacity=a.opacity!==void 0?a.opacity:1;this.transparent=a.transparent!==void 0?a.transparent:false;this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.blendSrc=a.blendSrc!==void 0?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=a.blendDst!==void 0?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=a.blendEquation!==void 0?a.blendEquation:THREE.AddEquation;this.depthTest=a.depthTest!==void 0?
 a.depthTest:true;this.depthWrite=a.depthWrite!==void 0?a.depthWrite:true;this.polygonOffset=a.polygonOffset!==void 0?a.polygonOffset:false;this.polygonOffsetFactor=a.polygonOffsetFactor!==void 0?a.polygonOffsetFactor:0;this.polygonOffsetUnits=a.polygonOffsetUnits!==void 0?a.polygonOffsetUnits:0;this.alphaTest=a.alphaTest!==void 0?a.alphaTest:0;this.overdraw=a.overdraw!==void 0?a.overdraw:false;this.needsUpdate=this.visible=true};THREE.MaterialCount=0;THREE.NoShading=0;THREE.FlatShading=1;
@@ -274,13 +275,13 @@ if(i.boundTo===void 0||i.boundTo==="vertices"){f=0;e=i.value.length;if(i.size===
 h=i.value[h];i.array[f]=h.x;i.array[f+1]=h.y;i.array[f+2]=h.z;i.array[f+3]=h.w;f=f+4}}}}}else{if(n)for(d=0;d<h;d++){e=i[d];f=d*3;k[f]=e.x;k[f+1]=e.y;k[f+2]=e.z}if(q)for(d=0;d<l;d++){e=j[d];f=d*3;m[f]=e.r;m[f+1]=e.g;m[f+2]=e.b}if(r){j=0;for(l=r.length;j<l;j++){i=r[j];if(i.needsUpdate&&(i.boundTo===void 0||i.boundTo==="vertices")){e=i.value.length;f=0;if(i.size===1)for(d=0;d<e;d++)i.array[d]=i.value[d];else if(i.size===2)for(d=0;d<e;d++){h=i.value[d];i.array[f]=h.x;i.array[f+1]=h.y;f=f+2}else if(i.size===
 3)if(i.type==="c")for(d=0;d<e;d++){h=i.value[d];i.array[f]=h.r;i.array[f+1]=h.g;i.array[f+2]=h.b;f=f+3}else for(d=0;d<e;d++){h=i.value[d];i.array[f]=h.x;i.array[f+1]=h.y;i.array[f+2]=h.z;f=f+3}else if(i.size===4)for(d=0;d<e;d++){h=i.value[d];i.array[f]=h.x;i.array[f+1]=h.y;i.array[f+2]=h.z;i.array[f+3]=h.w;f=f+4}}}}}if(n||c.sortParticles){g.bindBuffer(g.ARRAY_BUFFER,a.__webglVertexBuffer);g.bufferData(g.ARRAY_BUFFER,k,b)}if(q||c.sortParticles){g.bindBuffer(g.ARRAY_BUFFER,a.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,
 m,b)}if(r){j=0;for(l=r.length;j<l;j++){i=r[j];if(i.needsUpdate||c.sortParticles){g.bindBuffer(g.ARRAY_BUFFER,i.buffer);g.bufferData(g.ARRAY_BUFFER,i.array,b)}}}}function h(a,b){return b.z-a.z}function l(a,b){return b[1]-a[1]}function m(a,b,c){if(a.length)for(var d=0,g=a.length;d<g;d++){ga=za=null;na=ca=Ha=Ba=nb=Xa=Ia=-1;ob=true;a[d].render(b,c,$b,ac);ga=za=null;na=ca=Ha=Ba=nb=Xa=Ia=-1;ob=true}}function k(a,b,c,d,g,f,e,h){var i,j,l,k;if(b){j=a.length-1;k=b=-1}else{j=0;b=a.length;k=1}for(var m=j;m!==
-b;m=m+k){i=a[m];if(i.render){j=i.object;l=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;e&&F.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);F.setDepthTest(i.depthTest);F.setDepthWrite(i.depthWrite);s(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}F.setObjectFaces(j);l instanceof THREE.BufferGeometry?F.renderBufferDirect(d,g,f,i,l,j):F.renderBuffer(d,g,f,i,l,j)}}}function i(a,b,c,d,g,f,e){for(var h,i,j=0,l=a.length;j<l;j++){h=a[j];i=h.object;if(i.visible){if(e)h=e;else{h=
-h[b];if(!h)continue;f&&F.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);F.setDepthTest(h.depthTest);F.setDepthWrite(h.depthWrite);s(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}F.renderImmediateObject(c,d,g,h,i)}}}function o(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function j(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function w(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function r(a,
+b;m=m+k){i=a[m];if(i.render){j=i.object;l=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;e&&F.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);F.setDepthTest(i.depthTest);F.setDepthWrite(i.depthWrite);u(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}F.setObjectFaces(j);l instanceof THREE.BufferGeometry?F.renderBufferDirect(d,g,f,i,l,j):F.renderBuffer(d,g,f,i,l,j)}}}function i(a,b,c,d,g,f,e){for(var h,i,j=0,l=a.length;j<l;j++){h=a[j];i=h.object;if(i.visible){if(e)h=e;else{h=
+h[b];if(!h)continue;f&&F.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst);F.setDepthTest(h.depthTest);F.setDepthWrite(h.depthWrite);u(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}F.renderImmediateObject(c,d,g,h,i)}}}function o(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function j(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function w(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function r(a,
 b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,f){if(d.needsUpdate){d.program&&F.deallocateMaterial(d);F.initMaterial(d,b,c,f);d.needsUpdate=false}if(d.morphTargets&&!f.__webglMorphTargetInfluences)f.__webglMorphTargetInfluences=new Float32Array(F.maxMorphTargets);var e=false,h=d.program,i=h.uniforms,j=d.uniforms;if(h!==za){g.useProgram(h);za=h;e=true}if(d.id!==na){na=d.id;e=true}if(e||a!==ga){g.uniformMatrix4fv(i.projectionMatrix,
-false,a._projectionMatrixArray);a!==ga&&(ga=a)}if(e){if(c&&d.fog){j.fogColor.value=c.color;if(c instanceof THREE.Fog){j.fogNear.value=c.near;j.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(ob){for(var l,k=0,m=0,o=0,n,q,r,p=bc,s=p.directional.colors,w=p.directional.positions,u=p.point.colors,y=p.point.positions,B=p.point.distances,E=p.spot.colors,I=p.spot.positions,J=p.spot.distances,
-L=p.spot.directions,Q=p.spot.angles,G=p.spot.exponents,R=0,S=0,T=0,H=r=0,c=H=0,e=b.length;c<e;c++){l=b[c];if(!l.onlyShadow&&l.visible){n=l.color;q=l.intensity;r=l.distance;if(l instanceof THREE.AmbientLight)if(F.gammaInput){k=k+n.r*n.r;m=m+n.g*n.g;o=o+n.b*n.b}else{k=k+n.r;m=m+n.g;o=o+n.b}else if(l instanceof THREE.DirectionalLight){r=R*3;if(F.gammaInput){s[r]=n.r*n.r*q*q;s[r+1]=n.g*n.g*q*q;s[r+2]=n.b*n.b*q*q}else{s[r]=n.r*q;s[r+1]=n.g*q;s[r+2]=n.b*q}Ca.copy(l.matrixWorld.getPosition());Ca.subSelf(l.target.matrixWorld.getPosition());
-Ca.normalize();w[r]=Ca.x;w[r+1]=Ca.y;w[r+2]=Ca.z;R=R+1}else if(l instanceof THREE.PointLight){H=S*3;if(F.gammaInput){u[H]=n.r*n.r*q*q;u[H+1]=n.g*n.g*q*q;u[H+2]=n.b*n.b*q*q}else{u[H]=n.r*q;u[H+1]=n.g*q;u[H+2]=n.b*q}n=l.matrixWorld.getPosition();y[H]=n.x;y[H+1]=n.y;y[H+2]=n.z;B[S]=r;S=S+1}else if(l instanceof THREE.SpotLight){H=T*3;if(F.gammaInput){E[H]=n.r*n.r*q*q;E[H+1]=n.g*n.g*q*q;E[H+2]=n.b*n.b*q*q}else{E[H]=n.r*q;E[H+1]=n.g*q;E[H+2]=n.b*q}n=l.matrixWorld.getPosition();I[H]=n.x;I[H+1]=n.y;I[H+2]=
-n.z;J[T]=r;Ca.copy(n);Ca.subSelf(l.target.matrixWorld.getPosition());Ca.normalize();L[H]=Ca.x;L[H+1]=Ca.y;L[H+2]=Ca.z;Q[T]=Math.cos(l.angle);G[T]=l.exponent;T=T+1}}}c=R*3;for(e=s.length;c<e;c++)s[c]=0;c=S*3;for(e=u.length;c<e;c++)u[c]=0;c=T*3;for(e=E.length;c<e;c++)E[c]=0;p.directional.length=R;p.point.length=S;p.spot.length=T;p.ambient[0]=k;p.ambient[1]=m;p.ambient[2]=o;ob=false}c=bc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=
+false,a._projectionMatrixArray);a!==ga&&(ga=a)}if(e){if(c&&d.fog){j.fogColor.value=c.color;if(c instanceof THREE.Fog){j.fogNear.value=c.near;j.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(ob){for(var l,k=0,m=0,o=0,n,r,q,p=bc,u=p.directional.colors,w=p.directional.positions,s=p.point.colors,y=p.point.positions,B=p.point.distances,E=p.spot.colors,I=p.spot.positions,J=p.spot.distances,
+L=p.spot.directions,Q=p.spot.angles,G=p.spot.exponents,R=0,S=0,T=0,H=q=0,c=H=0,e=b.length;c<e;c++){l=b[c];if(!l.onlyShadow&&l.visible){n=l.color;r=l.intensity;q=l.distance;if(l instanceof THREE.AmbientLight)if(F.gammaInput){k=k+n.r*n.r;m=m+n.g*n.g;o=o+n.b*n.b}else{k=k+n.r;m=m+n.g;o=o+n.b}else if(l instanceof THREE.DirectionalLight){q=R*3;if(F.gammaInput){u[q]=n.r*n.r*r*r;u[q+1]=n.g*n.g*r*r;u[q+2]=n.b*n.b*r*r}else{u[q]=n.r*r;u[q+1]=n.g*r;u[q+2]=n.b*r}Ca.copy(l.matrixWorld.getPosition());Ca.subSelf(l.target.matrixWorld.getPosition());
+Ca.normalize();w[q]=Ca.x;w[q+1]=Ca.y;w[q+2]=Ca.z;R=R+1}else if(l instanceof THREE.PointLight){H=S*3;if(F.gammaInput){s[H]=n.r*n.r*r*r;s[H+1]=n.g*n.g*r*r;s[H+2]=n.b*n.b*r*r}else{s[H]=n.r*r;s[H+1]=n.g*r;s[H+2]=n.b*r}n=l.matrixWorld.getPosition();y[H]=n.x;y[H+1]=n.y;y[H+2]=n.z;B[S]=q;S=S+1}else if(l instanceof THREE.SpotLight){H=T*3;if(F.gammaInput){E[H]=n.r*n.r*r*r;E[H+1]=n.g*n.g*r*r;E[H+2]=n.b*n.b*r*r}else{E[H]=n.r*r;E[H+1]=n.g*r;E[H+2]=n.b*r}n=l.matrixWorld.getPosition();I[H]=n.x;I[H+1]=n.y;I[H+2]=
+n.z;J[T]=q;Ca.copy(n);Ca.subSelf(l.target.matrixWorld.getPosition());Ca.normalize();L[H]=Ca.x;L[H+1]=Ca.y;L[H+2]=Ca.z;Q[T]=Math.cos(l.angle);G[T]=l.exponent;T=T+1}}}c=R*3;for(e=u.length;c<e;c++)u[c]=0;c=S*3;for(e=s.length;c<e;c++)s[c]=0;c=T*3;for(e=E.length;c<e;c++)E[c]=0;p.directional.length=R;p.point.length=S;p.spot.length=T;p.ambient[0]=k;p.ambient[1]=m;p.ambient[2]=o;ob=false}c=bc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=
 c.directional.positions;j.pointLightColor.value=c.point.colors;j.pointLightPosition.value=c.point.positions;j.pointLightDistance.value=c.point.distances;j.spotLightColor.value=c.spot.colors;j.spotLightPosition.value=c.spot.positions;j.spotLightDistance.value=c.spot.distances;j.spotLightDirection.value=c.spot.directions;j.spotLightAngle.value=c.spot.angles;j.spotLightExponent.value=c.spot.exponents}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial){j.opacity.value=
 d.opacity;F.gammaInput?j.diffuse.value.copyGammaToLinear(d.color):j.diffuse.value=d.color;(j.map.texture=d.map)&&j.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y);j.lightMap.texture=d.lightMap;j.envMap.texture=d.envMap;j.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1;j.reflectivity.value=d.reflectivity;j.refractionRatio.value=d.refractionRatio;j.combine.value=d.combine;j.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping}if(d instanceof
 THREE.LineBasicMaterial){j.diffuse.value=d.color;j.opacity.value=d.opacity}else if(d instanceof THREE.ParticleBasicMaterial){j.psColor.value=d.color;j.opacity.value=d.opacity;j.size.value=d.size;j.scale.value=M.height/2;j.map.texture=d.map}else if(d instanceof THREE.MeshPhongMaterial){j.shininess.value=d.shininess;if(F.gammaInput){j.ambient.value.copyGammaToLinear(d.ambient);j.emissive.value.copyGammaToLinear(d.emissive);j.specular.value.copyGammaToLinear(d.specular)}else{j.ambient.value=d.ambient;
@@ -289,12 +290,12 @@ d.opacity;if(f.receiveShadow&&!d._shadowPass&&j.shadowMatrix){e=c=0;for(l=b.leng
 switch(m){case "i":g.uniform1i(k,l);break;case "f":g.uniform1f(k,l);break;case "v2":g.uniform2f(k,l.x,l.y);break;case "v3":g.uniform3f(k,l.x,l.y,l.z);break;case "v4":g.uniform4f(k,l.x,l.y,l.z,l.w);break;case "c":g.uniform3f(k,l.r,l.g,l.b);break;case "fv1":g.uniform1fv(k,l);break;case "fv":g.uniform3fv(k,l);break;case "v2v":if(!e._array)e._array=new Float32Array(2*l.length);m=0;for(o=l.length;m<o;m++){p=m*2;e._array[p]=l[m].x;e._array[p+1]=l[m].y}g.uniform2fv(k,e._array);break;case "v3v":if(!e._array)e._array=
 new Float32Array(3*l.length);m=0;for(o=l.length;m<o;m++){p=m*3;e._array[p]=l[m].x;e._array[p+1]=l[m].y;e._array[p+2]=l[m].z}g.uniform3fv(k,e._array);break;case "v4v":if(!e._array)e._array=new Float32Array(4*l.length);m=0;for(o=l.length;m<o;m++){p=m*4;e._array[p]=l[m].x;e._array[p+1]=l[m].y;e._array[p+2]=l[m].z;e._array[p+3]=l[m].w}g.uniform4fv(k,e._array);break;case "m4":if(!e._array)e._array=new Float32Array(16);l.flattenToArray(e._array);g.uniformMatrix4fv(k,false,e._array);break;case "m4v":if(!e._array)e._array=
 new Float32Array(16*l.length);m=0;for(o=l.length;m<o;m++)l[m].flattenToArrayOffset(e._array,m*16);g.uniformMatrix4fv(k,false,e._array);break;case "t":g.uniform1i(k,l);k=e.texture;if(!k)continue;if(k.image instanceof Array&&k.image.length===6){e=k;if(e.image.length===6)if(e.needsUpdate){if(!e.image.__webglTextureCube)e.image.__webglTextureCube=g.createTexture();g.activeTexture(g.TEXTURE0+l);g.bindTexture(g.TEXTURE_CUBE_MAP,e.image.__webglTextureCube);l=[];for(k=0;k<6;k++){m=l;o=k;if(F.autoScaleCubemaps){p=
-e.image[k];w=Kc;if(!(p.width<=w&&p.height<=w)){u=Math.max(p.width,p.height);s=Math.floor(p.width*w/u);w=Math.floor(p.height*w/u);u=document.createElement("canvas");u.width=s;u.height=w;u.getContext("2d").drawImage(p,0,0,p.width,p.height,0,0,s,w);p=u}}else p=e.image[k];m[o]=p}k=l[0];m=(k.width&k.width-1)===0&&(k.height&k.height-1)===0;o=D(e.format);p=D(e.type);A(g.TEXTURE_CUBE_MAP,e,m);for(k=0;k<6;k++)g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,o,o,p,l[k]);e.generateMipmaps&&m&&g.generateMipmap(g.TEXTURE_CUBE_MAP);
+e.image[k];w=Kc;if(!(p.width<=w&&p.height<=w)){s=Math.max(p.width,p.height);u=Math.floor(p.width*w/s);w=Math.floor(p.height*w/s);s=document.createElement("canvas");s.width=u;s.height=w;s.getContext("2d").drawImage(p,0,0,p.width,p.height,0,0,u,w);p=s}}else p=e.image[k];m[o]=p}k=l[0];m=(k.width&k.width-1)===0&&(k.height&k.height-1)===0;o=D(e.format);p=D(e.type);A(g.TEXTURE_CUBE_MAP,e,m);for(k=0;k<6;k++)g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,o,o,p,l[k]);e.generateMipmaps&&m&&g.generateMipmap(g.TEXTURE_CUBE_MAP);
 e.needsUpdate=false;if(e.onUpdate)e.onUpdate()}else{g.activeTexture(g.TEXTURE0+l);g.bindTexture(g.TEXTURE_CUBE_MAP,e.image.__webglTextureCube)}}else if(k instanceof THREE.WebGLRenderTargetCube){e=k;g.activeTexture(g.TEXTURE0+l);g.bindTexture(g.TEXTURE_CUBE_MAP,e.__webglTexture)}else F.setTexture(k,l);break;case "tv":if(!e._array){e._array=[];m=0;for(o=e.texture.length;m<o;m++)e._array[m]=l+m}g.uniform1iv(k,e._array);m=0;for(o=e.texture.length;m<o;m++)(k=e.texture[m])&&F.setTexture(k,e._array[m])}}if((d instanceof
 THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&i.cameraPosition!==null){b=a.matrixWorld.getPosition();g.uniform3f(i.cameraPosition,b.x,b.y,b.z)}(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&i.viewMatrix!==null&&g.uniformMatrix4fv(i.viewMatrix,false,a._viewMatrixArray);d.skinning&&g.uniformMatrix4fv(i.boneGlobalMatrices,false,f.boneMatrices)}g.uniformMatrix4fv(i.modelViewMatrix,false,f._modelViewMatrix.elements);
-i.normalMatrix&&g.uniformMatrix3fv(i.normalMatrix,false,f._normalMatrix.elements);i.objectMatrix!==null&&g.uniformMatrix4fv(i.objectMatrix,false,f.matrixWorld.elements);return h}function p(a,b){a._modelViewMatrix.multiply(b.matrixWorldInverse,a.matrixWorld);a._normalMatrix.getInverse(a._modelViewMatrix);a._normalMatrix.transpose()}function s(a,b,c){if(sc!==a){a?g.enable(g.POLYGON_OFFSET_FILL):g.disable(g.POLYGON_OFFSET_FILL);sc=a}if(a&&(tc!==b||uc!==c)){g.polygonOffset(b,c);tc=b;uc=c}}function B(a,
+i.normalMatrix&&g.uniformMatrix3fv(i.normalMatrix,false,f._normalMatrix.elements);i.objectMatrix!==null&&g.uniformMatrix4fv(i.objectMatrix,false,f.matrixWorld.elements);return h}function p(a,b){a._modelViewMatrix.multiply(b.matrixWorldInverse,a.matrixWorld);a._normalMatrix.getInverse(a._modelViewMatrix);a._normalMatrix.transpose()}function u(a,b,c){if(sc!==a){a?g.enable(g.POLYGON_OFFSET_FILL):g.disable(g.POLYGON_OFFSET_FILL);sc=a}if(a&&(tc!==b||uc!==c)){g.polygonOffset(b,c);tc=b;uc=c}}function B(a,
 b){var c;a==="fragment"?c=g.createShader(g.FRAGMENT_SHADER):a==="vertex"&&(c=g.createShader(g.VERTEX_SHADER));g.shaderSource(c,b);g.compileShader(c);if(!g.getShaderParameter(c,g.COMPILE_STATUS)){console.error(g.getShaderInfoLog(c));console.error(b);return null}return c}function A(a,b,c){if(c){g.texParameteri(a,g.TEXTURE_WRAP_S,D(b.wrapS));g.texParameteri(a,g.TEXTURE_WRAP_T,D(b.wrapT));g.texParameteri(a,g.TEXTURE_MAG_FILTER,D(b.magFilter));g.texParameteri(a,g.TEXTURE_MIN_FILTER,D(b.minFilter))}else{g.texParameteri(a,
-g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE);g.texParameteri(a,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE);g.texParameteri(a,g.TEXTURE_MAG_FILTER,J(b.magFilter));g.texParameteri(a,g.TEXTURE_MIN_FILTER,J(b.minFilter))}}function u(a,b){g.bindRenderbuffer(g.RENDERBUFFER,a);if(b.depthBuffer&&!b.stencilBuffer){g.renderbufferStorage(g.RENDERBUFFER,g.DEPTH_COMPONENT16,b.width,b.height);g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_ATTACHMENT,g.RENDERBUFFER,a)}else if(b.depthBuffer&&b.stencilBuffer){g.renderbufferStorage(g.RENDERBUFFER,
+g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE);g.texParameteri(a,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE);g.texParameteri(a,g.TEXTURE_MAG_FILTER,J(b.magFilter));g.texParameteri(a,g.TEXTURE_MIN_FILTER,J(b.minFilter))}}function s(a,b){g.bindRenderbuffer(g.RENDERBUFFER,a);if(b.depthBuffer&&!b.stencilBuffer){g.renderbufferStorage(g.RENDERBUFFER,g.DEPTH_COMPONENT16,b.width,b.height);g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_ATTACHMENT,g.RENDERBUFFER,a)}else if(b.depthBuffer&&b.stencilBuffer){g.renderbufferStorage(g.RENDERBUFFER,
 g.DEPTH_STENCIL,b.width,b.height);g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_STENCIL_ATTACHMENT,g.RENDERBUFFER,a)}else g.renderbufferStorage(g.RENDERBUFFER,g.RGBA4,b.width,b.height)}function J(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return g.NEAREST;default:return g.LINEAR}}function D(a){switch(a){case THREE.RepeatWrapping:return g.REPEAT;case THREE.ClampToEdgeWrapping:return g.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return g.MIRRORED_REPEAT;
 case THREE.NearestFilter:return g.NEAREST;case THREE.NearestMipMapNearestFilter:return g.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return g.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return g.LINEAR;case THREE.LinearMipMapNearestFilter:return g.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return g.LINEAR_MIPMAP_LINEAR;case THREE.UnsignedByteType:return g.UNSIGNED_BYTE;case THREE.UnsignedShort4444Type:return g.UNSIGNED_SHORT_4_4_4_4;case THREE.UnsignedShort5551Type:return g.UNSIGNED_SHORT_5_5_5_1;
 case THREE.UnsignedShort565Type:return g.UNSIGNED_SHORT_5_6_5;case THREE.ByteType:return g.BYTE;case THREE.ShortType:return g.SHORT;case THREE.UnsignedShortType:return g.UNSIGNED_SHORT;case THREE.IntType:return g.INT;case THREE.UnsignedIntType:return g.UNSIGNED_INT;case THREE.FloatType:return g.FLOAT;case THREE.AlphaFormat:return g.ALPHA;case THREE.RGBFormat:return g.RGB;case THREE.RGBAFormat:return g.RGBA;case THREE.LuminanceFormat:return g.LUMINANCE;case THREE.LuminanceAlphaFormat:return g.LUMINANCE_ALPHA;
@@ -312,7 +313,7 @@ void 0;for(d in c.__webglCustomAttributesList)g.deleteBuffer(c.__webglCustomAttr
 g.deleteBuffer(a.__webglColorBuffer);F.info.memory.geometries--}}};this.deallocateTexture=function(a){if(a.__webglInit){a.__webglInit=false;g.deleteTexture(a.__webglTexture);F.info.memory.textures--}};this.deallocateRenderTarget=function(a){if(a&&a.__webglTexture){g.deleteTexture(a.__webglTexture);if(a instanceof THREE.WebGLRenderTargetCube)for(var b=0;b<6;b++){g.deleteFramebuffer(a.__webglFramebuffer[b]);g.deleteRenderbuffer(a.__webglRenderbuffer[b])}else{g.deleteFramebuffer(a.__webglFramebuffer);
 g.deleteRenderbuffer(a.__webglRenderbuffer)}}};this.deallocateMaterial=function(a){var b=a.program;if(b){a.program=void 0;var c,d,e=false,a=0;for(c=W.length;a<c;a++){d=W[a];if(d.program===b){d.usedTimes--;d.usedTimes===0&&(e=true);break}}if(e){e=[];a=0;for(c=W.length;a<c;a++){d=W[a];d.program!==b&&e.push(d)}W=e;g.deleteProgram(b);F.info.memory.programs--}}};this.updateShadowMap=function(a,b){za=null;na=ca=nb=Xa=Ia=-1;ob=true;Ha=Ba=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,
 b,c){if(a.hasPositions&&!a.__webglVertexBuffer)a.__webglVertexBuffer=g.createBuffer();if(a.hasNormals&&!a.__webglNormalBuffer)a.__webglNormalBuffer=g.createBuffer();if(a.hasUvs&&!a.__webglUvBuffer)a.__webglUvBuffer=g.createBuffer();if(a.hasColors&&!a.__webglColorBuffer)a.__webglColorBuffer=g.createBuffer();if(a.hasPositions){g.bindBuffer(g.ARRAY_BUFFER,a.__webglVertexBuffer);g.bufferData(g.ARRAY_BUFFER,a.positionArray,g.DYNAMIC_DRAW);g.enableVertexAttribArray(b.attributes.position);g.vertexAttribPointer(b.attributes.position,
-3,g.FLOAT,false,0,0)}if(a.hasNormals){g.bindBuffer(g.ARRAY_BUFFER,a.__webglNormalBuffer);if(c.shading===THREE.FlatShading){var d,e,f,h,i,j,l,k,m,n,o,q=a.count*3;for(o=0;o<q;o=o+9){n=a.normalArray;d=n[o];e=n[o+1];f=n[o+2];h=n[o+3];j=n[o+4];k=n[o+5];i=n[o+6];l=n[o+7];m=n[o+8];d=(d+h+i)/3;e=(e+j+l)/3;f=(f+k+m)/3;n[o]=d;n[o+1]=e;n[o+2]=f;n[o+3]=d;n[o+4]=e;n[o+5]=f;n[o+6]=d;n[o+7]=e;n[o+8]=f}}g.bufferData(g.ARRAY_BUFFER,a.normalArray,g.DYNAMIC_DRAW);g.enableVertexAttribArray(b.attributes.normal);g.vertexAttribPointer(b.attributes.normal,
+3,g.FLOAT,false,0,0)}if(a.hasNormals){g.bindBuffer(g.ARRAY_BUFFER,a.__webglNormalBuffer);if(c.shading===THREE.FlatShading){var d,e,f,h,i,j,l,k,m,n,o,r=a.count*3;for(o=0;o<r;o=o+9){n=a.normalArray;d=n[o];e=n[o+1];f=n[o+2];h=n[o+3];j=n[o+4];k=n[o+5];i=n[o+6];l=n[o+7];m=n[o+8];d=(d+h+i)/3;e=(e+j+l)/3;f=(f+k+m)/3;n[o]=d;n[o+1]=e;n[o+2]=f;n[o+3]=d;n[o+4]=e;n[o+5]=f;n[o+6]=d;n[o+7]=e;n[o+8]=f}}g.bufferData(g.ARRAY_BUFFER,a.normalArray,g.DYNAMIC_DRAW);g.enableVertexAttribArray(b.attributes.normal);g.vertexAttribPointer(b.attributes.normal,
 3,g.FLOAT,false,0,0)}if(a.hasUvs&&c.map){g.bindBuffer(g.ARRAY_BUFFER,a.__webglUvBuffer);g.bufferData(g.ARRAY_BUFFER,a.uvArray,g.DYNAMIC_DRAW);g.enableVertexAttribArray(b.attributes.uv);g.vertexAttribPointer(b.attributes.uv,2,g.FLOAT,false,0,0)}if(a.hasColors&&c.vertexColors!==THREE.NoColors){g.bindBuffer(g.ARRAY_BUFFER,a.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,a.colorArray,g.DYNAMIC_DRAW);g.enableVertexAttribArray(b.attributes.color);g.vertexAttribPointer(b.attributes.color,3,g.FLOAT,false,
 0,0)}g.drawArrays(g.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,f){if(d.visible!==false){c=q(a,b,c,d,f);a=c.attributes;b=false;d=e.id*16777215+c.id*2+(d.wireframe?1:0);if(d!==ca){ca=d;b=true}if(f instanceof THREE.Mesh){f=e.offsets;d=0;for(c=f.length;d<c;++d){if(b){g.bindBuffer(g.ARRAY_BUFFER,e.vertexPositionBuffer);g.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,g.FLOAT,false,0,f[d].index*12);if(a.normal>=0&&e.vertexNormalBuffer){g.bindBuffer(g.ARRAY_BUFFER,
 e.vertexNormalBuffer);g.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,g.FLOAT,false,0,f[d].index*12)}if(a.uv>=0&&e.vertexUvBuffer)if(e.vertexUvBuffer){g.bindBuffer(g.ARRAY_BUFFER,e.vertexUvBuffer);g.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,g.FLOAT,false,0,f[d].index*8);g.enableVertexAttribArray(a.uv)}else g.disableVertexAttribArray(a.uv);if(a.color>=0&&e.vertexColorBuffer){g.bindBuffer(g.ARRAY_BUFFER,e.vertexColorBuffer);g.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,
@@ -325,16 +326,16 @@ c.size,g.FLOAT,false,0,0)}}}if(b.color>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webgl
 false,0,0);g.enableVertexAttribArray(b.uv)}else g.disableVertexAttribArray(b.uv);if(b.uv2>=0)if(e.__webglUV2Buffer){g.bindBuffer(g.ARRAY_BUFFER,e.__webglUV2Buffer);g.vertexAttribPointer(b.uv2,2,g.FLOAT,false,0,0);g.enableVertexAttribArray(b.uv2)}else g.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinVertexABuffer);g.vertexAttribPointer(b.skinVertexA,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,
 e.__webglSkinVertexBBuffer);g.vertexAttribPointer(b.skinVertexB,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);g.vertexAttribPointer(b.skinIndex,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);g.vertexAttribPointer(b.skinWeight,4,g.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==Hb){g.lineWidth(d);Hb=d}a&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);g.drawElements(g.LINES,e.__webglLineCount,
 g.UNSIGNED_SHORT,0)}else{a&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer);g.drawElements(g.TRIANGLES,e.__webglFaceCount,g.UNSIGNED_SHORT,0)}F.info.render.calls++;F.info.render.vertices=F.info.render.vertices+e.__webglFaceCount;F.info.render.faces=F.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?g.LINE_STRIP:g.LINES;d=d.linewidth;if(d!==Hb){g.lineWidth(d);Hb=d}g.drawArrays(f,0,e.__webglLineCount);F.info.render.calls++}else if(f instanceof
-THREE.ParticleSystem){g.drawArrays(g.POINTS,0,e.__webglParticleCount);F.info.render.calls++;F.info.render.points=F.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){g.drawArrays(g.TRIANGLE_STRIP,0,e.__webglVertexCount);F.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,j,l,n=a.__lights,o=a.fog;na=-1;ob=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();
+THREE.ParticleSystem){g.drawArrays(g.POINTS,0,e.__webglParticleCount);F.info.render.calls++;F.info.render.points=F.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){g.drawArrays(g.TRIANGLE_STRIP,0,e.__webglVertexCount);F.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,j,l,o=a.__lights,n=a.fog;na=-1;ob=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();
 if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Rb.multiply(b.projectionMatrix,b.matrixWorldInverse);dc.setFromMatrix(Rb);this.autoUpdateObjects&&this.initWebGLObjects(a);m(this.renderPluginsPre,a,b);F.info.render.calls=0;F.info.render.vertices=0;F.info.render.faces=
-0;F.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);l=a.__webglObjects;d=0;for(e=l.length;d<e;d++){f=l[d];j=f.object;f.render=false;if(j.visible&&(!(j instanceof THREE.Mesh||j instanceof THREE.ParticleSystem)||!j.frustumCulled||dc.contains(j))){p(j,b);var q=f,r=q.object,w=q.buffer,u=void 0,u=u=void 0,u=r.material;if(u instanceof THREE.MeshFaceMaterial){u=w.materialIndex;if(u>=0){u=r.geometry.materials[u];if(u.transparent){q.transparent=
-u;q.opaque=null}else{q.opaque=u;q.transparent=null}}}else if(u)if(u.transparent){q.transparent=u;q.opaque=null}else{q.opaque=u;q.transparent=null}f.render=true;if(this.sortObjects)if(j.renderDepth)f.z=j.renderDepth;else{Oa.copy(j.matrixWorld.getPosition());Rb.multiplyVector3(Oa);f.z=Oa.z}}}this.sortObjects&&l.sort(h);l=a.__webglObjectsImmediate;d=0;for(e=l.length;d<e;d++){f=l[d];j=f.object;if(j.visible){p(j,b);j=f.object.material;if(j.transparent){f.transparent=j;f.opaque=null}else{f.opaque=j;f.transparent=
-null}}}if(a.overrideMaterial){d=a.overrideMaterial;this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst);this.setDepthTest(d.depthTest);this.setDepthWrite(d.depthWrite);s(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits);k(a.__webglObjects,false,"",b,n,o,true,d);i(a.__webglObjectsImmediate,"",b,n,o,false,d)}else{this.setBlending(THREE.NormalBlending);k(a.__webglObjects,true,"opaque",b,n,o,false);i(a.__webglObjectsImmediate,"opaque",b,n,o,false);k(a.__webglObjects,false,"transparent",
-b,n,o,true);i(a.__webglObjectsImmediate,"transparent",b,n,o,true)}m(this.renderPluginsPost,a,b);if(c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter)if(c instanceof THREE.WebGLRenderTargetCube){g.bindTexture(g.TEXTURE_CUBE_MAP,c.__webglTexture);g.generateMipmap(g.TEXTURE_CUBE_MAP);g.bindTexture(g.TEXTURE_CUBE_MAP,null)}else{g.bindTexture(g.TEXTURE_2D,c.__webglTexture);g.generateMipmap(g.TEXTURE_2D);g.bindTexture(g.TEXTURE_2D,null)}this.setDepthTest(true);this.setDepthWrite(true)};
+0;F.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);l=a.__webglObjects;d=0;for(e=l.length;d<e;d++){f=l[d];j=f.object;f.render=false;if(j.visible&&(!(j instanceof THREE.Mesh||j instanceof THREE.ParticleSystem)||!j.frustumCulled||dc.contains(j))){p(j,b);var r=f,q=r.object,w=r.buffer,s=void 0,s=s=void 0,s=q.material;if(s instanceof THREE.MeshFaceMaterial){s=w.materialIndex;if(s>=0){s=q.geometry.materials[s];if(s.transparent){r.transparent=
+s;r.opaque=null}else{r.opaque=s;r.transparent=null}}}else if(s)if(s.transparent){r.transparent=s;r.opaque=null}else{r.opaque=s;r.transparent=null}f.render=true;if(this.sortObjects)if(j.renderDepth)f.z=j.renderDepth;else{Oa.copy(j.matrixWorld.getPosition());Rb.multiplyVector3(Oa);f.z=Oa.z}}}this.sortObjects&&l.sort(h);l=a.__webglObjectsImmediate;d=0;for(e=l.length;d<e;d++){f=l[d];j=f.object;if(j.visible){p(j,b);j=f.object.material;if(j.transparent){f.transparent=j;f.opaque=null}else{f.opaque=j;f.transparent=
+null}}}if(a.overrideMaterial){d=a.overrideMaterial;this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst);this.setDepthTest(d.depthTest);this.setDepthWrite(d.depthWrite);u(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits);k(a.__webglObjects,false,"",b,o,n,true,d);i(a.__webglObjectsImmediate,"",b,o,n,false,d)}else{this.setBlending(THREE.NormalBlending);k(a.__webglObjects,true,"opaque",b,o,n,false);i(a.__webglObjectsImmediate,"opaque",b,o,n,false);k(a.__webglObjects,false,"transparent",
+b,o,n,true);i(a.__webglObjectsImmediate,"transparent",b,o,n,true)}m(this.renderPluginsPost,a,b);if(c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter)if(c instanceof THREE.WebGLRenderTargetCube){g.bindTexture(g.TEXTURE_CUBE_MAP,c.__webglTexture);g.generateMipmap(g.TEXTURE_CUBE_MAP);g.bindTexture(g.TEXTURE_CUBE_MAP,null)}else{g.bindTexture(g.TEXTURE_2D,c.__webglTexture);g.generateMipmap(g.TEXTURE_2D);g.bindTexture(g.TEXTURE_2D,null)}this.setDepthTest(true);this.setDepthWrite(true)};
 this.renderImmediateObject=function(a,b,c,d,e){var f=q(a,b,c,d,e);ca=-1;F.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,g,dc):e.render(function(a){F.renderBufferImmediate(a,f,d)})};this.initWebGLObjects=function(a){if(!a.__webglObjects){a.__webglObjects=[];a.__webglObjectsImmediate=[];a.__webglSprites=[];a.__webglFlares=[]}for(;a.__objectsAdded.length;){var h=a.__objectsAdded[0],i=a,l=void 0,k=void 0,m=void 0;if(!h.__webglInit){h.__webglInit=true;h._modelViewMatrix=new THREE.Matrix4;
-h._normalMatrix=new THREE.Matrix3;if(h instanceof THREE.Mesh){k=h.geometry;if(k instanceof THREE.Geometry){if(k.geometryGroups===void 0){var q=k,p=void 0,s=void 0,u=void 0,y=void 0,D=void 0,A=void 0,B=void 0,E={},I=q.morphTargets.length,J=q.morphNormals.length;q.geometryGroups={};p=0;for(s=q.faces.length;p<s;p++){u=q.faces[p];y=u.materialIndex;A=y!==void 0?y:-1;E[A]===void 0&&(E[A]={hash:A,counter:0});B=E[A].hash+"_"+E[A].counter;q.geometryGroups[B]===void 0&&(q.geometryGroups[B]={faces3:[],faces4:[],
-materialIndex:y,vertices:0,numMorphTargets:I,numMorphNormals:J});D=u instanceof THREE.Face3?3:4;if(q.geometryGroups[B].vertices+D>65535){E[A].counter=E[A].counter+1;B=E[A].hash+"_"+E[A].counter;q.geometryGroups[B]===void 0&&(q.geometryGroups[B]={faces3:[],faces4:[],materialIndex:y,vertices:0,numMorphTargets:I,numMorphNormals:J})}u instanceof THREE.Face3?q.geometryGroups[B].faces3.push(p):q.geometryGroups[B].faces4.push(p);q.geometryGroups[B].vertices=q.geometryGroups[B].vertices+D}q.geometryGroupsList=
-[];var L=void 0;for(L in q.geometryGroups){q.geometryGroups[L].id=oa++;q.geometryGroupsList.push(q.geometryGroups[L])}}for(l in k.geometryGroups){m=k.geometryGroups[l];if(!m.__webglVertexBuffer){var H=m;H.__webglVertexBuffer=g.createBuffer();H.__webglNormalBuffer=g.createBuffer();H.__webglTangentBuffer=g.createBuffer();H.__webglColorBuffer=g.createBuffer();H.__webglUVBuffer=g.createBuffer();H.__webglUV2Buffer=g.createBuffer();H.__webglSkinVertexABuffer=g.createBuffer();H.__webglSkinVertexBBuffer=
+h._normalMatrix=new THREE.Matrix3;if(h instanceof THREE.Mesh){k=h.geometry;if(k instanceof THREE.Geometry){if(k.geometryGroups===void 0){var p=k,q=void 0,s=void 0,u=void 0,y=void 0,D=void 0,A=void 0,B=void 0,E={},I=p.morphTargets.length,J=p.morphNormals.length;p.geometryGroups={};q=0;for(s=p.faces.length;q<s;q++){u=p.faces[q];y=u.materialIndex;A=y!==void 0?y:-1;E[A]===void 0&&(E[A]={hash:A,counter:0});B=E[A].hash+"_"+E[A].counter;p.geometryGroups[B]===void 0&&(p.geometryGroups[B]={faces3:[],faces4:[],
+materialIndex:y,vertices:0,numMorphTargets:I,numMorphNormals:J});D=u instanceof THREE.Face3?3:4;if(p.geometryGroups[B].vertices+D>65535){E[A].counter=E[A].counter+1;B=E[A].hash+"_"+E[A].counter;p.geometryGroups[B]===void 0&&(p.geometryGroups[B]={faces3:[],faces4:[],materialIndex:y,vertices:0,numMorphTargets:I,numMorphNormals:J})}u instanceof THREE.Face3?p.geometryGroups[B].faces3.push(q):p.geometryGroups[B].faces4.push(q);p.geometryGroups[B].vertices=p.geometryGroups[B].vertices+D}p.geometryGroupsList=
+[];var L=void 0;for(L in p.geometryGroups){p.geometryGroups[L].id=oa++;p.geometryGroupsList.push(p.geometryGroups[L])}}for(l in k.geometryGroups){m=k.geometryGroups[l];if(!m.__webglVertexBuffer){var H=m;H.__webglVertexBuffer=g.createBuffer();H.__webglNormalBuffer=g.createBuffer();H.__webglTangentBuffer=g.createBuffer();H.__webglColorBuffer=g.createBuffer();H.__webglUVBuffer=g.createBuffer();H.__webglUV2Buffer=g.createBuffer();H.__webglSkinVertexABuffer=g.createBuffer();H.__webglSkinVertexBBuffer=
 g.createBuffer();H.__webglSkinIndicesBuffer=g.createBuffer();H.__webglSkinWeightsBuffer=g.createBuffer();H.__webglFaceBuffer=g.createBuffer();H.__webglLineBuffer=g.createBuffer();var M=void 0,Q=void 0;if(H.numMorphTargets){H.__webglMorphTargetsBuffers=[];M=0;for(Q=H.numMorphTargets;M<Q;M++)H.__webglMorphTargetsBuffers.push(g.createBuffer())}if(H.numMorphNormals){H.__webglMorphNormalsBuffers=[];M=0;for(Q=H.numMorphNormals;M<Q;M++)H.__webglMorphNormalsBuffers.push(g.createBuffer())}F.info.memory.geometries++;
 var G=m,S=h,R=S.geometry,T=G.faces3,Z=G.faces4,W=T.length*3+Z.length*4,ca=T.length*1+Z.length*2,na=T.length*3+Z.length*4,ga=c(S,G),za=f(ga),Ba=d(ga),Ha=ga.vertexColors?ga.vertexColors:false;G.__vertexArray=new Float32Array(W*3);if(Ba)G.__normalArray=new Float32Array(W*3);if(R.hasTangents)G.__tangentArray=new Float32Array(W*4);if(Ha)G.__colorArray=new Float32Array(W*3);if(za){if(R.faceUvs.length>0||R.faceVertexUvs.length>0)G.__uvArray=new Float32Array(W*2);if(R.faceUvs.length>1||R.faceVertexUvs.length>
 1)G.__uv2Array=new Float32Array(W*2)}if(S.geometry.skinWeights.length&&S.geometry.skinIndices.length){G.__skinVertexAArray=new Float32Array(W*4);G.__skinVertexBArray=new Float32Array(W*4);G.__skinIndexArray=new Float32Array(W*4);G.__skinWeightArray=new Float32Array(W*4)}G.__faceArray=new Uint16Array(ca*3);G.__lineArray=new Uint16Array(na*2);var Ca=void 0,Ia=void 0;if(G.numMorphTargets){G.__morphTargetsArrays=[];Ca=0;for(Ia=G.numMorphTargets;Ca<Ia;Ca++)G.__morphTargetsArrays.push(new Float32Array(W*
@@ -378,16 +379,16 @@ Fb.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,Ec,Vc)}}Y.verticesNeedUpdate=
 fa=void 0;if(tb.verticesNeedUpdate){for(qc=0;qc<hd;qc++){Fc=Yc[qc];ma=qc*3;Hc[ma]=Fc.x;Hc[ma+1]=Fc.y;Hc[ma+2]=Fc.z}g.bindBuffer(g.ARRAY_BUFFER,tb.__webglVertexBuffer);g.bufferData(g.ARRAY_BUFFER,Hc,Sc)}if(jd){for(rc=0;rc<id;rc++){Gc=Zc[rc];ma=rc*3;Ic[ma]=Gc.r;Ic[ma+1]=Gc.g;Ic[ma+2]=Gc.b}g.bindBuffer(g.ARRAY_BUFFER,tb.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,Ic,Sc)}if(Tc){Jc=0;for($c=Tc.length;Jc<$c;Jc++){fa=Tc[Jc];if(fa.needsUpdate&&(fa.boundTo===void 0||fa.boundTo==="vertices")){ma=0;Zb=fa.value.length;
 if(fa.size===1)for(ya=0;ya<Zb;ya++)fa.array[ya]=fa.value[ya];else if(fa.size===2)for(ya=0;ya<Zb;ya++){Ga=fa.value[ya];fa.array[ma]=Ga.x;fa.array[ma+1]=Ga.y;ma=ma+2}else if(fa.size===3)if(fa.type==="c")for(ya=0;ya<Zb;ya++){Ga=fa.value[ya];fa.array[ma]=Ga.r;fa.array[ma+1]=Ga.g;fa.array[ma+2]=Ga.b;ma=ma+3}else for(ya=0;ya<Zb;ya++){Ga=fa.value[ya];fa.array[ma]=Ga.x;fa.array[ma+1]=Ga.y;fa.array[ma+2]=Ga.z;ma=ma+3}else if(fa.size===4)for(ya=0;ya<Zb;ya++){Ga=fa.value[ya];fa.array[ma]=Ga.x;fa.array[ma+1]=
 Ga.y;fa.array[ma+2]=Ga.z;fa.array[ma+3]=Ga.w;ma=ma+4}g.bindBuffer(g.ARRAY_BUFFER,fa.buffer);g.bufferData(g.ARRAY_BUFFER,fa.array,Sc)}}}}Y.verticesNeedUpdate=false;Y.colorsNeedUpdate=false;Fa.attributes&&w(Fa)}else if(Va instanceof THREE.ParticleSystem){Fa=c(Va,gc);Tb=Fa.attributes&&j(Fa);(Y.verticesNeedUpdate||Y.colorsNeedUpdate||Va.sortParticles||Tb)&&e(Y,g.DYNAMIC_DRAW,Va);Y.verticesNeedUpdate=false;Y.colorsNeedUpdate=false;Fa.attributes&&w(Fa)}}};this.initMaterial=function(a,b,c,d){var e,f,h;a instanceof
-THREE.MeshDepthMaterial?h="depth":a instanceof THREE.MeshNormalMaterial?h="normal":a instanceof THREE.MeshBasicMaterial?h="basic":a instanceof THREE.MeshLambertMaterial?h="lambert":a instanceof THREE.MeshPhongMaterial?h="phong":a instanceof THREE.LineBasicMaterial?h="basic":a instanceof THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var i=THREE.ShaderLib[h];a.uniforms=THREE.UniformsUtils.clone(i.uniforms);a.vertexShader=i.vertexShader;a.fragmentShader=i.fragmentShader}var j,k,l,m,n;j=m=n=
-i=0;for(k=b.length;j<k;j++){l=b[j];if(!l.onlyShadow){l instanceof THREE.DirectionalLight&&m++;l instanceof THREE.PointLight&&n++;l instanceof THREE.SpotLight&&i++}}if(n+i+m<=Z){k=m;l=n;m=i}else{k=Math.ceil(Z*m/(n+m));m=l=Z-k}var o=0,i=0;for(n=b.length;i<n;i++){j=b[i];if(j.castShadow){j instanceof THREE.SpotLight&&o++;j instanceof THREE.DirectionalLight&&!j.shadowCascade&&o++}}var q=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)q=d.bones.length;var p;a:{j=a.fragmentShader;n=a.vertexShader;var i=
-a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,maxBones:q,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:k,maxPointLights:l,maxSpotLights:m,maxShadows:o,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,
-shadowMapCascade:this.shadowMapCascade,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:d&&d.doubleSided},r,d=[];if(h)d.push(h);else{d.push(j);d.push(n)}for(r in c){d.push(r);d.push(c[r])}h=d.join();r=0;for(d=W.length;r<d;r++){k=W[r];if(k.code===h){k.usedTimes++;p=k.program;break a}}r=g.createProgram();d=["precision "+E+" float;",ec>0?"#define VERTEX_TEXTURES":"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?
+THREE.MeshDepthMaterial?h="depth":a instanceof THREE.MeshNormalMaterial?h="normal":a instanceof THREE.MeshBasicMaterial?h="basic":a instanceof THREE.MeshLambertMaterial?h="lambert":a instanceof THREE.MeshPhongMaterial?h="phong":a instanceof THREE.LineBasicMaterial?h="basic":a instanceof THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var i=THREE.ShaderLib[h];a.uniforms=THREE.UniformsUtils.clone(i.uniforms);a.vertexShader=i.vertexShader;a.fragmentShader=i.fragmentShader}var j,k,l,m,o;j=m=o=
+i=0;for(k=b.length;j<k;j++){l=b[j];if(!l.onlyShadow){l instanceof THREE.DirectionalLight&&m++;l instanceof THREE.PointLight&&o++;l instanceof THREE.SpotLight&&i++}}if(o+i+m<=Z){k=m;l=o;m=i}else{k=Math.ceil(Z*m/(o+m));m=l=Z-k}var n=0,i=0;for(o=b.length;i<o;i++){j=b[i];if(j.castShadow){j instanceof THREE.SpotLight&&n++;j instanceof THREE.DirectionalLight&&!j.shadowCascade&&n++}}var r=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)r=d.bones.length;var p;a:{j=a.fragmentShader;o=a.vertexShader;var i=
+a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,maxBones:r,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:k,maxPointLights:l,maxSpotLights:m,maxShadows:n,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,
+shadowMapCascade:this.shadowMapCascade,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:d&&d.doubleSided},q,d=[];if(h)d.push(h);else{d.push(j);d.push(o)}for(q in c){d.push(q);d.push(c[q])}h=d.join();q=0;for(d=W.length;q<d;q++){k=W[q];if(k.code===h){k.usedTimes++;p=k.program;break a}}q=g.createProgram();d=["precision "+E+" float;",ec>0?"#define VERTEX_TEXTURES":"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?
 "#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?
 "#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
 k=["precision "+E+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":
 "",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
-j=B("fragment",k+j);d=B("vertex",d+n);g.attachShader(r,d);g.attachShader(r,j);g.linkProgram(r);g.getProgramParameter(r,g.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+g.getProgramParameter(r,g.VALIDATE_STATUS)+", gl error ["+g.getError()+"]");g.deleteShader(j);g.deleteShader(d);r.uniforms={};r.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(s in i)d.push(s);
-s=d;d=0;for(i=s.length;d<i;d++){n=s[d];r.uniforms[n]=g.getUniformLocation(r,n)}d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(s=0;s<c.maxMorphTargets;s++)d.push("morphTarget"+s);for(s=0;s<c.maxMorphNormals;s++)d.push("morphNormal"+s);for(p in b)d.push(p);p=d;s=0;for(b=p.length;s<b;s++){c=p[s];r.attributes[c]=g.getAttribLocation(r,c)}r.id=I++;W.push({program:r,code:h,usedTimes:1});F.info.memory.programs=W.length;p=r}a.program=p;p=a.program.attributes;
+j=B("fragment",k+j);d=B("vertex",d+o);g.attachShader(q,d);g.attachShader(q,j);g.linkProgram(q);g.getProgramParameter(q,g.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+g.getProgramParameter(q,g.VALIDATE_STATUS)+", gl error ["+g.getError()+"]");g.deleteShader(j);g.deleteShader(d);q.uniforms={};q.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(s in i)d.push(s);
+s=d;d=0;for(i=s.length;d<i;d++){o=s[d];q.uniforms[o]=g.getUniformLocation(q,o)}d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(s=0;s<c.maxMorphTargets;s++)d.push("morphTarget"+s);for(s=0;s<c.maxMorphNormals;s++)d.push("morphNormal"+s);for(p in b)d.push(p);p=d;s=0;for(b=p.length;s<b;s++){c=p[s];q.attributes[c]=g.getAttribLocation(q,c)}q.id=I++;W.push({program:q,code:h,usedTimes:1});F.info.memory.programs=W.length;p=q}a.program=p;p=a.program.attributes;
 p.position>=0&&g.enableVertexAttribArray(p.position);p.color>=0&&g.enableVertexAttribArray(p.color);p.normal>=0&&g.enableVertexAttribArray(p.normal);p.tangent>=0&&g.enableVertexAttribArray(p.tangent);if(a.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0){g.enableVertexAttribArray(p.skinVertexA);g.enableVertexAttribArray(p.skinVertexB);g.enableVertexAttribArray(p.skinIndex);g.enableVertexAttribArray(p.skinWeight)}if(a.attributes)for(f in a.attributes)p[f]!==void 0&&p[f]>=
 0&&g.enableVertexAttribArray(p[f]);if(a.morphTargets){a.numSupportedMorphTargets=0;b="morphTarget";for(f=0;f<this.maxMorphTargets;f++){s=b+f;if(p[s]>=0){g.enableVertexAttribArray(p[s]);a.numSupportedMorphTargets++}}}if(a.morphNormals){a.numSupportedMorphNormals=0;b="morphNormal";for(f=0;f<this.maxMorphNormals;f++){s=b+f;if(p[s]>=0){g.enableVertexAttribArray(p[s]);a.numSupportedMorphNormals++}}}a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a,
 b){if(a){!b||b==="ccw"?g.frontFace(g.CCW):g.frontFace(g.CW);a==="back"?g.cullFace(g.BACK):a==="front"?g.cullFace(g.FRONT):g.cullFace(g.FRONT_AND_BACK);g.enable(g.CULL_FACE)}else g.disable(g.CULL_FACE)};this.setObjectFaces=function(a){if(Ba!==a.doubleSided){a.doubleSided?g.disable(g.CULL_FACE):g.enable(g.CULL_FACE);Ba=a.doubleSided}if(Ha!==a.flipSided){a.flipSided?g.frontFace(g.CW):g.frontFace(g.CCW);Ha=a.flipSided}};this.setDepthTest=function(a){if(Xa!==a){a?g.enable(g.DEPTH_TEST):g.disable(g.DEPTH_TEST);
@@ -395,8 +396,8 @@ Xa=a}};this.setDepthWrite=function(a){if(nb!==a){g.depthMask(a);nb=a}};this.setB
 g.SRC_COLOR);break;case THREE.CustomBlending:g.enable(g.BLEND);break;default:g.enable(g.BLEND);g.blendEquationSeparate(g.FUNC_ADD,g.FUNC_ADD);g.blendFuncSeparate(g.SRC_ALPHA,g.ONE_MINUS_SRC_ALPHA,g.ONE,g.ONE_MINUS_SRC_ALPHA)}Ia=a}if(a===THREE.CustomBlending){if(b!==Sa){g.blendEquation(D(b));Sa=b}if(c!==Ua||d!==Na){g.blendFunc(D(c),D(d));Ua=c;Na=d}}else Na=Ua=Sa=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit){a.__webglInit=true;a.__webglTexture=g.createTexture();F.info.memory.textures++}g.activeTexture(g.TEXTURE0+
 b);g.bindTexture(g.TEXTURE_2D,a.__webglTexture);g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);var c=a.image,d=(c.width&c.width-1)===0&&(c.height&c.height-1)===0,e=D(a.format),f=D(a.type);A(g.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?g.texImage2D(g.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):g.texImage2D(g.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&g.generateMipmap(g.TEXTURE_2D);a.needsUpdate=false;if(a.onUpdate)a.onUpdate()}else{g.activeTexture(g.TEXTURE0+b);g.bindTexture(g.TEXTURE_2D,
 a.__webglTexture)}};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=true;if(a.stencilBuffer===void 0)a.stencilBuffer=true;a.__webglTexture=g.createTexture();var c=(a.width&a.width-1)===0&&(a.height&a.height-1)===0,d=D(a.format),e=D(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];g.bindTexture(g.TEXTURE_CUBE_MAP,a.__webglTexture);A(g.TEXTURE_CUBE_MAP,a,c);for(var f=0;f<6;f++){a.__webglFramebuffer[f]=
-g.createFramebuffer();a.__webglRenderbuffer[f]=g.createRenderbuffer();g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var h=a,i=g.TEXTURE_CUBE_MAP_POSITIVE_X+f;g.bindFramebuffer(g.FRAMEBUFFER,a.__webglFramebuffer[f]);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,i,h.__webglTexture,0);u(a.__webglRenderbuffer[f],a)}c&&g.generateMipmap(g.TEXTURE_CUBE_MAP)}else{a.__webglFramebuffer=g.createFramebuffer();a.__webglRenderbuffer=g.createRenderbuffer();g.bindTexture(g.TEXTURE_2D,
-a.__webglTexture);A(g.TEXTURE_2D,a,c);g.texImage2D(g.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null);d=g.TEXTURE_2D;g.bindFramebuffer(g.FRAMEBUFFER,a.__webglFramebuffer);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,d,a.__webglTexture,0);u(a.__webglRenderbuffer,a);c&&g.generateMipmap(g.TEXTURE_2D)}b?g.bindTexture(g.TEXTURE_CUBE_MAP,null):g.bindTexture(g.TEXTURE_2D,null);g.bindRenderbuffer(g.RENDERBUFFER,null);g.bindFramebuffer(g.FRAMEBUFFER,null)}if(a){b=b?a.__webglFramebuffer[a.activeCubeFace]:
+g.createFramebuffer();a.__webglRenderbuffer[f]=g.createRenderbuffer();g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var h=a,i=g.TEXTURE_CUBE_MAP_POSITIVE_X+f;g.bindFramebuffer(g.FRAMEBUFFER,a.__webglFramebuffer[f]);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,i,h.__webglTexture,0);s(a.__webglRenderbuffer[f],a)}c&&g.generateMipmap(g.TEXTURE_CUBE_MAP)}else{a.__webglFramebuffer=g.createFramebuffer();a.__webglRenderbuffer=g.createRenderbuffer();g.bindTexture(g.TEXTURE_2D,
+a.__webglTexture);A(g.TEXTURE_2D,a,c);g.texImage2D(g.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null);d=g.TEXTURE_2D;g.bindFramebuffer(g.FRAMEBUFFER,a.__webglFramebuffer);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,d,a.__webglTexture,0);s(a.__webglRenderbuffer,a);c&&g.generateMipmap(g.TEXTURE_2D)}b?g.bindTexture(g.TEXTURE_CUBE_MAP,null):g.bindTexture(g.TEXTURE_2D,null);g.bindRenderbuffer(g.RENDERBUFFER,null);g.bindFramebuffer(g.FRAMEBUFFER,null)}if(a){b=b?a.__webglFramebuffer[a.activeCubeFace]:
 a.__webglFramebuffer;c=a.width;a=a.height;e=d=0}else{b=null;c=Jb;a=Kb;d=Ib;e=cc}if(b!==H){g.bindFramebuffer(g.FRAMEBUFFER,b);g.viewport(d,e,c,a);H=b}$b=c;ac=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
 THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==void 0?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==void 0?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==void 0?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==void 0?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=c.format!==void 0?c.format:THREE.RGBAFormat;this.type=c.type!==void 0?c.type:
 THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:true;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:true;this.generateMipmaps=true};
@@ -422,29 +423,29 @@ THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.creat
 0;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]=0;d[r++]=1;r=0;f[r++]=0;f[r++]=1;f[r++]=2;f[r++]=0;f[r++]=2;f[r++]=3;e=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,e);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);l=b.createTexture();m=b.createTexture();b.bindTexture(b.TEXTURE_2D,l);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,
 b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.bindTexture(b.TEXTURE_2D,m);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);
 b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);if(b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){k=false;i=a(THREE.ShaderFlares.lensFlare)}else{k=true;i=a(THREE.ShaderFlares.lensFlareVertexTexture)}o={};j={};o.vertex=b.getAttribLocation(i,"position");o.uv=b.getAttribLocation(i,"uv");j.renderType=b.getUniformLocation(i,"renderType");j.map=b.getUniformLocation(i,"map");j.occlusionMap=b.getUniformLocation(i,"occlusionMap");j.opacity=b.getUniformLocation(i,"opacity");j.color=b.getUniformLocation(i,
-"color");j.scale=b.getUniformLocation(i,"scale");j.rotation=b.getUniformLocation(i,"rotation");j.screenPosition=b.getUniformLocation(i,"screenPosition");w=false};this.render=function(a,d,f,p){var a=a.__webglFlares,s=a.length;if(s){var B=new THREE.Vector3,A=p/f,u=f*0.5,J=p*0.5,D=16/p,M=new THREE.Vector2(D*A,D),E=new THREE.Vector3(1,1,0),Q=new THREE.Vector2(1,1),G=j,D=o;b.useProgram(i);if(!w){b.enableVertexAttribArray(o.vertex);b.enableVertexAttribArray(o.uv);w=true}b.uniform1i(G.occlusionMap,0);b.uniform1i(G.map,
-1);b.bindBuffer(b.ARRAY_BUFFER,e);b.vertexAttribPointer(D.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(D.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(false);var R,T,S,y,L;for(R=0;R<s;R++){D=16/p;M.set(D*A,D);y=a[R];B.set(y.matrixWorld.elements[12],y.matrixWorld.elements[13],y.matrixWorld.elements[14]);d.matrixWorldInverse.multiplyVector3(B);d.projectionMatrix.multiplyVector3(B);E.copy(B);Q.x=E.x*u+u;Q.y=E.y*J+J;if(k||Q.x>0&&Q.x<f&&Q.y>0&&
+"color");j.scale=b.getUniformLocation(i,"scale");j.rotation=b.getUniformLocation(i,"rotation");j.screenPosition=b.getUniformLocation(i,"screenPosition");w=false};this.render=function(a,d,f,p){var a=a.__webglFlares,u=a.length;if(u){var B=new THREE.Vector3,A=p/f,s=f*0.5,J=p*0.5,D=16/p,M=new THREE.Vector2(D*A,D),E=new THREE.Vector3(1,1,0),Q=new THREE.Vector2(1,1),G=j,D=o;b.useProgram(i);if(!w){b.enableVertexAttribArray(o.vertex);b.enableVertexAttribArray(o.uv);w=true}b.uniform1i(G.occlusionMap,0);b.uniform1i(G.map,
+1);b.bindBuffer(b.ARRAY_BUFFER,e);b.vertexAttribPointer(D.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(D.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(false);var R,T,S,y,L;for(R=0;R<u;R++){D=16/p;M.set(D*A,D);y=a[R];B.set(y.matrixWorld.elements[12],y.matrixWorld.elements[13],y.matrixWorld.elements[14]);d.matrixWorldInverse.multiplyVector3(B);d.projectionMatrix.multiplyVector3(B);E.copy(B);Q.x=E.x*s+s;Q.y=E.y*J+J;if(k||Q.x>0&&Q.x<f&&Q.y>0&&
 Q.y<p){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,l);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,Q.x-8,Q.y-8,16,16,0);b.uniform1i(G.renderType,0);b.uniform2f(G.scale,M.x,M.y);b.uniform3f(G.screenPosition,E.x,E.y,E.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,m);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,Q.x-8,Q.y-8,16,16,0);b.uniform1i(G.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);
 b.bindTexture(b.TEXTURE_2D,l);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);y.positionScreen.copy(E);y.customUpdateCallback?y.customUpdateCallback(y):y.updateLensFlares();b.uniform1i(G.renderType,2);b.enable(b.BLEND);T=0;for(S=y.lensFlares.length;T<S;T++){L=y.lensFlares[T];if(L.opacity>0.0010&&L.scale>0.0010){E.x=L.x;E.y=L.y;E.z=L.z;D=L.size*L.scale/p;M.x=D*A;M.y=D;b.uniform3f(G.screenPosition,E.x,E.y,E.z);b.uniform2f(G.scale,M.x,M.y);b.uniform1f(G.rotation,L.rotation);b.uniform1f(G.opacity,L.opacity);
 b.uniform3f(G.color,L.color.r,L.color.g,L.color.b);c.setBlending(L.blending,L.blendEquation,L.blendSrc,L.blendDst);c.setTexture(L.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}};
 THREE.ShadowMapPlugin=function(){var a,b,c,d,f=new THREE.Frustum,e=new THREE.Matrix4,h=new THREE.Vector3,l=new THREE.Vector3;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:true});c._shadowPass=true;d._shadowPass=true};this.render=
-function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(m,k){var i,o,j,w,r,n,q,p,s,B=[];w=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);b.shadowMapCullFrontFaces?a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);i=0;for(o=m.__lights.length;i<o;i++){j=m.__lights[i];if(j.castShadow)if(j instanceof THREE.DirectionalLight&&j.shadowCascade)for(r=0;r<j.shadowCascadeCount;r++){var A;if(j.shadowCascadeArray[r])A=j.shadowCascadeArray[r];
-else{s=j;q=r;A=new THREE.DirectionalLight;A.isVirtual=true;A.onlyShadow=true;A.castShadow=true;A.shadowCameraNear=s.shadowCameraNear;A.shadowCameraFar=s.shadowCameraFar;A.shadowCameraLeft=s.shadowCameraLeft;A.shadowCameraRight=s.shadowCameraRight;A.shadowCameraBottom=s.shadowCameraBottom;A.shadowCameraTop=s.shadowCameraTop;A.shadowCameraVisible=s.shadowCameraVisible;A.shadowDarkness=s.shadowDarkness;A.shadowBias=s.shadowCascadeBias[q];A.shadowMapWidth=s.shadowCascadeWidth[q];A.shadowMapHeight=s.shadowCascadeHeight[q];
-A.pointsWorld=[];A.pointsFrustum=[];p=A.pointsWorld;n=A.pointsFrustum;for(var u=0;u<8;u++){p[u]=new THREE.Vector3;n[u]=new THREE.Vector3}p=s.shadowCascadeNearZ[q];s=s.shadowCascadeFarZ[q];n[0].set(-1,-1,p);n[1].set(1,-1,p);n[2].set(-1,1,p);n[3].set(1,1,p);n[4].set(-1,-1,s);n[5].set(1,-1,s);n[6].set(-1,1,s);n[7].set(1,1,s);A.originalCamera=k;n=new THREE.Gyroscope;n.position=j.shadowCascadeOffset;n.add(A);n.add(A.target);k.add(n);j.shadowCascadeArray[r]=A;console.log("Created virtualLight",A)}q=j;p=
-r;s=q.shadowCascadeArray[p];s.position.copy(q.position);s.target.position.copy(q.target.position);s.lookAt(s.target);s.shadowCameraVisible=q.shadowCameraVisible;s.shadowDarkness=q.shadowDarkness;s.shadowBias=q.shadowCascadeBias[p];n=q.shadowCascadeNearZ[p];q=q.shadowCascadeFarZ[p];s=s.pointsFrustum;s[0].z=n;s[1].z=n;s[2].z=n;s[3].z=n;s[4].z=q;s[5].z=q;s[6].z=q;s[7].z=q;B[w]=A;w++}else{B[w]=j;w++}}i=0;for(o=B.length;i<o;i++){j=B[i];if(!j.shadowMap){j.shadowMap=new THREE.WebGLRenderTarget(j.shadowMapWidth,
+function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(m,k){var i,o,j,w,r,n,q,p,u,B=[];w=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);b.shadowMapCullFrontFaces?a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);i=0;for(o=m.__lights.length;i<o;i++){j=m.__lights[i];if(j.castShadow)if(j instanceof THREE.DirectionalLight&&j.shadowCascade)for(r=0;r<j.shadowCascadeCount;r++){var A;if(j.shadowCascadeArray[r])A=j.shadowCascadeArray[r];
+else{u=j;q=r;A=new THREE.DirectionalLight;A.isVirtual=true;A.onlyShadow=true;A.castShadow=true;A.shadowCameraNear=u.shadowCameraNear;A.shadowCameraFar=u.shadowCameraFar;A.shadowCameraLeft=u.shadowCameraLeft;A.shadowCameraRight=u.shadowCameraRight;A.shadowCameraBottom=u.shadowCameraBottom;A.shadowCameraTop=u.shadowCameraTop;A.shadowCameraVisible=u.shadowCameraVisible;A.shadowDarkness=u.shadowDarkness;A.shadowBias=u.shadowCascadeBias[q];A.shadowMapWidth=u.shadowCascadeWidth[q];A.shadowMapHeight=u.shadowCascadeHeight[q];
+A.pointsWorld=[];A.pointsFrustum=[];p=A.pointsWorld;n=A.pointsFrustum;for(var s=0;s<8;s++){p[s]=new THREE.Vector3;n[s]=new THREE.Vector3}p=u.shadowCascadeNearZ[q];u=u.shadowCascadeFarZ[q];n[0].set(-1,-1,p);n[1].set(1,-1,p);n[2].set(-1,1,p);n[3].set(1,1,p);n[4].set(-1,-1,u);n[5].set(1,-1,u);n[6].set(-1,1,u);n[7].set(1,1,u);A.originalCamera=k;n=new THREE.Gyroscope;n.position=j.shadowCascadeOffset;n.add(A);n.add(A.target);k.add(n);j.shadowCascadeArray[r]=A;console.log("Created virtualLight",A)}q=j;p=
+r;u=q.shadowCascadeArray[p];u.position.copy(q.position);u.target.position.copy(q.target.position);u.lookAt(u.target);u.shadowCameraVisible=q.shadowCameraVisible;u.shadowDarkness=q.shadowDarkness;u.shadowBias=q.shadowCascadeBias[p];n=q.shadowCascadeNearZ[p];q=q.shadowCascadeFarZ[p];u=u.pointsFrustum;u[0].z=n;u[1].z=n;u[2].z=n;u[3].z=n;u[4].z=q;u[5].z=q;u[6].z=q;u[7].z=q;B[w]=A;w++}else{B[w]=j;w++}}i=0;for(o=B.length;i<o;i++){j=B[i];if(!j.shadowMap){j.shadowMap=new THREE.WebGLRenderTarget(j.shadowMapWidth,
 j.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat});j.shadowMapSize=new THREE.Vector2(j.shadowMapWidth,j.shadowMapHeight);j.shadowMatrix=new THREE.Matrix4}if(!j.shadowCamera){if(j instanceof THREE.SpotLight)j.shadowCamera=new THREE.PerspectiveCamera(j.shadowCameraFov,j.shadowMapWidth/j.shadowMapHeight,j.shadowCameraNear,j.shadowCameraFar);else if(j instanceof THREE.DirectionalLight)j.shadowCamera=new THREE.OrthographicCamera(j.shadowCameraLeft,j.shadowCameraRight,
-j.shadowCameraTop,j.shadowCameraBottom,j.shadowCameraNear,j.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}m.add(j.shadowCamera);b.autoUpdateScene&&m.updateMatrixWorld()}if(j.shadowCameraVisible&&!j.cameraHelper){j.cameraHelper=new THREE.CameraHelper(j.shadowCamera);j.shadowCamera.add(j.cameraHelper)}if(j.isVirtual&&A.originalCamera==k){r=k;w=j.shadowCamera;n=j.pointsFrustum;s=j.pointsWorld;h.set(Infinity,Infinity,Infinity);l.set(-Infinity,-Infinity,-Infinity);for(q=
-0;q<8;q++){p=s[q];p.copy(n[q]);THREE.ShadowMapPlugin.__projector.unprojectVector(p,r);w.matrixWorldInverse.multiplyVector3(p);if(p.x<h.x)h.x=p.x;if(p.x>l.x)l.x=p.x;if(p.y<h.y)h.y=p.y;if(p.y>l.y)l.y=p.y;if(p.z<h.z)h.z=p.z;if(p.z>l.z)l.z=p.z}w.left=h.x;w.right=l.x;w.top=l.y;w.bottom=h.y;w.updateProjectionMatrix()}w=j.shadowMap;n=j.shadowMatrix;r=j.shadowCamera;r.position.copy(j.matrixWorld.getPosition());r.lookAt(j.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld);
+j.shadowCameraTop,j.shadowCameraBottom,j.shadowCameraNear,j.shadowCameraFar);else{console.error("Unsupported light type for shadow");continue}m.add(j.shadowCamera);b.autoUpdateScene&&m.updateMatrixWorld()}if(j.shadowCameraVisible&&!j.cameraHelper){j.cameraHelper=new THREE.CameraHelper(j.shadowCamera);j.shadowCamera.add(j.cameraHelper)}if(j.isVirtual&&A.originalCamera==k){r=k;w=j.shadowCamera;n=j.pointsFrustum;u=j.pointsWorld;h.set(Infinity,Infinity,Infinity);l.set(-Infinity,-Infinity,-Infinity);for(q=
+0;q<8;q++){p=u[q];p.copy(n[q]);THREE.ShadowMapPlugin.__projector.unprojectVector(p,r);w.matrixWorldInverse.multiplyVector3(p);if(p.x<h.x)h.x=p.x;if(p.x>l.x)l.x=p.x;if(p.y<h.y)h.y=p.y;if(p.y>l.y)l.y=p.y;if(p.z<h.z)h.z=p.z;if(p.z>l.z)l.z=p.z}w.left=h.x;w.right=l.x;w.top=l.y;w.bottom=h.y;w.updateProjectionMatrix()}w=j.shadowMap;n=j.shadowMatrix;r=j.shadowCamera;r.position.copy(j.matrixWorld.getPosition());r.lookAt(j.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld);
 if(j.cameraHelper)j.cameraHelper.lines.visible=j.shadowCameraVisible;j.shadowCameraVisible&&j.cameraHelper.update();n.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);n.multiplySelf(r.projectionMatrix);n.multiplySelf(r.matrixWorldInverse);if(!r._viewMatrixArray)r._viewMatrixArray=new Float32Array(16);if(!r._projectionMatrixArray)r._projectionMatrixArray=new Float32Array(16);r.matrixWorldInverse.flattenToArray(r._viewMatrixArray);r.projectionMatrix.flattenToArray(r._projectionMatrixArray);e.multiply(r.projectionMatrix,
-r.matrixWorldInverse);f.setFromMatrix(e);b.setRenderTarget(w);b.clear();s=m.__webglObjects;j=0;for(w=s.length;j<w;j++){q=s[j];n=q.object;q.render=false;if(n.visible&&n.castShadow&&(!(n instanceof THREE.Mesh)||!n.frustumCulled||f.contains(n))){n._modelViewMatrix.multiply(r.matrixWorldInverse,n.matrixWorld);q.render=true}}j=0;for(w=s.length;j<w;j++){q=s[j];if(q.render){n=q.object;q=q.buffer;p=n.customDepthMaterial?n.customDepthMaterial:n.geometry.morphTargets.length?d:c;q instanceof THREE.BufferGeometry?
-b.renderBufferDirect(r,m.__lights,null,p,q,n):b.renderBuffer(r,m.__lights,null,p,q,n)}}s=m.__webglObjectsImmediate;j=0;for(w=s.length;j<w;j++){q=s[j];n=q.object;if(n.visible&&n.castShadow){n._modelViewMatrix.multiply(r.matrixWorldInverse,n.matrixWorld);b.renderImmediateObject(r,m.__lights,null,c,n)}}}i=b.getClearColor();o=b.getClearAlpha();a.clearColor(i.r,i.g,i.b,o);a.enable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
+r.matrixWorldInverse);f.setFromMatrix(e);b.setRenderTarget(w);b.clear();u=m.__webglObjects;j=0;for(w=u.length;j<w;j++){q=u[j];n=q.object;q.render=false;if(n.visible&&n.castShadow&&(!(n instanceof THREE.Mesh)||!n.frustumCulled||f.contains(n))){n._modelViewMatrix.multiply(r.matrixWorldInverse,n.matrixWorld);q.render=true}}j=0;for(w=u.length;j<w;j++){q=u[j];if(q.render){n=q.object;q=q.buffer;p=n.customDepthMaterial?n.customDepthMaterial:n.geometry.morphTargets.length?d:c;q instanceof THREE.BufferGeometry?
+b.renderBufferDirect(r,m.__lights,null,p,q,n):b.renderBuffer(r,m.__lights,null,p,q,n)}}u=m.__webglObjectsImmediate;j=0;for(w=u.length;j<w;j++){q=u[j];n=q.object;if(n.visible&&n.castShadow){n._modelViewMatrix.multiply(r.matrixWorldInverse,n.matrixWorld);b.renderImmediateObject(r,m.__lights,null,c,n)}}}i=b.getClearColor();o=b.getClearAlpha();a.clearColor(i.r,i.g,i.b,o);a.enable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
 THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,f,e,h,l,m,k,i;this.init=function(a){b=a.context;c=a;d=new Float32Array(16);f=new Uint16Array(6);a=0;d[a++]=-1;d[a++]=-1;d[a++]=0;d[a++]=1;d[a++]=1;d[a++]=-1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=0;d[a++]=-1;d[a++]=1;d[a++]=0;a=d[a++]=0;f[a++]=0;f[a++]=1;f[a++]=2;f[a++]=0;f[a++]=2;f[a++]=3;e=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,e);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
 h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,j=b.createProgram(),w=b.createShader(b.FRAGMENT_SHADER),r=b.createShader(b.VERTEX_SHADER);b.shaderSource(w,a.fragmentShader);b.shaderSource(r,a.vertexShader);b.compileShader(w);b.compileShader(r);b.attachShader(j,w);b.attachShader(j,r);b.linkProgram(j);l=j;m={};k={};m.position=b.getAttribLocation(l,"position");m.uv=b.getAttribLocation(l,"uv");k.uvOffset=b.getUniformLocation(l,"uvOffset");k.uvScale=b.getUniformLocation(l,
 "uvScale");k.rotation=b.getUniformLocation(l,"rotation");k.scale=b.getUniformLocation(l,"scale");k.alignment=b.getUniformLocation(l,"alignment");k.color=b.getUniformLocation(l,"color");k.map=b.getUniformLocation(l,"map");k.opacity=b.getUniformLocation(l,"opacity");k.useScreenCoordinates=b.getUniformLocation(l,"useScreenCoordinates");k.affectedByDistance=b.getUniformLocation(l,"affectedByDistance");k.screenPosition=b.getUniformLocation(l,"screenPosition");k.modelViewMatrix=b.getUniformLocation(l,"modelViewMatrix");
-k.projectionMatrix=b.getUniformLocation(l,"projectionMatrix");i=false};this.render=function(d,f,w,r){var d=d.__webglSprites,n=d.length;if(n){var q=m,p=k,s=r/w,w=w*0.5,B=r*0.5,A=true;b.useProgram(l);if(!i){b.enableVertexAttribArray(q.position);b.enableVertexAttribArray(q.uv);i=true}b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(true);b.bindBuffer(b.ARRAY_BUFFER,e);b.vertexAttribPointer(q.position,2,b.FLOAT,false,16,0);b.vertexAttribPointer(q.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
-h);b.uniformMatrix4fv(p.projectionMatrix,false,f._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(p.map,0);for(var u,J=[],q=0;q<n;q++){u=d[q];if(u.visible&&u.opacity!==0)if(u.useScreenCoordinates)u.z=-u.position.z;else{u._modelViewMatrix.multiply(f.matrixWorldInverse,u.matrixWorld);u.z=-u._modelViewMatrix.elements[14]}}d.sort(a);for(q=0;q<n;q++){u=d[q];if(u.visible&&u.opacity!==0&&u.map&&u.map.image&&u.map.image.width){if(u.useScreenCoordinates){b.uniform1i(p.useScreenCoordinates,1);
-b.uniform3f(p.screenPosition,(u.position.x-w)/w,(B-u.position.y)/B,Math.max(0,Math.min(1,u.position.z)))}else{b.uniform1i(p.useScreenCoordinates,0);b.uniform1i(p.affectedByDistance,u.affectedByDistance?1:0);b.uniformMatrix4fv(p.modelViewMatrix,false,u._modelViewMatrix.elements)}f=u.map.image.width/(u.scaleByViewport?r:1);J[0]=f*s*u.scale.x;J[1]=f*u.scale.y;b.uniform2f(p.uvScale,u.uvScale.x,u.uvScale.y);b.uniform2f(p.uvOffset,u.uvOffset.x,u.uvOffset.y);b.uniform2f(p.alignment,u.alignment.x,u.alignment.y);
-b.uniform1f(p.opacity,u.opacity);b.uniform3f(p.color,u.color.r,u.color.g,u.color.b);b.uniform1f(p.rotation,u.rotation);b.uniform2fv(p.scale,J);if(u.mergeWith3D&&!A){b.enable(b.DEPTH_TEST);A=true}else if(!u.mergeWith3D&&A){b.disable(b.DEPTH_TEST);A=false}c.setBlending(u.blending,u.blendEquation,u.blendSrc,u.blendDst);c.setTexture(u.map,0);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}};
+k.projectionMatrix=b.getUniformLocation(l,"projectionMatrix");i=false};this.render=function(d,f,w,r){var d=d.__webglSprites,n=d.length;if(n){var q=m,p=k,u=r/w,w=w*0.5,B=r*0.5,A=true;b.useProgram(l);if(!i){b.enableVertexAttribArray(q.position);b.enableVertexAttribArray(q.uv);i=true}b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(true);b.bindBuffer(b.ARRAY_BUFFER,e);b.vertexAttribPointer(q.position,2,b.FLOAT,false,16,0);b.vertexAttribPointer(q.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
+h);b.uniformMatrix4fv(p.projectionMatrix,false,f._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(p.map,0);for(var s,J=[],q=0;q<n;q++){s=d[q];if(s.visible&&s.opacity!==0)if(s.useScreenCoordinates)s.z=-s.position.z;else{s._modelViewMatrix.multiply(f.matrixWorldInverse,s.matrixWorld);s.z=-s._modelViewMatrix.elements[14]}}d.sort(a);for(q=0;q<n;q++){s=d[q];if(s.visible&&s.opacity!==0&&s.map&&s.map.image&&s.map.image.width){if(s.useScreenCoordinates){b.uniform1i(p.useScreenCoordinates,1);
+b.uniform3f(p.screenPosition,(s.position.x-w)/w,(B-s.position.y)/B,Math.max(0,Math.min(1,s.position.z)))}else{b.uniform1i(p.useScreenCoordinates,0);b.uniform1i(p.affectedByDistance,s.affectedByDistance?1:0);b.uniformMatrix4fv(p.modelViewMatrix,false,s._modelViewMatrix.elements)}f=s.map.image.width/(s.scaleByViewport?r:1);J[0]=f*u*s.scale.x;J[1]=f*s.scale.y;b.uniform2f(p.uvScale,s.uvScale.x,s.uvScale.y);b.uniform2f(p.uvOffset,s.uvOffset.x,s.uvOffset.y);b.uniform2f(p.alignment,s.alignment.x,s.alignment.y);
+b.uniform1f(p.opacity,s.opacity);b.uniform3f(p.color,s.color.r,s.color.g,s.color.b);b.uniform1f(p.rotation,s.rotation);b.uniform2fv(p.scale,J);if(s.mergeWith3D&&!A){b.enable(b.DEPTH_TEST);A=true}else if(!s.mergeWith3D&&A){b.disable(b.DEPTH_TEST);A=false}c.setBlending(s.blending,s.blendEquation,s.blendSrc,s.blendDst);c.setTexture(s.map,0);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}};
 THREE.ShaderFlares={lensFlareVertexTexture:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = (       visibility.r / 9.0 ) *\n( 1.0 - visibility.g / 9.0 ) *\n(       visibility.b / 9.0 ) *\n( 1.0 - visibility.a / 9.0 );\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},
 lensFlare:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * visibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"}};
 THREE.ShaderSprite={sprite:{vertexShader:"uniform int useScreenCoordinates;\nuniform int affectedByDistance;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position + alignment;\nvec2 rotatedPosition;\nrotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;\nrotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;\nvec4 finalPosition;\nif( useScreenCoordinates != 0 ) {\nfinalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );\n} else {\nfinalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition * ( affectedByDistance == 1 ? 1.0 : finalPosition.z );\n}\ngl_Position = finalPosition;\n}",