earthjs
Version:
D3 Earth JS using SVG, Canvas & THREE js, build with some plugins.
95 lines • 511 kB
JavaScript
// threejs.org/license
(function(m,na){"object"===typeof exports&&"undefined"!==typeof module?na(exports):"function"===typeof define&&define.amd?define(["exports"],na):na(m.THREE=m.THREE||{})})(this,function(m){function na(){}function D(a,b){this.x=a||0;this.y=b||0}function N(a,b,c,d,e,f,g,h,k,l){Object.defineProperty(this,"id",{value:lf++});this.uuid=R.generateUUID();this.name="";this.image=void 0!==a?a:N.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:N.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:1001;this.wrapT=
void 0!==d?d:1001;this.magFilter=void 0!==e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==k?k:1;this.format=void 0!==g?g:1023;this.type=void 0!==h?h:1009;this.offset=new D(0,0);this.repeat=new D(1,1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==l?l:3E3;this.version=0;this.onUpdate=null}function S(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}function Ab(a,b,c){this.uuid=R.generateUUID();this.width=
a;this.height=b;this.scissor=new S(0,0,a,b);this.scissorTest=!1;this.viewport=new S(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=1006);this.texture=new N(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.encoding);this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?c.depthTexture:null}function Bb(a,b,c){Ab.call(this,a,b,c);this.activeMipMapLevel=this.activeCubeFace=
0}function ia(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function n(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function O(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function bb(a,b,c,d,e,f,g,h,k,l,q,p){N.call(this,null,f,g,h,k,l,d,e,q,p);this.image={data:a,width:b,height:c};this.magFilter=void 0!==k?k:1003;this.minFilter=void 0!==l?l:1003;this.flipY=
this.generateMipmaps=!1;this.unpackAlignment=1}function Va(a,b,c,d,e,f,g,h,k,l){a=void 0!==a?a:[];N.call(this,a,void 0!==b?b:301,c,d,e,f,g,h,k,l);this.flipY=!1}function Cb(a,b,c){var d=a[0];if(0>=d||0<d)return a;var e=b*c,f=ye[e];void 0===f&&(f=new Float32Array(e),ye[e]=f);if(0!==b)for(d.toArray(f,0),d=1,e=0;d!==b;++d)e+=c,a[d].toArray(f,e);return f}function ze(a,b){var c=Ae[b];void 0===c&&(c=new Int32Array(b),Ae[b]=c);for(var d=0;d!==b;++d)c[d]=a.allocTextureUnit();return c}function mf(a,b){a.uniform1f(this.addr,
b)}function nf(a,b){a.uniform1i(this.addr,b)}function of(a,b){void 0===b.x?a.uniform2fv(this.addr,b):a.uniform2f(this.addr,b.x,b.y)}function pf(a,b){void 0!==b.x?a.uniform3f(this.addr,b.x,b.y,b.z):void 0!==b.r?a.uniform3f(this.addr,b.r,b.g,b.b):a.uniform3fv(this.addr,b)}function qf(a,b){void 0===b.x?a.uniform4fv(this.addr,b):a.uniform4f(this.addr,b.x,b.y,b.z,b.w)}function rf(a,b){a.uniformMatrix2fv(this.addr,!1,b.elements||b)}function sf(a,b){void 0===b.elements?a.uniformMatrix3fv(this.addr,!1,b):
(Be.set(b.elements),a.uniformMatrix3fv(this.addr,!1,Be))}function tf(a,b){void 0===b.elements?a.uniformMatrix4fv(this.addr,!1,b):(Ce.set(b.elements),a.uniformMatrix4fv(this.addr,!1,Ce))}function uf(a,b,c){var d=c.allocTextureUnit();a.uniform1i(this.addr,d);c.setTexture2D(b||De,d)}function vf(a,b,c){var d=c.allocTextureUnit();a.uniform1i(this.addr,d);c.setTextureCube(b||Ee,d)}function Fe(a,b){a.uniform2iv(this.addr,b)}function Ge(a,b){a.uniform3iv(this.addr,b)}function He(a,b){a.uniform4iv(this.addr,
b)}function wf(a){switch(a){case 5126:return mf;case 35664:return of;case 35665:return pf;case 35666:return qf;case 35674:return rf;case 35675:return sf;case 35676:return tf;case 35678:case 36198:return uf;case 35680:return vf;case 5124:case 35670:return nf;case 35667:case 35671:return Fe;case 35668:case 35672:return Ge;case 35669:case 35673:return He}}function xf(a,b){a.uniform1fv(this.addr,b)}function yf(a,b){a.uniform1iv(this.addr,b)}function zf(a,b){a.uniform2fv(this.addr,Cb(b,this.size,2))}function Af(a,
b){a.uniform3fv(this.addr,Cb(b,this.size,3))}function Bf(a,b){a.uniform4fv(this.addr,Cb(b,this.size,4))}function Cf(a,b){a.uniformMatrix2fv(this.addr,!1,Cb(b,this.size,4))}function Df(a,b){a.uniformMatrix3fv(this.addr,!1,Cb(b,this.size,9))}function Ef(a,b){a.uniformMatrix4fv(this.addr,!1,Cb(b,this.size,16))}function Ff(a,b,c){var d=b.length,e=ze(c,d);a.uniform1iv(this.addr,e);for(a=0;a!==d;++a)c.setTexture2D(b[a]||De,e[a])}function Gf(a,b,c){var d=b.length,e=ze(c,d);a.uniform1iv(this.addr,e);for(a=
0;a!==d;++a)c.setTextureCube(b[a]||Ee,e[a])}function Hf(a){switch(a){case 5126:return xf;case 35664:return zf;case 35665:return Af;case 35666:return Bf;case 35674:return Cf;case 35675:return Df;case 35676:return Ef;case 35678:return Ff;case 35680:return Gf;case 5124:case 35670:return yf;case 35667:case 35671:return Fe;case 35668:case 35672:return Ge;case 35669:case 35673:return He}}function If(a,b,c){this.id=a;this.addr=c;this.setValue=wf(b.type)}function Jf(a,b,c){this.id=a;this.addr=c;this.size=
b.size;this.setValue=Hf(b.type)}function Ie(a){this.id=a;this.seq=[];this.map={}}function cb(a,b,c){this.seq=[];this.map={};this.renderer=c;c=a.getProgramParameter(b,a.ACTIVE_UNIFORMS);for(var d=0;d<c;++d){var e=a.getActiveUniform(b,d),f=a.getUniformLocation(b,e.name),g=this,h=e.name,k=h.length;for(Pd.lastIndex=0;;){var l=Pd.exec(h),q=Pd.lastIndex,p=l[1],t=l[3];"]"===l[2]&&(p|=0);if(void 0===t||"["===t&&q+2===k){h=g;e=void 0===t?new If(p,e,f):new Jf(p,e,f);h.seq.push(e);h.map[e.id]=e;break}else t=
g.map[p],void 0===t&&(t=new Ie(p),p=g,g=t,p.seq.push(g),p.map[g.id]=g),g=t}}}function C(a,b,c){return void 0===b&&void 0===c?this.set(a):this.setRGB(a,b,c)}function id(a,b){this.min=void 0!==a?a:new D(Infinity,Infinity);this.max=void 0!==b?b:new D(-Infinity,-Infinity)}function Kf(a,b,c,d,e){var f,g,h,k,l,q,p,t,r,m,u,x,y,A,I,B;this.render=function(a,v,xa,la){if(0!==a.length){v=new n;var H=la.w/la.z,va=.5*la.z,jd=.5*la.w,J=16/la.w,Ga=new D(J*H,J),ga=new n(1,1,0),M=new D(1,1),T=new id;T.min.set(la.x,
la.y);T.max.set(la.x+(la.z-16),la.y+(la.w-16));if(void 0===A){var J=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),La=new Uint16Array([0,1,2,0,2,3]);u=b.createBuffer();x=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,u);b.bufferData(b.ARRAY_BUFFER,J,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,x);b.bufferData(b.ELEMENT_ARRAY_BUFFER,La,b.STATIC_DRAW);I=b.createTexture();B=b.createTexture();c.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);c.bindTexture(b.TEXTURE_2D,B);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);var J=y={vertexShader:"uniform lowp int renderType;\nuniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\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 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = visibility.r / 9.0;\nvVisibility *= 1.0 - visibility.g / 9.0;\nvVisibility *= visibility.b / 9.0;\nvVisibility *= 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:"uniform lowp int renderType;\nuniform sampler2D map;\nuniform float opacity;\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}"},La=b.createProgram(),z=b.createShader(b.FRAGMENT_SHADER),
Y=b.createShader(b.VERTEX_SHADER),w="precision "+e.precision+" float;\n";b.shaderSource(z,w+J.fragmentShader);b.shaderSource(Y,w+J.vertexShader);b.compileShader(z);b.compileShader(Y);b.attachShader(La,z);b.attachShader(La,Y);b.linkProgram(La);A=La;r=b.getAttribLocation(A,"position");m=b.getAttribLocation(A,"uv");f=b.getUniformLocation(A,"renderType");g=b.getUniformLocation(A,"map");h=b.getUniformLocation(A,"occlusionMap");k=b.getUniformLocation(A,"opacity");l=b.getUniformLocation(A,"color");q=b.getUniformLocation(A,
"scale");p=b.getUniformLocation(A,"rotation");t=b.getUniformLocation(A,"screenPosition")}c.useProgram(A);c.initAttributes();c.enableAttribute(r);c.enableAttribute(m);c.disableUnusedAttributes();b.uniform1i(h,0);b.uniform1i(g,1);b.bindBuffer(b.ARRAY_BUFFER,u);b.vertexAttribPointer(r,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(m,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,x);c.disable(b.CULL_FACE);c.buffers.depth.setMask(!1);La=0;for(z=a.length;La<z;La++)if(J=16/la.w,Ga.set(J*H,J),Y=a[La],v.set(Y.matrixWorld.elements[12],
Y.matrixWorld.elements[13],Y.matrixWorld.elements[14]),v.applyMatrix4(xa.matrixWorldInverse),v.applyMatrix4(xa.projectionMatrix),ga.copy(v),M.x=la.x+ga.x*va+va-8,M.y=la.y+ga.y*jd+jd-8,!0===T.containsPoint(M)){c.activeTexture(b.TEXTURE0);c.bindTexture(b.TEXTURE_2D,null);c.activeTexture(b.TEXTURE1);c.bindTexture(b.TEXTURE_2D,I);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,M.x,M.y,16,16,0);b.uniform1i(f,0);b.uniform2f(q,Ga.x,Ga.y);b.uniform3f(t,ga.x,ga.y,ga.z);c.disable(b.BLEND);c.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,
6,b.UNSIGNED_SHORT,0);c.activeTexture(b.TEXTURE0);c.bindTexture(b.TEXTURE_2D,B);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,M.x,M.y,16,16,0);b.uniform1i(f,1);c.disable(b.DEPTH_TEST);c.activeTexture(b.TEXTURE1);c.bindTexture(b.TEXTURE_2D,I);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);Y.positionScreen.copy(ga);Y.customUpdateCallback?Y.customUpdateCallback(Y):Y.updateLensFlares();b.uniform1i(f,2);c.enable(b.BLEND);for(var w=0,F=Y.lensFlares.length;w<F;w++){var C=Y.lensFlares[w];.001<C.opacity&&.001<
C.scale&&(ga.x=C.x,ga.y=C.y,ga.z=C.z,J=C.size*C.scale/la.w,Ga.x=J*H,Ga.y=J,b.uniform3f(t,ga.x,ga.y,ga.z),b.uniform2f(q,Ga.x,Ga.y),b.uniform1f(p,C.rotation),b.uniform1f(k,C.opacity),b.uniform3f(l,C.color.r,C.color.g,C.color.b),c.setBlending(C.blending,C.blendEquation,C.blendSrc,C.blendDst),d.setTexture2D(C.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0))}}c.enable(b.CULL_FACE);c.enable(b.DEPTH_TEST);c.buffers.depth.setMask(!0);c.reset()}}}function oc(a,b,c,d,e,f,g,h,k){N.call(this,a,b,
c,d,e,f,g,h,k);this.needsUpdate=!0}function Lf(a,b,c,d,e){var f,g,h,k,l,q,p,t,r,m,u,x,y,A,I,B,H;function va(a,b){return a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.z!==b.z?b.z-a.z:b.id-a.id}var xa,la,ba,Je,jd=new n,J=new ia,Ga=new n;this.render=function(v,n,T){if(0!==v.length){if(void 0===ba){var M=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),z=new Uint16Array([0,1,2,0,2,3]);xa=b.createBuffer();la=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,xa);b.bufferData(b.ARRAY_BUFFER,
M,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,la);b.bufferData(b.ELEMENT_ARRAY_BUFFER,z,b.STATIC_DRAW);M=b.createProgram();z=b.createShader(b.VERTEX_SHADER);var w=b.createShader(b.FRAGMENT_SHADER);b.shaderSource(z,["precision "+e.precision+" float;","#define SHADER_NAME SpriteMaterial\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\nvec4 finalPosition;\nfinalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition;\nfinalPosition = projectionMatrix * finalPosition;\ngl_Position = finalPosition;\n}"].join("\n"));
b.shaderSource(w,["precision "+e.precision+" float;","#define SHADER_NAME SpriteMaterial\nuniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\nif ( texture.a < alphaTest ) discard;\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\nif ( fogType > 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n"));
b.compileShader(z);b.compileShader(w);b.attachShader(M,z);b.attachShader(M,w);b.linkProgram(M);ba=M;B=b.getAttribLocation(ba,"position");H=b.getAttribLocation(ba,"uv");f=b.getUniformLocation(ba,"uvOffset");g=b.getUniformLocation(ba,"uvScale");h=b.getUniformLocation(ba,"rotation");k=b.getUniformLocation(ba,"scale");l=b.getUniformLocation(ba,"color");q=b.getUniformLocation(ba,"map");p=b.getUniformLocation(ba,"opacity");t=b.getUniformLocation(ba,"modelViewMatrix");r=b.getUniformLocation(ba,"projectionMatrix");
m=b.getUniformLocation(ba,"fogType");u=b.getUniformLocation(ba,"fogDensity");x=b.getUniformLocation(ba,"fogNear");y=b.getUniformLocation(ba,"fogFar");A=b.getUniformLocation(ba,"fogColor");I=b.getUniformLocation(ba,"alphaTest");M=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");M.width=8;M.height=8;z=M.getContext("2d");z.fillStyle="white";z.fillRect(0,0,8,8);Je=new oc(M)}c.useProgram(ba);c.initAttributes();c.enableAttribute(B);c.enableAttribute(H);c.disableUnusedAttributes();c.disable(b.CULL_FACE);
c.enable(b.BLEND);b.bindBuffer(b.ARRAY_BUFFER,xa);b.vertexAttribPointer(B,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(H,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,la);b.uniformMatrix4fv(r,!1,T.projectionMatrix.elements);c.activeTexture(b.TEXTURE0);b.uniform1i(q,0);z=M=0;(w=n.fog)?(b.uniform3f(A,w.color.r,w.color.g,w.color.b),w.isFog?(b.uniform1f(x,w.near),b.uniform1f(y,w.far),b.uniform1i(m,1),z=M=1):w.isFogExp2&&(b.uniform1f(u,w.density),b.uniform1i(m,2),z=M=2)):(b.uniform1i(m,0),z=M=0);
for(var D=0,C=v.length;D<C;D++)w=v[D],w.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,w.matrixWorld),w.z=-w.modelViewMatrix.elements[14];v.sort(va);for(var ga=[],D=0,C=v.length;D<C;D++){w=v[D];var G=w.material;if(!1!==G.visible){w.onBeforeRender(a,n,T,void 0,G,void 0);b.uniform1f(I,G.alphaTest);b.uniformMatrix4fv(t,!1,w.modelViewMatrix.elements);w.matrixWorld.decompose(jd,J,Ga);ga[0]=Ga.x;ga[1]=Ga.y;var F=0;n.fog&&G.fog&&(F=z);M!==F&&(b.uniform1i(m,F),M=F);null!==G.map?(b.uniform2f(f,G.map.offset.x,
G.map.offset.y),b.uniform2f(g,G.map.repeat.x,G.map.repeat.y)):(b.uniform2f(f,0,0),b.uniform2f(g,1,1));b.uniform1f(p,G.opacity);b.uniform3f(l,G.color.r,G.color.g,G.color.b);b.uniform1f(h,G.rotation);b.uniform2fv(k,ga);c.setBlending(G.blending,G.blendEquation,G.blendSrc,G.blendDst,G.blendEquationAlpha,G.blendSrcAlpha,G.blendDstAlpha,G.premultipliedAlpha);c.buffers.depth.setTest(G.depthTest);c.buffers.depth.setMask(G.depthWrite);d.setTexture2D(G.map||Je,0);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,
0);w.onAfterRender(a,n,T,void 0,G,void 0)}}c.enable(b.CULL_FACE);c.reset()}}}function P(){Object.defineProperty(this,"id",{value:Mf++});this.uuid=R.generateUUID();this.name="";this.type="Material";this.lights=this.fog=!0;this.blending=1;this.side=0;this.flatShading=!1;this.vertexColors=0;this.opacity=1;this.transparent=!1;this.blendSrc=204;this.blendDst=205;this.blendEquation=100;this.blendEquationAlpha=this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=3;this.depthWrite=this.depthTest=!0;
this.clippingPlanes=null;this.clipShadows=this.clipIntersection=!1;this.colorWrite=!0;this.precision=null;this.polygonOffset=!1;this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.dithering=!1;this.alphaTest=0;this.premultipliedAlpha=!1;this.overdraw=0;this.visible=!0;this.userData={};this.needsUpdate=!0}function ya(a){P.call(this);this.type="ShaderMaterial";this.defines={};this.uniforms={};this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";
this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";this.linewidth=1;this.wireframe=!1;this.wireframeLinewidth=1;this.morphNormals=this.morphTargets=this.skinning=this.clipping=this.lights=this.fog=!1;this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]};this.index0AttributeName=void 0;void 0!==a&&(void 0!==a.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),
this.setValues(a))}function Wa(a){P.call(this);this.type="MeshDepthMaterial";this.depthPacking=3200;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.lights=this.fog=!1;this.setValues(a)}function Xa(a){P.call(this);this.type="MeshDistanceMaterial";this.referencePosition=new n;this.nearDistance=1;this.farDistance=1E3;this.morphTargets=this.skinning=!1;this.displacementMap=
this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.lights=this.fog=!1;this.setValues(a)}function Pa(a,b){this.min=void 0!==a?a:new n(Infinity,Infinity,Infinity);this.max=void 0!==b?b:new n(-Infinity,-Infinity,-Infinity)}function Ca(a,b){this.center=void 0!==a?a:new n;this.radius=void 0!==b?b:0}function qa(){this.elements=[1,0,0,0,1,0,0,0,1];0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function za(a,
b){this.normal=void 0!==a?a:new n(1,0,0);this.constant=void 0!==b?b:0}function kd(a,b,c,d,e,f){this.planes=[void 0!==a?a:new za,void 0!==b?b:new za,void 0!==c?c:new za,void 0!==d?d:new za,void 0!==e?e:new za,void 0!==f?f:new za]}function Ke(a,b,c){function d(b,c,d,e,f,g){var h=b.geometry;var l=p;var k=b.customDepthMaterial;d&&(l=t,k=b.customDistanceMaterial);k?l=k:(k=!1,c.morphTargets&&(h&&h.isBufferGeometry?k=h.morphAttributes&&h.morphAttributes.position&&0<h.morphAttributes.position.length:h&&h.isGeometry&&
(k=h.morphTargets&&0<h.morphTargets.length)),b.isSkinnedMesh&&!1===c.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",b),b=b.isSkinnedMesh&&c.skinning,h=0,k&&(h|=1),b&&(h|=2),l=l[h]);a.localClippingEnabled&&!0===c.clipShadows&&0!==c.clippingPlanes.length&&(h=l.uuid,k=c.uuid,b=r[h],void 0===b&&(b={},r[h]=b),h=b[k],void 0===h&&(h=l.clone(),b[k]=h),l=h);l.visible=c.visible;l.wireframe=c.wireframe;k=c.side;B.renderSingleSided&&2==k&&(k=0);B.renderReverseSided&&
(0===k?k=1:1===k&&(k=0));l.side=k;l.clipShadows=c.clipShadows;l.clippingPlanes=c.clippingPlanes;l.clipIntersection=c.clipIntersection;l.wireframeLinewidth=c.wireframeLinewidth;l.linewidth=c.linewidth;d&&l.isMeshDistanceMaterial&&(l.referencePosition.copy(e),l.nearDistance=f,l.farDistance=g);return l}function e(c,g,h,l){var k;if(!1!==c.visible){if(c.layers.test(g.layers)&&(c.isMesh||c.isLine||c.isPoints)&&c.castShadow&&(!c.frustumCulled||f.intersectsObject(c))){c.modelViewMatrix.multiplyMatrices(h.matrixWorldInverse,
c.matrixWorld);var p=b.update(c),t=c.material;if(Array.isArray(t))for(var r=p.groups,A=0,m=r.length;A<m;A++){var v=r[A];(k=t[v.materialIndex])&&k.visible&&(k=d(c,k,l,q,h.near,h.far),a.renderBufferDirect(h,null,p,k,c,v))}else t.visible&&(k=d(c,t,l,q,h.near,h.far),a.renderBufferDirect(h,null,p,k,c,null))}c=c.children;p=0;for(t=c.length;p<t;p++)e(c[p],g,h,l)}}var f=new kd,g=new O,h=new D,k=new D(c,c),l=new n,q=new n,p=Array(4),t=Array(4),r={},m=[new n(1,0,0),new n(-1,0,0),new n(0,0,1),new n(0,0,-1),
new n(0,1,0),new n(0,-1,0)],u=[new n(0,1,0),new n(0,1,0),new n(0,1,0),new n(0,1,0),new n(0,0,1),new n(0,0,-1)],x=[new S,new S,new S,new S,new S,new S];for(c=0;4!==c;++c){var y=0!==(c&1),A=0!==(c&2),I=new Wa({depthPacking:3201,morphTargets:y,skinning:A});p[c]=I;y=new Xa({morphTargets:y,skinning:A});t[c]=y}var B=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=1;this.renderSingleSided=this.renderReverseSided=!0;this.render=function(b,c,d){if(!1!==B.enabled&&(!1!==B.autoUpdate||
!1!==B.needsUpdate)&&0!==b.length){var p=a.state;p.disable(a.context.BLEND);p.buffers.color.setClear(1,1,1,1);p.buffers.depth.setTest(!0);p.setScissorTest(!1);for(var t,r=0,A=b.length;r<A;r++){var v=b[r];t=v.shadow;var I=v&&v.isPointLight;if(void 0===t)console.warn("THREE.WebGLShadowMap:",v,"has no shadow.");else{var n=t.camera;h.copy(t.mapSize);h.min(k);if(I){var y=h.x,H=h.y;x[0].set(2*y,H,y,H);x[1].set(0,H,y,H);x[2].set(3*y,H,y,H);x[3].set(y,H,y,H);x[4].set(3*y,0,y,H);x[5].set(y,0,y,H);h.x*=4;h.y*=
2}null===t.map&&(t.map=new Ab(h.x,h.y,{minFilter:1003,magFilter:1003,format:1023}),t.map.texture.name=v.name+".shadowMap",n.updateProjectionMatrix());t.isSpotLightShadow&&t.update(v);y=t.map;H=t.matrix;q.setFromMatrixPosition(v.matrixWorld);n.position.copy(q);I?(t=6,H.makeTranslation(-q.x,-q.y,-q.z)):(t=1,l.setFromMatrixPosition(v.target.matrixWorld),n.lookAt(l),n.updateMatrixWorld(),H.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),H.multiply(n.projectionMatrix),H.multiply(n.matrixWorldInverse));a.setRenderTarget(y);
a.clear();for(v=0;v<t;v++)I&&(l.copy(n.position),l.add(m[v]),n.up.copy(u[v]),n.lookAt(l),n.updateMatrixWorld(),p.viewport(x[v])),g.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),f.setFromMatrix(g),e(c,d,n,I)}}B.needsUpdate=!1}}}function Nf(a){var b={};return{get:function(a){a.isInterleavedBufferAttribute&&(a=a.data);return b[a.uuid]},remove:function(c){c.isInterleavedBufferAttribute&&(c=c.data);var d=b[c.uuid];d&&(a.deleteBuffer(d.buffer),delete b[c.uuid])},update:function(c,d){c.isInterleavedBufferAttribute&&
(c=c.data);var e=b[c.uuid];if(void 0===e){var e=c.uuid,f=c.array,g=c.dynamic?a.DYNAMIC_DRAW:a.STATIC_DRAW,h=a.createBuffer();a.bindBuffer(d,h);a.bufferData(d,f,g);c.onUploadCallback();d=a.FLOAT;f instanceof Float32Array?d=a.FLOAT:f instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):f instanceof Uint16Array?d=a.UNSIGNED_SHORT:f instanceof Int16Array?d=a.SHORT:f instanceof Uint32Array?d=a.UNSIGNED_INT:f instanceof Int32Array?d=a.INT:f instanceof
Int8Array?d=a.BYTE:f instanceof Uint8Array&&(d=a.UNSIGNED_BYTE);b[e]={buffer:h,type:d,bytesPerElement:f.BYTES_PER_ELEMENT,version:c.version}}else e.version<c.version&&(f=c,h=f.array,g=f.updateRange,a.bindBuffer(d,e.buffer),!1===f.dynamic?a.bufferData(d,h,a.STATIC_DRAW):-1===g.count?a.bufferSubData(d,0,h):0===g.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):
(a.bufferSubData(d,g.offset*h.BYTES_PER_ELEMENT,h.subarray(g.offset,g.offset+g.count)),g.count=-1),e.version=c.version)}}}function Ya(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||Ya.DefaultOrder}function Qd(){this.mask=1}function w(){Object.defineProperty(this,"id",{value:Of++});this.uuid=R.generateUUID();this.name="";this.type="Object3D";this.parent=null;this.children=[];this.up=w.DefaultUp.clone();var a=new n,b=new Ya,c=new ia,d=new n(1,1,1);b.onChange(function(){c.setFromEuler(b,
!1)});c.onChange(function(){b.setFromQuaternion(c,void 0,!1)});Object.defineProperties(this,{position:{enumerable:!0,value:a},rotation:{enumerable:!0,value:b},quaternion:{enumerable:!0,value:c},scale:{enumerable:!0,value:d},modelViewMatrix:{value:new O},normalMatrix:{value:new qa}});this.matrix=new O;this.matrixWorld=new O;this.matrixAutoUpdate=w.DefaultMatrixAutoUpdate;this.matrixWorldNeedsUpdate=!1;this.layers=new Qd;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.renderOrder=
0;this.userData={}}function Ma(){w.call(this);this.type="Camera";this.matrixWorldInverse=new O;this.projectionMatrix=new O}function Db(a,b,c,d,e,f){Ma.call(this);this.type="OrthographicCamera";this.zoom=1;this.view=null;this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=void 0!==e?e:.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()}function ja(a,b,c,d){Ma.call(this);this.type="PerspectiveCamera";this.fov=void 0!==a?a:50;this.zoom=1;this.near=void 0!==c?c:.1;this.far=void 0!==d?d:
2E3;this.focus=10;this.aspect=void 0!==b?b:1;this.view=null;this.filmGauge=35;this.filmOffset=0;this.updateProjectionMatrix()}function Qa(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d&&d.isVector3?d:new n;this.vertexNormals=Array.isArray(d)?d:[];this.color=e&&e.isColor?e:new C;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex=void 0!==f?f:0}function Q(){Object.defineProperty(this,"id",{value:Rd++});this.uuid=R.generateUUID();this.name="";this.type="Geometry";this.vertices=[];this.colors=
[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.verticesNeedUpdate=this.elementsNeedUpdate=!1}function K(a,b,c){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.uuid=R.generateUUID();this.name=
"";this.array=a;this.itemSize=b;this.count=void 0!==a?a.length/b:0;this.normalized=!0===c;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.onUploadCallback=function(){};this.version=0}function pc(a,b){K.call(this,new Int8Array(a),b)}function qc(a,b){K.call(this,new Uint8Array(a),b)}function rc(a,b){K.call(this,new Uint8ClampedArray(a),b)}function sc(a,b){K.call(this,new Int16Array(a),b)}function db(a,b){K.call(this,new Uint16Array(a),b)}function tc(a,b){K.call(this,new Int32Array(a),b)}function eb(a,
b){K.call(this,new Uint32Array(a),b)}function z(a,b){K.call(this,new Float32Array(a),b)}function uc(a,b){K.call(this,new Float64Array(a),b)}function Le(){this.indices=[];this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function Sd(a){if(0===a.length)return-Infinity;
for(var b=a[0],c=1,d=a.length;c<d;++c)a[c]>b&&(b=a[c]);return b}function F(){Object.defineProperty(this,"id",{value:Rd++});this.uuid=R.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity}}function Eb(a,b,c,d,e,f){Q.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};this.fromBufferGeometry(new fb(a,
b,c,d,e,f));this.mergeVertices()}function fb(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,m,va,xa,la){var A=f/va,v=g/xa,u=f/2,x=g/2,I=m/2;g=va+1;var B=xa+1,y=f=0,H,w,z=new n;for(w=0;w<B;w++){var D=w*v-x;for(H=0;H<g;H++)z[a]=(H*A-u)*d,z[b]=D*e,z[c]=I,l.push(z.x,z.y,z.z),z[a]=0,z[b]=0,z[c]=0<m?1:-1,q.push(z.x,z.y,z.z),p.push(H/va),p.push(1-w/xa),f+=1}for(w=0;w<xa;w++)for(H=0;H<va;H++)a=t+H+g*(w+1),b=t+(H+1)+g*(w+1),c=t+(H+1)+g*w,k.push(t+H+g*w,a,c),k.push(a,b,c),y+=6;h.addGroup(r,y,la);r+=y;t+=f}F.call(this);
this.type="BoxBufferGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};var h=this;d=Math.floor(d)||1;e=Math.floor(e)||1;f=Math.floor(f)||1;var k=[],l=[],q=[],p=[],t=0,r=0;g("z","y","x",-1,-1,c,b,a,f,e,0);g("z","y","x",1,-1,c,b,-a,f,e,1);g("x","z","y",1,1,a,c,b,d,f,2);g("x","z","y",1,-1,a,c,-b,d,f,3);g("x","y","z",1,-1,a,b,c,d,e,4);g("x","y","z",-1,-1,a,b,-c,d,e,5);this.setIndex(k);this.addAttribute("position",new z(l,3));this.addAttribute("normal",
new z(q,3));this.addAttribute("uv",new z(p,2))}function vc(a,b,c,d){Q.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new gb(a,b,c,d));this.mergeVertices()}function gb(a,b,c,d){F.call(this);this.type="PlaneBufferGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};var e=a/2,f=b/2;c=Math.floor(c)||1;d=Math.floor(d)||1;var g=c+1,h=d+1,k=a/c,l=b/d,q=[],p=[],t=[],r=[];for(a=0;a<h;a++){var m=a*l-f;
for(b=0;b<g;b++)p.push(b*k-e,-m,0),t.push(0,0,1),r.push(b/c),r.push(1-a/d)}for(a=0;a<d;a++)for(b=0;b<c;b++)e=b+g*(a+1),f=b+1+g*(a+1),h=b+1+g*a,q.push(b+g*a,e,h),q.push(e,f,h);this.setIndex(q);this.addAttribute("position",new z(p,3));this.addAttribute("normal",new z(t,3));this.addAttribute("uv",new z(r,2))}function sa(a){P.call(this);this.type="MeshBasicMaterial";this.color=new C(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=
this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.lights=this.morphTargets=this.skinning=!1;this.setValues(a)}function hb(a,b){this.origin=void 0!==a?a:new n;this.direction=void 0!==b?b:new n}function Fb(a,b){this.start=void 0!==a?a:new n;this.end=void 0!==b?b:new n}function Ra(a,b,c){this.a=void 0!==a?a:new n;this.b=void 0!==b?b:new n;this.c=void 0!==c?c:new n}function fa(a,
b){w.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new F;this.material=void 0!==b?b:new sa({color:16777215*Math.random()});this.drawMode=0;this.updateMorphTargets()}function Pf(a,b,c,d){function e(a,c){b.buffers.color.setClear(a.r,a.g,a.b,c,d)}var f=new C(0),g=0,h,k,l;return{getClearColor:function(){return f},setClearColor:function(a,b){f.set(a);g=void 0!==b?b:1;e(f,g)},getClearAlpha:function(){return g},setClearAlpha:function(a){g=a;e(f,g)},render:function(b,d,t,r){d=d.background;null===
d?e(f,g):d&&d.isColor&&(e(d,1),r=!0);(a.autoClear||r)&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil);d&&d.isCubeTexture?(void 0===l&&(l=new fa(new fb(1,1,1),new ya({uniforms:ib.cube.uniforms,vertexShader:ib.cube.vertexShader,fragmentShader:ib.cube.fragmentShader,side:1,depthTest:!0,depthWrite:!1,polygonOffset:!0,fog:!1})),l.geometry.removeAttribute("normal"),l.geometry.removeAttribute("uv"),l.onBeforeRender=function(a,b,c){a=c.far;this.matrixWorld.makeScale(a,a,a);this.matrixWorld.copyPosition(c.matrixWorld);
this.material.polygonOffsetUnits=10*a},c.update(l.geometry)),l.material.uniforms.tCube.value=d,b.push(l,l.geometry,l.material,0,null)):d&&d.isTexture&&(void 0===h&&(h=new Db(-1,1,1,-1,0,1),k=new fa(new gb(2,2),new sa({depthTest:!1,depthWrite:!1,fog:!1})),c.update(k.geometry)),k.material.map=d,a.renderBufferDirect(h,null,k.geometry,k.material,k,null))}}}function Qf(a,b){return a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.program&&b.program&&a.program!==b.program?a.program.id-b.program.id:
a.material.id!==b.material.id?a.material.id-b.material.id:a.z!==b.z?a.z-b.z:a.id-b.id}function Rf(a,b){return a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function Sf(){var a=[],b=0,c=[],d=[];return{opaque:c,transparent:d,init:function(){b=0;c.length=0;d.length=0},push:function(e,f,g,h,k){var l=a[b];void 0===l?(l={id:e.id,object:e,geometry:f,material:g,program:g.program,renderOrder:e.renderOrder,z:h,group:k},a[b]=l):(l.id=e.id,l.object=e,l.geometry=f,l.material=
g,l.program=g.program,l.renderOrder=e.renderOrder,l.z=h,l.group=k);(!0===g.transparent?d:c).push(l);b++},sort:function(){1<c.length&&c.sort(Qf);1<d.length&&d.sort(Rf)}}}function Tf(){var a={};return{get:function(b,c){b=b.id+","+c.id;c=a[b];void 0===c&&(c=new Sf,a[b]=c);return c},dispose:function(){a={}}}}function Uf(a,b){return Math.abs(b[1])-Math.abs(a[1])}function Vf(a){var b={},c=new Float32Array(8);return{update:function(d,e,f,g){var h=d.morphTargetInfluences,k=h.length;d=b[e.id];if(void 0===
d){d=[];for(var l=0;l<k;l++)d[l]=[l,0];b[e.id]=d}var q=f.morphTargets&&e.morphAttributes.position;f=f.morphNormals&&e.morphAttributes.normal;for(l=0;l<k;l++){var p=d[l];0!==p[1]&&(q&&e.removeAttribute("morphTarget"+l),f&&e.removeAttribute("morphNormal"+l))}for(l=0;l<k;l++)p=d[l],p[0]=l,p[1]=h[l];d.sort(Uf);for(l=0;8>l;l++){if(p=d[l])if(h=p[0],p=p[1]){q&&e.addAttribute("morphTarget"+l,q[h]);f&&e.addAttribute("morphNormal"+l,f[h]);c[l]=p;continue}c[l]=0}g.getUniforms().setValue(a,"morphTargetInfluences",
c)}}}function Wf(a,b,c){var d,e,f;this.setMode=function(a){d=a};this.setIndex=function(a){e=a.type;f=a.bytesPerElement};this.render=function(b,h){a.drawElements(d,h,e,b*f);c.calls++;c.vertices+=h;d===a.TRIANGLES?c.faces+=h/3:d===a.POINTS&&(c.points+=h)};this.renderInstances=function(g,h,k){var l=b.get("ANGLE_instanced_arrays");null===l?console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."):(l.drawElementsInstancedANGLE(d,
k,e,h*f,g.maxInstancedCount),c.calls++,c.vertices+=k*g.maxInstancedCount,d===a.TRIANGLES?c.faces+=g.maxInstancedCount*k/3:d===a.POINTS&&(c.points+=g.maxInstancedCount*k))}}function Xf(a,b,c){var d;this.setMode=function(a){d=a};this.render=function(b,f){a.drawArrays(d,b,f);c.calls++;c.vertices+=f;d===a.TRIANGLES?c.faces+=f/3:d===a.POINTS&&(c.points+=f)};this.renderInstances=function(e,f,g){var h=b.get("ANGLE_instanced_arrays");if(null===h)console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
else{var k=e.attributes.position;k.isInterleavedBufferAttribute?(g=k.data.count,h.drawArraysInstancedANGLE(d,0,g,e.maxInstancedCount)):h.drawArraysInstancedANGLE(d,f,g,e.maxInstancedCount);c.calls++;c.vertices+=g*e.maxInstancedCount;d===a.TRIANGLES?c.faces+=e.maxInstancedCount*g/3:d===a.POINTS&&(c.points+=e.maxInstancedCount*g)}}}function Yf(a,b,c){function d(a){a=a.target;var g=e[a.id];null!==g.index&&b.remove(g.index);for(var k in g.attributes)b.remove(g.attributes[k]);a.removeEventListener("dispose",
d);delete e[a.id];if(k=f[a.id])b.remove(k),delete f[a.id];if(k=f[g.id])b.remove(k),delete f[g.id];c.geometries--}var e={},f={};return{get:function(a,b){var f=e[b.id];if(f)return f;b.addEventListener("dispose",d);b.isBufferGeometry?f=b:b.isGeometry&&(void 0===b._bufferGeometry&&(b._bufferGeometry=(new F).setFromObject(a)),f=b._bufferGeometry);e[b.id]=f;c.geometries++;return f},update:function(c){var d=c.index,e=c.attributes;null!==d&&b.update(d,a.ELEMENT_ARRAY_BUFFER);for(var f in e)b.update(e[f],
a.ARRAY_BUFFER);c=c.morphAttributes;for(f in c)for(var d=c[f],e=0,g=d.length;e<g;e++)b.update(d[e],a.ARRAY_BUFFER)},getWireframeAttribute:function(c){var d=f[c.id];if(d)return d;d=[];var e=c.index;var g=c.attributes;if(null!==e){var q=e.array;for(var p=0,t=q.length;p<t;p+=3){var r=q[p+0];g=q[p+1];e=q[p+2];d.push(r,g,g,e,e,r)}}else for(q=g.position.array,p=0,t=q.length/3-1;p<t;p+=3)r=p+0,g=p+1,e=p+2,d.push(r,g,g,e,e,r);d=new (65535<Sd(d)?eb:db)(d,1);b.update(d,a.ELEMENT_ARRAY_BUFFER);return f[c.id]=
d}}}function Zf(){var a={};return{get:function(b){if(void 0!==a[b.id])return a[b.id];switch(b.type){case "DirectionalLight":var c={direction:new n,color:new C,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new D};break;case "SpotLight":c={position:new n,direction:new n,color:new C,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new D};break;case "PointLight":c={position:new n,color:new C,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new D,
shadowCameraNear:1,shadowCameraFar:1E3};break;case "HemisphereLight":c={direction:new n,skyColor:new C,groundColor:new C};break;case "RectAreaLight":c={color:new C,position:new n,halfWidth:new n,halfHeight:new n}}return a[b.id]=c}}}function $f(){var a=new Zf,b={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},c=new n,d=new O,e=new O;return{setup:function(f,
g,h){for(var k,l=0,q=0,p=0,t=0,r=0,m=0,u=0,x=0,n=h.matrixWorldInverse,A=0,I=f.length;A<I;A++){var B=f[A];k=B.color;var H=B.intensity,va=B.distance,xa=B.shadow&&B.shadow.map?B.shadow.map.texture:null;if(B.isAmbientLight)l+=k.r*H,q+=k.g*H,p+=k.b*H;else if(B.isDirectionalLight){h=a.get(B);h.color.copy(B.color).multiplyScalar(B.intensity);h.direction.setFromMatrixPosition(B.matrixWorld);c.setFromMatrixPosition(B.target.matrixWorld);h.direction.sub(c);h.direction.transformDirection(n);if(h.shadow=B.castShadow)k=
B.shadow,h.shadowBias=k.bias,h.shadowRadius=k.radius,h.shadowMapSize=k.mapSize;b.directionalShadowMap[t]=xa;b.directionalShadowMatrix[t]=B.shadow.matrix;b.directional[t]=h;t++}else if(B.isSpotLight){h=a.get(B);h.position.setFromMatrixPosition(B.matrixWorld);h.position.applyMatrix4(n);h.color.copy(k).multiplyScalar(H);h.distance=va;h.direction.setFromMatrixPosition(B.matrixWorld);c.setFromMatrixPosition(B.target.matrixWorld);h.direction.sub(c);h.direction.transformDirection(n);h.coneCos=Math.cos(B.angle);
h.penumbraCos=Math.cos(B.angle*(1-B.penumbra));h.decay=0===B.distance?0:B.decay;if(h.shadow=B.castShadow)k=B.shadow,h.shadowBias=k.bias,h.shadowRadius=k.radius,h.shadowMapSize=k.mapSize;b.spotShadowMap[m]=xa;b.spotShadowMatrix[m]=B.shadow.matrix;b.spot[m]=h;m++}else if(B.isRectAreaLight)h=a.get(B),h.color.copy(k).multiplyScalar(H/(B.width*B.height)),h.position.setFromMatrixPosition(B.matrixWorld),h.position.applyMatrix4(n),e.identity(),d.copy(B.matrixWorld),d.premultiply(n),e.extractRotation(d),h.halfWidth.set(.5*
B.width,0,0),h.halfHeight.set(0,.5*B.height,0),h.halfWidth.applyMatrix4(e),h.halfHeight.applyMatrix4(e),b.rectArea[u]=h,u++;else if(B.isPointLight){h=a.get(B);h.position.setFromMatrixPosition(B.matrixWorld);h.position.applyMatrix4(n);h.color.copy(B.color).multiplyScalar(B.intensity);h.distance=B.distance;h.decay=0===B.distance?0:B.decay;if(h.shadow=B.castShadow)k=B.shadow,h.shadowBias=k.bias,h.shadowRadius=k.radius,h.shadowMapSize=k.mapSize,h.shadowCameraNear=k.camera.near,h.shadowCameraFar=k.camera.far;
b.pointShadowMap[r]=xa;b.pointShadowMatrix[r]=B.shadow.matrix;b.point[r]=h;r++}else B.isHemisphereLight&&(h=a.get(B),h.direction.setFromMatrixPosition(B.matrixWorld),h.direction.transformDirection(n),h.direction.normalize(),h.skyColor.copy(B.color).multiplyScalar(H),h.groundColor.copy(B.groundColor).multiplyScalar(H),b.hemi[x]=h,x++)}b.ambient[0]=l;b.ambient[1]=q;b.ambient[2]=p;b.directional.length=t;b.spot.length=m;b.rectArea.length=u;b.point.length=r;b.hemi.length=x;b.hash=t+","+r+","+m+","+u+","+
x+","+g.length},state:b}}function ag(a,b){var c={};return{update:function(d){var e=b.frame,f=d.geometry,g=a.get(d,f);c[g.id]!==e&&(f.isGeometry&&g.updateFromObject(d),a.update(g),c[g.id]=e);return g},clear:function(){c={}}}}function bg(a){a=a.split("\n");for(var b=0;b<a.length;b++)a[b]=b+1+": "+a[b];return a.join("\n")}function Me(a,b,c){var d=a.createShader(b);a.shaderSource(d,c);a.compileShader(d);!1===a.getShaderParameter(d,a.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile.");
""!==a.getShaderInfoLog(d)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",b===a.VERTEX_SHADER?"vertex":"fragment",a.getShaderInfoLog(d),bg(c));return d}function Ne(a){switch(a){case 3E3:return["Linear","( value )"];case 3001:return["sRGB","( value )"];case 3002:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case 3007:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw Error("unsupported encoding: "+
a);}}function Td(a,b){b=Ne(b);return"vec4 "+a+"( vec4 value ) { return "+b[0]+"ToLinear"+b[1]+"; }"}function cg(a,b){b=Ne(b);return"vec4 "+a+"( vec4 value ) { return LinearTo"+b[0]+b[1]+"; }"}function dg(a,b){switch(b){case 1:b="Linear";break;case 2:b="Reinhard";break;case 3:b="Uncharted2";break;case 4:b="OptimizedCineon";break;default:throw Error("unsupported toneMapping: "+b);}return"vec3 "+a+"( vec3 color ) { return "+b+"ToneMapping( color ); }"}function eg(a,b,c){a=a||{};return[a.derivatives||
b.envMapCubeUV||b.bumpMap||b.normalMap||b.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(a.fragDepth||b.logarithmicDepthBuffer)&&c.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",a.drawBuffers&&c.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(a.shaderTextureLOD||b.envMap)&&c.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(wc).join("\n")}function fg(a){var b=[],c;for(c in a){var d=a[c];!1!==d&&b.push("#define "+
c+" "+d)}return b.join("\n")}function wc(a){return""!==a}function Oe(a,b){return a.replace(/NUM_DIR_LIGHTS/g,b.numDirLights).replace(/NUM_SPOT_LIGHTS/g,b.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,b.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,b.numPointLights).replace(/NUM_HEMI_LIGHTS/g,b.numHemiLights)}function Ud(a){return a.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(a,c){a=V[c];if(void 0===a)throw Error("Can not resolve #include <"+c+">");return Ud(a)})}function Pe(a){return a.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,
function(a,c,d,e){a="";for(c=parseInt(c);c<parseInt(d);c++)a+=e.replace(/\[ i \]/g,"[ "+c+" ]");return a})}function gg(a,b,c,d,e,f){var g=a.context,h=d.defines,k=e.vertexShader,l=e.fragmentShader,q="SHADOWMAP_TYPE_BASIC";1===f.shadowMapType?q="SHADOWMAP_TYPE_PCF":2===f.shadowMapType&&(q="SHADOWMAP_TYPE_PCF_SOFT");var p="ENVMAP_TYPE_CUBE",t="ENVMAP_MODE_REFLECTION",r="ENVMAP_BLENDING_MULTIPLY";if(f.envMap){switch(d.envMap.mapping){case 301:case 302:p="ENVMAP_TYPE_CUBE";break;case 306:case 307:p="ENVMAP_TYPE_CUBE_UV";
break;case 303:case 304:p="ENVMAP_TYPE_EQUIREC";break;case 305:p="ENVMAP_TYPE_SPHERE"}switch(d.envMap.mapping){case 302:case 304:t="ENVMAP_MODE_REFRACTION"}switch(d.combine){case 0:r="ENVMAP_BLENDING_MULTIPLY";break;case 1:r="ENVMAP_BLENDING_MIX";break;case 2:r="ENVMAP_BLENDING_ADD"}}var m=0<a.gammaFactor?a.gammaFactor:1,u=eg(d.extensions,f,b),x=fg(h),n=g.createProgram();d.isRawShaderMaterial?(h=[x,"\n"].filter(wc).join("\n"),b=[u,x,"\n"].filter(wc).join("\n")):(h=["precision "+f.precision+" float;",
"precision "+f.precision+" int;","#define SHADER_NAME "+e.name,x,f.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+m,"#define MAX_BONES "+f.maxBones,f.useFog&&f.fog?"#define USE_FOG":"",f.useFog&&f.fogExp?"#define FOG_EXP2":"",f.map?"#define USE_MAP":"",f.envMap?"#define USE_ENVMAP":"",f.envMap?"#define "+t:"",f.lightMap?"#define USE_LIGHTMAP":"",f.aoMap?"#define USE_AOMAP":"",f.emissiveMap?"#define USE_EMISSIVEMAP":"",f.bumpMap?"#define USE_BUMPMAP":"",f.normalMap?"#define USE_NORMALMAP":
"",f.displacementMap&&f.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",f.specularMap?"#define USE_SPECULARMAP":"",f.roughnessMap?"#define USE_ROUGHNESSMAP":"",f.metalnessMap?"#define USE_METALNESSMAP":"",f.alphaMap?"#define USE_ALPHAMAP":"",f.vertexColors?"#define USE_COLOR":"",f.flatShading?"#define FLAT_SHADED":"",f.skinning?"#define USE_SKINNING":"",f.useVertexTexture?"#define BONE_TEXTURE":"",f.morphTargets?"#define USE_MORPHTARGETS":"",f.morphNormals&&!1===f.flatShading?"#define USE_MORPHNORMALS":
"",f.doubleSided?"#define DOUBLE_SIDED":"",f.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+f.numClippingPlanes,f.shadowMapEnabled?"#define USE_SHADOWMAP":"",f.shadowMapEnabled?"#define "+q:"",f.sizeAttenuation?"#define USE_SIZEATTENUATION":"",f.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",f.logarithmicDepthBuffer&&b.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;",
"uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;",
"\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(wc).join("\n"),b=[u,"precision "+f.precision+" float;","precision "+f.precision+" int;","#define SHADER_NAME "+e.name,x,f.alphaTest?"#define ALPHATEST "+f.alphaTest:"","#define GAMMA_FACTOR "+m,f.useFog&&f.fog?"#define USE_FOG":
"",f.useFog&&f.fogExp?"#define FOG_EXP2":"",f.map?"#define USE_MAP":"",f.envMap?"#define USE_ENVMAP":"",f.envMap?"#define "+p:"",f.envMap?"#define "+t:"",f.envMap?"#define "+r:"",f.lightMap?"#define USE_LIGHTMAP":"",f.aoMap?"#define USE_AOMAP":"",f.emissiveMap?"#define USE_EMISSIVEMAP":"",f.bumpMap?"#define USE_BUMPMAP":"",f.normalMap?"#define USE_NORMALMAP":"",f.specularMap?"#define USE_SPECULARMAP":"",f.roughnessMap?"#define USE_ROUGHNESSMAP":"",f.metalnessMap?"#define USE_METALNESSMAP":"",f.alphaMap?
"#define USE_ALPHAMAP":"",f.vertexColors?"#define USE_COLOR":"",f.gradientMap?"#define USE_GRADIENTMAP":"",f.flatShading?"#define FLAT_SHADED":"",f.doubleSided?"#define DOUBLE_SIDED":"",f.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+f.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(f.numClippingPlanes-f.numClipIntersection),f.shadowMapEnabled?"#define USE_SHADOWMAP":"",f.shadowMapEnabled?"#define "+q:"",f.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",f.physicallyCorrectLights?
"#define PHYSICALLY_CORRECT_LIGHTS":"",f.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",f.logarithmicDepthBuffer&&b.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",f.envMap&&b.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",0!==f.toneMapping?"#define TONE_MAPPING":"",0!==f.toneMapping?V.tonemapping_pars_fragment:"",0!==f.toneMapping?dg("toneMapping",f.toneMapping):"",f.dithering?"#define DITHERING":"",f.outputEncoding||
f.mapEncoding||f.envMapEncoding||f.emissiveMapEncoding?V.encodings_pars_fragment:"",f.mapEncoding?Td("mapTexelToLinear",f.mapEncoding):"",f.envMapEncoding?Td("envMapTexelToLinear",f.envMapEncoding):"",f.emissiveMapEncoding?Td("emissiveMapTexelToLinear",f.emissiveMapEncoding):"",f.outputEncoding?cg("linearToOutputTexel",f.outputEncoding):"",f.depthPacking?"#define DEPTH_PACKING "+d.depthPacking:"","\n"].filter(wc).join("\n"));k=Ud(k);k=Oe(k,f);l=Ud(l);l=Oe(l,f);d.isShaderMaterial||(k=Pe(k),l=Pe(l));
l=b+l;k=Me(g,g.VERTEX_SHADER,h+k);l=Me(g,g.FRAGMENT_SHADER,l);g.attachShader(n,k);g.attachShader(n,l);void 0!==d.index0AttributeName?g.bindAttribLocation(n,0,d.index0AttributeName):!0===f.morphTargets&&g.bindAttribLocation(n,0,"position");g.linkProgram(n);f=g.getProgramInfoLog(n);e=g.getShaderInfoLog(k);q=g.getShaderInfoLog(l);t=p=!0;if(!1===g.getProgramParameter(n,g.LINK_STATUS))p=!1,console.error("THREE.WebGLProgram: shader error: ",g.getError(),"gl.VALIDATE_STATUS",g.getProgramParameter(n,g.VALIDATE_STATUS),
"gl.getProgramInfoLog",f,e,q);else if(""!==f)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",f);else if(""===e||""===q)t=!1;t&&(this.diagnostics={runnable:p,material:d,programLog:f,vertexShader:{log:e,prefix:h},fragmentShader:{log:q,prefix:b}});g.deleteShader(k);g.deleteShader(l);var A;this.getUniforms=function(){void 0===A&&(A=new cb(g,n,a));return A};var I;this.getAttributes=function(){if(void 0===I){for(var a={},b=g.getProgramParameter(n,g.ACTIVE_ATTRIBUTES),c=0;c<b;c++){var d=g.getActiveAttrib(n,
c).name;a[d]=g.getAttribLocation(n,d)}I=a}return I};this.destroy=function(){g.deleteProgram(n);this.program=void 0};Object.defineProperties(this,{uniforms:{get:function(){console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms().");return this.getUniforms()}},attributes:{get:function(){console.warn("THREE.WebGLProgram: .attributes is now .getAttributes().");return this.getAttributes()}}});this.id=hg++;this.code=c;this.usedTimes=1