solaris-js
Version:
A reusable component for interactive visualization of the Solar System
1 lines • 521 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Solaris=e()}(this,function(){"use strict";function t(){}function e(t,e){this.x=t||0,this.y=e||0}function n(t,i,r,a,o,s,c,l,h,u){Object.defineProperty(this,"id",{value:Fa++}),this.uuid=za.generateUUID(),this.name="",this.image=void 0!==t?t:n.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==i?i:n.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:kr,this.wrapT=void 0!==a?a:kr,this.magFilter=void 0!==o?o:Xr,this.minFilter=void 0!==s?s:qr,this.anisotropy=void 0!==h?h:1,this.format=void 0!==c?c:la,this.type=void 0!==l?l:Zr,this.offset=new e(0,0),this.repeat=new e(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==u?u:Aa,this.version=0,this.onUpdate=null}function i(t,e,n,i){this.x=t||0,this.y=e||0,this.z=n||0,this.w=void 0!==i?i:1}function r(t,e,r){this.uuid=za.generateUUID(),this.width=t,this.height=e,this.scissor=new i(0,0,t,e),this.scissorTest=!1,this.viewport=new i(0,0,t,e),void 0===(r=r||{}).minFilter&&(r.minFilter=Xr),this.texture=new n(void 0,void 0,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}function a(t,e,n,i){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==i?i:1}function o(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}function s(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function c(t,e,i,r,a,o,s,c,l,h){t=void 0!==t?t:[],e=void 0!==e?e:Nr,n.call(this,t,e,i,r,a,o,s,c,l,h),this.flipY=!1}function l(){this.seq=[],this.map={}}function h(t,e,n){var i=t[0];if(i<=0||i>0)return t;var r=e*n,a=ka[r];if(void 0===a&&(a=new Float32Array(r),ka[r]=a),0!==e){i.toArray(a,0);for(var o=1,s=0;o!==e;++o)s+=n,t[o].toArray(a,s)}return a}function u(t,e){var n=Ha[e];void 0===n&&(n=new Int32Array(e),Ha[e]=n);for(var i=0;i!==e;++i)n[i]=t.allocTextureUnit();return n}function p(t,e){t.uniform1f(this.addr,e)}function d(t,e){t.uniform1i(this.addr,e)}function f(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function m(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function g(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function v(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function y(t,e){t.uniformMatrix3fv(this.addr,!1,e.elements||e)}function x(t,e){t.uniformMatrix4fv(this.addr,!1,e.elements||e)}function _(t,e,n){var i=n.allocTextureUnit();t.uniform1i(this.addr,i),n.setTexture2D(e||Ba,i)}function b(t,e,n){var i=n.allocTextureUnit();t.uniform1i(this.addr,i),n.setTextureCube(e||Ga,i)}function w(t,e){t.uniform2iv(this.addr,e)}function M(t,e){t.uniform3iv(this.addr,e)}function E(t,e){t.uniform4iv(this.addr,e)}function T(t){switch(t){case 5126:return p;case 35664:return f;case 35665:return m;case 35666:return g;case 35674:return v;case 35675:return y;case 35676:return x;case 35678:return _;case 35680:return b;case 5124:case 35670:return d;case 35667:case 35671:return w;case 35668:case 35672:return M;case 35669:case 35673:return E}}function S(t,e){t.uniform1fv(this.addr,e)}function L(t,e){t.uniform1iv(this.addr,e)}function A(t,e){t.uniform2fv(this.addr,h(e,this.size,2))}function R(t,e){t.uniform3fv(this.addr,h(e,this.size,3))}function P(t,e){t.uniform4fv(this.addr,h(e,this.size,4))}function C(t,e){t.uniformMatrix2fv(this.addr,!1,h(e,this.size,4))}function I(t,e){t.uniformMatrix3fv(this.addr,!1,h(e,this.size,9))}function N(t,e){t.uniformMatrix4fv(this.addr,!1,h(e,this.size,16))}function U(t,e,n){var i=e.length,r=u(n,i);t.uniform1iv(this.addr,r);for(var a=0;a!==i;++a)n.setTexture2D(e[a]||Ba,r[a])}function D(t,e,n){var i=e.length,r=u(n,i);t.uniform1iv(this.addr,r);for(var a=0;a!==i;++a)n.setTextureCube(e[a]||Ga,r[a])}function O(t){switch(t){case 5126:return S;case 35664:return A;case 35665:return R;case 35666:return P;case 35674:return C;case 35675:return I;case 35676:return N;case 35678:return U;case 35680:return D;case 5124:case 35670:return L;case 35667:case 35671:return w;case 35668:case 35672:return M;case 35669:case 35673:return E}}function z(t,e,n){this.id=t,this.addr=n,this.setValue=T(e.type)}function F(t,e,n){this.id=t,this.addr=n,this.size=e.size,this.setValue=O(e.type)}function B(t){this.id=t,l.call(this)}function G(t,e){t.seq.push(e),t.map[e.id]=e}function k(t,e,n){var i=t.name,r=i.length;for(Va.lastIndex=0;;){var a=Va.exec(i),o=Va.lastIndex,s=a[1],c="]"===a[2],l=a[3];if(c&&(s|=0),void 0===l||"["===l&&o+2===r){G(n,void 0===l?new z(s,t,e):new F(s,t,e));break}var h=n.map[s];void 0===h&&G(n,h=new B(s)),n=h}}function H(t,e,n){l.call(this),this.renderer=n;for(var i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),r=0;r<i;++r){var a=t.getActiveUniform(e,r),o=a.name;k(a,t.getUniformLocation(e,o),this)}}function V(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}function j(t,e,i,r,a,o,s,c,l,h,u,p){n.call(this,null,o,s,c,l,h,r,a,u,p),this.image={data:t,width:e,height:i},this.magFilter=void 0!==l?l:Vr,this.minFilter=void 0!==h?h:Vr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function W(t,n){this.min=void 0!==t?t:new e(1/0,1/0),this.max=void 0!==n?n:new e(-1/0,-1/0)}function X(t,n){function i(){var t=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),e=new Uint16Array([0,1,2,0,2,3]);a=f.createBuffer(),s=f.createBuffer(),f.bindBuffer(f.ARRAY_BUFFER,a),f.bufferData(f.ARRAY_BUFFER,t,f.STATIC_DRAW),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,s),f.bufferData(f.ELEMENT_ARRAY_BUFFER,e,f.STATIC_DRAW),p=f.createTexture(),d=f.createTexture(),m.bindTexture(f.TEXTURE_2D,p),f.texImage2D(f.TEXTURE_2D,0,f.RGB,16,16,0,f.RGB,f.UNSIGNED_BYTE,null),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,f.NEAREST),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.NEAREST),m.bindTexture(f.TEXTURE_2D,d),f.texImage2D(f.TEXTURE_2D,0,f.RGBA,16,16,0,f.RGBA,f.UNSIGNED_BYTE,null),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,f.NEAREST),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.NEAREST),c={vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","vUV = uv;","vec2 pos = position;","if ( renderType == 2 ) {","vec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","vVisibility = visibility.r / 9.0;","vVisibility *= 1.0 - visibility.g / 9.0;","vVisibility *= visibility.b / 9.0;","vVisibility *= 1.0 - visibility.a / 9.0;","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","if ( renderType == 0 ) {","gl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","} else if ( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * vVisibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")},l=r(c),h={vertex:f.getAttribLocation(l,"position"),uv:f.getAttribLocation(l,"uv")},u={renderType:f.getUniformLocation(l,"renderType"),map:f.getUniformLocation(l,"map"),occlusionMap:f.getUniformLocation(l,"occlusionMap"),opacity:f.getUniformLocation(l,"opacity"),color:f.getUniformLocation(l,"color"),scale:f.getUniformLocation(l,"scale"),rotation:f.getUniformLocation(l,"rotation"),screenPosition:f.getUniformLocation(l,"screenPosition")}}function r(e){var n=f.createProgram(),i=f.createShader(f.FRAGMENT_SHADER),r=f.createShader(f.VERTEX_SHADER),a="precision "+t.getPrecision()+" float;\n";return f.shaderSource(i,a+e.fragmentShader),f.shaderSource(r,a+e.vertexShader),f.compileShader(i),f.compileShader(r),f.attachShader(n,i),f.attachShader(n,r),f.linkProgram(n),n}var a,s,c,l,h,u,p,d,f=t.context,m=t.state;this.render=function(r,c,g){if(0!==n.length){var v=new o,y=g.w/g.z,x=.5*g.z,_=.5*g.w,b=16/g.w,w=new e(b*y,b),M=new o(1,1,0),E=new e(1,1),T=new W;T.min.set(g.x,g.y),T.max.set(g.x+(g.z-16),g.y+(g.w-16)),void 0===l&&i(),f.useProgram(l),m.initAttributes(),m.enableAttribute(h.vertex),m.enableAttribute(h.uv),m.disableUnusedAttributes(),f.uniform1i(u.occlusionMap,0),f.uniform1i(u.map,1),f.bindBuffer(f.ARRAY_BUFFER,a),f.vertexAttribPointer(h.vertex,2,f.FLOAT,!1,16,0),f.vertexAttribPointer(h.uv,2,f.FLOAT,!1,16,8),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,s),m.disable(f.CULL_FACE),m.setDepthWrite(!1);for(var S=0,L=n.length;S<L;S++){b=16/g.w,w.set(b*y,b);var A=n[S];if(v.set(A.matrixWorld.elements[12],A.matrixWorld.elements[13],A.matrixWorld.elements[14]),v.applyMatrix4(c.matrixWorldInverse),v.applyMatrix4(c.projectionMatrix),M.copy(v),E.x=g.x+M.x*x+x-8,E.y=g.y+M.y*_+_-8,!0===T.containsPoint(E)){m.activeTexture(f.TEXTURE0),m.bindTexture(f.TEXTURE_2D,null),m.activeTexture(f.TEXTURE1),m.bindTexture(f.TEXTURE_2D,p),f.copyTexImage2D(f.TEXTURE_2D,0,f.RGB,E.x,E.y,16,16,0),f.uniform1i(u.renderType,0),f.uniform2f(u.scale,w.x,w.y),f.uniform3f(u.screenPosition,M.x,M.y,M.z),m.disable(f.BLEND),m.enable(f.DEPTH_TEST),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0),m.activeTexture(f.TEXTURE0),m.bindTexture(f.TEXTURE_2D,d),f.copyTexImage2D(f.TEXTURE_2D,0,f.RGBA,E.x,E.y,16,16,0),f.uniform1i(u.renderType,1),m.disable(f.DEPTH_TEST),m.activeTexture(f.TEXTURE1),m.bindTexture(f.TEXTURE_2D,p),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0),A.positionScreen.copy(M),A.customUpdateCallback?A.customUpdateCallback(A):A.updateLensFlares(),f.uniform1i(u.renderType,2),m.enable(f.BLEND);for(var R=0,P=A.lensFlares.length;R<P;R++){var C=A.lensFlares[R];C.opacity>.001&&C.scale>.001&&(M.x=C.x,M.y=C.y,M.z=C.z,b=C.size*C.scale/g.w,w.x=b*y,w.y=b,f.uniform3f(u.screenPosition,M.x,M.y,M.z),f.uniform2f(u.scale,w.x,w.y),f.uniform1f(u.rotation,C.rotation),f.uniform1f(u.opacity,C.opacity),f.uniform3f(u.color,C.color.r,C.color.g,C.color.b),m.setBlending(C.blending,C.blendEquation,C.blendSrc,C.blendDst),t.setTexture2D(C.texture,1),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0))}}}m.enable(f.CULL_FACE),m.enable(f.DEPTH_TEST),m.setDepthWrite(!0),t.resetGLState()}}}function Y(t,e){function i(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),e=new Uint16Array([0,1,2,0,2,3]);c=f.createBuffer(),l=f.createBuffer(),f.bindBuffer(f.ARRAY_BUFFER,c),f.bufferData(f.ARRAY_BUFFER,t,f.STATIC_DRAW),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,l),f.bufferData(f.ELEMENT_ARRAY_BUFFER,e,f.STATIC_DRAW),h=r(),u={position:f.getAttribLocation(h,"position"),uv:f.getAttribLocation(h,"uv")},p={uvOffset:f.getUniformLocation(h,"uvOffset"),uvScale:f.getUniformLocation(h,"uvScale"),rotation:f.getUniformLocation(h,"rotation"),scale:f.getUniformLocation(h,"scale"),color:f.getUniformLocation(h,"color"),map:f.getUniformLocation(h,"map"),opacity:f.getUniformLocation(h,"opacity"),modelViewMatrix:f.getUniformLocation(h,"modelViewMatrix"),projectionMatrix:f.getUniformLocation(h,"projectionMatrix"),fogType:f.getUniformLocation(h,"fogType"),fogDensity:f.getUniformLocation(h,"fogDensity"),fogNear:f.getUniformLocation(h,"fogNear"),fogFar:f.getUniformLocation(h,"fogFar"),fogColor:f.getUniformLocation(h,"fogColor"),alphaTest:f.getUniformLocation(h,"alphaTest")};var i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=8,i.height=8;var a=i.getContext("2d");a.fillStyle="white",a.fillRect(0,0,8,8),(d=new n(i)).needsUpdate=!0}function r(){var e=f.createProgram(),n=f.createShader(f.VERTEX_SHADER),i=f.createShader(f.FRAGMENT_SHADER);return f.shaderSource(n,["precision "+t.getPrecision()+" float;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),f.shaderSource(i,["precision "+t.getPrecision()+" float;","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),f.compileShader(n),f.compileShader(i),f.attachShader(e,n),f.attachShader(e,i),f.linkProgram(e),e}function s(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var c,l,h,u,p,d,f=t.context,m=t.state,g=new o,v=new a,y=new o;this.render=function(n,r){if(0!==e.length){void 0===h&&i(),f.useProgram(h),m.initAttributes(),m.enableAttribute(u.position),m.enableAttribute(u.uv),m.disableUnusedAttributes(),m.disable(f.CULL_FACE),m.enable(f.BLEND),f.bindBuffer(f.ARRAY_BUFFER,c),f.vertexAttribPointer(u.position,2,f.FLOAT,!1,16,0),f.vertexAttribPointer(u.uv,2,f.FLOAT,!1,16,8),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,l),f.uniformMatrix4fv(p.projectionMatrix,!1,r.projectionMatrix.elements),m.activeTexture(f.TEXTURE0),f.uniform1i(p.map,0);var a=0,o=0,x=n.fog;x?(f.uniform3f(p.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(f.uniform1f(p.fogNear,x.near),f.uniform1f(p.fogFar,x.far),f.uniform1i(p.fogType,1),a=1,o=1):x.isFogExp2&&(f.uniform1f(p.fogDensity,x.density),f.uniform1i(p.fogType,2),a=2,o=2)):(f.uniform1i(p.fogType,0),a=0,o=0);for(var _=0,b=e.length;_<b;_++)(M=e[_]).modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,M.matrixWorld),M.z=-M.modelViewMatrix.elements[14];e.sort(s);for(var w=[],_=0,b=e.length;_<b;_++){var M=e[_],E=M.material;if(!1!==E.visible){f.uniform1f(p.alphaTest,E.alphaTest),f.uniformMatrix4fv(p.modelViewMatrix,!1,M.modelViewMatrix.elements),M.matrixWorld.decompose(g,v,y),w[0]=y.x,w[1]=y.y;var T=0;n.fog&&E.fog&&(T=o),a!==T&&(f.uniform1i(p.fogType,T),a=T),null!==E.map?(f.uniform2f(p.uvOffset,E.map.offset.x,E.map.offset.y),f.uniform2f(p.uvScale,E.map.repeat.x,E.map.repeat.y)):(f.uniform2f(p.uvOffset,0,0),f.uniform2f(p.uvScale,1,1)),f.uniform1f(p.opacity,E.opacity),f.uniform3f(p.color,E.color.r,E.color.g,E.color.b),f.uniform1f(p.rotation,E.rotation),f.uniform2fv(p.scale,w),m.setBlending(E.blending,E.blendEquation,E.blendSrc,E.blendDst),m.setDepthTest(E.depthTest),m.setDepthWrite(E.depthWrite),E.map?t.setTexture2D(E.map,0):t.setTexture2D(d,0),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0)}}m.enable(f.CULL_FACE),t.resetGLState()}}}function q(){Object.defineProperty(this,"id",{value:Za++}),this.uuid=za.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=Ji,this.side=ki,this.shading=Wi,this.vertexColors=Xi,this.opacity=1,this.transparent=!1,this.blendSrc=hr,this.blendDst=ur,this.blendEquation=er,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=_r,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this._needsUpdate=!0}function Z(t){q.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.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!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!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function J(t){q.call(this),this.type="MeshDepthMaterial",this.depthPacking=Da,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function Q(t,e){this.min=void 0!==t?t:new o(1/0,1/0,1/0),this.max=void 0!==e?e:new o(-1/0,-1/0,-1/0)}function K(t,e){this.center=void 0!==t?t:new o,this.radius=void 0!==e?e:0}function $(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]),arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function tt(t,e){this.normal=void 0!==t?t:new o(1,0,0),this.constant=void 0!==e?e:0}function et(t,e,n,i,r,a){this.planes=[void 0!==t?t:new tt,void 0!==e?e:new tt,void 0!==n?n:new tt,void 0!==i?i:new tt,void 0!==r?r:new tt,void 0!==a?a:new tt]}function nt(t,n,a,c){function l(e,n,i,r){var a=e.geometry,o=null,s=E,c=e.customDepthMaterial;if(i&&(s=T,c=e.customDistanceMaterial),c)o=c;else{var l=!1;n.morphTargets&&(a&&a.isBufferGeometry?l=a.morphAttributes&&a.morphAttributes.position&&a.morphAttributes.position.length>0:a&&a.isGeometry&&(l=a.morphTargets&&a.morphTargets.length>0));var h=e.isSkinnedMesh&&n.skinning,u=0;l&&(u|=b),h&&(u|=w),o=s[u]}if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var p=o.uuid,d=n.uuid,f=S[p];void 0===f&&(f={},S[p]=f);var m=f[d];void 0===m&&(m=o.clone(),f[d]=m),o=m}o.visible=n.visible,o.wireframe=n.wireframe;var g=n.side;return F.renderSingleSided&&g==Vi&&(g=ki),F.renderReverseSided&&(g===ki?g=Hi:g===Hi&&(g=ki)),o.side=g,o.clipShadows=n.clipShadows,o.clippingPlanes=n.clippingPlanes,o.wireframeLinewidth=n.wireframeLinewidth,o.linewidth=n.linewidth,i&&void 0!==o.uniforms.lightPos&&o.uniforms.lightPos.value.copy(r),o}function h(t,e,n){if(!1!==t.visible){0!=(t.layers.mask&e.layers.mask)&&(t.isMesh||t.isLine||t.isPoints)&&(!t.castShadow||!1!==t.frustumCulled&&!0!==d.intersectsObject(t)||!0===t.material.visible&&(t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),_.push(t)));for(var i=t.children,r=0,a=i.length;r<a;r++)h(i[r],e,n)}}var u=t.context,p=t.state,d=new et,f=new s,m=n.shadows,g=new e,v=new e(c.maxTextureSize,c.maxTextureSize),y=new o,x=new o,_=[],b=1,w=2,M=1+(b|w),E=new Array(M),T=new Array(M),S={},L=[new o(1,0,0),new o(-1,0,0),new o(0,0,1),new o(0,0,-1),new o(0,1,0),new o(0,-1,0)],A=[new o(0,1,0),new o(0,1,0),new o(0,1,0),new o(0,1,0),new o(0,0,1),new o(0,0,-1)],R=[new i,new i,new i,new i,new i,new i],P=new J;P.depthPacking=Oa,P.clipping=!0;for(var C=qa.distanceRGBA,I=ja.clone(C.uniforms),N=0;N!==M;++N){var U=0!=(N&b),D=0!=(N&w),O=P.clone();O.morphTargets=U,O.skinning=D,E[N]=O;var z=new Z({defines:{USE_SHADOWMAP:""},uniforms:I,vertexShader:C.vertexShader,fragmentShader:C.fragmentShader,morphTargets:U,skinning:D,clipping:!0});T[N]=z}var F=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Bi,this.renderReverseSided=!0,this.renderSingleSided=!0,this.render=function(e,n){if(!1!==F.enabled&&(!1!==F.autoUpdate||!1!==F.needsUpdate)&&0!==m.length){p.buffers.color.setClear(1,1,1,1),p.disable(u.BLEND),p.setDepthTest(!0),p.setScissorTest(!1);for(var i,o,s=0,c=m.length;s<c;s++){var b=m[s],w=b.shadow;if(void 0!==w){var M=w.camera;if(g.copy(w.mapSize),g.min(v),b&&b.isPointLight){i=6,o=!0;var E=g.x,T=g.y;R[0].set(2*E,T,E,T),R[1].set(0,T,E,T),R[2].set(3*E,T,E,T),R[3].set(E,T,E,T),R[4].set(3*E,0,E,T),R[5].set(E,0,E,T),g.x*=4,g.y*=2}else i=1,o=!1;if(null===w.map){var S={minFilter:Vr,magFilter:Vr,format:la};w.map=new r(g.x,g.y,S),M.updateProjectionMatrix()}w.isSpotLightShadow&&w.update(b),w&&w.isRectAreaLightShadow&&w.update(b);var P=w.map,C=w.matrix;x.setFromMatrixPosition(b.matrixWorld),M.position.copy(x),t.setRenderTarget(P),t.clear();for(var I=0;I<i;I++){if(o){y.copy(M.position),y.add(L[I]),M.up.copy(A[I]),M.lookAt(y);var N=R[I];p.viewport(N)}else y.setFromMatrixPosition(b.target.matrixWorld),M.lookAt(y);M.updateMatrixWorld(),M.matrixWorldInverse.getInverse(M.matrixWorld),C.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),C.multiply(M.projectionMatrix),C.multiply(M.matrixWorldInverse),f.multiplyMatrices(M.projectionMatrix,M.matrixWorldInverse),d.setFromMatrix(f),_.length=0,h(e,n,M);for(var U=0,D=_.length;U<D;U++){var O=_[U],z=a.update(O),B=O.material;if(B&&B.isMultiMaterial)for(var G=z.groups,k=B.materials,H=0,V=G.length;H<V;H++){var j=G[H],W=k[j.materialIndex];if(!0===W.visible){X=l(O,W,o,x);t.renderBufferDirect(M,null,z,X,O,j)}}else{var X=l(O,B,o,x);t.renderBufferDirect(M,null,z,X,O,null)}}}}else console.warn("THREE.WebGLShadowMap:",b,"has no shadow.")}var Y=t.getClearColor(),q=t.getClearAlpha();t.setClearColor(Y,q),F.needsUpdate=!1}}}function it(t,e){this.origin=void 0!==t?t:new o,this.direction=void 0!==e?e:new o}function rt(t,e,n,i){this._x=t||0,this._y=e||0,this._z=n||0,this._order=i||rt.DefaultOrder}function at(){this.mask=1}function ot(){Object.defineProperty(this,"id",{value:Ja++}),this.uuid=za.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ot.DefaultUp.clone();var t=new o,e=new rt,n=new a,i=new o(1,1,1);e.onChange(function(){n.setFromEuler(e,!1)}),n.onChange(function(){e.setFromQuaternion(n,void 0,!1)}),Object.defineProperties(this,{position:{enumerable:!0,value:t},rotation:{enumerable:!0,value:e},quaternion:{enumerable:!0,value:n},scale:{enumerable:!0,value:i},modelViewMatrix:{value:new s},normalMatrix:{value:new $}}),this.matrix=new s,this.matrixWorld=new s,this.matrixAutoUpdate=ot.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new at,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={},this.onBeforeRender=function(){},this.onAfterRender=function(){}}function st(t,e){this.start=void 0!==t?t:new o,this.end=void 0!==e?e:new o}function ct(t,e,n){this.a=void 0!==t?t:new o,this.b=void 0!==e?e:new o,this.c=void 0!==n?n:new o}function lt(t,e,n,i,r,a){this.a=t,this.b=e,this.c=n,this.normal=i&&i.isVector3?i:new o,this.vertexNormals=Array.isArray(i)?i:[],this.color=r&&r.isColor?r:new V,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=void 0!==a?a:0}function ht(t){q.call(this),this.type="MeshBasicMaterial",this.color=new V(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Tr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.lights=!1,this.setValues(t)}function ut(t,e,n){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.uuid=za.generateUUID(),this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===n,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function pt(t,e){ut.call(this,new Uint16Array(t),e)}function dt(t,e){ut.call(this,new Uint32Array(t),e)}function ft(t,e){ut.call(this,new Float32Array(t),e)}function mt(){this.indices=[],this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function gt(t){for(var e=t.length,n=-1/0;e--;)t[e]>n&&(n=t[e]);return n}function vt(){return Qa++}function yt(){Object.defineProperty(this,"id",{value:vt()}),this.uuid=za.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.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function xt(){Object.defineProperty(this,"id",{value:vt()}),this.uuid=za.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function _t(t,e){ot.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new xt,this.material=void 0!==e?e:new ht({color:16777215*Math.random()}),this.drawMode=Ta,this.updateMorphTargets()}function bt(t,e,n,i,r,a){yt.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a},this.fromBufferGeometry(new wt(t,e,n,i,r,a)),this.mergeVertices()}function wt(t,e,n,i,r,a){function s(t,e,n,i,r,a,s,m,g,v,y){var x,_,b=a/g,w=s/v,M=a/2,E=s/2,T=m/2,S=g+1,L=v+1,A=0,R=0,P=new o;for(_=0;_<L;_++){var C=_*w-E;for(x=0;x<S;x++){var I=x*b-M;P[t]=I*i,P[e]=C*r,P[n]=T,h.push(P.x,P.y,P.z),P[t]=0,P[e]=0,P[n]=m>0?1:-1,u.push(P.x,P.y,P.z),p.push(x/g),p.push(1-_/v),A+=1}}for(_=0;_<v;_++)for(x=0;x<g;x++){var N=d+x+S*_,U=d+x+S*(_+1),D=d+(x+1)+S*(_+1),O=d+(x+1)+S*_;l.push(N,U,O),l.push(U,D,O),R+=6}c.addGroup(f,R,y),f+=R,d+=A}xt.call(this),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};var c=this;i=Math.floor(i)||1,r=Math.floor(r)||1;var l=[],h=[],u=[],p=[],d=0,f=0;s("z","y","x",-1,-1,n,e,t,a=Math.floor(a)||1,r,0),s("z","y","x",1,-1,n,e,-t,a,r,1),s("x","z","y",1,1,t,n,e,i,a,2),s("x","z","y",1,-1,t,n,-e,i,a,3),s("x","y","z",1,-1,t,e,n,i,r,4),s("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(l),this.addAttribute("position",new ft(h,3)),this.addAttribute("normal",new ft(u,3)),this.addAttribute("uv",new ft(p,2))}function Mt(t,e,n,i){yt.call(this),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i},this.fromBufferGeometry(new Et(t,e,n,i))}function Et(t,e,n,i){xt.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};var r,a,o=t/2,s=e/2,c=Math.floor(n)||1,l=Math.floor(i)||1,h=c+1,u=l+1,p=t/c,d=e/l,f=[],m=[],g=[],v=[];for(a=0;a<u;a++){var y=a*d-s;for(r=0;r<h;r++){var x=r*p-o;m.push(x,-y,0),g.push(0,0,1),v.push(r/c),v.push(1-a/l)}}for(a=0;a<l;a++)for(r=0;r<c;r++){var _=r+h*a,b=r+h*(a+1),w=r+1+h*(a+1),M=r+1+h*a;f.push(_,b,M),f.push(b,w,M)}this.setIndex(f),this.addAttribute("position",new ft(m,3)),this.addAttribute("normal",new ft(g,3)),this.addAttribute("uv",new ft(v,2))}function Tt(){ot.call(this),this.type="Camera",this.matrixWorldInverse=new s,this.projectionMatrix=new s}function St(t,e,n,i){Tt.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==n?n:.1,this.far=void 0!==i?i:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function Lt(t,e,n,i,r,a){Tt.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=void 0!==r?r:.1,this.far=void 0!==a?a:2e3,this.updateProjectionMatrix()}function At(t,e,n){var i,r,a;return{setMode:function(t){i=t},setIndex:function(n){n.array instanceof Uint32Array&&e.get("OES_element_index_uint")?(r=t.UNSIGNED_INT,a=4):n.array instanceof Uint16Array?(r=t.UNSIGNED_SHORT,a=2):(r=t.UNSIGNED_BYTE,a=1)},render:function(e,o){t.drawElements(i,o,r,e*a),n.calls++,n.vertices+=o,i===t.TRIANGLES&&(n.faces+=o/3)},renderInstances:function(o,s,c){var l=e.get("ANGLE_instanced_arrays");null!==l?(l.drawElementsInstancedANGLE(i,c,r,s*a,o.maxInstancedCount),n.calls++,n.vertices+=c*o.maxInstancedCount,i===t.TRIANGLES&&(n.faces+=o.maxInstancedCount*c/3)):console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.")}}}function Rt(t,e,n){var i;return{setMode:function(t){i=t},render:function(e,r){t.drawArrays(i,e,r),n.calls++,n.vertices+=r,i===t.TRIANGLES&&(n.faces+=r/3)},renderInstances:function(r){var a=e.get("ANGLE_instanced_arrays");if(null!==a){var o=r.attributes.position,s=0;o.isInterleavedBufferAttribute?(s=o.data.count,a.drawArraysInstancedANGLE(i,0,s,r.maxInstancedCount)):(s=o.count,a.drawArraysInstancedANGLE(i,0,s,r.maxInstancedCount)),n.calls++,n.vertices+=s*r.maxInstancedCount,i===t.TRIANGLES&&(n.faces+=r.maxInstancedCount*s/3)}else console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.")}}}function Pt(){var t={};return{get:function(n){if(void 0!==t[n.id])return t[n.id];var i;switch(n.type){case"DirectionalLight":i={direction:new o,color:new V,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new e};break;case"SpotLight":i={position:new o,direction:new o,color:new V,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new e};break;case"PointLight":i={position:new o,color:new V,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new e};break;case"HemisphereLight":i={direction:new o,skyColor:new V,groundColor:new V};break;case"RectAreaLight":i={color:new V,position:new o,halfWidth:new o,halfHeight:new o}}return t[n.id]=i,i}}}function Ct(t){for(var e=t.split("\n"),n=0;n<e.length;n++)e[n]=n+1+": "+e[n];return e.join("\n")}function It(t,e,n){var i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),!1===t.getShaderParameter(i,t.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==t.getShaderInfoLog(i)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",e===t.VERTEX_SHADER?"vertex":"fragment",t.getShaderInfoLog(i),Ct(n)),i}function Nt(t){switch(t){case Aa:return["Linear","( value )"];case Ra:return["sRGB","( value )"];case Ca:return["RGBE","( value )"];case Ia:return["RGBM","( value, 7.0 )"];case Na:return["RGBM","( value, 16.0 )"];case Ua:return["RGBD","( value, 256.0 )"];case Pa:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+t)}}function Ut(t,e){var n=Nt(e);return"vec4 "+t+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function Dt(t,e){var n=Nt(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function Ot(t,e){var n;switch(e){case Rr:n="Linear";break;case Pr:n="Reinhard";break;case Cr:n="Uncharted2";break;case Ir:n="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function zt(t,e,n){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&n.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&n.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&n.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Gt).join("\n")}function Ft(t){var e=[];for(var n in t){var i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}function Bt(t,e,n){for(var i={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),a=0;a<r;a++){var o=t.getActiveAttrib(e,a).name;i[o]=t.getAttribLocation(e,o)}return i}function Gt(t){return""!==t}function kt(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights)}function Ht(t){var e=/#include +<([\w\d.]+)>/g;return t.replace(e,function(t,e){var n=Wa[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return Ht(n)})}function Vt(t){var e=/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;return t.replace(e,function(t,e,n,i){for(var r="",a=parseInt(e);a<parseInt(n);a++)r+=i.replace(/\[ i \]/g,"[ "+a+" ]");return r})}function jt(t,e,n,i){var r=t.context,a=n.extensions,o=n.defines,s=n.__webglShader.vertexShader,c=n.__webglShader.fragmentShader,l="SHADOWMAP_TYPE_BASIC";i.shadowMapType===Bi?l="SHADOWMAP_TYPE_PCF":i.shadowMapType===Gi&&(l="SHADOWMAP_TYPE_PCF_SOFT");var h="ENVMAP_TYPE_CUBE",u="ENVMAP_MODE_REFLECTION",p="ENVMAP_BLENDING_MULTIPLY";if(i.envMap){switch(n.envMap.mapping){case Nr:case Ur:h="ENVMAP_TYPE_CUBE";break;case Fr:case Br:h="ENVMAP_TYPE_CUBE_UV";break;case Dr:case Or:h="ENVMAP_TYPE_EQUIREC";break;case zr:h="ENVMAP_TYPE_SPHERE"}switch(n.envMap.mapping){case Ur:case Or:u="ENVMAP_MODE_REFRACTION"}switch(n.combine){case Tr:p="ENVMAP_BLENDING_MULTIPLY";break;case Sr:p="ENVMAP_BLENDING_MIX";break;case Lr:p="ENVMAP_BLENDING_ADD"}}var d,f,m=t.gammaFactor>0?t.gammaFactor:1,g=zt(a,i,t.extensions),v=Ft(o),y=r.createProgram();n.isRawShaderMaterial?(d=[v,"\n"].filter(Gt).join("\n"),f=[g,v,"\n"].filter(Gt).join("\n")):(d=["precision "+i.precision+" float;","precision "+i.precision+" int;","#define SHADER_NAME "+n.__webglShader.name,v,i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+m,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+u:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.vertexColors?"#define USE_COLOR":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+i.numClippingPlanes,i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&t.extensions.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(Gt).join("\n"),f=[g,"precision "+i.precision+" float;","precision "+i.precision+" int;","#define SHADER_NAME "+n.__webglShader.name,v,i.alphaTest?"#define ALPHATEST "+i.alphaTest:"","#define GAMMA_FACTOR "+m,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.envMap?"#define "+u:"",i.envMap?"#define "+p:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.vertexColors?"#define USE_COLOR":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+i.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(i.numClippingPlanes-i.numClipIntersection),i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&t.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",i.envMap&&t.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",i.toneMapping!==Ar?"#define TONE_MAPPING":"",i.toneMapping!==Ar?Wa.tonemapping_pars_fragment:"",i.toneMapping!==Ar?Ot("toneMapping",i.toneMapping):"",i.outputEncoding||i.mapEncoding||i.envMapEncoding||i.emissiveMapEncoding?Wa.encodings_pars_fragment:"",i.mapEncoding?Ut("mapTexelToLinear",i.mapEncoding):"",i.envMapEncoding?Ut("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMapEncoding?Ut("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.outputEncoding?Dt("linearToOutputTexel",i.outputEncoding):"",i.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Gt).join("\n")),s=kt(s=Ht(s,i),i),c=kt(c=Ht(c,i),i),n.isShaderMaterial||(s=Vt(s),c=Vt(c));var x=d+s,_=f+c,b=It(r,r.VERTEX_SHADER,x),w=It(r,r.FRAGMENT_SHADER,_);r.attachShader(y,b),r.attachShader(y,w),void 0!==n.index0AttributeName?r.bindAttribLocation(y,0,n.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);var M=r.getProgramInfoLog(y),E=r.getShaderInfoLog(b),T=r.getShaderInfoLog(w),S=!0,L=!0;!1===r.getProgramParameter(y,r.LINK_STATUS)?(S=!1,console.error("THREE.WebGLProgram: shader error: ",r.getError(),"gl.VALIDATE_STATUS",r.getProgramParameter(y,r.VALIDATE_STATUS),"gl.getProgramInfoLog",M,E,T)):""!==M?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",M):""!==E&&""!==T||(L=!1),L&&(this.diagnostics={runnable:S,material:n,programLog:M,vertexShader:{log:E,prefix:d},fragmentShader:{log:T,prefix:f}}),r.deleteShader(b),r.deleteShader(w);var A;this.getUniforms=function(){return void 0===A&&(A=new H(r,y,t)),A};var R;return this.getAttributes=function(){return void 0===R&&(R=Bt(r,y)),R},this.destroy=function(){r.deleteProgram(y),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.id=Ka++,this.code=e,this.usedTimes=1,this.program=y,this.vertexShader=b,this.fragmentShader=w,this}function Wt(t,e){function n(t){if(e.floatVertexTextures&&t&&t.skeleton&&t.skeleton.useVertexTexture)return 1024;var n=e.maxVertexUniforms,i=Math.floor((n-20)/4);return void 0!==t&&t&&t.isSkinnedMesh&&(i=Math.min(t.skeleton.bones.length,i))<t.skeleton.bones.length&&console.warn("WebGLRenderer: too many bones - "+t.skeleton.bones.length+", this GPU supports just "+i+" (try OpenGL instead of ANGLE)"),i}function i(t,e){var n;return t?t.isTexture?n=t.encoding:t.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),n=t.texture.encoding):n=Aa,n===Aa&&e&&(n=Pa),n}var r=[],a={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points"},o=["precision","supportsVertexTextures","map","mapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking"];this.getParameters=function(r,o,s,c,l,h){var u=a[r.type],p=n(h),d=t.getPrecision();null!==r.precision&&(d=e.getMaxPrecision(r.precision))!==r.precision&&console.warn("THREE.WebGLProgram.getParameters:",r.precision,"not supported, using",d,"instead.");var f=t.getCurrentRenderTarget();return{shaderID:u,precision:d,supportsVertexTextures:e.vertexTextures,outputEncoding:i(f?f.texture:null,t.gammaOutput),map:!!r.map,mapEncoding:i(r.map,t.gammaInput),envMap:!!r.envMap,envMapMode:r.envMap&&r.envMap.mapping,envMapEncoding:i(r.envMap,t.gammaInput),envMapCubeUV:!!r.envMap&&(r.envMap.mapping===Fr||r.envMap.mapping===Br),lightMap:!!r.lightMap,aoMap:!!r.aoMap,emissiveMap:!!r.emissiveMap,emissiveMapEncoding:i(r.emissiveMap,t.gammaInput),bumpMap:!!r.bumpMap,normalMap:!!r.normalMap,displacementMap:!!r.displacementMap,roughnessMap:!!r.roughnessMap,metalnessMap:!!r.metalnessMap,specularMap:!!r.specularMap,alphaMap:!!r.alphaMap,gradientMap:!!r.gradientMap,combine:r.combine,vertexColors:r.vertexColors,fog:!!s,useFog:r.fog,fogExp:s&&s.isFogExp2,flatShading:r.shading===ji,sizeAttenuation:r.sizeAttenuation,logarithmicDepthBuffer:e.logarithmicDepthBuffer,skinning:r.skinning,maxBones:p,useVertexTexture:e.floatVertexTextures&&h&&h.skeleton&&h.skeleton.useVertexTexture,morphTargets:r.morphTargets,morphNormals:r.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numClippingPlanes:c,numClipIntersection:l,shadowMapEnabled:t.shadowMap.enabled&&h.receiveShadow&&o.shadows.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,alphaTest:r.alphaTest,doubleSided:r.side===Vi,flipSided:r.side===Hi,depthPacking:void 0!==r.depthPacking&&r.depthPacking}},this.getProgramCode=function(t,e){var n=[];if(e.shaderID?n.push(e.shaderID):(n.push(t.fragmentShader),n.push(t.vertexShader)),void 0!==t.defines)for(var i in t.defines)n.push(i),n.push(t.defines[i]);for(var r=0;r<o.length;r++)n.push(e[o[r]]);return n.join()},this.acquireProgram=function(e,n,i){for(var a,o=0,s=r.length;o<s;o++){var c=r[o];if(c.code===i){++(a=c).usedTimes;break}}return void 0===a&&(a=new jt(t,i,e,n),r.push(a)),a},this.releaseProgram=function(t){if(0==--t.usedTimes){var e=r.indexOf(t);r[e]=r[r.length-1],r.pop(),t.destroy()}},this.programs=r}function Xt(t,e,n){function i(t){var r=t.target,s=c[r.id];null!==s.index&&a(s.index),o(s.attributes),r.removeEventListener("dispose",i),delete c[r.id];var l=e.get(r);l.wireframe&&a(l.wireframe),e.delete(r);var h=e.get(s);h.wireframe&&a(h.wireframe),e.delete(s),n.memory.geometries--}function r(t){return t.isInterleavedBufferAttribute?e.get(t.data).__webglBuffer:e.get(t).__webglBuffer}function a(e){var n=r(e);void 0!==n&&(t.deleteBuffer(n),s(e))}function o(t){for(var e in t)a(t[e])}function s(t){t.isInterleavedBufferAttribute?e.delete(t.data):e.delete(t)}var c={};return{get:function(t){var e=t.geometry;if(void 0!==c[e.id])return c[e.id];e.addEventListener("dispose",i);var r;return e.isBufferGeometry?r=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new xt).setFromObject(t)),r=e._bufferGeometry),c[e.id]=r,n.memory.geometries++,r}}}function Yt(t,e,n){function i(t,n){var i=t.isInterleavedBufferAttribute?t.data:t,o=e.get(i);void 0===o.__webglBuffer?r(o,i,n):o.version!==i.version&&a(o,i,n)}function r(e,n,i){e.__webglBuffer=t.createBuffer(),t.bindBuffer(i,e.__webglBuffer);var r=n.dynamic?t.DYNAMIC_DRAW:t.STATIC_DRAW;t.bufferData(i,n.array,r);var a=t.FLOAT,o=n.array;o instanceof Float32Array?a=t.FLOAT:o instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array"):o instanceof Uint16Array?a=t.UNSIGNED_SHORT:o instanceof Int16Array?a=t.SHORT:o instanceof Uint32Array?a=t.UNSIGNED_INT:o instanceof Int32Array?a=t.INT:o instanceof Int8Array?a=t.BYTE:o instanceof Uint8Array&&(a=t.UNSIGNED_BYTE),e.bytesPerElement=o.BYTES_PER_ELEMENT,e.type=a,e.version=n.version,n.onUploadCallback()}function a(e,n,i){t.bindBuffer(i,e.__webglBuffer),!1===n.dynamic?t.bufferData(i,n.array,t.STATIC_DRAW):-1===n.updateRange.count?t.bufferSubData(i,0,n.array):0===n.updateRange.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."):(t.bufferSubData(i,n.updateRange.offset*n.array.BYTES_PER_ELEMENT,n.array.subarray(n.updateRange.offset,n.updateRange.offset+n.updateRange.count)),n.updateRange.count=0),e.version=n.version}var o=new Xt(t,e,n);return{getAttributeBuffer:function(t){return t.isInterleavedBufferAttribute?e.get(t.data).__webglBuffer:e.get(t).__webglBuffer},getAttributeProperties:function(t){return t.isInterleavedBufferAttribute?e.get(t.data):e.get(t)},getWireframeAttribute:function(n){var r=e.get(n);if(void 0!==r.wireframe)return r.wireframe;var a=[],o=n.index,s=n.attributes;if(null!==o)for(var c=0,l=(d=o.array).length;c<l;c+=3){var h=d[c+0],u=d[c+1],p=d[c+2];a.push(h,u,u,p,p,h)}else for(var d=s.position.array,c=0,l=d.length/3-1;c<l;c+=3){var h=c+0,u=c+1,p=c+2;a.push(h,u,u,p,p,h)}var f=new(gt(a)>65535?dt:pt)(a,1);return i(f,t.ELEMENT_ARRAY_BUFFER),r.wireframe=f,f},update:function(e){var n=o.get(e);e.geometry.isGeometry&&n.updateFromObject(e);var r=n.index,a=n.attributes;null!==r&&i(r,t.ELEMENT_ARRAY_BUFFER);for(var s in a)i(a[s],t.ARRAY_BUFFER);var c=n.morphAttributes;for(var s in c)for(var l=c[s],h=0,u=l.length;h<u;h++)i(l[h],t.ARRAY_BUFFER);return n}}}function qt(t,e,n,i,r,a,o){function s(t,e){if(t.width>e||t.height>e){var n=e/Math.max(t.width,t.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(t.width*n),i.height=Math.floor(t.height*n),i.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+i.width+"x"+i.height,t),i}return t}function c(t){return za.isPowerOfTwo(t.width)&&za.isPowerOfTwo(t.height)}function l(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=za.nearestPowerOfTwo(t.width),e.height=za.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+e.width+"x"+e.height,t),e}return t}function h(t){return t.wrapS!==kr||t.wrapT!==kr||t.minFilter!==Vr&&t.minFilter!==Xr}function u(e){return e===Vr||e===jr||e===Wr?t.NEAREST:t.LINEAR}function p(t){var e=t.target;e.removeEventListener("dispose",p),f(e),M.textures--}function d(t){var e=t.target;e.removeEventListener("dispose",d),m(e),M.textures--}function f(e){var n=i.get(e);if(e.imag