Browse Source

Fixed bug in GeometryUtils.triangulateQuads.

Can't clone quad to get triangle, what was I thinking.
alteredq 13 years ago
parent
commit
70ee0cf598
3 changed files with 94 additions and 73 deletions
  1. 64 63
      build/Three.js
  2. 9 8
      build/custom/ThreeExtras.js
  3. 21 2
      src/extras/GeometryUtils.js

+ 64 - 63
build/Three.js

@@ -171,8 +171,8 @@ p,m,o,q,n=k.getContext("2d"),r=new THREE.Color(0),s=0,t=1,w=0,u=null,v=null,z=nu
 document.createElement("canvas");fa.width=fa.height=2;Fb=fa.getContext("2d");Fb.fillStyle="rgba(0,0,0,1)";Fb.fillRect(0,0,2,2);Tc=Fb.getImageData(0,0,2,2);fb=Tc.data;pc=document.createElement("canvas");pc.width=pc.height=a;Cc=pc.getContext("2d");Cc.translate(-a/2,-a/2);Cc.scale(a,a);a--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){p=a;m=b;o=Math.floor(p/2);q=Math.floor(m/2);k.width=p;k.height=m;Ga.set(-o,
 -q,o,q);ra.set(-o,-q,o,q);t=1;w=0;D=G=z=v=u=null};this.setClearColor=function(a,b){r.copy(a);s=b;ra.set(-o,-q,o,q)};this.setClearColorHex=function(a,b){r.setHex(a);s=b;ra.set(-o,-q,o,q)};this.clear=function(){n.setTransform(1,0,0,-1,o,q);ra.isEmpty()||(ra.minSelf(Ga),ra.inflate(2),1>s&&n.clearRect(Math.floor(ra.getX()),Math.floor(ra.getY()),Math.floor(ra.getWidth()),Math.floor(ra.getHeight())),0<s&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(255*r.r)+","+Math.floor(255*r.g)+","+Math.floor(255*
 r.b)+","+s+")"),n.fillRect(Math.floor(ra.getX()),Math.floor(ra.getY()),Math.floor(ra.getWidth()),Math.floor(ra.getHeight()))),ra.empty())};this.render=function(a,k){function m(a){var b,c,d,e;sa.setRGB(0,0,0);Wa.setRGB(0,0,0);mb.setRGB(0,0,0);for(b=0,c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(sa.r+=e.r,sa.g+=e.g,sa.b+=e.b):d instanceof THREE.DirectionalLight?(Wa.r+=e.r,Wa.g+=e.g,Wa.b+=e.b):d instanceof THREE.PointLight&&(mb.r+=e.r,mb.g+=e.g,mb.b+=e.b)}function p(a,b,c,d){var e,
-g,f,h,i,l;for(e=0,g=a.length;e<g;e++)f=a[e],h=f.color,f instanceof THREE.DirectionalLight?(i=f.matrixWorld.getPosition(),l=c.dot(i),0>=l||(l*=f.intensity,d.r+=h.r*l,d.g+=h.g*l,d.b+=h.b*l)):f instanceof THREE.PointLight&&(i=f.matrixWorld.getPosition(),l=c.dot(ba.sub(i,b).normalize()),0>=l||(l*=0==f.distance?1:1-Math.min(b.distanceTo(i)/f.distance,1),0!=l&&(l*=f.intensity,d.r+=h.r*l,d.g+=h.g*l,d.b+=h.b*l)))}function r(a,g,f){b(f.opacity);c(f.blending);var h,ba,l,i,fa,j;if(f instanceof THREE.ParticleBasicMaterial){if(f.map)i=
-f.map.image,fa=i.width>>1,j=i.height>>1,f=g.scale.x*o,l=g.scale.y*q,h=f*fa,ba=l*j,Ba.set(a.x-h,a.y-ba,a.x+h,a.y+ba),Ga.intersects(Ba)&&(n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(f,-l),n.translate(-fa,-j),n.drawImage(i,0,0),n.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(h=g.scale.x*o,ba=g.scale.y*q,Ba.set(a.x-h,a.y-ba,a.x+h,a.y+ba),Ga.intersects(Ba)&&(d(f.color.getContextStyle()),e(f.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(h,
+g,f,h,i,l;for(e=0,g=a.length;e<g;e++)f=a[e],h=f.color,f instanceof THREE.DirectionalLight?(i=f.matrixWorld.getPosition(),l=c.dot(i),0>=l||(l*=f.intensity,d.r+=h.r*l,d.g+=h.g*l,d.b+=h.b*l)):f instanceof THREE.PointLight&&(i=f.matrixWorld.getPosition(),l=c.dot(ba.sub(i,b).normalize()),0>=l||(l*=0==f.distance?1:1-Math.min(b.distanceTo(i)/f.distance,1),0!=l&&(l*=f.intensity,d.r+=h.r*l,d.g+=h.g*l,d.b+=h.b*l)))}function r(a,g,f){b(f.opacity);c(f.blending);var h,ba,i,l,fa,j;if(f instanceof THREE.ParticleBasicMaterial){if(f.map)l=
+f.map.image,fa=l.width>>1,j=l.height>>1,f=g.scale.x*o,i=g.scale.y*q,h=f*fa,ba=i*j,Ba.set(a.x-h,a.y-ba,a.x+h,a.y+ba),Ga.intersects(Ba)&&(n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(f,-i),n.translate(-fa,-j),n.drawImage(l,0,0),n.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(h=g.scale.x*o,ba=g.scale.y*q,Ba.set(a.x-h,a.y-ba,a.x+h,a.y+ba),Ga.intersects(Ba)&&(d(f.color.getContextStyle()),e(f.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(h,
 ba),f.program(n),n.restore()))}function s(a,e,g,f){b(f.opacity);c(f.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(z!=a)n.lineWidth=z=a;a=f.linecap;if(G!=a)n.lineCap=G=a;a=f.linejoin;if(D!=a)n.lineJoin=D=a;d(f.color.getContextStyle());n.stroke();Ba.inflate(2*f.linewidth)}}function t(a,d,e,f,h,fa,j,m){g.info.render.vertices+=3;g.info.render.faces++;b(m.opacity);
 c(m.blending);B=a.positionScreen.x;N=a.positionScreen.y;E=d.positionScreen.x;l=d.positionScreen.y;Y=e.positionScreen.x;F=e.positionScreen.y;v(B,N,E,l,Y,F);if(m instanceof THREE.MeshBasicMaterial)if(m.map)m.map.mapping instanceof THREE.UVMapping&&(ka=j.uvs[0],Uc(B,N,E,l,Y,F,ka[f].u,ka[f].v,ka[h].u,ka[h].v,ka[fa].u,ka[fa].v,m.map));else if(m.envMap){if(m.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,ba.copy(j.vertexNormalsWorld[f]),bb=0.5*(ba.x*a.n11+ba.y*a.n12+ba.z*
 a.n13)+0.5,jb=0.5*-(ba.x*a.n21+ba.y*a.n22+ba.z*a.n23)+0.5,ba.copy(j.vertexNormalsWorld[h]),Va=0.5*(ba.x*a.n11+ba.y*a.n12+ba.z*a.n13)+0.5,cb=0.5*-(ba.x*a.n21+ba.y*a.n22+ba.z*a.n23)+0.5,ba.copy(j.vertexNormalsWorld[fa]),eb=0.5*(ba.x*a.n11+ba.y*a.n12+ba.z*a.n13)+0.5,db=0.5*-(ba.x*a.n21+ba.y*a.n22+ba.z*a.n23)+0.5,Uc(B,N,E,l,Y,F,bb,jb,Va,cb,eb,db,m.envMap)}else m.wireframe?Mb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(m.color);else if(m instanceof THREE.MeshLambertMaterial)m.map&&
@@ -185,11 +185,11 @@ N=a.positionScreen.y,E=d.positionScreen.x,l=d.positionScreen.y,Y=e.positionScree
 Math.min(j.color.b*T.b,1)),aa.r=Math.max(0,Math.min(j.color.r*aa.r,1)),aa.g=Math.max(0,Math.min(j.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(j.color.b*aa.b,1)),da.r=Math.max(0,Math.min(j.color.r*da.r,1)),da.g=Math.max(0,Math.min(j.color.g*da.g,1)),da.b=Math.max(0,Math.min(j.color.b*da.b,1)),Aa=Dc($,T,aa,da),v(B,N,E,l,y,S),gc(B,N,E,l,y,S,0,0,1,0,0,1,Aa),v(P,Z,Y,F,ja,ha),gc(P,Z,Y,F,ja,ha,1,0,1,1,0,1,Aa)):(R.r=sa.r,R.g=sa.g,R.b=sa.b,p(i,fa.centroidWorld,fa.normalWorld,R),R.r=Math.max(0,Math.min(j.color.r*
 R.r,1)),R.g=Math.max(0,Math.min(j.color.g*R.g,1)),R.b=Math.max(0,Math.min(j.color.b*R.b,1)),w(B,N,E,l,Y,F,y,S),j.wireframe?Mb(R,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Gb(R)):(w(B,N,E,l,Y,F,y,S),j.wireframe?Mb(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Gb(j.color));else if(j instanceof THREE.MeshNormalMaterial)R.r=hc(fa.normalWorld.x),R.g=hc(fa.normalWorld.y),R.b=hc(fa.normalWorld.z),w(B,N,E,l,Y,F,y,S),j.wireframe?Mb(R,j.wireframeLinewidth,j.wireframeLinecap,
 j.wireframeLinejoin):Gb(R);else if(j instanceof THREE.MeshDepthMaterial)oa=k.near,Fa=k.far,$.r=$.g=$.b=1-ac(a.positionScreen.z,oa,Fa),T.r=T.g=T.b=1-ac(d.positionScreen.z,oa,Fa),aa.r=aa.g=aa.b=1-ac(f.positionScreen.z,oa,Fa),da.r=da.g=da.b=1-ac(e.positionScreen.z,oa,Fa),Aa=Dc($,T,aa,da),v(B,N,E,l,y,S),gc(B,N,E,l,y,S,0,0,1,0,0,1,Aa),v(P,Z,Y,F,ja,ha),gc(P,Z,Y,F,ja,ha,1,0,1,1,0,1,Aa)}function v(a,b,c,d,e,f){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(a,b);n.closePath()}function w(a,
-b,c,d,e,f,g,h){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(g,h);n.lineTo(a,b);n.closePath()}function Mb(a,b,c,e){if(z!=b)n.lineWidth=z=b;if(G!=c)n.lineCap=G=c;if(D!=e)n.lineJoin=D=e;d(a.getContextStyle());n.stroke();Ba.inflate(2*b)}function Gb(a){e(a.getContextStyle());n.fill()}function Uc(a,b,c,d,f,g,h,ba,l,i,fa,j,m){if(0!=m.image.width){if(!0==m.needsUpdate||void 0==Ua[m.id]){var k=m.wrapS==THREE.RepeatWrapping,o=m.wrapT==THREE.RepeatWrapping;Ua[m.id]=n.createPattern(m.image,
-k&&o?"repeat":k&&!o?"repeat-x":!k&&o?"repeat-y":"no-repeat");m.needsUpdate=!1}e(Ua[m.id]);var k=m.offset.x/m.repeat.x,o=m.offset.y/m.repeat.y,Fb=m.image.width*m.repeat.x,p=m.image.height*m.repeat.y,h=(h+k)*Fb,ba=(ba+o)*p,c=c-a,d=d-b,f=f-a,g=g-b,l=(l+k)*Fb-h,i=(i+o)*p-ba,fa=(fa+k)*Fb-h,j=(j+o)*p-ba,k=l*j-fa*i;if(0==k){if(void 0===Ia[m.id])b=document.createElement("canvas"),b.width=m.image.width,b.height=m.image.height,b=b.getContext("2d"),b.drawImage(m.image,0,0),Ia[m.id]=b.getImageData(0,0,m.image.width,
-m.image.height).data;b=Ia[m.id];h=4*(Math.floor(h)+Math.floor(ba)*m.image.width);R.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);Gb(R)}else k=1/k,m=(j*c-i*f)*k,i=(j*d-i*g)*k,c=(l*f-fa*c)*k,d=(l*g-fa*d)*k,a=a-m*h-c*ba,h=b-i*h-d*ba,n.save(),n.transform(m,i,c,d,a,h),n.fill(),n.restore()}}function gc(a,b,c,d,e,f,g,h,ba,l,i,fa,j){var m,k;m=j.width-1;k=j.height-1;g*=m;h*=k;c-=a;d-=b;e-=a;f-=b;ba=ba*m-g;l=l*k-h;i=i*m-g;fa=fa*k-h;k=1/(ba*fa-i*l);m=(fa*c-l*e)*k;l=(fa*d-l*f)*k;c=(ba*e-i*c)*k;d=(ba*f-i*d)*k;a=a-m*
-g-c*h;b=b-l*g-d*h;n.save();n.transform(m,l,c,d,a,b);n.clip();n.drawImage(j,0,0);n.restore()}function Dc(a,b,c,d){var e=~~(255*a.r),f=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),h=~~(255*b.g),b=~~(255*b.b),ba=~~(255*c.r),l=~~(255*c.g),c=~~(255*c.b),i=~~(255*d.r),j=~~(255*d.g),d=~~(255*d.b);fb[0]=0>e?0:255<e?255:e;fb[1]=0>f?0:255<f?255:f;fb[2]=0>a?0:255<a?255:a;fb[4]=0>g?0:255<g?255:g;fb[5]=0>h?0:255<h?255:h;fb[6]=0>b?0:255<b?255:b;fb[8]=0>ba?0:255<ba?255:ba;fb[9]=0>l?0:255<l?255:l;fb[10]=0>c?0:255<c?255:
-c;fb[12]=0>i?0:255<i?255:i;fb[13]=0>j?0:255<j?255:j;fb[14]=0>d?0:255<d?255:d;Fb.putImageData(Tc,0,0);Cc.drawImage(fa,0,0);return pc}function ac(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function hc(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function Nb(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;0!=e&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Ec,ed,Pa,kb;this.autoClear?this.clear():n.setTransform(1,0,0,-1,o,q);g.info.render.vertices=0;g.info.render.faces=0;f=j.projectScene(a,k,this.sortElements);
+b,c,d,e,f,g,h){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(g,h);n.lineTo(a,b);n.closePath()}function Mb(a,b,c,e){if(z!=b)n.lineWidth=z=b;if(G!=c)n.lineCap=G=c;if(D!=e)n.lineJoin=D=e;d(a.getContextStyle());n.stroke();Ba.inflate(2*b)}function Gb(a){e(a.getContextStyle());n.fill()}function Uc(a,b,c,d,f,g,h,ba,i,l,fa,j,m){if(0!=m.image.width){if(!0==m.needsUpdate||void 0==Ua[m.id]){var k=m.wrapS==THREE.RepeatWrapping,o=m.wrapT==THREE.RepeatWrapping;Ua[m.id]=n.createPattern(m.image,
+k&&o?"repeat":k&&!o?"repeat-x":!k&&o?"repeat-y":"no-repeat");m.needsUpdate=!1}e(Ua[m.id]);var k=m.offset.x/m.repeat.x,o=m.offset.y/m.repeat.y,Fb=m.image.width*m.repeat.x,p=m.image.height*m.repeat.y,h=(h+k)*Fb,ba=(ba+o)*p,c=c-a,d=d-b,f=f-a,g=g-b,i=(i+k)*Fb-h,l=(l+o)*p-ba,fa=(fa+k)*Fb-h,j=(j+o)*p-ba,k=i*j-fa*l;if(0==k){if(void 0===Ia[m.id])b=document.createElement("canvas"),b.width=m.image.width,b.height=m.image.height,b=b.getContext("2d"),b.drawImage(m.image,0,0),Ia[m.id]=b.getImageData(0,0,m.image.width,
+m.image.height).data;b=Ia[m.id];h=4*(Math.floor(h)+Math.floor(ba)*m.image.width);R.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);Gb(R)}else k=1/k,m=(j*c-l*f)*k,l=(j*d-l*g)*k,c=(i*f-fa*c)*k,d=(i*g-fa*d)*k,a=a-m*h-c*ba,h=b-l*h-d*ba,n.save(),n.transform(m,l,c,d,a,h),n.fill(),n.restore()}}function gc(a,b,c,d,e,f,g,h,ba,i,l,fa,j){var m,k;m=j.width-1;k=j.height-1;g*=m;h*=k;c-=a;d-=b;e-=a;f-=b;ba=ba*m-g;i=i*k-h;l=l*m-g;fa=fa*k-h;k=1/(ba*fa-l*i);m=(fa*c-i*e)*k;i=(fa*d-i*f)*k;c=(ba*e-l*c)*k;d=(ba*f-l*d)*k;a=a-m*
+g-c*h;b=b-i*g-d*h;n.save();n.transform(m,i,c,d,a,b);n.clip();n.drawImage(j,0,0);n.restore()}function Dc(a,b,c,d){var e=~~(255*a.r),f=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),h=~~(255*b.g),b=~~(255*b.b),ba=~~(255*c.r),i=~~(255*c.g),c=~~(255*c.b),l=~~(255*d.r),j=~~(255*d.g),d=~~(255*d.b);fb[0]=0>e?0:255<e?255:e;fb[1]=0>f?0:255<f?255:f;fb[2]=0>a?0:255<a?255:a;fb[4]=0>g?0:255<g?255:g;fb[5]=0>h?0:255<h?255:h;fb[6]=0>b?0:255<b?255:b;fb[8]=0>ba?0:255<ba?255:ba;fb[9]=0>i?0:255<i?255:i;fb[10]=0>c?0:255<c?255:
+c;fb[12]=0>l?0:255<l?255:l;fb[13]=0>j?0:255<j?255:j;fb[14]=0>d?0:255<d?255:d;Fb.putImageData(Tc,0,0);Cc.drawImage(fa,0,0);return pc}function ac(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function hc(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function Nb(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;0!=e&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Ec,ed,Pa,kb;this.autoClear?this.clear():n.setTransform(1,0,0,-1,o,q);g.info.render.vertices=0;g.info.render.faces=0;f=j.projectScene(a,k,this.sortElements);
 h=f.elements;i=f.lights;(Oa=0<i.length)&&m(i);for(Ec=0,ed=h.length;Ec<ed;Ec++)if(Pa=h[Ec],kb=Pa.material,kb=kb instanceof THREE.MeshFaceMaterial?Pa.faceMaterial:kb,!(null==kb||0==kb.opacity)){Ba.empty();if(Pa instanceof THREE.RenderableParticle)C=Pa,C.x*=o,C.y*=q,r(C,Pa,kb,a);else if(Pa instanceof THREE.RenderableLine)C=Pa.v1,I=Pa.v2,C.positionScreen.x*=o,C.positionScreen.y*=q,I.positionScreen.x*=o,I.positionScreen.y*=q,Ba.addPoint(C.positionScreen.x,C.positionScreen.y),Ba.addPoint(I.positionScreen.x,
 I.positionScreen.y),Ga.intersects(Ba)&&s(C,I,Pa,kb,a);else if(Pa instanceof THREE.RenderableFace3)C=Pa.v1,I=Pa.v2,K=Pa.v3,C.positionScreen.x*=o,C.positionScreen.y*=q,I.positionScreen.x*=o,I.positionScreen.y*=q,K.positionScreen.x*=o,K.positionScreen.y*=q,kb.overdraw&&(Nb(C.positionScreen,I.positionScreen),Nb(I.positionScreen,K.positionScreen),Nb(K.positionScreen,C.positionScreen)),Ba.add3Points(C.positionScreen.x,C.positionScreen.y,I.positionScreen.x,I.positionScreen.y,K.positionScreen.x,K.positionScreen.y),
 Ga.intersects(Ba)&&t(C,I,K,0,1,2,Pa,kb,a);else if(Pa instanceof THREE.RenderableFace4)C=Pa.v1,I=Pa.v2,K=Pa.v3,O=Pa.v4,C.positionScreen.x*=o,C.positionScreen.y*=q,I.positionScreen.x*=o,I.positionScreen.y*=q,K.positionScreen.x*=o,K.positionScreen.y*=q,O.positionScreen.x*=o,O.positionScreen.y*=q,Q.positionScreen.copy(I.positionScreen),L.positionScreen.copy(O.positionScreen),kb.overdraw&&(Nb(C.positionScreen,I.positionScreen),Nb(I.positionScreen,O.positionScreen),Nb(O.positionScreen,C.positionScreen),
@@ -240,16 +240,16 @@ THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.
 THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",
 THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,
 "}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask  = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}};
-THREE.WebGLRenderer=function(a){function b(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(void 0===a.__webglCustomAttributesList)a.__webglCustomAttributesList=[];for(var e in d.attributes){var g=d.attributes[e];if(!g.__webglInitialized||g.createUniqueBuffers){g.__webglInitialized=!0;var f=1;"v2"===g.type?f=2:"v3"===g.type?f=3:"v4"===g.type?f=4:"c"===g.type&&(f=3);g.size=f;g.array=new Float32Array(c*f);g.buffer=l.createBuffer();g.buffer.belongsToAttribute=e;g.needsUpdate=!0}a.__webglCustomAttributesList.push(g)}}}
-function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;if(0<=b.materialIndex)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?!1:a&&void 0!==a.shading&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function e(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?!0:!1}function g(a,b,c){var d,e,g,f,h=a.vertices;f=h.length;
-var i=a.colors,j=i.length,m=a.__vertexArray,k=a.__colorArray,n=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,q=a.__webglCustomAttributesList;if(c.sortParticles){db.copy(eb);db.multiplySelf(c.matrixWorld);for(d=0;d<f;d++)e=h[d].position,Ga.copy(e),db.multiplyVector3(Ga),n[d]=[Ga.z,d];n.sort(function(a,b){return b[0]-a[0]});for(d=0;d<f;d++)e=h[n[d][1]].position,g=3*d,m[g]=e.x,m[g+1]=e.y,m[g+2]=e.z;for(d=0;d<j;d++)g=3*d,e=i[n[d][1]],k[g]=e.r,k[g+1]=e.g,k[g+2]=e.b;if(q)for(i=0,j=q.length;i<j;i++)if(h=
-q[i],void 0===h.boundTo||"vertices"===h.boundTo)if(g=0,e=h.value.length,1===h.size)for(d=0;d<e;d++)f=n[d][1],h.array[d]=h.value[f];else if(2===h.size)for(d=0;d<e;d++)f=n[d][1],f=h.value[f],h.array[g]=f.x,h.array[g+1]=f.y,g+=2;else if(3===h.size)if("c"===h.type)for(d=0;d<e;d++)f=n[d][1],f=h.value[f],h.array[g]=f.r,h.array[g+1]=f.g,h.array[g+2]=f.b,g+=3;else for(d=0;d<e;d++)f=n[d][1],f=h.value[f],h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,g+=3;else if(4===h.size)for(d=0;d<e;d++)f=n[d][1],f=h.value[f],
-h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,h.array[g+3]=f.w,g+=4}else{if(o)for(d=0;d<f;d++)e=h[d].position,g=3*d,m[g]=e.x,m[g+1]=e.y,m[g+2]=e.z;if(p)for(d=0;d<j;d++)e=i[d],g=3*d,k[g]=e.r,k[g+1]=e.g,k[g+2]=e.b;if(q)for(i=0,j=q.length;i<j;i++)if(h=q[i],h.needsUpdate&&(void 0===h.boundTo||"vertices"===h.boundTo))if(e=h.value.length,g=0,1===h.size)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(2===h.size)for(d=0;d<e;d++)f=h.value[d],h.array[g]=f.x,h.array[g+1]=f.y,g+=2;else if(3===h.size)if("c"===
-h.type)for(d=0;d<e;d++)f=h.value[d],h.array[g]=f.r,h.array[g+1]=f.g,h.array[g+2]=f.b,g+=3;else for(d=0;d<e;d++)f=h.value[d],h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,g+=3;else if(4===h.size)for(d=0;d<e;d++)f=h.value[d],h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,h.array[g+3]=f.w,g+=4}if(o||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,a.__webglVertexBuffer),l.bufferData(l.ARRAY_BUFFER,m,b);if(p||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,a.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,
-k,b);if(q)for(i=0,j=q.length;i<j;i++)if(h=q[i],h.needsUpdate||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,h.buffer),l.bufferData(l.ARRAY_BUFFER,h.array,b)}function f(a,b){return b.z-a.z}function h(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++)Z=F=null,S=P=aa=T=$=-1,a[d].render(b,c,jb,Va),Z=F=null,S=P=aa=T=$=-1}function i(a,b,c,d,e,g,f,h){var i,j,l,m;b?(j=a.length-1,m=b=-1):(j=0,b=a.length,m=1);for(var k=j;k!==b;k+=m)if(i=a[k],i.render){j=i.object;l=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;
-f&&E.setBlending(i.blending);E.setDepthTest(i.depthTest);E.setDepthWrite(i.depthWrite);s(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}E.setObjectFaces(j);l instanceof THREE.BufferGeometry?E.renderBufferDirect(d,e,g,i,l,j):E.renderBuffer(d,e,g,i,l,j)}}function j(a,b,c,d,e,g,f){for(var h,i,j=0,l=a.length;j<l;j++)if(h=a[j],i=h.object,i.visible){if(f)h=f;else{h=h[b];if(!h)continue;g&&E.setBlending(h.blending);E.setDepthTest(h.depthTest);E.setDepthWrite(h.depthWrite);s(h.polygonOffset,h.polygonOffsetFactor,
+THREE.WebGLRenderer=function(a){function b(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(void 0===a.__webglCustomAttributesList)a.__webglCustomAttributesList=[];for(var e in d.attributes){var f=d.attributes[e];if(!f.__webglInitialized||f.createUniqueBuffers){f.__webglInitialized=!0;var g=1;"v2"===f.type?g=2:"v3"===f.type?g=3:"v4"===f.type?g=4:"c"===f.type&&(g=3);f.size=g;f.array=new Float32Array(c*g);f.buffer=l.createBuffer();f.buffer.belongsToAttribute=e;f.needsUpdate=!0}a.__webglCustomAttributesList.push(f)}}}
+function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;if(0<=b.materialIndex)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?!1:a&&void 0!==a.shading&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function e(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?!0:!1}function g(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;
+var i=a.colors,j=i.length,m=a.__vertexArray,k=a.__colorArray,n=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,q=a.__webglCustomAttributesList;if(c.sortParticles){db.copy(eb);db.multiplySelf(c.matrixWorld);for(d=0;d<g;d++)e=h[d].position,Ga.copy(e),db.multiplyVector3(Ga),n[d]=[Ga.z,d];n.sort(function(a,b){return b[0]-a[0]});for(d=0;d<g;d++)e=h[n[d][1]].position,f=3*d,m[f]=e.x,m[f+1]=e.y,m[f+2]=e.z;for(d=0;d<j;d++)f=3*d,e=i[n[d][1]],k[f]=e.r,k[f+1]=e.g,k[f+2]=e.b;if(q)for(i=0,j=q.length;i<j;i++)if(h=
+q[i],void 0===h.boundTo||"vertices"===h.boundTo)if(f=0,e=h.value.length,1===h.size)for(d=0;d<e;d++)g=n[d][1],h.array[d]=h.value[g];else if(2===h.size)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+=2;else if(3===h.size)if("c"===h.type)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+=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+=3;else if(4===h.size)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+=4}else{if(o)for(d=0;d<g;d++)e=h[d].position,f=3*d,m[f]=e.x,m[f+1]=e.y,m[f+2]=e.z;if(p)for(d=0;d<j;d++)e=i[d],f=3*d,k[f]=e.r,k[f+1]=e.g,k[f+2]=e.b;if(q)for(i=0,j=q.length;i<j;i++)if(h=q[i],h.needsUpdate&&(void 0===h.boundTo||"vertices"===h.boundTo))if(e=h.value.length,f=0,1===h.size)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(2===h.size)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(3===h.size)if("c"===
+h.type)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(4===h.size)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}if(o||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,a.__webglVertexBuffer),l.bufferData(l.ARRAY_BUFFER,m,b);if(p||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,a.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,
+k,b);if(q)for(i=0,j=q.length;i<j;i++)if(h=q[i],h.needsUpdate||c.sortParticles)l.bindBuffer(l.ARRAY_BUFFER,h.buffer),l.bufferData(l.ARRAY_BUFFER,h.array,b)}function f(a,b){return b.z-a.z}function h(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++)Z=F=null,S=P=aa=T=$=-1,a[d].render(b,c,jb,Va),Z=F=null,S=P=aa=T=$=-1}function i(a,b,c,d,e,f,g,h){var i,j,l,m;b?(j=a.length-1,m=b=-1):(j=0,b=a.length,m=1);for(var k=j;k!==b;k+=m)if(i=a[k],i.render){j=i.object;l=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;
+g&&E.setBlending(i.blending);E.setDepthTest(i.depthTest);E.setDepthWrite(i.depthWrite);s(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}E.setObjectFaces(j);l instanceof THREE.BufferGeometry?E.renderBufferDirect(d,e,f,i,l,j):E.renderBuffer(d,e,f,i,l,j)}}function j(a,b,c,d,e,f,g){for(var h,i,j=0,l=a.length;j<l;j++)if(h=a[j],i=h.object,i.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&E.setBlending(h.blending);E.setDepthTest(h.depthTest);E.setDepthWrite(h.depthWrite);s(h.polygonOffset,h.polygonOffsetFactor,
 h.polygonOffsetUnits)}E.renderImmediateObject(c,d,e,h,i)}}function k(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function p(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function m(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function o(a,b){for(var c=a.length-1;0<=c;c--)a[c].object===b&&a.splice(c,1)}function q(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,1)}function n(a,b,c,d,e){if(!d.program||d.needsUpdate)E.initMaterial(d,
-b,c,e),d.needsUpdate=!1;if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(E.maxMorphTargets);for(var g=0,f=E.maxMorphTargets;g<f;g++)e.__webglMorphTargetInfluences[g]=0}var h=!1,g=d.program,f=g.uniforms,i=d.uniforms;g!==F&&(l.useProgram(g),F=g,h=!0);if(d.id!==S)S=d.id,h=!0;if(h||a!==Z)l.uniformMatrix4fv(f.projectionMatrix,!1,a._projectionMatrixArray),a!==Z&&(Z=a);if(h){if(c&&d.fog)if(i.fogColor.value=c.color,c instanceof THREE.Fog)i.fogNear.value=
+b,c,e),d.needsUpdate=!1;if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(E.maxMorphTargets);for(var f=0,g=E.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=!1,f=d.program,g=f.uniforms,i=d.uniforms;f!==F&&(l.useProgram(f),F=f,h=!0);if(d.id!==S)S=d.id,h=!0;if(h||a!==Z)l.uniformMatrix4fv(g.projectionMatrix,!1,a._projectionMatrixArray),a!==Z&&(Z=a);if(h){if(c&&d.fog)if(i.fogColor.value=c.color,c instanceof THREE.Fog)i.fogNear.value=
 c.near,i.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)i.fogDensity.value=c.density;if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){var j,m=0,k=0,n=0,o,p,q,r=Ba,s=r.directional.colors,y=r.directional.positions,t=r.point.colors,u=r.point.positions,v=r.point.distances,P=0,C=0,D=q=0;for(c=0,h=b.length;c<h;c++)if(j=b[c],!j.onlyShadow)if(o=j.color,p=j.intensity,q=j.distance,j instanceof THREE.AmbientLight)E.gammaInput?(m+=o.r*o.r,k+=o.g*o.g,n+=o.b*o.b):
 (m+=o.r,k+=o.g,n+=o.b);else if(j instanceof THREE.DirectionalLight)q=3*P,E.gammaInput?(s[q]=o.r*o.r*p*p,s[q+1]=o.g*o.g*p*p,s[q+2]=o.b*o.b*p*p):(s[q]=o.r*p,s[q+1]=o.g*p,s[q+2]=o.b*p),ra.copy(j.matrixWorld.getPosition()),ra.subSelf(j.target.matrixWorld.getPosition()),ra.normalize(),y[q]=ra.x,y[q+1]=ra.y,y[q+2]=ra.z,P+=1;else if(j instanceof THREE.PointLight||j instanceof THREE.SpotLight)D=3*C,E.gammaInput?(t[D]=o.r*o.r*p*p,t[D+1]=o.g*o.g*p*p,t[D+2]=o.b*o.b*p*p):(t[D]=o.r*p,t[D+1]=o.g*p,t[D+2]=o.b*p),
 j=j.matrixWorld.getPosition(),u[D]=j.x,u[D+1]=j.y,u[D+2]=j.z,v[C]=q,C+=1;for(c=3*P,h=s.length;c<h;c++)s[c]=0;for(c=3*C,h=t.length;c<h;c++)t[c]=0;r.point.length=C;r.directional.length=P;r.ambient[0]=m;r.ambient[1]=k;r.ambient[2]=n;c=Ba;i.ambientLightColor.value=c.ambient;i.directionalLightColor.value=c.directional.colors;i.directionalLightDirection.value=c.directional.positions;i.pointLightColor.value=c.point.colors;i.pointLightPosition.value=c.point.positions;i.pointLightDistance.value=c.point.distances}if(d instanceof
@@ -257,13 +257,13 @@ THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof TH
 d.refractionRatio,i.combine.value=d.combine,i.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping;if(d instanceof THREE.LineBasicMaterial)i.diffuse.value=d.color,i.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)i.psColor.value=d.color,i.opacity.value=d.opacity,i.size.value=d.size,i.scale.value=G.height/2,i.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)i.shininess.value=d.shininess,E.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),
 i.emissive.value.copyGammaToLinear(d.emissive),i.specular.value.copyGammaToLinear(d.specular)):(i.ambient.value=d.ambient,i.emissive.value=d.emissive,i.specular.value=d.specular),d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshLambertMaterial)E.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),i.emissive.value.copyGammaToLinear(d.emissive)):(i.ambient.value=d.ambient,i.emissive.value=d.emissive),d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof
 THREE.MeshDepthMaterial)i.mNear.value=a.near,i.mFar.value=a.far,i.opacity.value=d.opacity;else if(d instanceof THREE.MeshNormalMaterial)i.opacity.value=d.opacity;if(e.receiveShadow&&!d._shadowPass&&i.shadowMatrix){h=c=0;for(m=b.length;h<m;h++)if(k=b[h],k.castShadow&&(k instanceof THREE.SpotLight||k instanceof THREE.DirectionalLight&&!k.shadowCascade))i.shadowMap.texture[c]=k.shadowMap,i.shadowMapSize.value[c]=k.shadowMapSize,i.shadowMatrix.value[c]=k.shadowMatrix,i.shadowDarkness.value[c]=k.shadowDarkness,
-i.shadowBias.value[c]=k.shadowBias,c++}b=d.uniformsList;for(i=0,c=b.length;i<c;i++)if(k=g.uniforms[b[i][1]])if(h=b[i][0],n=h.type,m=h.value,"i"===n)l.uniform1i(k,m);else if("f"===n)l.uniform1f(k,m);else if("v2"===n)l.uniform2f(k,m.x,m.y);else if("v3"===n)l.uniform3f(k,m.x,m.y,m.z);else if("v4"===n)l.uniform4f(k,m.x,m.y,m.z,m.w);else if("c"===n)l.uniform3f(k,m.r,m.g,m.b);else if("fv1"===n)l.uniform1fv(k,m);else if("fv"===n)l.uniform3fv(k,m);else if("v2v"===n){if(!h._array)h._array=new Float32Array(2*
+i.shadowBias.value[c]=k.shadowBias,c++}b=d.uniformsList;for(i=0,c=b.length;i<c;i++)if(k=f.uniforms[b[i][1]])if(h=b[i][0],n=h.type,m=h.value,"i"===n)l.uniform1i(k,m);else if("f"===n)l.uniform1f(k,m);else if("v2"===n)l.uniform2f(k,m.x,m.y);else if("v3"===n)l.uniform3f(k,m.x,m.y,m.z);else if("v4"===n)l.uniform4f(k,m.x,m.y,m.z,m.w);else if("c"===n)l.uniform3f(k,m.r,m.g,m.b);else if("fv1"===n)l.uniform1fv(k,m);else if("fv"===n)l.uniform3fv(k,m);else if("v2v"===n){if(!h._array)h._array=new Float32Array(2*
 m.length);for(n=0,r=m.length;n<r;n++)s=2*n,h._array[s]=m[n].x,h._array[s+1]=m[n].y;l.uniform2fv(k,h._array)}else if("v3v"===n){if(!h._array)h._array=new Float32Array(3*m.length);for(n=0,r=m.length;n<r;n++)s=3*n,h._array[s]=m[n].x,h._array[s+1]=m[n].y,h._array[s+2]=m[n].z;l.uniform3fv(k,h._array)}else if("v4v"==n){if(!h._array)h._array=new Float32Array(4*m.length);for(n=0,r=m.length;n<r;n++)s=4*n,h._array[s]=m[n].x,h._array[s+1]=m[n].y,h._array[s+2]=m[n].z,h._array[s+3]=m[n].w;l.uniform4fv(k,h._array)}else if("m4"===
 n){if(!h._array)h._array=new Float32Array(16);m.flattenToArray(h._array);l.uniformMatrix4fv(k,!1,h._array)}else if("m4v"===n){if(!h._array)h._array=new Float32Array(16*m.length);for(n=0,r=m.length;n<r;n++)m[n].flattenToArrayOffset(h._array,16*n);l.uniformMatrix4fv(k,!1,h._array)}else if("t"===n){if(l.uniform1i(k,m),k=h.texture)if(k.image instanceof Array&&6===k.image.length){if(h=k,6===h.image.length)if(h.needsUpdate){if(!h.image.__webglTextureCube)h.image.__webglTextureCube=l.createTexture();l.activeTexture(l.TEXTURE0+
 m);l.bindTexture(l.TEXTURE_CUBE_MAP,h.image.__webglTextureCube);m=[];for(k=0;6>k;k++){n=m;r=k;if(E.autoScaleCubemaps){if(s=h.image[k],t=sa,!(s.width<=t&&s.height<=t))u=Math.max(s.width,s.height),y=Math.floor(s.width*t/u),t=Math.floor(s.height*t/u),u=document.createElement("canvas"),u.width=y,u.height=t,u.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,y,t),s=u}else s=h.image[k];n[r]=s}k=m[0];n=0===(k.width&k.width-1)&&0===(k.height&k.height-1);r=z(h.format);s=z(h.type);w(l.TEXTURE_CUBE_MAP,
 h,n);for(k=0;6>k;k++)l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,r,r,s,m[k]);h.generateMipmaps&&n&&l.generateMipmap(l.TEXTURE_CUBE_MAP);h.needsUpdate=!1;if(h.onUpdate)h.onUpdate()}else l.activeTexture(l.TEXTURE0+m),l.bindTexture(l.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}else k instanceof THREE.WebGLRenderTargetCube?(h=k,l.activeTexture(l.TEXTURE0+m),l.bindTexture(l.TEXTURE_CUBE_MAP,h.__webglTexture)):E.setTexture(k,m)}else if("tv"===n){if(!h._array){h._array=[];for(n=0,r=h.texture.length;n<
-r;n++)h._array[n]=m+n}l.uniform1iv(k,h._array);for(n=0,r=h.texture.length;n<r;n++)(k=h.texture[n])&&E.setTexture(k,h._array[n])}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==f.cameraPosition)b=a.matrixWorld.getPosition(),l.uniform3f(f.cameraPosition,b.x,b.y,b.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==f.viewMatrix&&l.uniformMatrix4fv(f.viewMatrix,!1,a._viewMatrixArray);
-d.skinning&&l.uniformMatrix4fv(f.boneGlobalMatrices,!1,e.boneMatrices)}l.uniformMatrix4fv(f.modelViewMatrix,!1,e._modelViewMatrixArray);f.normalMatrix&&l.uniformMatrix3fv(f.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&null!==f.objectMatrix&&l.uniformMatrix4fv(f.objectMatrix,!1,e._objectMatrixArray);return g}function r(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);
+r;n++)h._array[n]=m+n}l.uniform1iv(k,h._array);for(n=0,r=h.texture.length;n<r;n++)(k=h.texture[n])&&E.setTexture(k,h._array[n])}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==g.cameraPosition)b=a.matrixWorld.getPosition(),l.uniform3f(g.cameraPosition,b.x,b.y,b.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==g.viewMatrix&&l.uniformMatrix4fv(g.viewMatrix,!1,a._viewMatrixArray);
+d.skinning&&l.uniformMatrix4fv(g.boneGlobalMatrices,!1,e.boneMatrices)}l.uniformMatrix4fv(g.modelViewMatrix,!1,e._modelViewMatrixArray);g.normalMatrix&&l.uniformMatrix3fv(g.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&null!==g.objectMatrix&&l.uniformMatrix4fv(g.objectMatrix,!1,e._objectMatrixArray);return f}function r(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);
 c&&c.transposeIntoArray(a._normalMatrixArray)}function s(a,b,c){da!==a&&(a?l.enable(l.POLYGON_OFFSET_FILL):l.disable(l.POLYGON_OFFSET_FILL),da=a);if(a&&(Ua!==b||Ia!==c))l.polygonOffset(b,c),Ua=b,Ia=c}function t(a,b){var c;"fragment"===a?c=l.createShader(l.FRAGMENT_SHADER):"vertex"===a&&(c=l.createShader(l.VERTEX_SHADER));l.shaderSource(c,b);l.compileShader(c);return!l.getShaderParameter(c,l.COMPILE_STATUS)?(console.error(l.getShaderInfoLog(c)),console.error(b),null):c}function w(a,b,c){c?(l.texParameteri(a,
 l.TEXTURE_WRAP_S,z(b.wrapS)),l.texParameteri(a,l.TEXTURE_WRAP_T,z(b.wrapT)),l.texParameteri(a,l.TEXTURE_MAG_FILTER,z(b.magFilter)),l.texParameteri(a,l.TEXTURE_MIN_FILTER,z(b.minFilter))):(l.texParameteri(a,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(a,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(a,l.TEXTURE_MAG_FILTER,v(b.magFilter)),l.texParameteri(a,l.TEXTURE_MIN_FILTER,v(b.minFilter)))}function u(a,b){l.bindRenderbuffer(l.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,
 l.DEPTH_COMPONENT16,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_STENCIL,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,a)):l.renderbufferStorage(l.RENDERBUFFER,l.RGBA4,b.width,b.height)}function v(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return l.NEAREST;
@@ -280,24 +280,24 @@ a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry
 l.deleteBuffer(c.__webglLineBuffer);var d=void 0,e=void 0;if(c.numMorphTargets)for(d=0,e=c.numMorphTargets;d<e;d++)l.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.numMorphNormals)for(d=0,e=c.numMorphNormals;d<e;d++)l.deleteBuffer(c.__webglMorphNormalsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)l.deleteBuffer(c.__webglCustomAttributesList[d].buffer);E.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,l.deleteBuffer(a.__webglVertexBuffer),
 l.deleteBuffer(a.__webglColorBuffer),E.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,l.deleteBuffer(a.__webglVertexBuffer),l.deleteBuffer(a.__webglColorBuffer),E.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,l.deleteBuffer(a.__webglVertexBuffer),l.deleteBuffer(a.__webglColorBuffer),E.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,l.deleteTexture(a.__webglTexture),E.info.memory.textures--};this.updateShadowMap=
 function(a,b){F=null;S=P=aa=T=$=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=l.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=l.createBuffer();a.hasPos&&(l.bindBuffer(l.ARRAY_BUFFER,a.__webglVertexBuffer),l.bufferData(l.ARRAY_BUFFER,a.positionArray,l.DYNAMIC_DRAW),l.enableVertexAttribArray(b.attributes.position),l.vertexAttribPointer(b.attributes.position,3,l.FLOAT,!1,0,0));if(a.hasNormal){l.bindBuffer(l.ARRAY_BUFFER,
-a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,g,f,h,i,j,m,k,n,o=3*a.count;for(n=0;n<o;n+=9)c=a.normalArray,d=c[n],e=c[n+1],g=c[n+2],f=c[n+3],i=c[n+4],m=c[n+5],h=c[n+6],j=c[n+7],k=c[n+8],d=(d+f+h)/3,e=(e+i+j)/3,g=(g+m+k)/3,c[n]=d,c[n+1]=e,c[n+2]=g,c[n+3]=d,c[n+4]=e,c[n+5]=g,c[n+6]=d,c[n+7]=e,c[n+8]=g}l.bufferData(l.ARRAY_BUFFER,a.normalArray,l.DYNAMIC_DRAW);l.enableVertexAttribArray(b.attributes.normal);l.vertexAttribPointer(b.attributes.normal,3,l.FLOAT,!1,0,0)}l.drawArrays(l.TRIANGLES,
-0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,g){if(0!==d.opacity&&(c=n(a,b,c,d,g),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?1:0),d!==P&&(P=d,b=!0),g instanceof THREE.Mesh)){g=e.offsets;d=0;for(c=g.length;d<c;++d)b&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexPositionBuffer),l.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,l.FLOAT,!1,0,12*g[d].index),0<=a.normal&&e.vertexNormalBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexNormalBuffer),l.vertexAttribPointer(a.normal,
-e.vertexNormalBuffer.itemSize,l.FLOAT,!1,0,12*g[d].index)),0<=a.uv&&e.vertexUvBuffer&&(e.vertexUvBuffer?(l.bindBuffer(l.ARRAY_BUFFER,e.vertexUvBuffer),l.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,l.FLOAT,!1,0,8*g[d].index),l.enableVertexAttribArray(a.uv)):l.disableVertexAttribArray(a.uv)),0<=a.color&&e.vertexColorBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexColorBuffer),l.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,l.FLOAT,!1,0,16*g[d].index)),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,
-e.vertexIndexBuffer)),l.drawElements(l.TRIANGLES,g[d].count,l.UNSIGNED_SHORT,2*g[d].start),E.info.render.calls++,E.info.render.vertices+=g[d].count,E.info.render.faces+=g[d].count/3}};this.renderBuffer=function(a,b,c,d,e,g){if(0!==d.opacity){var f,h,c=n(a,b,c,d,g),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==P&&(P=c,a=!0);if(!d.morphTargets&&0<=b.position)a&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),l.vertexAttribPointer(b.position,3,l.FLOAT,!1,0,0));else if(g.morphTargetBase){c=
-d.program.attributes;-1!==g.morphTargetBase?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[g.morphTargetBase]),l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0)):0<=c.position&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){f=0;var i=g.morphTargetForcedOrder;for(h=g.morphTargetInfluences;f<d.numSupportedMorphTargets&&f<i.length;)l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[f]]),l.vertexAttribPointer(c["morphTarget"+
-f],3,l.FLOAT,!1,0,0),d.morphNormals&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[i[f]]),l.vertexAttribPointer(c["morphNormal"+f],3,l.FLOAT,!1,0,0)),g.__webglMorphTargetInfluences[f]=h[i[f]],f++}else{var i=[],j=-1,m=0;h=g.morphTargetInfluences;var k,o=h.length;f=0;for(-1!==g.morphTargetBase&&(i[g.morphTargetBase]=!0);f<d.numSupportedMorphTargets;){for(k=0;k<o;k++)!i[k]&&h[k]>j&&(m=k,j=h[m]);l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[m]);l.vertexAttribPointer(c["morphTarget"+
-f],3,l.FLOAT,!1,0,0);d.morphNormals&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[m]),l.vertexAttribPointer(c["morphNormal"+f],3,l.FLOAT,!1,0,0));g.__webglMorphTargetInfluences[f]=j;i[m]=1;j=-1;f++}}null!==d.program.uniforms.morphTargetInfluences&&l.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(f=0,h=e.__webglCustomAttributesList.length;f<h;f++)c=e.__webglCustomAttributesList[f],0<=b[c.buffer.belongsToAttribute]&&
+a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,f,g,h,i,j,m,k,n,o=3*a.count;for(n=0;n<o;n+=9)c=a.normalArray,d=c[n],e=c[n+1],f=c[n+2],g=c[n+3],i=c[n+4],m=c[n+5],h=c[n+6],j=c[n+7],k=c[n+8],d=(d+g+h)/3,e=(e+i+j)/3,f=(f+m+k)/3,c[n]=d,c[n+1]=e,c[n+2]=f,c[n+3]=d,c[n+4]=e,c[n+5]=f,c[n+6]=d,c[n+7]=e,c[n+8]=f}l.bufferData(l.ARRAY_BUFFER,a.normalArray,l.DYNAMIC_DRAW);l.enableVertexAttribArray(b.attributes.normal);l.vertexAttribPointer(b.attributes.normal,3,l.FLOAT,!1,0,0)}l.drawArrays(l.TRIANGLES,
+0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,f){if(0!==d.opacity&&(c=n(a,b,c,d,f),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?1:0),d!==P&&(P=d,b=!0),f instanceof THREE.Mesh)){f=e.offsets;d=0;for(c=f.length;d<c;++d)b&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexPositionBuffer),l.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,l.FLOAT,!1,0,12*f[d].index),0<=a.normal&&e.vertexNormalBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexNormalBuffer),l.vertexAttribPointer(a.normal,
+e.vertexNormalBuffer.itemSize,l.FLOAT,!1,0,12*f[d].index)),0<=a.uv&&e.vertexUvBuffer&&(e.vertexUvBuffer?(l.bindBuffer(l.ARRAY_BUFFER,e.vertexUvBuffer),l.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,l.FLOAT,!1,0,8*f[d].index),l.enableVertexAttribArray(a.uv)):l.disableVertexAttribArray(a.uv)),0<=a.color&&e.vertexColorBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexColorBuffer),l.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,l.FLOAT,!1,0,16*f[d].index)),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,
+e.vertexIndexBuffer)),l.drawElements(l.TRIANGLES,f[d].count,l.UNSIGNED_SHORT,2*f[d].start),E.info.render.calls++,E.info.render.vertices+=f[d].count,E.info.render.faces+=f[d].count/3}};this.renderBuffer=function(a,b,c,d,e,f){if(0!==d.opacity){var g,h,c=n(a,b,c,d,f),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==P&&(P=c,a=!0);if(!d.morphTargets&&0<=b.position)a&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),l.vertexAttribPointer(b.position,3,l.FLOAT,!1,0,0));else if(f.morphTargetBase){c=
+d.program.attributes;-1!==f.morphTargetBase?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]),l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0)):0<=c.position&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){g=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;g<d.numSupportedMorphTargets&&g<i.length;)l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[g]]),l.vertexAttribPointer(c["morphTarget"+
+g],3,l.FLOAT,!1,0,0),d.morphNormals&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[i[g]]),l.vertexAttribPointer(c["morphNormal"+g],3,l.FLOAT,!1,0,0)),f.__webglMorphTargetInfluences[g]=h[i[g]],g++}else{var i=[],j=-1,m=0;h=f.morphTargetInfluences;var k,o=h.length;g=0;for(-1!==f.morphTargetBase&&(i[f.morphTargetBase]=!0);g<d.numSupportedMorphTargets;){for(k=0;k<o;k++)!i[k]&&h[k]>j&&(m=k,j=h[m]);l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[m]);l.vertexAttribPointer(c["morphTarget"+
+g],3,l.FLOAT,!1,0,0);d.morphNormals&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[m]),l.vertexAttribPointer(c["morphNormal"+g],3,l.FLOAT,!1,0,0));f.__webglMorphTargetInfluences[g]=j;i[m]=1;j=-1;g++}}null!==d.program.uniforms.morphTargetInfluences&&l.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(g=0,h=e.__webglCustomAttributesList.length;g<h;g++)c=e.__webglCustomAttributesList[g],0<=b[c.buffer.belongsToAttribute]&&
 (l.bindBuffer(l.ARRAY_BUFFER,c.buffer),l.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,l.FLOAT,!1,0,0));0<=b.color&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglColorBuffer),l.vertexAttribPointer(b.color,3,l.FLOAT,!1,0,0));0<=b.normal&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglNormalBuffer),l.vertexAttribPointer(b.normal,3,l.FLOAT,!1,0,0));0<=b.tangent&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglTangentBuffer),l.vertexAttribPointer(b.tangent,4,l.FLOAT,!1,0,0));0<=b.uv&&(e.__webglUVBuffer?(l.bindBuffer(l.ARRAY_BUFFER,
 e.__webglUVBuffer),l.vertexAttribPointer(b.uv,2,l.FLOAT,!1,0,0),l.enableVertexAttribArray(b.uv)):l.disableVertexAttribArray(b.uv));0<=b.uv2&&(e.__webglUV2Buffer?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglUV2Buffer),l.vertexAttribPointer(b.uv2,2,l.FLOAT,!1,0,0),l.enableVertexAttribArray(b.uv2)):l.disableVertexAttribArray(b.uv2));d.skinning&&0<=b.skinVertexA&&0<=b.skinVertexB&&0<=b.skinIndex&&0<=b.skinWeight&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinVertexABuffer),l.vertexAttribPointer(b.skinVertexA,4,
-l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),l.vertexAttribPointer(b.skinVertexB,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),l.vertexAttribPointer(b.skinIndex,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),l.vertexAttribPointer(b.skinWeight,4,l.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==oa&&(l.lineWidth(d),oa=d),a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),l.drawElements(l.LINES,
-e.__webglLineCount,l.UNSIGNED_SHORT,0)):(a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),l.drawElements(l.TRIANGLES,e.__webglFaceCount,l.UNSIGNED_SHORT,0)),E.info.render.calls++,E.info.render.vertices+=e.__webglFaceCount,E.info.render.faces+=e.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?l.LINE_STRIP:l.LINES,d=d.linewidth,d!==oa&&(l.lineWidth(d),oa=d),l.drawArrays(g,0,e.__webglLineCount),E.info.render.calls++):g instanceof THREE.ParticleSystem?(l.drawArrays(l.POINTS,
-0,e.__webglParticleCount),E.info.render.calls++,E.info.render.points+=e.__webglParticleCount):g instanceof THREE.Ribbon&&(l.drawArrays(l.TRIANGLE_STRIP,0,e.__webglVertexCount),E.info.render.calls++)}};this.render=function(a,b,c,d){var e,g,m,k,n=a.__lights,o=a.fog;S=-1;void 0===b.parent&&(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=
+l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),l.vertexAttribPointer(b.skinVertexB,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),l.vertexAttribPointer(b.skinIndex,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),l.vertexAttribPointer(b.skinWeight,4,l.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==oa&&(l.lineWidth(d),oa=d),a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),l.drawElements(l.LINES,
+e.__webglLineCount,l.UNSIGNED_SHORT,0)):(a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),l.drawElements(l.TRIANGLES,e.__webglFaceCount,l.UNSIGNED_SHORT,0)),E.info.render.calls++,E.info.render.vertices+=e.__webglFaceCount,E.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?l.LINE_STRIP:l.LINES,d=d.linewidth,d!==oa&&(l.lineWidth(d),oa=d),l.drawArrays(f,0,e.__webglLineCount),E.info.render.calls++):f instanceof THREE.ParticleSystem?(l.drawArrays(l.POINTS,
+0,e.__webglParticleCount),E.info.render.calls++,E.info.render.points+=e.__webglParticleCount):f instanceof THREE.Ribbon&&(l.drawArrays(l.TRIANGLE_STRIP,0,e.__webglVertexCount),E.info.render.calls++)}};this.render=function(a,b,c,d){var e,g,m,k,n=a.__lights,o=a.fog;S=-1;void 0===b.parent&&(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);eb.multiply(b.projectionMatrix,b.matrixWorldInverse);cb.setFromMatrix(eb);this.autoUpdateObjects&&this.initWebGLObjects(a);h(this.renderPluginsPre,a,b);E.info.render.calls=0;E.info.render.vertices=0;E.info.render.faces=0;E.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,
 this.autoClearDepth,this.autoClearStencil);k=a.__webglObjects;for(d=0,e=k.length;d<e;d++)if(g=k[d],m=g.object,g.render=!1,m.visible&&(!(m instanceof THREE.Mesh||m instanceof THREE.ParticleSystem)||!m.frustumCulled||cb.contains(m))){m.matrixWorld.flattenToArray(m._objectMatrixArray);r(m,b);var p=g,q=p.object,y=p.buffer,t=void 0,t=t=void 0,t=q.material;if(t instanceof THREE.MeshFaceMaterial){if(t=y.materialIndex,0<=t)t=q.geometry.materials[t],t.transparent?(p.transparent=t,p.opaque=null):(p.opaque=
 t,p.transparent=null)}else if(t)t.transparent?(p.transparent=t,p.opaque=null):(p.opaque=t,p.transparent=null);g.render=!0;if(this.sortObjects)m.renderDepth?g.z=m.renderDepth:(Ga.copy(m.matrixWorld.getPosition()),eb.multiplyVector3(Ga),g.z=Ga.z)}this.sortObjects&&k.sort(f);k=a.__webglObjectsImmediate;for(d=0,e=k.length;d<e;d++)if(g=k[d],m=g.object,m.visible)m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),r(m,b),m=g.object.material,m.transparent?(g.transparent=m,g.opaque=null):
 (g.opaque=m,g.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),this.setDepthWrite(a.overrideMaterial.depthWrite),s(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),i(a.__webglObjects,!1,"",b,n,o,!0,a.overrideMaterial),j(a.__webglObjectsImmediate,"",b,n,o,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),i(a.__webglObjects,!0,"opaque",b,n,o,
 !1),j(a.__webglObjectsImmediate,"opaque",b,n,o,!1),i(a.__webglObjects,!1,"transparent",b,n,o,!0),j(a.__webglObjectsImmediate,"transparent",b,n,o,!0));h(this.renderPluginsPost,a,b);c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(l.bindTexture(l.TEXTURE_CUBE_MAP,c.__webglTexture),l.generateMipmap(l.TEXTURE_CUBE_MAP),l.bindTexture(l.TEXTURE_CUBE_MAP,null)):(l.bindTexture(l.TEXTURE_2D,c.__webglTexture),l.generateMipmap(l.TEXTURE_2D),
-l.bindTexture(l.TEXTURE_2D,null)));this.setDepthTest(!0);this.setDepthWrite(!0)};this.renderImmediateObject=function(a,b,c,d,e){var g=n(a,b,c,d,e);P=-1;E.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(g,l,cb):e.render(function(a){E.renderBufferImmediate(a,g,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var f=a.__objectsAdded[0],h=a,i=
+l.bindTexture(l.TEXTURE_2D,null)));this.setDepthTest(!0);this.setDepthWrite(!0)};this.renderImmediateObject=function(a,b,c,d,e){var f=n(a,b,c,d,e);P=-1;E.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,l,cb):e.render(function(a){E.renderBufferImmediate(a,f,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var f=a.__objectsAdded[0],h=a,i=
 void 0,j=void 0,n=void 0;if(!f.__webglInit)if(f.__webglInit=!0,f._modelViewMatrix=new THREE.Matrix4,f._normalMatrixArray=new Float32Array(9),f._modelViewMatrixArray=new Float32Array(16),f._objectMatrixArray=new Float32Array(16),f.matrixWorld.flattenToArray(f._objectMatrixArray),f instanceof THREE.Mesh){if(j=f.geometry,j instanceof THREE.Geometry){if(void 0===j.geometryGroups){var r=j,s=void 0,y=void 0,t=void 0,u=void 0,v=void 0,w=void 0,z=void 0,S={},P=r.morphTargets.length,C=r.morphNormals.length;
 r.geometryGroups={};for(s=0,y=r.faces.length;s<y;s++)t=r.faces[s],u=t.materialIndex,w=void 0!==u?u:-1,void 0===S[w]&&(S[w]={hash:w,counter:0}),z=S[w].hash+"_"+S[w].counter,void 0===r.geometryGroups[z]&&(r.geometryGroups[z]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:P,numMorphNormals:C}),v=t instanceof THREE.Face3?3:4,65535<r.geometryGroups[z].vertices+v&&(S[w].counter+=1,z=S[w].hash+"_"+S[w].counter,void 0===r.geometryGroups[z]&&(r.geometryGroups[z]={faces3:[],faces4:[],materialIndex:u,
 vertices:0,numMorphTargets:P,numMorphNormals:C})),t instanceof THREE.Face3?r.geometryGroups[z].faces3.push(s):r.geometryGroups[z].faces4.push(s),r.geometryGroups[z].vertices+=v;r.geometryGroupsList=[];var F=void 0;for(F in r.geometryGroups)r.geometryGroups[F].id=ja++,r.geometryGroupsList.push(r.geometryGroups[F])}for(i in j.geometryGroups)if(n=j.geometryGroups[i],!n.__webglVertexBuffer){var Z=n;Z.__webglVertexBuffer=l.createBuffer();Z.__webglNormalBuffer=l.createBuffer();Z.__webglTangentBuffer=l.createBuffer();
@@ -344,9 +344,9 @@ Mc,kd)}if(Bd){for(zc=0;zc<Ad;zc++)Lc=md[zc],$b=3*zc,Nc[$b]=Lc.r,Nc[$b+1]=Lc.g,Nc
 Ed=Lb.__dirtyColors,dd=Lb.__webglCustomAttributesList,Sc=void 0,pd=void 0,Qa=void 0,oc=void 0,Ya=void 0,ta=void 0;if(Lb.__dirtyVertices){for(Ac=0;Ac<Cd;Ac++)Oc=nd[Ac].position,za=3*Ac,Qc[za]=Oc.x,Qc[za+1]=Oc.y,Qc[za+2]=Oc.z;l.bindBuffer(l.ARRAY_BUFFER,Lb.__webglVertexBuffer);l.bufferData(l.ARRAY_BUFFER,Qc,cd)}if(Ed){for(Bc=0;Bc<Dd;Bc++)Pc=od[Bc],za=3*Bc,Rc[za]=Pc.r,Rc[za+1]=Pc.g,Rc[za+2]=Pc.b;l.bindBuffer(l.ARRAY_BUFFER,Lb.__webglColorBuffer);l.bufferData(l.ARRAY_BUFFER,Rc,cd)}if(dd)for(Sc=0,pd=dd.length;Sc<
 pd;Sc++)if(ta=dd[Sc],ta.needsUpdate&&(void 0===ta.boundTo||"vertices"===ta.boundTo)){za=0;oc=ta.value.length;if(1===ta.size)for(Qa=0;Qa<oc;Qa++)ta.array[Qa]=ta.value[Qa];else if(2===ta.size)for(Qa=0;Qa<oc;Qa++)Ya=ta.value[Qa],ta.array[za]=Ya.x,ta.array[za+1]=Ya.y,za+=2;else if(3===ta.size)if("c"===ta.type)for(Qa=0;Qa<oc;Qa++)Ya=ta.value[Qa],ta.array[za]=Ya.r,ta.array[za+1]=Ya.g,ta.array[za+2]=Ya.b,za+=3;else for(Qa=0;Qa<oc;Qa++)Ya=ta.value[Qa],ta.array[za]=Ya.x,ta.array[za+1]=Ya.y,ta.array[za+2]=
 Ya.z,za+=3;else if(4===ta.size)for(Qa=0;Qa<oc;Qa++)Ya=ta.value[Qa],ta.array[za]=Ya.x,ta.array[za+1]=Ya.y,ta.array[za+2]=Ya.z,ta.array[za+3]=Ya.w,za+=4;l.bindBuffer(l.ARRAY_BUFFER,ta.buffer);l.bufferData(l.ARRAY_BUFFER,ta.array,cd)}}ia.__dirtyVertices=!1;ia.__dirtyColors=!1;Xa.attributes&&m(Xa)}else if(nb instanceof THREE.ParticleSystem)Xa=c(nb,qc),ic=Xa.attributes&&p(Xa),(ia.__dirtyVertices||ia.__dirtyColors||nb.sortParticles||ic)&&g(ia,l.DYNAMIC_DRAW,nb),ia.__dirtyVertices=!1,ia.__dirtyColors=!1,
-Xa.attributes&&m(Xa)}};this.initMaterial=function(a,b,c,d){var e,g,f,h,i;a instanceof THREE.MeshDepthMaterial?i="depth":a instanceof THREE.MeshNormalMaterial?i="normal":a instanceof THREE.MeshBasicMaterial?i="basic":a instanceof THREE.MeshLambertMaterial?i="lambert":a instanceof THREE.MeshPhongMaterial?i="phong":a instanceof THREE.LineBasicMaterial?i="basic":a instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];a.uniforms=THREE.UniformsUtils.clone(j.uniforms);
-a.vertexShader=j.vertexShader;a.fragmentShader=j.fragmentShader}var m,k;g=j=0;for(m=0,k=b.length;m<k;m++)e=b[m],e.onlyShadow||(e instanceof THREE.DirectionalLight&&g++,e instanceof THREE.PointLight&&j++,e instanceof THREE.SpotLight&&j++);j+g<=N?m=g:(m=Math.ceil(N*g/(j+g)),j=N-m);e=m;g=j;var n=0;for(j=0,m=b.length;j<m;j++)k=b[j],k.castShadow&&(k instanceof THREE.SpotLight&&n++,k instanceof THREE.DirectionalLight&&!k.shadowCascade&&n++);var o=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)o=d.bones.length;
-var p;a:{m=a.fragmentShader;k=a.vertexShader;var j=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:e,maxPointLights:g,maxBones:o,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,
+Xa.attributes&&m(Xa)}};this.initMaterial=function(a,b,c,d){var e,f,g,h,i;a instanceof THREE.MeshDepthMaterial?i="depth":a instanceof THREE.MeshNormalMaterial?i="normal":a instanceof THREE.MeshBasicMaterial?i="basic":a instanceof THREE.MeshLambertMaterial?i="lambert":a instanceof THREE.MeshPhongMaterial?i="phong":a instanceof THREE.LineBasicMaterial?i="basic":a instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];a.uniforms=THREE.UniformsUtils.clone(j.uniforms);
+a.vertexShader=j.vertexShader;a.fragmentShader=j.fragmentShader}var m,k;f=j=0;for(m=0,k=b.length;m<k;m++)e=b[m],e.onlyShadow||(e instanceof THREE.DirectionalLight&&f++,e instanceof THREE.PointLight&&j++,e instanceof THREE.SpotLight&&j++);j+f<=N?m=f:(m=Math.ceil(N*f/(j+f)),j=N-m);e=m;f=j;var n=0;for(j=0,m=b.length;j<m;j++)k=b[j],k.castShadow&&(k instanceof THREE.SpotLight&&n++,k instanceof THREE.DirectionalLight&&!k.shadowCascade&&n++);var o=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)o=d.bones.length;
+var p;a:{m=a.fragmentShader;k=a.vertexShader;var j=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:e,maxPointLights:f,maxBones:o,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,
 shadowMapCascade:this.shadowMapCascade,maxShadows:n,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:d&&d.doubleSided},q,d=[];i?d.push(i):(d.push(m),d.push(k));for(q in c)d.push(q),d.push(c[q]);i=d.join();for(q=0,d=Y.length;q<d;q++)if(Y[q].code===i){p=Y[q].program;break a}q=l.createProgram();d=[0<Oa?"#define VERTEX_TEXTURES":"",E.gammaInput?"#define GAMMA_INPUT":"",E.gammaOutput?"#define GAMMA_OUTPUT":"",E.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":
 "","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.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");
@@ -355,12 +355,12 @@ e=["precision "+D+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MA
 l.attachShader(q,t("vertex",d+k));l.linkProgram(q);l.getProgramParameter(q,l.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+l.getProgramParameter(q,l.VALIDATE_STATUS)+", gl error ["+l.getError()+"]");q.uniforms={};q.attributes={};var r,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,boneGlobalMatrices,morphTargetInfluences".split(",");for(r in j)d.push(r);r=d;for(d=0,j=r.length;d<j;d++)m=r[d],q.uniforms[m]=l.getUniformLocation(q,
 m);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");for(r=0;r<c.maxMorphTargets;r++)d.push("morphTarget"+r);for(r=0;r<c.maxMorphNormals;r++)d.push("morphNormal"+r);for(p in b)d.push(p);p=d;for(r=0,b=p.length;r<b;r++)c=p[r],q.attributes[c]=l.getAttribLocation(q,c);q.id=Y.length;Y.push({program:q,code:i});E.info.memory.programs=Y.length;p=q}a.program=p;p=a.program.attributes;0<=p.position&&l.enableVertexAttribArray(p.position);0<=p.color&&l.enableVertexAttribArray(p.color);
 0<=p.normal&&l.enableVertexAttribArray(p.normal);0<=p.tangent&&l.enableVertexAttribArray(p.tangent);a.skinning&&0<=p.skinVertexA&&0<=p.skinVertexB&&0<=p.skinIndex&&0<=p.skinWeight&&(l.enableVertexAttribArray(p.skinVertexA),l.enableVertexAttribArray(p.skinVertexB),l.enableVertexAttribArray(p.skinIndex),l.enableVertexAttribArray(p.skinWeight));if(a.attributes)for(h in a.attributes)void 0!==p[h]&&0<=p[h]&&l.enableVertexAttribArray(p[h]);if(a.morphTargets){a.numSupportedMorphTargets=0;q="morphTarget";
-for(h=0;h<this.maxMorphTargets;h++)r=q+h,0<=p[r]&&(l.enableVertexAttribArray(p[r]),a.numSupportedMorphTargets++)}if(a.morphNormals){a.numSupportedMorphNormals=0;q="morphNormal";for(h=0;h<this.maxMorphNormals;h++)r=q+h,0<=p[r]&&(l.enableVertexAttribArray(p[r]),a.numSupportedMorphNormals++)}a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.setFaceCulling=function(a,b){a?(!b||"ccw"===b?l.frontFace(l.CCW):l.frontFace(l.CW),"back"===a?l.cullFace(l.BACK):"front"===a?l.cullFace(l.FRONT):
+for(h=0;h<this.maxMorphTargets;h++)r=q+h,0<=p[r]&&(l.enableVertexAttribArray(p[r]),a.numSupportedMorphTargets++)}if(a.morphNormals){a.numSupportedMorphNormals=0;q="morphNormal";for(h=0;h<this.maxMorphNormals;h++)r=q+h,0<=p[r]&&(l.enableVertexAttribArray(p[r]),a.numSupportedMorphNormals++)}a.uniformsList=[];for(g in a.uniforms)a.uniformsList.push([a.uniforms[g],g])};this.setFaceCulling=function(a,b){a?(!b||"ccw"===b?l.frontFace(l.CCW):l.frontFace(l.CW),"back"===a?l.cullFace(l.BACK):"front"===a?l.cullFace(l.FRONT):
 l.cullFace(l.FRONT_AND_BACK),l.enable(l.CULL_FACE)):l.disable(l.CULL_FACE)};this.setObjectFaces=function(a){if(ha!==a.doubleSided)a.doubleSided?l.disable(l.CULL_FACE):l.enable(l.CULL_FACE),ha=a.doubleSided;if(R!==a.flipSided)a.flipSided?l.frontFace(l.CW):l.frontFace(l.CCW),R=a.flipSided};this.setDepthTest=function(a){T!==a&&(a?l.enable(l.DEPTH_TEST):l.disable(l.DEPTH_TEST),T=a)};this.setDepthWrite=function(a){aa!==a&&(l.depthMask(a),aa=a)};this.setBlending=function(a){if(a!==$){switch(a){case THREE.NoBlending:l.disable(l.BLEND);
 break;case THREE.AdditiveBlending:l.enable(l.BLEND);l.blendEquation(l.FUNC_ADD);l.blendFunc(l.SRC_ALPHA,l.ONE);break;case THREE.SubtractiveBlending:l.enable(l.BLEND);l.blendEquation(l.FUNC_ADD);l.blendFunc(l.ZERO,l.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:l.enable(l.BLEND);l.blendEquation(l.FUNC_ADD);l.blendFunc(l.ZERO,l.SRC_COLOR);break;default:l.enable(l.BLEND),l.blendEquationSeparate(l.FUNC_ADD,l.FUNC_ADD),l.blendFuncSeparate(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA)}$=
-a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=l.createTexture(),E.info.memory.textures++;l.activeTexture(l.TEXTURE0+b);l.bindTexture(l.TEXTURE_2D,a.__webglTexture);var c=a.image,d=0===(c.width&c.width-1)&&0===(c.height&c.height-1),e=z(a.format),g=z(a.type);w(l.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?l.texImage2D(l.TEXTURE_2D,0,e,c.width,c.height,0,e,g,c.data):l.texImage2D(l.TEXTURE_2D,0,e,e,g,a.image);a.generateMipmaps&&d&&l.generateMipmap(l.TEXTURE_2D);
+a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=l.createTexture(),E.info.memory.textures++;l.activeTexture(l.TEXTURE0+b);l.bindTexture(l.TEXTURE_2D,a.__webglTexture);var c=a.image,d=0===(c.width&c.width-1)&&0===(c.height&c.height-1),e=z(a.format),f=z(a.type);w(l.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?l.texImage2D(l.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):l.texImage2D(l.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&l.generateMipmap(l.TEXTURE_2D);
 a.needsUpdate=!1;if(a.onUpdate)a.onUpdate()}else l.activeTexture(l.TEXTURE0+b),l.bindTexture(l.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(void 0===a.depthBuffer)a.depthBuffer=!0;if(void 0===a.stencilBuffer)a.stencilBuffer=!0;a.__webglTexture=l.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=z(a.format),e=z(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];l.bindTexture(l.TEXTURE_CUBE_MAP,
-a.__webglTexture);w(l.TEXTURE_CUBE_MAP,a,c);for(c=0;6>c;c++){a.__webglFramebuffer[c]=l.createFramebuffer();a.__webglRenderbuffer[c]=l.createRenderbuffer();l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,0,d,e,null);var g=a,f=l.TEXTURE_CUBE_MAP_POSITIVE_X+c;l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer[c]);l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,f,g.__webglTexture,0);u(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=l.createFramebuffer(),a.__webglRenderbuffer=
+a.__webglTexture);w(l.TEXTURE_CUBE_MAP,a,c);for(c=0;6>c;c++){a.__webglFramebuffer[c]=l.createFramebuffer();a.__webglRenderbuffer[c]=l.createRenderbuffer();l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,0,d,e,null);var f=a,g=l.TEXTURE_CUBE_MAP_POSITIVE_X+c;l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer[c]);l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,g,f.__webglTexture,0);u(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=l.createFramebuffer(),a.__webglRenderbuffer=
 l.createRenderbuffer(),l.bindTexture(l.TEXTURE_2D,a.__webglTexture),w(l.TEXTURE_2D,a,c),l.texImage2D(l.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=l.TEXTURE_2D,l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,d,a.__webglTexture,0),u(a.__webglRenderbuffer,a);b?l.bindTexture(l.TEXTURE_CUBE_MAP,null):l.bindTexture(l.TEXTURE_2D,null);l.bindRenderbuffer(l.RENDERBUFFER,null);l.bindFramebuffer(l.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:
 a.__webglFramebuffer,d=a.width,a=a.height,c=e=0):(b=null,d=ka,a=bb,e=Fa,c=Aa);b!==y&&(l.bindFramebuffer(l.FRAMEBUFFER,b),l.viewport(e,c,d,a),y=b);jb=d;Va=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
 THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter;this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=void 0!==c.format?c.format:THREE.RGBAFormat;this.type=void 0!==c.type?c.type:
@@ -380,13 +380,14 @@ e=b.vertices[a.b].position,g=b.vertices[a.c].position,THREE.GeometryUtils.random
 (c+f)<c?THREE.GeometryUtils.randomPointInTriangle(d,e,b):THREE.GeometryUtils.randomPointInTriangle(e,g,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return j[e]>a?b(c,e-1):j[e]<a?b(e+1,d):e}return b(0,j.length-1)}var d,e,g=a.faces,f=a.vertices,h=g.length,i=0,j=[],k,p,m,o;for(e=0;e<h;e++){d=g[e];if(d instanceof THREE.Face3)k=f[d.a].position,p=f[d.b].position,m=f[d.c].position,d._area=THREE.GeometryUtils.triangleArea(k,p,m);else if(d instanceof
 THREE.Face4)k=f[d.a].position,p=f[d.b].position,m=f[d.c].position,o=f[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(k,p,o),d._area2=THREE.GeometryUtils.triangleArea(p,m,o),d._area=d._area1+d._area2;i+=d._area;j[e]=i}d=[];for(e=0;e<b;e++)f=THREE.GeometryUtils.random()*i,f=c(f),d[e]=THREE.GeometryUtils.randomPointInFace(g[f],a,!0);return d},triangleArea:function(a,b,c){var d,e=THREE.GeometryUtils.__v1;e.sub(a,b);d=e.length();e.sub(a,c);a=e.length();e.sub(b,c);c=e.length();b=0.5*(d+a+c);return Math.sqrt(b*
 (b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();var b=a.boundingBox,c=new THREE.Vector3;c.add(b.min,b.max);c.multiplyScalar(-0.5);a.applyMatrix((new THREE.Matrix4).setTranslation(c.x,c.y,c.z));a.computeBoundingBox();return c},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],e=0,g=d.length;e<g;e++)1!==d[e].u&&(d[e].u-=Math.floor(d[e].u)),1!==d[e].v&&(d[e].v-=Math.floor(d[e].v))},triangulateQuads:function(a){for(var b=a.faces.length-1;0<=b;b--){var c=
-a.faces[b];if(c instanceof THREE.Face4){var d=c.a,e=c.b,g=c.c,f=c.d,h=c.clone(),c=c.clone();h.a=d;h.b=e;h.c=f;c.a=e;c.b=g;c.c=f;a.faces.splice(b,1,h,c);for(d=0;d<a.faceVertexUvs.length;d++)a.faceVertexUvs[d].length&&(h=a.faceVertexUvs[d][b],e=h[1],g=h[2],f=h[3],h=[h[0].clone(),e.clone(),f.clone()],e=[e.clone(),g.clone(),f.clone()],a.faceVertexUvs[d].splice(b,1,h,e));for(d=0;d<a.faceUvs.length;d++)a.faceUvs[d].length&&(e=a.faceUvs[d][b],a.faceUvs[d].splice(b,1,e,e))}}a.computeCentroids();a.computeFaceNormals();
-a.computeVertexNormals();a.hasTangents&&a.computeTangents()},explode:function(a){for(var b=[],c=0,d=a.faces.length;c<d;c++){var e=b.length,g=a.faces[c];if(g instanceof THREE.Face4){var f=g.a,h=g.b,i=g.c,f=a.vertices[f],h=a.vertices[h],i=a.vertices[i],j=a.vertices[g.d];b.push(f.clone());b.push(h.clone());b.push(i.clone());b.push(j.clone());g.a=e;g.b=e+1;g.c=e+2;g.d=e+3}else f=g.a,h=g.b,i=g.c,f=a.vertices[f],h=a.vertices[h],i=a.vertices[i],b.push(f.clone()),b.push(h.clone()),b.push(i.clone()),g.a=e,
-g.b=e+1,g.c=e+2}a.vertices=b},tessellate:function(a,b){var c,d,e,g,f,h,i,j,k,p,m,o,q,n,r,s,t;for(c=a.faces.length-1;0<=c;c--)if(d=a.faces[c],d instanceof THREE.Face3){if(e=d.a,g=d.b,f=d.c,i=a.vertices[e],j=a.vertices[g],k=a.vertices[f],m=i.position.distanceTo(j.position),o=j.position.distanceTo(k.position),p=i.position.distanceTo(k.position),m>b||o>b||p>b){h=a.vertices.length;t=d.clone();d=d.clone();m>=o&&m>=p?(i=i.clone(),i.position.lerpSelf(j.position,0.5),t.a=e,t.b=h,t.c=f,d.a=h,d.b=g,d.c=f,e=
-0):o>=m&&o>=p?(i=j.clone(),i.position.lerpSelf(k.position,0.5),t.a=e,t.b=g,t.c=h,d.a=h,d.b=f,d.c=e,e=1):(i=i.clone(),i.position.lerpSelf(k.position,0.5),t.a=e,t.b=g,t.c=h,d.a=h,d.b=g,d.c=f,e=2);a.faces.splice(c,1,t,d);a.vertices.push(i);for(g=0;g<a.faceVertexUvs.length;g++)a.faceVertexUvs[g].length&&(k=a.faceVertexUvs[g][c],j=k[0],f=k[1],i=k[2],0===e?(m=j.clone(),m.lerpSelf(f,0.5),k=[j.clone(),m.clone(),i.clone()],f=[m.clone(),f.clone(),i.clone()]):1===e?(m=f.clone(),m.lerpSelf(i,0.5),k=[j.clone(),
-f.clone(),m.clone()],f=[m.clone(),i.clone(),j.clone()]):(m=j.clone(),m.lerpSelf(i,0.5),k=[j.clone(),f.clone(),m.clone()],f=[m.clone(),f.clone(),i.clone()]),a.faceVertexUvs[g].splice(c,1,k,f))}}else if(e=d.a,g=d.b,f=d.c,h=d.d,i=a.vertices[e],j=a.vertices[g],k=a.vertices[f],p=a.vertices[h],m=i.position.distanceTo(j.position),o=j.position.distanceTo(k.position),q=k.position.distanceTo(p.position),n=i.position.distanceTo(p.position),m>b||o>b||q>b||n>b){r=a.vertices.length;s=a.vertices.length+1;t=d.clone();
-d=d.clone();m>=o&&m>=q&&m>=n||q>=o&&q>=m&&q>=n?(m=i.clone(),m.position.lerpSelf(j.position,0.5),j=k.clone(),j.position.lerpSelf(p.position,0.5),t.a=e,t.b=r,t.c=s,t.d=h,d.a=r,d.b=g,d.c=f,d.d=s,e=0):(m=j.clone(),m.position.lerpSelf(k.position,0.5),j=p.clone(),j.position.lerpSelf(i.position,0.5),t.a=e,t.b=g,t.c=r,t.d=s,d.a=s,d.b=r,d.c=f,d.d=h,e=1);a.faces.splice(c,1,t,d);a.vertices.push(m);a.vertices.push(j);for(g=0;g<a.faceVertexUvs.length;g++)a.faceVertexUvs[g].length&&(k=a.faceVertexUvs[g][c],j=k[0],
-f=k[1],i=k[2],k=k[3],0===e?(m=j.clone(),m.lerpSelf(f,0.5),o=i.clone(),o.lerpSelf(k,0.5),j=[j.clone(),m.clone(),o.clone(),k.clone()],f=[m.clone(),f.clone(),i.clone(),o.clone()]):(m=f.clone(),m.lerpSelf(i,0.5),o=k.clone(),o.lerpSelf(j,0.5),j=[j.clone(),f.clone(),m.clone(),o.clone()],f=[o.clone(),m.clone(),i.clone(),k.clone()]),a.faceVertexUvs[g].splice(c,1,j,f))}}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
+a.faces[b];if(c instanceof THREE.Face4){var d=c.a,e=c.b,g=c.c,f=c.d,h=new THREE.Face3,i=new THREE.Face3;h.color.copy(c.color);i.color.copy(c.color);h.materialIndex=c.materialIndex;i.materialIndex=c.materialIndex;h.a=d;h.b=e;h.c=f;i.a=e;i.b=g;i.c=f;4===c.vertexColors.length&&(h.vertexColors[0]=c.vertexColors[0].clone(),h.vertexColors[1]=c.vertexColors[1].clone(),h.vertexColors[2]=c.vertexColors[3].clone(),i.vertexColors[0]=c.vertexColors[1].clone(),i.vertexColors[1]=c.vertexColors[2].clone(),i.vertexColors[2]=
+c.vertexColors[3].clone());a.faces.splice(b,1,h,i);for(c=0;c<a.faceVertexUvs.length;c++)a.faceVertexUvs[c].length&&(f=a.faceVertexUvs[c][b],d=f[1],e=f[2],g=f[3],f=[f[0].clone(),d.clone(),g.clone()],d=[d.clone(),e.clone(),g.clone()],a.faceVertexUvs[c].splice(b,1,f,d));for(c=0;c<a.faceUvs.length;c++)a.faceUvs[c].length&&(d=a.faceUvs[c][b],a.faceUvs[c].splice(b,1,d,d))}}a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals();a.hasTangents&&a.computeTangents()},explode:function(a){for(var b=
+[],c=0,d=a.faces.length;c<d;c++){var e=b.length,g=a.faces[c];if(g instanceof THREE.Face4){var f=g.a,h=g.b,i=g.c,f=a.vertices[f],h=a.vertices[h],i=a.vertices[i],j=a.vertices[g.d];b.push(f.clone());b.push(h.clone());b.push(i.clone());b.push(j.clone());g.a=e;g.b=e+1;g.c=e+2;g.d=e+3}else f=g.a,h=g.b,i=g.c,f=a.vertices[f],h=a.vertices[h],i=a.vertices[i],b.push(f.clone()),b.push(h.clone()),b.push(i.clone()),g.a=e,g.b=e+1,g.c=e+2}a.vertices=b;delete a.__tmpVertices},tessellate:function(a,b){var c,d,e,g,
+f,h,i,j,k,p,m,o,q,n,r,s,t;for(c=a.faces.length-1;0<=c;c--)if(d=a.faces[c],d instanceof THREE.Face3){if(e=d.a,g=d.b,f=d.c,i=a.vertices[e],j=a.vertices[g],k=a.vertices[f],m=i.position.distanceTo(j.position),o=j.position.distanceTo(k.position),p=i.position.distanceTo(k.position),m>b||o>b||p>b){h=a.vertices.length;t=d.clone();d=d.clone();m>=o&&m>=p?(i=i.clone(),i.position.lerpSelf(j.position,0.5),t.a=e,t.b=h,t.c=f,d.a=h,d.b=g,d.c=f,e=0):o>=m&&o>=p?(i=j.clone(),i.position.lerpSelf(k.position,0.5),t.a=
+e,t.b=g,t.c=h,d.a=h,d.b=f,d.c=e,e=1):(i=i.clone(),i.position.lerpSelf(k.position,0.5),t.a=e,t.b=g,t.c=h,d.a=h,d.b=g,d.c=f,e=2);a.faces.splice(c,1,t,d);a.vertices.push(i);for(g=0;g<a.faceVertexUvs.length;g++)a.faceVertexUvs[g].length&&(k=a.faceVertexUvs[g][c],j=k[0],f=k[1],i=k[2],0===e?(m=j.clone(),m.lerpSelf(f,0.5),k=[j.clone(),m.clone(),i.clone()],f=[m.clone(),f.clone(),i.clone()]):1===e?(m=f.clone(),m.lerpSelf(i,0.5),k=[j.clone(),f.clone(),m.clone()],f=[m.clone(),i.clone(),j.clone()]):(m=j.clone(),
+m.lerpSelf(i,0.5),k=[j.clone(),f.clone(),m.clone()],f=[m.clone(),f.clone(),i.clone()]),a.faceVertexUvs[g].splice(c,1,k,f))}}else if(e=d.a,g=d.b,f=d.c,h=d.d,i=a.vertices[e],j=a.vertices[g],k=a.vertices[f],p=a.vertices[h],m=i.position.distanceTo(j.position),o=j.position.distanceTo(k.position),q=k.position.distanceTo(p.position),n=i.position.distanceTo(p.position),m>b||o>b||q>b||n>b){r=a.vertices.length;s=a.vertices.length+1;t=d.clone();d=d.clone();m>=o&&m>=q&&m>=n||q>=o&&q>=m&&q>=n?(m=i.clone(),m.position.lerpSelf(j.position,
+0.5),j=k.clone(),j.position.lerpSelf(p.position,0.5),t.a=e,t.b=r,t.c=s,t.d=h,d.a=r,d.b=g,d.c=f,d.d=s,e=0):(m=j.clone(),m.position.lerpSelf(k.position,0.5),j=p.clone(),j.position.lerpSelf(i.position,0.5),t.a=e,t.b=g,t.c=r,t.d=s,d.a=s,d.b=r,d.c=f,d.d=h,e=1);a.faces.splice(c,1,t,d);a.vertices.push(m);a.vertices.push(j);for(g=0;g<a.faceVertexUvs.length;g++)a.faceVertexUvs[g].length&&(k=a.faceVertexUvs[g][c],j=k[0],f=k[1],i=k[2],k=k[3],0===e?(m=j.clone(),m.lerpSelf(f,0.5),o=i.clone(),o.lerpSelf(k,0.5),
+j=[j.clone(),m.clone(),o.clone(),k.clone()],f=[m.clone(),f.clone(),i.clone(),o.clone()]):(m=f.clone(),m.lerpSelf(i,0.5),o=k.clone(),o.lerpSelf(j,0.5),j=[j.clone(),f.clone(),m.clone(),o.clone()],f=[o.clone(),m.clone(),i.clone(),k.clone()]),a.faceVertexUvs[g].splice(c,1,j,f))}}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
 THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(a,b,c){var d=new Image,e=new THREE.Texture(d,b);d.onload=function(){e.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return e},loadTextureCube:function(a,b,c){var d,e=[],g=new THREE.Texture(e,b);e.loadCount=0;for(b=0,d=a.length;b<d;++b)e[b]=new Image,e[b].onload=function(){e.loadCount+=1;if(6===e.loadCount)g.needsUpdate=!0;c&&c(this)},e[b].crossOrigin=this.crossOrigin,e[b].src=a[b];return g},getNormalMap:function(a,
 b){var c=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,g=document.createElement("canvas");g.width=d;g.height=e;var f=g.getContext("2d");f.drawImage(a,0,0);for(var h=f.getImageData(0,0,d,e).data,i=f.createImageData(d,e),j=i.data,k=0;k<d;k++)for(var p=1;p<e;p++){var m=0>p-1?e-1:p-1,o=(p+1)%e,q=0>k-1?d-1:k-1,n=(k+1)%d,r=[],s=[0,0,h[4*(p*d+k)]/255*b];r.push([-1,0,h[4*(p*d+q)]/255*b]);r.push([-1,-1,h[4*(m*d+q)]/255*b]);r.push([0,-1,
 h[4*(m*d+k)]/255*b]);r.push([1,-1,h[4*(m*d+n)]/255*b]);r.push([1,0,h[4*(p*d+n)]/255*b]);r.push([1,1,h[4*(o*d+n)]/255*b]);r.push([0,1,h[4*(o*d+k)]/255*b]);r.push([-1,1,h[4*(o*d+q)]/255*b]);m=[];q=r.length;for(o=0;o<q;o++){var n=r[o],t=r[(o+1)%q],n=[n[0]-s[0],n[1]-s[1],n[2]-s[2]],t=[t[0]-s[0],t[1]-s[1],t[2]-s[2]];m.push(c([n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]))}r=[0,0,0];for(o=0;o<m.length;o++)r[0]+=m[o][0],r[1]+=m[o][1],r[2]+=m[o][2];r[0]/=m.length;r[1]/=m.length;r[2]/=m.length;
@@ -502,7 +503,7 @@ function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:
 this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);a*=this.lookSpeed;this.activeLook||(a=0);this.lon+=this.mouseX*a;this.lookVertical&&(this.lat-=this.mouseY*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target,c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);b=1;this.constrainVertical&&
 (b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*a;this.lookVertical&&(this.lat-=this.mouseY*a*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);b=this.target;c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);
 this.object.lookAt(b)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};
-THREE.PathControls=function(a,b){function c(a){return 1>(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function e(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},g,f=b.getControlPointsArray(),h=b.getLength(),r=f.length,s=0;g=r-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[g]={time:d,pos:f[g],rot:[0,0,0,1],scl:[1,1,1]};for(g=1;g<r-1;g++)s=d*h.chunks[g]/h.total,b.keys[g]={time:s,pos:f[g]};e.hierarchy[0]=b;THREE.AnimationHandler.add(e);
+THREE.PathControls=function(a,b){function c(a){return 1>(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function e(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),r=g.length,s=0;f=r-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f<r-1;f++)s=d*h.chunks[f]/h.total,b.keys[f]={time:s,pos:g[f]};e.hierarchy[0]=b;THREE.AnimationHandler.add(e);
 return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function g(a,b){var c,d,e=new THREE.Geometry;for(c=0;c<a.points.length*b;c++)d=c/(a.points.length*b),d=a.getPoint(d),e.vertices[c]=new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.z));return e}this.object=a;this.domElement=void 0!==b?b:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=
 new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/
 2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var f=2*Math.PI,h=Math.PI/180;this.update=function(a){var b;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed*a);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed*a);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;a=this.phi%f;this.phi=0<=a?a:a+f;b=this.verticalAngleMap.srcRange;a=this.verticalAngleMap.dstRange;
@@ -544,9 +545,9 @@ m=j[i+1][h+1],o=j[i][h+1],q=this.vertices[c].position.clone().setY(0).normalize(
 0;h<d;h++)c=j[0][h],p=j[0][h+1],m=this.vertices.length-1,q=new THREE.Vector3(0,1,0),n=new THREE.Vector3(0,1,0),r=new THREE.Vector3(0,1,0),t=k[0][h].clone(),w=k[0][h+1].clone(),u=new THREE.UV(w.u,0),this.faces.push(new THREE.Face3(c,p,m,[q,n,r])),this.faceVertexUvs[0].push([t,w,u])}if(!g&&0<b){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(h=0;h<d;h++)c=j[i][h+1],p=j[i][h],m=this.vertices.length-1,q=new THREE.Vector3(0,-1,0),n=new THREE.Vector3(0,-1,0),r=new THREE.Vector3(0,-1,
 0),t=k[i][h+1].clone(),w=k[i][h].clone(),u=new THREE.UV(w.u,1),this.faces.push(new THREE.Face3(c,p,m,[q,n,r])),this.faceVertexUvs[0].push([t,w,u])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
 THREE.ExtrudeGeometry=function(a,b){if("undefined"!==typeof a)THREE.Geometry.call(this),a=a instanceof Array?a:[a],this.shapebb=a[a.length-1].getBoundingBox(),this.addShapeList(a,b),this.computeCentroids(),this.computeFaceNormals()};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)};
-THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,g=THREE.ExtrudeGeometry.__v3,f=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,i=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();g.set(-d.y,d.x);f.set(e.y,-e.x);h.copy(a).addSelf(g);i.copy(a).addSelf(f);if(h.equals(i))return f.clone();
-h.copy(b).addSelf(g);i.copy(c).addSelf(f);g=d.dot(f);f=i.subSelf(h).dot(f);0===g&&(console.log("Either infinite or no solutions!"),0===f?console.log("Its finite solutions."):console.log("Too bad, no solutions."));f/=g;return 0>f?(b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),new THREE.Vector2(a,c)):d.multiplyScalar(f).addSelf(h).subSelf(a).clone()}function e(c,d){var e,g;for(y=c.length;0<=--y;){e=y;g=y-1;0>g&&(g=c.length-1);
-for(var f=0,h=o+2*k,f=0;f<h;f++){var i=l*f,j=l*(f+1),m=d+e+i,i=d+g+i,n=d+g+j,j=d+e+j,p=c,q=f,r=h,m=m+C,i=i+C,n=n+C,j=j+C;D.faces.push(new THREE.Face4(m,i,n,j,null,null,u));m=P.generateSideWallUV(D,a,p,b,m,i,n,j,q,r);D.faceVertexUvs[0].push(m)}}}function g(a,b,c){D.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function f(c,d,e,g){c+=C;d+=C;e+=C;D.faces.push(new THREE.Face3(c,d,e,null,null,w));c=g?P.generateBottomUV(D,a,b,c,d,e):P.generateTopUV(D,a,b,c,d,e);D.faceVertexUvs[0].push(c)}var h=
+THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,i=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).addSelf(f);i.copy(a).addSelf(g);if(h.equals(i))return g.clone();
+h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);0===f&&(console.log("Either infinite or no solutions!"),0===g?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;return 0>g?(b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),new THREE.Vector2(a,c)):d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(c,d){var e,f;for(y=c.length;0<=--y;){e=y;f=y-1;0>f&&(f=c.length-1);
+for(var g=0,h=o+2*k,g=0;g<h;g++){var i=l*g,j=l*(g+1),m=d+e+i,i=d+f+i,n=d+f+j,j=d+e+j,p=c,q=g,r=h,m=m+C,i=i+C,n=n+C,j=j+C;D.faces.push(new THREE.Face4(m,i,n,j,null,null,u));m=P.generateSideWallUV(D,a,p,b,m,i,n,j,q,r);D.faceVertexUvs[0].push(m)}}}function g(a,b,c){D.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function f(c,d,e,f){c+=C;d+=C;e+=C;D.faces.push(new THREE.Face3(c,d,e,null,null,w));c=f?P.generateBottomUV(D,a,b,c,d,e):P.generateTopUV(D,a,b,c,d,e);D.faceVertexUvs[0].push(c)}var h=
 void 0!==b.amount?b.amount:100,i=void 0!==b.bevelThickness?b.bevelThickness:6,j=void 0!==b.bevelSize?b.bevelSize:i-2,k=void 0!==b.bevelSegments?b.bevelSegments:3,p=void 0!==b.bevelEnabled?b.bevelEnabled:!0,m=void 0!==b.curveSegments?b.curveSegments:12,o=void 0!==b.steps?b.steps:1,q=b.bendPath,n=b.extrudePath,r,s=!1,t=void 0!==b.useSpacedPoints?b.useSpacedPoints:!1,w=b.material,u=b.extrudeMaterial;if(n)r=n.getPoints(m),o=r.length,s=!0,p=!1;p||(j=i=k=0);var v,z,G,D=this,C=this.vertices.length;q&&a.addWrapPath(q);
 var q=t?a.extractAllSpacedPoints(m):a.extractAllPoints(m),m=q.shape,I=q.holes;if(q=!THREE.Shape.Utils.isClockWise(m)){m=m.reverse();for(z=0,G=I.length;z<G;z++)v=I[z],THREE.Shape.Utils.isClockWise(v)&&(I[z]=v.reverse());q=!1}var K=THREE.Shape.Utils.triangulateShape(m,I),O=m;for(z=0,G=I.length;z<G;z++)v=I[z],m=m.concat(v);var Q,L,B,N,E,l=m.length,Y,F=K.length,q=[],y=0;B=O.length;Q=B-1;for(L=y+1;y<B;y++,Q++,L++)Q===B&&(Q=0),L===B&&(L=0),q[y]=d(O[y],O[Q],O[L]);var n=[],S,t=q.concat();for(z=0,G=I.length;z<
 G;z++){v=I[z];S=[];for(y=0,B=v.length,Q=B-1,L=y+1;y<B;y++,Q++,L++)Q===B&&(Q=0),L===B&&(L=0),S[y]=d(v[y],v[Q],v[L]);n.push(S);t=t.concat(S)}for(Q=0;Q<k;Q++){B=Q/k;N=i*(1-B);L=j*Math.sin(B*Math.PI/2);for(y=0,B=O.length;y<B;y++)E=c(O[y],q[y],L),g(E.x,E.y,-N);for(z=0,G=I.length;z<G;z++){v=I[z];S=n[z];for(y=0,B=v.length;y<B;y++)E=c(v[y],S[y],L),g(E.x,E.y,-N)}}L=j;for(y=0;y<l;y++)E=p?c(m[y],t[y],L):m[y],s?g(E.x,E.y+r[0].y,r[0].x):g(E.x,E.y,0);for(B=1;B<=o;B++)for(y=0;y<l;y++)E=p?c(m[y],t[y],L):m[y],s?g(E.x,
@@ -574,7 +575,7 @@ a[f[j]],a[f[k]]]);h.push([f[i],f[j],f[k]]);for(i=j,k=j+1;k<e;i++,k++)f[i]=f[k];e
 THREE.TorusGeometry=function(a,b,c,d,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;this.arc=e||2*Math.PI;e=new THREE.Vector3;a=[];b=[];for(c=0;c<=this.segmentsR;c++)for(d=0;d<=this.segmentsT;d++){var g=d/this.segmentsT*this.arc,f=2*c/this.segmentsR*Math.PI;e.x=this.radius*Math.cos(g);e.y=this.radius*Math.sin(g);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(f))*Math.cos(g);h.y=(this.radius+this.tube*Math.cos(f))*Math.sin(g);h.z=
 this.tube*Math.sin(f);this.vertices.push(new THREE.Vertex(h));a.push(new THREE.UV(d/this.segmentsT,1-c/this.segmentsR));b.push(h.clone().subSelf(e).normalize())}for(c=1;c<=this.segmentsR;c++)for(d=1;d<=this.segmentsT;d++){var e=(this.segmentsT+1)*c+d-1,g=(this.segmentsT+1)*(c-1)+d-1,f=(this.segmentsT+1)*(c-1)+d,h=(this.segmentsT+1)*c+d,i=new THREE.Face4(e,g,f,h,[b[e],b[g],b[f],b[h]]);i.normal.addSelf(b[e]);i.normal.addSelf(b[g]);i.normal.addSelf(b[f]);i.normal.addSelf(b[h]);i.normal.normalize();this.faces.push(i);
 this.faceVertexUvs[0].push([a[e].clone(),a[g].clone(),a[f].clone(),a[h].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=new THREE.Geometry;THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
-THREE.TorusKnotGeometry=function(a,b,c,d,e,g,f){function h(a,b,c,d,e,g){var f=Math.cos(a);Math.cos(b);b=Math.sin(a);a*=c/d;c=Math.cos(a);f*=0.5*e*(2+c);b=0.5*e*(2+c)*b;e=0.5*g*e*Math.sin(a);return new THREE.Vector3(f,b,e)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=d||8;this.p=e||2;this.q=g||3;this.heightScale=f||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;d=new THREE.Vector3;e=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=
+THREE.TorusKnotGeometry=function(a,b,c,d,e,g,f){function h(a,b,c,d,e,f){var g=Math.cos(a);Math.cos(b);b=Math.sin(a);a*=c/d;c=Math.cos(a);g*=0.5*e*(2+c);b=0.5*e*(2+c)*b;e=0.5*f*e*Math.sin(a);return new THREE.Vector3(g,b,e)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=d||8;this.p=e||2;this.q=g||3;this.heightScale=f||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;d=new THREE.Vector3;e=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=
 Array(this.segmentsT);for(b=0;b<this.segmentsT;++b){var i=2*(a/this.segmentsR)*this.p*Math.PI,f=2*(b/this.segmentsT)*Math.PI,g=h(i,f,this.q,this.p,this.radius,this.heightScale),i=h(i+0.01,f,this.q,this.p,this.radius,this.heightScale);c.sub(i,g);d.add(i,g);e.cross(c,d);d.cross(e,c);e.normalize();d.normalize();i=-this.tube*Math.cos(f);f=this.tube*Math.sin(f);g.x+=i*d.x+f*e.x;g.y+=i*d.y+f*e.y;g.z+=i*d.z+f*e.z;this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,g.z)))-1}}for(a=
 0;a<this.segmentsR;++a)for(b=0;b<this.segmentsT;++b){var e=(a+1)%this.segmentsR,g=(b+1)%this.segmentsT,c=this.grid[a][b],d=this.grid[e][b],e=this.grid[e][g],g=this.grid[a][g],f=new THREE.UV(a/this.segmentsR,b/this.segmentsT),i=new THREE.UV((a+1)/this.segmentsR,b/this.segmentsT),j=new THREE.UV((a+1)/this.segmentsR,(b+1)/this.segmentsT),k=new THREE.UV(a/this.segmentsR,(b+1)/this.segmentsT);this.faces.push(new THREE.Face4(c,d,e,g));this.faceVertexUvs[0].push([f,i,j,k])}this.computeCentroids();this.computeFaceNormals();
 this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;
@@ -601,7 +602,7 @@ THREE.CameraHelper.prototype.update=function(a){function b(a,b,g,f){THREE.Camera
 THREE.SubdivisionModifier=function(a){this.subdivisions=void 0===a?1:a;this.useOldVertexColors=!1;this.supportUVs=!0};THREE.SubdivisionModifier.prototype.constructor=THREE.SubdivisionModifier;THREE.SubdivisionModifier.prototype.modify=function(a){for(var b=this.subdivisions;0<b--;)this.smooth(a)};
 THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,b,c,d,h,i){var j=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(f.useOldVertexColors){j.vertexColors=[];for(var k,n,p,o=0;4>o;o++){p=i[o];k=new THREE.Color;k.setRGB(0,0,0);for(var q=0;q<p.length;q++)n=h.vertexColors[p[q]-1],k.r+=n.r,k.g+=n.g,k.b+=n.b;k.r/=p.length;k.g/=p.length;k.b/=p.length;j.vertexColors[o]=k}}e.push(j);(!f.supportUVs||0!=m.length)&&g.push([m[a],m[b],m[c],m[d]])}function c(a,b){return Math.min(a,b)+"_"+Math.max(a,
 b)}var d=[],e=[],g=[],f=this,h=a.vertices,d=a.faces,i=h.concat(),j=[],k={},p={},m=[],o,q,n,r,s,t=a.faceVertexUvs[0];for(o=0,q=t.length;o<q;o++)for(n=0,r=t[o].length;n<r;n++)s=d[o]["abcd".charAt(n)],m[s]||(m[s]=t[o][n]);var w;for(o=0,q=d.length;o<q;o++)if(s=d[o],j.push(s.centroid),i.push(new THREE.Vertex(s.centroid)),f.supportUVs&&0!=m.length){w=new THREE.UV;if(s instanceof THREE.Face3)w.u=m[s.a].u+m[s.b].u+m[s.c].u,w.v=m[s.a].v+m[s.b].v+m[s.c].v,w.u/=3,w.v/=3;else if(s instanceof THREE.Face4)w.u=
-m[s.a].u+m[s.b].u+m[s.c].u+m[s.d].u,w.v=m[s.a].v+m[s.b].v+m[s.c].v+m[s.d].v,w.u/=4,w.v/=4;m.push(w)}q=function(a){function b(a,c,d){void 0===a[c]&&(a[c]=[]);a[c].push(d)}var d,e,g,f,h={};for(d=0,e=a.faces.length;d<e;d++)g=a.faces[d],g instanceof THREE.Face3?(f=c(g.a,g.b),b(h,f,d),f=c(g.b,g.c),b(h,f,d),f=c(g.c,g.a),b(h,f,d)):g instanceof THREE.Face4&&(f=c(g.a,g.b),b(h,f,d),f=c(g.b,g.c),b(h,f,d),f=c(g.c,g.d),b(h,f,d),f=c(g.d,g.a),b(h,f,d));return h}(a);var u=0,t=h.length,v,z,G={},D={},C=function(a,
+m[s.a].u+m[s.b].u+m[s.c].u+m[s.d].u,w.v=m[s.a].v+m[s.b].v+m[s.c].v+m[s.d].v,w.u/=4,w.v/=4;m.push(w)}q=function(a){function b(a,c,d){void 0===a[c]&&(a[c]=[]);a[c].push(d)}var d,e,f,g,h={};for(d=0,e=a.faces.length;d<e;d++)f=a.faces[d],f instanceof THREE.Face3?(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.a),b(h,g,d)):f instanceof THREE.Face4&&(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.d),b(h,g,d),g=c(f.d,f.a),b(h,g,d));return h}(a);var u=0,t=h.length,v,z,G={},D={},C=function(a,
 b){void 0===G[a]&&(G[a]=[]);G[a].push(b)},I=function(a,b){void 0===D[a]&&(D[a]={});D[a][b]=null};for(o in q){w=q[o];v=o.split("_");z=v[0];v=v[1];C(z,[z,v]);C(v,[z,v]);for(n=0,r=w.length;n<r;n++)s=w[n],I(z,s,o),I(v,s,o);2>w.length&&(p[o]=!0)}for(o in q)if(w=q[o],s=w[0],w=w[1],v=o.split("_"),z=v[0],v=v[1],r=new THREE.Vector3,p[o]?(r.addSelf(h[z].position),r.addSelf(h[v].position),r.multiplyScalar(0.5)):(r.addSelf(j[s]),r.addSelf(j[w]),r.addSelf(h[z].position),r.addSelf(h[v].position),r.multiplyScalar(0.25)),
 k[o]=t+d.length+u,i.push(new THREE.Vertex(r)),u++,f.supportUVs&&0!=m.length)w=new THREE.UV,w.u=m[z].u+m[v].u,w.v=m[z].v+m[v].v,w.u/=2,w.v/=2,m.push(w);var K,O;v=["123","12","2","23"];r=["123","23","3","31"];var C=["123","31","1","12"],I=["1234","12","2","23"],Q=["1234","23","3","34"],L=["1234","34","4","41"],B=["1234","41","1","12"];for(o=0,q=j.length;o<q;o++)s=d[o],w=t+o,s instanceof THREE.Face3?(u=c(s.a,s.b),z=c(s.b,s.c),K=c(s.c,s.a),b(w,k[u],s.b,k[z],s,v),b(w,k[z],s.c,k[K],s,r),b(w,k[K],s.a,k[u],
 s,C)):s instanceof THREE.Face4?(u=c(s.a,s.b),z=c(s.b,s.c),K=c(s.c,s.d),O=c(s.d,s.a),b(w,k[u],s.b,k[z],s,I),b(w,k[z],s.c,k[K],s,Q),b(w,k[K],s.d,k[O],s,L),b(w,k[O],s.a,k[u],s,B)):console.log("face should be a face!",s);d=i;i=new THREE.Vector3;k=new THREE.Vector3;for(o=0,q=h.length;o<q;o++)if(void 0!==G[o]){i.set(0,0,0);k.set(0,0,0);s=new THREE.Vector3(0,0,0);w=0;for(n in D[o])i.addSelf(j[n]),w++;u=0;t=G[o].length;for(n=0;n<t;n++)p[c(G[o][n][0],G[o][n][1])]&&u++;if(2!=u){i.divideScalar(w);for(n=0;n<
@@ -609,8 +610,8 @@ t;n++)w=G[o][n],w=h[w[0]].position.clone().addSelf(h[w[1]].position).divideScala
 THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
 THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:"anonymous",addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ",b=a.total?b+((100*a.loaded/
 a.total).toFixed(0)+"%"):b+((a.loaded/1E3).toFixed(2)+" KB");this.statusDomElement.innerHTML=b},extractUrlBase:function(a){a=a.split("/");a.pop();return(1>a.length?".":a.join("/"))+"/"},initMaterials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(b[d],c)},hasNormals:function(a){var b,c,d=a.materials.length;for(c=0;c<d;c++)if(b=a.materials[c],b instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(a,b){function c(a){a=
-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 e(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=!0};e.crossOrigin=h.crossOrigin;e.src=b}function g(a,c,d,g,f,h){var i=document.createElement("canvas");a[c]=new THREE.Texture(i);a[c].sourceFile=d;
-if(g){a[c].repeat.set(g[0],g[1]);if(1!=g[0])a[c].wrapS=THREE.RepeatWrapping;if(1!=g[1])a[c].wrapT=THREE.RepeatWrapping}f&&a[c].offset.set(f[0],f[1]);if(h){g={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(void 0!==g[h[0]])a[c].wrapS=g[h[0]];if(void 0!==g[h[1]])a[c].wrapT=g[h[1]]}e(a[c],b+"/"+d)}function f(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]}var h=this,i="MeshLambertMaterial",j={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};a.shading&&
+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 e(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=!0};e.crossOrigin=h.crossOrigin;e.src=b}function g(a,c,d,f,g,h){var i=document.createElement("canvas");a[c]=new THREE.Texture(i);a[c].sourceFile=d;
+if(f){a[c].repeat.set(f[0],f[1]);if(1!=f[0])a[c].wrapS=THREE.RepeatWrapping;if(1!=f[1])a[c].wrapT=THREE.RepeatWrapping}g&&a[c].offset.set(g[0],g[1]);if(h){f={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(void 0!==f[h[0]])a[c].wrapS=f[h[0]];if(void 0!==f[h[1]])a[c].wrapT=f[h[1]]}e(a[c],b+"/"+d)}function f(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]}var h=this,i="MeshLambertMaterial",j={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};a.shading&&
 ("Phong"==a.shading?i="MeshPhongMaterial":"Basic"==a.shading&&(i="MeshBasicMaterial"));if(a.blending)if("Additive"==a.blending)j.blending=THREE.AdditiveBlending;else if("Subtractive"==a.blending)j.blending=THREE.SubtractiveBlending;else if("Multiply"==a.blending)j.blending=THREE.MultiplyBlending;if(void 0!==a.transparent||1>a.opacity)j.transparent=a.transparent;if(void 0!==a.depthTest)j.depthTest=a.depthTest;if(void 0!==a.vertexColors)if("face"==a.vertexColors)j.vertexColors=THREE.FaceColors;else if(a.vertexColors)j.vertexColors=
 THREE.VertexColors;if(a.colorDiffuse)j.color=f(a.colorDiffuse);else if(a.DbgColor)j.color=a.DbgColor;if(a.colorSpecular)j.specular=f(a.colorSpecular);if(a.colorAmbient)j.ambient=f(a.colorAmbient);if(a.transparency)j.opacity=a.transparency;if(a.specularCoef)j.shininess=a.specularCoef;a.mapDiffuse&&b&&g(j,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&g(j,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&g(j,"normalMap",
 a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);a.mapSpecular&&b&&g(j,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var i=THREE.ShaderUtils.lib.normal,k=THREE.UniformsUtils.clone(i.uniforms);k.tNormal.texture=j.normalMap;if(a.mapNormalFactor)k.uNormalScale.value=a.mapNormalFactor;if(j.map)k.tDiffuse.texture=j.map,k.enableDiffuse.value=!0;if(j.specularMap)k.tSpecular.texture=j.specularMap,k.enableSpecular.value=!0;if(j.lightMap)k.tAO.texture=
@@ -619,23 +620,23 @@ THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.const
 THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,e,g){var f=new XMLHttpRequest;f.onreadystatechange=function(){if(4==f.readyState)if(200==f.status||0==f.status){var h=JSON.parse(f.responseText);a.loadAjaxBuffers(h,c,e,d,g)}else console.error("THREE.BinaryLoader: Couldn't load ["+b+"] ["+f.status+"]")};f.open("GET",b,!0);f.overrideMimeType&&f.overrideMimeType("text/plain; charset=x-user-defined");f.setRequestHeader("Content-Type","text/plain");f.send(null)};
 THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,e){var g=new XMLHttpRequest,f=c+"/"+a.buffers,h=0;g.onreadystatechange=function(){4==g.readyState?200==g.status||0==g.status?THREE.BinaryLoader.prototype.createBinModel(g.response,b,d,a.materials):console.error("THREE.BinaryLoader: Couldn't load ["+f+"] ["+g.status+"]"):3==g.readyState?e&&(0==h&&(h=g.getResponseHeader("Content-Length")),e({total:h,loaded:g.responseText.length})):2==g.readyState&&(h=g.getResponseHeader("Content-Length"))};
 g.open("GET",f,!0);g.responseType="arraybuffer";g.send(null)};
-THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var e=function(b){var c,e,i,j,k,p,m,o,q,n,r,s,t,w,u;function v(a){return a%4?4-a%4:0}function z(a,b){return(new Uint8Array(a,b,1))[0]}function G(a,b){return(new Uint32Array(a,b,1))[0]}function D(b,c){var d,e,g,f,h,i,j,k,m=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=m[3*d];g=m[3*d+1];f=m[3*d+2];h=E[2*e];e=E[2*e+1];i=E[2*g];j=E[2*g+1];g=E[2*f];k=E[2*f+1];f=L.faceVertexUvs[0];var l=[];l.push(new THREE.UV(h,e));l.push(new THREE.UV(i,j));l.push(new THREE.UV(g,
-k));f.push(l)}}function C(b,c){var d,e,g,f,h,i,j,k,m,l,n=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=n[4*d];g=n[4*d+1];f=n[4*d+2];h=n[4*d+3];i=E[2*e];e=E[2*e+1];j=E[2*g];m=E[2*g+1];k=E[2*f];l=E[2*f+1];f=E[2*h];g=E[2*h+1];h=L.faceVertexUvs[0];var o=[];o.push(new THREE.UV(i,e));o.push(new THREE.UV(j,m));o.push(new THREE.UV(k,l));o.push(new THREE.UV(f,g));h.push(o)}}function I(b,c,d){for(var e,g,f,h,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[3*d],g=c[3*d+1],f=c[3*d+2],h=i[d],
-L.faces.push(new THREE.Face3(e,g,f,null,null,h))}function K(b,c,d){for(var e,g,f,h,i,c=new Uint32Array(a,c,4*b),j=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[4*d],g=c[4*d+1],f=c[4*d+2],h=c[4*d+3],i=j[d],L.faces.push(new THREE.Face4(e,g,f,h,null,null,i))}function O(b,c,d,e){for(var g,f,h,i,j,k,m,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),l=new Uint16Array(a,e,b),e=0;e<b;e++){g=c[3*e];f=c[3*e+1];h=c[3*e+2];j=d[3*e];k=d[3*e+1];m=d[3*e+2];i=l[e];var n=N[3*k],o=N[3*k+1];k=N[3*k+2];var p=N[3*m],q=
-N[3*m+1];m=N[3*m+2];L.faces.push(new THREE.Face3(g,f,h,[new THREE.Vector3(N[3*j],N[3*j+1],N[3*j+2]),new THREE.Vector3(n,o,k),new THREE.Vector3(p,q,m)],null,i))}}function Q(b,c,d,e){for(var g,f,h,i,j,k,m,l,n,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),o=new Uint16Array(a,e,b),e=0;e<b;e++){g=c[4*e];f=c[4*e+1];h=c[4*e+2];i=c[4*e+3];k=d[4*e];m=d[4*e+1];l=d[4*e+2];n=d[4*e+3];j=o[e];var p=N[3*m],q=N[3*m+1];m=N[3*m+2];var r=N[3*l],s=N[3*l+1];l=N[3*l+2];var t=N[3*n],u=N[3*n+1];n=N[3*n+2];L.faces.push(new THREE.Face4(g,
-f,h,i,[new THREE.Vector3(N[3*k],N[3*k+1],N[3*k+2]),new THREE.Vector3(p,q,m),new THREE.Vector3(r,s,l),new THREE.Vector3(t,u,n)],null,j))}}var L=this,B=0,N=[],E=[],l,Y,F;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(L,d,b);(function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",e=0;e<c;e++)d+=String.fromCharCode(a[b+e]);return d})(a,B,12);c=z(a,B+12);z(a,B+13);z(a,B+14);z(a,B+15);e=z(a,B+16);i=z(a,B+17);j=z(a,B+18);k=z(a,B+19);p=G(a,B+20);m=G(a,B+20+4);o=G(a,B+20+8);b=G(a,B+20+12);q=
-G(a,B+20+16);n=G(a,B+20+20);r=G(a,B+20+24);s=G(a,B+20+28);t=G(a,B+20+32);w=G(a,B+20+36);u=G(a,B+20+40);B+=c;c=3*e+k;F=4*e+k;l=b*c;Y=q*(c+3*i);e=n*(c+3*j);k=r*(c+3*i+3*j);c=s*F;i=t*(F+4*i);j=w*(F+4*j);B+=function(b){var b=new Float32Array(a,b,3*p),c,d,e,g;for(c=0;c<p;c++)d=b[3*c],e=b[3*c+1],g=b[3*c+2],L.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,g)));return 3*p*Float32Array.BYTES_PER_ELEMENT}(B);B+=function(b){if(m){var b=new Int8Array(a,b,3*m),c,d,e,g;for(c=0;c<m;c++)d=b[3*c],e=b[3*c+1],
-g=b[3*c+2],N.push(d/127,e/127,g/127)}return 3*m*Int8Array.BYTES_PER_ELEMENT}(B);B+=v(3*m);B+=function(b){if(o){var b=new Float32Array(a,b,2*o),c,d,e;for(c=0;c<o;c++)d=b[2*c],e=b[2*c+1],E.push(d,e)}return 2*o*Float32Array.BYTES_PER_ELEMENT}(B);l=B+l+v(2*b);Y=l+Y+v(2*q);e=Y+e+v(2*n);k=e+k+v(2*r);c=k+c+v(2*s);i=c+i+v(2*t);j=i+j+v(2*w);(function(a){if(n){var b=a+3*n*Uint32Array.BYTES_PER_ELEMENT;I(n,a,b+3*n*Uint32Array.BYTES_PER_ELEMENT);D(n,b)}})(Y);(function(a){if(r){var b=a+3*r*Uint32Array.BYTES_PER_ELEMENT,
+THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var e=function(b){var c,e,i,j,k,p,m,o,q,n,r,s,t,w,u;function v(a){return a%4?4-a%4:0}function z(a,b){return(new Uint8Array(a,b,1))[0]}function G(a,b){return(new Uint32Array(a,b,1))[0]}function D(b,c){var d,e,f,g,h,i,j,k,m=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=m[3*d];f=m[3*d+1];g=m[3*d+2];h=E[2*e];e=E[2*e+1];i=E[2*f];j=E[2*f+1];f=E[2*g];k=E[2*g+1];g=L.faceVertexUvs[0];var l=[];l.push(new THREE.UV(h,e));l.push(new THREE.UV(i,j));l.push(new THREE.UV(f,
+k));g.push(l)}}function C(b,c){var d,e,f,g,h,i,j,k,m,l,n=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=n[4*d];f=n[4*d+1];g=n[4*d+2];h=n[4*d+3];i=E[2*e];e=E[2*e+1];j=E[2*f];m=E[2*f+1];k=E[2*g];l=E[2*g+1];g=E[2*h];f=E[2*h+1];h=L.faceVertexUvs[0];var o=[];o.push(new THREE.UV(i,e));o.push(new THREE.UV(j,m));o.push(new THREE.UV(k,l));o.push(new THREE.UV(g,f));h.push(o)}}function I(b,c,d){for(var e,f,g,h,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[3*d],f=c[3*d+1],g=c[3*d+2],h=i[d],
+L.faces.push(new THREE.Face3(e,f,g,null,null,h))}function K(b,c,d){for(var e,f,g,h,i,c=new Uint32Array(a,c,4*b),j=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[4*d],f=c[4*d+1],g=c[4*d+2],h=c[4*d+3],i=j[d],L.faces.push(new THREE.Face4(e,f,g,h,null,null,i))}function O(b,c,d,e){for(var f,g,h,i,j,k,m,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),l=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[3*e];g=c[3*e+1];h=c[3*e+2];j=d[3*e];k=d[3*e+1];m=d[3*e+2];i=l[e];var n=N[3*k],o=N[3*k+1];k=N[3*k+2];var p=N[3*m],q=
+N[3*m+1];m=N[3*m+2];L.faces.push(new THREE.Face3(f,g,h,[new THREE.Vector3(N[3*j],N[3*j+1],N[3*j+2]),new THREE.Vector3(n,o,k),new THREE.Vector3(p,q,m)],null,i))}}function Q(b,c,d,e){for(var f,g,h,i,j,k,m,l,n,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),o=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[4*e];g=c[4*e+1];h=c[4*e+2];i=c[4*e+3];k=d[4*e];m=d[4*e+1];l=d[4*e+2];n=d[4*e+3];j=o[e];var p=N[3*m],q=N[3*m+1];m=N[3*m+2];var r=N[3*l],s=N[3*l+1];l=N[3*l+2];var t=N[3*n],u=N[3*n+1];n=N[3*n+2];L.faces.push(new THREE.Face4(f,
+g,h,i,[new THREE.Vector3(N[3*k],N[3*k+1],N[3*k+2]),new THREE.Vector3(p,q,m),new THREE.Vector3(r,s,l),new THREE.Vector3(t,u,n)],null,j))}}var L=this,B=0,N=[],E=[],l,Y,F;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(L,d,b);(function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",e=0;e<c;e++)d+=String.fromCharCode(a[b+e]);return d})(a,B,12);c=z(a,B+12);z(a,B+13);z(a,B+14);z(a,B+15);e=z(a,B+16);i=z(a,B+17);j=z(a,B+18);k=z(a,B+19);p=G(a,B+20);m=G(a,B+20+4);o=G(a,B+20+8);b=G(a,B+20+12);q=
+G(a,B+20+16);n=G(a,B+20+20);r=G(a,B+20+24);s=G(a,B+20+28);t=G(a,B+20+32);w=G(a,B+20+36);u=G(a,B+20+40);B+=c;c=3*e+k;F=4*e+k;l=b*c;Y=q*(c+3*i);e=n*(c+3*j);k=r*(c+3*i+3*j);c=s*F;i=t*(F+4*i);j=w*(F+4*j);B+=function(b){var b=new Float32Array(a,b,3*p),c,d,e,f;for(c=0;c<p;c++)d=b[3*c],e=b[3*c+1],f=b[3*c+2],L.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,f)));return 3*p*Float32Array.BYTES_PER_ELEMENT}(B);B+=function(b){if(m){var b=new Int8Array(a,b,3*m),c,d,e,f;for(c=0;c<m;c++)d=b[3*c],e=b[3*c+1],
+f=b[3*c+2],N.push(d/127,e/127,f/127)}return 3*m*Int8Array.BYTES_PER_ELEMENT}(B);B+=v(3*m);B+=function(b){if(o){var b=new Float32Array(a,b,2*o),c,d,e;for(c=0;c<o;c++)d=b[2*c],e=b[2*c+1],E.push(d,e)}return 2*o*Float32Array.BYTES_PER_ELEMENT}(B);l=B+l+v(2*b);Y=l+Y+v(2*q);e=Y+e+v(2*n);k=e+k+v(2*r);c=k+c+v(2*s);i=c+i+v(2*t);j=i+j+v(2*w);(function(a){if(n){var b=a+3*n*Uint32Array.BYTES_PER_ELEMENT;I(n,a,b+3*n*Uint32Array.BYTES_PER_ELEMENT);D(n,b)}})(Y);(function(a){if(r){var b=a+3*r*Uint32Array.BYTES_PER_ELEMENT,
 c=b+3*r*Uint32Array.BYTES_PER_ELEMENT;O(r,a,b,c+3*r*Uint32Array.BYTES_PER_ELEMENT);D(r,c)}})(e);(function(a){if(w){var b=a+4*w*Uint32Array.BYTES_PER_ELEMENT;K(w,a,b+4*w*Uint32Array.BYTES_PER_ELEMENT);C(w,b)}})(i);(function(a){if(u){var b=a+4*u*Uint32Array.BYTES_PER_ELEMENT,c=b+4*u*Uint32Array.BYTES_PER_ELEMENT;Q(u,a,b,c+4*u*Uint32Array.BYTES_PER_ELEMENT);C(u,c)}})(j);b&&I(b,B,B+3*b*Uint32Array.BYTES_PER_ELEMENT);(function(a){if(q){var b=a+3*q*Uint32Array.BYTES_PER_ELEMENT;O(q,a,b,b+3*q*Uint32Array.BYTES_PER_ELEMENT)}})(l);
 s&&K(s,k,k+4*s*Uint32Array.BYTES_PER_ELEMENT);(function(a){if(t){var b=a+4*t*Uint32Array.BYTES_PER_ELEMENT;Q(t,a,b,b+4*t*Uint32Array.BYTES_PER_ELEMENT)}})(c);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))};
 THREE.ColladaLoader=function(){function a(a,d,e){T=a;d=d||Ua;void 0!==e&&(a=e.split("/"),a.pop(),db=(1>a.length?".":a.join("/"))+"/");if((a=T.evaluate("//dae:asset",T,y,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(e=0;e<a.childNodes.length;e++){var i=a.childNodes[e];switch(i.nodeName){case "unit":(i=i.getAttribute("meter"))&&parseFloat(i);break;case "up_axis":sa=i.textContent.charAt(0)}}if(!Oa.convertUpAxis||sa===Oa.upAxis)Wa=null;else switch(sa){case "X":Wa="Y"===
 Oa.upAxis?"XtoY":"XtoZ";break;case "Y":Wa="X"===Oa.upAxis?"YtoX":"YtoZ";break;case "Z":Wa="X"===Oa.upAxis?"ZtoX":"ZtoY"}oa=b("//dae:library_images/dae:image",f,"image");bb=b("//dae:library_materials/dae:material",D,"material");jb=b("//dae:library_effects/dae:effect",Q,"effect");ka=b("//dae:library_geometries/dae:geometry",r,"geometry");Va=b(".//dae:library_cameras/dae:camera",Y,"camera");Aa=b("//dae:library_controllers/dae:controller",h,"controller");Fa=b("//dae:library_animations/dae:animation",
 B,"animation");eb=b(".//dae:library_visual_scenes/dae:visual_scene",k,"visual_scene");Ga=[];ra=[];(a=T.evaluate(".//dae:scene/dae:instance_visual_scene",T,y,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),da=eb[0<a.length?a:"visual_scene0"]):da=null;aa=new THREE.Object3D;for(a=0;a<da.nodes.length;a++)aa.add(g(da.nodes[a]));cb=[];c(aa);a={scene:aa,morphs:Ga,skins:ra,animations:cb,dae:{images:oa,materials:bb,cameras:Va,effects:jb,geometries:ka,controllers:Aa,
-animations:Fa,visualScenes:eb,scene:da}};d&&d(a);return a}function b(a,b,c){for(var a=T.evaluate(a,T,y,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),d={},e=a.iterateNext(),g=0;e;){e=(new b).parse(e);if(!e.id||0==e.id.length)e.id=c+g++;d[e.id]=e;e=a.iterateNext()}return d}function c(a){var b=da.getChildById(a.name,!0),d=null;if(b&&b.keys){d={fps:60,hierarchy:[{node:b,keys:b.keys,sids:b.sids}],node:a,name:"animation_"+a.name,length:0};cb.push(d);for(var e=0,g=b.keys.length;e<g;e++)d.length=Math.max(d.length,
-b.keys[e].time)}else d={hierarchy:[{keys:[],sids:[]}]};e=0;for(g=a.children.length;e<g;e++)for(var b=0,f=c(a.children[e]).hierarchy.length;b<f;b++)d.hierarchy.push({keys:[],sids:[]});return d}function d(a,b,c,e){a.world=a.world||new THREE.Matrix4;a.world.copy(a.matrix);if(a.channels&&a.channels.length){var g=a.channels[0].sampler.output[c];g instanceof THREE.Matrix4&&a.world.copy(g)}e&&a.world.multiply(e,a.world);b.push(a);for(e=0;e<a.nodes.length;e++)d(a.nodes[e],b,c,a.world)}function e(a,b,c){var e,
-g=Aa[b.url];if(!g||!g.skin)console.log("ColladaLoader: Could not find skin controller.");else if(!b.skeleton||!b.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{var c=1E6,f=-c,h=0;for(e in Fa)for(var i=Fa[e],j=0;j<i.sampler.length;j++){var m=i.sampler[j];m.create();c=Math.min(c,m.startTime);f=Math.max(f,m.endTime);h=Math.max(h,m.input.length)}e=h;for(var b=da.getChildById(b.skeleton[0],!0)||da.getChildBySid(b.skeleton[0],!0),k,l,f=new THREE.Vector3,n,
-j=0;j<a.vertices.length;j++)g.skin.bindShapeMatrix.multiplyVector3(a.vertices[j].position);for(c=0;c<e;c++){h=[];i=[];for(j=0;j<a.vertices.length;j++)i.push(new THREE.Vertex(new THREE.Vector3));d(b,h,c);j=h;m=g.skin;for(l=0;l<j.length;l++)if(k=j[l],n=-1,"JOINT"==k.type){for(var o=0;o<m.joints.length;o++)if(k.sid==m.joints[o]){n=o;break}if(0<=n){o=m.invBindMatrices[n];k.invBindMatrix=o;k.skinningMatrix=new THREE.Matrix4;k.skinningMatrix.multiply(k.world,o);k.weights=[];for(o=0;o<m.weights.length;o++)for(var p=
-0;p<m.weights[o].length;p++){var q=m.weights[o][p];q.joint==n&&k.weights.push(q)}}else throw"ColladaLoader: Could not find joint '"+k.sid+"'.";}for(j=0;j<h.length;j++)if("JOINT"==h[j].type)for(m=0;m<h[j].weights.length;m++)k=h[j].weights[m],l=k.index,k=k.weight,n=a.vertices[l],l=i[l],f.x=n.position.x,f.y=n.position.y,f.z=n.position.z,h[j].skinningMatrix.multiplyVector3(f),l.position.x+=f.x*k,l.position.y+=f.y*k,l.position.z+=f.z*k;a.morphTargets.push({name:"target_"+c,vertices:i})}}}function g(a){var b=
+animations:Fa,visualScenes:eb,scene:da}};d&&d(a);return a}function b(a,b,c){for(var a=T.evaluate(a,T,y,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),d={},e=a.iterateNext(),f=0;e;){e=(new b).parse(e);if(!e.id||0==e.id.length)e.id=c+f++;d[e.id]=e;e=a.iterateNext()}return d}function c(a){var b=da.getChildById(a.name,!0),d=null;if(b&&b.keys){d={fps:60,hierarchy:[{node:b,keys:b.keys,sids:b.sids}],node:a,name:"animation_"+a.name,length:0};cb.push(d);for(var e=0,f=b.keys.length;e<f;e++)d.length=Math.max(d.length,
+b.keys[e].time)}else d={hierarchy:[{keys:[],sids:[]}]};e=0;for(f=a.children.length;e<f;e++)for(var b=0,g=c(a.children[e]).hierarchy.length;b<g;b++)d.hierarchy.push({keys:[],sids:[]});return d}function d(a,b,c,e){a.world=a.world||new THREE.Matrix4;a.world.copy(a.matrix);if(a.channels&&a.channels.length){var f=a.channels[0].sampler.output[c];f instanceof THREE.Matrix4&&a.world.copy(f)}e&&a.world.multiply(e,a.world);b.push(a);for(e=0;e<a.nodes.length;e++)d(a.nodes[e],b,c,a.world)}function e(a,b,c){var e,
+f=Aa[b.url];if(!f||!f.skin)console.log("ColladaLoader: Could not find skin controller.");else if(!b.skeleton||!b.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{var c=1E6,g=-c,h=0;for(e in Fa)for(var i=Fa[e],j=0;j<i.sampler.length;j++){var m=i.sampler[j];m.create();c=Math.min(c,m.startTime);g=Math.max(g,m.endTime);h=Math.max(h,m.input.length)}e=h;for(var b=da.getChildById(b.skeleton[0],!0)||da.getChildBySid(b.skeleton[0],!0),k,l,g=new THREE.Vector3,n,
+j=0;j<a.vertices.length;j++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[j].position);for(c=0;c<e;c++){h=[];i=[];for(j=0;j<a.vertices.length;j++)i.push(new THREE.Vertex(new THREE.Vector3));d(b,h,c);j=h;m=f.skin;for(l=0;l<j.length;l++)if(k=j[l],n=-1,"JOINT"==k.type){for(var o=0;o<m.joints.length;o++)if(k.sid==m.joints[o]){n=o;break}if(0<=n){o=m.invBindMatrices[n];k.invBindMatrix=o;k.skinningMatrix=new THREE.Matrix4;k.skinningMatrix.multiply(k.world,o);k.weights=[];for(o=0;o<m.weights.length;o++)for(var p=
+0;p<m.weights[o].length;p++){var q=m.weights[o][p];q.joint==n&&k.weights.push(q)}}else throw"ColladaLoader: Could not find joint '"+k.sid+"'.";}for(j=0;j<h.length;j++)if("JOINT"==h[j].type)for(m=0;m<h[j].weights.length;m++)k=h[j].weights[m],l=k.index,k=k.weight,n=a.vertices[l],l=i[l],g.x=n.position.x,g.y=n.position.y,g.z=n.position.z,h[j].skinningMatrix.multiplyVector3(g),l.position.x+=g.x*k,l.position.y+=g.y*k,l.position.z+=g.z*k;a.morphTargets.push({name:"target_"+c,vertices:i})}}}function g(a){var b=
 new THREE.Object3D,c,d,f,h;for(f=0;f<a.controllers.length;f++){var i=Aa[a.controllers[f].url];switch(i.type){case "skin":if(ka[i.skin.source]){var j=new n;j.url=i.skin.source;j.instance_material=a.controllers[f].instance_material;a.geometries.push(j);c=a.controllers[f]}else if(Aa[i.skin.source]&&(d=i=Aa[i.skin.source],i.morph&&ka[i.morph.source]))j=new n,j.url=i.morph.source,j.instance_material=a.controllers[f].instance_material,a.geometries.push(j);break;case "morph":if(ka[i.morph.source])j=new n,
 j.url=i.morph.source,j.instance_material=a.controllers[f].instance_material,a.geometries.push(j),d=a.controllers[f];console.log("ColladaLoader: Morph-controller partially supported.")}}for(f=0;f<a.geometries.length;f++){var i=a.geometries[f],j=i.instance_material,i=ka[i.url],k={},m=[],l=0,p;if(i&&i.mesh&&i.mesh.primitives){if(0==b.name.length)b.name=i.id;if(j)for(h=0;h<j.length;h++){p=j[h];var q=bb[p.target],r=jb[q.instance_effect.url].shader;r.material.opacity=!r.material.opacity?1:r.material.opacity;
 k[p.symbol]=l;m.push(r.material);p=r.material;p.name=null==q.name||""===q.name?q.id:q.name;l++}j=p||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});i=i.mesh.geometry3js;if(1<l){j=new THREE.MeshFaceMaterial;i.materials=m;for(h=0;h<i.faces.length;h++)m=i.faces[h],m.materialIndex=k[m.daeMaterial]}if(void 0!==c)e(i,c),j.morphTargets=!0,j=new THREE.SkinnedMesh(i,j),j.skeleton=c.skeleton,j.skinController=Aa[c.url],j.skinInstanceController=c,j.name="skin_"+ra.length,ra.push(j);

+ 9 - 8
build/custom/ThreeExtras.js

@@ -9,13 +9,14 @@ f=b.vertices[a.b].position,g=b.vertices[a.c].position,THREE.GeometryUtils.random
 (c+e)<c?THREE.GeometryUtils.randomPointInTriangle(d,f,b):THREE.GeometryUtils.randomPointInTriangle(f,g,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var f=c+Math.floor((d-c)/2);return k[f]>a?b(c,f-1):k[f]<a?b(f+1,d):f}return b(0,k.length-1)}var d,f,g=a.faces,e=a.vertices,h=g.length,i=0,k=[],j,q,l,n;for(f=0;f<h;f++){d=g[f];if(d instanceof THREE.Face3)j=e[d.a].position,q=e[d.b].position,l=e[d.c].position,d._area=THREE.GeometryUtils.triangleArea(j,q,l);else if(d instanceof
 THREE.Face4)j=e[d.a].position,q=e[d.b].position,l=e[d.c].position,n=e[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(j,q,n),d._area2=THREE.GeometryUtils.triangleArea(q,l,n),d._area=d._area1+d._area2;i+=d._area;k[f]=i}d=[];for(f=0;f<b;f++)e=THREE.GeometryUtils.random()*i,e=c(e),d[f]=THREE.GeometryUtils.randomPointInFace(g[e],a,!0);return d},triangleArea:function(a,b,c){var d,f=THREE.GeometryUtils.__v1;f.sub(a,b);d=f.length();f.sub(a,c);a=f.length();f.sub(b,c);c=f.length();b=0.5*(d+a+c);return Math.sqrt(b*
 (b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();var b=a.boundingBox,c=new THREE.Vector3;c.add(b.min,b.max);c.multiplyScalar(-0.5);a.applyMatrix((new THREE.Matrix4).setTranslation(c.x,c.y,c.z));a.computeBoundingBox();return c},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],f=0,g=d.length;f<g;f++)1!==d[f].u&&(d[f].u-=Math.floor(d[f].u)),1!==d[f].v&&(d[f].v-=Math.floor(d[f].v))},triangulateQuads:function(a){for(var b=a.faces.length-1;0<=b;b--){var c=
-a.faces[b];if(c instanceof THREE.Face4){var d=c.a,f=c.b,g=c.c,e=c.d,h=c.clone(),c=c.clone();h.a=d;h.b=f;h.c=e;c.a=f;c.b=g;c.c=e;a.faces.splice(b,1,h,c);for(d=0;d<a.faceVertexUvs.length;d++)a.faceVertexUvs[d].length&&(h=a.faceVertexUvs[d][b],f=h[1],g=h[2],e=h[3],h=[h[0].clone(),f.clone(),e.clone()],f=[f.clone(),g.clone(),e.clone()],a.faceVertexUvs[d].splice(b,1,h,f));for(d=0;d<a.faceUvs.length;d++)a.faceUvs[d].length&&(f=a.faceUvs[d][b],a.faceUvs[d].splice(b,1,f,f))}}a.computeCentroids();a.computeFaceNormals();
-a.computeVertexNormals();a.hasTangents&&a.computeTangents()},explode:function(a){for(var b=[],c=0,d=a.faces.length;c<d;c++){var f=b.length,g=a.faces[c];if(g instanceof THREE.Face4){var e=g.a,h=g.b,i=g.c,e=a.vertices[e],h=a.vertices[h],i=a.vertices[i],k=a.vertices[g.d];b.push(e.clone());b.push(h.clone());b.push(i.clone());b.push(k.clone());g.a=f;g.b=f+1;g.c=f+2;g.d=f+3}else e=g.a,h=g.b,i=g.c,e=a.vertices[e],h=a.vertices[h],i=a.vertices[i],b.push(e.clone()),b.push(h.clone()),b.push(i.clone()),g.a=f,
-g.b=f+1,g.c=f+2}a.vertices=b},tessellate:function(a,b){var c,d,f,g,e,h,i,k,j,q,l,n,r,m,o,p,s;for(c=a.faces.length-1;0<=c;c--)if(d=a.faces[c],d instanceof THREE.Face3){if(f=d.a,g=d.b,e=d.c,i=a.vertices[f],k=a.vertices[g],j=a.vertices[e],l=i.position.distanceTo(k.position),n=k.position.distanceTo(j.position),q=i.position.distanceTo(j.position),l>b||n>b||q>b){h=a.vertices.length;s=d.clone();d=d.clone();l>=n&&l>=q?(i=i.clone(),i.position.lerpSelf(k.position,0.5),s.a=f,s.b=h,s.c=e,d.a=h,d.b=g,d.c=e,f=
-0):n>=l&&n>=q?(i=k.clone(),i.position.lerpSelf(j.position,0.5),s.a=f,s.b=g,s.c=h,d.a=h,d.b=e,d.c=f,f=1):(i=i.clone(),i.position.lerpSelf(j.position,0.5),s.a=f,s.b=g,s.c=h,d.a=h,d.b=g,d.c=e,f=2);a.faces.splice(c,1,s,d);a.vertices.push(i);for(g=0;g<a.faceVertexUvs.length;g++)a.faceVertexUvs[g].length&&(j=a.faceVertexUvs[g][c],k=j[0],e=j[1],i=j[2],0===f?(l=k.clone(),l.lerpSelf(e,0.5),j=[k.clone(),l.clone(),i.clone()],e=[l.clone(),e.clone(),i.clone()]):1===f?(l=e.clone(),l.lerpSelf(i,0.5),j=[k.clone(),
-e.clone(),l.clone()],e=[l.clone(),i.clone(),k.clone()]):(l=k.clone(),l.lerpSelf(i,0.5),j=[k.clone(),e.clone(),l.clone()],e=[l.clone(),e.clone(),i.clone()]),a.faceVertexUvs[g].splice(c,1,j,e))}}else if(f=d.a,g=d.b,e=d.c,h=d.d,i=a.vertices[f],k=a.vertices[g],j=a.vertices[e],q=a.vertices[h],l=i.position.distanceTo(k.position),n=k.position.distanceTo(j.position),r=j.position.distanceTo(q.position),m=i.position.distanceTo(q.position),l>b||n>b||r>b||m>b){o=a.vertices.length;p=a.vertices.length+1;s=d.clone();
-d=d.clone();l>=n&&l>=r&&l>=m||r>=n&&r>=l&&r>=m?(l=i.clone(),l.position.lerpSelf(k.position,0.5),k=j.clone(),k.position.lerpSelf(q.position,0.5),s.a=f,s.b=o,s.c=p,s.d=h,d.a=o,d.b=g,d.c=e,d.d=p,f=0):(l=k.clone(),l.position.lerpSelf(j.position,0.5),k=q.clone(),k.position.lerpSelf(i.position,0.5),s.a=f,s.b=g,s.c=o,s.d=p,d.a=p,d.b=o,d.c=e,d.d=h,f=1);a.faces.splice(c,1,s,d);a.vertices.push(l);a.vertices.push(k);for(g=0;g<a.faceVertexUvs.length;g++)a.faceVertexUvs[g].length&&(j=a.faceVertexUvs[g][c],k=j[0],
-e=j[1],i=j[2],j=j[3],0===f?(l=k.clone(),l.lerpSelf(e,0.5),n=i.clone(),n.lerpSelf(j,0.5),k=[k.clone(),l.clone(),n.clone(),j.clone()],e=[l.clone(),e.clone(),i.clone(),n.clone()]):(l=e.clone(),l.lerpSelf(i,0.5),n=j.clone(),n.lerpSelf(k,0.5),k=[k.clone(),e.clone(),l.clone(),n.clone()],e=[n.clone(),l.clone(),i.clone(),j.clone()]),a.faceVertexUvs[g].splice(c,1,k,e))}}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
+a.faces[b];if(c instanceof THREE.Face4){var d=c.a,f=c.b,g=c.c,e=c.d,h=new THREE.Face3,i=new THREE.Face3;h.color.copy(c.color);i.color.copy(c.color);h.materialIndex=c.materialIndex;i.materialIndex=c.materialIndex;h.a=d;h.b=f;h.c=e;i.a=f;i.b=g;i.c=e;4===c.vertexColors.length&&(h.vertexColors[0]=c.vertexColors[0].clone(),h.vertexColors[1]=c.vertexColors[1].clone(),h.vertexColors[2]=c.vertexColors[3].clone(),i.vertexColors[0]=c.vertexColors[1].clone(),i.vertexColors[1]=c.vertexColors[2].clone(),i.vertexColors[2]=
+c.vertexColors[3].clone());a.faces.splice(b,1,h,i);for(c=0;c<a.faceVertexUvs.length;c++)a.faceVertexUvs[c].length&&(e=a.faceVertexUvs[c][b],d=e[1],f=e[2],g=e[3],e=[e[0].clone(),d.clone(),g.clone()],d=[d.clone(),f.clone(),g.clone()],a.faceVertexUvs[c].splice(b,1,e,d));for(c=0;c<a.faceUvs.length;c++)a.faceUvs[c].length&&(d=a.faceUvs[c][b],a.faceUvs[c].splice(b,1,d,d))}}a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals();a.hasTangents&&a.computeTangents()},explode:function(a){for(var b=
+[],c=0,d=a.faces.length;c<d;c++){var f=b.length,g=a.faces[c];if(g instanceof THREE.Face4){var e=g.a,h=g.b,i=g.c,e=a.vertices[e],h=a.vertices[h],i=a.vertices[i],k=a.vertices[g.d];b.push(e.clone());b.push(h.clone());b.push(i.clone());b.push(k.clone());g.a=f;g.b=f+1;g.c=f+2;g.d=f+3}else e=g.a,h=g.b,i=g.c,e=a.vertices[e],h=a.vertices[h],i=a.vertices[i],b.push(e.clone()),b.push(h.clone()),b.push(i.clone()),g.a=f,g.b=f+1,g.c=f+2}a.vertices=b;delete a.__tmpVertices},tessellate:function(a,b){var c,d,f,g,
+e,h,i,k,j,q,l,n,r,m,o,p,s;for(c=a.faces.length-1;0<=c;c--)if(d=a.faces[c],d instanceof THREE.Face3){if(f=d.a,g=d.b,e=d.c,i=a.vertices[f],k=a.vertices[g],j=a.vertices[e],l=i.position.distanceTo(k.position),n=k.position.distanceTo(j.position),q=i.position.distanceTo(j.position),l>b||n>b||q>b){h=a.vertices.length;s=d.clone();d=d.clone();l>=n&&l>=q?(i=i.clone(),i.position.lerpSelf(k.position,0.5),s.a=f,s.b=h,s.c=e,d.a=h,d.b=g,d.c=e,f=0):n>=l&&n>=q?(i=k.clone(),i.position.lerpSelf(j.position,0.5),s.a=
+f,s.b=g,s.c=h,d.a=h,d.b=e,d.c=f,f=1):(i=i.clone(),i.position.lerpSelf(j.position,0.5),s.a=f,s.b=g,s.c=h,d.a=h,d.b=g,d.c=e,f=2);a.faces.splice(c,1,s,d);a.vertices.push(i);for(g=0;g<a.faceVertexUvs.length;g++)a.faceVertexUvs[g].length&&(j=a.faceVertexUvs[g][c],k=j[0],e=j[1],i=j[2],0===f?(l=k.clone(),l.lerpSelf(e,0.5),j=[k.clone(),l.clone(),i.clone()],e=[l.clone(),e.clone(),i.clone()]):1===f?(l=e.clone(),l.lerpSelf(i,0.5),j=[k.clone(),e.clone(),l.clone()],e=[l.clone(),i.clone(),k.clone()]):(l=k.clone(),
+l.lerpSelf(i,0.5),j=[k.clone(),e.clone(),l.clone()],e=[l.clone(),e.clone(),i.clone()]),a.faceVertexUvs[g].splice(c,1,j,e))}}else if(f=d.a,g=d.b,e=d.c,h=d.d,i=a.vertices[f],k=a.vertices[g],j=a.vertices[e],q=a.vertices[h],l=i.position.distanceTo(k.position),n=k.position.distanceTo(j.position),r=j.position.distanceTo(q.position),m=i.position.distanceTo(q.position),l>b||n>b||r>b||m>b){o=a.vertices.length;p=a.vertices.length+1;s=d.clone();d=d.clone();l>=n&&l>=r&&l>=m||r>=n&&r>=l&&r>=m?(l=i.clone(),l.position.lerpSelf(k.position,
+0.5),k=j.clone(),k.position.lerpSelf(q.position,0.5),s.a=f,s.b=o,s.c=p,s.d=h,d.a=o,d.b=g,d.c=e,d.d=p,f=0):(l=k.clone(),l.position.lerpSelf(j.position,0.5),k=q.clone(),k.position.lerpSelf(i.position,0.5),s.a=f,s.b=g,s.c=o,s.d=p,d.a=p,d.b=o,d.c=e,d.d=h,f=1);a.faces.splice(c,1,s,d);a.vertices.push(l);a.vertices.push(k);for(g=0;g<a.faceVertexUvs.length;g++)a.faceVertexUvs[g].length&&(j=a.faceVertexUvs[g][c],k=j[0],e=j[1],i=j[2],j=j[3],0===f?(l=k.clone(),l.lerpSelf(e,0.5),n=i.clone(),n.lerpSelf(j,0.5),
+k=[k.clone(),l.clone(),n.clone(),j.clone()],e=[l.clone(),e.clone(),i.clone(),n.clone()]):(l=e.clone(),l.lerpSelf(i,0.5),n=j.clone(),n.lerpSelf(k,0.5),k=[k.clone(),e.clone(),l.clone(),n.clone()],e=[n.clone(),l.clone(),i.clone(),j.clone()]),a.faceVertexUvs[g].splice(c,1,k,e))}}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
 THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(a,b,c){var d=new Image,f=new THREE.Texture(d,b);d.onload=function(){f.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return f},loadTextureCube:function(a,b,c){var d,f=[],g=new THREE.Texture(f,b);f.loadCount=0;for(b=0,d=a.length;b<d;++b)f[b]=new Image,f[b].onload=function(){f.loadCount+=1;if(6===f.loadCount)g.needsUpdate=!0;c&&c(this)},f[b].crossOrigin=this.crossOrigin,f[b].src=a[b];return g},getNormalMap:function(a,
 b){var c=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,f=a.height,g=document.createElement("canvas");g.width=d;g.height=f;var e=g.getContext("2d");e.drawImage(a,0,0);for(var h=e.getImageData(0,0,d,f).data,i=e.createImageData(d,f),k=i.data,j=0;j<d;j++)for(var q=1;q<f;q++){var l=0>q-1?f-1:q-1,n=(q+1)%f,r=0>j-1?d-1:j-1,m=(j+1)%d,o=[],p=[0,0,h[4*(q*d+j)]/255*b];o.push([-1,0,h[4*(q*d+r)]/255*b]);o.push([-1,-1,h[4*(l*d+r)]/255*b]);o.push([0,-1,
 h[4*(l*d+j)]/255*b]);o.push([1,-1,h[4*(l*d+m)]/255*b]);o.push([1,0,h[4*(q*d+m)]/255*b]);o.push([1,1,h[4*(n*d+m)]/255*b]);o.push([0,1,h[4*(n*d+j)]/255*b]);o.push([-1,1,h[4*(n*d+r)]/255*b]);l=[];r=o.length;for(n=0;n<r;n++){var m=o[n],s=o[(n+1)%r],m=[m[0]-p[0],m[1]-p[1],m[2]-p[2]],s=[s[0]-p[0],s[1]-p[1],s[2]-p[2]];l.push(c([m[1]*s[2]-m[2]*s[1],m[2]*s[0]-m[0]*s[2],m[0]*s[1]-m[1]*s[0]]))}o=[0,0,0];for(n=0;n<l.length;n++)o[0]+=l[n][0],o[1]+=l[n][1],o[2]+=l[n][2];o[0]/=l.length;o[1]/=l.length;o[2]/=l.length;
@@ -132,7 +133,7 @@ this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b)
 (b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*a;this.lookVertical&&(this.lat-=this.mouseY*a*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);b=this.target;c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);
 this.object.lookAt(b)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};
 THREE.PathControls=function(a,b){function c(a){return 1>(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function f(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),o=g.length,p=0;f=o-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f<o-1;f++)p=d*h.chunks[f]/h.total,b.keys[f]={time:p,pos:g[f]};e.hierarchy[0]=b;THREE.AnimationHandler.add(e);
-return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function g(a,b){var c,d,f=new THREE.Geometry;for(c=0;c<a.points.length*b;c++)d=c/(a.points.length*b),d=a.getPoint(d),f.vertices[c]=new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.z));return f}this.object=a;this.domElement=void 0!==b?b:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=
+return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function g(a,b){var c,d,e=new THREE.Geometry;for(c=0;c<a.points.length*b;c++)d=c/(a.points.length*b),d=a.getPoint(d),e.vertices[c]=new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.z));return e}this.object=a;this.domElement=void 0!==b?b:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=
 new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/
 2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var e=2*Math.PI,h=Math.PI/180;this.update=function(a){var b;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed*a);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed*a);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;a=this.phi%e;this.phi=0<=a?a:a+e;b=this.verticalAngleMap.srcRange;a=this.verticalAngleMap.dstRange;
 b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=function(a){this.domElement===

+ 21 - 2
src/extras/GeometryUtils.js

@@ -497,8 +497,14 @@ THREE.GeometryUtils = {
 				var c = face.c;
 				var d = face.d;
 
-				var triA = face.clone();
-				var triB = face.clone();
+				var triA = new THREE.Face3();
+				var triB = new THREE.Face3();
+
+				triA.color.copy( face.color );
+				triB.color.copy( face.color );
+
+				triA.materialIndex = face.materialIndex;
+				triB.materialIndex = face.materialIndex;
 
 				triA.a = a;
 				triA.b = b;
@@ -508,6 +514,18 @@ THREE.GeometryUtils = {
 				triB.b = c;
 				triB.c = d;
 
+				if ( face.vertexColors.length === 4 ) {
+
+					triA.vertexColors[ 0 ] = face.vertexColors[ 0 ].clone();
+					triA.vertexColors[ 1 ] = face.vertexColors[ 1 ].clone();
+					triA.vertexColors[ 2 ] = face.vertexColors[ 3 ].clone();
+
+					triB.vertexColors[ 0 ] = face.vertexColors[ 1 ].clone();
+					triB.vertexColors[ 1 ] = face.vertexColors[ 2 ].clone();
+					triB.vertexColors[ 2 ] = face.vertexColors[ 3 ].clone();
+
+				}
+
 				geometry.faces.splice( i, 1, triA, triB );
 
 				for ( var j = 0; j < geometry.faceVertexUvs.length; j ++ ) {
@@ -612,6 +630,7 @@ THREE.GeometryUtils = {
 		}
 
 		geometry.vertices = vertices;
+		delete geometry.__tmpVertices;
 
 	},