Bladeren bron

Set WebGLRenderer's default precision back to 'highp'. Added specifier to vertex shader too. Fixes #1602.

Mr.doob 13 jaren geleden
bovenliggende
commit
65c637109c
3 gewijzigde bestanden met toevoegingen van 63 en 60 verwijderingen
  1. 18 18
      build/Three.js
  2. 42 41
      build/custom/ThreeWebGL.js
  3. 3 1
      src/renderers/WebGLRenderer.js

+ 18 - 18
build/Three.js

@@ -2,7 +2,7 @@
 'use strict';var THREE=THREE||{REVISION:"49dev"};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;
 (function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var c=(new Date).getTime(),f=Math.max(0,16-(c-a)),g=window.setTimeout(function(){b(c+f)},f);a=c+f;return g};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
 function(a){clearTimeout(a)}})();THREE.Clock=function(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1};THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=!0};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=!1};THREE.Clock.prototype.getElapsedTime=function(){return this.elapsedTime+=this.getDelta()};
-THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.0010*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a};THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
+THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a};THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
 THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);
 this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,f;if(0===c)this.r=this.g=this.b=0;else switch(d=Math.floor(6*a),e=6*a-d,a=c*(1-b),f=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=f;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=f;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=f;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=
 Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},lerpSelf:function(a,b){this.r+=(a.r-this.r)*b;this.g+=(a.g-this.g)*b;this.b+=(a.b-this.b)*b;return this},getHex:function(){return Math.floor(255*this.r)<<16^Math.floor(255*this.g)<<8^Math.floor(255*this.b)},getContextStyle:function(){return"rgb("+Math.floor(255*this.r)+","+Math.floor(255*this.g)+","+Math.floor(255*this.b)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
@@ -81,7 +81,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo
 this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiply:function(a,
 b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,i=this.w,j=i*c+g*e-h*d,k=i*d+h*c-f*e,p=i*e+f*
 d-g*c,c=-f*c-g*d-h*e;b.x=j*i+c*-f+k*-h-p*-g;b.y=k*i+c*-g+p*-f-j*-h;b.z=p*i+c*-h+j*-g-k*-f;return b},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.001>Math.abs(e))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();for(b=0,c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();for(b=0,c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
 return a}};THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
@@ -270,7 +270,7 @@ l.TEXTURE_WRAP_S,z(b.wrapS)),l.texParameteri(a,l.TEXTURE_WRAP_T,z(b.wrapT)),l.te
 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 w(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return l.NEAREST;
 default:return l.LINEAR}}function z(a){switch(a){case THREE.RepeatWrapping:return l.REPEAT;case THREE.ClampToEdgeWrapping:return l.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return l.MIRRORED_REPEAT;case THREE.NearestFilter:return l.NEAREST;case THREE.NearestMipMapNearestFilter:return l.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return l.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return l.LINEAR;case THREE.LinearMipMapNearestFilter:return l.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return l.LINEAR_MIPMAP_LINEAR;
 case THREE.ByteType:return l.BYTE;case THREE.UnsignedByteType:return l.UNSIGNED_BYTE;case THREE.ShortType:return l.SHORT;case THREE.UnsignedShortType:return l.UNSIGNED_SHORT;case THREE.IntType:return l.INT;case THREE.UnsignedIntType:return l.UNSIGNED_INT;case THREE.FloatType:return l.FLOAT;case THREE.AlphaFormat:return l.ALPHA;case THREE.RGBFormat:return l.RGB;case THREE.RGBAFormat:return l.RGBA;case THREE.LuminanceFormat:return l.LUMINANCE;case THREE.LuminanceAlphaFormat:return l.LUMINANCE_ALPHA}return 0}
-var a=a||{},F=void 0!==a.canvas?a.canvas:document.createElement("canvas"),C=void 0!==a.precision?a.precision:"mediump",D=void 0!==a.alpha?a.alpha:!0,I=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,K=void 0!==a.antialias?a.antialias:!1,O=void 0!==a.stencil?a.stencil:!0,Q=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,L=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),B=void 0!==a.clearAlpha?a.clearAlpha:0,N=void 0!==a.maxLights?a.maxLights:4;this.domElement=
+var a=a||{},F=void 0!==a.canvas?a.canvas:document.createElement("canvas"),C=void 0!==a.precision?a.precision:"highp",D=void 0!==a.alpha?a.alpha:!0,I=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,K=void 0!==a.antialias?a.antialias:!1,O=void 0!==a.stencil?a.stencil:!0,Q=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,L=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),B=void 0!==a.clearAlpha?a.clearAlpha:0,N=void 0!==a.maxLights?a.maxLights:4;this.domElement=
 F;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapEnabled=this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.shadowMapCascade=this.shadowMapDebug=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=!0;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info=
 {memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var E=this,l,Y=[],G=null,y=null,T=-1,P=null,ea=null,ja=0,ha=null,R=null,Z=null,S=null,$=null,da=null,Ua=null,Ia=null,oa=null,Fa=0,Aa=0,ka=0,bb=0,jb=0,Va=0,cb=new THREE.Frustum,eb=new THREE.Matrix4,db=new THREE.Matrix4,Ga=new THREE.Vector4,ra=new THREE.Vector3,Ba={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};l=function(){var a;try{if(!(a=
 F.getContext("experimental-webgl",{alpha:D,premultipliedAlpha:I,antialias:K,stencil:O,preserveDrawingBuffer:Q})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();l.clearColor(0,0,0,1);l.clearDepth(1);l.clearStencil(0);l.enable(l.DEPTH_TEST);l.depthFunc(l.LEQUAL);l.frontFace(l.CCW);l.cullFace(l.BACK);
@@ -348,9 +348,9 @@ Ya.z,za+=3;else if(4===ta.size)for(Qa=0;Qa<oc;Qa++)Ya=ta.value[Qa],ta.array[za]=
 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 k,n;f=j=0;for(k=0,n=b.length;k<n;k++)e=b[k],e.onlyShadow||(e instanceof THREE.DirectionalLight&&f++,e instanceof THREE.PointLight&&j++,e instanceof THREE.SpotLight&&j++);j+f<=N?k=f:(k=Math.ceil(N*f/(j+f)),j=N-k);e=k;f=j;var m=0;for(j=0,k=b.length;j<k;j++)n=b[j],n.castShadow&&(n instanceof THREE.SpotLight&&m++,n instanceof THREE.DirectionalLight&&!n.shadowCascade&&m++);var o=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)o=d.bones.length;
 var p;a:{k=a.fragmentShader;n=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:m,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:d&&d.doubleSided},q,d=[];i?d.push(i):(d.push(k),d.push(n));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");
+shadowMapCascade:this.shadowMapCascade,maxShadows:m,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:d&&d.doubleSided},q,d=[];i?d.push(i):(d.push(k),d.push(n));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=["precision "+C+" float;",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");
 e=["precision "+C+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",E.gammaInput?"#define GAMMA_INPUT":"",E.gammaOutput?"#define GAMMA_OUTPUT":"",E.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?
 "#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");l.attachShader(q,u("fragment",e+k));
 l.attachShader(q,u("vertex",d+n));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++)k=r[d],q.uniforms[k]=l.getUniformLocation(q,
@@ -482,7 +482,7 @@ c)THREE.Quaternion.slerp(e,f,a.quaternion,d);else if("scl"===c)c=a.scale,c.x=e[0
 THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],e,f,g,h,i,j;e=(a.length-1)*b;f=Math.floor(e);e-=f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];i=a[c[2]];j=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],j[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],j[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],j[2],e,c,g);return d};
 THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c<d.length-1?c:d.length-1:c%d.length;c<d.length;c++)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?0<c?c:0:0<=c?c:c+d.length;0<=c;c--)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[d.length-1]};
-THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.0010;this.isPlaying=!1;this.loop=this.isPaused=!0;this.JITCompile=void 0!==c?c:!0;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var e=0;e<c.length;e++){var f=c[e],g=this.getNextKeyWith(f,a,0);g&&g.apply(f)}d.matrixAutoUpdate=!1;this.data.hierarchy[a].node.updateMatrix();
+THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.001;this.isPlaying=!1;this.loop=this.isPaused=!0;this.JITCompile=void 0!==c?c:!0;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var e=0;e<c.length;e++){var f=c[e],g=this.getNextKeyWith(f,a,0);g&&g.apply(f)}d.matrixAutoUpdate=!1;this.data.hierarchy[a].node.updateMatrix();
 d.matrixWorldNeedsUpdate=!0}}};
 THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=void 0!==a?a:!0;this.currentTime=void 0!==b?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,e,f;for(c=0;c<d;c++){e=this.hierarchy[c];f=this.data.hierarchy[c];e.useQuaternion=!0;if(void 0===f.animationCache)f.animationCache={},f.animationCache.prevKey=null,f.animationCache.nextKey=null,f.animationCache.originalMatrix=e instanceof THREE.Bone?e.skinMatrix:
 e.matrix;e=this.data.hierarchy[c].keys;if(e.length)f.animationCache.prevKey=e[0],f.animationCache.nextKey=e[1],this.startTime=Math.min(e[0].time,this.startTime),this.endTime=Math.max(e[e.length-1].time,this.endTime)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
@@ -501,7 +501,7 @@ THREE.CombinedCamera.prototype.toOrthographic=function(){var a=this.cameraP.aspe
 THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,b){var c=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};
 THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};
 THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};
-THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=void 0!==b?b:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
+THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=void 0!==b?b:document;this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
 0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=
 !0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=
 function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=
@@ -511,14 +511,14 @@ this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b)
 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:[]},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 f(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/
+new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/
 2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var g=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%g;this.phi=0<=a?a:a+g;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===
 document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}),
 c=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(g,b);a.position.set(0,10,0);this.animation=e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=e(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a=
 this.debugPath,b=this.spline,g=f(b,10),c=f(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),g=new THREE.Line(g,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));g.scale.set(1,1,1);a.add(g);c.scale.set(1,1,1);a.add(c);for(var g=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),o=0;o<b.points.length;o++)c=new THREE.Mesh(g,h),c.position.copy(b.points[o]),a.add(c)}this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),
 !1)}};THREE.PathControlsIdCounter=0;
-THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=void 0!==b?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
+THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=void 0!==b?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
 0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if("function"==typeof this[a.type])this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=
 1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=
 0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
@@ -562,7 +562,7 @@ K[y],g(Y[2],Y[1],Y[0],!0);for(y=0;y<G;y++)Y=K[y],g(Y[0]+l*o,Y[1]+l*o,Y[2]+l*o,!1
 THREE.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(a,b,c,d,e,f){b=a.vertices[e].position.x;e=a.vertices[e].position.y;c=a.vertices[f].position.x;f=a.vertices[f].position.y;return[new THREE.UV(a.vertices[d].position.x,1-a.vertices[d].position.y),new THREE.UV(b,1-e),new THREE.UV(c,1-f)]},generateBottomUV:function(a,b,c,d,e,f){return this.generateTopUV(a,b,c,d,e,f)},generateSideWallUV:function(a,b,c,d,e,f,g,h){var b=a.vertices[e].position.x,c=a.vertices[e].position.y,e=a.vertices[e].position.z,
 d=a.vertices[f].position.x,i=a.vertices[f].position.y,f=a.vertices[f].position.z,j=a.vertices[g].position.x,k=a.vertices[g].position.y,g=a.vertices[g].position.z,p=a.vertices[h].position.x,m=a.vertices[h].position.y,a=a.vertices[h].position.z;return 0.01>Math.abs(c-i)?[new THREE.UV(b,e),new THREE.UV(d,f),new THREE.UV(j,g),new THREE.UV(p,a)]:[new THREE.UV(c,e),new THREE.UV(i,f),new THREE.UV(k,g),new THREE.UV(m,a)]}};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;
 THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
-THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],d=[],e=[],f=[],g=(new THREE.Matrix4).setRotationZ(b),h=0;h<a.length;h++)this.vertices.push(new THREE.Vertex(a[h])),c[h]=a[h].clone(),d[h]=this.vertices.length-1;for(var i=0;i<=this.angle+0.0010;i+=b){for(h=0;h<c.length;h++)i<this.angle?(c[h]=g.multiplyVector3(c[h].clone()),this.vertices.push(new THREE.Vertex(c[h])),e[h]=this.vertices.length-1):e=f;0==i&&(f=d);
+THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],d=[],e=[],f=[],g=(new THREE.Matrix4).setRotationZ(b),h=0;h<a.length;h++)this.vertices.push(new THREE.Vertex(a[h])),c[h]=a[h].clone(),d[h]=this.vertices.length-1;for(var i=0;i<=this.angle+0.001;i+=b){for(h=0;h<c.length;h++)i<this.angle?(c[h]=g.multiplyVector3(c[h].clone()),this.vertices.push(new THREE.Vertex(c[h])),e[h]=this.vertices.length-1):e=f;0==i&&(f=d);
 for(h=0;h<d.length-1;h++)this.faces.push(new THREE.Face4(e[h],e[h+1],d[h+1],d[h])),this.faceVertexUvs[0].push([new THREE.UV(1-i/this.angle,h/a.length),new THREE.UV(1-i/this.angle,(h+1)/a.length),new THREE.UV(1-(i-b)/this.angle,(h+1)/a.length),new THREE.UV(1-(i-b)/this.angle,h/a.length)]);d=e;e=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
 THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);for(var e=a/2,f=b/2,c=c||1,d=d||1,g=c+1,h=d+1,i=a/c,j=b/d,k=new THREE.Vector3(0,1,0),a=0;a<h;a++)for(b=0;b<g;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*i-e,0,a*j-f)));for(a=0;a<d;a++)for(b=0;b<c;b++)e=new THREE.Face4(b+g*a,b+g*(a+1),b+1+g*(a+1),b+1+g*a),e.normal.copy(k),e.vertexNormals.push(k.clone(),k.clone(),k.clone(),k.clone()),this.faces.push(e),this.faceVertexUvs[0].push([new THREE.UV(b/c,a/d),new THREE.UV(b/c,(a+
 1)/d),new THREE.UV((b+1)/c,(a+1)/d),new THREE.UV((b+1)/c,a/d)]);this.computeCentroids()};THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
@@ -585,11 +585,11 @@ THREE.TorusKnotGeometry=function(a,b,c,d,e,f,g){function h(a,b,c,d,e,f){var g=Ma
 Array(this.segmentsT);for(b=0;b<this.segmentsT;++b){var i=2*(a/this.segmentsR)*this.p*Math.PI,g=2*(b/this.segmentsT)*Math.PI,f=h(i,g,this.q,this.p,this.radius,this.heightScale),i=h(i+0.01,g,this.q,this.p,this.radius,this.heightScale);c.sub(i,f);d.add(i,f);e.cross(c,d);d.cross(e,c);e.normalize();d.normalize();i=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);f.x+=i*d.x+g*e.x;f.y+=i*d.y+g*e.y;f.z+=i*d.z+g*e.z;this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z)))-1}}for(a=
 0;a<this.segmentsR;++a)for(b=0;b<this.segmentsT;++b){var e=(a+1)%this.segmentsR,f=(b+1)%this.segmentsT,c=this.grid[a][b],d=this.grid[e][b],e=this.grid[e][f],f=this.grid[a][f],g=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,f));this.faceVertexUvs[0].push([g,i,j,k])}this.computeCentroids();this.computeFaceNormals();
 this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;
-THREE.TubeGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);this.path=a;this.segments=b||64;this.radius=c||1;this.segmentsRadius=d||8;this.closed=e||!1;if(f)this.debug=new THREE.Object3D;this.grid=[];for(var b=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,b=new THREE.Vector3,h=new THREE.Matrix4,d=[],f=[],i=[],j=this.segments+1,k,p,m,o,a=0;a<j;a++)k=a/(j-1),d[a]=this.path.getTangentAt(k),d[a].normalize();f[0]=new THREE.Vector3;i[0]=new THREE.Vector3;a=Number.MAX_VALUE;k=Math.abs(d[0].x);
-p=Math.abs(d[0].y);m=Math.abs(d[0].z);k<=a&&(a=k,g.set(1,0,0));p<=a&&(a=p,g.set(0,1,0));m<=a&&g.set(0,0,1);b.cross(d[0],g).normalize();f[0].cross(d[0],b);i[0].cross(d[0],f[0]);for(a=1;a<j;a++)f[a]=f[a-1].clone(),i[a]=i[a-1].clone(),b.cross(d[a-1],d[a]),1.0E-4<b.length()&&(b.normalize(),g=Math.acos(d[a-1].dot(d[a])),h.setRotationAxis(b,g).multiplyVector3(f[a])),i[a].cross(d[a],f[a]);if(this.closed){g=Math.acos(f[0].dot(f[j-1]));g/=j-1;0<d[0].dot(b.cross(f[0],f[j-1]))&&(g=-g);for(a=1;a<j;a++)h.setRotationAxis(d[a],
-g*a).multiplyVector3(f[a]),i[a].cross(d[a],f[a])}for(a=0;a<j;a++){this.grid[a]=[];k=a/(j-1);k=this.path.getPointAt(k);b=d[a];g=f[a];h=i[a];this.debug&&(this.debug.add(new THREE.ArrowHelper(b,k,c,255)),this.debug.add(new THREE.ArrowHelper(g,k,c,16711680)),this.debug.add(new THREE.ArrowHelper(h,k,c,65280)));for(b=0;b<this.segmentsRadius;b++)m=2*(b/this.segmentsRadius)*Math.PI,p=-this.radius*Math.cos(m),m=this.radius*Math.sin(m),o=(new THREE.Vector3).copy(k),o.x+=p*g.x+m*h.x,o.y+=p*g.y+m*h.y,o.z+=p*
-g.z+m*h.z,this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o.x,o.y,o.z)))-1}for(a=0;a<this.segments;a++)for(b=0;b<this.segmentsRadius;b++)f=e?(a+1)%this.segments:a+1,i=(b+1)%this.segmentsRadius,c=this.grid[a][b],d=this.grid[f][b],f=this.grid[f][i],i=this.grid[a][i],j=new THREE.UV(a/this.segments,b/this.segmentsRadius),g=new THREE.UV((a+1)/this.segments,b/this.segmentsRadius),h=new THREE.UV((a+1)/this.segments,(b+1)/this.segmentsRadius),k=new THREE.UV(a/this.segments,(b+1)/this.segmentsRadius),
-this.faces.push(new THREE.Face4(c,d,f,i)),this.faceVertexUvs[0].push([j,g,h,k]);this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TubeGeometry.prototype=new THREE.Geometry;THREE.TubeGeometry.prototype.constructor=THREE.TubeGeometry;
+THREE.TubeGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);this.path=a;this.segments=b||64;this.radius=c||1;this.segmentsRadius=d||8;this.closed=e||!1;if(f)this.debug=new THREE.Object3D;this.grid=[];var b=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,b=new THREE.Vector3,h=new THREE.Matrix4,d=[],f=[],i=[],j=this.segments+1,k,p,m,o;this.tangents=d;this.normals=f;this.binormals=i;for(a=0;a<j;a++)k=a/(j-1),d[a]=this.path.getTangentAt(k),d[a].normalize();f[0]=new THREE.Vector3;i[0]=
+new THREE.Vector3;a=Number.MAX_VALUE;k=Math.abs(d[0].x);p=Math.abs(d[0].y);m=Math.abs(d[0].z);k<=a&&(a=k,g.set(1,0,0));p<=a&&(a=p,g.set(0,1,0));m<=a&&g.set(0,0,1);b.cross(d[0],g).normalize();f[0].cross(d[0],b);i[0].cross(d[0],f[0]);for(a=1;a<j;a++)f[a]=f[a-1].clone(),i[a]=i[a-1].clone(),b.cross(d[a-1],d[a]),1.0E-4<b.length()&&(b.normalize(),g=Math.acos(d[a-1].dot(d[a])),h.setRotationAxis(b,g).multiplyVector3(f[a])),i[a].cross(d[a],f[a]);if(this.closed){g=Math.acos(f[0].dot(f[j-1]));g/=j-1;0<d[0].dot(b.cross(f[0],
+f[j-1]))&&(g=-g);for(a=1;a<j;a++)h.setRotationAxis(d[a],g*a).multiplyVector3(f[a]),i[a].cross(d[a],f[a])}for(a=0;a<j;a++){this.grid[a]=[];k=a/(j-1);k=this.path.getPointAt(k);b=d[a];g=f[a];h=i[a];this.debug&&(this.debug.add(new THREE.ArrowHelper(b,k,c,255)),this.debug.add(new THREE.ArrowHelper(g,k,c,16711680)),this.debug.add(new THREE.ArrowHelper(h,k,c,65280)));for(b=0;b<this.segmentsRadius;b++)m=2*(b/this.segmentsRadius)*Math.PI,p=-this.radius*Math.cos(m),m=this.radius*Math.sin(m),o=(new THREE.Vector3).copy(k),
+o.x+=p*g.x+m*h.x,o.y+=p*g.y+m*h.y,o.z+=p*g.z+m*h.z,this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o.x,o.y,o.z)))-1}for(a=0;a<this.segments;a++)for(b=0;b<this.segmentsRadius;b++)f=e?(a+1)%this.segments:a+1,i=(b+1)%this.segmentsRadius,c=this.grid[a][b],d=this.grid[f][b],f=this.grid[f][i],i=this.grid[a][i],j=new THREE.UV(a/this.segments,b/this.segmentsRadius),g=new THREE.UV((a+1)/this.segments,b/this.segmentsRadius),h=new THREE.UV((a+1)/this.segments,(b+1)/this.segmentsRadius),
+k=new THREE.UV(a/this.segments,(b+1)/this.segmentsRadius),this.faces.push(new THREE.Face4(c,d,f,i)),this.faceVertexUvs[0].push([j,g,h,k]);this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TubeGeometry.prototype=new THREE.Geometry;THREE.TubeGeometry.prototype.constructor=THREE.TubeGeometry;
 THREE.PolyhedronGeometry=function(a,b,c,d){function e(a){var b=new THREE.Vertex(a.normalize());b.index=i.vertices.push(b)-1;var c=Math.atan2(a.z,-a.x)/2/Math.PI+0.5,a=Math.atan2(-a.y,Math.sqrt(a.x*a.x+a.z*a.z))/Math.PI+0.5;b.uv=new THREE.UV(c,a);return b}function f(a,b,c,d){1>d?(d=new THREE.Face3(a.index,b.index,c.index,[a.position.clone(),b.position.clone(),c.position.clone()]),d.centroid.addSelf(a.position).addSelf(b.position).addSelf(c.position).divideScalar(3),d.normal=d.centroid.clone().normalize(),
 i.faces.push(d),d=Math.atan2(d.centroid.z,-d.centroid.x),i.faceVertexUvs[0].push([h(a.uv,a.position,d),h(b.uv,b.position,d),h(c.uv,c.position,d)])):(d-=1,f(a,g(a,b),g(a,c),d),f(g(a,b),b,g(b,c),d),f(g(a,c),g(b,c),c,d),f(g(a,b),g(b,c),g(a,c),d))}function g(a,b){p[a.index]||(p[a.index]=[]);p[b.index]||(p[b.index]=[]);var c=p[a.index][b.index];void 0===c&&(p[a.index][b.index]=p[b.index][a.index]=c=e((new THREE.Vector3).add(a.position,b.position).divideScalar(2)));return c}function h(a,b,c){0>c&&1===a.u&&
 (a=new THREE.UV(a.u-1,a.v));0===b.x&&0===b.z&&(a=new THREE.UV(c/2/Math.PI+0.5,a.v));return a}THREE.Geometry.call(this);for(var c=c||1,d=d||0,i=this,j=0,k=a.length;j<k;j++)e(new THREE.Vector3(a[j][0],a[j][1],a[j][2]));for(var p=[],a=this.vertices,j=0,k=b.length;j<k;j++)f(a[b[j][0]],a[b[j][1]],a[b[j][2]],d);this.mergeVertices();j=0;for(k=this.vertices.length;j<k;j++)this.vertices[j].position.multiplyScalar(c);this.boundingSphere={radius:c}};THREE.PolyhedronGeometry.prototype=new THREE.Geometry;
@@ -787,8 +787,8 @@ b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b
 "color");m.scale=b.getUniformLocation(k,"scale");m.rotation=b.getUniformLocation(k,"rotation");m.screenPosition=b.getUniformLocation(k,"screenPosition");o=!1};this.render=function(a,d,e,s){var a=a.__webglFlares,u=a.length;if(u){var v=new THREE.Vector3,t=s/e,w=0.5*e,z=0.5*s,F=16/s,C=new THREE.Vector2(F*t,F),D=new THREE.Vector3(1,1,0),I=new THREE.Vector2(1,1),K=m,F=p;b.useProgram(k);o||(b.enableVertexAttribArray(p.vertex),b.enableVertexAttribArray(p.uv),o=!0);b.uniform1i(K.occlusionMap,0);b.uniform1i(K.map,
 1);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(F.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(F.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(!1);var O,Q,L,B,N;for(O=0;O<u;O++)if(F=16/s,C.set(F*t,F),B=a[O],v.set(B.matrixWorld.n14,B.matrixWorld.n24,B.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(v),d.projectionMatrix.multiplyVector3(v),D.copy(v),I.x=D.x*w+w,I.y=D.y*z+z,j||0<I.x&&I.x<e&&0<I.y&&I.y<s){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
 h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,I.x-8,I.y-8,16,16,0);b.uniform1i(K.renderType,0);b.uniform2f(K.scale,C.x,C.y);b.uniform3f(K.screenPosition,D.x,D.y,D.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,I.x-8,I.y-8,16,16,0);b.uniform1i(K.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,h);b.drawElements(b.TRIANGLES,
-6,b.UNSIGNED_SHORT,0);B.positionScreen.copy(D);B.customUpdateCallback?B.customUpdateCallback(B):B.updateLensFlares();b.uniform1i(K.renderType,2);b.enable(b.BLEND);for(Q=0,L=B.lensFlares.length;Q<L;Q++)if(N=B.lensFlares[Q],0.0010<N.opacity&&0.0010<N.scale)D.x=N.x,D.y=N.y,D.z=N.z,F=N.size*N.scale/s,C.x=F*t,C.y=F,b.uniform3f(K.screenPosition,D.x,D.y,D.z),b.uniform2f(K.scale,C.x,C.y),b.uniform1f(K.rotation,N.rotation),b.uniform1f(K.opacity,N.opacity),b.uniform3f(K.color,N.color.r,N.color.g,N.color.b),
-c.setBlending(N.blending),c.setTexture(N.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
+6,b.UNSIGNED_SHORT,0);B.positionScreen.copy(D);B.customUpdateCallback?B.customUpdateCallback(B):B.updateLensFlares();b.uniform1i(K.renderType,2);b.enable(b.BLEND);for(Q=0,L=B.lensFlares.length;Q<L;Q++)if(N=B.lensFlares[Q],0.001<N.opacity&&0.001<N.scale)D.x=N.x,D.y=N.y,D.z=N.z,F=N.size*N.scale/s,C.x=F*t,C.y=F,b.uniform3f(K.screenPosition,D.x,D.y,D.z),b.uniform2f(K.scale,C.x,C.y),b.uniform1f(K.rotation,N.rotation),b.uniform1f(K.opacity,N.opacity),b.uniform3f(K.color,N.color.r,N.color.g,N.color.b),c.setBlending(N.blending),
+c.setTexture(N.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
 THREE.ShadowMapPlugin=function(){var a,b,c,d,e=new THREE.Frustum,f=new THREE.Matrix4,g=new THREE.Vector3,h=new THREE.Vector3;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=function(a,
 c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(i,j){var k,p,m,o,q,n,r,s,u,v=[];o=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(k=0,p=i.__lights.length;k<p;k++)if(m=i.__lights[k],m.castShadow)if(m instanceof THREE.DirectionalLight&&m.shadowCascade)for(q=0;q<m.shadowCascadeCount;q++){var t;if(m.shadowCascadeArray[q])t=m.shadowCascadeArray[q];else{u=m;r=q;t=new THREE.DirectionalLight;t.isVirtual=
 !0;t.onlyShadow=!0;t.castShadow=!0;t.shadowCameraNear=u.shadowCameraNear;t.shadowCameraFar=u.shadowCameraFar;t.shadowCameraLeft=u.shadowCameraLeft;t.shadowCameraRight=u.shadowCameraRight;t.shadowCameraBottom=u.shadowCameraBottom;t.shadowCameraTop=u.shadowCameraTop;t.shadowCameraVisible=u.shadowCameraVisible;t.shadowDarkness=u.shadowDarkness;t.shadowBias=u.shadowCascadeBias[r];t.shadowMapWidth=u.shadowCascadeWidth[r];t.shadowMapHeight=u.shadowCascadeHeight[r];t.pointsWorld=[];t.pointsFrustum=[];s=

+ 42 - 41
build/custom/ThreeWebGL.js

@@ -20,11 +20,11 @@ a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){
 setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
 THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes;c[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);c[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);c[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);c[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);c[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);c[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;6>a;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))};
 THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),e=0;6>e;e++)if(a=b[e].x*c.n14+b[e].y*c.n24+b[e].z*c.n34+b[e].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3;
-THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);y=o.dot(b);w=p.add(a,s.copy(b).multiplyScalar(y));return N=c.distanceTo(w)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);s.sub(a,b);A=o.dot(o);u=o.dot(p);D=o.dot(s);I=p.dot(p);E=p.dot(s);L=1/(A*I-u*u);K=(I*D-u*E)*L;M=(A*E-u*D)*L;return 0<=K&&0<=M&&1>K+M}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;var e=1.0E-4;this.setPrecision=function(a){e=a};var g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,m=new THREE.Vector3,
+THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);y=o.dot(b);w=p.add(a,s.copy(b).multiplyScalar(y));return N=c.distanceTo(w)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);s.sub(a,b);A=o.dot(o);u=o.dot(p);E=o.dot(s);I=p.dot(p);D=p.dot(s);L=1/(A*I-u*u);K=(I*E-u*D)*L;M=(A*D-u*E)*L;return 0<=K&&0<=M&&1>K+M}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;var e=1.0E-4;this.setPrecision=function(a){e=a};var g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,m=new THREE.Vector3,
 k=new THREE.Vector3,j=new THREE.Vector3,n=new THREE.Vector3,l=new THREE.Vector3,q=new THREE.Vector3;this.intersectObject=function(a){var b,o=[];if(a instanceof THREE.Particle){var p=c(this.origin,this.direction,a.matrixWorld.getPosition());if(p>a.scale.x)return[];b={distance:p,point:a.position,face:null,object:a};o.push(b)}else if(a instanceof THREE.Mesh){var p=c(this.origin,this.direction,a.matrixWorld.getPosition()),s=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),
 a.matrixWorld.getColumnZ().length());if(p>a.geometry.boundingSphere.radius*Math.max(s.x,Math.max(s.y,s.z)))return o;var u,f,y=a.geometry,w=y.vertices,A;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(p=0,s=y.faces.length;p<s;p++)if(b=y.faces[p],k.copy(this.origin),j.copy(this.direction),A=a.matrixWorld,n=A.multiplyVector3(n.copy(b.centroid)).subSelf(k),l=a.matrixRotationWorld.multiplyVector3(l.copy(b.normal)),u=j.dot(l),!(Math.abs(u)<e)&&(f=l.dot(n)/u,!(0>f)&&(a.doubleSided||(a.flipSided?
 0<u:0>u))))if(q.add(k,j.multiplyScalar(f)),b instanceof THREE.Face3)g=A.multiplyVector3(g.copy(w[b.a].position)),h=A.multiplyVector3(h.copy(w[b.b].position)),i=A.multiplyVector3(i.copy(w[b.c].position)),d(q,g,h,i)&&(b={distance:k.distanceTo(q),point:q.clone(),face:b,object:a},o.push(b));else if(b instanceof THREE.Face4&&(g=A.multiplyVector3(g.copy(w[b.a].position)),h=A.multiplyVector3(h.copy(w[b.b].position)),i=A.multiplyVector3(i.copy(w[b.c].position)),m=A.multiplyVector3(m.copy(w[b.d].position)),
-d(q,g,h,m)||d(q,h,i,m)))b={distance:k.distanceTo(q),point:q.clone(),face:b,object:a},o.push(b)}return o};this.intersectObjects=function(a){for(var b=[],c=0,d=a.length;c<d;c++)Array.prototype.push.apply(b,this.intersectObject(a[c]));b.sort(function(a,b){return a.distance-b.distance});return b};var o=new THREE.Vector3,p=new THREE.Vector3,s=new THREE.Vector3,y,w,N,A,u,D,I,E,L,K,M};
+d(q,g,h,m)||d(q,h,i,m)))b={distance:k.distanceTo(q),point:q.clone(),face:b,object:a},o.push(b)}return o};this.intersectObjects=function(a){for(var b=[],c=0,d=a.length;c<d;c++)Array.prototype.push.apply(b,this.intersectObject(a[c]));b.sort(function(a,b){return a.distance-b.distance});return b};var o=new THREE.Vector3,p=new THREE.Vector3,s=new THREE.Vector3,y,w,N,A,u,E,I,D,L,K,M};
 THREE.Rectangle=function(){function a(){g=d-b;h=e-c}var b,c,d,e,g,h,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,h,j,n){i=!1;b=g;c=h;d=j;e=n;a()};this.addPoint=function(g,h){i?(i=!1,b=g,c=h,d=g,e=h):(b=b<g?b:g,c=c<h?c:h,d=d>g?d:g,e=e>h?e:h);a()};this.add3Points=
 function(g,h,j,n,l,q){i?(i=!1,b=g<j?g<l?g:l:j<l?j:l,c=h<n?h<q?h:q:n<q?n:q,d=g>j?g>l?g:l:j>l?j:l,e=h>n?h>q?h:q:n>q?n:q):(b=g<j?g<l?g<b?g:b:l<b?l:b:j<l?j<b?j:b:l<b?l:b,c=h<n?h<q?h<c?h:c:q<c?q:c:n<q?n<c?n:c:q<c?q:c,d=g>j?g>l?g>d?g:d:l>d?l:d:j>l?j>d?j:d:l>d?l:d,e=h>n?h>q?h>e?h:e:q>e?q:e:n>q?n>e?n:e:q>e?q:e);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),e=g.getBottom()):(b=b<g.getLeft()?b:g.getLeft(),c=c<g.getTop()?c:g.getTop(),d=d>g.getRight()?d:g.getRight(),e=e>
 g.getBottom()?e:g.getBottom());a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();e=e<g.getBottom()?e:g.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||e<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}};
@@ -32,7 +32,7 @@ THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b
 THREE.Matrix3.prototype={constructor:THREE.Matrix3,transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,g,h,i,m,k,j,n,l,q,o,p){this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==g?g:1,h||0,i||0,m||0,k||0,void 0!==j?j:1,n||0,l||0,q||0,o||0,void 0!==p?p:1);this.m33=new THREE.Matrix3};
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,h,i,m,k,j,n,l,q,o,p){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=i;this.n31=m;this.n32=k;this.n33=j;this.n34=n;this.n41=l;this.n42=q;this.n43=o;this.n44=p;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
 b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(0===g.length())g.z=1;d.cross(c,g).normalize();0===d.length()&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d);this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,i=a.n22,m=a.n23,k=a.n24,j=a.n31,n=a.n32,l=a.n33,q=a.n34,o=a.n41,p=a.n42,s=a.n43,y=a.n44,w=b.n11,
-N=b.n12,A=b.n13,u=b.n14,D=b.n21,I=b.n22,E=b.n23,L=b.n24,K=b.n31,M=b.n32,ja=b.n33,oa=b.n34,ka=b.n41,X=b.n42,$=b.n43,C=b.n44;this.n11=c*w+d*D+e*K+g*ka;this.n12=c*N+d*I+e*M+g*X;this.n13=c*A+d*E+e*ja+g*$;this.n14=c*u+d*L+e*oa+g*C;this.n21=h*w+i*D+m*K+k*ka;this.n22=h*N+i*I+m*M+k*X;this.n23=h*A+i*E+m*ja+k*$;this.n24=h*u+i*L+m*oa+k*C;this.n31=j*w+n*D+l*K+q*ka;this.n32=j*N+n*I+l*M+q*X;this.n33=j*A+n*E+l*ja+q*$;this.n34=j*u+n*L+l*oa+q*C;this.n41=o*w+p*D+s*K+y*ka;this.n42=o*N+p*I+s*M+y*X;this.n43=o*A+p*E+s*
+N=b.n12,A=b.n13,u=b.n14,E=b.n21,I=b.n22,D=b.n23,L=b.n24,K=b.n31,M=b.n32,ja=b.n33,oa=b.n34,ka=b.n41,X=b.n42,$=b.n43,C=b.n44;this.n11=c*w+d*E+e*K+g*ka;this.n12=c*N+d*I+e*M+g*X;this.n13=c*A+d*D+e*ja+g*$;this.n14=c*u+d*L+e*oa+g*C;this.n21=h*w+i*E+m*K+k*ka;this.n22=h*N+i*I+m*M+k*X;this.n23=h*A+i*D+m*ja+k*$;this.n24=h*u+i*L+m*oa+k*C;this.n31=j*w+n*E+l*K+q*ka;this.n32=j*N+n*I+l*M+q*X;this.n33=j*A+n*D+l*ja+q*$;this.n34=j*u+n*L+l*oa+q*C;this.n41=o*w+p*E+s*K+y*ka;this.n42=o*N+p*I+s*M+y*X;this.n43=o*A+p*D+s*
 ja+y*$;this.n44=o*u+p*L+s*oa+y*C;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
 a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*
 c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*
@@ -49,7 +49,7 @@ a.x,c=a.y,d=a.z,e=a.w,g=b+b,h=c+c,i=d+d,a=b*g,m=b*h,b=b*i,k=c*h,c=c*i,d=d*i,g=e*
 d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);g.set(this.n13,this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();
 c.y=e.length();c.z=g.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=
 a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this},rotateByAxis:function(a,b){if(1===a.x&&0===a.y&&0===a.z)return this.rotateX(b);if(0===a.x&&1===a.y&&0===a.z)return this.rotateY(b);if(0===a.x&&0===a.y&&1===a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,g=Math.sqrt(c*c+d*d+e*e),c=c/g,d=d/g,e=e/g,g=c*c,h=d*d,i=e*e,m=Math.cos(b),k=Math.sin(b),j=1-m,n=c*d*j,l=c*e*j,j=d*e*j,c=c*k,q=d*k,k=e*k,e=
-g+(1-g)*m,g=n+k,d=l-q,n=n-k,h=h+(1-h)*m,k=j+c,l=l+q,j=j-c,i=i+(1-i)*m,m=this.n11,c=this.n21,q=this.n31,o=this.n41,p=this.n12,s=this.n22,y=this.n32,w=this.n42,N=this.n13,A=this.n23,u=this.n33,D=this.n43;this.n11=e*m+g*p+d*N;this.n21=e*c+g*s+d*A;this.n31=e*q+g*y+d*u;this.n41=e*o+g*w+d*D;this.n12=n*m+h*p+k*N;this.n22=n*c+h*s+k*A;this.n32=n*q+h*y+k*u;this.n42=n*o+h*w+k*D;this.n13=l*m+j*p+i*N;this.n23=l*c+j*s+i*A;this.n33=l*q+j*y+i*u;this.n43=l*o+j*w+i*D;return this},rotateX:function(a){var b=this.n12,
+g+(1-g)*m,g=n+k,d=l-q,n=n-k,h=h+(1-h)*m,k=j+c,l=l+q,j=j-c,i=i+(1-i)*m,m=this.n11,c=this.n21,q=this.n31,o=this.n41,p=this.n12,s=this.n22,y=this.n32,w=this.n42,N=this.n13,A=this.n23,u=this.n33,E=this.n43;this.n11=e*m+g*p+d*N;this.n21=e*c+g*s+d*A;this.n31=e*q+g*y+d*u;this.n41=e*o+g*w+d*E;this.n12=n*m+h*p+k*N;this.n22=n*c+h*s+k*A;this.n32=n*q+h*y+k*u;this.n42=n*o+h*w+k*E;this.n13=l*m+j*p+i*N;this.n23=l*c+j*s+i*A;this.n33=l*q+j*y+i*u;this.n43=l*o+j*w+i*E;return this},rotateX:function(a){var b=this.n12,
 c=this.n22,d=this.n32,e=this.n42,g=this.n13,h=this.n23,i=this.n33,m=this.n43,k=Math.cos(a),a=Math.sin(a);this.n12=k*b+a*g;this.n22=k*c+a*h;this.n32=k*d+a*i;this.n42=k*e+a*m;this.n13=k*g-a*b;this.n23=k*h-a*c;this.n33=k*i-a*d;this.n43=k*m-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,g=this.n13,h=this.n23,i=this.n33,m=this.n43,k=Math.cos(a),a=Math.sin(a);this.n11=k*b-a*g;this.n21=k*c-a*h;this.n31=k*d-a*i;this.n41=k*e-a*m;this.n13=k*g+a*b;this.n23=k*h+a*c;this.n33=
 k*i+a*d;this.n43=k*m+a*e;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,g=this.n12,h=this.n22,i=this.n32,m=this.n42,k=Math.cos(a),a=Math.sin(a);this.n11=k*b+a*g;this.n21=k*c+a*h;this.n31=k*d+a*i;this.n41=k*e+a*m;this.n12=k*g-a*b;this.n22=k*h-a*c;this.n32=k*i-a*d;this.n42=k*m-a*e;return this},translate:function(a){var b=a.x,c=a.y,a=a.z;this.n14=this.n11*b+this.n12*c+this.n13*a+this.n14;this.n24=this.n21*b+this.n22*c+this.n23*a+this.n24;this.n34=this.n31*b+this.n32*
 c+this.n33*a+this.n34;this.n44=this.n41*b+this.n42*c+this.n43*a+this.n44;return this},clone:function(){return new THREE.Matrix4(this.n11,this.n12,this.n13,this.n14,this.n21,this.n22,this.n23,this.n24,this.n31,this.n32,this.n33,this.n34,this.n41,this.n42,this.n43,this.n44)}};
@@ -64,23 +64,23 @@ this.children.indexOf(a);if(-1!==b){a.parent=void 0;this.children.splice(b,1);fo
 this.eulerOrder);if(1!==this.scale.x||1!==this.scale.y||1!==this.scale.z)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<
 c;b++)this.children[b].updateMatrixWorld(a)}};THREE.Object3DCount=0;
 THREE.Projector=function(){function a(){var a=h[g]=h[g]||new THREE.RenderableObject;g++;return a}function b(){var a=k[m]=k[m]||new THREE.RenderableVertex;m++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d<c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}
-var e,g,h=[],i,m,k=[],j,n,l=[],q,o=[],p,s,y=[],w,N,A=[],u={objects:[],sprites:[],lights:[],elements:[]},D=new THREE.Vector3,I=new THREE.Vector4,E=new THREE.Matrix4,L=new THREE.Matrix4,K=new THREE.Frustum,M=new THREE.Vector4,ja=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);E.multiply(b.projectionMatrix,b.matrixWorldInverse);E.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);E.multiply(b.matrixWorld,
-b.projectionMatrixInverse);E.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){g=0;u.objects.length=0;u.sprites.length=0;u.lights.length=0;var h=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||K.contains(b))?(D.copy(b.matrixWorld.getPosition()),E.multiplyVector3(D),
-e=a(),e.object=b,e.z=D.z,u.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(D.copy(b.matrixWorld.getPosition()),E.multiplyVector3(D),e=a(),e.object=b,e.z=D.z,u.sprites.push(e)):b instanceof THREE.Light&&u.lights.push(b);for(var c=0,f=b.children.length;c<f;c++)h(b.children[c])}};h(b);d&&u.objects.sort(c);return u};this.projectScene=function(a,e,g){var h=e.near,C=e.far,f=!1,D,Ba,S,sa,J,aa,ta,xa,T,Aa,Ga,Ha,Sa,Wa,Ma;N=s=q=n=0;u.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
-a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);E.multiply(e.projectionMatrix,e.matrixWorldInverse);K.setFromMatrix(E);u=this.projectGraph(a,!1);for(a=0,D=u.objects.length;a<D;a++)if(T=u.objects[a].object,Aa=T.matrixWorld,m=0,T instanceof THREE.Mesh){Ga=T.geometry;Ha=T.geometry.materials;sa=Ga.vertices;Sa=Ga.faces;Wa=Ga.faceVertexUvs;Ga=T.matrixRotationWorld.extractRotation(Aa);for(Ba=0,S=sa.length;Ba<S;Ba++)i=b(),i.positionWorld.copy(sa[Ba].position),Aa.multiplyVector3(i.positionWorld),
-i.positionScreen.copy(i.positionWorld),E.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,i.visible=i.positionScreen.z>h&&i.positionScreen.z<C;for(sa=0,Ba=Sa.length;sa<Ba;sa++){S=Sa[sa];if(S instanceof THREE.Face3)if(J=k[S.a],aa=k[S.b],ta=k[S.c],J.visible&&aa.visible&&ta.visible)if(f=0>(ta.positionScreen.x-J.positionScreen.x)*(aa.positionScreen.y-J.positionScreen.y)-(ta.positionScreen.y-J.positionScreen.y)*(aa.positionScreen.x-J.positionScreen.x),
+var e,g,h=[],i,m,k=[],j,n,l=[],q,o=[],p,s,y=[],w,N,A=[],u={objects:[],sprites:[],lights:[],elements:[]},E=new THREE.Vector3,I=new THREE.Vector4,D=new THREE.Matrix4,L=new THREE.Matrix4,K=new THREE.Frustum,M=new THREE.Vector4,ja=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);D.multiply(b.projectionMatrix,b.matrixWorldInverse);D.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);D.multiply(b.matrixWorld,
+b.projectionMatrixInverse);D.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){g=0;u.objects.length=0;u.sprites.length=0;u.lights.length=0;var h=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||K.contains(b))?(E.copy(b.matrixWorld.getPosition()),D.multiplyVector3(E),
+e=a(),e.object=b,e.z=E.z,u.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(E.copy(b.matrixWorld.getPosition()),D.multiplyVector3(E),e=a(),e.object=b,e.z=E.z,u.sprites.push(e)):b instanceof THREE.Light&&u.lights.push(b);for(var c=0,f=b.children.length;c<f;c++)h(b.children[c])}};h(b);d&&u.objects.sort(c);return u};this.projectScene=function(a,e,g){var h=e.near,C=e.far,f=!1,E,Ba,S,sa,J,aa,ta,xa,T,Aa,Ga,Ha,Sa,Wa,Ma;N=s=q=n=0;u.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
+a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);D.multiply(e.projectionMatrix,e.matrixWorldInverse);K.setFromMatrix(D);u=this.projectGraph(a,!1);for(a=0,E=u.objects.length;a<E;a++)if(T=u.objects[a].object,Aa=T.matrixWorld,m=0,T instanceof THREE.Mesh){Ga=T.geometry;Ha=T.geometry.materials;sa=Ga.vertices;Sa=Ga.faces;Wa=Ga.faceVertexUvs;Ga=T.matrixRotationWorld.extractRotation(Aa);for(Ba=0,S=sa.length;Ba<S;Ba++)i=b(),i.positionWorld.copy(sa[Ba].position),Aa.multiplyVector3(i.positionWorld),
+i.positionScreen.copy(i.positionWorld),D.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,i.visible=i.positionScreen.z>h&&i.positionScreen.z<C;for(sa=0,Ba=Sa.length;sa<Ba;sa++){S=Sa[sa];if(S instanceof THREE.Face3)if(J=k[S.a],aa=k[S.b],ta=k[S.c],J.visible&&aa.visible&&ta.visible)if(f=0>(ta.positionScreen.x-J.positionScreen.x)*(aa.positionScreen.y-J.positionScreen.y)-(ta.positionScreen.y-J.positionScreen.y)*(aa.positionScreen.x-J.positionScreen.x),
 T.doubleSided||f!=T.flipSided)xa=l[n]=l[n]||new THREE.RenderableFace3,n++,j=xa,j.v1.copy(J),j.v2.copy(aa),j.v3.copy(ta);else continue;else continue;else if(S instanceof THREE.Face4)if(J=k[S.a],aa=k[S.b],ta=k[S.c],xa=k[S.d],J.visible&&aa.visible&&ta.visible&&xa.visible)if(f=0>(xa.positionScreen.x-J.positionScreen.x)*(aa.positionScreen.y-J.positionScreen.y)-(xa.positionScreen.y-J.positionScreen.y)*(aa.positionScreen.x-J.positionScreen.x)||0>(aa.positionScreen.x-ta.positionScreen.x)*(xa.positionScreen.y-
-ta.positionScreen.y)-(aa.positionScreen.y-ta.positionScreen.y)*(xa.positionScreen.x-ta.positionScreen.x),T.doubleSided||f!=T.flipSided)Ma=o[q]=o[q]||new THREE.RenderableFace4,q++,j=Ma,j.v1.copy(J),j.v2.copy(aa),j.v3.copy(ta),j.v4.copy(xa);else continue;else continue;j.normalWorld.copy(S.normal);!f&&(T.flipSided||T.doubleSided)&&j.normalWorld.negate();Ga.multiplyVector3(j.normalWorld);j.centroidWorld.copy(S.centroid);Aa.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);E.multiplyVector3(j.centroidScreen);
-ta=S.vertexNormals;for(J=0,aa=ta.length;J<aa;J++)xa=j.vertexNormalsWorld[J],xa.copy(ta[J]),!f&&(T.flipSided||T.doubleSided)&&xa.negate(),Ga.multiplyVector3(xa);for(J=0,aa=Wa.length;J<aa;J++)if(Ma=Wa[J][sa])for(ta=0,xa=Ma.length;ta<xa;ta++)j.uvs[J][ta]=Ma[ta];j.material=T.material;j.faceMaterial=null!==S.materialIndex?Ha[S.materialIndex]:null;j.z=j.centroidScreen.z;u.elements.push(j)}}else if(T instanceof THREE.Line){L.multiply(E,Aa);sa=T.geometry.vertices;J=b();J.positionScreen.copy(sa[0].position);
-L.multiplyVector4(J.positionScreen);for(Ba=1,S=sa.length;Ba<S;Ba++)if(J=b(),J.positionScreen.copy(sa[Ba].position),L.multiplyVector4(J.positionScreen),aa=k[m-2],M.copy(J.positionScreen),ja.copy(aa.positionScreen),d(M,ja))M.multiplyScalar(1/M.w),ja.multiplyScalar(1/ja.w),Aa=y[s]=y[s]||new THREE.RenderableLine,s++,p=Aa,p.v1.positionScreen.copy(M),p.v2.positionScreen.copy(ja),p.z=Math.max(M.z,ja.z),p.material=T.material,u.elements.push(p)}for(a=0,D=u.sprites.length;a<D;a++)if(T=u.sprites[a].object,Aa=
-T.matrixWorld,T instanceof THREE.Particle&&(I.set(Aa.n14,Aa.n24,Aa.n34,1),E.multiplyVector4(I),I.z/=I.w,0<I.z&&1>I.z))h=A[N]=A[N]||new THREE.RenderableParticle,N++,w=h,w.x=I.x/I.w,w.y=I.y/I.w,w.z=I.z,w.rotation=T.rotation.z,w.scale.x=T.scale.x*Math.abs(w.x-(I.x+e.projectionMatrix.n11)/(I.w+e.projectionMatrix.n14)),w.scale.y=T.scale.y*Math.abs(w.y-(I.y+e.projectionMatrix.n22)/(I.w+e.projectionMatrix.n24)),w.material=T.material,u.elements.push(w);g&&u.elements.sort(c);return u}};
+ta.positionScreen.y)-(aa.positionScreen.y-ta.positionScreen.y)*(xa.positionScreen.x-ta.positionScreen.x),T.doubleSided||f!=T.flipSided)Ma=o[q]=o[q]||new THREE.RenderableFace4,q++,j=Ma,j.v1.copy(J),j.v2.copy(aa),j.v3.copy(ta),j.v4.copy(xa);else continue;else continue;j.normalWorld.copy(S.normal);!f&&(T.flipSided||T.doubleSided)&&j.normalWorld.negate();Ga.multiplyVector3(j.normalWorld);j.centroidWorld.copy(S.centroid);Aa.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);D.multiplyVector3(j.centroidScreen);
+ta=S.vertexNormals;for(J=0,aa=ta.length;J<aa;J++)xa=j.vertexNormalsWorld[J],xa.copy(ta[J]),!f&&(T.flipSided||T.doubleSided)&&xa.negate(),Ga.multiplyVector3(xa);for(J=0,aa=Wa.length;J<aa;J++)if(Ma=Wa[J][sa])for(ta=0,xa=Ma.length;ta<xa;ta++)j.uvs[J][ta]=Ma[ta];j.material=T.material;j.faceMaterial=null!==S.materialIndex?Ha[S.materialIndex]:null;j.z=j.centroidScreen.z;u.elements.push(j)}}else if(T instanceof THREE.Line){L.multiply(D,Aa);sa=T.geometry.vertices;J=b();J.positionScreen.copy(sa[0].position);
+L.multiplyVector4(J.positionScreen);for(Ba=1,S=sa.length;Ba<S;Ba++)if(J=b(),J.positionScreen.copy(sa[Ba].position),L.multiplyVector4(J.positionScreen),aa=k[m-2],M.copy(J.positionScreen),ja.copy(aa.positionScreen),d(M,ja))M.multiplyScalar(1/M.w),ja.multiplyScalar(1/ja.w),Aa=y[s]=y[s]||new THREE.RenderableLine,s++,p=Aa,p.v1.positionScreen.copy(M),p.v2.positionScreen.copy(ja),p.z=Math.max(M.z,ja.z),p.material=T.material,u.elements.push(p)}for(a=0,E=u.sprites.length;a<E;a++)if(T=u.sprites[a].object,Aa=
+T.matrixWorld,T instanceof THREE.Particle&&(I.set(Aa.n14,Aa.n24,Aa.n34,1),D.multiplyVector4(I),I.z/=I.w,0<I.z&&1>I.z))h=A[N]=A[N]||new THREE.RenderableParticle,N++,w=h,w.x=I.x/I.w,w.y=I.y/I.w,w.z=I.z,w.rotation=T.rotation.z,w.scale.x=T.scale.x*Math.abs(w.x-(I.x+e.projectionMatrix.n11)/(I.w+e.projectionMatrix.n14)),w.scale.y=T.scale.y*Math.abs(w.y-(I.y+e.projectionMatrix.n22)/(I.w+e.projectionMatrix.n24)),w.material=T.material,u.elements.push(w);g&&u.elements.sort(c);return u}};
 THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),h=a*b,i=d*e;this.w=h*g-i*c;this.x=h*c+i*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-Math.abs(this.z):Math.abs(this.z);
 this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiply:function(a,
 b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,g=a.x,h=a.y,i=a.z,a=a.w;this.x=b*a+e*g+c*i-d*h;this.y=c*a+e*h+d*g-b*i;this.z=d*a+e*i+b*h-c*g;this.w=e*a-b*g-c*h-d*i;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,h=this.y,i=this.z,m=this.w,k=m*c+h*e-i*d,j=m*d+i*c-g*e,n=m*e+g*
 d-h*c,c=-g*c-h*d-i*e;b.x=k*m+c*-g+j*-i-n*-h;b.y=j*m+c*-h+n*-g-k*-i;b.z=n*m+c*-i+k*-h-j*-g;return b},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),e=Math.sqrt(1-e*e);if(0.001>Math.abs(e))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
 THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();for(b=0,c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();for(b=0,c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
 return a}};THREE.Face4=function(a,b,c,d,e,g,h){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3};
@@ -95,9 +95,9 @@ d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));for(a=0,b=this.vertices.lengt
 d;c++){e=this.faces[c];e.__originalFaceNormal?e.__originalFaceNormal.copy(e.normal):e.__originalFaceNormal=e.normal.clone();if(!e.__originalVertexNormals)e.__originalVertexNormals=[];for(a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]?e.__originalVertexNormals[a].copy(e.vertexNormals[a]):e.__originalVertexNormals[a]=e.vertexNormals[a].clone()}var g=new THREE.Geometry;g.faces=this.faces;for(a=0,b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]={};
 this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];var h=this.morphNormals[a].faceNormals,i=this.morphNormals[a].vertexNormals,m,k;for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],m=new THREE.Vector3,k=e instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3},h.push(m),i.push(k)}h=this.morphNormals[a];g.vertices=this.morphTargets[a].vertices;g.computeFaceNormals();
 g.computeVertexNormals();for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],m=h.faceNormals[c],k=h.vertexNormals[c],m.copy(e.normal),e instanceof THREE.Face3?(k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2])):(k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2]),k.d.copy(e.vertexNormals[3]))}for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],e.normal=e.__originalFaceNormal,e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){function a(a,
-b,c,d,e,g,E){i=a.vertices[b].position;m=a.vertices[c].position;k=a.vertices[d].position;j=h[e];n=h[g];l=h[E];q=m.x-i.x;o=k.x-i.x;p=m.y-i.y;s=k.y-i.y;y=m.z-i.z;w=k.z-i.z;N=n.u-j.u;A=l.u-j.u;u=n.v-j.v;D=l.v-j.v;I=1/(N*D-A*u);M.set((D*q-u*o)*I,(D*p-u*s)*I,(D*y-u*w)*I);ja.set((N*o-A*q)*I,(N*s-A*p)*I,(N*w-A*y)*I);L[b].addSelf(M);L[c].addSelf(M);L[d].addSelf(M);K[b].addSelf(ja);K[c].addSelf(ja);K[d].addSelf(ja)}var b,c,d,e,g,h,i,m,k,j,n,l,q,o,p,s,y,w,N,A,u,D,I,E,L=[],K=[],M=new THREE.Vector3,ja=new THREE.Vector3,
+b,c,d,e,g,D){i=a.vertices[b].position;m=a.vertices[c].position;k=a.vertices[d].position;j=h[e];n=h[g];l=h[D];q=m.x-i.x;o=k.x-i.x;p=m.y-i.y;s=k.y-i.y;y=m.z-i.z;w=k.z-i.z;N=n.u-j.u;A=l.u-j.u;u=n.v-j.v;E=l.v-j.v;I=1/(N*E-A*u);M.set((E*q-u*o)*I,(E*p-u*s)*I,(E*y-u*w)*I);ja.set((N*o-A*q)*I,(N*s-A*p)*I,(N*w-A*y)*I);L[b].addSelf(M);L[c].addSelf(M);L[d].addSelf(M);K[b].addSelf(ja);K[c].addSelf(ja);K[d].addSelf(ja)}var b,c,d,e,g,h,i,m,k,j,n,l,q,o,p,s,y,w,N,A,u,E,I,D,L=[],K=[],M=new THREE.Vector3,ja=new THREE.Vector3,
 oa=new THREE.Vector3,ka=new THREE.Vector3,X=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)L[b]=new THREE.Vector3,K[b]=new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)g=this.faces[b],h=this.faceVertexUvs[0][b],g instanceof THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var $=["a","b","c","d"];for(b=0,c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++)X.copy(g.vertexNormals[d]),e=g[$[d]],
-E=L[e],oa.copy(E),oa.subSelf(X.multiplyScalar(X.dot(E))).normalize(),ka.cross(g.vertexNormals[d],E),e=ka.dot(K[e]),e=0>e?-1:1,g.vertexTangents[d]=new THREE.Vector4(oa.x,oa.y,oa.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<
+D=L[e],oa.copy(D),oa.subSelf(X.multiplyScalar(X.dot(D))).normalize(),ka.cross(g.vertexNormals[d],D),e=ka.dot(K[e]),e=0>e?-1:1,g.vertexTangents[d]=new THREE.Vector4(oa.x,oa.y,oa.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<
 e;d++){a=this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;c<d;c++)a=this.vertices[c].position.length(),a>b&&(b=a);this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,
 4),g,h;for(g=0,h=this.vertices.length;g<h;g++)d=this.vertices[g].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*e)].join("_"),void 0===a[d]?(a[d]=g,b.push(this.vertices[g]),c[g]=b.length-1):c[g]=c[a[d]];for(g=0,h=this.faces.length;g<h;g++)if(a=this.faces[g],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
 THREE.Spline=function(a){function b(a,b,c,d,e,g,h){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*h+(-3*(b-c)-2*a-d)*g+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,g,h,i,m,k,j,n,l;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;g=Math.floor(e);h=e-g;c[0]=0===g?g:g-1;c[1]=g;c[2]=g>this.points.length-2?this.points.length-1:g+1;c[3]=g>this.points.length-3?this.points.length-1:
@@ -202,9 +202,9 @@ l,b);if(q)for(j=0,k=q.length;j<k;j++)if(i=q[j],i.needsUpdate||c.sortParticles)f.
 g&&C.setBlending(i.blending);C.setDepthTest(i.depthTest);C.setDepthWrite(i.depthWrite);y(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}C.setObjectFaces(j);k instanceof THREE.BufferGeometry?C.renderBufferDirect(d,f,e,i,k,j):C.renderBuffer(d,f,e,i,k,j)}}function k(a,b,c,d,f,e,g){for(var h,i,j=0,k=a.length;j<k;j++)if(h=a[j],i=h.object,i.visible){if(g)h=g;else{h=h[b];if(!h)continue;e&&C.setBlending(h.blending);C.setDepthTest(h.depthTest);C.setDepthWrite(h.depthWrite);y(h.polygonOffset,h.polygonOffsetFactor,
 h.polygonOffsetUnits)}C.renderImmediateObject(c,d,f,h,i)}}function j(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function n(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function l(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function q(a,b){for(var c=a.length-1;0<=c;c--)a[c].object===b&&a.splice(c,1)}function o(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,1)}function p(a,b,c,d,e){if(!d.program||d.needsUpdate)C.initMaterial(d,
 b,c,e),d.needsUpdate=!1;if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(C.maxMorphTargets);for(var g=0,h=C.maxMorphTargets;g<h;g++)e.__webglMorphTargetInfluences[g]=0}var i=!1,g=d.program,h=g.uniforms,j=d.uniforms;g!==Ba&&(f.useProgram(g),Ba=g,i=!0);if(d.id!==sa)sa=d.id,i=!0;if(i||a!==aa)f.uniformMatrix4fv(h.projectionMatrix,!1,a._projectionMatrixArray),a!==aa&&(aa=a);if(i){if(c&&d.fog)if(j.fogColor.value=c.color,c instanceof THREE.Fog)j.fogNear.value=
-c.near,j.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density;if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){var k,l=0,m=0,n=0,p,o,q,s=oc,u=s.directional.colors,w=s.directional.positions,y=s.point.colors,A=s.point.positions,E=s.point.distances,L=0,M=0,J=q=0;for(c=0,i=b.length;c<i;c++)if(k=b[c],!k.onlyShadow)if(p=k.color,o=k.intensity,q=k.distance,k instanceof THREE.AmbientLight)C.gammaInput?(l+=p.r*p.r,m+=p.g*p.g,n+=p.b*p.b):
+c.near,j.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density;if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){var k,l=0,m=0,n=0,p,o,q,s=oc,u=s.directional.colors,w=s.directional.positions,y=s.point.colors,A=s.point.positions,D=s.point.distances,L=0,M=0,J=q=0;for(c=0,i=b.length;c<i;c++)if(k=b[c],!k.onlyShadow)if(p=k.color,o=k.intensity,q=k.distance,k instanceof THREE.AmbientLight)C.gammaInput?(l+=p.r*p.r,m+=p.g*p.g,n+=p.b*p.b):
 (l+=p.r,m+=p.g,n+=p.b);else if(k instanceof THREE.DirectionalLight)q=3*L,C.gammaInput?(u[q]=p.r*p.r*o*o,u[q+1]=p.g*p.g*o*o,u[q+2]=p.b*p.b*o*o):(u[q]=p.r*o,u[q+1]=p.g*o,u[q+2]=p.b*o),nb.copy(k.matrixWorld.getPosition()),nb.subSelf(k.target.matrixWorld.getPosition()),nb.normalize(),w[q]=nb.x,w[q+1]=nb.y,w[q+2]=nb.z,L+=1;else if(k instanceof THREE.PointLight||k instanceof THREE.SpotLight)J=3*M,C.gammaInput?(y[J]=p.r*p.r*o*o,y[J+1]=p.g*p.g*o*o,y[J+2]=p.b*p.b*o*o):(y[J]=p.r*o,y[J+1]=p.g*o,y[J+2]=p.b*o),
-k=k.matrixWorld.getPosition(),A[J]=k.x,A[J+1]=k.y,A[J+2]=k.z,E[M]=q,M+=1;for(c=3*L,i=u.length;c<i;c++)u[c]=0;for(c=3*M,i=y.length;c<i;c++)y[c]=0;s.point.length=M;s.directional.length=L;s.ambient[0]=l;s.ambient[1]=m;s.ambient[2]=n;c=oc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=c.directional.positions;j.pointLightColor.value=c.point.colors;j.pointLightPosition.value=c.point.positions;j.pointLightDistance.value=c.point.distances}if(d instanceof
+k=k.matrixWorld.getPosition(),A[J]=k.x,A[J+1]=k.y,A[J+2]=k.z,D[M]=q,M+=1;for(c=3*L,i=u.length;c<i;c++)u[c]=0;for(c=3*M,i=y.length;c<i;c++)y[c]=0;s.point.length=M;s.directional.length=L;s.ambient[0]=l;s.ambient[1]=m;s.ambient[2]=n;c=oc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=c.directional.positions;j.pointLightColor.value=c.point.colors;j.pointLightPosition.value=c.point.positions;j.pointLightDistance.value=c.point.distances}if(d instanceof
 THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)j.opacity.value=d.opacity,C.gammaInput?j.diffuse.value.copyGammaToLinear(d.color):j.diffuse.value=d.color,(j.map.texture=d.map)&&j.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y),j.lightMap.texture=d.lightMap,j.envMap.texture=d.envMap,j.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,j.reflectivity.value=d.reflectivity,j.refractionRatio.value=
 d.refractionRatio,j.combine.value=d.combine,j.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping;if(d instanceof THREE.LineBasicMaterial)j.diffuse.value=d.color,j.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)j.psColor.value=d.color,j.opacity.value=d.opacity,j.size.value=d.size,j.scale.value=I.height/2,j.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)j.shininess.value=d.shininess,C.gammaInput?(j.ambient.value.copyGammaToLinear(d.ambient),
 j.emissive.value.copyGammaToLinear(d.emissive),j.specular.value.copyGammaToLinear(d.specular)):(j.ambient.value=d.ambient,j.emissive.value=d.emissive,j.specular.value=d.specular),d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshLambertMaterial)C.gammaInput?(j.ambient.value.copyGammaToLinear(d.ambient),j.emissive.value.copyGammaToLinear(d.emissive)):(j.ambient.value=d.ambient,j.emissive.value=d.emissive),d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof
@@ -212,16 +212,16 @@ THREE.MeshDepthMaterial)j.mNear.value=a.near,j.mFar.value=a.far,j.opacity.value=
 j.shadowBias.value[c]=m.shadowBias,c++}b=d.uniformsList;for(j=0,c=b.length;j<c;j++)if(m=g.uniforms[b[j][1]])if(i=b[j][0],n=i.type,l=i.value,"i"===n)f.uniform1i(m,l);else if("f"===n)f.uniform1f(m,l);else if("v2"===n)f.uniform2f(m,l.x,l.y);else if("v3"===n)f.uniform3f(m,l.x,l.y,l.z);else if("v4"===n)f.uniform4f(m,l.x,l.y,l.z,l.w);else if("c"===n)f.uniform3f(m,l.r,l.g,l.b);else if("fv1"===n)f.uniform1fv(m,l);else if("fv"===n)f.uniform3fv(m,l);else if("v2v"===n){if(!i._array)i._array=new Float32Array(2*
 l.length);for(n=0,s=l.length;n<s;n++)u=2*n,i._array[u]=l[n].x,i._array[u+1]=l[n].y;f.uniform2fv(m,i._array)}else if("v3v"===n){if(!i._array)i._array=new Float32Array(3*l.length);for(n=0,s=l.length;n<s;n++)u=3*n,i._array[u]=l[n].x,i._array[u+1]=l[n].y,i._array[u+2]=l[n].z;f.uniform3fv(m,i._array)}else if("v4v"==n){if(!i._array)i._array=new Float32Array(4*l.length);for(n=0,s=l.length;n<s;n++)u=4*n,i._array[u]=l[n].x,i._array[u+1]=l[n].y,i._array[u+2]=l[n].z,i._array[u+3]=l[n].w;f.uniform4fv(m,i._array)}else if("m4"===
 n){if(!i._array)i._array=new Float32Array(16);l.flattenToArray(i._array);f.uniformMatrix4fv(m,!1,i._array)}else if("m4v"===n){if(!i._array)i._array=new Float32Array(16*l.length);for(n=0,s=l.length;n<s;n++)l[n].flattenToArrayOffset(i._array,16*n);f.uniformMatrix4fv(m,!1,i._array)}else if("t"===n){if(f.uniform1i(m,l),m=i.texture)if(m.image instanceof Array&&6===m.image.length){if(i=m,6===i.image.length)if(i.needsUpdate){if(!i.image.__webglTextureCube)i.image.__webglTextureCube=f.createTexture();f.activeTexture(f.TEXTURE0+
-l);f.bindTexture(f.TEXTURE_CUBE_MAP,i.image.__webglTextureCube);l=[];for(m=0;6>m;m++){n=l;s=m;if(C.autoScaleCubemaps){if(u=i.image[m],y=Fc,!(u.width<=y&&u.height<=y))A=Math.max(u.width,u.height),w=Math.floor(u.width*y/A),y=Math.floor(u.height*y/A),A=document.createElement("canvas"),A.width=w,A.height=y,A.getContext("2d").drawImage(u,0,0,u.width,u.height,0,0,w,y),u=A}else u=i.image[m];n[s]=u}m=l[0];n=0===(m.width&m.width-1)&&0===(m.height&m.height-1);s=D(i.format);u=D(i.type);N(f.TEXTURE_CUBE_MAP,
+l);f.bindTexture(f.TEXTURE_CUBE_MAP,i.image.__webglTextureCube);l=[];for(m=0;6>m;m++){n=l;s=m;if(C.autoScaleCubemaps){if(u=i.image[m],y=Fc,!(u.width<=y&&u.height<=y))A=Math.max(u.width,u.height),w=Math.floor(u.width*y/A),y=Math.floor(u.height*y/A),A=document.createElement("canvas"),A.width=w,A.height=y,A.getContext("2d").drawImage(u,0,0,u.width,u.height,0,0,w,y),u=A}else u=i.image[m];n[s]=u}m=l[0];n=0===(m.width&m.width-1)&&0===(m.height&m.height-1);s=E(i.format);u=E(i.type);N(f.TEXTURE_CUBE_MAP,
 i,n);for(m=0;6>m;m++)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,s,s,u,l[m]);i.generateMipmaps&&n&&f.generateMipmap(f.TEXTURE_CUBE_MAP);i.needsUpdate=!1;if(i.onUpdate)i.onUpdate()}else f.activeTexture(f.TEXTURE0+l),f.bindTexture(f.TEXTURE_CUBE_MAP,i.image.__webglTextureCube)}else m instanceof THREE.WebGLRenderTargetCube?(i=m,f.activeTexture(f.TEXTURE0+l),f.bindTexture(f.TEXTURE_CUBE_MAP,i.__webglTexture)):C.setTexture(m,l)}else if("tv"===n){if(!i._array){i._array=[];for(n=0,s=i.texture.length;n<
 s;n++)i._array[n]=l+n}f.uniform1iv(m,i._array);for(n=0,s=i.texture.length;n<s;n++)(m=i.texture[n])&&C.setTexture(m,i._array[n])}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==h.cameraPosition)b=a.matrixWorld.getPosition(),f.uniform3f(h.cameraPosition,b.x,b.y,b.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==h.viewMatrix&&f.uniformMatrix4fv(h.viewMatrix,!1,a._viewMatrixArray);
 d.skinning&&f.uniformMatrix4fv(h.boneGlobalMatrices,!1,e.boneMatrices)}f.uniformMatrix4fv(h.modelViewMatrix,!1,e._modelViewMatrixArray);h.normalMatrix&&f.uniformMatrix3fv(h.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&null!==h.objectMatrix&&f.uniformMatrix4fv(h.objectMatrix,!1,e._objectMatrixArray);return g}function s(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);
 c&&c.transposeIntoArray(a._normalMatrixArray)}function y(a,b,c){Sa!==a&&(a?f.enable(f.POLYGON_OFFSET_FILL):f.disable(f.POLYGON_OFFSET_FILL),Sa=a);if(a&&(Wa!==b||Ma!==c))f.polygonOffset(b,c),Wa=b,Ma=c}function w(a,b){var c;"fragment"===a?c=f.createShader(f.FRAGMENT_SHADER):"vertex"===a&&(c=f.createShader(f.VERTEX_SHADER));f.shaderSource(c,b);f.compileShader(c);return!f.getShaderParameter(c,f.COMPILE_STATUS)?(console.error(f.getShaderInfoLog(c)),console.error(b),null):c}function N(a,b,c){c?(f.texParameteri(a,
-f.TEXTURE_WRAP_S,D(b.wrapS)),f.texParameteri(a,f.TEXTURE_WRAP_T,D(b.wrapT)),f.texParameteri(a,f.TEXTURE_MAG_FILTER,D(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,D(b.minFilter))):(f.texParameteri(a,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(a,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(a,f.TEXTURE_MAG_FILTER,u(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,u(b.minFilter)))}function A(a,b){f.bindRenderbuffer(f.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,
+f.TEXTURE_WRAP_S,E(b.wrapS)),f.texParameteri(a,f.TEXTURE_WRAP_T,E(b.wrapT)),f.texParameteri(a,f.TEXTURE_MAG_FILTER,E(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,E(b.minFilter))):(f.texParameteri(a,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(a,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(a,f.TEXTURE_MAG_FILTER,u(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,u(b.minFilter)))}function A(a,b){f.bindRenderbuffer(f.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,
 f.DEPTH_COMPONENT16,b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_STENCIL,b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,a)):f.renderbufferStorage(f.RENDERBUFFER,f.RGBA4,b.width,b.height)}function u(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;
-default:return f.LINEAR}}function D(a){switch(a){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;
+default:return f.LINEAR}}function E(a){switch(a){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;
 case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedIntType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}
-var a=a||{},I=void 0!==a.canvas?a.canvas:document.createElement("canvas"),E=void 0!==a.precision?a.precision:"mediump",L=void 0!==a.alpha?a.alpha:!0,K=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,M=void 0!==a.antialias?a.antialias:!1,ja=void 0!==a.stencil?a.stencil:!0,oa=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,ka=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),X=void 0!==a.clearAlpha?a.clearAlpha:0,$=void 0!==a.maxLights?a.maxLights:4;this.domElement=
+var a=a||{},I=void 0!==a.canvas?a.canvas:document.createElement("canvas"),D=void 0!==a.precision?a.precision:"highp",L=void 0!==a.alpha?a.alpha:!0,K=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,M=void 0!==a.antialias?a.antialias:!1,ja=void 0!==a.stencil?a.stencil:!0,oa=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,ka=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),X=void 0!==a.clearAlpha?a.clearAlpha:0,$=void 0!==a.maxLights?a.maxLights:4;this.domElement=
 I;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapEnabled=this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.shadowMapCascade=this.shadowMapDebug=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=!0;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info=
 {memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var C=this,f,Va=[],Ba=null,S=null,sa=-1,J=null,aa=null,ta=0,xa=null,T=null,Aa=null,Ga=null,Ha=null,Sa=null,Wa=null,Ma=null,tb=null,Yb=0,Hb=0,Pb=0,Zb=0,mc=0,nc=0,Ib=new THREE.Frustum,mb=new THREE.Matrix4,Ob=new THREE.Matrix4,Na=new THREE.Vector4,nb=new THREE.Vector3,oc={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};f=function(){var a;try{if(!(a=
 I.getContext("experimental-webgl",{alpha:L,premultipliedAlpha:K,antialias:M,stencil:ja,preserveDrawingBuffer:oa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();f.clearColor(0,0,0,1);f.clearDepth(1);f.clearStencil(0);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);
@@ -250,9 +250,9 @@ w,o.transparent=null)}else if(w)w.transparent?(o.transparent=w,o.opaque=null):(o
 (g.opaque=j,g.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),this.setDepthWrite(a.overrideMaterial.depthWrite),y(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),m(a.__webglObjects,!1,"",b,n,p,!0,a.overrideMaterial),k(a.__webglObjectsImmediate,"",b,n,p,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),m(a.__webglObjects,!0,"opaque",b,n,p,
 !1),k(a.__webglObjectsImmediate,"opaque",b,n,p,!1),m(a.__webglObjects,!1,"transparent",b,n,p,!0),k(a.__webglObjectsImmediate,"transparent",b,n,p,!0));i(this.renderPluginsPost,a,b);c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(f.bindTexture(f.TEXTURE_CUBE_MAP,c.__webglTexture),f.generateMipmap(f.TEXTURE_CUBE_MAP),f.bindTexture(f.TEXTURE_CUBE_MAP,null)):(f.bindTexture(f.TEXTURE_2D,c.__webglTexture),f.generateMipmap(f.TEXTURE_2D),
 f.bindTexture(f.TEXTURE_2D,null)));this.setDepthTest(!0);this.setDepthWrite(!0)};this.renderImmediateObject=function(a,b,c,d,e){var g=p(a,b,c,d,e);J=-1;C.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(g,f,Ib):e.render(function(a){C.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 h=a.__objectsAdded[0],i=a,m=
-void 0,k=void 0,p=void 0;if(!h.__webglInit)if(h.__webglInit=!0,h._modelViewMatrix=new THREE.Matrix4,h._normalMatrixArray=new Float32Array(9),h._modelViewMatrixArray=new Float32Array(16),h._objectMatrixArray=new Float32Array(16),h.matrixWorld.flattenToArray(h._objectMatrixArray),h instanceof THREE.Mesh){if(k=h.geometry,k instanceof THREE.Geometry){if(void 0===k.geometryGroups){var s=k,u=void 0,w=void 0,y=void 0,A=void 0,I=void 0,E=void 0,D=void 0,J={},L=s.morphTargets.length,N=s.morphNormals.length;
-s.geometryGroups={};for(u=0,w=s.faces.length;u<w;u++)y=s.faces[u],A=y.materialIndex,E=void 0!==A?A:-1,void 0===J[E]&&(J[E]={hash:E,counter:0}),D=J[E].hash+"_"+J[E].counter,void 0===s.geometryGroups[D]&&(s.geometryGroups[D]={faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:L,numMorphNormals:N}),I=y instanceof THREE.Face3?3:4,65535<s.geometryGroups[D].vertices+I&&(J[E].counter+=1,D=J[E].hash+"_"+J[E].counter,void 0===s.geometryGroups[D]&&(s.geometryGroups[D]={faces3:[],faces4:[],materialIndex:A,
-vertices:0,numMorphTargets:L,numMorphNormals:N})),y instanceof THREE.Face3?s.geometryGroups[D].faces3.push(u):s.geometryGroups[D].faces4.push(u),s.geometryGroups[D].vertices+=I;s.geometryGroupsList=[];var M=void 0;for(M in s.geometryGroups)s.geometryGroups[M].id=ta++,s.geometryGroupsList.push(s.geometryGroups[M])}for(m in k.geometryGroups)if(p=k.geometryGroups[m],!p.__webglVertexBuffer){var K=p;K.__webglVertexBuffer=f.createBuffer();K.__webglNormalBuffer=f.createBuffer();K.__webglTangentBuffer=f.createBuffer();
+void 0,k=void 0,p=void 0;if(!h.__webglInit)if(h.__webglInit=!0,h._modelViewMatrix=new THREE.Matrix4,h._normalMatrixArray=new Float32Array(9),h._modelViewMatrixArray=new Float32Array(16),h._objectMatrixArray=new Float32Array(16),h.matrixWorld.flattenToArray(h._objectMatrixArray),h instanceof THREE.Mesh){if(k=h.geometry,k instanceof THREE.Geometry){if(void 0===k.geometryGroups){var s=k,u=void 0,w=void 0,y=void 0,A=void 0,I=void 0,D=void 0,E=void 0,J={},L=s.morphTargets.length,N=s.morphNormals.length;
+s.geometryGroups={};for(u=0,w=s.faces.length;u<w;u++)y=s.faces[u],A=y.materialIndex,D=void 0!==A?A:-1,void 0===J[D]&&(J[D]={hash:D,counter:0}),E=J[D].hash+"_"+J[D].counter,void 0===s.geometryGroups[E]&&(s.geometryGroups[E]={faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:L,numMorphNormals:N}),I=y instanceof THREE.Face3?3:4,65535<s.geometryGroups[E].vertices+I&&(J[D].counter+=1,E=J[D].hash+"_"+J[D].counter,void 0===s.geometryGroups[E]&&(s.geometryGroups[E]={faces3:[],faces4:[],materialIndex:A,
+vertices:0,numMorphTargets:L,numMorphNormals:N})),y instanceof THREE.Face3?s.geometryGroups[E].faces3.push(u):s.geometryGroups[E].faces4.push(u),s.geometryGroups[E].vertices+=I;s.geometryGroupsList=[];var M=void 0;for(M in s.geometryGroups)s.geometryGroups[M].id=ta++,s.geometryGroupsList.push(s.geometryGroups[M])}for(m in k.geometryGroups)if(p=k.geometryGroups[m],!p.__webglVertexBuffer){var K=p;K.__webglVertexBuffer=f.createBuffer();K.__webglNormalBuffer=f.createBuffer();K.__webglTangentBuffer=f.createBuffer();
 K.__webglColorBuffer=f.createBuffer();K.__webglUVBuffer=f.createBuffer();K.__webglUV2Buffer=f.createBuffer();K.__webglSkinVertexABuffer=f.createBuffer();K.__webglSkinVertexBBuffer=f.createBuffer();K.__webglSkinIndicesBuffer=f.createBuffer();K.__webglSkinWeightsBuffer=f.createBuffer();K.__webglFaceBuffer=f.createBuffer();K.__webglLineBuffer=f.createBuffer();var T=void 0,X=void 0;if(K.numMorphTargets){K.__webglMorphTargetsBuffers=[];for(T=0,X=K.numMorphTargets;T<X;T++)K.__webglMorphTargetsBuffers.push(f.createBuffer())}if(K.numMorphNormals){K.__webglMorphNormalsBuffers=
 [];for(T=0,X=K.numMorphNormals;T<X;T++)K.__webglMorphNormalsBuffers.push(f.createBuffer())}C.info.memory.geometries++;var ca=p,$=h,aa=$.geometry,ja=ca.faces3,ka=ca.faces4,S=3*ja.length+4*ka.length,sa=1*ja.length+2*ka.length,xa=3*ja.length+4*ka.length,oa=c($,ca),Aa=e(oa),Ba=d(oa),Ga=oa.vertexColors?oa.vertexColors:!1;ca.__vertexArray=new Float32Array(3*S);if(Ba)ca.__normalArray=new Float32Array(3*S);if(aa.hasTangents)ca.__tangentArray=new Float32Array(4*S);if(Ga)ca.__colorArray=new Float32Array(3*
 S);if(Aa){if(0<aa.faceUvs.length||0<aa.faceVertexUvs.length)ca.__uvArray=new Float32Array(2*S);if(1<aa.faceUvs.length||1<aa.faceVertexUvs.length)ca.__uv2Array=new Float32Array(2*S)}if($.geometry.skinWeights.length&&$.geometry.skinIndices.length)ca.__skinVertexAArray=new Float32Array(4*S),ca.__skinVertexBArray=new Float32Array(4*S),ca.__skinIndexArray=new Float32Array(4*S),ca.__skinWeightArray=new Float32Array(4*S);ca.__faceArray=new Uint16Array(3*sa);ca.__lineArray=new Uint16Array(2*xa);var Ha=void 0,
@@ -299,9 +299,10 @@ THREE.ParticleSystem)Ea=c(Ta,ac),Rb=Ea.attributes&&n(Ea),(R.__dirtyVertices||R._
 THREE.LineBasicMaterial?j="basic":a instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var k=THREE.ShaderLib[j];a.uniforms=THREE.UniformsUtils.clone(k.uniforms);a.vertexShader=k.vertexShader;a.fragmentShader=k.fragmentShader}var l,m;g=k=0;for(l=0,m=b.length;l<m;l++)e=b[l],e.onlyShadow||(e instanceof THREE.DirectionalLight&&g++,e instanceof THREE.PointLight&&k++,e instanceof THREE.SpotLight&&k++);k+g<=$?l=g:(l=Math.ceil($*g/(k+g)),k=$-l);e=l;g=k;var n=0;for(k=0,l=b.length;k<l;k++)m=
 b[k],m.castShadow&&(m instanceof THREE.SpotLight&&n++,m instanceof THREE.DirectionalLight&&!m.shadowCascade&&n++);var p=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)p=d.bones.length;var o;a:{l=a.fragmentShader;m=a.vertexShader;var k=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:p,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=[];j?d.push(j):(d.push(l),d.push(m));for(q in c)d.push(q),d.push(c[q]);j=d.join();for(q=0,d=Va.length;q<d;q++)if(Va[q].code===j){o=
-Va[q].program;break a}q=f.createProgram();d=[0<pc?"#define VERTEX_TEXTURES":"",C.gammaInput?"#define GAMMA_INPUT":"",C.gammaOutput?"#define GAMMA_OUTPUT":"",C.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");
-e=["precision "+E+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",C.gammaInput?"#define GAMMA_INPUT":"",C.gammaOutput?"#define GAMMA_OUTPUT":"",C.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?
+Va[q].program;break a}q=f.createProgram();d=["precision "+D+" float;",0<pc?"#define VERTEX_TEXTURES":"",C.gammaInput?"#define GAMMA_INPUT":"",C.gammaOutput?"#define GAMMA_OUTPUT":"",C.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");
+e=["precision "+D+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",C.gammaInput?"#define GAMMA_INPUT":"",C.gammaOutput?"#define GAMMA_OUTPUT":"",C.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?
 "#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");f.attachShader(q,w("fragment",e+l));
 f.attachShader(q,w("vertex",d+m));f.linkProgram(q);f.getProgramParameter(q,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(q,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");q.uniforms={};q.attributes={};var s,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,boneGlobalMatrices,morphTargetInfluences".split(",");for(s in k)d.push(s);s=d;for(d=0,k=s.length;d<k;d++)l=s[d],q.uniforms[l]=f.getUniformLocation(q,
 l);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");for(s=0;s<c.maxMorphTargets;s++)d.push("morphTarget"+s);for(s=0;s<c.maxMorphNormals;s++)d.push("morphNormal"+s);for(o in b)d.push(o);o=d;for(s=0,b=o.length;s<b;s++)c=o[s],q.attributes[c]=f.getAttribLocation(q,c);q.id=Va.length;Va.push({program:q,code:j});C.info.memory.programs=Va.length;o=q}a.program=o;o=a.program.attributes;0<=o.position&&f.enableVertexAttribArray(o.position);0<=o.color&&f.enableVertexAttribArray(o.color);
@@ -309,8 +310,8 @@ l);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,ski
 for(i=0;i<this.maxMorphTargets;i++)s=q+i,0<=o[s]&&(f.enableVertexAttribArray(o[s]),a.numSupportedMorphTargets++)}if(a.morphNormals){a.numSupportedMorphNormals=0;q="morphNormal";for(i=0;i<this.maxMorphNormals;i++)s=q+i,0<=o[s]&&(f.enableVertexAttribArray(o[s]),a.numSupportedMorphNormals++)}a.uniformsList=[];for(h in a.uniforms)a.uniformsList.push([a.uniforms[h],h])};this.setFaceCulling=function(a,b){a?(!b||"ccw"===b?f.frontFace(f.CCW):f.frontFace(f.CW),"back"===a?f.cullFace(f.BACK):"front"===a?f.cullFace(f.FRONT):
 f.cullFace(f.FRONT_AND_BACK),f.enable(f.CULL_FACE)):f.disable(f.CULL_FACE)};this.setObjectFaces=function(a){if(xa!==a.doubleSided)a.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE),xa=a.doubleSided;if(T!==a.flipSided)a.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW),T=a.flipSided};this.setDepthTest=function(a){Ga!==a&&(a?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),Ga=a)};this.setDepthWrite=function(a){Ha!==a&&(f.depthMask(a),Ha=a)};this.setBlending=function(a){if(a!==Aa){switch(a){case THREE.NoBlending:f.disable(f.BLEND);
 break;case THREE.AdditiveBlending:f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE);break;case THREE.SubtractiveBlending:f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.SRC_COLOR);break;default:f.enable(f.BLEND),f.blendEquationSeparate(f.FUNC_ADD,f.FUNC_ADD),f.blendFuncSeparate(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA)}Aa=
-a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=f.createTexture(),C.info.memory.textures++;f.activeTexture(f.TEXTURE0+b);f.bindTexture(f.TEXTURE_2D,a.__webglTexture);var c=a.image,d=0===(c.width&c.width-1)&&0===(c.height&c.height-1),e=D(a.format),g=D(a.type);N(f.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?f.texImage2D(f.TEXTURE_2D,0,e,c.width,c.height,0,e,g,c.data):f.texImage2D(f.TEXTURE_2D,0,e,e,g,a.image);a.generateMipmaps&&d&&f.generateMipmap(f.TEXTURE_2D);
-a.needsUpdate=!1;if(a.onUpdate)a.onUpdate()}else f.activeTexture(f.TEXTURE0+b),f.bindTexture(f.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=f.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=D(a.format),e=D(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];f.bindTexture(f.TEXTURE_CUBE_MAP,
+a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=f.createTexture(),C.info.memory.textures++;f.activeTexture(f.TEXTURE0+b);f.bindTexture(f.TEXTURE_2D,a.__webglTexture);var c=a.image,d=0===(c.width&c.width-1)&&0===(c.height&c.height-1),e=E(a.format),g=E(a.type);N(f.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?f.texImage2D(f.TEXTURE_2D,0,e,c.width,c.height,0,e,g,c.data):f.texImage2D(f.TEXTURE_2D,0,e,e,g,a.image);a.generateMipmaps&&d&&f.generateMipmap(f.TEXTURE_2D);
+a.needsUpdate=!1;if(a.onUpdate)a.onUpdate()}else f.activeTexture(f.TEXTURE0+b),f.bindTexture(f.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=f.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=E(a.format),e=E(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];f.bindTexture(f.TEXTURE_CUBE_MAP,
 a.__webglTexture);N(f.TEXTURE_CUBE_MAP,a,c);for(c=0;6>c;c++){a.__webglFramebuffer[c]=f.createFramebuffer();a.__webglRenderbuffer[c]=f.createRenderbuffer();f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,0,d,e,null);var g=a,h=f.TEXTURE_CUBE_MAP_POSITIVE_X+c;f.bindFramebuffer(f.FRAMEBUFFER,a.__webglFramebuffer[c]);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,h,g.__webglTexture,0);A(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=f.createFramebuffer(),a.__webglRenderbuffer=
 f.createRenderbuffer(),f.bindTexture(f.TEXTURE_2D,a.__webglTexture),N(f.TEXTURE_2D,a,c),f.texImage2D(f.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=f.TEXTURE_2D,f.bindFramebuffer(f.FRAMEBUFFER,a.__webglFramebuffer),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,d,a.__webglTexture,0),A(a.__webglRenderbuffer,a);b?f.bindTexture(f.TEXTURE_CUBE_MAP,null):f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:
 a.__webglFramebuffer,d=a.width,a=a.height,c=e=0):(b=null,d=Pb,a=Zb,e=Yb,c=Hb);b!==S&&(f.bindFramebuffer(f.FRAMEBUFFER,b),f.viewport(e,c,d,a),S=b);mc=d;nc=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
@@ -336,10 +337,10 @@ THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.le
 THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.material=b;this.init=function(a){this.resolution=a;this.isolation=80;this.size=a;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(3*this.size3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=0;this.hasNormal=
 this.hasPos=!1;this.positionArray=new Float32Array(3*this.maxCount);this.normalArray=new Float32Array(3*this.maxCount)};this.lerp=function(a,b,e){return a+(b-a)*e};this.VIntX=function(a,b,e,g,h,i,m,k,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i+h*this.delta;b[g+1]=m;b[g+2]=k;e[g]=this.lerp(j[a],j[a+3],h);e[g+1]=this.lerp(j[a+1],j[a+4],h);e[g+2]=this.lerp(j[a+2],j[a+5],h)};this.VIntY=function(a,b,e,g,h,i,m,k,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i;b[g+1]=m+h*this.delta;b[g+2]=k;b=a+3*this.yd;
 e[g]=this.lerp(j[a],j[b],h);e[g+1]=this.lerp(j[a+1],j[b+1],h);e[g+2]=this.lerp(j[a+2],j[b+2],h)};this.VIntZ=function(a,b,e,g,h,i,m,k,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i;b[g+1]=m;b[g+2]=k+h*this.delta;b=a+3*this.zd;e[g]=this.lerp(j[a],j[b],h);e[g+1]=this.lerp(j[a+1],j[b+1],h);e[g+2]=this.lerp(j[a+2],j[b+2],h)};this.compNorm=function(a){var b=3*a;0===this.normal_cache[b]&&(this.normal_cache[b]=this.field[a-1]-this.field[a+1],this.normal_cache[b+1]=this.field[a-this.yd]-this.field[a+this.yd],
-this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,e,g,h,i){var m=g+1,k=g+this.yd,j=g+this.zd,n=m+this.yd,l=m+this.zd,q=g+this.yd+this.zd,o=m+this.yd+this.zd,p=0,s=this.field[g],y=this.field[m],w=this.field[k],N=this.field[n],A=this.field[j],u=this.field[l],D=this.field[q],I=this.field[o];s<h&&(p|=1);y<h&&(p|=2);w<h&&(p|=8);N<h&&(p|=4);A<h&&(p|=16);u<h&&(p|=32);D<h&&(p|=128);I<h&&(p|=64);var E=THREE.edgeTable[p];if(0===E)return 0;var L=this.delta,K=a+
-L,M=b+L,L=e+L;E&1&&(this.compNorm(g),this.compNorm(m),this.VIntX(3*g,this.vlist,this.nlist,0,h,a,b,e,s,y));E&2&&(this.compNorm(m),this.compNorm(n),this.VIntY(3*m,this.vlist,this.nlist,3,h,K,b,e,y,N));E&4&&(this.compNorm(k),this.compNorm(n),this.VIntX(3*k,this.vlist,this.nlist,6,h,a,M,e,w,N));E&8&&(this.compNorm(g),this.compNorm(k),this.VIntY(3*g,this.vlist,this.nlist,9,h,a,b,e,s,w));E&16&&(this.compNorm(j),this.compNorm(l),this.VIntX(3*j,this.vlist,this.nlist,12,h,a,b,L,A,u));E&32&&(this.compNorm(l),
-this.compNorm(o),this.VIntY(3*l,this.vlist,this.nlist,15,h,K,b,L,u,I));E&64&&(this.compNorm(q),this.compNorm(o),this.VIntX(3*q,this.vlist,this.nlist,18,h,a,M,L,D,I));E&128&&(this.compNorm(j),this.compNorm(q),this.VIntY(3*j,this.vlist,this.nlist,21,h,a,b,L,A,D));E&256&&(this.compNorm(g),this.compNorm(j),this.VIntZ(3*g,this.vlist,this.nlist,24,h,a,b,e,s,A));E&512&&(this.compNorm(m),this.compNorm(l),this.VIntZ(3*m,this.vlist,this.nlist,27,h,K,b,e,y,u));E&1024&&(this.compNorm(n),this.compNorm(o),this.VIntZ(3*
-n,this.vlist,this.nlist,30,h,K,M,e,N,I));E&2048&&(this.compNorm(k),this.compNorm(q),this.VIntZ(3*k,this.vlist,this.nlist,33,h,a,M,e,w,D));p<<=4;for(h=g=0;-1!=THREE.triTable[p+h];)a=p+h,b=a+1,e=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[e],i),h+=3,g++;return g};this.posnormtriv=function(a,b,e,g,h,i){var m=3*this.count;this.positionArray[m]=a[e];this.positionArray[m+1]=a[e+1];this.positionArray[m+2]=a[e+2];this.positionArray[m+3]=a[g];this.positionArray[m+
+this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,e,g,h,i){var m=g+1,k=g+this.yd,j=g+this.zd,n=m+this.yd,l=m+this.zd,q=g+this.yd+this.zd,o=m+this.yd+this.zd,p=0,s=this.field[g],y=this.field[m],w=this.field[k],N=this.field[n],A=this.field[j],u=this.field[l],E=this.field[q],I=this.field[o];s<h&&(p|=1);y<h&&(p|=2);w<h&&(p|=8);N<h&&(p|=4);A<h&&(p|=16);u<h&&(p|=32);E<h&&(p|=128);I<h&&(p|=64);var D=THREE.edgeTable[p];if(0===D)return 0;var L=this.delta,K=a+
+L,M=b+L,L=e+L;D&1&&(this.compNorm(g),this.compNorm(m),this.VIntX(3*g,this.vlist,this.nlist,0,h,a,b,e,s,y));D&2&&(this.compNorm(m),this.compNorm(n),this.VIntY(3*m,this.vlist,this.nlist,3,h,K,b,e,y,N));D&4&&(this.compNorm(k),this.compNorm(n),this.VIntX(3*k,this.vlist,this.nlist,6,h,a,M,e,w,N));D&8&&(this.compNorm(g),this.compNorm(k),this.VIntY(3*g,this.vlist,this.nlist,9,h,a,b,e,s,w));D&16&&(this.compNorm(j),this.compNorm(l),this.VIntX(3*j,this.vlist,this.nlist,12,h,a,b,L,A,u));D&32&&(this.compNorm(l),
+this.compNorm(o),this.VIntY(3*l,this.vlist,this.nlist,15,h,K,b,L,u,I));D&64&&(this.compNorm(q),this.compNorm(o),this.VIntX(3*q,this.vlist,this.nlist,18,h,a,M,L,E,I));D&128&&(this.compNorm(j),this.compNorm(q),this.VIntY(3*j,this.vlist,this.nlist,21,h,a,b,L,A,E));D&256&&(this.compNorm(g),this.compNorm(j),this.VIntZ(3*g,this.vlist,this.nlist,24,h,a,b,e,s,A));D&512&&(this.compNorm(m),this.compNorm(l),this.VIntZ(3*m,this.vlist,this.nlist,27,h,K,b,e,y,u));D&1024&&(this.compNorm(n),this.compNorm(o),this.VIntZ(3*
+n,this.vlist,this.nlist,30,h,K,M,e,N,I));D&2048&&(this.compNorm(k),this.compNorm(q),this.VIntZ(3*k,this.vlist,this.nlist,33,h,a,M,e,w,E));p<<=4;for(h=g=0;-1!=THREE.triTable[p+h];)a=p+h,b=a+1,e=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[e],i),h+=3,g++;return g};this.posnormtriv=function(a,b,e,g,h,i){var m=3*this.count;this.positionArray[m]=a[e];this.positionArray[m+1]=a[e+1];this.positionArray[m+2]=a[e+2];this.positionArray[m+3]=a[g];this.positionArray[m+
 4]=a[g+1];this.positionArray[m+5]=a[g+2];this.positionArray[m+6]=a[h];this.positionArray[m+7]=a[h+1];this.positionArray[m+8]=a[h+2];this.normalArray[m]=b[e];this.normalArray[m+1]=b[e+1];this.normalArray[m+2]=b[e+2];this.normalArray[m+3]=b[g];this.normalArray[m+4]=b[g+1];this.normalArray[m+5]=b[g+2];this.normalArray[m+6]=b[h];this.normalArray[m+7]=b[h+1];this.normalArray[m+8]=b[h+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&i(this)};this.begin=function(){this.count=0;
 this.hasNormal=this.hasPos=!1};this.end=function(a){if(0!==this.count){for(var b=3*this.count;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,e,g,h){var i=this.size*Math.sqrt(g/h),m=e*this.size,k=b*this.size,j=a*this.size,n=Math.floor(m-i);1>n&&(n=1);m=Math.floor(m+i);m>this.size-1&&(m=this.size-1);var l=Math.floor(k-i);1>l&&(l=1);k=Math.floor(k+i);k>this.size-1&&(k=this.size-1);var q=Math.floor(j-i);1>q&&(q=1);i=Math.floor(j+i);i>this.size-1&&(i=this.size-
 1);for(var o,p,s,y,w,N,A,j=n;j<m;j++){s=this.size2*j;w=j/this.size-e;N=w*w;for(n=l;n<k;n++){p=s+this.size*n;o=n/this.size-b;A=o*o;for(o=q;o<i;o++)y=o/this.size-a,y=g/(1.0E-6+y*y+A+N)-h,0<y&&(this.field[p+o]+=y)}}};this.addPlaneX=function(a,b){var e,g,h,i,m,k=this.size,j=this.yd,n=this.zd,l=this.field,q=k*Math.sqrt(a/b);q>k&&(q=k);for(e=0;e<q;e++)if(g=e/k,g*=g,i=a/(1.0E-4+g)-b,0<i)for(g=0;g<k;g++){m=e+g*j;for(h=0;h<k;h++)l[n*h+m]+=i}};this.addPlaneY=function(a,b){var e,g,h,i,m,k,j=this.size,n=this.yd,
@@ -374,10 +375,10 @@ THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.creat
 0;d[o++]=1;d[o++]=1;d[o++]=1;d[o++]=1;d[o++]=-1;d[o++]=1;d[o++]=0;d[o++]=1;o=0;e[o++]=0;e[o++]=1;e[o++]=2;e[o++]=0;e[o++]=2;e[o++]=3;g=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);i=b.createTexture();m=b.createTexture();b.bindTexture(b.TEXTURE_2D,i);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,
 b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.bindTexture(b.TEXTURE_2D,m);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);
 b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(k=!1,j=a(THREE.ShaderFlares.lensFlare)):(k=!0,j=a(THREE.ShaderFlares.lensFlareVertexTexture));n={};l={};n.vertex=b.getAttribLocation(j,"position");n.uv=b.getAttribLocation(j,"uv");l.renderType=b.getUniformLocation(j,"renderType");l.map=b.getUniformLocation(j,"map");l.occlusionMap=b.getUniformLocation(j,"occlusionMap");l.opacity=b.getUniformLocation(j,"opacity");l.color=b.getUniformLocation(j,
-"color");l.scale=b.getUniformLocation(j,"scale");l.rotation=b.getUniformLocation(j,"rotation");l.screenPosition=b.getUniformLocation(j,"screenPosition");q=!1};this.render=function(a,d,e,y){var a=a.__webglFlares,w=a.length;if(w){var N=new THREE.Vector3,A=y/e,u=0.5*e,D=0.5*y,I=16/y,E=new THREE.Vector2(I*A,I),L=new THREE.Vector3(1,1,0),K=new THREE.Vector2(1,1),M=l,I=n;b.useProgram(j);q||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),q=!0);b.uniform1i(M.occlusionMap,0);b.uniform1i(M.map,
-1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(I.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(I.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(!1);var ja,oa,ka,X,$;for(ja=0;ja<w;ja++)if(I=16/y,E.set(I*A,I),X=a[ja],N.set(X.matrixWorld.n14,X.matrixWorld.n24,X.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(N),d.projectionMatrix.multiplyVector3(N),L.copy(N),K.x=L.x*u+u,K.y=L.y*D+D,k||0<K.x&&K.x<e&&0<K.y&&K.y<y){b.activeTexture(b.TEXTURE1);
-b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,K.x-8,K.y-8,16,16,0);b.uniform1i(M.renderType,0);b.uniform2f(M.scale,E.x,E.y);b.uniform3f(M.screenPosition,L.x,L.y,L.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,m);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,K.x-8,K.y-8,16,16,0);b.uniform1i(M.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
-i);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);X.positionScreen.copy(L);X.customUpdateCallback?X.customUpdateCallback(X):X.updateLensFlares();b.uniform1i(M.renderType,2);b.enable(b.BLEND);for(oa=0,ka=X.lensFlares.length;oa<ka;oa++)if($=X.lensFlares[oa],0.0010<$.opacity&&0.0010<$.scale)L.x=$.x,L.y=$.y,L.z=$.z,I=$.size*$.scale/y,E.x=I*A,E.y=I,b.uniform3f(M.screenPosition,L.x,L.y,L.z),b.uniform2f(M.scale,E.x,E.y),b.uniform1f(M.rotation,$.rotation),b.uniform1f(M.opacity,$.opacity),b.uniform3f(M.color,
+"color");l.scale=b.getUniformLocation(j,"scale");l.rotation=b.getUniformLocation(j,"rotation");l.screenPosition=b.getUniformLocation(j,"screenPosition");q=!1};this.render=function(a,d,e,y){var a=a.__webglFlares,w=a.length;if(w){var N=new THREE.Vector3,A=y/e,u=0.5*e,E=0.5*y,I=16/y,D=new THREE.Vector2(I*A,I),L=new THREE.Vector3(1,1,0),K=new THREE.Vector2(1,1),M=l,I=n;b.useProgram(j);q||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),q=!0);b.uniform1i(M.occlusionMap,0);b.uniform1i(M.map,
+1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(I.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(I.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(!1);var ja,oa,ka,X,$;for(ja=0;ja<w;ja++)if(I=16/y,D.set(I*A,I),X=a[ja],N.set(X.matrixWorld.n14,X.matrixWorld.n24,X.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(N),d.projectionMatrix.multiplyVector3(N),L.copy(N),K.x=L.x*u+u,K.y=L.y*E+E,k||0<K.x&&K.x<e&&0<K.y&&K.y<y){b.activeTexture(b.TEXTURE1);
+b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,K.x-8,K.y-8,16,16,0);b.uniform1i(M.renderType,0);b.uniform2f(M.scale,D.x,D.y);b.uniform3f(M.screenPosition,L.x,L.y,L.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,m);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,K.x-8,K.y-8,16,16,0);b.uniform1i(M.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
+i);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);X.positionScreen.copy(L);X.customUpdateCallback?X.customUpdateCallback(X):X.updateLensFlares();b.uniform1i(M.renderType,2);b.enable(b.BLEND);for(oa=0,ka=X.lensFlares.length;oa<ka;oa++)if($=X.lensFlares[oa],0.001<$.opacity&&0.001<$.scale)L.x=$.x,L.y=$.y,L.z=$.z,I=$.size*$.scale/y,D.x=I*A,D.y=I,b.uniform3f(M.screenPosition,L.x,L.y,L.z),b.uniform2f(M.scale,D.x,D.y),b.uniform1f(M.rotation,$.rotation),b.uniform1f(M.opacity,$.opacity),b.uniform3f(M.color,
 $.color.r,$.color.g,$.color.b),c.setBlending($.blending),c.setTexture($.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
 THREE.ShadowMapPlugin=function(){var a,b,c,d,e=new THREE.Frustum,g=new THREE.Matrix4,h=new THREE.Vector3,i=new THREE.Vector3;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,g=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:g});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:g,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=function(a,
 c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(m,k){var j,n,l,q,o,p,s,y,w,N=[];q=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(j=0,n=m.__lights.length;j<n;j++)if(l=m.__lights[j],l.castShadow)if(l instanceof THREE.DirectionalLight&&l.shadowCascade)for(o=0;o<l.shadowCascadeCount;o++){var A;if(l.shadowCascadeArray[o])A=l.shadowCascadeArray[o];else{w=l;s=o;A=new THREE.DirectionalLight;A.isVirtual=
@@ -395,9 +396,9 @@ THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,e,g,h,i,m
 h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,l=b.createProgram(),q=b.createShader(b.FRAGMENT_SHADER),o=b.createShader(b.VERTEX_SHADER);b.shaderSource(q,a.fragmentShader);b.shaderSource(o,a.vertexShader);b.compileShader(q);b.compileShader(o);b.attachShader(l,q);b.attachShader(l,o);b.linkProgram(l);i=l;m={};k={};m.position=b.getAttribLocation(i,"position");m.uv=b.getAttribLocation(i,"uv");k.uvOffset=b.getUniformLocation(i,"uvOffset");k.uvScale=b.getUniformLocation(i,
 "uvScale");k.rotation=b.getUniformLocation(i,"rotation");k.scale=b.getUniformLocation(i,"scale");k.alignment=b.getUniformLocation(i,"alignment");k.color=b.getUniformLocation(i,"color");k.map=b.getUniformLocation(i,"map");k.opacity=b.getUniformLocation(i,"opacity");k.useScreenCoordinates=b.getUniformLocation(i,"useScreenCoordinates");k.affectedByDistance=b.getUniformLocation(i,"affectedByDistance");k.screenPosition=b.getUniformLocation(i,"screenPosition");k.modelViewMatrix=b.getUniformLocation(i,"modelViewMatrix");
 k.projectionMatrix=b.getUniformLocation(i,"projectionMatrix");j=!1};this.render=function(d,e,q,o){var d=d.__webglSprites,p=d.length;if(p){var s=m,y=k,w=o/q,q=0.5*q,N=0.5*o,A=!0;b.useProgram(i);j||(b.enableVertexAttribArray(s.position),b.enableVertexAttribArray(s.uv),j=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(s.position,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(s.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.uniformMatrix4fv(y.projectionMatrix,
-!1,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(y.map,0);for(var u,D=[],s=0;s<p;s++)if(u=d[s],u.visible&&0!==u.opacity)u.useScreenCoordinates?u.z=-u.position.z:(u._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,u.matrixWorld,u._modelViewMatrixArray),u.z=-u._modelViewMatrix.n34);d.sort(a);for(s=0;s<p;s++)u=d[s],u.visible&&0!==u.opacity&&u.map&&u.map.image&&u.map.image.width&&(u.useScreenCoordinates?(b.uniform1i(y.useScreenCoordinates,1),b.uniform3f(y.screenPosition,(u.position.x-
-q)/q,(N-u.position.y)/N,Math.max(0,Math.min(1,u.position.z)))):(b.uniform1i(y.useScreenCoordinates,0),b.uniform1i(y.affectedByDistance,u.affectedByDistance?1:0),b.uniformMatrix4fv(y.modelViewMatrix,!1,u._modelViewMatrixArray)),e=u.map.image.width/(u.scaleByViewport?o:1),D[0]=e*w*u.scale.x,D[1]=e*u.scale.y,b.uniform2f(y.uvScale,u.uvScale.x,u.uvScale.y),b.uniform2f(y.uvOffset,u.uvOffset.x,u.uvOffset.y),b.uniform2f(y.alignment,u.alignment.x,u.alignment.y),b.uniform1f(y.opacity,u.opacity),b.uniform3f(y.color,
-u.color.r,u.color.g,u.color.b),b.uniform1f(y.rotation,u.rotation),b.uniform2fv(y.scale,D),u.mergeWith3D&&!A?(b.enable(b.DEPTH_TEST),A=!0):!u.mergeWith3D&&A&&(b.disable(b.DEPTH_TEST),A=!1),c.setBlending(u.blending),c.setTexture(u.map,0),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0));b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
+!1,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(y.map,0);for(var u,E=[],s=0;s<p;s++)if(u=d[s],u.visible&&0!==u.opacity)u.useScreenCoordinates?u.z=-u.position.z:(u._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,u.matrixWorld,u._modelViewMatrixArray),u.z=-u._modelViewMatrix.n34);d.sort(a);for(s=0;s<p;s++)u=d[s],u.visible&&0!==u.opacity&&u.map&&u.map.image&&u.map.image.width&&(u.useScreenCoordinates?(b.uniform1i(y.useScreenCoordinates,1),b.uniform3f(y.screenPosition,(u.position.x-
+q)/q,(N-u.position.y)/N,Math.max(0,Math.min(1,u.position.z)))):(b.uniform1i(y.useScreenCoordinates,0),b.uniform1i(y.affectedByDistance,u.affectedByDistance?1:0),b.uniformMatrix4fv(y.modelViewMatrix,!1,u._modelViewMatrixArray)),e=u.map.image.width/(u.scaleByViewport?o:1),E[0]=e*w*u.scale.x,E[1]=e*u.scale.y,b.uniform2f(y.uvScale,u.uvScale.x,u.uvScale.y),b.uniform2f(y.uvOffset,u.uvOffset.x,u.uvOffset.y),b.uniform2f(y.alignment,u.alignment.x,u.alignment.y),b.uniform1f(y.opacity,u.opacity),b.uniform3f(y.color,
+u.color.r,u.color.g,u.color.b),b.uniform1f(y.rotation,u.rotation),b.uniform2fv(y.scale,E),u.mergeWith3D&&!A?(b.enable(b.DEPTH_TEST),A=!0):!u.mergeWith3D&&A&&(b.disable(b.DEPTH_TEST),A=!1),c.setBlending(u.blending),c.setTexture(u.map,0),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0));b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
 THREE.ShaderFlares={lensFlareVertexTexture:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = (       visibility.r / 9.0 ) *\n( 1.0 - visibility.g / 9.0 ) *\n(       visibility.b / 9.0 ) *\n( 1.0 - visibility.a / 9.0 );\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},
 lensFlare:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * visibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"}};
 THREE.ShaderSprite={sprite:{vertexShader:"uniform int useScreenCoordinates;\nuniform int affectedByDistance;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position + alignment;\nvec2 rotatedPosition;\nrotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;\nrotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;\nvec4 finalPosition;\nif( useScreenCoordinates != 0 ) {\nfinalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );\n} else {\nfinalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition * ( affectedByDistance == 1 ? 1.0 : finalPosition.z );\n}\ngl_Position = finalPosition;\n}",

+ 3 - 1
src/renderers/WebGLRenderer.js

@@ -13,7 +13,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	var _canvas = parameters.canvas !== undefined ? parameters.canvas : document.createElement( 'canvas' ),
 
-	_precision = parameters.precision !== undefined ? parameters.precision : 'mediump',
+	_precision = parameters.precision !== undefined ? parameters.precision : 'highp',
 
 	_alpha = parameters.alpha !== undefined ? parameters.alpha : true,
 	_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,
@@ -5287,6 +5287,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		var prefix_vertex = [
 
+			"precision " + _precision + " float;",
+
 			( _maxVertexTextures > 0 ) ? "#define VERTEX_TEXTURES" : "",
 
 			_this.gammaInput ? "#define GAMMA_INPUT" : "",