forked from expo/troggle
2 lines
644 KiB
JavaScript
2 lines
644 KiB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.CV=t.CV||{})}(this,function(t){"use strict";function e(){this.elements=[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 r(t,e,r,n){this._x=t||0,this._y=e||0,this._z=r||0,this._w=void 0!==n?n:1}function n(t,e,r){this.x=t||0,this.y=e||0,this.z=r||0}function i(t){if(void 0!==t){var e;for(e in t)Bs.set(e,t[e])}}function a(t,e){return Bs.has(t)?Bs.get(t):e}function o(t,e){return t.split(".").shift()+"."+e}function s(){}function c(t,e,r){return void 0===e&&void 0===r?this.set(t):this.setRGB(t,e,r)}function l(){}function h(t,e){this.x=t||0,this.y=e||0}function u(t,e,r,n,i,a,o,s,c,l){Object.defineProperty(this,"id",{value:Wl++}),this.uuid=Ko.generateUUID(),this.name="",this.image=void 0!==t?t:u.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:u.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:Zc,this.wrapT=void 0!==n?n:Zc,this.magFilter=void 0!==i?i:tl,this.minFilter=void 0!==a?a:rl,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:vl,this.type=void 0!==s?s:nl,this.offset=new h(0,0),this.repeat=new h(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:Ul,this.version=0,this.onUpdate=null}function d(t,e,r,n,i,a,o,s,c,l,h,d){u.call(this,null,a,o,s,c,l,n,i,h,d),this.image={data:t,width:e,height:r},this.magFilter=void 0!==c?c:Qc,this.minFilter=void 0!==l?l:Qc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function p(t){for(var e=t.length,r=new Uint8Array(3*e),n=0;n<e;){var i=t[e-++n],a=3*n;r[a]=i[0],r[a+1]=i[1],r[a+2]=i[2]}var o=new d(r,e,1,gl,nl);return o.needsUpdate=!0,o}function f(t){for(var e,r=[],n=0,i=t.length;n<i;n++)e=t[n],r[n]=new c(e[0]/255,e[1]/255,e[2]/255);return r}function m(t,e,r){var n=Xl[t],i=n[r];if(void 0===i){var a=ks[r];void 0===a&&console.error("unknown colour scale requested "+r),i=e(a),n[r]=i}return i}function g(t){return m("texture",p,t)}function v(t){return m("colors",f,t)}function y(t,e,r,n){this.x=t||0,this.y=e||0,this.z=r||0,this.w=void 0!==n?n:1}function x(t,e,r){this.uuid=Ko.generateUUID(),this.width=t,this.height=e,this.scissor=new y(0,0,t,e),this.scissorTest=!1,this.viewport=new y(0,0,t,e),void 0===(r=r||{}).minFilter&&(r.minFilter=tl),this.texture=new u(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 b(t,e,r,n,i,a,o,s,c,l){t=void 0!==t?t:[],e=void 0!==e?e:Gc,u.call(this,t,e,r,n,i,a,o,s,c,l),this.flipY=!1}function w(){this.seq=[],this.map={}}function _(t,e,r){var n=t[0];if(n<=0||n>0)return t;var i=e*r,a=Jl[i];if(void 0===a&&(a=new Float32Array(i),Jl[i]=a),0!==e){n.toArray(a,0);for(var o=1,s=0;o!==e;++o)s+=r,t[o].toArray(a,s)}return a}function M(t,e){var r=Ql[e];void 0===r&&(r=new Int32Array(e),Ql[e]=r);for(var n=0;n!==e;++n)r[n]=t.allocTextureUnit();return r}function E(t,e){t.uniform1f(this.addr,e)}function S(t,e){t.uniform1i(this.addr,e)}function T(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function A(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 L(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function C(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function R(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):($l.set(e.elements),t.uniformMatrix3fv(this.addr,!1,$l))}function P(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(Kl.set(e.elements),t.uniformMatrix4fv(this.addr,!1,Kl))}function I(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTexture2D(e||ql,n)}function O(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTextureCube(e||Zl,n)}function N(t,e){t.uniform2iv(this.addr,e)}function D(t,e){t.uniform3iv(this.addr,e)}function U(t,e){t.uniform4iv(this.addr,e)}function z(t){switch(t){case 5126:return E;case 35664:return T;case 35665:return A;case 35666:return L;case 35674:return C;case 35675:return R;case 35676:return P;case 35678:case 36198:return I;case 35680:return O;case 5124:case 35670:return S;case 35667:case 35671:return N;case 35668:case 35672:return D;case 35669:case 35673:return U}}function B(t,e){t.uniform1fv(this.addr,e)}function F(t,e){t.uniform1iv(this.addr,e)}function k(t,e){t.uniform2fv(this.addr,_(e,this.size,2))}function G(t,e){t.uniform3fv(this.addr,_(e,this.size,3))}function V(t,e){t.uniform4fv(this.addr,_(e,this.size,4))}function H(t,e){t.uniformMatrix2fv(this.addr,!1,_(e,this.size,4))}function j(t,e){t.uniformMatrix3fv(this.addr,!1,_(e,this.size,9))}function W(t,e){t.uniformMatrix4fv(this.addr,!1,_(e,this.size,16))}function X(t,e,r){var n=e.length,i=M(r,n);t.uniform1iv(this.addr,i);for(var a=0;a!==n;++a)r.setTexture2D(e[a]||ql,i[a])}function Y(t,e,r){var n=e.length,i=M(r,n);t.uniform1iv(this.addr,i);for(var a=0;a!==n;++a)r.setTextureCube(e[a]||Zl,i[a])}function q(t){switch(t){case 5126:return B;case 35664:return k;case 35665:return G;case 35666:return V;case 35674:return H;case 35675:return j;case 35676:return W;case 35678:return X;case 35680:return Y;case 5124:case 35670:return F;case 35667:case 35671:return N;case 35668:case 35672:return D;case 35669:case 35673:return U}}function Z(t,e,r){this.id=t,this.addr=r,this.setValue=z(e.type)}function J(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=q(e.type)}function Q(t){this.id=t,w.call(this)}function K(t,e){t.seq.push(e),t.map[e.id]=e}function $(t,e,r){var n=t.name,i=n.length;for(th.lastIndex=0;;){var a=th.exec(n),o=th.lastIndex,s=a[1],c="]"===a[2],l=a[3];if(c&&(s|=0),void 0===l||"["===l&&o+2===i){K(r,void 0===l?new Z(s,t,e):new J(s,t,e));break}var h=r.map[s];void 0===h&&K(r,h=new Q(s)),r=h}}function tt(t,e,r){w.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i<n;++i){var a=t.getActiveUniform(e,i),o=a.name;$(a,t.getUniformLocation(e,o),this)}}function et(t,e){this.min=void 0!==t?t:new h(1/0,1/0),this.max=void 0!==e?e:new h(-1/0,-1/0)}function rt(t,e){function r(){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(),o=f.createBuffer(),f.bindBuffer(f.ARRAY_BUFFER,a),f.bufferData(f.ARRAY_BUFFER,t,f.STATIC_DRAW),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,o),f.bufferData(f.ELEMENT_ARRAY_BUFFER,e,f.STATIC_DRAW),d=f.createTexture(),p=f.createTexture(),m.bindTexture(f.TEXTURE_2D,d),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,p),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),s={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")},c=i(s),l={vertex:f.getAttribLocation(c,"position"),uv:f.getAttribLocation(c,"uv")},u={renderType:f.getUniformLocation(c,"renderType"),map:f.getUniformLocation(c,"map"),occlusionMap:f.getUniformLocation(c,"occlusionMap"),opacity:f.getUniformLocation(c,"opacity"),color:f.getUniformLocation(c,"color"),scale:f.getUniformLocation(c,"scale"),rotation:f.getUniformLocation(c,"rotation"),screenPosition:f.getUniformLocation(c,"screenPosition")}}function i(e){var r=f.createProgram(),n=f.createShader(f.FRAGMENT_SHADER),i=f.createShader(f.VERTEX_SHADER),a="precision "+t.getPrecision()+" float;\n";return f.shaderSource(n,a+e.fragmentShader),f.shaderSource(i,a+e.vertexShader),f.compileShader(n),f.compileShader(i),f.attachShader(r,n),f.attachShader(r,i),f.linkProgram(r),r}var a,o,s,c,l,u,d,p,f=t.context,m=t.state;this.render=function(i,s,g){if(0!==e.length){var v=new n,y=g.w/g.z,x=.5*g.z,b=.5*g.w,w=16/g.w,_=new h(w*y,w),M=new n(1,1,0),E=new h(1,1),S=new et;S.min.set(g.x,g.y),S.max.set(g.x+(g.z-16),g.y+(g.w-16)),void 0===c&&r(),f.useProgram(c),m.initAttributes(),m.enableAttribute(l.vertex),m.enableAttribute(l.uv),m.disableUnusedAttributes(),f.uniform1i(u.occlusionMap,0),f.uniform1i(u.map,1),f.bindBuffer(f.ARRAY_BUFFER,a),f.vertexAttribPointer(l.vertex,2,f.FLOAT,!1,16,0),f.vertexAttribPointer(l.uv,2,f.FLOAT,!1,16,8),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,o),m.disable(f.CULL_FACE),m.buffers.depth.setMask(!1);for(var T=0,A=e.length;T<A;T++){w=16/g.w,_.set(w*y,w);var L=e[T];if(v.set(L.matrixWorld.elements[12],L.matrixWorld.elements[13],L.matrixWorld.elements[14]),v.applyMatrix4(s.matrixWorldInverse),v.applyMatrix4(s.projectionMatrix),M.copy(v),E.x=g.x+M.x*x+x-8,E.y=g.y+M.y*b+b-8,!0===S.containsPoint(E)){m.activeTexture(f.TEXTURE0),m.bindTexture(f.TEXTURE_2D,null),m.activeTexture(f.TEXTURE1),m.bindTexture(f.TEXTURE_2D,d),f.copyTexImage2D(f.TEXTURE_2D,0,f.RGB,E.x,E.y,16,16,0),f.uniform1i(u.renderType,0),f.uniform2f(u.scale,_.x,_.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,p),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,d),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0),L.positionScreen.copy(M),L.customUpdateCallback?L.customUpdateCallback(L):L.updateLensFlares(),f.uniform1i(u.renderType,2),m.enable(f.BLEND);for(var C=0,R=L.lensFlares.length;C<R;C++){var P=L.lensFlares[C];P.opacity>.001&&P.scale>.001&&(M.x=P.x,M.y=P.y,M.z=P.z,w=P.size*P.scale/g.w,_.x=w*y,_.y=w,f.uniform3f(u.screenPosition,M.x,M.y,M.z),f.uniform2f(u.scale,_.x,_.y),f.uniform1f(u.rotation,P.rotation),f.uniform1f(u.opacity,P.opacity),f.uniform3f(u.color,P.color.r,P.color.g,P.color.b),m.setBlending(P.blending,P.blendEquation,P.blendSrc,P.blendDst),t.setTexture2D(P.texture,1),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0))}}}m.enable(f.CULL_FACE),m.enable(f.DEPTH_TEST),m.buffers.depth.setMask(!0),t.resetGLState()}}}function nt(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]);s=f.createBuffer(),c=f.createBuffer(),f.bindBuffer(f.ARRAY_BUFFER,s),f.bufferData(f.ARRAY_BUFFER,t,f.STATIC_DRAW),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,c),f.bufferData(f.ELEMENT_ARRAY_BUFFER,e,f.STATIC_DRAW),l=a(),h={position:f.getAttribLocation(l,"position"),uv:f.getAttribLocation(l,"uv")},d={uvOffset:f.getUniformLocation(l,"uvOffset"),uvScale:f.getUniformLocation(l,"uvScale"),rotation:f.getUniformLocation(l,"rotation"),scale:f.getUniformLocation(l,"scale"),color:f.getUniformLocation(l,"color"),map:f.getUniformLocation(l,"map"),opacity:f.getUniformLocation(l,"opacity"),modelViewMatrix:f.getUniformLocation(l,"modelViewMatrix"),projectionMatrix:f.getUniformLocation(l,"projectionMatrix"),fogType:f.getUniformLocation(l,"fogType"),fogDensity:f.getUniformLocation(l,"fogDensity"),fogNear:f.getUniformLocation(l,"fogNear"),fogFar:f.getUniformLocation(l,"fogFar"),fogColor:f.getUniformLocation(l,"fogColor"),alphaTest:f.getUniformLocation(l,"alphaTest")};var r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");r.width=8,r.height=8;var n=r.getContext("2d");n.fillStyle="white",n.fillRect(0,0,8,8),(p=new u(r)).needsUpdate=!0}function a(){var e=f.createProgram(),r=f.createShader(f.VERTEX_SHADER),n=f.createShader(f.FRAGMENT_SHADER);return f.shaderSource(r,["precision "+t.getPrecision()+" float;","#define SHADER_NAME SpriteMaterial","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(n,["precision "+t.getPrecision()+" float;","#define SHADER_NAME SpriteMaterial","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(r),f.compileShader(n),f.attachShader(e,r),f.attachShader(e,n),f.linkProgram(e),e}function o(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var s,c,l,h,d,p,f=t.context,m=t.state,g=new n,v=new r,y=new n;this.render=function(r,n){if(0!==e.length){void 0===l&&i(),f.useProgram(l),m.initAttributes(),m.enableAttribute(h.position),m.enableAttribute(h.uv),m.disableUnusedAttributes(),m.disable(f.CULL_FACE),m.enable(f.BLEND),f.bindBuffer(f.ARRAY_BUFFER,s),f.vertexAttribPointer(h.position,2,f.FLOAT,!1,16,0),f.vertexAttribPointer(h.uv,2,f.FLOAT,!1,16,8),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,c),f.uniformMatrix4fv(d.projectionMatrix,!1,n.projectionMatrix.elements),m.activeTexture(f.TEXTURE0),f.uniform1i(d.map,0);var a=0,u=0,x=r.fog;x?(f.uniform3f(d.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(f.uniform1f(d.fogNear,x.near),f.uniform1f(d.fogFar,x.far),f.uniform1i(d.fogType,1),a=1,u=1):x.isFogExp2&&(f.uniform1f(d.fogDensity,x.density),f.uniform1i(d.fogType,2),a=2,u=2)):(f.uniform1i(d.fogType,0),a=0,u=0);for(var b=0,w=e.length;b<w;b++)(M=e[b]).modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,M.matrixWorld),M.z=-M.modelViewMatrix.elements[14];e.sort(o);for(var _=[],b=0,w=e.length;b<w;b++){var M=e[b],E=M.material;if(!1!==E.visible){M.onBeforeRender(t,r,n,void 0,E,void 0),f.uniform1f(d.alphaTest,E.alphaTest),f.uniformMatrix4fv(d.modelViewMatrix,!1,M.modelViewMatrix.elements),M.matrixWorld.decompose(g,v,y),_[0]=y.x,_[1]=y.y;var S=0;r.fog&&E.fog&&(S=u),a!==S&&(f.uniform1i(d.fogType,S),a=S),null!==E.map?(f.uniform2f(d.uvOffset,E.map.offset.x,E.map.offset.y),f.uniform2f(d.uvScale,E.map.repeat.x,E.map.repeat.y)):(f.uniform2f(d.uvOffset,0,0),f.uniform2f(d.uvScale,1,1)),f.uniform1f(d.opacity,E.opacity),f.uniform3f(d.color,E.color.r,E.color.g,E.color.b),f.uniform1f(d.rotation,E.rotation),f.uniform2fv(d.scale,_),m.setBlending(E.blending,E.blendEquation,E.blendSrc,E.blendDst,E.blendEquationAlpha,E.blendSrcAlpha,E.blendDstAlpha,E.premultipliedAlpha),m.buffers.depth.setTest(E.depthTest),m.buffers.depth.setMask(E.depthWrite),E.map?t.setTexture2D(E.map,0):t.setTexture2D(p,0),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0),M.onAfterRender(t,r,n,void 0,E,void 0)}}m.enable(f.CULL_FACE),t.resetGLState()}}}function it(){Object.defineProperty(this,"id",{value:ah++}),this.uuid=Ko.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=ic,this.side=Zs,this.shading=$s,this.vertexColors=tc,this.opacity=1,this.transparent=!1,this.blendSrc=yc,this.blendDst=xc,this.blendEquation=lc,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Lc,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.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.needsUpdate=!0}function at(t){it.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 ot(t){it.call(this),this.type="MeshDepthMaterial",this.depthPacking=Hl,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 st(t,e){this.min=void 0!==t?t:new n(1/0,1/0,1/0),this.max=void 0!==e?e:new n(-1/0,-1/0,-1/0)}function ct(t,e){this.center=void 0!==t?t:new n,this.radius=void 0!==e?e:0}function lt(){this.elements=[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 ht(t,e){this.normal=void 0!==t?t:new n(1,0,0),this.constant=void 0!==e?e:0}function ut(t,e,r,n,i,a){this.planes=[void 0!==t?t:new ht,void 0!==e?e:new ht,void 0!==r?r:new ht,void 0!==n?n:new ht,void 0!==i?i:new ht,void 0!==a?a:new ht]}function dt(t,r,i,a){function o(e,r,n,i){var a=e.geometry,o=null,s=M,c=e.customDepthMaterial;if(n&&(s=E,c=e.customDistanceMaterial),c)o=c;else{var l=!1;r.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)),e.isSkinnedMesh&&!1===r.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e);var h=e.isSkinnedMesh&&r.skinning,u=0;l&&(u|=b),h&&(u|=w),o=s[u]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var d=o.uuid,p=r.uuid,f=S[d];void 0===f&&(f={},S[d]=f);var m=f[p];void 0===m&&(m=o.clone(),f[p]=m),o=m}o.visible=r.visible,o.wireframe=r.wireframe;var g=r.side;return z.renderSingleSided&&g==Qs&&(g=Zs),z.renderReverseSided&&(g===Zs?g=Js:g===Js&&(g=Zs)),o.side=g,o.clipShadows=r.clipShadows,o.clippingPlanes=r.clippingPlanes,o.wireframeLinewidth=r.wireframeLinewidth,o.linewidth=r.linewidth,n&&void 0!==o.uniforms.lightPos&&o.uniforms.lightPos.value.copy(i),o}function s(e,r,n,a){if(!1!==e.visible){if(e.layers.test(r.layers)&&(e.isMesh||e.isLine||e.isPoints)&&e.castShadow&&(!e.frustumCulled||u.intersectsObject(e))){e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld);var c=i.update(e),l=e.material;if(Array.isArray(l))for(var h=c.groups,d=0,p=h.length;d<p;d++){var f=h[d],m=l[f.materialIndex];if(m&&m.visible){g=o(e,m,a,v);t.renderBufferDirect(n,null,c,g,e,f)}}else if(l.visible){var g=o(e,l,a,v);t.renderBufferDirect(n,null,c,g,e,null)}}for(var y=e.children,x=0,b=y.length;x<b;x++)s(y[x],r,n,a)}}var c=t.context,l=t.state,u=new ut,d=new e,p=r.shadows,f=new h,m=new h(a.maxTextureSize,a.maxTextureSize),g=new n,v=new n,b=1,w=2,_=1+(b|w),M=new Array(_),E=new Array(_),S={},T=[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)],A=[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)],L=[new y,new y,new y,new y,new y,new y],C=new ot;C.depthPacking=jl,C.clipping=!0;for(var R=ih.distanceRGBA,P=rh.clone(R.uniforms),I=0;I!==_;++I){var O=0!=(I&b),N=0!=(I&w),D=C.clone();D.morphTargets=O,D.skinning=N,M[I]=D;var U=new at({defines:{USE_SHADOWMAP:""},uniforms:P,vertexShader:R.vertexShader,fragmentShader:R.fragmentShader,morphTargets:O,skinning:N,clipping:!0});E[I]=U}var z=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ys,this.renderReverseSided=!0,this.renderSingleSided=!0,this.render=function(e,r){if(!1!==z.enabled&&(!1!==z.autoUpdate||!1!==z.needsUpdate)&&0!==p.length){l.disable(c.BLEND),l.buffers.color.setClear(1,1,1,1),l.buffers.depth.setTest(!0),l.setScissorTest(!1);for(var n,i=0,a=p.length;i<a;i++){var o=p[i],h=o.shadow,y=o&&o.isPointLight;if(void 0!==h){var b=h.camera;if(f.copy(h.mapSize),f.min(m),y){var w=f.x,_=f.y;L[0].set(2*w,_,w,_),L[1].set(0,_,w,_),L[2].set(3*w,_,w,_),L[3].set(w,_,w,_),L[4].set(3*w,0,w,_),L[5].set(w,0,w,_),f.x*=4,f.y*=2}if(null===h.map){var M={minFilter:Qc,magFilter:Qc,format:vl};h.map=new x(f.x,f.y,M),h.map.texture.name=o.name+".shadowMap",b.updateProjectionMatrix()}h.isSpotLightShadow&&h.update(o);var E=h.map,S=h.matrix;v.setFromMatrixPosition(o.matrixWorld),b.position.copy(v),y?(n=6,S.makeTranslation(-v.x,-v.y,-v.z)):(n=1,g.setFromMatrixPosition(o.target.matrixWorld),b.lookAt(g),b.updateMatrixWorld(),S.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),S.multiply(b.projectionMatrix),S.multiply(b.matrixWorldInverse)),t.setRenderTarget(E),t.clear();for(var C=0;C<n;C++){if(y){g.copy(b.position),g.add(T[C]),b.up.copy(A[C]),b.lookAt(g),b.updateMatrixWorld();var R=L[C];l.viewport(R)}d.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse),u.setFromMatrix(d),s(e,r,b,y)}}else console.warn("THREE.WebGLShadowMap:",o,"has no shadow.")}var P=t.getClearColor(),I=t.getClearAlpha();t.setClearColor(P,I),z.needsUpdate=!1}}}function pt(t){function e(e,r){var n=e.array,i=e.dynamic?t.DYNAMIC_DRAW:t.STATIC_DRAW,a=t.createBuffer();t.bindBuffer(r,a),t.bufferData(r,n,i),e.onUploadCallback();var o=t.FLOAT;return n instanceof Float32Array?o=t.FLOAT:n instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):n instanceof Uint16Array?o=t.UNSIGNED_SHORT:n instanceof Int16Array?o=t.SHORT:n instanceof Uint32Array?o=t.UNSIGNED_INT:n instanceof Int32Array?o=t.INT:n instanceof Int8Array?o=t.BYTE:n instanceof Uint8Array&&(o=t.UNSIGNED_BYTE),{buffer:a,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version}}function r(e,r,n){var i=r.array,a=r.updateRange;t.bindBuffer(n,e),!1===r.dynamic?t.bufferData(n,i,t.STATIC_DRAW):-1===a.count?t.bufferSubData(n,0,i):0===a.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(n,a.offset*i.BYTES_PER_ELEMENT,i.subarray(a.offset,a.offset+a.count)),a.count=-1)}function n(t){return t.isInterleavedBufferAttribute&&(t=t.data),o[t.uuid]}function i(e){e.isInterleavedBufferAttribute&&(e=e.data);var r=o[e.uuid];r&&(t.deleteBuffer(r.buffer),delete o[e.uuid])}function a(t,n){t.isInterleavedBufferAttribute&&(t=t.data);var i=o[t.uuid];void 0===i?o[t.uuid]=e(t,n):i.version<t.version&&(r(i.buffer,t,n),i.version=t.version)}var o={};return{get:n,remove:i,update:a}}function ft(t,e,r,n){this._x=t||0,this._y=e||0,this._z=r||0,this._order=n||ft.DefaultOrder}function mt(){this.mask=1}function gt(){function t(){s.setFromEuler(o,!1)}function i(){o.setFromQuaternion(s,void 0,!1)}Object.defineProperty(this,"id",{value:oh++}),this.uuid=Ko.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DefaultUp.clone();var a=new n,o=new ft,s=new r,c=new n(1,1,1);o.onChange(t),s.onChange(i),Object.defineProperties(this,{position:{enumerable:!0,value:a},rotation:{enumerable:!0,value:o},quaternion:{enumerable:!0,value:s},scale:{enumerable:!0,value:c},modelViewMatrix:{value:new e},normalMatrix:{value:new lt}}),this.matrix=new e,this.matrixWorld=new e,this.matrixAutoUpdate=gt.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new mt,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function vt(){gt.call(this),this.type="Camera",this.matrixWorldInverse=new e,this.projectionMatrix=new e}function yt(t,e,r,n,i,a){vt.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=r,this.bottom=n,this.near=void 0!==i?i:.1,this.far=void 0!==a?a:2e3,this.updateProjectionMatrix()}function xt(t,e,r,n){vt.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==r?r:.1,this.far=void 0!==n?n:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function bt(t,e,r,i,a,o){this.a=t,this.b=e,this.c=r,this.normal=i&&i.isVector3?i:new n,this.vertexNormals=Array.isArray(i)?i:[],this.color=a&&a.isColor?a:new c,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=void 0!==o?o:0}function wt(){return sh++}function _t(){Object.defineProperty(this,"id",{value:wt()}),this.uuid=Ko.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 Mt(t,e,r){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.uuid=Ko.generateUUID(),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===r,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function Et(t,e){Mt.call(this,new Uint16Array(t),e)}function St(t,e){Mt.call(this,new Uint32Array(t),e)}function Tt(t,e){Mt.call(this,new Float32Array(t),e)}function At(){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 Lt(t){if(0===t.length)return-1/0;for(var e=t[0],r=1,n=t.length;r<n;++r)t[r]>e&&(e=t[r]);return e}function Ct(){Object.defineProperty(this,"id",{value:wt()}),this.uuid=Ko.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 Rt(t,e,r,n,i,a){_t.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:a},this.fromBufferGeometry(new Pt(t,e,r,n,i,a)),this.mergeVertices()}function Pt(t,e,r,i,a,o){function s(t,e,r,i,a,o,s,m,g,v,y){var x,b,w=o/g,_=s/v,M=o/2,E=s/2,S=m/2,T=g+1,A=v+1,L=0,C=0,R=new n;for(b=0;b<A;b++){var P=b*_-E;for(x=0;x<T;x++){var I=x*w-M;R[t]=I*i,R[e]=P*a,R[r]=S,h.push(R.x,R.y,R.z),R[t]=0,R[e]=0,R[r]=m>0?1:-1,u.push(R.x,R.y,R.z),d.push(x/g),d.push(1-b/v),L+=1}}for(b=0;b<v;b++)for(x=0;x<g;x++){var O=p+x+T*b,N=p+x+T*(b+1),D=p+(x+1)+T*(b+1),U=p+(x+1)+T*b;l.push(O,N,U),l.push(N,D,U),C+=6}c.addGroup(f,C,y),f+=C,p+=L}Ct.call(this),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};var c=this;i=Math.floor(i)||1,a=Math.floor(a)||1;var l=[],h=[],u=[],d=[],p=0,f=0;s("z","y","x",-1,-1,r,e,t,o=Math.floor(o)||1,a,0),s("z","y","x",1,-1,r,e,-t,o,a,1),s("x","z","y",1,1,t,r,e,i,o,2),s("x","z","y",1,-1,t,r,-e,i,o,3),s("x","y","z",1,-1,t,e,r,i,a,4),s("x","y","z",-1,-1,t,e,-r,i,a,5),this.setIndex(l),this.addAttribute("position",new Tt(h,3)),this.addAttribute("normal",new Tt(u,3)),this.addAttribute("uv",new Tt(d,2))}function It(t,e,r,n){_t.call(this),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:r,heightSegments:n},this.fromBufferGeometry(new Ot(t,e,r,n)),this.mergeVertices()}function Ot(t,e,r,n){Ct.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:r,heightSegments:n};var i,a,o=t/2,s=e/2,c=Math.floor(r)||1,l=Math.floor(n)||1,h=c+1,u=l+1,d=t/c,p=e/l,f=[],m=[],g=[],v=[];for(a=0;a<u;a++){var y=a*p-s;for(i=0;i<h;i++){var x=i*d-o;m.push(x,-y,0),g.push(0,0,1),v.push(i/c),v.push(1-a/l)}}for(a=0;a<l;a++)for(i=0;i<c;i++){var b=i+h*a,w=i+h*(a+1),_=i+1+h*(a+1),M=i+1+h*a;f.push(b,w,M),f.push(w,_,M)}this.setIndex(f),this.addAttribute("position",new Tt(m,3)),this.addAttribute("normal",new Tt(g,3)),this.addAttribute("uv",new Tt(v,2))}function Nt(t){it.call(this),this.type="MeshBasicMaterial",this.color=new c(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=Oc,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 Dt(t,e){this.origin=void 0!==t?t:new n,this.direction=void 0!==e?e:new n}function Ut(t,e){this.start=void 0!==t?t:new n,this.end=void 0!==e?e:new n}function zt(t,e,r){this.a=void 0!==t?t:new n,this.b=void 0!==e?e:new n,this.c=void 0!==r?r:new n}function Bt(t,e){gt.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new Ct,this.material=void 0!==e?e:new Nt({color:16777215*Math.random()}),this.drawMode=Ol,this.updateMorphTargets()}function Ft(t,e,r,n){function i(e,n,i){var c=e.background;null===c?a(u,d):c&&c.isColor&&(a(c,1),i=!0),(t.autoClear||i)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),c&&c.isCubeTexture?(void 0===l&&(l=new xt,h=new Bt(new Pt(5,5,5),new at({uniforms:ih.cube.uniforms,vertexShader:ih.cube.vertexShader,fragmentShader:ih.cube.fragmentShader,side:Js,depthTest:!1,depthWrite:!1,fog:!1}))),l.projectionMatrix.copy(n.projectionMatrix),l.matrixWorld.extractRotation(n.matrixWorld),l.matrixWorldInverse.getInverse(l.matrixWorld),h.material.uniforms.tCube.value=c,h.modelViewMatrix.multiplyMatrices(l.matrixWorldInverse,h.matrixWorld),r.update(h),t.renderBufferDirect(l,null,h.geometry,h.material,h,null)):c&&c.isTexture&&(void 0===o&&(o=new yt(-1,1,1,-1,0,1),s=new Bt(new Ot(2,2),new Nt({depthTest:!1,depthWrite:!1,fog:!1}))),s.material.map=c,r.update(s),t.renderBufferDirect(o,null,s.geometry,s.material,s,null))}function a(t,r){e.buffers.color.setClear(t.r,t.g,t.b,r,n)}var o,s,l,h,u=new c(0),d=0;return{getClearColor:function(){return u},setClearColor:function(t,e){u.set(t),a(u,d=void 0!==e?e:1)},getClearAlpha:function(){return d},setClearAlpha:function(t){a(u,d=t)},render:i}}function kt(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program&&e.program&&t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Gt(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Vt(){function t(){a=-1,s=-1}function e(t,e,r,n,c){var l,h;r.transparent?(l=o,h=++s):(l=i,h=++a);var u=l[h];u?(u.id=t.id,u.object=t,u.geometry=e,u.material=r,u.program=r.program,u.renderOrder=t.renderOrder,u.z=n,u.group=c):(u={id:t.id,object:t,geometry:e,material:r,program:r.program,renderOrder:t.renderOrder,z:n,group:c},l.push(u))}function r(){i.length=a+1,o.length=s+1}function n(){i.sort(kt),o.sort(Gt)}var i=[],a=-1,o=[],s=-1;return{opaque:i,transparent:o,init:t,push:e,finish:r,sort:n}}function Ht(){function t(t,e){var n=t.id+","+e.id,i=r[n];return void 0===i&&(i=new Vt,r[n]=i),i}function e(){r={}}var r={};return{get:t,dispose:e}}function jt(t,e,r){function n(t){s=t}function i(t){c=t.type,l=t.bytesPerElement}function a(e,n){t.drawElements(s,n,c,e*l),r.calls++,r.vertices+=n,s===t.TRIANGLES&&(r.faces+=n/3)}function o(n,i,a){var o=e.get("ANGLE_instanced_arrays");if(null===o)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");o.drawElementsInstancedANGLE(s,a,c,i*l,n.maxInstancedCount),r.calls++,r.vertices+=a*n.maxInstancedCount,s===t.TRIANGLES&&(r.faces+=n.maxInstancedCount*a/3)}var s,c,l;this.setMode=n,this.setIndex=i,this.render=a,this.renderInstances=o}function Wt(t,e,r){function n(t){o=t}function i(e,n){t.drawArrays(o,e,n),r.calls++,r.vertices+=n,o===t.TRIANGLES&&(r.faces+=n/3)}function a(n,i,a){var s=e.get("ANGLE_instanced_arrays");if(null===s)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");var c=n.attributes.position;c.isInterleavedBufferAttribute?(a=c.data.count,s.drawArraysInstancedANGLE(o,0,a,n.maxInstancedCount)):s.drawArraysInstancedANGLE(o,i,a,n.maxInstancedCount),r.calls++,r.vertices+=a*n.maxInstancedCount,o===t.TRIANGLES&&(r.faces+=n.maxInstancedCount*a/3)}var o;this.setMode=n,this.render=i,this.renderInstances=a}function Xt(t,e,r){function n(t){var i=t.target,a=s[i.id];null!==a.index&&e.remove(a.index);for(var o in a.attributes)e.remove(a.attributes[o]);i.removeEventListener("dispose",n),delete s[i.id];var l=c[i.id];l&&(e.remove(l),delete c[i.id]),(l=c[a.id])&&(e.remove(l),delete c[a.id]),r.geometries--}function i(t,e){var i=s[e.id];return i||(e.addEventListener("dispose",n),e.isBufferGeometry?i=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new Ct).setFromObject(t)),i=e._bufferGeometry),s[e.id]=i,r.geometries++,i)}function a(r){var n=r.index,i=r.attributes;null!==n&&e.update(n,t.ELEMENT_ARRAY_BUFFER);for(var a in i)e.update(i[a],t.ARRAY_BUFFER);var o=r.morphAttributes;for(var a in o)for(var s=o[a],c=0,l=s.length;c<l;c++)e.update(s[c],t.ARRAY_BUFFER)}function o(r){var n=c[r.id];if(n)return n;var i=[],a=r.index,o=r.attributes;if(null!==a)for(var s=0,l=(p=a.array).length;s<l;s+=3){var h=p[s+0],u=p[s+1],d=p[s+2];i.push(h,u,u,d,d,h)}else for(var p=o.position.array,s=0,l=p.length/3-1;s<l;s+=3){var h=s+0,u=s+1,d=s+2;i.push(h,u,u,d,d,h)}return n=new(Lt(i)>65535?St:Et)(i,1),e.update(n,t.ELEMENT_ARRAY_BUFFER),c[r.id]=n,n}var s={},c={};return{get:i,update:a,getWireframeAttribute:o}}function Yt(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var r;switch(e.type){case"DirectionalLight":r={direction:new n,color:new c,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new h};break;case"SpotLight":r={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 h};break;case"PointLight":r={position:new n,color:new c,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new h};break;case"HemisphereLight":r={direction:new n,skyColor:new c,groundColor:new c};break;case"RectAreaLight":r={color:new c,position:new n,halfWidth:new n,halfHeight:new n}}return t[e.id]=r,r}}}function qt(t,e,r){function n(t){var n=r.frame,i=t.geometry,o=e.get(t,i);return a[o.id]!==n&&(i.isGeometry&&o.updateFromObject(t),e.update(o),a[o.id]=n),o}function i(){a={}}var a={};return{update:n,clear:i}}function Zt(t){for(var e=t.split("\n"),r=0;r<e.length;r++)e[r]=r+1+": "+e[r];return e.join("\n")}function Jt(t,e,r){var n=t.createShader(e);return t.shaderSource(n,r),t.compileShader(n),!1===t.getShaderParameter(n,t.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==t.getShaderInfoLog(n)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",e===t.VERTEX_SHADER?"vertex":"fragment",t.getShaderInfoLog(n),Zt(r)),n}function Qt(t){switch(t){case Ul:return["Linear","( value )"];case zl:return["sRGB","( value )"];case Fl:return["RGBE","( value )"];case kl:return["RGBM","( value, 7.0 )"];case Gl:return["RGBM","( value, 16.0 )"];case Vl:return["RGBD","( value, 256.0 )"];case Bl:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+t)}}function Kt(t,e){var r=Qt(e);return"vec4 "+t+"( vec4 value ) { return "+r[0]+"ToLinear"+r[1]+"; }"}function $t(t,e){var r=Qt(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+r[0]+r[1]+"; }"}function te(t,e){var r;switch(e){case zc:r="Linear";break;case Bc:r="Reinhard";break;case Fc:r="Uncharted2";break;case kc:r="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}function ee(t,e,r){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&r.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&r.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&r.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ie).join("\n")}function re(t){var e=[];for(var r in t){var n=t[r];!1!==n&&e.push("#define "+r+" "+n)}return e.join("\n")}function ne(t,e,r){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),a=0;a<i;a++){var o=t.getActiveAttrib(e,a).name;n[o]=t.getAttribLocation(e,o)}return n}function ie(t){return""!==t}function ae(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 oe(t){function e(t,e){var r=nh[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return oe(r)}return t.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,e)}function se(t){function e(t,e,r,n){for(var i="",a=parseInt(e);a<parseInt(r);a++)i+=n.replace(/\[ i \]/g,"[ "+a+" ]");return i}return t.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,e)}function ce(t,e,r,n,i){var a=t.context,o=r.extensions,s=r.defines,c=n.vertexShader,l=n.fragmentShader,h="SHADOWMAP_TYPE_BASIC";i.shadowMapType===Ys?h="SHADOWMAP_TYPE_PCF":i.shadowMapType===qs&&(h="SHADOWMAP_TYPE_PCF_SOFT");var u="ENVMAP_TYPE_CUBE",d="ENVMAP_MODE_REFLECTION",p="ENVMAP_BLENDING_MULTIPLY";if(i.envMap){switch(r.envMap.mapping){case Gc:case Vc:u="ENVMAP_TYPE_CUBE";break;case Xc:case Yc:u="ENVMAP_TYPE_CUBE_UV";break;case Hc:case jc:u="ENVMAP_TYPE_EQUIREC";break;case Wc:u="ENVMAP_TYPE_SPHERE"}switch(r.envMap.mapping){case Vc:case jc:d="ENVMAP_MODE_REFRACTION"}switch(r.combine){case Oc:p="ENVMAP_BLENDING_MULTIPLY";break;case Nc:p="ENVMAP_BLENDING_MIX";break;case Dc:p="ENVMAP_BLENDING_ADD"}}var f,m,g=t.gammaFactor>0?t.gammaFactor:1,v=ee(o,i,t.extensions),y=re(s),x=a.createProgram();r.isRawShaderMaterial?(f=[y,"\n"].filter(ie).join("\n"),m=[v,y,"\n"].filter(ie).join("\n")):(f=["precision "+i.precision+" float;","precision "+i.precision+" int;","#define SHADER_NAME "+n.name,y,i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#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 "+d:"",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 "+h:"",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(ie).join("\n"),m=[v,"precision "+i.precision+" float;","precision "+i.precision+" int;","#define SHADER_NAME "+n.name,y,i.alphaTest?"#define ALPHATEST "+i.alphaTest:"","#define GAMMA_FACTOR "+g,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.envMap?"#define "+d:"",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 "+h:"",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!==Uc?"#define TONE_MAPPING":"",i.toneMapping!==Uc?nh.tonemapping_pars_fragment:"",i.toneMapping!==Uc?te("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.outputEncoding||i.mapEncoding||i.envMapEncoding||i.emissiveMapEncoding?nh.encodings_pars_fragment:"",i.mapEncoding?Kt("mapTexelToLinear",i.mapEncoding):"",i.envMapEncoding?Kt("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMapEncoding?Kt("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.outputEncoding?$t("linearToOutputTexel",i.outputEncoding):"",i.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(ie).join("\n")),c=ae(c=oe(c),i),l=ae(l=oe(l),i),r.isShaderMaterial||(c=se(c),l=se(l));var b=f+c,w=m+l,_=Jt(a,a.VERTEX_SHADER,b),M=Jt(a,a.FRAGMENT_SHADER,w);a.attachShader(x,_),a.attachShader(x,M),void 0!==r.index0AttributeName?a.bindAttribLocation(x,0,r.index0AttributeName):!0===i.morphTargets&&a.bindAttribLocation(x,0,"position"),a.linkProgram(x);var E=a.getProgramInfoLog(x),S=a.getShaderInfoLog(_),T=a.getShaderInfoLog(M),A=!0,L=!0;!1===a.getProgramParameter(x,a.LINK_STATUS)?(A=!1,console.error("THREE.WebGLProgram: shader error: ",a.getError(),"gl.VALIDATE_STATUS",a.getProgramParameter(x,a.VALIDATE_STATUS),"gl.getProgramInfoLog",E,S,T)):""!==E?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",E):""!==S&&""!==T||(L=!1),L&&(this.diagnostics={runnable:A,material:r,programLog:E,vertexShader:{log:S,prefix:f},fragmentShader:{log:T,prefix:m}}),a.deleteShader(_),a.deleteShader(M);var C;this.getUniforms=function(){return void 0===C&&(C=new tt(a,x,t)),C};var R;return this.getAttributes=function(){return void 0===R&&(R=ne(a,x)),R},this.destroy=function(){a.deleteProgram(x),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=ch++,this.code=e,this.usedTimes=1,this.program=x,this.vertexShader=_,this.fragmentShader=M,this}function le(t,e){function r(t){var r=t.skeleton.bones;if(e.floatVertexTextures)return 1024;var n=e.maxVertexUniforms,i=Math.floor((n-20)/4),a=Math.min(i,r.length);return a<r.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+r.length+" bones. This GPU supports "+a+"."),0):a}function n(t,e){var r;return t?t.isTexture?r=t.encoding:t.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),r=t.texture.encoding):r=Ul,r===Ul&&e&&(r=Bl),r}var i=[],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","dithering"];this.getParameters=function(i,o,s,c,l,h){var u=a[i.type],d=h.isSkinnedMesh?r(h):0,p=t.getPrecision();null!==i.precision&&(p=e.getMaxPrecision(i.precision))!==i.precision&&console.warn("THREE.WebGLProgram.getParameters:",i.precision,"not supported, using",p,"instead.");var f=t.getRenderTarget();return{shaderID:u,precision:p,supportsVertexTextures:e.vertexTextures,outputEncoding:n(f?f.texture:null,t.gammaOutput),map:!!i.map,mapEncoding:n(i.map,t.gammaInput),envMap:!!i.envMap,envMapMode:i.envMap&&i.envMap.mapping,envMapEncoding:n(i.envMap,t.gammaInput),envMapCubeUV:!!i.envMap&&(i.envMap.mapping===Xc||i.envMap.mapping===Yc),lightMap:!!i.lightMap,aoMap:!!i.aoMap,emissiveMap:!!i.emissiveMap,emissiveMapEncoding:n(i.emissiveMap,t.gammaInput),bumpMap:!!i.bumpMap,normalMap:!!i.normalMap,displacementMap:!!i.displacementMap,roughnessMap:!!i.roughnessMap,metalnessMap:!!i.metalnessMap,specularMap:!!i.specularMap,alphaMap:!!i.alphaMap,gradientMap:!!i.gradientMap,combine:i.combine,vertexColors:i.vertexColors,fog:!!s,useFog:i.fog,fogExp:s&&s.isFogExp2,flatShading:i.shading===Ks,sizeAttenuation:i.sizeAttenuation,logarithmicDepthBuffer:e.logarithmicDepthBuffer,skinning:i.skinning&&d>0,maxBones:d,useVertexTexture:e.floatVertexTextures,morphTargets:i.morphTargets,morphNormals:i.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,dithering:i.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.receiveShadow&&o.shadows.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:i.premultipliedAlpha,alphaTest:i.alphaTest,doubleSided:i.side===Qs,flipSided:i.side===Js,depthPacking:void 0!==i.depthPacking&&i.depthPacking}},this.getProgramCode=function(e,r){var n=[];if(r.shaderID?n.push(r.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)n.push(i),n.push(e.defines[i]);for(var a=0;a<o.length;a++)n.push(r[o[a]]);return n.push(e.onBeforeCompile.toString()),n.push(t.gammaOutput),n.join()},this.acquireProgram=function(e,r,n,a){for(var o,s=0,c=i.length;s<c;s++){var l=i[s];if(l.code===a){++(o=l).usedTimes;break}}return void 0===o&&(o=new ce(t,a,e,r,n),i.push(o)),o},this.releaseProgram=function(t){if(0==--t.usedTimes){var e=i.indexOf(t);i[e]=i[i.length-1],i.pop(),t.destroy()}},this.programs=i}function he(t,e,r,n,i,a,o){function s(t,e){if(t.width>e||t.height>e){var r=e/Math.max(t.width,t.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return n.width=Math.floor(t.width*r),n.height=Math.floor(t.height*r),n.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,n.width,n.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+n.width+"x"+n.height,t),n}return t}function c(t){return Ko.isPowerOfTwo(t.width)&&Ko.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=Ko.nearestPowerOfTwo(t.width),e.height=Ko.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!==Zc||t.wrapT!==Zc||t.minFilter!==Qc&&t.minFilter!==tl}function u(t,e){return t.generateMipmaps&&e&&t.minFilter!==Qc&&t.minFilter!==tl}function d(e){return e===Qc||e===Kc||e===$c?t.NEAREST:t.LINEAR}function p(t){var e=t.target;e.removeEventListener("dispose",p),m(e),o.textures--}function f(t){var e=t.target;e.removeEventListener("dispose",f),g(e),o.textures--}function m(e){var r=n.get(e);if(e.image&&r.__image__webglTextureCube)t.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;t.deleteTexture(r.__webglTexture)}n.remove(e)}function g(e){var r=n.get(e),i=n.get(e.texture);if(e){if(void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLRenderTargetCube)for(var a=0;a<6;a++)t.deleteFramebuffer(r.__webglFramebuffer[a]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[a]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer);n.remove(e.texture),n.remove(e)}}function v(e,i){var a=n.get(e);if(e.version>0&&a.__version!==e.version){var o=e.image;if(void 0===o)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==o.complete)return void w(a,e,i);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",e)}}r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_2D,a.__webglTexture)}function y(e,l){var h=n.get(e);if(6===e.image.length)if(e.version>0&&h.__version!==e.version){h.__image__webglTextureCube||(e.addEventListener("dispose",p),h.__image__webglTextureCube=t.createTexture(),o.textures++),r.activeTexture(t.TEXTURE0+l),r.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var d=e&&e.isCompressedTexture,f=e.image[0]&&e.image[0].isDataTexture,m=[],g=0;g<6;g++)m[g]=d||f?f?e.image[g].image:e.image[g]:s(e.image[g],i.maxCubemapSize);var v=c(m[0]),y=a(e.format),x=a(e.type);b(t.TEXTURE_CUBE_MAP,e,v);for(g=0;g<6;g++)if(d)for(var w,_=m[g].mipmaps,M=0,E=_.length;M<E;M++)w=_[M],e.format!==vl&&e.format!==gl?r.getCompressedTextureFormats().indexOf(y)>-1?r.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,M,y,w.width,w.height,0,w.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,M,y,w.width,w.height,0,y,x,w.data);else f?r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,y,m[g].width,m[g].height,0,y,x,m[g].data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,y,y,x,m[g]);u(e,v)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),h.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+l),r.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube)}function x(e,i){r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_CUBE_MAP,n.get(e).__webglTexture)}function b(r,o,s){var c;if(s?(t.texParameteri(r,t.TEXTURE_WRAP_S,a(o.wrapS)),t.texParameteri(r,t.TEXTURE_WRAP_T,a(o.wrapT)),t.texParameteri(r,t.TEXTURE_MAG_FILTER,a(o.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,a(o.minFilter))):(t.texParameteri(r,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(r,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),o.wrapS===Zc&&o.wrapT===Zc||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",o),t.texParameteri(r,t.TEXTURE_MAG_FILTER,d(o.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,d(o.minFilter)),o.minFilter!==Qc&&o.minFilter!==tl&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",o)),c=e.get("EXT_texture_filter_anisotropic")){if(o.type===ll&&null===e.get("OES_texture_float_linear"))return;if(o.type===hl&&null===e.get("OES_texture_half_float_linear"))return;(o.anisotropy>1||n.get(o).__currentAnisotropy)&&(t.texParameterf(r,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,i.getMaxAnisotropy())),n.get(o).__currentAnisotropy=o.anisotropy)}}function w(e,n,d){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",p),e.__webglTexture=t.createTexture(),o.textures++),r.activeTexture(t.TEXTURE0+d),r.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,n.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,n.unpackAlignment);var f=s(n.image,i.maxTextureSize);h(n)&&!1===c(f)&&(f=l(f));var m=c(f),g=a(n.format),v=a(n.type);b(t.TEXTURE_2D,n,m);var y,x=n.mipmaps;if(n.isDepthTexture){var w=t.DEPTH_COMPONENT;if(n.type===ll){if(!L)throw new Error("Float Depth Texture only supported in WebGL2.0");w=t.DEPTH_COMPONENT32F}else L&&(w=t.DEPTH_COMPONENT16);n.format===bl&&w===t.DEPTH_COMPONENT&&n.type!==ol&&n.type!==cl&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=ol,v=a(n.type)),n.format===wl&&(w=t.DEPTH_STENCIL,n.type!==fl&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=fl,v=a(n.type))),r.texImage2D(t.TEXTURE_2D,0,w,f.width,f.height,0,g,v,null)}else if(n.isDataTexture)if(x.length>0&&m){for(var _=0,M=x.length;_<M;_++)y=x[_],r.texImage2D(t.TEXTURE_2D,_,g,y.width,y.height,0,g,v,y.data);n.generateMipmaps=!1}else r.texImage2D(t.TEXTURE_2D,0,g,f.width,f.height,0,g,v,f.data);else if(n.isCompressedTexture)for(var _=0,M=x.length;_<M;_++)y=x[_],n.format!==vl&&n.format!==gl?r.getCompressedTextureFormats().indexOf(g)>-1?r.compressedTexImage2D(t.TEXTURE_2D,_,g,y.width,y.height,0,y.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texImage2D(t.TEXTURE_2D,_,g,y.width,y.height,0,g,v,y.data);else if(x.length>0&&m){for(var _=0,M=x.length;_<M;_++)y=x[_],r.texImage2D(t.TEXTURE_2D,_,g,g,v,y);n.generateMipmaps=!1}else r.texImage2D(t.TEXTURE_2D,0,g,g,v,f);u(n,m)&&t.generateMipmap(t.TEXTURE_2D),e.__version=n.version,n.onUpdate&&n.onUpdate(n)}function _(e,i,o,s){var c=a(i.texture.format),l=a(i.texture.type);r.texImage2D(s,0,c,i.width,i.height,0,c,l,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,o,s,n.get(i.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function M(e,r){t.bindRenderbuffer(t.RENDERBUFFER,e),r.depthBuffer&&!r.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,r.width,r.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):r.depthBuffer&&r.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,r.width,r.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,r.width,r.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}function E(e,r){if(r&&r.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported!");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),v(r.depthTexture,0);var i=n.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===bl)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,i,0);else{if(r.depthTexture.format!==wl)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,i,0)}}function S(e){var r=n.get(e),i=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");E(r.__webglFramebuffer,e)}else if(i){r.__webglDepthbuffer=[];for(var a=0;a<6;a++)t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[a]),r.__webglDepthbuffer[a]=t.createRenderbuffer(),M(r.__webglDepthbuffer[a],e)}else t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),M(r.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}function T(e){var i=n.get(e),a=n.get(e.texture);e.addEventListener("dispose",f),a.__webglTexture=t.createTexture(),o.textures++;var s=!0===e.isWebGLRenderTargetCube,l=c(e);if(s){i.__webglFramebuffer=[];for(h=0;h<6;h++)i.__webglFramebuffer[h]=t.createFramebuffer()}else i.__webglFramebuffer=t.createFramebuffer();if(s){r.bindTexture(t.TEXTURE_CUBE_MAP,a.__webglTexture),b(t.TEXTURE_CUBE_MAP,e.texture,l);for(var h=0;h<6;h++)_(i.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);u(e.texture,l)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,a.__webglTexture),b(t.TEXTURE_2D,e.texture,l),_(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),u(e.texture,l)&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&S(e)}function A(e){var i=e.texture;if(u(i,c(e))){var a=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,o=n.get(i).__webglTexture;r.bindTexture(a,o),t.generateMipmap(a),r.bindTexture(a,null)}}var L="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext;this.setTexture2D=v,this.setTextureCube=y,this.setTextureCubeDynamic=x,this.setupRenderTarget=T,this.updateRenderTargetMipmap=A}function ue(){function t(t){var e=t.uuid,r=n[e];return void 0===r&&(r={},n[e]=r),r}function e(t){delete n[t.uuid]}function r(){n={}}var n={};return{get:t,remove:e,clear:r}}function de(t,e,r){function n(){var e=!1,r=new y,n=null,i=new y;return{setMask:function(r){n===r||e||(t.colorMask(r,r,r,r),n=r)},setLocked:function(t){e=t},setClear:function(e,n,a,o,s){!0===s&&(e*=o,n*=o,a*=o),r.set(e,n,a,o),!1===i.equals(r)&&(t.clearColor(e,n,a,o),i.copy(r))},reset:function(){e=!1,n=null,i.set(0,0,0,1)}}}function i(){var e=!1,r=null,n=null,i=null;return{setTest:function(e){e?d(t.DEPTH_TEST):p(t.DEPTH_TEST)},setMask:function(n){r===n||e||(t.depthMask(n),r=n)},setFunc:function(e){if(n!==e){if(e)switch(e){case Sc:t.depthFunc(t.NEVER);break;case Tc:t.depthFunc(t.ALWAYS);break;case Ac:t.depthFunc(t.LESS);break;case Lc:t.depthFunc(t.LEQUAL);break;case Cc:t.depthFunc(t.EQUAL);break;case Rc:t.depthFunc(t.GEQUAL);break;case Pc:t.depthFunc(t.GREATER);break;case Ic:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);n=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,r=null,n=null,i=null}}}function a(){var e=!1,r=null,n=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(e){e?d(t.STENCIL_TEST):p(t.STENCIL_TEST)},setMask:function(n){r===n||e||(t.stencilMask(n),r=n)},setFunc:function(e,r,o){n===e&&i===r&&a===o||(t.stencilFunc(e,r,o),n=e,i=r,a=o)},setOp:function(e,r,n){o===e&&s===r&&c===n||(t.stencilOp(e,r,n),o=e,s=r,c=n)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,r=null,n=null,i=null,a=null,o=null,s=null,c=null,l=null}}}function o(e,r,n){var i=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var o=0;o<n;o++)t.texImage2D(r+o,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,i);return a}function s(){P.setClear(0,0,0,1),I.setClear(1),O.setClear(0),d(t.DEPTH_TEST),I.setFunc(Lc),v(!1),x(js),d(t.CULL_FACE),d(t.BLEND),m(ic)}function c(){for(var t=0,e=D.length;t<e;t++)D[t]=0}function l(r){D[r]=1,0===U[r]&&(t.enableVertexAttribArray(r),U[r]=1),0!==z[r]&&(e.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(r,0),z[r]=0)}function h(r,n){D[r]=1,0===U[r]&&(t.enableVertexAttribArray(r),U[r]=1),z[r]!==n&&(e.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(r,n),z[r]=n)}function u(){for(var e=0,r=U.length;e!==r;++e)U[e]!==D[e]&&(t.disableVertexAttribArray(e),U[e]=0)}function d(e){!0!==B[e]&&(t.enable(e),B[e]=!0)}function p(e){!1!==B[e]&&(t.disable(e),B[e]=!1)}function f(){if(null===F&&(F=[],e.get("WEBGL_compressed_texture_pvrtc")||e.get("WEBGL_compressed_texture_s3tc")||e.get("WEBGL_compressed_texture_etc1")))for(var r=t.getParameter(t.COMPRESSED_TEXTURE_FORMATS),n=0;n<r.length;n++)F.push(r[n]);return F}function m(e,n,i,a,o,s,c,l){e!==nc?d(t.BLEND):p(t.BLEND),e===cc||e===k&&l===Y||(e===ac?l?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE,t.ONE,t.ONE)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.SRC_ALPHA,t.ONE)):e===oc?l?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ZERO,t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ONE_MINUS_SRC_ALPHA)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ZERO,t.ONE_MINUS_SRC_COLOR)):e===sc?l?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ZERO,t.SRC_COLOR)):l?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)),k=e,Y=l),e===cc?(o=o||n,s=s||i,c=c||a,n===G&&o===j||(t.blendEquationSeparate(r(n),r(o)),G=n,j=o),i===V&&a===H&&s===W&&c===X||(t.blendFuncSeparate(r(i),r(a),r(s),r(c)),V=i,H=a,W=s,X=c)):(G=null,V=null,H=null,j=null,W=null,X=null)}function g(e){e.side===Qs?p(t.CULL_FACE):d(t.CULL_FACE),v(e.side===Js),!0===e.transparent?m(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha):m(nc),I.setFunc(e.depthFunc),I.setTest(e.depthTest),I.setMask(e.depthWrite),P.setMask(e.colorWrite),w(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)}function v(e){q!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),q=e)}function x(e){e!==Hs?(d(t.CULL_FACE),e!==Z&&(e===js?t.cullFace(t.BACK):e===Ws?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):p(t.CULL_FACE),Z=e}function b(e){e!==J&&(rt&&t.lineWidth(e),J=e)}function w(e,r,n){e?(d(t.POLYGON_OFFSET_FILL),Q===r&&K===n||(t.polygonOffset(r,n),Q=r,K=n)):p(t.POLYGON_OFFSET_FILL)}function _(){return $}function M(e){$=e,e?d(t.SCISSOR_TEST):p(t.SCISSOR_TEST)}function E(e){void 0===e&&(e=t.TEXTURE0+tt-1),nt!==e&&(t.activeTexture(e),nt=e)}function S(e,r){null===nt&&E();var n=it[nt];void 0===n&&(n={type:void 0,texture:void 0},it[nt]=n),n.type===e&&n.texture===r||(t.bindTexture(e,r||st[e]),n.type=e,n.texture=r)}function T(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}}function A(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}}function L(e){!1===at.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),at.copy(e))}function C(e){!1===ot.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),ot.copy(e))}function R(){for(var e=0;e<U.length;e++)1===U[e]&&(t.disableVertexAttribArray(e),U[e]=0);B={},F=null,nt=null,it={},k=null,q=null,Z=null,P.reset(),I.reset(),O.reset()}var P=new n,I=new i,O=new a,N=t.getParameter(t.MAX_VERTEX_ATTRIBS),D=new Uint8Array(N),U=new Uint8Array(N),z=new Uint8Array(N),B={},F=null,k=null,G=null,V=null,H=null,j=null,W=null,X=null,Y=!1,q=null,Z=null,J=null,Q=null,K=null,$=null,tt=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),et=parseFloat(/^WebGL\ ([0-9])/.exec(t.getParameter(t.VERSION))[1]),rt=parseFloat(et)>=1,nt=null,it={},at=new y,ot=new y,st={};return st[t.TEXTURE_2D]=o(t.TEXTURE_2D,t.TEXTURE_2D,1),st[t.TEXTURE_CUBE_MAP]=o(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),{buffers:{color:P,depth:I,stencil:O},init:s,initAttributes:c,enableAttribute:l,enableAttributeAndDivisor:h,disableUnusedAttributes:u,enable:d,disable:p,getCompressedTextureFormats:f,setBlending:m,setMaterial:g,setFlipSided:v,setCullFace:x,setLineWidth:b,setPolygonOffset:w,getScissorTest:_,setScissorTest:M,activeTexture:E,bindTexture:S,compressedTexImage2D:T,texImage2D:A,scissor:L,viewport:C,reset:R}}function pe(t,e,r){function n(){if(void 0!==a)return a;var r=e.get("EXT_texture_filter_anisotropic");return a=null!==r?t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}function i(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var a,o=void 0!==r.precision?r.precision:"highp",s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var c=!0===r.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),l=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),h=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_TEXTURE_SIZE),d=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),m=t.getParameter(t.MAX_VARYING_VECTORS),g=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=h>0,y=!!e.get("OES_texture_float");return{getMaxAnisotropy:n,getMaxPrecision:i,precision:o,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:h,maxTextureSize:u,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y}}function fe(t){xt.call(this),this.cameras=t||[]}function me(t){function r(){if(i.isPresenting){var e=i.getEyeParameters("left"),r=e.renderWidth,a=e.renderHeight;p=t.getPixelRatio(),d=t.getSize(),t.setDrawingBufferSize(2*r,a,1)}else n.enabled&&t.setDrawingBufferSize(d.width,d.height,p)}var n=this,i=null,a=null;"VRFrameData"in window&&(a=new window.VRFrameData);var o=new e,s=new e,c=new e,l=new xt;l.bounds=new y(0,0,.5,1),l.layers.enable(1);var h=new xt;h.bounds=new y(.5,0,.5,1),h.layers.enable(2);var u=new fe([l,h]);u.layers.enable(1),u.layers.enable(2);var d,p;window.addEventListener("vrdisplaypresentchange",r,!1),this.enabled=!1,this.standing=!1,this.getDevice=function(){return i},this.setDevice=function(t){void 0!==t&&(i=t)},this.getCamera=function(t){if(null===i)return t;i.depthNear=t.near,i.depthFar=t.far,i.getFrameData(a);var e=a.pose;null!==e.position?t.position.fromArray(e.position):t.position.set(0,0,0),null!==e.orientation&&t.quaternion.fromArray(e.orientation),t.updateMatrixWorld();var r=i.stageParameters;if(this.standing&&r&&(s.fromArray(r.sittingToStandingTransform),c.getInverse(s),t.matrixWorld.multiply(s),t.matrixWorldInverse.multiply(c)),!1===i.isPresenting)return t;u.matrixWorld.copy(t.matrixWorld),u.matrixWorldInverse.copy(t.matrixWorldInverse),l.matrixWorldInverse.fromArray(a.leftViewMatrix),h.matrixWorldInverse.fromArray(a.rightViewMatrix),this.standing&&r&&(l.matrixWorldInverse.multiply(c),h.matrixWorldInverse.multiply(c));var n=t.parent;null!==n&&(o.getInverse(n.matrixWorld),l.matrixWorldInverse.multiply(o),h.matrixWorldInverse.multiply(o)),l.matrixWorld.getInverse(l.matrixWorldInverse),h.matrixWorld.getInverse(h.matrixWorldInverse),l.projectionMatrix.fromArray(a.leftProjectionMatrix),h.projectionMatrix.fromArray(a.rightProjectionMatrix),u.projectionMatrix.copy(l.projectionMatrix);var d=i.getLayers();if(d.length){var p=d[0];null!==p.leftBounds&&4===p.leftBounds.length&&l.bounds.fromArray(p.leftBounds),null!==p.rightBounds&&4===p.rightBounds.length&&h.bounds.fromArray(p.rightBounds)}return u},this.getStandingMatrix=function(){return s},this.submitFrame=function(){i&&i.isPresenting&&i.submitFrame()}}function ge(t){var e={};return{get:function(r){if(void 0!==e[r])return e[r];var n;switch(r){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":n=t.getExtension("WEBGL_compressed_texture_etc1");break;default:n=t.getExtension(r)}return null===n&&console.warn("THREE.WebGLRenderer: "+r+" extension not supported."),e[r]=n,n}}}function ve(){function t(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),r.numPlanes=i,r.numIntersection=0}function e(t,e,n,i){var a=null!==t?t.length:0,o=null;if(0!==a){if(o=l.value,!0!==i||null===o){var h=n+4*a,u=e.matrixWorldInverse;c.getNormalMatrix(u),(null===o||o.length<h)&&(o=new Float32Array(h));for(var d=0,p=n;d!==a;++d,p+=4)s.copy(t[d]).applyMatrix4(u,c),s.normal.toArray(o,p),o[p+3]=s.constant}l.value=o,l.needsUpdate=!0}return r.numPlanes=a,o}var r=this,n=null,i=0,a=!1,o=!1,s=new ht,c=new lt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,r,o){var s=0!==t.length||r||0!==i||a;return a=r,n=e(t,o,0),i=t.length,s},this.beginShadows=function(){o=!0,e(null)},this.endShadows=function(){o=!1,t()},this.setState=function(r,s,c,h,u,d){if(!a||null===r||0===r.length||o&&!c)o?e(null):t();else{var p=o?0:i,f=4*p,m=u.clippingState||null;l.value=m,m=e(r,h,f,d);for(var g=0;g!==f;++g)m[g]=n[g];u.clippingState=m,this.numIntersection=s?this.numPlanes:0,this.numPlanes+=p}}}function ye(t){function r(){return null===Q?mt:1}function i(){Dt.init(),Dt.scissor(ot.copy(gt).multiplyScalar(mt)),Dt.viewport(ct.copy(yt).multiplyScalar(mt))}function a(){J=null,it=null,et="",$=-1,Dt.reset()}function o(t){t.preventDefault(),a(),i(),Ut.clear(),Gt.clear()}function s(t){var e=t.target;e.removeEventListener("dispose",s),c(e)}function c(t){l(t),Ut.remove(t)}function l(t){var e=Ut.get(t).program;t.program=void 0,void 0!==e&&Vt.releaseProgram(e)}function h(t,e,r){t.render(function(t){Z.renderBufferImmediate(t,e,r)})}function u(t,e){return Math.abs(e[0])-Math.abs(t[0])}function p(t,e,r,n){if(r&&r.isInstancedBufferGeometry&&null===Ot.get("ANGLE_instanced_arrays"))return void console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");void 0===n&&(n=0),Dt.initAttributes();var i=r.attributes,a=e.getAttributes(),o=t.defaultAttributeValues;for(var s in a){var c=a[s];if(c>=0){var l=i[s];if(void 0!==l){var h=l.normalized,u=l.itemSize,d=Bt.get(l),p=d.buffer,f=d.type,m=d.bytesPerElement;if(l.isInterleavedBufferAttribute){var g=l.data,v=g.stride,y=l.offset;g&&g.isInstancedInterleavedBuffer?(Dt.enableAttributeAndDivisor(c,g.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=g.meshPerAttribute*g.count)):Dt.enableAttribute(c),Pt.bindBuffer(Pt.ARRAY_BUFFER,p),Pt.vertexAttribPointer(c,u,f,h,v*m,(n*v+y)*m)}else l.isInstancedBufferAttribute?(Dt.enableAttributeAndDivisor(c,l.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=l.meshPerAttribute*l.count)):Dt.enableAttribute(c),Pt.bindBuffer(Pt.ARRAY_BUFFER,p),Pt.vertexAttribPointer(c,u,f,h,0,n*u*m)}else if(void 0!==o){var x=o[s];if(void 0!==x)switch(x.length){case 2:Pt.vertexAttrib2fv(c,x);break;case 3:Pt.vertexAttrib3fv(c,x);break;case 4:Pt.vertexAttrib4fv(c,x);break;default:Pt.vertexAttrib1fv(c,x)}}}}Dt.disableUnusedAttributes()}function f(t,e,r){if(t.visible){if(t.layers.test(e.layers))if(t.isLight)j.push(t);else if(t.isSprite)t.frustumCulled&&!xt.intersectsSprite(t)||Y.push(t);else if(t.isLensFlare)q.push(t);else if(t.isImmediateRenderObject)r&&Et.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Mt),W.push(t,null,t.material,Et.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||xt.intersectsObject(t))){r&&Et.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Mt);var n=Gt.update(t),i=t.material;if(Array.isArray(i))for(var a=n.groups,o=0,s=a.length;o<s;o++){var c=a[o],l=i[c.materialIndex];l&&l.visible&&W.push(t,n,l,Et.z,c)}else i.visible&&W.push(t,n,i,Et.z,null)}for(var h=t.children,o=0,s=h.length;o<s;o++)f(h[o],e,r)}}function m(t,e,r,n){for(var i=0,a=t.length;i<a;i++){var o=t[i],s=o.object,c=o.geometry,l=void 0===n?o.material:n,h=o.group;if(r.isArrayCamera){at=r;for(var u=r.cameras,d=0,p=u.length;d<p;d++){var f=u[d];if(s.layers.test(f.layers)){var m=f.bounds,v=m.x*ht,y=m.y*ft,x=m.z*ht,b=m.w*ft;Z.setViewport(v,y,x,b),Z.setScissor(v,y,x,b),Z.setScissorTest(!0),g(s,e,f,c,l,h)}}}else at=null,g(s,e,r,c,l,h)}}function g(t,e,r,n,i,a){if(t.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.onBeforeRender(Z,e,r,n,i,a),t.isImmediateRenderObject){Dt.setMaterial(i);var o=x(r,e.fog,i,t);et="",h(t,o,i)}else Z.renderBufferDirect(r,e.fog,n,i,t,a);t.onAfterRender(Z,e,r,n,i,a)}function v(t,e,r){var n=Ut.get(t),i=Vt.getParameters(t,At,e,bt.numPlanes,bt.numIntersection,r),a=Vt.getProgramCode(t,i),o=n.program,c=!0;if(void 0===o)t.addEventListener("dispose",s);else if(o.code!==a)l(t);else{if(void 0!==i.shaderID)return;c=!1}if(c){if(i.shaderID){var h=ih[i.shaderID];n.shader={name:t.type,uniforms:rh.clone(h.uniforms),vertexShader:h.vertexShader,fragmentShader:h.fragmentShader}}else n.shader={name:t.type,uniforms:t.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader};t.onBeforeCompile(n.shader),o=Vt.acquireProgram(t,n.shader,i,a),n.program=o,t.program=o}var u=o.getAttributes();if(t.morphTargets){t.numSupportedMorphTargets=0;for(d=0;d<Z.maxMorphTargets;d++)u["morphTarget"+d]>=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var d=0;d<Z.maxMorphNormals;d++)u["morphNormal"+d]>=0&&t.numSupportedMorphNormals++}var p=n.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=bt.numPlanes,n.numIntersection=bt.numIntersection,p.clippingPlanes=bt.uniform),n.fog=e,n.lightsHash=At.hash,t.lights&&(p.ambientLightColor.value=At.ambient,p.directionalLights.value=At.directional,p.spotLights.value=At.spot,p.rectAreaLights.value=At.rectArea,p.pointLights.value=At.point,p.hemisphereLights.value=At.hemi,p.directionalShadowMap.value=At.directionalShadowMap,p.directionalShadowMatrix.value=At.directionalShadowMatrix,p.spotShadowMap.value=At.spotShadowMap,p.spotShadowMatrix.value=At.spotShadowMatrix,p.pointShadowMap.value=At.pointShadowMap,p.pointShadowMatrix.value=At.pointShadowMatrix);var f=n.program.getUniforms(),m=tt.seqWithValue(f.seq,p);n.uniformsList=m}function x(t,e,r,n){lt=0;var i=Ut.get(r);if(wt&&(_t||t!==it)){var a=t===it&&r.id===$;bt.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,t,i,a)}!1===r.needsUpdate&&(void 0===i.program?r.needsUpdate=!0:r.fog&&i.fog!==e?r.needsUpdate=!0:r.lights&&i.lightsHash!==At.hash?r.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===bt.numPlanes&&i.numIntersection===bt.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(v(r,e,n),r.needsUpdate=!1);var o=!1,s=!1,c=!1,l=i.program,h=l.getUniforms(),u=i.shader.uniforms;if(l.id!==J&&(Pt.useProgram(l.program),J=l.id,o=!0,s=!0,c=!0),r.id!==$&&($=r.id,s=!0),o||t!==it){if(h.setValue(Pt,"projectionMatrix",t.projectionMatrix),Nt.logarithmicDepthBuffer&&h.setValue(Pt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),it!==(at||t)&&(it=at||t,s=!0,c=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var p=h.map.cameraPosition;void 0!==p&&p.setValue(Pt,Et.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&h.setValue(Pt,"viewMatrix",t.matrixWorldInverse)}if(r.skinning){h.setOptional(Pt,n,"bindMatrix"),h.setOptional(Pt,n,"bindMatrixInverse");var f=n.skeleton;if(f){var m=f.bones;if(Nt.floatVertexTextures){if(void 0===f.boneTexture){var g=Math.sqrt(4*m.length);g=Ko.nextPowerOfTwo(Math.ceil(g)),g=Math.max(g,4);var y=new Float32Array(g*g*4);y.set(f.boneMatrices);var x=new d(y,g,g,vl,ll);f.boneMatrices=y,f.boneTexture=x,f.boneTextureSize=g}h.setValue(Pt,"boneTexture",f.boneTexture),h.setValue(Pt,"boneTextureSize",f.boneTextureSize)}else h.setOptional(Pt,f,"boneMatrices")}}return s&&(h.setValue(Pt,"toneMappingExposure",Z.toneMappingExposure),h.setValue(Pt,"toneMappingWhitePoint",Z.toneMappingWhitePoint),r.lights&&P(u,c),e&&r.fog&&E(u,e),(r.isMeshBasicMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshNormalMaterial||r.isMeshDepthMaterial)&&b(u,r),r.isLineBasicMaterial?w(u,r):r.isLineDashedMaterial?(w(u,r),_(u,r)):r.isPointsMaterial?M(u,r):r.isMeshLambertMaterial?S(u,r):r.isMeshToonMaterial?A(u,r):r.isMeshPhongMaterial?T(u,r):r.isMeshPhysicalMaterial?C(u,r):r.isMeshStandardMaterial?L(u,r):r.isMeshDepthMaterial?r.displacementMap&&(u.displacementMap.value=r.displacementMap,u.displacementScale.value=r.displacementScale,u.displacementBias.value=r.displacementBias):r.isMeshNormalMaterial&&R(u,r),void 0!==u.ltcMat&&(u.ltcMat.value=eh.LTC_MAT_TEXTURE),void 0!==u.ltcMag&&(u.ltcMag.value=eh.LTC_MAG_TEXTURE),tt.upload(Pt,i.uniformsList,u,Z)),h.setValue(Pt,"modelViewMatrix",n.modelViewMatrix),h.setValue(Pt,"normalMatrix",n.normalMatrix),h.setValue(Pt,"modelMatrix",n.matrixWorld),l}function b(t,e){t.opacity.value=e.opacity,t.diffuse.value=e.color,e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),t.map.value=e.map,t.specularMap.value=e.specularMap,t.alphaMap.value=e.alphaMap,e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity);var r;if(e.map?r=e.map:e.specularMap?r=e.specularMap:e.displacementMap?r=e.displacementMap:e.normalMap?r=e.normalMap:e.bumpMap?r=e.bumpMap:e.roughnessMap?r=e.roughnessMap:e.metalnessMap?r=e.metalnessMap:e.alphaMap?r=e.alphaMap:e.emissiveMap&&(r=e.emissiveMap),void 0!==r){r.isWebGLRenderTarget&&(r=r.texture);var n=r.offset,i=r.repeat;t.offsetRepeat.value.set(n.x,n.y,i.x,i.y)}t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio}function w(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function _(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}function M(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*mt,t.scale.value=.5*ft,t.map.value=e.map,null!==e.map){var r=e.map.offset,n=e.map.repeat;t.offsetRepeat.value.set(r.x,r.y,n.x,n.y)}}function E(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}function S(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}function T(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function A(t,e){T(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}function L(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}function C(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,L(t,e)}function R(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function P(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}function I(t){for(var e=0,r=0,n=t.length;r<n;r++){var i=t[r];i.castShadow&&(At.shadows[e]=i,e++)}At.shadows.length=e}function O(t,e){var r,n,i,a,o,s,c,l,h=0,u=0,d=0,p=e.matrixWorldInverse,f=0,m=0,g=0,v=0,y=0;for(r=0,n=t.length;r<n;r++)if(i=t[r],o=i.color,s=i.intensity,c=i.distance,l=i.shadow&&i.shadow.map?i.shadow.map.texture:null,i.isAmbientLight)h+=o.r*s,u+=o.g*s,d+=o.b*s;else if(i.isDirectionalLight)(x=Zt.get(i)).color.copy(i.color).multiplyScalar(i.intensity),x.direction.setFromMatrixPosition(i.matrixWorld),Et.setFromMatrixPosition(i.target.matrixWorld),x.direction.sub(Et),x.direction.transformDirection(p),x.shadow=i.castShadow,i.castShadow&&(a=i.shadow,x.shadowBias=a.bias,x.shadowRadius=a.radius,x.shadowMapSize=a.mapSize),At.directionalShadowMap[f]=l,At.directionalShadowMatrix[f]=i.shadow.matrix,At.directional[f]=x,f++;else if(i.isSpotLight)(x=Zt.get(i)).position.setFromMatrixPosition(i.matrixWorld),x.position.applyMatrix4(p),x.color.copy(o).multiplyScalar(s),x.distance=c,x.direction.setFromMatrixPosition(i.matrixWorld),Et.setFromMatrixPosition(i.target.matrixWorld),x.direction.sub(Et),x.direction.transformDirection(p),x.coneCos=Math.cos(i.angle),x.penumbraCos=Math.cos(i.angle*(1-i.penumbra)),x.decay=0===i.distance?0:i.decay,x.shadow=i.castShadow,i.castShadow&&(a=i.shadow,x.shadowBias=a.bias,x.shadowRadius=a.radius,x.shadowMapSize=a.mapSize),At.spotShadowMap[g]=l,At.spotShadowMatrix[g]=i.shadow.matrix,At.spot[g]=x,g++;else if(i.isRectAreaLight)(x=Zt.get(i)).color.copy(o).multiplyScalar(s/(i.width*i.height)),x.position.setFromMatrixPosition(i.matrixWorld),x.position.applyMatrix4(p),Tt.identity(),St.copy(i.matrixWorld),St.premultiply(p),Tt.extractRotation(St),x.halfWidth.set(.5*i.width,0,0),x.halfHeight.set(0,.5*i.height,0),x.halfWidth.applyMatrix4(Tt),x.halfHeight.applyMatrix4(Tt),At.rectArea[v]=x,v++;else if(i.isPointLight)(x=Zt.get(i)).position.setFromMatrixPosition(i.matrixWorld),x.position.applyMatrix4(p),x.color.copy(i.color).multiplyScalar(i.intensity),x.distance=i.distance,x.decay=0===i.distance?0:i.decay,x.shadow=i.castShadow,i.castShadow&&(a=i.shadow,x.shadowBias=a.bias,x.shadowRadius=a.radius,x.shadowMapSize=a.mapSize),At.pointShadowMap[m]=l,At.pointShadowMatrix[m]=i.shadow.matrix,At.point[m]=x,m++;else if(i.isHemisphereLight){var x=Zt.get(i);x.direction.setFromMatrixPosition(i.matrixWorld),x.direction.transformDirection(p),x.direction.normalize(),x.skyColor.copy(i.color).multiplyScalar(s),x.groundColor.copy(i.groundColor).multiplyScalar(s),At.hemi[y]=x,y++}At.ambient[0]=h,At.ambient[1]=u,At.ambient[2]=d,At.directional.length=f,At.spot.length=g,At.rectArea.length=v,At.point.length=m,At.hemi.length=y,At.hash=f+","+m+","+g+","+v+","+y+","+At.shadows.length}function N(){var t=lt;return t>=Nt.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+t+" texture units while this GPU supports only "+Nt.maxTextures),lt+=1,t}function D(t){var e;if(t===qc)return Pt.REPEAT;if(t===Zc)return Pt.CLAMP_TO_EDGE;if(t===Jc)return Pt.MIRRORED_REPEAT;if(t===Qc)return Pt.NEAREST;if(t===Kc)return Pt.NEAREST_MIPMAP_NEAREST;if(t===$c)return Pt.NEAREST_MIPMAP_LINEAR;if(t===tl)return Pt.LINEAR;if(t===el)return Pt.LINEAR_MIPMAP_NEAREST;if(t===rl)return Pt.LINEAR_MIPMAP_LINEAR;if(t===nl)return Pt.UNSIGNED_BYTE;if(t===ul)return Pt.UNSIGNED_SHORT_4_4_4_4;if(t===dl)return Pt.UNSIGNED_SHORT_5_5_5_1;if(t===pl)return Pt.UNSIGNED_SHORT_5_6_5;if(t===il)return Pt.BYTE;if(t===al)return Pt.SHORT;if(t===ol)return Pt.UNSIGNED_SHORT;if(t===sl)return Pt.INT;if(t===cl)return Pt.UNSIGNED_INT;if(t===ll)return Pt.FLOAT;if(t===hl&&null!==(e=Ot.get("OES_texture_half_float")))return e.HALF_FLOAT_OES;if(t===ml)return Pt.ALPHA;if(t===gl)return Pt.RGB;if(t===vl)return Pt.RGBA;if(t===yl)return Pt.LUMINANCE;if(t===xl)return Pt.LUMINANCE_ALPHA;if(t===bl)return Pt.DEPTH_COMPONENT;if(t===wl)return Pt.DEPTH_STENCIL;if(t===lc)return Pt.FUNC_ADD;if(t===hc)return Pt.FUNC_SUBTRACT;if(t===uc)return Pt.FUNC_REVERSE_SUBTRACT;if(t===fc)return Pt.ZERO;if(t===mc)return Pt.ONE;if(t===gc)return Pt.SRC_COLOR;if(t===vc)return Pt.ONE_MINUS_SRC_COLOR;if(t===yc)return Pt.SRC_ALPHA;if(t===xc)return Pt.ONE_MINUS_SRC_ALPHA;if(t===bc)return Pt.DST_ALPHA;if(t===wc)return Pt.ONE_MINUS_DST_ALPHA;if(t===_c)return Pt.DST_COLOR;if(t===Mc)return Pt.ONE_MINUS_DST_COLOR;if(t===Ec)return Pt.SRC_ALPHA_SATURATE;if((t===_l||t===Ml||t===El||t===Sl)&&null!==(e=Ot.get("WEBGL_compressed_texture_s3tc"))){if(t===_l)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===Ml)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===El)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===Sl)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((t===Tl||t===Al||t===Ll||t===Cl)&&null!==(e=Ot.get("WEBGL_compressed_texture_pvrtc"))){if(t===Tl)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===Al)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===Ll)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===Cl)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t===Rl&&null!==(e=Ot.get("WEBGL_compressed_texture_etc1")))return e.COMPRESSED_RGB_ETC1_WEBGL;if((t===dc||t===pc)&&null!==(e=Ot.get("EXT_blend_minmax"))){if(t===dc)return e.MIN_EXT;if(t===pc)return e.MAX_EXT}return t===fl&&null!==(e=Ot.get("WEBGL_depth_texture"))?e.UNSIGNED_INT_24_8_WEBGL:0}console.log("THREE.WebGLRenderer",Gs);var U=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),z=void 0!==t.context?t.context:null,B=void 0!==t.alpha&&t.alpha,F=void 0===t.depth||t.depth,k=void 0===t.stencil||t.stencil,G=void 0!==t.antialias&&t.antialias,V=void 0===t.premultipliedAlpha||t.premultipliedAlpha,H=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,j=[],W=null,X=new Float32Array(8),Y=[],q=[];this.domElement=U,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=zc,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var Z=this,J=null,Q=null,K=null,$=-1,et="",it=null,at=null,ot=new y,st=null,ct=new y,lt=0,ht=U.width,ft=U.height,mt=1,gt=new y(0,0,ht,ft),vt=!1,yt=new y(0,0,ht,ft),xt=new ut,bt=new ve,wt=!1,_t=!1,Mt=new e,Et=new n,St=new e,Tt=new e,At={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[]},Lt={geometries:0,textures:0},Rt={frame:0,calls:0,vertices:0,faces:0,points:0};this.info={render:Rt,memory:Lt,programs:null};var Pt;try{var It={alpha:B,depth:F,stencil:k,antialias:G,premultipliedAlpha:V,preserveDrawingBuffer:H};if(null===(Pt=z||U.getContext("webgl",It)||U.getContext("experimental-webgl",It)))throw null!==U.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===Pt.getShaderPrecisionFormat&&(Pt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),U.addEventListener("webglcontextlost",o,!1)}catch(t){console.error("THREE.WebGLRenderer: "+t)}var Ot=new ge(Pt);Ot.get("WEBGL_depth_texture"),Ot.get("OES_texture_float"),Ot.get("OES_texture_float_linear"),Ot.get("OES_texture_half_float"),Ot.get("OES_texture_half_float_linear"),Ot.get("OES_standard_derivatives"),Ot.get("ANGLE_instanced_arrays"),Ot.get("OES_element_index_uint")&&(Ct.MaxIndex=4294967296);var Nt=new pe(Pt,Ot,t),Dt=new de(Pt,Ot,D),Ut=new ue,zt=new he(Pt,Ot,Dt,Ut,Nt,D,Lt),Bt=new pt(Pt),kt=new Xt(Pt,Bt,Lt),Gt=new qt(Pt,kt,Rt),Vt=new le(this,Nt),Zt=new Yt,Jt=new Ht,Qt=new Ft(this,Dt,Gt,V),Kt=new me(this);this.info.programs=Vt.programs;var $t=new Wt(Pt,Ot,Rt),te=new jt(Pt,Ot,Rt);i(),this.context=Pt,this.capabilities=Nt,this.extensions=Ot,this.properties=Ut,this.renderLists=Jt,this.state=Dt,this.vr=Kt;var ee=new dt(this,At,Gt,Nt);this.shadowMap=ee;var re=new nt(this,Y),ne=new rt(this,q);this.getContext=function(){return Pt},this.getContextAttributes=function(){return Pt.getContextAttributes()},this.forceContextLoss=function(){var t=Ot.get("WEBGL_lose_context");t&&t.loseContext()},this.getMaxAnisotropy=function(){return Nt.getMaxAnisotropy()},this.getPrecision=function(){return Nt.precision},this.getPixelRatio=function(){return mt},this.setPixelRatio=function(t){void 0!==t&&(mt=t,this.setSize(ht,ft,!1))},this.getSize=function(){return{width:ht,height:ft}},this.setSize=function(t,e,r){var n=Kt.getDevice();if(n&&n.isPresenting)return void console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");ht=t,ft=e,U.width=t*mt,U.height=e*mt,!1!==r&&(U.style.width=t+"px",U.style.height=e+"px"),this.setViewport(0,0,t,e)},this.getDrawingBufferSize=function(){return{width:ht*mt,height:ft*mt}},this.setDrawingBufferSize=function(t,e,r){ht=t,ft=e,mt=r,U.width=t*r,U.height=e*r,this.setViewport(0,0,t,e)},this.setViewport=function(t,e,r,n){yt.set(t,ft-e-n,r,n),Dt.viewport(ct.copy(yt).multiplyScalar(mt))},this.setScissor=function(t,e,r,n){gt.set(t,ft-e-n,r,n),Dt.scissor(ot.copy(gt).multiplyScalar(mt))},this.setScissorTest=function(t){Dt.setScissorTest(vt=t)},this.getClearColor=Qt.getClearColor,this.setClearColor=Qt.setClearColor,this.getClearAlpha=Qt.getClearAlpha,this.setClearAlpha=Qt.setClearAlpha,this.clear=function(t,e,r){var n=0;(void 0===t||t)&&(n|=Pt.COLOR_BUFFER_BIT),(void 0===e||e)&&(n|=Pt.DEPTH_BUFFER_BIT),(void 0===r||r)&&(n|=Pt.STENCIL_BUFFER_BIT),Pt.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(t,e,r,n){this.setRenderTarget(t),this.clear(e,r,n)},this.resetGLState=a,this.dispose=function(){U.removeEventListener("webglcontextlost",o,!1),Jt.dispose()},this.renderBufferImmediate=function(t,e,r){Dt.initAttributes();var n=Ut.get(t);t.hasPositions&&!n.position&&(n.position=Pt.createBuffer()),t.hasNormals&&!n.normal&&(n.normal=Pt.createBuffer()),t.hasUvs&&!n.uv&&(n.uv=Pt.createBuffer()),t.hasColors&&!n.color&&(n.color=Pt.createBuffer());var i=e.getAttributes();if(t.hasPositions&&(Pt.bindBuffer(Pt.ARRAY_BUFFER,n.position),Pt.bufferData(Pt.ARRAY_BUFFER,t.positionArray,Pt.DYNAMIC_DRAW),Dt.enableAttribute(i.position),Pt.vertexAttribPointer(i.position,3,Pt.FLOAT,!1,0,0)),t.hasNormals){if(Pt.bindBuffer(Pt.ARRAY_BUFFER,n.normal),!r.isMeshPhongMaterial&&!r.isMeshStandardMaterial&&!r.isMeshNormalMaterial&&r.shading===Ks)for(var a=0,o=3*t.count;a<o;a+=9){var s=t.normalArray,c=(s[a+0]+s[a+3]+s[a+6])/3,l=(s[a+1]+s[a+4]+s[a+7])/3,h=(s[a+2]+s[a+5]+s[a+8])/3;s[a+0]=c,s[a+1]=l,s[a+2]=h,s[a+3]=c,s[a+4]=l,s[a+5]=h,s[a+6]=c,s[a+7]=l,s[a+8]=h}Pt.bufferData(Pt.ARRAY_BUFFER,t.normalArray,Pt.DYNAMIC_DRAW),Dt.enableAttribute(i.normal),Pt.vertexAttribPointer(i.normal,3,Pt.FLOAT,!1,0,0)}t.hasUvs&&r.map&&(Pt.bindBuffer(Pt.ARRAY_BUFFER,n.uv),Pt.bufferData(Pt.ARRAY_BUFFER,t.uvArray,Pt.DYNAMIC_DRAW),Dt.enableAttribute(i.uv),Pt.vertexAttribPointer(Bt.uv,2,Pt.FLOAT,!1,0,0)),t.hasColors&&r.vertexColors!==tc&&(Pt.bindBuffer(Pt.ARRAY_BUFFER,n.color),Pt.bufferData(Pt.ARRAY_BUFFER,t.colorArray,Pt.DYNAMIC_DRAW),Dt.enableAttribute(i.color),Pt.vertexAttribPointer(i.color,3,Pt.FLOAT,!1,0,0)),Dt.disableUnusedAttributes(),Pt.drawArrays(Pt.TRIANGLES,0,t.count),t.count=0},this.renderBufferDirect=function(t,e,n,i,a,o){Dt.setMaterial(i);var s=x(t,e,i,a),c=n.id+"_"+s.id+"_"+(!0===i.wireframe),l=!1;c!==et&&(et=c,l=!0);var h=a.morphTargetInfluences;if(void 0!==h){for(var d=[],f=0,m=h.length;f<m;f++){v=h[f];d.push([v,f])}d.sort(u),d.length>8&&(d.length=8);for(var g=n.morphAttributes,f=0,m=d.length;f<m;f++){var v=d[f];if(X[f]=v[0],0!==v[0]){b=v[1];!0===i.morphTargets&&g.position&&n.addAttribute("morphTarget"+f,g.position[b]),!0===i.morphNormals&&g.normal&&n.addAttribute("morphNormal"+f,g.normal[b])}else!0===i.morphTargets&&n.removeAttribute("morphTarget"+f),!0===i.morphNormals&&n.removeAttribute("morphNormal"+f)}for(var f=d.length,y=X.length;f<y;f++)X[f]=0;s.getUniforms().setValue(Pt,"morphTargetInfluences",X),l=!0}var b=n.index,w=n.attributes.position,_=1;!0===i.wireframe&&(b=kt.getWireframeAttribute(n),_=2);var M,E=$t;null!==b&&(M=Bt.get(b),(E=te).setIndex(M)),l&&(p(i,s,n),null!==b&&Pt.bindBuffer(Pt.ELEMENT_ARRAY_BUFFER,M.buffer));var S=0;null!==b?S=b.count:void 0!==w&&(S=w.count);var T=n.drawRange.start*_,A=n.drawRange.count*_,L=null!==o?o.start*_:0,C=null!==o?o.count*_:1/0,R=Math.max(T,L),P=Math.min(S,T+A,L+C)-1,I=Math.max(0,P-R+1);if(0!==I){if(a.isMesh)if(!0===i.wireframe)Dt.setLineWidth(i.wireframeLinewidth*r()),E.setMode(Pt.LINES);else switch(a.drawMode){case Ol:E.setMode(Pt.TRIANGLES);break;case Nl:E.setMode(Pt.TRIANGLE_STRIP);break;case Dl:E.setMode(Pt.TRIANGLE_FAN)}else if(a.isLine){var O=i.linewidth;void 0===O&&(O=1),Dt.setLineWidth(O*r()),a.isLineSegments?E.setMode(Pt.LINES):a.isLineLoop?E.setMode(Pt.LINE_LOOP):E.setMode(Pt.LINE_STRIP)}else a.isPoints&&E.setMode(Pt.POINTS);n&&n.isInstancedBufferGeometry?n.maxInstancedCount>0&&E.renderInstances(n,R,I):E.render(R,I)}},this.compile=function(t,e){j=[],t.traverse(function(t){t.isLight&&j.push(t)}),O(j,e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var r=0;r<e.material.length;r++)v(e.material[r],t.fog,e);else v(e.material,t.fog,e)})},this.animate=function(t){function e(){t(),(Kt.getDevice()||window).requestAnimationFrame(e)}(Kt.getDevice()||window).requestAnimationFrame(e)},this.render=function(t,e,r,n){if(!e||!e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");et="",$=-1,it=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),Kt.enabled&&(e=Kt.getCamera(e)),Mt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),xt.setFromMatrix(Mt),j.length=0,Y.length=0,q.length=0,_t=this.localClippingEnabled,wt=bt.init(this.clippingPlanes,_t,e),(W=Jt.get(t,e)).init(),f(t,e,Z.sortObjects),W.finish(),!0===Z.sortObjects&&W.sort(),wt&&bt.beginShadows(),I(j),ee.render(t,e),O(j,e),wt&&bt.endShadows(),Rt.frame++,Rt.calls=0,Rt.vertices=0,Rt.faces=0,Rt.points=0,void 0===r&&(r=null),this.setRenderTarget(r),Qt.render(t,e,n);var i=W.opaque,a=W.transparent;if(t.overrideMaterial){var o=t.overrideMaterial;i.length&&m(i,t,e,o),a.length&&m(a,t,e,o)}else i.length&&m(i,t,e),a.length&&m(a,t,e);re.render(t,e),ne.render(t,e,ct),r&&zt.updateRenderTargetMipmap(r),Dt.buffers.depth.setTest(!0),Dt.buffers.depth.setMask(!0),Dt.buffers.color.setMask(!0),e.isArrayCamera&&Z.setScissorTest(!1),Kt.enabled&&Kt.submitFrame()},this.setFaceCulling=function(t,e){Dt.setCullFace(t),Dt.setFlipSided(e===Xs)},this.allocTextureUnit=N,this.setTexture2D=function(){var t=!1;return function(e,r){e&&e.isWebGLRenderTarget&&(t||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),zt.setTexture2D(e,r)}}(),this.setTexture=function(){var t=!1;return function(e,r){t||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),t=!0),zt.setTexture2D(e,r)}}(),this.setTextureCube=function(){var t=!1;return function(e,r){e&&e.isWebGLRenderTargetCube&&(t||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?zt.setTextureCube(e,r):zt.setTextureCubeDynamic(e,r)}}(),this.getRenderTarget=function(){return Q},this.setRenderTarget=function(t){Q=t,t&&void 0===Ut.get(t).__webglFramebuffer&&zt.setupRenderTarget(t);var e,r=t&&t.isWebGLRenderTargetCube;if(t){var n=Ut.get(t);e=r?n.__webglFramebuffer[t.activeCubeFace]:n.__webglFramebuffer,ot.copy(t.scissor),st=t.scissorTest,ct.copy(t.viewport)}else e=null,ot.copy(gt).multiplyScalar(mt),st=vt,ct.copy(yt).multiplyScalar(mt);if(K!==e&&(Pt.bindFramebuffer(Pt.FRAMEBUFFER,e),K=e),Dt.scissor(ot),Dt.setScissorTest(st),Dt.viewport(ct),r){var i=Ut.get(t.texture);Pt.framebufferTexture2D(Pt.FRAMEBUFFER,Pt.COLOR_ATTACHMENT0,Pt.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,i.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,r,n,i,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");var o=Ut.get(t).__webglFramebuffer;if(o){var s=!1;o!==K&&(Pt.bindFramebuffer(Pt.FRAMEBUFFER,o),s=!0);try{var c=t.texture,l=c.format,h=c.type;if(l!==vl&&D(l)!==Pt.getParameter(Pt.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===nl||D(h)===Pt.getParameter(Pt.IMPLEMENTATION_COLOR_READ_TYPE)||h===ll&&(Ot.get("OES_texture_float")||Ot.get("WEBGL_color_buffer_float"))||h===hl&&Ot.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");Pt.checkFramebufferStatus(Pt.FRAMEBUFFER)===Pt.FRAMEBUFFER_COMPLETE?e>=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&Pt.readPixels(e,r,n,i,D(l),D(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&Pt.bindFramebuffer(Pt.FRAMEBUFFER,K)}}}}function xe(t,e){this.name="",this.color=new c(t),this.density=void 0!==e?e:25e-5}function be(t,e,r){this.name="",this.color=new c(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function we(){gt.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function _e(t,e,r,i,a){gt.call(this),this.lensFlares=[],this.positionScreen=new n,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,i,a)}function Me(t){it.call(this),this.type="SpriteMaterial",this.color=new c(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function Ee(t){gt.call(this),this.type="Sprite",this.material=void 0!==t?t:new Me}function Se(){gt.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Te(t,r){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===r)this.calculateInverses();else if(this.bones.length===r.length)this.boneInverses=r.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new e)}}function Ae(){gt.call(this),this.type="Bone"}function Le(t,r){Bt.call(this,t,r),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new e,this.bindMatrixInverse=new e;var n=new Te(this.initBones());this.bind(n,this.matrixWorld),this.normalizeSkinWeights()}function Ce(t){it.call(this),this.type="LineBasicMaterial",this.color=new c(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.lights=!1,this.setValues(t)}function Re(t,e,r){if(1===r)return console.warn("THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead."),new Pe(t,e);gt.call(this),this.type="Line",this.geometry=void 0!==t?t:new Ct,this.material=void 0!==e?e:new Ce({color:16777215*Math.random()})}function Pe(t,e){Re.call(this,t,e),this.type="LineSegments"}function Ie(t,e){Re.call(this,t,e),this.type="LineLoop"}function Oe(t){it.call(this),this.type="PointsMaterial",this.color=new c(16777215),this.map=null,this.size=1,this.sizeAttenuation=!0,this.lights=!1,this.setValues(t)}function Ne(t,e){gt.call(this),this.type="Points",this.geometry=void 0!==t?t:new Ct,this.material=void 0!==e?e:new Oe({color:16777215*Math.random()})}function De(){gt.call(this),this.type="Group"}function Ue(t,e,r,n,i,a,o,s,c,l,h,d){u.call(this,null,a,o,s,c,l,n,i,h,d),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function ze(t,e,r,n,i,a,o,s,c){u.call(this,t,e,r,n,i,a,o,s,c),this.needsUpdate=!0}function Be(t){Ct.call(this),this.type="WireframeGeometry";var e,r,i,a,o,s,c,l,h,u,d=[],p=[0,0],f={},m=["a","b","c"];if(t&&t.isGeometry){var g=t.faces;for(e=0,i=g.length;e<i;e++){var v=g[e];for(r=0;r<3;r++)c=v[m[r]],l=v[m[(r+1)%3]],p[0]=Math.min(c,l),p[1]=Math.max(c,l),void 0===f[h=p[0]+","+p[1]]&&(f[h]={index1:p[0],index2:p[1]})}for(h in f)s=f[h],u=t.vertices[s.index1],d.push(u.x,u.y,u.z),u=t.vertices[s.index2],d.push(u.x,u.y,u.z)}else if(t&&t.isBufferGeometry){var y,x,b,w,_,M,E;if(u=new n,null!==t.index){for(y=t.attributes.position,x=t.index,0===(b=t.groups).length&&(b=[{start:0,count:x.count,materialIndex:0}]),a=0,o=b.length;a<o;++a)for(e=_=(w=b[a]).start,i=_+w.count;e<i;e+=3)for(r=0;r<3;r++)c=x.getX(e+r),l=x.getX(e+(r+1)%3),p[0]=Math.min(c,l),p[1]=Math.max(c,l),void 0===f[h=p[0]+","+p[1]]&&(f[h]={index1:p[0],index2:p[1]});for(h in f)s=f[h],u.fromBufferAttribute(y,s.index1),d.push(u.x,u.y,u.z),u.fromBufferAttribute(y,s.index2),d.push(u.x,u.y,u.z)}else for(e=0,i=(y=t.attributes.position).count/3;e<i;e++)for(r=0;r<3;r++)M=3*e+r,u.fromBufferAttribute(y,M),d.push(u.x,u.y,u.z),E=3*e+(r+1)%3,u.fromBufferAttribute(y,E),d.push(u.x,u.y,u.z)}this.addAttribute("position",new Tt(d,3))}function Fe(t,e,r){_t.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:r},this.fromBufferGeometry(new ke(t,e,r)),this.mergeVertices()}function ke(t,e,r){Ct.call(this),this.type="ParametricBufferGeometry",this.parameters={func:t,slices:e,stacks:r};var i,a,o=[],s=[],c=[],l=[],h=new n,u=new n,d=new n,p=new n,f=new n,m=e+1;for(i=0;i<=r;i++){var g=i/r;for(a=0;a<=e;a++){var v=a/e;u=t(v,g,u),s.push(u.x,u.y,u.z),v-1e-5>=0?(d=t(v-1e-5,g,d),p.subVectors(u,d)):(d=t(v+1e-5,g,d),p.subVectors(d,u)),g-1e-5>=0?(d=t(v,g-1e-5,d),f.subVectors(u,d)):(d=t(v,g+1e-5,d),f.subVectors(d,u)),h.crossVectors(p,f).normalize(),c.push(h.x,h.y,h.z),l.push(v,g)}}for(i=0;i<r;i++)for(a=0;a<e;a++){var y=i*m+a,x=i*m+a+1,b=(i+1)*m+a+1,w=(i+1)*m+a;o.push(y,x,w),o.push(x,b,w)}this.setIndex(o),this.addAttribute("position",new Tt(s,3)),this.addAttribute("normal",new Tt(c,3)),this.addAttribute("uv",new Tt(l,2))}function Ge(t,e,r,n){_t.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:n},this.fromBufferGeometry(new Ve(t,e,r,n)),this.mergeVertices()}function Ve(t,e,r,i){function a(t,e,r,n){var i,a,o=Math.pow(2,n),c=[];for(i=0;i<=o;i++){c[i]=[];var l=t.clone().lerp(r,i/o),h=e.clone().lerp(r,i/o),u=o-i;for(a=0;a<=u;a++)c[i][a]=0===a&&i===o?l:l.clone().lerp(h,a/u)}for(i=0;i<o;i++)for(a=0;a<2*(o-i)-1;a++){var d=Math.floor(a/2);a%2==0?(s(c[i][d+1]),s(c[i+1][d]),s(c[i][d])):(s(c[i][d+1]),s(c[i+1][d+1]),s(c[i+1][d]))}}function o(){for(var t=0;t<m.length;t+=6){var e=m[t+0],r=m[t+2],n=m[t+4],i=Math.max(e,r,n),a=Math.min(e,r,n);i>.9&&a<.1&&(e<.2&&(m[t+0]+=1),r<.2&&(m[t+2]+=1),n<.2&&(m[t+4]+=1))}}function s(t){f.push(t.x,t.y,t.z)}function c(e,r){var n=3*e;r.x=t[n+0],r.y=t[n+1],r.z=t[n+2]}function l(){for(var t=new n,e=new n,r=new n,i=new n,a=new h,o=new h,s=new h,c=0,l=0;c<f.length;c+=9,l+=6){t.set(f[c+0],f[c+1],f[c+2]),e.set(f[c+3],f[c+4],f[c+5]),r.set(f[c+6],f[c+7],f[c+8]),a.set(m[l+0],m[l+1]),o.set(m[l+2],m[l+3]),s.set(m[l+4],m[l+5]),i.copy(t).add(e).add(r).divideScalar(3);var p=d(i);u(a,l+0,t,p),u(o,l+2,e,p),u(s,l+4,r,p)}}function u(t,e,r,n){n<0&&1===t.x&&(m[e]=t.x-1),0===r.x&&0===r.z&&(m[e]=n/2/Math.PI+.5)}function d(t){return Math.atan2(t.z,-t.x)}function p(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}Ct.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:i},r=r||1;var f=[],m=[];!function(t){for(var r=new n,i=new n,o=new n,s=0;s<e.length;s+=3)c(e[s+0],r),c(e[s+1],i),c(e[s+2],o),a(r,i,o,t)}(i=i||0),function(t){for(var e=new n,r=0;r<f.length;r+=3)e.x=f[r+0],e.y=f[r+1],e.z=f[r+2],e.normalize().multiplyScalar(t),f[r+0]=e.x,f[r+1]=e.y,f[r+2]=e.z}(r),function(){for(var t=new n,e=0;e<f.length;e+=3){t.x=f[e+0],t.y=f[e+1],t.z=f[e+2];var r=d(t)/2/Math.PI+.5,i=p(t)/Math.PI+.5;m.push(r,1-i)}l(),o()}(),this.addAttribute("position",new Tt(f,3)),this.addAttribute("normal",new Tt(f.slice(),3)),this.addAttribute("uv",new Tt(m,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}function He(t,e){_t.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new je(t,e)),this.mergeVertices()}function je(t,e){var r=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],n=[2,1,0,0,3,2,1,3,0,2,3,1];Ve.call(this,r,n,t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function We(t,e){_t.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Xe(t,e)),this.mergeVertices()}function Xe(t,e){var r=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],n=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];Ve.call(this,r,n,t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Ye(t,e){_t.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new qe(t,e)),this.mergeVertices()}function qe(t,e){var r=(1+Math.sqrt(5))/2,n=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],i=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];Ve.call(this,n,i,t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Ze(t,e){_t.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Je(t,e)),this.mergeVertices()}function Je(t,e){var r=(1+Math.sqrt(5))/2,n=1/r,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];Ve.call(this,i,a,t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Qe(t,e,r,n,i,a){_t.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:n,closed:i},void 0!==a&&console.warn("THREE.TubeGeometry: taper has been removed.");var o=new Ke(t,e,r,n,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function Ke(t,e,r,i,a){function o(n){var a=t.getPointAt(n/e),o=l.normals[n],s=l.binormals[n];for(d=0;d<=i;d++){var c=d/i*Math.PI*2,h=Math.sin(c),u=-Math.cos(c);f.x=u*o.x+h*s.x,f.y=u*o.y+h*s.y,f.z=u*o.z+h*s.z,f.normalize(),v.push(f.x,f.y,f.z),p.x=a.x+r*f.x,p.y=a.y+r*f.y,p.z=a.z+r*f.z,g.push(p.x,p.y,p.z)}}function s(){for(d=1;d<=e;d++)for(u=1;u<=i;u++){var t=(i+1)*(d-1)+(u-1),r=(i+1)*d+(u-1),n=(i+1)*d+u,a=(i+1)*(d-1)+u;x.push(t,r,a),x.push(r,n,a)}}function c(){for(u=0;u<=e;u++)for(d=0;d<=i;d++)m.x=u/e,m.y=d/i,y.push(m.x,m.y)}Ct.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:i,closed:a},e=e||64,r=r||1,i=i||8,a=a||!1;var l=t.computeFrenetFrames(e,a);this.tangents=l.tangents,this.normals=l.normals,this.binormals=l.binormals;var u,d,p=new n,f=new n,m=new h,g=[],v=[],y=[],x=[];!function(){for(u=0;u<e;u++)o(u);o(!1===a?e:0),c(),s()}(),this.setIndex(x),this.addAttribute("position",new Tt(g,3)),this.addAttribute("normal",new Tt(v,3)),this.addAttribute("uv",new Tt(y,2))}function $e(t,e,r,n,i,a,o){_t.call(this),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:n,p:i,q:a},void 0!==o&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new tr(t,e,r,n,i,a)),this.mergeVertices()}function tr(t,e,r,i,a,o){function s(t,e,r,n,i){var a=Math.cos(t),o=Math.sin(t),s=r/e*t,c=Math.cos(s);i.x=n*(2+c)*.5*a,i.y=n*(2+c)*o*.5,i.z=n*Math.sin(s)*.5}Ct.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:i,p:a,q:o},t=t||100,e=e||40,r=Math.floor(r)||64,i=Math.floor(i)||8,a=a||2,o=o||3;var c,l,h=[],u=[],d=[],p=[],f=new n,m=new n,g=new n,v=new n,y=new n,x=new n,b=new n;for(c=0;c<=r;++c){var w=c/r*a*Math.PI*2;for(s(w,a,o,t,g),s(w+.01,a,o,t,v),x.subVectors(v,g),b.addVectors(v,g),y.crossVectors(x,b),b.crossVectors(y,x),y.normalize(),b.normalize(),l=0;l<=i;++l){var _=l/i*Math.PI*2,M=-e*Math.cos(_),E=e*Math.sin(_);f.x=g.x+(M*b.x+E*y.x),f.y=g.y+(M*b.y+E*y.y),f.z=g.z+(M*b.z+E*y.z),u.push(f.x,f.y,f.z),m.subVectors(f,g).normalize(),d.push(m.x,m.y,m.z),p.push(c/r),p.push(l/i)}}for(l=1;l<=r;l++)for(c=1;c<=i;c++){var S=(i+1)*(l-1)+(c-1),T=(i+1)*l+(c-1),A=(i+1)*l+c,L=(i+1)*(l-1)+c;h.push(S,T,L),h.push(T,A,L)}this.setIndex(h),this.addAttribute("position",new Tt(u,3)),this.addAttribute("normal",new Tt(d,3)),this.addAttribute("uv",new Tt(p,2))}function er(t,e,r,n,i){_t.call(this),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:r,tubularSegments:n,arc:i},this.fromBufferGeometry(new rr(t,e,r,n,i)),this.mergeVertices()}function rr(t,e,r,i,a){Ct.call(this),this.type="TorusBufferGeometry",this.parameters={radius:t,tube:e,radialSegments:r,tubularSegments:i,arc:a},t=t||100,e=e||40,r=Math.floor(r)||8,i=Math.floor(i)||6,a=a||2*Math.PI;var o,s,c=[],l=[],h=[],u=[],d=new n,p=new n,f=new n;for(o=0;o<=r;o++)for(s=0;s<=i;s++){var m=s/i*a,g=o/r*Math.PI*2;p.x=(t+e*Math.cos(g))*Math.cos(m),p.y=(t+e*Math.cos(g))*Math.sin(m),p.z=e*Math.sin(g),l.push(p.x,p.y,p.z),d.x=t*Math.cos(m),d.y=t*Math.sin(m),f.subVectors(p,d).normalize(),h.push(f.x,f.y,f.z),u.push(s/i),u.push(o/r)}for(o=1;o<=r;o++)for(s=1;s<=i;s++){var v=(i+1)*o+s-1,y=(i+1)*(o-1)+s-1,x=(i+1)*(o-1)+s,b=(i+1)*o+s;c.push(v,y,b),c.push(y,x,b)}this.setIndex(c),this.addAttribute("position",new Tt(l,3)),this.addAttribute("normal",new Tt(h,3)),this.addAttribute("uv",new Tt(u,2))}function nr(t,e){_t.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},this.fromBufferGeometry(new ir(t,e)),this.mergeVertices()}function ir(t,e){void 0!==t&&(Ct.call(this),this.type="ExtrudeBufferGeometry",t=Array.isArray(t)?t:[t],this.addShapeList(t,e),this.computeVertexNormals())}function ar(t,e){_t.call(this),this.type="TextGeometry",this.parameters={text:t,parameters:e},this.fromBufferGeometry(new or(t,e)),this.mergeVertices()}function or(t,e){var r=(e=e||{}).font;if(!r||!r.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new _t;var n=r.generateShapes(t,e.size,e.curveSegments);e.amount=void 0!==e.height?e.height:50,void 0===e.bevelThickness&&(e.bevelThickness=10),void 0===e.bevelSize&&(e.bevelSize=8),void 0===e.bevelEnabled&&(e.bevelEnabled=!1),ir.call(this,n,e),this.type="TextBufferGeometry"}function sr(t,e,r,n,i,a,o){_t.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:n,phiLength:i,thetaStart:a,thetaLength:o},this.fromBufferGeometry(new cr(t,e,r,n,i,a,o)),this.mergeVertices()}function cr(t,e,r,i,a,o,s){Ct.call(this),this.type="SphereBufferGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:i,phiLength:a,thetaStart:o,thetaLength:s},t=t||50,e=Math.max(3,Math.floor(e)||8),r=Math.max(2,Math.floor(r)||6),i=void 0!==i?i:0,a=void 0!==a?a:2*Math.PI;var c,l,h=(o=void 0!==o?o:0)+(s=void 0!==s?s:Math.PI),u=0,d=[],p=new n,f=new n,m=[],g=[],v=[],y=[];for(l=0;l<=r;l++){var x=[],b=l/r;for(c=0;c<=e;c++){var w=c/e;p.x=-t*Math.cos(i+w*a)*Math.sin(o+b*s),p.y=t*Math.cos(o+b*s),p.z=t*Math.sin(i+w*a)*Math.sin(o+b*s),g.push(p.x,p.y,p.z),f.set(p.x,p.y,p.z).normalize(),v.push(f.x,f.y,f.z),y.push(w,1-b),x.push(u++)}d.push(x)}for(l=0;l<r;l++)for(c=0;c<e;c++){var _=d[l][c+1],M=d[l][c],E=d[l+1][c],S=d[l+1][c+1];(0!==l||o>0)&&m.push(_,M,S),(l!==r-1||h<Math.PI)&&m.push(M,E,S)}this.setIndex(m),this.addAttribute("position",new Tt(g,3)),this.addAttribute("normal",new Tt(v,3)),this.addAttribute("uv",new Tt(y,2))}function lr(t,e,r,n,i,a){_t.call(this),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:r,phiSegments:n,thetaStart:i,thetaLength:a},this.fromBufferGeometry(new hr(t,e,r,n,i,a)),this.mergeVertices()}function hr(t,e,r,i,a,o){Ct.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:r,phiSegments:i,thetaStart:a,thetaLength:o},t=t||20,e=e||50,a=void 0!==a?a:0,o=void 0!==o?o:2*Math.PI,r=void 0!==r?Math.max(3,r):8;var s,c,l,u=[],d=[],p=[],f=[],m=t,g=(e-t)/(i=void 0!==i?Math.max(1,i):1),v=new n,y=new h;for(c=0;c<=i;c++){for(l=0;l<=r;l++)s=a+l/r*o,v.x=m*Math.cos(s),v.y=m*Math.sin(s),d.push(v.x,v.y,v.z),p.push(0,0,1),y.x=(v.x/e+1)/2,y.y=(v.y/e+1)/2,f.push(y.x,y.y);m+=g}for(c=0;c<i;c++){var x=c*(r+1);for(l=0;l<r;l++){var b=s=l+x,w=s+r+1,_=s+r+2,M=s+1;u.push(b,w,M),u.push(w,_,M)}}this.setIndex(u),this.addAttribute("position",new Tt(d,3)),this.addAttribute("normal",new Tt(p,3)),this.addAttribute("uv",new Tt(f,2))}function ur(t,e,r,n){_t.call(this),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:n},this.fromBufferGeometry(new dr(t,e,r,n)),this.mergeVertices()}function dr(t,e,r,i){Ct.call(this),this.type="LatheBufferGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:i},e=Math.floor(e)||12,r=r||0,i=i||2*Math.PI,i=Ko.clamp(i,0,2*Math.PI);var a,o,s,c=[],l=[],u=[],d=1/e,p=new n,f=new h;for(o=0;o<=e;o++){var m=r+o*d*i,g=Math.sin(m),v=Math.cos(m);for(s=0;s<=t.length-1;s++)p.x=t[s].x*g,p.y=t[s].y,p.z=t[s].x*v,l.push(p.x,p.y,p.z),f.x=o/e,f.y=s/(t.length-1),u.push(f.x,f.y)}for(o=0;o<e;o++)for(s=0;s<t.length-1;s++){var y=a=s+o*t.length,x=a+t.length,b=a+t.length+1,w=a+1;c.push(y,x,w),c.push(x,b,w)}if(this.setIndex(c),this.addAttribute("position",new Tt(l,3)),this.addAttribute("uv",new Tt(u,2)),this.computeVertexNormals(),i===2*Math.PI){var _=this.attributes.normal.array,M=new n,E=new n,S=new n;for(a=e*t.length*3,o=0,s=0;o<t.length;o++,s+=3)M.x=_[s+0],M.y=_[s+1],M.z=_[s+2],E.x=_[a+s+0],E.y=_[a+s+1],E.z=_[a+s+2],S.addVectors(M,E).normalize(),_[s+0]=_[a+s+0]=S.x,_[s+1]=_[a+s+1]=S.y,_[s+2]=_[a+s+2]=S.z}}function pr(t,e){_t.call(this),this.type="ShapeGeometry","object"==typeof e&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),e=e.curveSegments),this.parameters={shapes:t,curveSegments:e},this.fromBufferGeometry(new fr(t,e)),this.mergeVertices()}function fr(t,e){function r(t){var r,s,l,h=i.length/3,u=t.extractPoints(e),d=u.shape,p=u.holes;if(!1===lh.isClockWise(d))for(d=d.reverse(),r=0,s=p.length;r<s;r++)l=p[r],!0===lh.isClockWise(l)&&(p[r]=l.reverse());var f=lh.triangulateShape(d,p);for(r=0,s=p.length;r<s;r++)l=p[r],d=d.concat(l);for(r=0,s=d.length;r<s;r++){var m=d[r];i.push(m.x,m.y,0),a.push(0,0,1),o.push(m.x,m.y)}for(r=0,s=f.length;r<s;r++){var g=f[r],v=g[0]+h,y=g[1]+h,x=g[2]+h;n.push(v,y,x),c+=3}}Ct.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:t,curveSegments:e},e=e||12;var n=[],i=[],a=[],o=[],s=0,c=0;if(!1===Array.isArray(t))r(t);else for(var l=0;l<t.length;l++)r(t[l]),this.addGroup(s,c,l),s+=c,c=0;this.setIndex(n),this.addAttribute("position",new Tt(i,3)),this.addAttribute("normal",new Tt(a,3)),this.addAttribute("uv",new Tt(o,2))}function mr(t,e){Ct.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:e},e=void 0!==e?e:1;var r,n,i,a,o=[],s=Math.cos(Ko.DEG2RAD*e),c=[0,0],l={},h=["a","b","c"];t.isBufferGeometry?(a=new _t).fromBufferGeometry(t):a=t.clone(),a.mergeVertices(),a.computeFaceNormals();for(var u=a.vertices,d=a.faces,p=0,f=d.length;p<f;p++)for(var m=d[p],g=0;g<3;g++)r=m[h[g]],n=m[h[(g+1)%3]],c[0]=Math.min(r,n),c[1]=Math.max(r,n),void 0===l[i=c[0]+","+c[1]]?l[i]={index1:c[0],index2:c[1],face1:p,face2:void 0}:l[i].face2=p;for(i in l){var v=l[i];if(void 0===v.face2||d[v.face1].normal.dot(d[v.face2].normal)<=s){var y=u[v.index1];o.push(y.x,y.y,y.z),y=u[v.index2],o.push(y.x,y.y,y.z)}}this.addAttribute("position",new Tt(o,3))}function gr(t,e,r,n,i,a,o,s){_t.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:n,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s},this.fromBufferGeometry(new vr(t,e,r,n,i,a,o,s)),this.mergeVertices()}function vr(t,e,r,i,a,o,s,c){function l(r){var a,o,l,v=new h,b=new n,w=0,_=!0===r?t:e,M=!0===r?1:-1;for(o=g,a=1;a<=i;a++)p.push(0,y*M,0),f.push(0,M,0),m.push(.5,.5),g++;for(l=g,a=0;a<=i;a++){var E=a/i*c+s,S=Math.cos(E),T=Math.sin(E);b.x=_*T,b.y=y*M,b.z=_*S,p.push(b.x,b.y,b.z),f.push(0,M,0),v.x=.5*S+.5,v.y=.5*T*M+.5,m.push(v.x,v.y),g++}for(a=0;a<i;a++){var A=o+a,L=l+a;!0===r?d.push(L,L+1,A):d.push(L+1,L,A),w+=3}u.addGroup(x,w,!0===r?1:2),x+=w}Ct.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:i,heightSegments:a,openEnded:o,thetaStart:s,thetaLength:c};var u=this;t=void 0!==t?t:20,e=void 0!==e?e:20,r=void 0!==r?r:100,i=Math.floor(i)||8,a=Math.floor(a)||1,o=void 0!==o&&o,s=void 0!==s?s:0,c=void 0!==c?c:2*Math.PI;var d=[],p=[],f=[],m=[],g=0,v=[],y=r/2,x=0;!function(){var o,l,h=new n,b=new n,w=0,_=(e-t)/r;for(l=0;l<=a;l++){var M=[],E=l/a,S=E*(e-t)+t;for(o=0;o<=i;o++){var T=o/i,A=T*c+s,L=Math.sin(A),C=Math.cos(A);b.x=S*L,b.y=-E*r+y,b.z=S*C,p.push(b.x,b.y,b.z),h.set(L,_,C).normalize(),f.push(h.x,h.y,h.z),m.push(T,1-E),M.push(g++)}v.push(M)}for(o=0;o<i;o++)for(l=0;l<a;l++){var R=v[l][o],P=v[l+1][o],I=v[l+1][o+1],O=v[l][o+1];d.push(R,P,O),d.push(P,I,O),w+=6}u.addGroup(x,w,0),x+=w}(),!1===o&&(t>0&&l(!0),e>0&&l(!1)),this.setIndex(d),this.addAttribute("position",new Tt(p,3)),this.addAttribute("normal",new Tt(f,3)),this.addAttribute("uv",new Tt(m,2))}function yr(t,e,r,n,i,a,o){gr.call(this,0,t,e,r,n,i,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:a,thetaLength:o}}function xr(t,e,r,n,i,a,o){vr.call(this,0,t,e,r,n,i,a,o),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:a,thetaLength:o}}function br(t,e,r,n){_t.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new wr(t,e,r,n)),this.mergeVertices()}function wr(t,e,r,i){Ct.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:i},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI;var a,o,s=[],c=[],l=[],u=[],d=new n,p=new h;for(c.push(0,0,0),l.push(0,0,1),u.push(.5,.5),o=0,a=3;o<=e;o++,a+=3){var f=r+o/e*i;d.x=t*Math.cos(f),d.y=t*Math.sin(f),c.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(c[a]/t+1)/2,p.y=(c[a+1]/t+1)/2,u.push(p.x,p.y)}for(a=1;a<=e;a++)s.push(a,a+1,0);this.setIndex(s),this.addAttribute("position",new Tt(c,3)),this.addAttribute("normal",new Tt(l,3)),this.addAttribute("uv",new Tt(u,2))}function _r(t){at.call(this,{uniforms:rh.merge([eh.lights,{opacity:{value:1}}]),vertexShader:nh.shadow_vert,fragmentShader:nh.shadow_frag}),this.lights=!0,this.transparent=!0,Object.defineProperties(this,{opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}}}),this.setValues(t)}function Mr(t){at.call(this,t),this.type="RawShaderMaterial"}function Er(t){it.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new c(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new c(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new h(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Sr(t){Er.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function Tr(t){it.call(this),this.type="MeshPhongMaterial",this.color=new c(16777215),this.specular=new c(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new c(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new h(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Oc,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.morphNormals=!1,this.setValues(t)}function Ar(t){Tr.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Lr(t){it.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new h(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Cr(t){it.call(this),this.type="MeshLambertMaterial",this.color=new c(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new c(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Oc,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.morphNormals=!1,this.setValues(t)}function Rr(t){it.call(this),this.type="LineDashedMaterial",this.color=new c(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.lights=!1,this.setValues(t)}function Pr(t,e,r){var n=this,i=!1,a=0,o=0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(t){o++,!1===i&&void 0!==n.onStart&&n.onStart(t,a,o),i=!0},this.itemEnd=function(t){a++,void 0!==n.onProgress&&n.onProgress(t,a,o),a===o&&(i=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)}}function Ir(t){this.manager=void 0!==t?t:ph}function Or(t){this.manager=void 0!==t?t:ph,this._parser=null}function Nr(t){this.manager=void 0!==t?t:ph,this._parser=null}function Dr(t){this.manager=void 0!==t?t:ph}function Ur(t){this.manager=void 0!==t?t:ph}function zr(t){this.manager=void 0!==t?t:ph}function Br(t,e){gt.call(this),this.type="Light",this.color=new c(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function Fr(t,e,r){Br.call(this,t,r),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(gt.DefaultUp),this.updateMatrix(),this.groundColor=new c(e)}function kr(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new h(512,512),this.map=null,this.matrix=new e}function Gr(){kr.call(this,new xt(50,1,.5,500))}function Vr(t,e,r,n,i,a){Br.call(this,t,e),this.type="SpotLight",this.position.copy(gt.DefaultUp),this.updateMatrix(),this.target=new gt,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==r?r:0,this.angle=void 0!==n?n:Math.PI/3,this.penumbra=void 0!==i?i:0,this.decay=void 0!==a?a:1,this.shadow=new Gr}function Hr(t,e,r,n){Br.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==r?r:0,this.decay=void 0!==n?n:1,this.shadow=new kr(new xt(90,1,.5,500))}function jr(){kr.call(this,new yt(-5,5,5,-5,.5,500))}function Wr(t,e){Br.call(this,t,e),this.type="DirectionalLight",this.position.copy(gt.DefaultUp),this.updateMatrix(),this.target=new gt,this.shadow=new jr}function Xr(t,e){Br.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function Yr(t,e,r,n){Br.call(this,t,e),this.type="RectAreaLight",this.position.set(0,1,0),this.updateMatrix(),this.width=void 0!==r?r:10,this.height=void 0!==n?n:10}function qr(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r}function Zr(t,e,r,n){qr.call(this,t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Jr(t,e,r,n){qr.call(this,t,e,r,n)}function Qr(t,e,r,n){qr.call(this,t,e,r,n)}function Kr(t,e,r,n){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=fh.convertArray(e,this.TimeBufferType),this.values=fh.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function $r(t,e,r,n){Kr.call(this,t,e,r,n)}function tn(t,e,r,n){qr.call(this,t,e,r,n)}function en(t,e,r,n){Kr.call(this,t,e,r,n)}function rn(t,e,r,n){Kr.call(this,t,e,r,n)}function nn(t,e,r,n){Kr.call(this,t,e,r,n)}function an(t,e,r){Kr.call(this,t,e,r)}function on(t,e,r,n){Kr.call(this,t,e,r,n)}function sn(t,e,r,n){Kr.apply(this,arguments)}function cn(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=Ko.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function ln(t){this.manager=void 0!==t?t:ph,this.textures={}}function hn(t){this.manager=void 0!==t?t:ph}function un(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function dn(t){"boolean"==typeof t&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),t=void 0),this.manager=void 0!==t?t:ph,this.withCredentials=!1}function pn(t){this.manager=void 0!==t?t:ph,this.texturePath=""}function fn(t,e,r,n,i){var a=.5*(n-e),o=.5*(i-r),s=t*t;return(2*r-2*n+a+o)*(t*s)+(-3*r+3*n-2*a-o)*s+a*t+r}function mn(t,e){var r=1-t;return r*r*e}function gn(t,e){return 2*(1-t)*t*e}function vn(t,e){return t*t*e}function yn(t,e,r,n){return mn(t,e)+gn(t,r)+vn(t,n)}function xn(t,e){var r=1-t;return r*r*r*e}function bn(t,e){var r=1-t;return 3*r*r*t*e}function wn(t,e){return 3*(1-t)*t*t*e}function _n(t,e){return t*t*t*e}function Mn(t,e,r,n,i){return xn(t,e)+bn(t,r)+wn(t,n)+_n(t,i)}function En(){this.arcLengthDivisions=200}function Sn(t,e){En.call(this),this.v1=t,this.v2=e}function Tn(){En.call(this),this.curves=[],this.autoClose=!1}function An(t,e,r,n,i,a,o,s){En.call(this),this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s||0}function Ln(t){En.call(this),this.points=void 0===t?[]:t}function Cn(t,e,r,n){En.call(this),this.v0=t,this.v1=e,this.v2=r,this.v3=n}function Rn(t,e,r){En.call(this),this.v0=t,this.v1=e,this.v2=r}function Pn(t){Tn.call(this),this.currentPoint=new h,t&&this.fromPoints(t)}function In(){Pn.apply(this,arguments),this.holes=[]}function On(){this.subPaths=[],this.currentPath=null}function Nn(t){this.data=t}function Dn(t){this.manager=void 0!==t?t:ph}function Un(t){this.manager=void 0!==t?t:ph}function zn(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new xt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new xt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function Bn(){gt.call(this),this.type="AudioListener",this.context=_h.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Fn(t){gt.call(this),this.type="Audio",this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function kn(t){Fn.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function Gn(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function Vn(t,e,r){this.binding=t,this.valueSize=r;var n,i=Float64Array;switch(e){case"quaternion":n=this._slerp;break;case"string":case"bool":i=Array,n=this._select;break;default:n=this._lerp}this.buffer=new i(4*r),this._mixBufferRegion=n,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function Hn(t,e,r){var n=r||jn.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}function jn(t,e,r){this.path=e,this.parsedPath=r||jn.parseTrackName(e),this.node=jn.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Wn(t){this.uuid=Ko.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var r=0,n=arguments.length;r!==n;++r)e[arguments[r].uuid]=r;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var i=this;this.stats={objects:{get total(){return i._objects.length},get inUse(){return this.total-i.nCachedObjects_}},get bindingsPerObject(){return i._bindings.length}}}function Xn(t,e,r){this._mixer=t,this._clip=e,this._localRoot=r||null;for(var n=e.tracks,i=n.length,a=new Array(i),o={endingStart:Il,endingEnd:Il},s=0;s!==i;++s){var c=n[s].createInterpolant(null);a[s]=c,c.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Pl,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function Yn(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function qn(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Zn(){Ct.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Jn(t,e,r,n){this.uuid=Ko.generateUUID(),this.data=t,this.itemSize=e,this.offset=r,this.normalized=!0===n}function Qn(t,e){this.uuid=Ko.generateUUID(),this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function Kn(t,e,r){Qn.call(this,t,e),this.meshPerAttribute=r||1}function $n(t,e,r){Mt.call(this,t,e),this.meshPerAttribute=r||1}function ti(t,e,r,n){this.ray=new Dt(t,e),this.near=r||0,this.far=n||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function ei(t,e){return t.distance-e.distance}function ri(t,e,r,n){if(!1!==t.visible&&(t.raycast(e,r),!0===n))for(var i=t.children,a=0,o=i.length;a<o;a++)ri(i[a],e,r,!0)}function ni(t){this.autoStart=void 0===t||t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}function ii(t,e,r){return this.radius=void 0!==t?t:1,this.phi=void 0!==e?e:0,this.theta=void 0!==r?r:0,this}function ai(t,e,r){return this.radius=void 0!==t?t:1,this.theta=void 0!==e?e:0,this.y=void 0!==r?r:0,this}function oi(t,e,r,n){this.object=t,this.size=void 0!==e?e:1;var i=void 0!==r?r:16711680,a=void 0!==n?n:1,o=0,s=this.object.geometry;s&&s.isGeometry?o=3*s.faces.length:s&&s.isBufferGeometry&&(o=s.attributes.normal.count);var c=new Ct,l=new Tt(2*o*3,3);c.addAttribute("position",l),Pe.call(this,c,new Ce({color:i,linewidth:a})),this.matrixAutoUpdate=!1,this.update()}function si(t){var e=[];t&&t.isBone&&e.push(t);for(var r=0;r<t.children.length;r++)e.push.apply(e,si(t.children[r]));return e}function ci(t){for(var e=si(t),r=new Ct,n=[],i=[],a=new c(0,0,1),o=new c(0,1,0),s=0;s<e.length;s++){var l=e[s];l.parent&&l.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),i.push(a.r,a.g,a.b),i.push(o.r,o.g,o.b))}r.addAttribute("position",new Tt(n,3)),r.addAttribute("color",new Tt(i,3));var h=new Ce({vertexColors:rc,depthTest:!1,depthWrite:!1,transparent:!0});Pe.call(this,r,h),this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.onBeforeRender()}function li(t,e){gt.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;var r=new Xe(e);r.rotateY(.5*Math.PI);var n=new Nt({vertexColors:rc,wireframe:!0}),i=r.getAttribute("position"),a=new Float32Array(3*i.count);r.addAttribute("color",new Mt(a,3)),this.add(new Bt(r,n)),this.update()}function hi(t,e,r,n){this.object=t,this.size=void 0!==e?e:1;var i=void 0!==r?r:16776960,a=void 0!==n?n:1,o=0,s=this.object.geometry;s&&s.isGeometry?o=s.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");var c=new Ct,l=new Tt(2*o*3,3);c.addAttribute("position",l),Pe.call(this,c,new Ce({color:i,linewidth:a})),this.matrixAutoUpdate=!1,this.update()}function ui(t){function e(t,e,n){r(t,n),r(e,n)}function r(t,e){a.push(0,0,0),o.push(e.r,e.g,e.b),void 0===s[t]&&(s[t]=[]),s[t].push(a.length/3-1)}var n=new Ct,i=new Ce({color:16777215,vertexColors:ec}),a=[],o=[],s={},l=new c(16755200),h=new c(16711680),u=new c(43775),d=new c(16777215),p=new c(3355443);e("n1","n2",l),e("n2","n4",l),e("n4","n3",l),e("n3","n1",l),e("f1","f2",l),e("f2","f4",l),e("f4","f3",l),e("f3","f1",l),e("n1","f1",l),e("n2","f2",l),e("n3","f3",l),e("n4","f4",l),e("p","n1",h),e("p","n2",h),e("p","n3",h),e("p","n4",h),e("u1","u2",u),e("u2","u3",u),e("u3","u1",u),e("c","t",d),e("p","c",p),e("cn1","cn2",p),e("cn3","cn4",p),e("cf1","cf2",p),e("cf3","cf4",p),n.addAttribute("position",new Tt(a,3)),n.addAttribute("color",new Tt(o,3)),Pe.call(this,n,i),this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}function di(){function t(t,a,o,s){e=t,r=o,n=-3*t+3*a-2*o-s,i=2*t-2*a+o+s}var e=0,r=0,n=0,i=0;return{initCatmullRom:function(e,r,n,i,a){t(r,n,a*(n-e),a*(i-r))},initNonuniformCatmullRom:function(e,r,n,i,a,o,s){var c=(r-e)/a-(n-e)/(a+o)+(n-r)/o,l=(n-r)/o-(i-r)/(o+s)+(i-n)/s;t(r,n,c*=o,l*=o)},calc:function(t){var a=t*t;return e+r*t+n*a+i*(a*t)}}}function pi(t){En.call(this),t.length<2&&console.warn("THREE.CatmullRomCurve3: Points array needs at least two entries."),this.points=t||[],this.closed=!1}function fi(t,e,r,n){En.call(this),this.v0=t,this.v1=e,this.v2=r,this.v3=n}function mi(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),pi.call(this,t),this.type="catmullrom"}function gi(t){var e=s.stdWidth,r=s.stdMargin;De.call(this),this.name="CV.AHI",this.domObjects=[],this.lastPitch=0;var i=new De,a=new vr(.9*e,e,3,32,1,!0);a.rotateX(Math.PI/2);var o,c=new cr(e-10,31,31),l=new _t,h=new _t,u=c.getAttribute("position").count,d=new Mt(new Float32Array(3*u),3),p=[],f=Yl.hudBlue,m=Yl.hudRed;for(o=0;o<u;o++)p.push(o<u/2?f:m);c.addAttribute("color",d.copyColorsArray(p)),l.vertices.push(new n(4-e,0,e)),l.vertices.push(new n(e-4,0,e));var g=new n(4,0,e-10),v=new n(-4,0,e-10),y=new n(1,0,0);for(o=0;o<12;o++){var x=g.clone(),b=v.clone();o%3==0&&(x.x=7,b.x=-7),x.applyAxisAngle(y,o*Math.PI/6),b.applyAxisAngle(y,o*Math.PI/6),h.vertices.push(x),h.vertices.push(b)}var w=new Bt(a,new Tr({color:8947848,specular:8947848})),_=new Bt(c,new Tr({vertexColors:rc,specular:6710886,shininess:20})),M=new Pe(l,new Ce({color:13421568})),E=new Pe(h,new Ce({color:16777215}));_.rotateOnAxis(new n(0,1,0),Math.PI/2),E.rotateOnAxis(new n(1,0,0),Math.PI/2),w.rotateOnAxis(new n(0,0,1),Math.PI/8),i.add(_),i.add(E),this.add(w),this.add(i),this.add(M);var S=e+r;this.translateX(-3*S),this.translateY(S);var T=document.createElement("div");return T.classList.add("cv-ahi"),T.textContent="",t.appendChild(T),this.globe=i,this.txt=T,this.domObjects.push(T),this.addEventListener("removed",this.removeDomObjects),this.txt.textContent="-90°",this}function vi(t){var e,r,i=t.clientWidth,a=t.clientHeight,o=s.stdWidth,c=s.stdMargin,l=new lr(1,40,36,1,Math.PI,Math.PI),h=[],u=new n(1,0,0),d=Yl.getColors("inclination"),p=l.vertices,f=new n;for(e=0,r=p.length;e<r;e++){f.copy(p[e]).normalize();var m=f.dot(u),g=Math.floor(254*Math.asin(Math.abs(m))/Math.PI);h[e]=d[g]}var v,y=l.faces;for(e=0,r=y.length;e<r;e++)(v=y[e]).vertexColors=[h[v.a],h[v.b],h[v.c]];l.colorsNeedUpdate=!0,Bt.call(this,l,new Nt({color:16777215,vertexColors:rc,side:Zs})),this.translateY(-a/2+3*(o+c)+c+30),this.translateX(i/2-40-5),this.name="CV.AngleScale",this.domObjects=[];var x=document.createElement("div");return x.id="angle-legend",x.textContent="Inclination",t.appendChild(x),this.txt=x,this.domObjects.push(x),this.addEventListener("removed",this.removeDomObjects),this}function yi(t){function e(t,e,r,i){var a=t*e,o=new _t;o.vertices.push(new n(0,t,0)),o.vertices.push(new n(a,a,0)),o.vertices.push(new n(0,0,14*e)),o.vertices.push(new n(-a,a,0));var s=new bt(0,2,1,new n(0,0,1),r,0),c=new bt(0,3,2,new n(0,0,1),i,0);return o.faces.push(s),o.faces.push(c),o}function r(t,r,n,i){var a=e(t,r,new c(n),new c(i)),o=a.clone(),s=a.clone(),l=a.clone();return o.rotateZ(Math.PI/2),s.rotateZ(Math.PI),l.rotateZ(Math.PI/2*3),a.merge(o),a.merge(s),a.merge(l),a.computeFaceNormals(),a}var i=s.stdWidth,a=s.stdMargin;De.call(this),this.name="CV.Compass",this.domObjects=[];var o=new vr(.9*i,i,3,32,1,!0);o.rotateX(Math.PI/2);var l=new Bt(o,new Tr({color:8947848,specular:8947848})),h=new lr(.9*i,i,4,1,-Math.PI/32+Math.PI/2,Math.PI/16);h.translate(0,0,5);var u=new Bt(h,new Nt({color:11549204})),d=r(.8*i,.141,5774602,807786),p=r(.9*i,.141,11549204,1750245);d.rotateZ(Math.PI/4),d.merge(p);var f=new Bt(d,new Cr({vertexColors:rc,side:Zs,shading:Ks}));this.add(l),this.add(u),this.add(f);var m=i+a;this.translateX(-m),this.translateY(m),this.lastRotation=0;var g=document.createElement("div");return g.classList.add("cv-compass"),g.textContent="",t.appendChild(g),this.txt=g,this.domObjects.push(g),this.addEventListener("removed",this.removeDomObjects),this.txt.textContent="000°",this}function xi(t,e){function r(){this.uniforms.surfaceOpacity.value=this.opacity}return at.call(this),this.halfRange=(e.max.z-e.min.z)/2,this.defines=t===ts?{USE_COLOR:!0}:{SURFACE:!0},this.uniforms={uLight:{value:new n(-1,-1,2)},cursor:{value:0},cursorWidth:{value:5},baseColor:{value:Yl.lightGrey},cursorColor:{value:Yl.green}},this.vertexShader=Ah.cursorVertexShader,this.fragmentShader=Ah.cursorFragmentShader,this.type="CV.CursorMaterial",this.addEventListener("update",r),this}function bi(t,e,r){var i=r.boundingBox,a=i.getSize(),o=t===ts?{USE_COLOR:!0}:{SURFACE:!0};return at.call(this,{uniforms:{uLight:{value:new n(-1,-1,2)},minX:{value:i.min.x},minY:{value:i.min.y},minZ:{value:i.min.z},scaleX:{value:1/a.x},scaleY:{value:1/a.y},rangeZ:{value:a.z},depthScale:{value:1/(e.max.z-e.min.z)},cmap:{value:Yl.getTexture("gradient")},depthMap:{value:r.depthTexture},datumShift:{value:0}},defines:o,vertexShader:Ah.depthVertexShader,fragmentShader:Ah.depthFragmentShader}),this.type="CV.DepthMaterial",this}function wi(t,e,r){var i=r.boundingBox,a=i.getSize();return this.max=e.max.z-e.min.z,at.call(this,{uniforms:{uLight:{value:new n(-1,-1,2)},minX:{value:i.min.x},minY:{value:i.min.y},minZ:{value:i.min.z},scaleX:{value:1/a.x},scaleY:{value:1/a.y},rangeZ:{value:a.z},depthMap:{value:r.depthTexture},datumShift:{value:0},cursor:{value:this.max/2},cursorWidth:{value:5},baseColor:{value:Yl.lightGrey},cursorColor:{value:Yl.green}},vertexShader:Ah.depthCursorVertexShader,fragmentShader:Ah.depthCursorFragmentShader}),this.defines={},t===ts?this.defines.USE_COLOR=!0:this.defines.SURFACE=!0,this.type="CV.DepthCursorMaterial",this}function _i(t){void 0===t.boundingBox&&t.computeBoundingBox();var e=t.boundingBox,r=e.min.z,n=e.max.z;return at.call(this,{uniforms:{minZ:{value:r},scaleZ:{value:1/(n-r)}},vertexShader:Ah.depthMapVertexShader,fragmentShader:Ah.depthMapFragmentShader,depthWrite:!1,type:"CV.DepthMapMaterial"}),this}function Mi(t,e){return at.call(this),this.defines=t===ts?{USE_COLOR:!0}:{SURFACE:!0},this.uniforms={uLight:{value:new n(-1,-1,2)},minZ:{value:e.min.z},scaleZ:{value:1/(e.max.z-e.min.z)},cmap:{value:Yl.getTexture("gradient")}},this.vertexShader=Ah.heightVertexShader,this.fragmentShader=Ah.heightFragmentShader,this.type="CV.HeightMaterial",this}function Ei(t){var e=document.createElement("canvas"),r={};e||console.error("creating canvas for glyph atlas failed"),e.width=512,e.height=512;var n=e.getContext("2d");n||console.error("cannot obtain 2D canvas"),n.fillStyle="rgba( 0, 0, 0, 1 )",n.fillRect(0,0,512,512);var i="☐ ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_",a=i.length;if(a>256)return void console.error("too many glyphs for atlas");var o;n.textAlign="left",n.font="20px "+t,n.fillStyle="#ffffff";for(var s,c,l=0;l<a;l++){o=i.charAt(l);var h=n.measureText(o).width/32;s=Math.floor(l/16)+1,c=l%16,r[o]={row:(16-s)/16,column:c/16,width:h},n.fillText(o,32*c,32*s-6)}this.texture=new ze(e),this.map=r,this.cellScale=.0625}function Si(t,e,r,n){function i(){h.uniforms.scale.value=e.clientHeight/e.clientWidth}var a=Ch.getAtlas(t),o=a.getCellScale(),s=Math.cos(r),c=Math.sin(r),l=new Float32Array([s,c,-c,s]);n=n||[1,1,1],at.call(this,{uniforms:{cellScale:{value:o},atlas:{value:a.getTexture()},rotate:{value:l},scale:{value:e.clientHeight/e.clientWidth}},vertexShader:Ah.glyphVertexShader,fragmentShader:Ah.glyphFragmentShader}),this.opacity=1,this.alphaTest=.8,this.depthTest=!1,this.transparent=!0,this.defines={USE_COLOR:!0},this.defaultAttributeValues.color=n,this.type="CV.GlyphMaterial",this.atlas=a,window.addEventListener("resize",i);var h=this;return this}function Ti(t){Rh.initCursorHeight=t.setCursor(Rh.cursorHeight)}function Ai(){Ih.forEach(Ti)}function Li(t){function e(t){t.setDatumShift(r)}var r=t.value;Oh.forEach(e)}function Ci(t,e){var r="height"+t;if(Ph.has(r))return Ph.get(r);var n=new Mi(t,e);return Ph.set(r,n),Nh[r]=n,n}function Ri(t){return new _i(t)}function Pi(t,e,r){var n="depth"+t,i=Ph.get(n);return void 0===i&&(i=new bi(t,e,r),Ph.set(n,i),Nh[n]=i,Oh.push(i)),i}function Ii(t,e){var r="cursor"+t,n=Ph.get(r);return void 0===n&&(n=new xi(t,e),Nh[r]=n,Ph.set(r,n)),Rh.initCursorHeight=n.getCursor(),Ih[t]=n,n}function Oi(t,e,r){var n="depthCursor"+t,i=Ph.get(n);return void 0===i&&(i=new wi(t,e,r),Nh[n]=i,Oh.push(i),Ph.set(n,i)),Rh.initCursorHeight=i.getCursor(),Ih[t]=i,i}function Ni(){if(Ph.has("surface"))return Ph.get("surface");var t=new Cr({color:16777215,vertexColors:tc});return Ph.set("surface",t),t}function Di(){if(Ph.has("line"))return Ph.get("line");var t=new Ce({color:16777215,vertexColors:rc});return Ph.set("line",t),t}function Ui(t,e,r){var n=t+":"+e.toString()+":"+(r?r.toString():"default");if(Ph.has(n))return Ph.get(n);var i=new Si(t,Rh.container,e,r);return Ph.set(n,i),i}function zi(t){t.addEventListener("datumShiftChange",Li)}function Bi(t){Ph.clear(),(Rh=t).addEventListener("cursorChange",Ai)}function Fi(){var t;for(t in Nh)Nh[t].dispose(),Ph.delete(t);Oh=[],Nh={}}function ki(t,r){var i=t.clientWidth,a=t.clientHeight,o=s.stdWidth,c=s.stdMargin;this.name="CV.LinearScale",this.domObjects=[];var l=3*(o+c),h=(a-l)/2,u=o/2,d=r.maxHeight-r.minHeight,p=new Ot(u,d);p.rotateX(Math.PI/2),p.translate(-u/2,0,0),Bt.call(this,p,Dh.getHeightMaterial(ts));var f=(new e).makeScale(1,1,h/d);f.multiply((new e).makeTranslation(i/2-c,-a/2+l+h/2,0)),this.applyMatrix(f),this.rotateOnAxis(new n(1,0,0),-Math.PI/2);var m=document.createElement("div"),g=document.createElement("div"),v=document.createElement("div");return m.classList.add("linear-scale"),g.classList.add("linear-scale"),v.classList.add("linear-scale-caption"),m.id="max-div",g.id="min-div",v.id="linear-caption",m.style.top=h+"px",g.style.bottom=l+"px",v.style.bottom=a-h+"px",t.appendChild(m),t.appendChild(g),t.appendChild(v),m.textContent="---",g.textContent="---",v.textContent="xxxx",this.maxDiv=m,this.minDiv=g,this.caption=v,this.domObjects.push(g),this.domObjects.push(m),this.domObjects.push(v),this.addEventListener("removed",this.removeDomObjects),this}function Gi(t){var e=t.clientWidth,r=t.clientHeight,i=s.stdWidth,a=s.stdMargin;this.name="CV.CursorScale",this.domObjects=[];var o=3*(i+a),c=(r-o)/2,l=i/2,h=new Ot(l,c);Bt.call(this,h,new Nt({color:7829367})),this.translateX(e/2-l/2-a),this.translateY(-r/2+c/2+o),this.barHeight=c;var u=new _t;u.vertices.push(new n(l/2,-c/2,0)),u.vertices.push(new n(-l/2,-c/2,0));var d=new Re(u,new Ce({color:16777215}));this.add(d),this.cursor=d;var p=document.createElement("div"),f=document.createElement("div"),m=document.createElement("div");return p.classList.add("linear-scale"),f.classList.add("linear-scale"),m.classList.add("linear-scale-caption"),p.id="max-div",f.id="min-div",m.id="linear-caption",p.style.top=c+"px",f.style.bottom=o+"px",m.style.bottom=r-c+"px",t.appendChild(p),t.appendChild(f),t.appendChild(m),p.textContent="---",f.textContent="---",m.textContent="xxxx",this.maxDiv=p,this.minDiv=f,this.caption=m,this.domObjects.push(f),this.domObjects.push(p),this.domObjects.push(m),this.addEventListener("removed",this.removeDomObjects),this}function Vi(){var t=s.stdWidth,e=s.stdMargin,r=new lr(.9*t,t,50);Bt.call(this,r,new Nt({color:16777215,vertexColors:ec})),this.name="CV.ProgressDial",this.domObjects=[];var n=t+e;return this.translateX(5*-n),this.translateY(n),this.rotateOnAxis(zs,Math.PI/2),this.visible=!1,this.isVisible=!0,this.addEventListener("removed",this.removeDomObjects),this}function Hi(t,e,r){De.call(this),this.name="CV.ScaleBar",this.domObjects=[],this.hScale=e,this.scaleBars=[],this.currentLength=0,this.position.set(-t.clientWidth/2+5,-t.clientHeight/2+10,0),this.scaleMax=t.clientWidth-(10+r);var n=document.createElement("div");return n.classList.add("scale-legend"),n.textContent="",t.appendChild(n),this.legend=n,this.domObjects.push(n),this.addEventListener("removed",this.removeDomObjects),this}function ji(t,e){Hh=document.getElementById(t),Uh=e;var r=Hh.clientHeight/2,n=Hh.clientWidth/2;(zh=new yt(-n,n,r,-r,1,1e3)).position.z=600,Bh=new we,(Fh=new De).position.set(n,-r,0),Bh.add(Fh);var i=new Xr(8947848),a=new Wr(16777215);a.position.set(-1,1,1),Bh.add(i),Bh.add(a),kh=new yi(Hh),Gh=new gi(Hh),Vh=new Vi,Fh.add(kh),Fh.add(Gh),Fh.add(Vh),window.addEventListener("resize",Zi),ed.addEventListener("newCave",Ki),ed.addEventListener("change",ta),(jh=ed.getControls()).addEventListener("change",Ji)}function Wi(t){kh.setVisibility(t),Gh.setVisibility(t),Vh.setVisibility(t),Zh&&Zh.setVisibility(t),Jh=t,Xh&&(t?ta({type:"change",name:"shadingMode"}):(Xh.setVisibility(!1),qh.setVisibility(!1),Yh.setVisibility(!1))),ed.renderView()}function Xi(){return Jh}function Yi(){return Vh}function qi(t){Wh=t}function Zi(){var t=Hh.clientWidth/2,e=Hh.clientHeight/2;zh.left=-t,zh.right=t,zh.top=e,zh.bottom=-e,zh.updateProjectionMatrix(),Fh.position.set(t,-e,0),$i(),Wi(Jh)}function Ji(){var t=jh.object;kh.set(t),Gh.set(t),ra(t)}function Qi(){Uh.clearDepth(),Uh.render(Bh,zh)}function Ki(){$i(),ta({type:"change",name:"shadingMode"})}function $i(){Xh&&Bh.remove(Xh),Xh=new ki(Hh,ed),Bh.add(Xh),qh&&Bh.remove(qh),qh=new Gi(Hh),Bh.add(qh),Yh&&Bh.remove(Yh),Yh=new vi(Hh),Bh.add(Yh),Zh&&(Bh.remove(Zh),Zh=null),ra(jh.object)}function ta(t){if("shadingMode"===t.name&&Jh){var e=!1,r=!1,n=!1;switch(ed.shadingMode){case ds:r=!0,Xh.setRange(ed.minHeight,ed.maxHeight,"Height above Datum").setMaterial(Dh.getHeightMaterial(ts));break;case bs:r=!0,Xh.setRange(ed.maxHeight-ed.minHeight,0,"Depth below surface").setMaterial(Dh.getHeightMaterial(ts));break;case ms:n=!0,qh.setRange(ed.minHeight,ed.maxHeight,"Height"),ea();break;case _s:n=!0,qh.setRange(ed.maxHeight-ed.minHeight,0,"Depth"),ea();break;case ps:r=!0,Xh.setRange(ed.minLegLength,ed.maxLegLength,"Leg length").setMaterial(Dh.getHeightMaterial(ts,!0)).setVisibility(!0);break;case fs:e=!0}Yh.setVisibility(e),Xh.setVisibility(r),qh.setVisibility(n),n?ed.addEventListener("cursorChange",ea):ed.removeEventListener("cursorChange",ea),ed.renderView()}}function ea(){var t=ed.cursorHeight,e=ed.maxHeight-ed.minHeight,r=0;r=ed.shadingMode===ms?(ed.cursorHeight+e/2)/e:1-t/e,r=Math.max(Math.min(r,1),0),qh.setCursor(r,Math.round(t))}function ra(t){t instanceof yt?(null===Zh&&(Zh=new Hi(Hh,Wh,4*(s.stdWidth+s.stdMargin)),Bh.add(Zh)),Jh!==Zh.visible&&Zh.setVisibility(Jh),Zh.setScale(t.zoom)):null!==Zh&&Zh.visible&&Zh.setVisibility(!1)}function na(t,e,r){this.cameraTarget=null,this.targetPOI=null,this.controls=t,this.renderFunction=e,this.endCallback=r,this.frameCount=0,this.frames=0,this.targetZoom=1,this.curve=null,this.skipNext=!1,this.moveRequired=!1}function ia(t,e,r,n){void 0===r?(this.id=0,this.maxId=0,this.root=this,this.parent=null):(this.root=r,this.parent=n,this.id=null===e?++r.maxId:e),this.name=t||"",this.children=[]}function aa(t,e){this.box3=t,void 0===e&&(e=16776960);var r=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),i=new Ct;i.setIndex(new Mt(r,1)),i.addAttribute("position",new Mt(n,3)),Pe.call(this,i,new Ce({color:e})),this.matrixAutoUpdate=!1,this.update(t)}function oa(t,e){Zn.call(this),this.type="GlyphStringGeometry",this.name=t,this.width=0;var r=new Et([0,2,1,0,3,2],1),n=new Tt([0,0,0,0,1,0,1,1,0,1,0,0],3);this.setIndex(r),this.addAttribute("position",n);var i,a,o,s=0;a=t.length;var c=new Float32Array(2*a),l=new Float32Array(a),h=new Float32Array(a);for(i=0;i<a;i++)0!==t.charCodeAt()&&(o=e.getGlyph(t[i]),c[2*i]=o.column,c[2*i+1]=o.row,l[i]=o.width,h[i]=s,s+=o.width);this.width=s,this.addAttribute("instanceUvs",new $n(c,2,1)),this.addAttribute("instanceOffsets",new $n(h,1,1)),this.addAttribute("instanceWidths",new $n(l,1,1))}function sa(t,e){var r=new oa(t,e.getAtlas());Bt.call(this,r,e),this.type="GlyphString",this.name=t,this.frustumCulled=!1}function ca(t){var e=new Ct;return t=t||new Oe({color:16777215}),e.addAttribute("position",new Tt([0,0,0],3)),Ne.call(this,e,t),this.type="Point",this}function la(t){var e=iu[t];if(void 0!==e)return e;var r=document.createElement("canvas");r||console.error("creating canvas for glyph atlas failed"),r.width=64,r.height=64;var n=r.getContext("2d");n||console.error("cannot obtain 2D canvas"),n.fillStyle="rgba( 0, 0, 0, 0 )",n.fillRect(0,0,64,64);n.textAlign="center",n.font="bold 40px helvetica,sans-serif",n.fillStyle="#ffffff";var i=n.createRadialGradient(32,32,30,32,32,0);return i.addColorStop(0,"rgba( 255, 128, 0, 64 )"),i.addColorStop(.3,"rgba( 255, 200, 0, 255 )"),i.addColorStop(1,"rgba( 255, 255, 0, 255 )"),n.fillStyle=i,n.beginPath(),n.arc(32,32,30,0,2*Math.PI),n.fill(),n.fillStyle="rgba( 0, 0, 0, 255 )",n.fillText(t,32,47),e=new Oe({map:new ze(r),size:32,depthTest:!1,transparent:!0,alphaTest:.8,sizeAttenuation:!1}),iu[t]=e,e}function ha(t){return new ca(la(t))}function ua(t,e,r,i){this.nodes=new Array(4),this.count=0,this.markers=[],this.quadMarker=null,this.centroid=new n,this.xMin=t,this.xMax=e,this.yMin=r,this.yMax=i}function da(t,e){gt.call(this);var r=t.min,n=t.max;return this.maxDepth=e,this.type="CV.ClusterMarker",this.quadTree=new ua(r.x,n.x,r.y,n.y),this.addEventListener("removed",this.onRemoved),this}function pa(){return at.call(this,{uniforms:{diffuse:{value:Yl.white},opacity:{value:1},size:{value:1},scale:{value:1},pScale:{value:1},offsetRepeat:{value:new y},map:{value:null}},vertexShader:Ah.extendedPointsVertexShader,fragmentShader:Ah.extendedPointsFragmentShader,vertexColors:rc}),this.map=(new zr).load(a("home","")+"images/disc.png"),this.color=Yl.white,this.opacity=1,this.alphaTest=.8,this.size=1,this.scale=1,this.sizeAttenuation=!0,this.transparent=!0,this.type="CV.ExtendedPointsMaterial",this.isPointsMaterial=!0,this}function fa(){function t(t){if("splays"===t.name){var e,n=ed.splays?1:0,i=r.stations,a=r.geometry.getAttribute("pSize"),o=i.length;for(e=0;e<o;e++)0===i[e].hitCount&&a.setX(e,n);a.needsUpdate=!0,ed.renderView()}}function e(){ed.removeEventListener("change",t)}Ne.call(this,new Ct,new pa),this.type="CV.Stations",this.map=new Map,this.stationCount=0,this.baseColor=Yl.red,this.junctionColor=Yl.yellow,this.layers.set(Rs),this.pointSizes=[],this.vertices=[],this.colors=[],this.stations=[],this.selected=null,this.selectedSize=0;var r=this;ed.addEventListener("change",t),this.addEventListener("removed",e),Object.defineProperty(this,"count",{get:function(){return this.stations.length}})}function ma(){De.call(this),this.type="CV.StationLabels",this.layers.set(Ns),this.junctionLabelMaterial=Dh.getGlyphMaterial("normal helvetica,sans-serif",0,[1,1,0]),this.defaultLabelMaterial=Dh.getGlyphMaterial("normal helvetica,sans-serif",0),this.splayLabelMaterial=Dh.getGlyphMaterial("normal helvetica,sans-serif",0,[.6,.6,.6])}function ga(t){this.metadataSource=t,this.surveyTree=null,this.vertexPairToSegment=[],this.segmentMap=new Map,this.segmentToInfo={},this.routes=new Map,this.routeNames=[],this.currentRoute=new Set,this.currentRouteName=null,this.adjacentSegments=new Set,Object.defineProperty(this,"setRoute",{set:function(t){this.loadRoute(t)},get:function(){return this.currentRouteName}});var e,r=t.getRoutes(),n=this.routeNames;for(e in r){var i=r[e];n.push(e),this.routes.set(e,i.segments)}n.sort(),this.dispatchEvent({type:"changed",name:"download"})}function va(t){var e=t.state.buffers.stencil,r=t.context;e.setTest(!0),e.setOp(r.KEEP,r.KEEP,r.INCR)}function ya(t){t.state.buffers.stencil.setTest(!1)}function xa(t){var e=new _t;return Pe.call(this,e,ou),this.layers.set(t),this.type="Legs",this.onBeforeRender=va,this.onAfterRender=ya,this}function ba(t){var e=new Ct;return Bt.call(this,e,su),this.layers.set(t),this.type="Walls",this}function wa(){return at.call(this,{uniforms:{offset:{value:0}},vertexShader:Ah.waterVertexShader,fragmentShader:Ah.waterFragmentShader,depthWrite:!1,type:"CV.WaterMaterial",side:Qs}),this}function _a(t,e,r,n,i){i.uniforms.offset.value+=.1}function Ma(){var t=new Ct;return Bt.call(this,t,new wa),this.vertices=[],this.ends=[],this.onBeforeRender=_a,this.layers.set(Ps),this}function Ea(t,e){this.name=t;var r={},n=[];null!==e&&(e.routes&&(r=e.routes),e.traces&&(n=e.traces));var i=localStorage.getItem(t);if(null!==i){var a,o,s=(i=JSON.parse(i)).routes;for(a in s)(o=s[a]).local=!0,r[a]=o}this.routes=r,this.traces=n}function Sa(t){return uu*t[0]+du*t[1]+pu*t[2]+fu*t[3]}function Ta(){De.call(this),this.hasOverlay=!1,this.defaultOverlay=null,this.activeOverlay=null,this.depthTexture=null,this.renderer=null,this.renderTarget=null,this.datumShift=0,this.activeDatumShift=0,this.terrainBase=null,this.terrainRange=null,this.addEventListener("removed",function(){this.removed()})}function Aa(t,e){Ct.call(this),this.type="LoxTerrainGeometry";var r,i,a,o,s,c,l,h=t.data,u=[],d=[],p=1/0,f=-1/0,m=0,g=t.lines,v=t.samples,y=g*v,x=t.xx,b=t.xy,w=t.yx,_=t.yy,M=t.xOrigin-e.x,E=t.yOrigin-e.y,S=-e.z,T=v-1,A=g-1;for(i=0;i<g;i++)for(r=0;r<v;r++)l=h[m++],s=r*x+(A-i)*b+M,c=r*w+(A-i)*_+E,l+=S,d.push(s,c,l),l<p&&(p=l),l>f&&(f=l);var L=T*x+A*b+M,C=T*w+A*_+E;for(this.boundingBox=new st(new n(M,E,p),new n(L,C,f)),i=0;i<A;i++)for(r=0;r<T;r++){var R=r+v*i,P=r+v*(i+1),I=r+1+v*(i+1),O=r+1+v*i;Math.abs(d[3*R+2]-d[3*O+2])<Math.abs(d[3*P+2]-d[3*I+2])?(u.push(R,P,O),u.push(P,I,O)):(u.push(R,P,I),u.push(I,O,R))}this.setIndex(u),this.addAttribute("position",new Tt(d,3)),this.computeVertexNormals();var N,D,U=ks.terrain,z=U.length-1,B=this.getAttribute("normal"),F=new n,k=new Float32Array(3*y),G=[];for(a=0,o=U.length;a<o;a++)D=U[a],G.push([D[0]/255,D[1]/255,D[2]/255]);for(a=0;a<y;a++){F.fromArray(B.array,3*a),N=F.dot(zs),D=G[Math.floor(2*z*Math.acos(Math.abs(N))/Math.PI)];var V=3*a;k[V]=D[0],k[V+1]=D[1],k[V+2]=D[2]}this.addAttribute("color",new Tt(k,3))}function La(t,e){Ta.call(this),this.type="CV.Terrain",this.offsets=e,this.bitmap=t.bitmap,this.overlayMaterial=null;var r=new Bt(new Aa(t.dtm,e),Dh.getSurfaceMaterial());r.layers.set(Cs),r.isTile=!0,r.onBeforeRender=mu.onBeforeRender,r.onAfterRender=mu.onAfterRender,this.tile=r,this.add(r),this.hasOverlay=!!t.bitmap}function Ca(t){this.script=a("home","")+"js/workers/"+t,void 0===Ca.workers[t]&&(Ca.workers[t]=[]),this.workers=Ca.workers[t]}function Ra(t){if(!t)return void alert("failed loading cave information");gt.call(this),this.selectedSectionIds=new Set,this.selectedSection=0,this.selectedBox=null,this.highlightBox=null,this.featureBox=null,this.surveyTree=null,this.projection=null,this.pointTargets=[],this.legTargets=[],this.type="CV.Survey",this.cutInProgress=!1,this.terrain=null,this.isRegion=t.isRegion,this.features=[],this.routes=null,this.stations=null,this.workerPool=new Ca("caveWorker.js"),this.inverseWorld=null;var e=new ca(new Oe({size:32,map:(new zr).load(a("home","")+"images/ic_location.png"),transparent:!0,sizeAttenuation:!1,alphaTest:.8}));e.visible=!1,this.add(e),this.stationHighlight=e;var r=this;hu.clearMap();var i=t.getSurvey();if(this.name=i.title,this.CRS=null===i.sourceCRS?a("CRS","fred"):i.sourceCRS,!0===this.isRegion)this.surveyTree=i.surveyTree,this.limits=t.getLimits();else{var o=i.limits;this.limits=new st((new n).copy(o.min),(new n).copy(o.max)),this.offsets=i.offsets;var s=(new st).copy(this.limits);s.min.sub(this.offsets),s.max.sub(this.offsets),this.modelLimits=s,this.loadCave(i),this.legTargets=[this.features[Ms]]}this.loadEntrances(),this.setFeatureBox(),function(){if(null===i.sourceCRS||null===i.targetCRS)return void(r.scaleFactor=1);var t=r.limits,e=t.min.clone(),n=t.max.clone();e.z=0,n.z=0;var a=e.distanceTo(n),o=proj4(i.targetCRS,i.sourceCRS);e.copy(o.forward(e)),n.copy(o.forward(n)),r.projection=o;var s=e.distanceTo(n);r.scaleFactor=a/s}(),this.addEventListener("removed",this.onRemoved)}function Pa(t){this.div=document.createElement("div"),this.div.classList.add(t)}function Ia(t,e,r){Pa.call(this,"station-info");for(var n,i=t.getPath(),a=!1;i.length>20;)(n=i.split(".")).shift(),i=n.join("."),a=!0;a&&(i="..."+i),this.addLine(i),this.addLine("x: "+e.x+" m").addLine("y: "+e.y+" m").addLine("z: "+e.z+" m"),null!==r&&this.addLine("depth from surface: "+Math.round(r)+" m")}function Oa(){this.array=null}function Na(t,e,r,n,i){return this.x=t,this.y=e,this.zoom=r,this.tileSet=n,this.clip=i,this.canZoom=!0,this.evicted=!1,this.replaced=!1,this.evictionCount=1,this.resurrectionPending=!1,this.childrenLoading=0,this.childErrors=0,this.boundingBox=null,this.worldBoundingBox=null,Bt.call(this,new Ct,Dh.getSurfaceMaterial()),this.onBeforeRender=mu.onBeforeRender,this.onAfterRender=mu.onAfterRender,this}function Da(t,e,r){function n(t){s.tileSets=JSON.parse(t),e()}function i(){e()}Ta.call(this),this.name="WebTerrain",this.type="CV.WebTerrain";var o=t.limits;this.limits=new et(new h(o.min.x,o.min.y),new h(o.max.x,o.max.y)),this.offsets=t.offsets,this.onLoaded=r,this.childrenLoading=0,this.childErrors=0,this.terrainLoaded=!1,this.material=null,this.initialZoom=null,this.currentZoom=null,this.currentLimits=null,this.dying=!1,this.overlaysLoading=0,this.debug=!0,this.workerPool=new Ca("webTileWorker.js"),void 0!==Qh&&(this.progressDial=Qh.getProgressDial());var s=this;(new Ir).setResponseType("text").load(a("terrainDirectory","")+"/tileSets.json",n,function(){},i)}function Ua(t,e){this.provider=t,this.container=e;var r=t.getAttribution();r&&(r.classList.add("overlay-branding"),this.attribution=r),this.materialCache={}}function za(t,e){function i(){return 2*Math.PI/60/60*U.autoRotateSpeed}function a(){return Math.pow(.95,U.zoomSpeed)}function o(t){j.theta-=t}function s(t){j.phi-=t}function c(t){U.object instanceof xt?W/=t:U.object instanceof yt?(U.object.zoom=Math.max(U.minZoom,Math.min(U.maxZoom,U.object.zoom*t)),U.object.updateProjectionMatrix(),Y=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),U.enableZoom=!1)}function l(t){U.object instanceof xt?W*=t:U.object instanceof yt?(U.object.zoom=Math.max(U.minZoom,Math.min(U.maxZoom,U.object.zoom/t)),U.object.updateProjectionMatrix(),Y=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),U.enableZoom=!1)}function u(t){q.set(t.clientX,t.clientY)}function d(t){tt.set(t.clientX,t.clientY)}function p(t){Q.set(t.clientX,t.clientY)}function f(t){Z.set(t.clientX,t.clientY),J.subVectors(Z,q);var e=U.domElement===document?U.domElement.body:U.domElement;o(2*Math.PI*J.x/e.clientWidth*U.rotateSpeed),s(2*Math.PI*J.y/e.clientHeight*U.rotateSpeed),q.copy(Z),U.update()}function m(t){et.set(t.clientX,t.clientY),rt.subVectors(et,tt),rt.y>0?c(a()):rt.y<0&&l(a()),tt.copy(et),U.update()}function g(t){K.set(t.clientX,t.clientY),$.subVectors(K,Q),at($.x,$.y),Q.copy(K),U.update()}function v(t){}function y(t){t.deltaY<0?l(a()):t.deltaY>0&&c(a()),U.update()}function x(t){switch(t.keyCode){case U.keys.UP:at(0,U.keyPanSpeed),U.update();break;case U.keys.BOTTOM:at(0,-U.keyPanSpeed),U.update();break;case U.keys.LEFT:at(U.keyPanSpeed,0),U.update();break;case U.keys.RIGHT:at(-U.keyPanSpeed,0),U.update()}}function b(t){q.set(t.touches[0].pageX,t.touches[0].pageY)}function w(t){var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY,n=Math.sqrt(e*e+r*r);tt.set(0,n)}function _(t){Q.set(t.touches[0].pageX,t.touches[0].pageY)}function M(t){Z.set(t.touches[0].pageX,t.touches[0].pageY),J.subVectors(Z,q);var e=U.domElement===document?U.domElement.body:U.domElement;o(2*Math.PI*J.x/e.clientWidth*U.rotateSpeed),s(2*Math.PI*J.y/e.clientHeight*U.rotateSpeed),q.copy(Z),U.update()}function E(t){var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY,n=Math.sqrt(e*e+r*r);et.set(0,n),rt.subVectors(et,tt),rt.y>0?l(a()):rt.y<0&&c(a()),tt.copy(et),U.update()}function S(t){K.set(t.touches[0].pageX,t.touches[0].pageY),$.subVectors(K,Q),at($.x,$.y),Q.copy(K),U.update()}function T(t){}function A(t){if(!1!==U.enabled){if(t.preventDefault(),t.button===U.mouseButtons.ORBIT){if(!1===U.enableRotate)return;u(t),G=k.ROTATE}else if(t.button===U.mouseButtons.ZOOM){if(!1===U.enableZoom)return;d(t),G=k.DOLLY}else if(t.button===U.mouseButtons.PAN){if(!1===U.enablePan)return;p(t),G=k.PAN}G!==k.NONE&&(document.addEventListener("mousemove",L,!1),document.addEventListener("mouseup",C,!1),U.dispatchEvent(B))}}function L(t){if(!1!==U.enabled)if(t.preventDefault(),G===k.ROTATE){if(!1===U.enableRotate)return;f(t)}else if(G===k.DOLLY){if(!1===U.enableZoom)return;m(t)}else if(G===k.PAN){if(!1===U.enablePan)return;g(t)}}function C(t){!1!==U.enabled&&(v(t),document.removeEventListener("mousemove",L,!1),document.removeEventListener("mouseup",C,!1),U.dispatchEvent(F),G=k.NONE)}function R(t){!1===U.enabled||!1===U.enableZoom||G!==k.NONE&&G!==k.ROTATE||(t.preventDefault(),t.stopPropagation(),y(t),U.dispatchEvent(B),U.dispatchEvent(F))}function P(t){!1!==U.enabled&&!1!==U.enableKeys&&!1!==U.enablePan&&x(t)}function I(t){if(!1!==U.enabled){switch(t.touches.length){case 1:if(!1===U.enableRotate)return;b(t),G=k.TOUCH_ROTATE;break;case 2:if(!1===U.enableZoom)return;w(t),G=k.TOUCH_DOLLY;break;case 3:if(!1===U.enablePan)return;_(t),G=k.TOUCH_PAN;break;default:G=k.NONE}G!==k.NONE&&U.dispatchEvent(B)}}function O(t){if(!1!==U.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:if(!1===U.enableRotate)return;if(G!==k.TOUCH_ROTATE)return;M(t);break;case 2:if(!1===U.enableZoom)return;if(G!==k.TOUCH_DOLLY)return;E(t);break;case 3:if(!1===U.enablePan)return;if(G!==k.TOUCH_PAN)return;S(t);break;default:G=k.NONE}}function N(t){!1!==U.enabled&&(T(t),U.dispatchEvent(F),G=k.NONE)}function D(t){t.preventDefault()}this.object=t,this.domElement=void 0!==e?e:document,this.enabled=!0,this.target=new n,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={ORBIT:Vs.LEFT,ZOOM:Vs.MIDDLE,PAN:Vs.RIGHT},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return H.phi},this.getAzimuthalAngle=function(){return H.theta},this.reset=function(){U.target.copy(U.target0),U.object.position.copy(U.position0),U.object.zoom=U.zoom0,U.object.updateProjectionMatrix(),U.dispatchEvent(z),U.update(),G=k.NONE},this.update=function(){var e=new n,a=(new r).setFromUnitVectors(t.up,new n(0,1,0)),s=a.clone().inverse(),c=new n,l=new r;return function(){var t=U.object.position;return e.copy(t).sub(U.target),e.applyQuaternion(a),H.setFromVector3(e),U.autoRotate&&G===k.NONE&&o(i()),H.theta+=j.theta,H.phi+=j.phi,H.theta=Math.max(U.minAzimuthAngle,Math.min(U.maxAzimuthAngle,H.theta)),H.phi=Math.max(U.minPolarAngle,Math.min(U.maxPolarAngle,H.phi)),H.makeSafe(),H.radius*=W,H.radius=Math.max(U.minDistance,Math.min(U.maxDistance,H.radius)),U.target.add(X),e.setFromSpherical(H),e.applyQuaternion(s),t.copy(U.target).add(e),U.object.lookAt(U.target),!0===U.enableDamping?(j.theta*=1-U.dampingFactor,j.phi*=1-U.dampingFactor):j.set(0,0,0),W=1,X.set(0,0,0),!!(Y||c.distanceToSquared(U.object.position)>V||8*(1-l.dot(U.object.quaternion))>V)&&(U.dispatchEvent(z),c.copy(U.object.position),l.copy(U.object.quaternion),Y=!1,!0)}}(),this.dispose=function(){U.domElement.removeEventListener("contextmenu",D,!1),U.domElement.removeEventListener("mousedown",A,!1),U.domElement.removeEventListener("wheel",R,!1),U.domElement.removeEventListener("touchstart",I,!1),U.domElement.removeEventListener("touchend",N,!1),U.domElement.removeEventListener("touchmove",O,!1),document.removeEventListener("mousemove",L,!1),document.removeEventListener("mouseup",C,!1),window.removeEventListener("keydown",P,!1)};var U=this,z={type:"change"},B={type:"start"},F={type:"end"},k={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},G=k.NONE,V=1e-6,H=new ii,j=new ii,W=1,X=new n,Y=!1,q=new h,Z=new h,J=new h,Q=new h,K=new h,$=new h,tt=new h,et=new h,rt=new h,nt=function(){var t=new n;return function(e,r){t.setFromMatrixColumn(r,0),t.multiplyScalar(-e),X.add(t)}}(),it=function(){var t=new n;return function(e,r){t.setFromMatrixColumn(r,1),t.multiplyScalar(e),X.add(t)}}(),at=function(){var t=new n;return function(e,r){var n=U.domElement===document?U.domElement.body:U.domElement;if(U.object instanceof xt){var i=U.object.position;t.copy(i).sub(U.target);var a=t.length();a*=Math.tan(U.object.fov/2*Math.PI/180),nt(2*e*a/n.clientHeight,U.object.matrix),it(2*r*a/n.clientHeight,U.object.matrix)}else U.object instanceof yt?(nt(e*(U.object.right-U.object.left)/U.object.zoom/n.clientWidth,U.object.matrix),it(r*(U.object.top-U.object.bottom)/U.object.zoom/n.clientHeight,U.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),U.enablePan=!1)}}();U.domElement.addEventListener("contextmenu",D,!1),U.domElement.addEventListener("mousedown",A,!1),U.domElement.addEventListener("wheel",R,!1),U.domElement.addEventListener("touchstart",I,!1),U.domElement.addEventListener("touchend",N,!1),U.domElement.addEventListener("touchmove",O,!1),window.addEventListener("keydown",P,!1),this.update()}function Ba(t,e){function r(t,e){Object.defineProperty(ed,e,{writeable:!0,get:function(){return qa(t)},set:function(r){Ya(t,r),this.dispatchEvent({type:"change",name:e})}})}function n(t,e){r(t,e),e="has"+e.substr(0,1).toUpperCase()+e.substr(1),Object.defineProperty(ed,e,{get:function(){return Pu.hasFeature(t)}})}function a(t,e,r){t(isNaN(r)?r:Number(r)),ed.dispatchEvent({type:"change",name:e})}function o(t){switch(Wu=t?us:hs){case hs:Xu=Pu.pointTargets;break;case us:Xu=Pu.legTargets;break;default:console.warn("invalid mouse mode")}}console.log("CaveView v"+$o),(Eu=document.getElementById(t))||alert("No container DOM object ["+t+"] available"),i(e);var s=Eu.clientWidth,c=Eu.clientHeight;(Su=new ye({antialias:!0})).setSize(s,c),Su.setPixelRatio(window.devicePixelRatio),Su.setClearColor(0),Su.autoClear=!1,(Tu=new yt(-s/2,s/2,c/2,-c/2,1,4e3)).rotateOnAxis(zs,Math.PI/2),Xa(Tu),Xa(Au=new xt(75,s/c,1,16e3)),Lu=Au,Hu.add(Au),Hu.add(Tu),(Ru=new Wr(16777215)).position.copy(ku),Hu.add(Ru),Hu.add(new Fr(16777215,65535,.3)),Cu=new ti,Su.clear(),Eu.appendChild(Su.domElement),Bu=new za(Lu,Su.domElement),Fu=new na(Bu,rd,mo),Bu.addEventListener("change",function(){Fu.prepare(null,null),Fu.start(80)}),Bu.enableDamping=!0,window.addEventListener("resize",io),Object.defineProperties(ed,{container:{value:Eu},terrain:{writeable:!0,get:function(){return qa(Cs)},set:function(t){co(t)}},terrainShading:{writeable:!0,get:function(){return Uu},set:function(t){a(Ja,"terrainShading",t)}},hasTerrain:{get:function(){return!!Yu}},terrainDatumShift:{writeable:!0,get:function(){return!!Yu.activeDatumShift},set:function(t){Ha(t)}},terrainOverlays:{get:function(){return Yu.isTiled?Object.keys(Ju):Yu.hasOverlay?[!0]:[]}},terrainOverlay:{writeable:!0,get:function(){return Qu},set:function(t){a($a,"terrainOverlay",t)}},terrainOpacity:{writeable:!0,get:function(){return Yu.getOpacity()},set:function(t){Va(t)}},shadingMode:{writeable:!0,get:function(){return Du},set:function(t){a(Qa,"shadingMode",t)}},surfaceShading:{writeable:!0,get:function(){return Zu},set:function(t){a(Ka,"surfaceShading",t)}},cameraType:{writeable:!0,get:function(){return zu},set:function(t){a(Wa,"cameraType",t)}},view:{writeable:!0,get:function(){return is},set:function(t){a(Za,"view",t)}},cursorHeight:{writeable:!0,get:function(){return Nu},set:function(t){Ga(t)}},initCursorHeight:{writeable:!0,get:function(){return Nu},set:function(t){Nu=t}},maxHeight:{get:function(){return Iu.max.z}},minHeight:{get:function(){return Iu.min.z}},maxLegLength:{get:function(){return qu.maxLegLength}},minLegLength:{get:function(){return qu.minLegLength}},section:{writeable:!0,get:function(){return Ku},set:function(t){a(no,"section",t)}},highlight:{writeable:!0,set:function(t){a(ro,"highlight",t)}},routeEdit:{writeable:!0,get:function(){return Wu===us},set:function(t){o(t),this.dispatchEvent({type:"change",name:"routeEdit"})}},setPOI:{writeable:!0,get:function(){return!0},set:function(t){a(vo,"setPOI",t)}},developerInfo:{writeable:!0,get:function(){return!0},set:function(t){}},HUD:{writeable:!0,get:function(){return Qh.getVisibility()},set:function(t){Qh.setVisibility(t)}},cut:{writeable:!0,get:function(){return!0},set:function(){eo()}},zScale:{writeable:!0,get:function(){return Ou},set:function(t){Fa(t)}},autoRotate:{writeable:!0,get:function(){return Bu.autoRotate},set:function(t){ka(!!t)}},autoRotateSpeed:{writeable:!0,get:function(){return Bu.autoRotateSpeed/11},set:function(t){Bu.autoRotateSpeed=11*t}}}),r(Ts,"box"),n(Ls,"entrances"),n(Rs,"stations"),n(Ps,"traces"),n(Os,"scraps"),n(Is,"walls"),n(Es,"splays"),n(Ss,"surfaceLegs"),n(Ns,"stationLabels"),Dh.initCache(ed),Qh.init(t,Su)}function Fa(t){var r=Math.pow(2,4*(Ou-.5)),n=Math.pow(2,4*(t-.5));Pu.applyMatrix((new e).makeScale(1,1,n/r)),Ou=t,rd()}function ka(t){Bu.autoRotate=t,t?(Fu.prepare(null,null),Fu.start(2952e3)):Fu.stop()}function Ga(t){Nu=t,ed.dispatchEvent({type:"cursorChange",name:"cursorHeight"}),rd()}function Va(t){Yu.setOpacity(t),ed.dispatchEvent({type:"change",name:"terrainOpacity"}),rd()}function Ha(t){Yu.applyDatumShift(t),ed.dispatchEvent({type:"change",name:"terrainDatumShift"}),rd()}function ja(){if(null!==Yu&&Yu.isLoaded()){var t=Eu.clientWidth,e=Eu.clientHeight,r=Iu.getSize(),n=t/r.x,i=e/r.y;n<i?e=e*n/i:t=t*i/n;var a=new yt(-t/2,t/2,e/2,-e/2,-1e4,1e4);a.layers.set(Cs),Hu.overrideMaterial=Dh.getDepthMapMaterial(Yu);var o=new x(512,512,{minFilter:tl,magFilter:Qc,format:vl});o.texture.generateMipmaps=!1,o.texture.name="CV.DepthMapTexture",Dh.setTerrain(Yu),Su.setSize(512,512),Su.setPixelRatio(1),Su.clear(),Su.render(Hu,a,o,!0),Yu.addHeightMap(Su,o),Pu.calibrateTerrain(Yu),Su.setRenderTarget(),Su.setSize(Eu.clientWidth,Eu.clientHeight),Su.setPixelRatio(window.devicePixelRatio),Hu.overrideMaterial=null,rd(),Su.renderLists.dispose()}}function Wa(t){if(t!==zu){var e=Lu.position.clone().sub(Bu.target);switch(t){case rs:e.setLength(ns/Tu.zoom),Lu=Au;break;case es:Tu.zoom=ns/e.length(),e.setLength(2*ns),Lu=Tu;break;default:return void console.warn("unknown camera mode",t)}Lu.position.copy(e.add(Bu.target)),Lu.updateProjectionMatrix(),Lu.lookAt(Bu.target),Bu.object=Lu,zu=t,Qh.update(),rd()}}function Xa(t){t.up=zs,t.zoom=1,t.layers.set(0),t.layers.enable(Ms),t.layers.enable(Ls),t.layers.enable(Ts),t.layers.enable(As),t.position.set(0,0,ns),t.lookAt(0,0,0),t.updateProjectionMatrix()}function Ya(t,e){e?(Tu.layers.enable(t),Au.layers.enable(t)):(Tu.layers.disable(t),Au.layers.disable(t)),rd()}function qa(t){return(Lu.layers.mask&1<<t)>0}function Za(t,e){var r=new n,i=e||240;switch(t){case as:r.set(0,0,ns);break;case os:r.set(0,ns,0);break;case ss:r.set(0,-ns,0);break;case cs:r.set(ns,0,0);break;case ls:r.set(-ns,0,0);break;default:return void console.warn("invalid view mode specified: ",t)}r.add($u),Fu.cancel(),Fu.prepare(r,$u),Fu.start(i)}function Ja(t){Yu.setShadingMode(t,rd)&&(Uu=t),rd()}function Qa(t){(null!==Yu||t!==bs&&t!==_s)&&(Pu.setShadingMode(t)&&(Du=t),rd())}function Ka(t){Pu.setLegShading(Ss,t)&&(Zu=t),rd()}function $a(t){Uu===ys&&(Qu=t,Yu.setOverlay(Ju[t],rd))}function to(t,e){Ju[t]=new Ua(e,Eu),1===Object.keys(Ju).length&&(Qu=t)}function eo(){if(0!==Ku){Pu.remove(Yu),Pu.cutSection(Ku);var t=Pu;ao(),so(t)}}function ro(t){Pu.highlightSelection(t),rd()}function no(t){var e=Pu.selectSection(t);if(Qa(Du),Ku=t,0!==t){if(void 0===e.p){if(void 0===e.boundingBox)return;var r=e.boundingBox.clone();Fu.prepare(null,r.applyMatrix4(Pu.matrixWorld))}else Fu.prepare(null,Pu.getWorldPosition(e.p));rd()}}function io(){var t=Eu.clientWidth,e=Eu.clientHeight;Su.setSize(t,e),void 0!==Tu&&(Tu.left=-t/2,Tu.right=t/2,Tu.top=e/2,Tu.bottom=-e/2,Tu.updateProjectionMatrix(),Au.aspect=t/e,Au.updateProjectionMatrix(),rd())}function ao(){Vu=!1,Su.clear(),Qh.setVisibility(!1),Pu&&(Pu.remove(Yu),Hu.remove(Pu)),Bu.enabled=!1,Pu=null,Yu=null,Ku=0,Wu=hs,Xu=[],Du=ds,Zu=gs,Uu=xs,ho(),Dh.flushCache(),Eu.removeEventListener("mousedown",fo),Xa(Au),Xa(Tu),ed.cameraType=rs,Za(as,1),rd()}function oo(t){if(!t)return void alert("failed loading cave information");so(new Ra(t))}function so(t){function e(){Yu.hasCoverage()?(Ja(Uu),Yu.tileArea(Pu.limits),Yu.setDefaultOverlay(Ju[Qu]),Pu.add(Yu)):Yu=null,ed.dispatchEvent({type:"newCave",name:"newCave"})}function r(){rd(),lo(),null===Yu.depthTexture&&ja()}function n(){Qa(Du),rd()}var i=!1;qu=(Pu=t).getFeature(Ms).stats,yo(Pu),Yu=Pu.terrain,Hu.up=zs,Hu.add(Pu),Vu=!0,no(0),Xu=Pu.pointTargets,Ka(Zu),null===Yu?(Yu=new Da(Pu,e,r,rd),i=!0):(Pu.add(Yu),Ja(Uu),ja()),Hu.matrixAutoUpdate=!1,Eu.addEventListener("mousedown",fo,!1),Qh.setVisibility(!0),i||ed.dispatchEvent({type:"newCave",name:"newCave"}),Bu.object=Lu,Bu.enabled=!0,Pu.getRoutes().addEventListener("changed",n),Za(as,1),rd()}function co(t){Yu.isLoaded()&&(t?lo():ho(),Yu.setVisibility(t),Ya(Cs,t),ed.dispatchEvent({type:"change",name:"terrain"}))}function lo(){uo(),Bu.addEventListener("end",uo)}function ho(){Bu&&(Bu.removeEventListener("end",uo),po())}function uo(){td=performance.now()}function po(){td=0}function fo(t){function e(){Qa(Du),rd()}var r,i;ju.x=t.clientX/Eu.clientWidth*2-1,ju.y=-t.clientY/Eu.clientHeight*2+1,Cu.setFromCamera(ju,Lu);for(var a=Cu.intersectObjects(Xu,!1),o=0,s=a.length;o<s;o++){switch(r=a[o],Wu){case hs:i=r.object.isPoints?function(e){var r=Pu.selectStation(e.index);rd();var n=Yu?r.p.z-Yu.getHeight(r.p):null,i=new Ia(r,Pu.getGeographicalPosition(r.p),n),a=Pu.getWorldPosition(r.p);return i.display(Eu,t.clientX,t.clientY,Lu,a),Fu.prepare(null,a.clone()),!0}(r):function(t){if(!ed.entrances)return!1;var r=t.object,i=r.getWorldPosition();return Fu.prepare(i.clone().add(new n(0,0,5)),i),console.log(r.type,r.name),!0===Pu.isRegion?Pu.loadFromEntrance(r,e):Fu.start(80),!0}(r);break;case us:i=function(t){return _o().toggleSegment(t.index),Qa(ws),rd(),!0}(r)}if(i)break}}function mo(){Yu&&Yu.isTiled&&ed.terrain&&setTimeout(go,Gu)}function go(){td&&performance.now()-td>Gu&&(po(),Yu.zoomCheck(Lu)&&setTimeout(go,5*Gu))}function vo(){Fu.start(200)}function yo(t){var e=Eu.clientWidth,r=Eu.clientHeight,i=Pu.scaleFactor;Iu=Pu.limits,Ou=.5;var a=Iu.getSize();Nu=0;var o=Math.min(e/a.x,r/a.y),s=o*i,c=new n(o,o,s);t.scale.copy(c),t.position.copy(Pu.modelLimits.getCenter().multiply(c).negate()),Qh.setScale(s),t.setScale(s)}function xo(){return qu}function bo(){return Bu}function wo(){return Pu.getMetadataURL()}function _o(){return Pu.getRoutes()}function Mo(){return Pu.surveyTree}function Eo(t,e){function r(t){t.target.parentElement.classList.remove("onscreen")}var n=document.createElement("div"),i=document.createElement("div"),a=Eo.frame;if(i.classList.add("page"),n.id=t,n.classList.add("tab"),n.style.top=40*Eo.position+++"px",n.addEventListener("click",this.tabHandleClick),void 0!==e&&n.addEventListener("click",e),null===a){(a=document.createElement("div")).id="frame",a.style.display="block",Eo.frame=a;var o=document.createElement("div");o.id="close",o.addEventListener("click",r),a.appendChild(o)}a.appendChild(n),a.appendChild(i),Eo.pages.push({tab:n,page:i}),this.page=i,this.slide=void 0}function So(t){var e=(t.clientWidth-300)/2,r=document.createElement("div");r.id="status-text",r.style.width="300px",r.style.left=e+"px";var n=document.createElement("progress");n.id="progress-bar",n.style.width="300px",n.style.left=e+"px",n.setAttribute("max","100"),this.container=t,this.progressBar=n,this.statusText=r}function To(t){this.fileName=t,this.groups=[],this.surface=[],this.xGroups=[],this.surveyTree=new ia,this.sourceCRS=null,this.targetCRS="EPSG:3857",this.projection=null}function Ao(t){this.fileName=t,this.scraps=[],this.faults=[],this.lineSegments=[],this.xGroups=[],this.surveyTree=new ia("",0),this.terrain={},this.hasTerrain=!1}function Lo(t){this.fileName=t,this.groups=[],this.surface=[],this.xGroups=[],this.surveyTree=new ia,this.sourceCRS=null,this.targetCRS="EPSG:3857",this.projection=null}function Co(t){this.filename=t,this.box=new st}function Ro(t,e){t||alert("No callback specified"),this.callback=t,this.progress=e,this.dataResponse=null,this.metadataResponse=null,this.taskCount=0}function Po(t,e){if(!(sd=document.getElementById(t)))return void alert("No container DOM object ["+t+"] available");ld=new So(sd),ed.init(t,e),id=new Ro(Zo,qo),document.addEventListener("keydown",Qo),sd.addEventListener("drop",Vo),sd.addEventListener("dragover",Go),Object.defineProperty(pd,"file",{get:function(){return cd},set:function(t){Xo(t),cd=t}}),ed.addEventListener("change",Eo.handleChange),ed.addEventListener("change",Oo),ed.addEventListener("newCave",Jo)}function Io(t,e){for(var r,n=e?"block":"none",i=0,a=t.length;i<a;i++)null!==(r=t[i])&&(r.style.display=n)}function Oo(t){switch(t.name){case"routeEdit":Io(gd,ed.routeEdit);break;case"terrain":Io(md,ed.terrain);case"terrainShading":ed.terrain&&vd&&ed.terrainShading===ys?vd.style.display="block":vd&&(vd.style.display="none")}}function No(){function t(t){fd&&("section"!==t.name&&"shadingMode"!==t.name&&"splays"!==t.name||s.replaceSlide(e(od),l,o))}function e(t){function e(t){if(0!==t.hitCount||ed.splays){var e=document.createElement("li"),r=document.createTextNode(t.name),n=document.createElement("span");if(e.id="sv"+t.id,ed.section===t.id&&e.classList.add("selected"),void 0===t.hitCount){var i;i=ed.shadingMode===vs&&void 0!==d[t.id]?d[t.id].getHexString():"444444",n.style.color="#"+i,n.textContent="█ "}else void 0!==t.type&&t.type===Us?(n.style.color="yellow",n.textContent="∩ "):t.hitCount>2?(n.style.color="yellow",n.textContent="◼ "):0===t.hitCount?(n.style.color="red",n.textContent="◻ "):(n.style.color="red",n.textContent="◼ ");if(e.appendChild(n),e.appendChild(r),t.children.length>0){var a=document.createElement("div");a.classList.add("descend-tree"),a.id="ssv"+t.id,a.textContent="►",e.appendChild(a)}o.appendChild(e)}}function a(t,e){return u(t.name,e.name)}for(var o,l,h,d=hu.getSurveyColourMap(ad,ed.section);l=c.firstChild;)c.removeChild(l);null===t.parent?c.textContent=""===t.name?"[model]":t.name:((h=document.createElement("span")).textContent=" ◄",s.addListener(h,"click",i),c.appendChild(h),c.appendChild(document.createTextNode(" "+t.name))),o=document.createElement("ul");var p=t.children;return p.sorted||(p.sort(a),p.sorted=!0),t.forEachChild(e),od=t,s.addListener(o,"mouseover",n),s.addListener(o,"mouseleave",r),o}function r(t){t.stopPropagation(),ed.highlight=0}function n(t){t.stopPropagation();var e=t.target;if("LI"===e.nodeName){var r=Number(e.id.split("v")[1]);return r!==h&&(ed.highlight=ed.section!==r?r:0,h=r),!1}}function i(t){t.stopPropagation(),null!==od.parent&&s.replaceSlide(e(od.parent),--l,o)}function a(){ed.section=od.id}function o(t){var r=t.target,n=Number(r.id.split("v")[1]);switch(t.stopPropagation(),r.nodeName){case"LI":ed.section=ed.section!==n?n:0,ed.setPOI=!0;break;case"DIV":n&&s.replaceSlide(e(od.findById(n)),++l,o)}}var s,c=document.createElement("div"),l=0,h=0,u=new Intl.Collator("en-GB",{numeric:!0}).compare;if(od=ad,fd){(s=new Eo("icon_explore")).addHeader("Selection"),c.id="ui-path",s.addListener(c,"click",a),s.appendChild(c),s.addSlide(e(od),l,o);sd.clientHeight;s.addListener(ed,"change",t)}}function Do(){function t(){hd.addRoute(i()),n=a.addSelect("Current Route",hd.getRouteNames(),hd,"setRoute",n)}function e(){hd.saveCurrent()}function r(){ed.shadingMode=ws,!hd.setRoute&&s.length>0&&(hd.setRoute=s[0])}var n,i,a=new Eo("icon_route",r),s=hd.getRouteNames();a.addHeader("Routes"),a.addCheckbox("Edit Routes",ed,"routeEdit"),n=a.addSelect("Current Route",s,hd,"setRoute"),gd.push(a.addButton("Save",e)),gd.push(a.addTextBox("New Route","---",function(t){i=t})),gd.push(a.addButton("Add",t)),gd.push(a.addDownloadButton("Download",ed.getMetadata,o(cd,"json"))),Io(gd,!1),a.addListener(hd,"changed",Eo.handleChange)}function Uo(){function t(t,r){var n=document.createElement("dt"),i=document.createElement("dd");n.textContent=t,i.textContent=r,e.appendChild(n),e.appendChild(i)}var e,r=new Eo("icon_help");r.addHeader("Help - key commands"),r.addHeader("Shading"),e=document.createElement("dl"),t("1","height"),t("2","leg angle"),t("3","leg length"),t("4","height cursor "),t("5","single colour"),t("6","survey section"),t("7","route"),t("8","depth from surface"),t("9","depth cursor"),t("[","move depth cursor up"),t("]","move depth cursor down"),dd.length>0&&t("n","next cave"),r.appendChild(e),r.addHeader("View"),e=document.createElement("dl"),t("O","orthogonal view"),t("P","perspective view"),t("R","reset to plan view"),t(".","center view on last feature selected"),r.appendChild(e),r.addHeader("Visibility"),e=document.createElement("dl"),t("C","scraps on/off [lox only]"),t("J","station labels on/off"),t("L","labels on/off"),t("Q","splay legs on/off"),t("S","surface legs on/off"),t("T","terrain on/off"),t("W","LRUD walls on/off"),t("Z","stations on/off"),t("","-"),t("<","Decrease terrain opacity"),t(">","Increase terrain opacity"),r.appendChild(e),r.addHeader("Selection"),e=document.createElement("dl"),t("V","Remove all except selected section"),r.appendChild(e)}function zo(){var t=new Eo("icon_info");t.addHeader("Information"),t.addText("CaveView v"+$o+" - a work in progress 3d cave viewer for Survex (.3d) and Therion (.lox) models."),t.addText("Requires a browser supporting WebGL (IE 11+ and most other recent browsers), no plugins required. Created using the THREE.js 3D library and chroma,js colour handling library.")}function Bo(){var t=Object.assign({},yd);ed.hasTerrain&&(t.depth=bs,t["depth cursor"]=_s);var e=new Eo("icon_settings");e.addHeader("Survey"),dd.length>0&&e.addSelect("File",dd,pd,"file"),e.addHeader("View"),e.addSelect("Camera Type",_d,ed,"cameraType"),e.addSelect("View",wd,ed,"view"),e.addRange("Vertical scaling",ed,"zScale"),e.addCheckbox("Auto Rotate",ed,"autoRotate"),e.addRange("Rotation Speed",ed,"autoRotateSpeed"),e.addHeader("Shading"),e.addSelect("Underground Legs",t,ed,"shadingMode"),e.addHeader("Visibility"),ed.hasEntrances&&e.addCheckbox("Entrances",ed,"entrances"),ed.hasStations&&e.addCheckbox("Stations",ed,"stations"),ed.hasStationLabels&&e.addCheckbox("Station Labels",ed,"stationLabels"),ed.hasSplays&&e.addCheckbox("Splay Legs",ed,"splays"),ed.hasWalls&&e.addCheckbox("Walls (LRUD)",ed,"walls"),ed.hasScraps&&e.addCheckbox("Scraps",ed,"scraps"),ed.hasTraces&&e.addCheckbox("Dye Traces",ed,"traces"),e.addCheckbox("Indicators",ed,"HUD"),e.addCheckbox("Bounding Box",ed,"box")}function Fo(){vd=null,md=[];var t=new Eo("icon_terrain");if(t.addHeader("Surface Features"),ed.hasSurfaceLegs&&(t.addCheckbox("Surface Legs",ed,"surfaceLegs"),t.addSelect("Leg Shading",xd,ed,"surfaceShading")),ed.hasTerrain){t.addHeader("Terrain"),t.addCheckbox("Terrain",ed,"terrain");var e=ed.terrainOverlays,r=Object.assign({},bd);e.length>0&&(r["map overlay"]=ys),md.push(t.addSelect("Shading",r,ed,"terrainShading")),e.length>1&&(vd=t.addSelect("Overlay",e,ed,"terrainOverlay"),md.push(vd)),md.push(t.addRange("Terrain opacity",ed,"terrainOpacity")),md.push(t.addCheckbox("Vertical datum shift",ed,"terrainDatumShift")),Io(md,!1)}}function ko(){Eo.reset(),Bo(),Fo(),No(),Do(),zo(),Uo(),sd.appendChild(Eo.frame)}function Go(t){t.preventDefault(),t.dataTransfer.dropEffect="copy"}function Vo(t){var e=t.dataTransfer;t.preventDefault(),1===e.files.length&&Yo(e.files[0])}function Ho(){fd&&(fd=!1,Eo.clear(),ad=null)}function jo(t){dd=t,Wo()}function Wo(){if(0===dd.length)return!1;++ud>=dd.length&&(ud=0),pd.file=dd[ud]}function Xo(t){cd=t,Ho(),ed.clearView(),ld.Start("Loading file "+cd+" ..."),id.loadURL(cd)}function Yo(t){Ho(),ed.clearView(),ld.Start("Loading file "+t.name+" ..."),id.loadFile(t)}function qo(t){ld.Update(t)}function Zo(t){function e(){ld.End(),ld.Start("Rendering..."),setTimeout(r,100)}function r(){ed.loadCave(nd),ld.End()}nd=t,setTimeout(e,100)}function Jo(){ed.shadingMode=ds,ad=ed.getSurveyTree(),hd=ed.getRoutes(),fd=!0,nd=null,ko()}function Qo(t){if(fd)switch(t.keyCode){case 49:ed.shadingMode=ds;break;case 50:ed.shadingMode=fs;break;case 51:ed.shadingMode=ps;break;case 52:ed.shadingMode=ms;break;case 53:ed.shadingMode=gs;break;case 54:ed.shadingMode=vs;break;case 55:ed.shadingMode=ws;break;case 56:ed.shadingMode=bs;break;case 57:ed.shadingMode=_s;break;case 67:ed.hasScraps&&(ed.scraps=!ed.scraps);break;case 68:ed.hasTraces&&(ed.traces=!ed.traces);break;case 73:ed.developerInfo=!0;break;case 74:ed.hasStationLabels&&(ed.stationLabels=!ed.stationLabels);break;case 76:ed.hasEntrances&&(ed.entrances=!ed.entrances);break;case 78:Wo();break;case 79:ed.cameraType=es;break;case 80:ed.cameraType=rs;break;case 81:ed.hasSplays&&(ed.splays=!ed.splays);break;case 82:ed.view=as;break;case 83:ed.hasSurfaceLegs&&(ed.surfaceLegs=!ed.surfaceLegs);break;case 84:ed.hasTerrain&&(ed.terrain=!ed.terrain);break;case 86:Ho(),ed.cut=!0;break;case 87:ed.hasWalls&&(ed.walls=!ed.walls);break;case 88:ed.setPOI=!0;break;case 90:ed.stations=!ed.stations;break;case 107:case 219:ed.cursorHeight++;break;case 109:case 221:ed.cursorHeight--;break;case 188:ed.hasTerrain&&(ed.terrainOpacity=Math.max(ed.terrainOpacity-.05,0));break;case 190:ed.hasTerrain&&(ed.terrainOpacity=Math.min(ed.terrainOpacity+.05,1))}}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:t>0?1:+t}),void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&function(){Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),r=1;r<arguments.length;r++){var n=arguments[r];if(void 0!==n&&null!==n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}}();var Ko={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var t,e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=new Array(36),n=0;return function(){for(var i=0;i<36;i++)8===i||13===i||18===i||23===i?r[i]="-":14===i?r[i]="4":(n<=2&&(n=33554432+16777216*Math.random()|0),t=15&n,n>>=4,r[i]=e[19===i?3&t|8:t]);return r.join("")}}(),clamp:function(t,e,r){return Math.max(e,Math.min(r,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,r,n,i){return n+(t-e)*(i-n)/(r-e)},lerp:function(t,e,r){return(1-r)*t+r*e},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*Ko.DEG2RAD},radToDeg:function(t){return t*Ko.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}};Object.assign(e.prototype,{isMatrix4:!0,set:function(t,e,r,n,i,a,o,s,c,l,h,u,d,p,f,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=n,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new e).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:function(){var t=new n;return function(e){var r=this.elements,n=e.elements,i=1/t.setFromMatrixColumn(e,0).length(),a=1/t.setFromMatrixColumn(e,1).length(),o=1/t.setFromMatrixColumn(e,2).length();return r[0]=n[0]*i,r[1]=n[1]*i,r[2]=n[2]*i,r[4]=n[4]*a,r[5]=n[5]*a,r[6]=n[6]*a,r[8]=n[8]*o,r[9]=n[9]*o,r[10]=n[10]*o,this}}(),makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,r=t.x,n=t.y,i=t.z,a=Math.cos(r),o=Math.sin(r),s=Math.cos(n),c=Math.sin(n),l=Math.cos(i),h=Math.sin(i);if("XYZ"===t.order){var u=a*l,d=a*h,p=o*l,f=o*h;e[0]=s*l,e[4]=-s*h,e[8]=c,e[1]=d+p*c,e[5]=u-f*c,e[9]=-o*s,e[2]=f-u*c,e[6]=p+d*c,e[10]=a*s}else if("YXZ"===t.order){var m=s*l,g=s*h,v=c*l,y=c*h;e[0]=m+y*o,e[4]=v*o-g,e[8]=a*c,e[1]=a*h,e[5]=a*l,e[9]=-o,e[2]=g*o-v,e[6]=y+m*o,e[10]=a*s}else if("ZXY"===t.order){var m=s*l,g=s*h,v=c*l,y=c*h;e[0]=m-y*o,e[4]=-a*h,e[8]=v+g*o,e[1]=g+v*o,e[5]=a*l,e[9]=y-m*o,e[2]=-a*c,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){var u=a*l,d=a*h,p=o*l,f=o*h;e[0]=s*l,e[4]=p*c-d,e[8]=u*c+f,e[1]=s*h,e[5]=f*c+u,e[9]=d*c-p,e[2]=-c,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){var x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=_-x*h,e[8]=w*h+b,e[1]=h,e[5]=a*l,e[9]=-o*l,e[2]=-c*l,e[6]=b*h+w,e[10]=x-_*h}else if("XZY"===t.order){var x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=-h,e[8]=c*l,e[1]=x*h+_,e[5]=a*l,e[9]=b*h-w,e[2]=w*h-b,e[6]=o*l,e[10]=_*h+x}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,r=t._x,n=t._y,i=t._z,a=t._w,o=r+r,s=n+n,c=i+i,l=r*o,h=r*s,u=r*c,d=n*s,p=n*c,f=i*c,m=a*o,g=a*s,v=a*c;return e[0]=1-(d+f),e[4]=h-v,e[8]=u+g,e[1]=h+v,e[5]=1-(l+f),e[9]=p-m,e[2]=u-g,e[6]=p+m,e[10]=1-(l+d),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t=new n,e=new n,r=new n;return function(n,i,a){var o=this.elements;return r.subVectors(n,i),0===r.lengthSq()&&(r.z=1),r.normalize(),t.crossVectors(a,r),0===t.lengthSq()&&(1===Math.abs(a.z)?r.x+=1e-4:r.z+=1e-4,r.normalize(),t.crossVectors(a,r)),t.normalize(),e.crossVectors(r,t),o[0]=t.x,o[4]=e.x,o[8]=r.x,o[1]=t.y,o[5]=e.y,o[9]=r.y,o[2]=t.z,o[6]=e.z,o[10]=r.z,this}}(),multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,n=e.elements,i=this.elements,a=r[0],o=r[4],s=r[8],c=r[12],l=r[1],h=r[5],u=r[9],d=r[13],p=r[2],f=r[6],m=r[10],g=r[14],v=r[3],y=r[7],x=r[11],b=r[15],w=n[0],_=n[4],M=n[8],E=n[12],S=n[1],T=n[5],A=n[9],L=n[13],C=n[2],R=n[6],P=n[10],I=n[14],O=n[3],N=n[7],D=n[11],U=n[15];return i[0]=a*w+o*S+s*C+c*O,i[4]=a*_+o*T+s*R+c*N,i[8]=a*M+o*A+s*P+c*D,i[12]=a*E+o*L+s*I+c*U,i[1]=l*w+h*S+u*C+d*O,i[5]=l*_+h*T+u*R+d*N,i[9]=l*M+h*A+u*P+d*D,i[13]=l*E+h*L+u*I+d*U,i[2]=p*w+f*S+m*C+g*O,i[6]=p*_+f*T+m*R+g*N,i[10]=p*M+f*A+m*P+g*D,i[14]=p*E+f*L+m*I+g*U,i[3]=v*w+y*S+x*C+b*O,i[7]=v*_+y*T+x*R+b*N,i[11]=v*M+y*A+x*P+b*D,i[15]=v*E+y*L+x*I+b*U,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:function(){var t=new n;return function(e){for(var r=0,n=e.count;r<n;r++)t.x=e.getX(r),t.y=e.getY(r),t.z=e.getZ(r),t.applyMatrix4(this),e.setXYZ(r,t.x,t.y,t.z);return e}}(),determinant:function(){var t=this.elements,e=t[0],r=t[4],n=t[8],i=t[12],a=t[1],o=t[5],s=t[9],c=t[13],l=t[2],h=t[6],u=t[10],d=t[14];return t[3]*(+i*s*h-n*c*h-i*o*u+r*c*u+n*o*d-r*s*d)+t[7]*(+e*s*d-e*c*u+i*a*u-n*a*d+n*c*l-i*s*l)+t[11]*(+e*c*h-e*o*d-i*a*h+r*a*d+i*o*l-r*c*l)+t[15]*(-n*o*l-e*s*h+e*o*u+n*a*h-r*a*u+r*s*l)},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},setPosition:function(t){var e=this.elements;return e[12]=t.x,e[13]=t.y,e[14]=t.z,this},getInverse:function(t,e){var r=this.elements,n=t.elements,i=n[0],a=n[1],o=n[2],s=n[3],c=n[4],l=n[5],h=n[6],u=n[7],d=n[8],p=n[9],f=n[10],m=n[11],g=n[12],v=n[13],y=n[14],x=n[15],b=p*y*u-v*f*u+v*h*m-l*y*m-p*h*x+l*f*x,w=g*f*u-d*y*u-g*h*m+c*y*m+d*h*x-c*f*x,_=d*v*u-g*p*u+g*l*m-c*v*m-d*l*x+c*p*x,M=g*p*h-d*v*h-g*l*f+c*v*f+d*l*y-c*p*y,E=i*b+a*w+o*_+s*M;if(0===E){var S="THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0";if(!0===e)throw new Error(S);return console.warn(S),this.identity()}var T=1/E;return r[0]=b*T,r[1]=(v*f*s-p*y*s-v*o*m+a*y*m+p*o*x-a*f*x)*T,r[2]=(l*y*s-v*h*s+v*o*u-a*y*u-l*o*x+a*h*x)*T,r[3]=(p*h*s-l*f*s-p*o*u+a*f*u+l*o*m-a*h*m)*T,r[4]=w*T,r[5]=(d*y*s-g*f*s+g*o*m-i*y*m-d*o*x+i*f*x)*T,r[6]=(g*h*s-c*y*s-g*o*u+i*y*u+c*o*x-i*h*x)*T,r[7]=(c*f*s-d*h*s+d*o*u-i*f*u-c*o*m+i*h*m)*T,r[8]=_*T,r[9]=(g*p*s-d*v*s-g*a*m+i*v*m+d*a*x-i*p*x)*T,r[10]=(c*v*s-g*l*s+g*a*u-i*v*u-c*a*x+i*l*x)*T,r[11]=(d*l*s-c*p*s-d*a*u+i*p*u+c*a*m-i*l*m)*T,r[12]=M*T,r[13]=(d*v*o-g*p*o+g*a*f-i*v*f-d*a*y+i*p*y)*T,r[14]=(g*l*o-c*v*o-g*a*h+i*v*h+c*a*y-i*l*y)*T,r[15]=(c*p*o-d*l*o+d*a*h-i*p*h-c*a*f+i*l*f)*T,this},scale:function(t){var e=this.elements,r=t.x,n=t.y,i=t.z;return e[0]*=r,e[4]*=n,e[8]*=i,e[1]*=r,e[5]*=n,e[9]*=i,e[2]*=r,e[6]*=n,e[10]*=i,e[3]*=r,e[7]*=n,e[11]*=i,this},getMaxScaleOnAxis:function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,n))},makeTranslation:function(t,e,r){return this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this},makeRotationX:function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this},makeRotationY:function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this},makeRotationZ:function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(t,e){var r=Math.cos(e),n=Math.sin(e),i=1-r,a=t.x,o=t.y,s=t.z,c=i*a,l=i*o;return this.set(c*a+r,c*o-n*s,c*s+n*o,0,c*o+n*s,l*o+r,l*s-n*a,0,c*s-n*o,l*s+n*a,i*s*s+r,0,0,0,0,1),this},makeScale:function(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this},makeShear:function(t,e,r){return this.set(1,e,r,0,t,1,r,0,t,e,1,0,0,0,0,1),this},compose:function(t,e,r){return this.makeRotationFromQuaternion(e),this.scale(r),this.setPosition(t),this},decompose:function(){var t=new n,r=new e;return function(e,n,i){var a=this.elements,o=t.set(a[0],a[1],a[2]).length(),s=t.set(a[4],a[5],a[6]).length(),c=t.set(a[8],a[9],a[10]).length();this.determinant()<0&&(o=-o),e.x=a[12],e.y=a[13],e.z=a[14],r.copy(this);var l=1/o,h=1/s,u=1/c;return r.elements[0]*=l,r.elements[1]*=l,r.elements[2]*=l,r.elements[4]*=h,r.elements[5]*=h,r.elements[6]*=h,r.elements[8]*=u,r.elements[9]*=u,r.elements[10]*=u,n.setFromRotationMatrix(r),i.x=o,i.y=s,i.z=c,this}}(),makePerspective:function(t,e,r,n,i,a){void 0===a&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var o=this.elements,s=2*i/(e-t),c=2*i/(r-n),l=(e+t)/(e-t),h=(r+n)/(r-n),u=-(a+i)/(a-i),d=-2*a*i/(a-i);return o[0]=s,o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=c,o[9]=h,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this},makeOrthographic:function(t,e,r,n,i,a){var o=this.elements,s=1/(e-t),c=1/(r-n),l=1/(a-i),h=(e+t)*s,u=(r+n)*c,d=(a+i)*l;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-h,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=-2*l,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this},equals:function(t){for(var e=this.elements,r=t.elements,n=0;n<16;n++)if(e[n]!==r[n])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var r=0;r<16;r++)this.elements[r]=t[r+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}}),Object.assign(r,{slerp:function(t,e,r,n){return r.copy(t).slerp(e,n)},slerpFlat:function(t,e,r,n,i,a,o){var s=r[n+0],c=r[n+1],l=r[n+2],h=r[n+3],u=i[a+0],d=i[a+1],p=i[a+2],f=i[a+3];if(h!==f||s!==u||c!==d||l!==p){var m=1-o,g=s*u+c*d+l*p+h*f,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,g*v);m=Math.sin(m*b)/x,o=Math.sin(o*b)/x}var w=o*v;if(s=s*m+u*w,c=c*m+d*w,l=l*m+p*w,h=h*m+f*w,m===1-o){var _=1/Math.sqrt(s*s+c*c+l*l+h*h);s*=_,c*=_,l*=_,h*=_}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=h}}),Object.defineProperties(r.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}}),Object.assign(r.prototype,{set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=t._x,n=t._y,i=t._z,a=t.order,o=Math.cos,s=Math.sin,c=o(r/2),l=o(n/2),h=o(i/2),u=s(r/2),d=s(n/2),p=s(i/2);return"XYZ"===a?(this._x=u*l*h+c*d*p,this._y=c*d*h-u*l*p,this._z=c*l*p+u*d*h,this._w=c*l*h-u*d*p):"YXZ"===a?(this._x=u*l*h+c*d*p,this._y=c*d*h-u*l*p,this._z=c*l*p-u*d*h,this._w=c*l*h+u*d*p):"ZXY"===a?(this._x=u*l*h-c*d*p,this._y=c*d*h+u*l*p,this._z=c*l*p+u*d*h,this._w=c*l*h-u*d*p):"ZYX"===a?(this._x=u*l*h-c*d*p,this._y=c*d*h+u*l*p,this._z=c*l*p-u*d*h,this._w=c*l*h+u*d*p):"YZX"===a?(this._x=u*l*h+c*d*p,this._y=c*d*h+u*l*p,this._z=c*l*p-u*d*h,this._w=c*l*h-u*d*p):"XZY"===a&&(this._x=u*l*h-c*d*p,this._y=c*d*h-u*l*p,this._z=c*l*p+u*d*h,this._w=c*l*h+u*d*p),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,r=t.elements,n=r[0],i=r[4],a=r[8],o=r[1],s=r[5],c=r[9],l=r[2],h=r[6],u=r[10],d=n+s+u;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(h-c)*e,this._y=(a-l)*e,this._z=(o-i)*e):n>s&&n>u?(e=2*Math.sqrt(1+n-s-u),this._w=(h-c)/e,this._x=.25*e,this._y=(i+o)/e,this._z=(a+l)/e):s>u?(e=2*Math.sqrt(1+s-n-u),this._w=(a-l)/e,this._x=(i+o)/e,this._y=.25*e,this._z=(c+h)/e):(e=2*Math.sqrt(1+u-n-s),this._w=(o-i)/e,this._x=(a+l)/e,this._y=(c+h)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e=new n;return function(r,i){return void 0===e&&(e=new n),t=r.dot(i)+1,t<1e-6?(t=0,Math.abs(r.x)>Math.abs(r.z)?e.set(-r.y,r.x,0):e.set(0,-r.z,r.y)):e.crossVectors(r,i),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var r=t._x,n=t._y,i=t._z,a=t._w,o=e._x,s=e._y,c=e._z,l=e._w;return this._x=r*l+a*o+n*c-i*s,this._y=n*l+a*s+i*o-r*c,this._z=i*l+a*c+r*s-n*o,this._w=a*l-r*o-n*s-i*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var r=this._x,n=this._y,i=this._z,a=this._w,o=a*t._w+r*t._x+n*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=r,this._y=n,this._z=i,this;var s=Math.sqrt(1-o*o);if(Math.abs(s)<.001)return this._w=.5*(a+this._w),this._x=.5*(r+this._x),this._y=.5*(n+this._y),this._z=.5*(i+this._z),this;var c=Math.atan2(s,o),l=Math.sin((1-e)*c)/s,h=Math.sin(e*c)/s;return this._w=a*l+this._w*h,this._x=r*l+this._x*h,this._y=n*l+this._y*h,this._z=i*l+this._z*h,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(n.prototype,{isVector3:!0,set:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(){var t=new r;return function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t=new r;return function(e,r){return this.applyQuaternion(t.setFromAxisAngle(e,r))}}(),applyMatrix3:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements,a=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*a,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*a,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*a,this},applyQuaternion:function(t){var e=this.x,r=this.y,n=this.z,i=t.x,a=t.y,o=t.z,s=t.w,c=s*e+a*n-o*r,l=s*r+o*e-i*n,h=s*n+i*r-a*e,u=-i*e-a*r-o*n;return this.x=c*s+u*-i+l*-o-h*-a,this.y=l*s+u*-a+h*-i-c*-o,this.z=h*s+u*-o+c*-a-l*-i,this},project:function(){var t=new e;return function(e){return t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t=new e;return function(e){return t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),transformDirection:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t=new n,e=new n;return function(r,n){return t.set(r,r,r),e.set(n,n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},cross:function(t,e){if(void 0!==e)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e);var r=this.x,n=this.y,i=this.z;return this.x=n*t.z-i*t.y,this.y=i*t.x-r*t.z,this.z=r*t.y-n*t.x,this},crossVectors:function(t,e){var r=t.x,n=t.y,i=t.z,a=e.x,o=e.y,s=e.z;return this.x=n*s-i*o,this.y=i*a-r*s,this.z=r*o-n*a,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t=new n;return function(e){return t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t=new n;return function(e){return this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(Ko.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}});var $o="1.2.2",ts=1,es=1,rs=2,ns=600,is=0,as=1,os=2,ss=3,cs=4,ls=5,hs=0,us=1,ds=1,ps=2,fs=3,ms=4,gs=5,vs=6,ys=7,xs=8,bs=9,ws=10,_s=11,Ms=1,Es=2,Ss=3,Ts=4,As=5,Ls=6,Cs=7,Rs=8,Ps=9,Is=10,Os=11,Ns=12,Ds=0,Us=1,zs=new n(0,0,1),Bs=new Map;String.prototype.padStart||(String.prototype.padStart=function(t,e){return t>>=0,e=String(e||" "),this.length>t?String(this):((t-=this.length)>e.length&&(e+=e.repeat(t/e.length)),e.slice(0,t)+String(this))}),String.prototype.repeat||(String.prototype.repeat=function(t){if(null==this)throw new TypeError("can't convert "+this+" to object");var e=""+this;if((t=+t)!=t&&(t=0),t<0)throw new RangeError("repeat count must be non-negative");if(t==1/0)throw new RangeError("repeat count must be less than infinity");if(t=Math.floor(t),0==e.length||0==t)return"";if(e.length*t>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!=(t>>>=1);)e+=e;return r}),s.stdWidth=40,s.stdMargin=5,s.prototype.removeDomObjects=function(){for(var t,e=0,r=this.domObjects.length;e<r;e++)(t=this.domObjects[e]).parentElement.removeChild(t);this.domObjects=[]},s.prototype.setVisibility=function(t){var e;this.visible=t,e=t?"block":"none";for(var r=0,n=this.domObjects.length;r<n;r++)this.domObjects[r].style.display=e};var Fs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Object.assign(c.prototype,{isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,r){return this.r=t,this.g=e,this.b=r,this},setHSL:function(){function t(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}return function(e,r,n){if(e=Ko.euclideanModulo(e,1),r=Ko.clamp(r,0,1),n=Ko.clamp(n,0,1),0===r)this.r=this.g=this.b=n;else{var i=n<=.5?n*(1+r):n+r-n*r,a=2*n-i;this.r=t(a,i,e+1/3),this.g=t(a,i,e),this.b=t(a,i,e-1/3)}return this}}(),setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,i=r[1],a=r[2];switch(i){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,c=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(o,s,c)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=(h=r[1]).length;if(3===l)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}if(t&&t.length>0){var h=Fs[t];void 0!==h?this.setHex(h):console.warn("THREE.Color: Unknown color "+t)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,n=t||{h:0,s:0,l:0},i=this.r,a=this.g,o=this.b,s=Math.max(i,a,o),c=Math.min(i,a,o),l=(c+s)/2;if(c===s)e=0,r=0;else{var h=s-c;switch(r=l<=.5?h/(s+c):h/(2-s-c),s){case i:e=(a-o)/h+(a<o?6:0);break;case a:e=(o-i)/h+2;break;case o:e=(i-a)/h+4}e/=6}return n.h=e,n.s=r,n.l=l,n},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(t,e,r){var n=this.getHSL();return n.h+=t,n.s+=e,n.l+=r,this.setHSL(n.h,n.s,n.l),this},add:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},addColors:function(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this},addScalar:function(t){return this.r+=t,this.g+=t,this.b+=t,this},sub:function(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this},multiply:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},multiplyScalar:function(t){return this.r*=t,this.g*=t,this.b*=t,this},lerp:function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this},equals:function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},fromArray:function(t,e){return void 0===e&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t},toJSON:function(){return this.getHex()}});var ks={inclination:[[255,255,0],[253,254,2],[251,253,4],[249,252,5],[247,251,7],[245,250,9],[243,249,11],[241,249,13],[239,248,14],[237,247,16],[235,246,18],[233,245,20],[231,244,22],[229,243,23],[227,242,25],[225,241,27],[223,240,29],[221,239,31],[219,238,32],[217,237,34],[215,237,36],[213,236,38],[211,235,40],[209,234,41],[207,233,43],[205,232,45],[203,231,47],[201,230,49],[199,229,50],[197,228,52],[195,227,54],[193,226,56],[191,226,58],[189,225,60],[187,224,61],[185,223,63],[183,222,65],[181,221,67],[179,220,69],[177,219,70],[175,218,72],[173,217,74],[171,216,76],[169,215,78],[167,214,79],[165,214,81],[163,213,83],[161,212,85],[159,211,87],[157,210,88],[155,209,90],[153,208,92],[151,207,94],[149,206,96],[147,205,97],[145,204,99],[143,203,101],[141,202,103],[139,202,105],[137,201,106],[135,200,108],[133,199,110],[131,198,112],[129,197,114],[126,196,115],[124,195,117],[122,194,119],[120,193,121],[118,192,123],[116,191,124],[114,191,126],[112,190,128],[110,189,130],[108,188,132],[106,187,133],[104,186,135],[102,185,137],[100,184,139],[98,183,141],[96,182,142],[94,181,144],[92,180,146],[90,179,148],[88,179,150],[86,178,151],[84,177,153],[82,176,155],[80,175,157],[78,174,159],[76,173,160],[74,172,162],[72,171,164],[70,170,166],[68,169,168],[66,168,169],[64,167,171],[62,167,173],[60,166,175],[58,165,177],[56,164,179],[54,163,180],[52,162,182],[50,161,184],[48,160,186],[46,159,188],[44,158,189],[42,157,191],[40,156,193],[38,156,195],[36,155,197],[34,154,198],[32,153,200],[30,152,202],[28,151,204],[26,150,206],[24,149,207],[22,148,209],[20,147,211],[18,146,213],[16,145,215],[14,144,216],[12,144,218],[10,143,220],[8,142,222],[6,141,224],[4,140,225],[2,139,227],[0,138,229]],terrain:[[50,205,50],[52,205,52],[53,206,53],[55,206,55],[56,207,56],[58,207,58],[60,207,60],[61,208,61],[63,208,63],[65,209,65],[66,209,66],[68,209,68],[69,210,69],[71,210,71],[73,211,73],[74,211,74],[76,211,76],[77,212,77],[79,212,79],[81,212,81],[82,213,82],[84,213,84],[86,214,86],[87,214,87],[89,214,89],[90,215,90],[92,215,92],[94,216,94],[95,216,95],[97,216,97],[98,217,98],[100,217,100],[102,218,102],[103,218,103],[105,218,105],[106,219,106],[108,219,108],[110,220,110],[111,220,111],[113,220,113],[115,221,115],[116,221,116],[118,222,118],[119,222,119],[121,222,121],[123,223,123],[124,223,124],[126,224,126],[127,224,127],[129,224,129],[131,225,131],[132,225,132],[134,225,134],[136,226,136],[137,226,137],[139,227,139],[140,227,140],[142,227,142],[144,228,144],[145,228,145],[147,229,147],[148,229,148],[150,229,150],[152,230,152],[153,230,153],[155,231,155],[157,231,157],[158,231,158],[160,232,160],[161,232,161],[163,233,163],[165,233,165],[166,233,166],[168,234,168],[169,234,169],[171,235,171],[173,235,173],[174,235,174],[176,236,176],[178,236,178],[179,236,179],[181,237,181],[182,237,182],[184,238,184],[186,238,186],[187,238,187],[189,239,189],[190,239,190],[192,240,192],[194,240,194],[195,240,195],[197,241,197],[199,241,199],[200,242,200],[202,242,202],[203,242,203],[205,243,205],[207,243,207],[208,244,208],[210,244,210],[211,244,211],[213,245,213],[215,245,215],[216,246,216],[218,246,218],[219,246,219],[221,247,221],[223,247,223],[224,248,224],[226,248,226],[228,248,228],[229,249,229],[231,249,231],[232,249,232],[234,250,234],[236,250,236],[237,251,237],[239,251,239],[240,251,240],[242,252,242],[244,252,244],[245,253,245],[247,253,247],[249,253,249],[250,254,250],[252,254,252],[253,255,253],[255,255,255]],gradient:[[235,99,111],[235,99,112],[234,99,113],[234,100,114],[233,100,114],[233,100,115],[232,100,116],[232,101,117],[231,101,118],[231,101,119],[230,101,119],[230,101,120],[230,102,121],[229,102,122],[229,102,123],[228,102,124],[228,103,124],[227,103,125],[227,103,126],[226,103,127],[226,103,128],[226,104,129],[225,104,129],[225,104,130],[224,104,131],[224,104,132],[223,105,133],[223,105,134],[222,105,134],[222,105,135],[221,106,136],[221,106,137],[221,106,138],[220,106,139],[220,106,139],[219,107,140],[219,107,141],[218,107,142],[218,107,143],[217,108,144],[217,108,144],[216,108,145],[216,108,146],[216,108,147],[215,109,148],[215,109,149],[214,109,149],[214,109,150],[213,110,151],[213,110,152],[212,110,153],[212,110,154],[211,110,154],[211,111,155],[211,111,156],[210,111,157],[210,111,158],[209,111,159],[209,112,159],[208,112,160],[208,112,161],[207,112,162],[207,113,163],[207,113,164],[206,113,164],[206,113,165],[205,113,166],[205,114,167],[204,114,168],[204,114,169],[203,114,169],[203,115,170],[202,115,171],[202,115,172],[201,115,172],[200,116,173],[199,116,173],[198,116,173],[197,117,174],[196,117,174],[194,118,174],[193,118,175],[192,118,175],[191,119,176],[190,119,176],[189,119,176],[188,120,177],[187,120,177],[186,121,177],[185,121,178],[184,121,178],[183,122,178],[181,122,179],[180,122,179],[179,123,179],[178,123,180],[177,124,180],[176,124,181],[175,124,181],[174,125,181],[173,125,182],[172,125,182],[171,126,182],[170,126,183],[168,126,183],[167,127,183],[166,127,184],[165,128,184],[164,128,184],[163,128,185],[162,129,185],[161,129,186],[160,129,186],[159,130,186],[158,130,187],[157,131,187],[155,131,187],[154,131,188],[153,132,188],[152,132,188],[151,132,189],[150,133,189],[149,133,189],[148,133,190],[147,134,190],[146,134,191],[145,135,191],[144,135,191],[142,135,192],[141,136,192],[140,136,192],[139,136,193],[138,137,193],[137,137,193],[136,138,194],[135,138,194],[134,138,194],[133,139,195],[132,139,195],[131,139,196],[129,140,196],[128,140,196],[127,141,197],[126,141,197],[125,141,197],[124,142,198],[123,142,198],[122,142,198],[120,142,197],[119,143,197],[117,143,197],[116,143,197],[114,143,196],[113,144,196],[111,144,196],[110,144,195],[108,144,195],[107,144,195],[105,145,195],[104,145,194],[102,145,194],[101,145,194],[100,146,193],[98,146,193],[97,146,193],[95,146,193],[94,146,192],[92,147,192],[91,147,192],[89,147,191],[88,147,191],[86,147,191],[85,148,191],[83,148,190],[82,148,190],[80,148,190],[79,149,189],[78,149,189],[76,149,189],[75,149,189],[73,149,188],[72,150,188],[70,150,188],[69,150,187],[67,150,187],[66,151,187],[64,151,186],[63,151,186],[61,151,186],[60,151,186],[59,152,185],[57,152,185],[56,152,185],[54,152,184],[53,153,184],[51,153,184],[50,153,184],[48,153,183],[47,153,183],[45,154,183],[44,154,182],[42,154,182],[41,154,182],[39,154,182],[38,155,181],[37,155,181],[35,155,181],[34,155,180],[32,156,180],[31,156,180],[29,156,180],[28,156,179],[26,156,179],[25,157,179],[23,157,178],[22,157,178],[20,157,178],[19,158,178],[17,158,177],[16,158,177],[16,158,176],[17,158,176],[17,158,175],[18,158,174],[18,158,174],[19,158,173],[19,158,172],[20,158,171],[20,158,171],[21,158,170],[21,158,169],[22,158,169],[22,159,168],[23,159,167],[23,159,167],[23,159,166],[24,159,165],[24,159,164],[25,159,164],[25,159,163],[26,159,162],[26,159,162],[27,159,161],[27,159,160],[28,159,160],[28,159,159],[29,159,158],[29,159,157],[30,159,157],[30,159,156],[30,159,155],[31,159,155],[31,159,154],[32,159,153],[32,159,153],[33,159,152],[33,160,151],[34,160,150],[34,160,150],[35,160,149],[35,160,148],[36,160,148],[36,160,147],[36,160,146],[37,160,146],[37,160,145],[38,160,144],[38,160,143],[39,160,143],[39,160,142],[40,160,141],[40,160,141],[41,160,140],[41,160,139],[42,160,139],[42,160,138],[43,160,137],[43,160,136],[43,160,136],[44,160,135],[44,161,134],[45,161,134],[45,161,133],[46,161,132],[46,161,132],[47,161,131],[47,161,130],[48,161,129],[48,161,129],[49,161,128],[49,161,127],[50,161,127],[50,161,126],[51,161,125],[52,161,125],[53,161,124],[54,161,123],[55,161,123],[56,161,122],[56,160,121],[57,160,121],[58,160,120],[59,160,120],[60,160,119],[61,160,118],[62,160,118],[63,160,117],[64,160,116],[65,160,116],[66,160,115],[67,160,114],[67,159,114],[68,159,113],[69,159,112],[70,159,112],[71,159,111],[72,159,111],[73,159,110],[74,159,109],[75,159,109],[76,159,108],[77,159,107],[78,159,107],[78,158,106],[79,158,105],[80,158,105],[81,158,104],[82,158,103],[83,158,103],[84,158,102],[85,158,102],[86,158,101],[87,158,100],[88,158,100],[89,158,99],[89,157,98],[90,157,98],[91,157,97],[92,157,96],[93,157,96],[94,157,95],[95,157,94],[96,157,94],[97,157,93],[98,157,93],[99,157,92],[100,157,91],[100,156,91],[101,156,90],[102,156,89],[103,156,89],[104,156,88],[105,156,87],[106,156,87],[107,156,86],[108,156,85],[109,156,85],[110,156,84],[111,156,84],[111,155,83],[112,155,82],[113,155,82],[114,155,81],[115,155,80],[116,155,80],[117,155,79],[118,155,79],[118,155,79],[119,154,78],[120,154,78],[121,154,78],[121,154,78],[122,154,78],[123,153,77],[123,153,77],[124,153,77],[125,153,77],[126,153,77],[126,152,77],[127,152,76],[128,152,76],[128,152,76],[129,152,76],[130,151,76],[131,151,75],[131,151,75],[132,151,75],[133,150,75],[133,150,75],[134,150,74],[135,150,74],[136,150,74],[136,149,74],[137,149,74],[138,149,73],[138,149,73],[139,149,73],[140,148,73],[141,148,73],[141,148,72],[142,148,72],[143,148,72],[143,147,72],[144,147,72],[145,147,72],[145,147,71],[146,147,71],[147,146,71],[148,146,71],[148,146,71],[149,146,70],[150,146,70],[150,145,70],[151,145,70],[152,145,70],[153,145,69],[153,145,69],[154,144,69],[155,144,69],[155,144,69],[156,144,68],[157,143,68],[158,143,68],[158,143,68],[159,143,68],[160,143,67],[160,142,67],[161,142,67],[162,142,67],[163,142,67],[163,142,67],[164,141,66],[165,141,66],[165,141,66],[166,141,66],[167,141,66],[168,140,65],[168,140,65],[169,140,65],[169,140,65],[170,140,66],[170,139,66],[171,139,66],[171,139,67],[172,139,67],[172,139,67],[172,138,68],[173,138,68],[173,138,68],[174,138,69],[174,138,69],[175,137,69],[175,137,70],[175,137,70],[176,137,70],[176,137,71],[177,136,71],[177,136,71],[177,136,72],[178,136,72],[178,135,72],[179,135,73],[179,135,73],[180,135,73],[180,135,74],[180,134,74],[181,134,74],[181,134,75],[182,134,75],[182,134,75],[183,133,76],[183,133,76],[183,133,76],[184,133,77],[184,133,77],[185,132,77],[185,132,77],[186,132,78],[186,132,78],[186,132,78],[187,131,79],[187,131,79],[188,131,79],[188,131,80],[189,131,80],[189,130,80],[189,130,81],[190,130,81],[190,130,81],[191,130,82],[191,129,82],[192,129,82],[192,129,83],[192,129,83],[193,128,83],[193,128,84],[194,128,84],[194,128,84],[194,128,85],[195,127,85],[195,127,85],[196,127,86],[196,127,86],[197,127,86],[197,126,87],[197,126,87],[198,126,87],[198,126,88],[199,126,88],[199,125,88],[200,125,89],[200,125,89]],survey:[[166,206,227],[31,120,180],[178,223,138],[51,160,44],[251,154,153],[227,26,28],[253,191,111],[255,127,0],[202,178,214],[106,61,154],[255,255,153]],depth:[[255,255,204],[255,255,203],[255,255,203],[255,254,202],[255,254,202],[255,254,201],[255,254,200],[255,253,200],[255,253,199],[255,253,199],[255,253,198],[255,252,197],[255,252,197],[255,252,196],[255,252,196],[255,251,195],[255,251,194],[255,251,194],[255,251,193],[255,250,193],[255,250,192],[255,250,191],[255,250,191],[255,249,190],[255,249,190],[255,249,189],[255,249,188],[255,248,188],[255,248,187],[255,248,187],[255,248,186],[255,247,185],[255,247,185],[255,247,184],[255,247,184],[255,246,183],[255,246,182],[255,246,182],[255,246,181],[255,245,180],[255,245,180],[255,245,179],[255,245,179],[255,244,178],[255,244,177],[255,244,177],[255,244,176],[255,243,176],[255,243,175],[255,243,174],[255,243,174],[255,242,173],[255,242,173],[255,242,172],[255,242,171],[255,241,171],[255,241,170],[255,241,170],[255,241,169],[255,240,168],[255,240,168],[255,240,167],[255,240,167],[255,239,166],[255,239,165],[255,239,165],[255,239,164],[255,238,164],[255,238,163],[255,238,162],[255,238,162],[255,237,161],[255,237,161],[255,237,160],[255,237,159],[255,236,159],[255,236,158],[255,236,158],[255,236,157],[255,235,157],[255,235,156],[255,235,155],[255,235,155],[255,234,154],[255,234,154],[255,234,153],[255,233,153],[255,233,152],[255,233,151],[255,233,151],[255,232,150],[255,232,150],[255,232,149],[255,232,148],[255,231,148],[255,231,147],[255,231,147],[255,230,146],[255,230,146],[255,230,145],[255,230,144],[255,229,144],[255,229,143],[255,229,143],[255,229,142],[255,228,142],[255,228,141],[255,228,140],[255,227,140],[255,227,139],[254,227,139],[254,227,138],[254,226,138],[254,226,137],[254,226,136],[254,225,136],[254,225,135],[254,225,135],[254,225,134],[254,224,134],[254,224,133],[254,224,132],[254,224,132],[254,223,131],[254,223,131],[254,223,130],[254,222,130],[254,222,129],[254,222,128],[254,222,128],[254,221,127],[254,221,127],[254,221,126],[254,221,125],[254,220,125],[254,220,124],[254,220,124],[254,219,123],[254,219,123],[254,219,122],[254,219,121],[254,218,121],[254,218,120],[254,218,120],[254,218,119],[254,217,119],[254,217,118],[254,216,117],[254,216,117],[254,215,116],[254,215,116],[254,214,115],[254,214,115],[254,213,114],[254,213,113],[254,212,113],[254,212,112],[254,211,112],[254,211,111],[254,210,111],[254,210,110],[254,209,109],[254,208,109],[254,208,108],[254,207,108],[254,207,107],[254,206,106],[254,206,106],[254,205,105],[254,205,105],[254,204,104],[254,204,104],[254,203,103],[254,203,102],[254,202,102],[254,202,101],[254,201,101],[254,200,100],[254,200,100],[254,199,99],[254,199,98],[254,198,98],[254,198,97],[254,197,97],[254,197,96],[254,196,96],[254,196,95],[254,195,94],[254,195,94],[254,194,93],[254,193,93],[254,193,92],[254,192,92],[254,192,91],[254,191,90],[254,191,90],[254,190,89],[254,190,89],[254,189,88],[254,189,88],[254,188,87],[254,188,86],[254,187,86],[254,187,85],[254,186,85],[254,185,84],[254,185,83],[254,184,83],[254,184,82],[254,183,82],[254,183,81],[254,182,81],[254,182,80],[254,181,79],[254,181,79],[254,180,78],[254,180,78],[254,179,77],[254,179,77],[254,178,76],[254,177,76],[254,177,76],[254,176,75],[254,176,75],[254,175,75],[254,175,75],[254,174,74],[254,174,74],[254,173,74],[254,173,74],[254,172,74],[254,172,73],[254,171,73],[254,171,73],[254,170,73],[254,170,72],[254,169,72],[254,169,72],[254,168,72],[254,168,72],[254,167,71],[254,167,71],[254,166,71],[254,166,71],[254,165,71],[254,165,70],[254,164,70],[254,164,70],[254,163,70],[254,163,69],[254,162,69],[254,162,69],[254,161,69],[254,161,69],[254,160,68],[254,160,68],[253,159,68],[253,159,68],[253,158,67],[253,158,67],[253,157,67],[253,157,67],[253,156,67],[253,156,66],[253,155,66],[253,155,66],[253,154,66],[253,154,65],[253,153,65],[253,153,65],[253,152,65],[253,152,65],[253,151,64],[253,151,64],[253,150,64],[253,150,64],[253,149,64],[253,149,63],[253,148,63],[253,148,63],[253,147,63],[253,147,62],[253,146,62],[253,146,62],[253,145,62],[253,145,62],[253,144,61],[253,144,61],[253,143,61],[253,143,61],[253,142,60],[253,142,60],[253,141,60],[253,140,60],[253,139,60],[253,138,59],[253,138,59],[253,137,59],[253,136,59],[253,135,58],[253,134,58],[253,133,58],[253,132,58],[253,132,57],[253,131,57],[253,130,57],[253,129,57],[253,128,56],[253,127,56],[253,126,56],[253,125,56],[253,125,55],[253,124,55],[253,123,55],[253,122,55],[253,121,54],[253,120,54],[253,119,54],[253,119,54],[253,118,53],[253,117,53],[253,116,53],[253,115,53],[253,114,52],[253,113,52],[253,113,52],[253,112,52],[253,111,51],[253,110,51],[252,109,51],[252,108,51],[252,107,50],[252,106,50],[252,106,50],[252,105,50],[252,104,49],[252,103,49],[252,102,49],[252,101,49],[252,100,48],[252,100,48],[252,99,48],[252,98,48],[252,97,47],[252,96,47],[252,95,47],[252,94,47],[252,94,46],[252,93,46],[252,92,46],[252,91,46],[252,90,45],[252,89,45],[252,88,45],[252,87,45],[252,87,44],[252,86,44],[252,85,44],[252,84,44],[252,83,43],[252,82,43],[252,81,43],[252,81,43],[252,80,42],[252,79,42],[252,78,42],[252,77,42],[251,77,42],[251,76,41],[251,75,41],[250,74,41],[250,74,41],[250,73,41],[249,72,40],[249,72,40],[249,71,40],[248,70,40],[248,69,40],[248,69,40],[247,68,39],[247,67,39],[247,67,39],[246,66,39],[246,65,39],[245,64,38],[245,64,38],[245,63,38],[244,62,38],[244,62,38],[244,61,37],[243,60,37],[243,59,37],[243,59,37],[242,58,37],[242,57,36],[242,57,36],[241,56,36],[241,55,36],[241,54,36],[240,54,35],[240,53,35],[240,52,35],[239,52,35],[239,51,35],[239,50,35],[238,50,34],[238,49,34],[238,48,34],[237,47,34],[237,47,34],[237,46,33],[236,45,33],[236,45,33],[236,44,33],[235,43,33],[235,42,32],[235,42,32],[234,41,32],[234,40,32],[234,40,32],[233,39,31],[233,38,31],[232,37,31],[232,37,31],[232,36,31],[231,35,30],[231,35,30],[231,34,30],[230,33,30],[230,32,30],[230,32,30],[229,31,29],[229,30,29],[229,30,29],[228,29,29],[228,28,29],[228,27,28],[227,27,28],[227,26,28],[226,26,28],[226,25,28],[225,25,28],[224,25,29],[224,24,29],[223,24,29],[222,24,29],[222,23,29],[221,23,29],[220,22,29],[219,22,30],[219,22,30],[218,21,30],[217,21,30],[217,21,30],[216,20,30],[215,20,30],[215,20,30],[214,19,31],[213,19,31],[213,19,31],[212,18,31],[211,18,31],[211,17,31],[210,17,31],[209,17,32],[209,16,32],[208,16,32],[207,16,32],[206,15,32],[206,15,32],[205,15,32],[204,14,33],[204,14,33],[203,14,33],[202,13,33],[202,13,33],[201,12,33],[200,12,33],[200,12,33],[199,11,34],[198,11,34],[198,11,34],[197,10,34],[196,10,34],[195,10,34],[195,9,34],[194,9,35],[193,9,35],[193,8,35],[192,8,35],[191,7,35],[191,7,35],[190,7,35],[189,6,36],[189,6,36],[188,6,36],[187,5,36],[187,5,36],[186,5,36],[185,4,36],[185,4,36],[184,4,37],[183,3,37],[182,3,37],[182,2,37],[181,2,37],[180,2,37],[180,1,37],[179,1,38],[178,1,38],[178,0,38],[177,0,38]],spectrum:[[100,60,60],[100,63,60],[100,66,60],[100,68,60],[100,71,60],[100,73,60],[100,76,60],[100,79,60],[100,81,60],[100,84,60],[100,86,60],[100,89,60],[100,92,60],[100,94,60],[100,97,60],[99,100,60],[97,100,60],[94,100,60],[92,100,60],[89,100,60],[86,100,60],[84,100,60],[81,100,60],[79,100,60],[76,100,60],[73,100,60],[71,100,60],[68,100,60],[65,100,60],[63,100,60],[60,100,60],[60,100,63],[60,100,66],[60,100,68],[60,100,71],[60,100,73],[60,100,76],[60,100,79],[60,100,81],[60,100,84],[60,100,86],[60,100,89],[60,100,92],[60,100,94],[60,100,97],[60,99,100],[60,97,100],[60,94,100],[60,92,100],[60,89,100],[60,86,100],[60,84,100],[60,81,100],[60,79,100],[60,76,100],[60,73,100],[60,71,100],[60,68,100],[60,65,100],[60,63,100],[60,60,100],[63,60,100],[66,60,100],[68,60,100],[71,60,100],[73,60,100],[76,60,100],[79,60,100],[81,60,100],[84,60,100],[87,60,100],[89,60,100],[92,60,100],[94,60,100],[97,60,100],[100,60,99],[100,60,97],[100,60,94],[100,60,92],[100,60,89],[100,60,86],[100,60,84],[100,60,81],[100,60,78],[100,60,76],[100,60,73],[100,60,71],[100,60,68],[100,60,65],[100,60,63],[100,60,60],[100,63,60],[100,66,60],[100,68,60],[100,71,60],[100,73,60],[100,76,60],[100,79,60],[100,81,60],[100,84,60],[100,87,60],[100,89,60],[100,92,60],[100,94,60],[100,97,60],[99,100,60],[97,100,60],[94,100,60],[92,100,60],[89,100,60],[86,100,60],[84,100,60],[81,100,60],[78,100,60],[76,100,60],[73,100,60],[71,100,60],[68,100,60],[65,100,60],[63,100,60],[60,100,60],[60,100,63],[60,100,66],[60,100,68],[60,100,71],[60,100,74],[60,100,76],[60,100,79]]};Object.assign(l.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});var r=this._listeners;void 0===r[t]&&(r[t]=[]),-1===r[t].indexOf(e)&&r[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;var r=this._listeners;return void 0!==r[t]&&-1!==r[t].indexOf(e)},removeEventListener:function(t,e){if(void 0!==this._listeners){var r=this._listeners[t];if(void 0!==r){var n=r.indexOf(e);-1!==n&&r.splice(n,1)}}},dispatchEvent:function(t){if(void 0!==this._listeners){var e=this._listeners[t.type];if(void 0!==e){t.target=this;for(var r=e.slice(0),n=0,i=r.length;n<i;n++)r[n].call(this,t)}}}});var Gs="86",Vs={LEFT:0,MIDDLE:1,RIGHT:2},Hs=0,js=1,Ws=2,Xs=0,Ys=1,qs=2,Zs=0,Js=1,Qs=2,Ks=1,$s=2,tc=0,ec=1,rc=2,nc=0,ic=1,ac=2,oc=3,sc=4,cc=5,lc=100,hc=101,uc=102,dc=103,pc=104,fc=200,mc=201,gc=202,vc=203,yc=204,xc=205,bc=206,wc=207,_c=208,Mc=209,Ec=210,Sc=0,Tc=1,Ac=2,Lc=3,Cc=4,Rc=5,Pc=6,Ic=7,Oc=0,Nc=1,Dc=2,Uc=0,zc=1,Bc=2,Fc=3,kc=4,Gc=301,Vc=302,Hc=303,jc=304,Wc=305,Xc=306,Yc=307,qc=1e3,Zc=1001,Jc=1002,Qc=1003,Kc=1004,$c=1005,tl=1006,el=1007,rl=1008,nl=1009,il=1010,al=1011,ol=1012,sl=1013,cl=1014,ll=1015,hl=1016,ul=1017,dl=1018,pl=1019,fl=1020,ml=1021,gl=1022,vl=1023,yl=1024,xl=1025,bl=1026,wl=1027,_l=2001,Ml=2002,El=2003,Sl=2004,Tl=2100,Al=2101,Ll=2102,Cl=2103,Rl=2151,Pl=2201,Il=2400,Ol=0,Nl=1,Dl=2,Ul=3e3,zl=3001,Bl=3007,Fl=3002,kl=3004,Gl=3005,Vl=3006,Hl=3200,jl=3201;Object.defineProperties(h.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(h.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(){var t=new h,e=new h;return function(r,n){return t.set(r,r),e.set(n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*r-a*n+t.x,this.y=i*n+a*r+t.y,this}});var Wl=0;u.DEFAULT_IMAGE=void 0,u.DEFAULT_MAPPING=300,Object.defineProperty(u.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(u.prototype,l.prototype,{constructor:u,isTexture:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){if(void 0!==t.textures[this.uuid])return t.textures[this.uuid];var e={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var r=this.image;void 0===r.uuid&&(r.uuid=Ko.generateUUID()),void 0===t.images[r.uuid]&&(t.images[r.uuid]={uuid:r.uuid,url:function(t){var e;return void 0!==t.toDataURL?e=t:((e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0,t.width,t.height)),e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(r)}),e.image=r.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case qc:t.x=t.x-Math.floor(t.x);break;case Zc:t.x=t.x<0?0:1;break;case Jc:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case qc:t.y=t.y-Math.floor(t.y);break;case Zc:t.y=t.y<0?0:1;break;case Jc:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}}),d.prototype=Object.create(u.prototype),d.prototype.constructor=d,d.prototype.isDataTexture=!0;var Xl={colors:[],texture:[]},Yl={getTexture:g,getColors:v,red:new c(16711680),yellow:new c(16776960),green:new c(65280),white:new c(16777215),grey:new c(4473924),lightGrey:new c(8947848),hudBlue:new c(1077133),hudRed:new c(8397056)};Object.assign(y.prototype,{isVector4:!0,set:function(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=this.w,a=t.elements;return this.x=a[0]*e+a[4]*r+a[8]*n+a[12]*i,this.y=a[1]*e+a[5]*r+a[9]*n+a[13]*i,this.z=a[2]*e+a[6]*r+a[10]*n+a[14]*i,this.w=a[3]*e+a[7]*r+a[11]*n+a[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,r,n,i,a=t.elements,o=a[0],s=a[4],c=a[8],l=a[1],h=a[5],u=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(s-l)<.01&&Math.abs(c-d)<.01&&Math.abs(u-p)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+d)<.1&&Math.abs(u+p)<.1&&Math.abs(o+h+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(o+1)/2,g=(h+1)/2,v=(f+1)/2,y=(s+l)/4,x=(c+d)/4,b=(u+p)/4;return m>g&&m>v?m<.01?(r=0,n=.707106781,i=.707106781):(n=y/(r=Math.sqrt(m)),i=x/r):g>v?g<.01?(r=.707106781,n=0,i=.707106781):(r=y/(n=Math.sqrt(g)),i=b/n):v<.01?(r=.707106781,n=.707106781,i=0):(r=x/(i=Math.sqrt(v)),n=b/i),this.set(r,n,i,e),this}var w=Math.sqrt((p-u)*(p-u)+(c-d)*(c-d)+(l-s)*(l-s));return Math.abs(w)<.001&&(w=1),this.x=(p-u)/w,this.y=(c-d)/w,this.z=(l-s)/w,this.w=Math.acos((o+h+f-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(){var t,e;return function(r,n){return void 0===t&&(t=new y,e=new y),t.set(r,r,r,r),e.set(n,n,n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),Object.assign(x.prototype,l.prototype,{isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),b.prototype=Object.create(u.prototype),b.prototype.constructor=b,b.prototype.isCubeTexture=!0,Object.defineProperty(b.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}});var ql=new u,Zl=new b,Jl=[],Ql=[],Kl=new Float32Array(16),$l=new Float32Array(9);Q.prototype.setValue=function(t,e){for(var r=this.seq,n=0,i=r.length;n!==i;++n){var a=r[n];a.setValue(t,e[a.id])}};var th=/([\w\d_]+)(\])?(\[|\.)?/g;tt.prototype.setValue=function(t,e,r){var n=this.map[e];void 0!==n&&n.setValue(t,r,this.renderer)},tt.prototype.setOptional=function(t,e,r){var n=e[r];void 0!==n&&this.setValue(t,r,n)},tt.upload=function(t,e,r,n){for(var i=0,a=e.length;i!==a;++i){var o=e[i],s=r[o.id];!1!==s.needsUpdate&&o.setValue(t,s.value,n)}},tt.seqWithValue=function(t,e){for(var r=[],n=0,i=t.length;n!==i;++n){var a=t[n];a.id in e&&r.push(a)}return r};var eh={common:{diffuse:{value:new c(15658734)},opacity:{value:1},map:{value:null},offsetRepeat:{value:new y(0,0,1,1)},specularMap:{value:null},alphaMap:{value:null},envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new h(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new c(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new c(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},offsetRepeat:{value:new y(0,0,1,1)}}},rh={merge:function(t){for(var e={},r=0;r<t.length;r++){var n=this.clone(t[r]);for(var i in n)e[i]=n[i]}return e},clone:function(t){var e={};for(var r in t){e[r]={};for(var n in t[r]){var i=t[r][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture)?e[r][n]=i.clone():Array.isArray(i)?e[r][n]=i.slice():e[r][n]=i}}return e}},nh={alphamap_fragment:"#ifdef USE_ALPHAMAP\r\n\r\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\r\n\r\n#endif\r\n",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\r\n\r\n\tuniform sampler2D alphaMap;\r\n\r\n#endif\r\n",alphatest_fragment:"#ifdef ALPHATEST\r\n\r\n\tif ( diffuseColor.a < ALPHATEST ) discard;\r\n\r\n#endif\r\n",aomap_fragment:"#ifdef USE_AOMAP\r\n\r\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\r\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\r\n\r\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\r\n\r\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\r\n\r\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\r\n\r\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\r\n\r\n\t#endif\r\n\r\n#endif\r\n",aomap_pars_fragment:"#ifdef USE_AOMAP\r\n\r\n\tuniform sampler2D aoMap;\r\n\tuniform float aoMapIntensity;\r\n\r\n#endif",begin_vertex:"\r\nvec3 transformed = vec3( position );\r\n",beginnormal_vertex:"\r\nvec3 objectNormal = vec3( normal );\r\n",bsdfs:'float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\r\n\r\n\tif( decayExponent > 0.0 ) {\r\n\r\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\r\n\r\n\t\t// based upon Frostbite 3 Moving to Physically-based Rendering\r\n\t\t// page 32, equation 26: E[window1]\r\n\t\t// http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr_v2.pdf\r\n\t\t// this is intended to be used on spot and point lights who are represented as luminous intensity\r\n\t\t// but who must be converted to luminous irradiance for surface lighting calculation\r\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\r\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\r\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\r\n\r\n#else\r\n\r\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\r\n\r\n#endif\r\n\r\n\t}\r\n\r\n\treturn 1.0;\r\n\r\n}\r\n\r\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\r\n\r\n\treturn RECIPROCAL_PI * diffuseColor;\r\n\r\n} // validated\r\n\r\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\r\n\r\n\t// Original approximation by Christophe Schlick \'94\r\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\r\n\r\n\t// Optimized variant (presented by Epic at SIGGRAPH \'13)\r\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\r\n\r\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\r\n\r\n} // validated\r\n\r\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\r\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\r\n// alpha is "roughness squared" in Disney’s reparameterization\r\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\r\n\r\n\t// geometry term = G(l)⋅G(v) / 4(n⋅l)(n⋅v)\r\n\r\n\tfloat a2 = pow2( alpha );\r\n\r\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\r\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\r\n\r\n\treturn 1.0 / ( gl * gv );\r\n\r\n} // validated\r\n\r\n// Moving Frostbite to Physically Based Rendering 2.0 - page 12, listing 2\r\n// http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr_v2.pdf\r\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\r\n\r\n\tfloat a2 = pow2( alpha );\r\n\r\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\r\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\r\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\r\n\r\n\treturn 0.5 / max( gv + gl, EPSILON );\r\n}\r\n\r\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\r\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\r\n// alpha is "roughness squared" in Disney’s reparameterization\r\nfloat D_GGX( const in float alpha, const in float dotNH ) {\r\n\r\n\tfloat a2 = pow2( alpha );\r\n\r\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\r\n\r\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\r\n\r\n}\r\n\r\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\r\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\r\n\r\n\tfloat alpha = pow2( roughness ); // UE4\'s roughness\r\n\r\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\r\n\r\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\r\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\r\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\r\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\r\n\r\n\tvec3 F = F_Schlick( specularColor, dotLH );\r\n\r\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\r\n\r\n\tfloat D = D_GGX( alpha, dotNH );\r\n\r\n\treturn F * ( G * D );\r\n\r\n} // validated\r\n\r\n// Rect Area Light\r\n\r\n// Area light computation code adapted from:\r\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\r\n// By: Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt\r\n// https://drive.google.com/file/d/0BzvWIdpUpRx_d09ndGVjNVJzZjA/view\r\n// https://eheitzresearch.wordpress.com/415-2/\r\n// http://blog.selfshadow.com/sandbox/ltc.html\r\n\r\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\r\n\r\n\tconst float LUT_SIZE = 64.0;\r\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\r\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\r\n\r\n\tfloat theta = acos( dot( N, V ) );\r\n\r\n\t// Parameterization of texture:\r\n\t// sqrt(roughness) -> [0,1]\r\n\t// theta -> [0, PI/2]\r\n\tvec2 uv = vec2(\r\n\t\tsqrt( saturate( roughness ) ),\r\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\r\n\r\n\t// Ensure we don\'t have nonlinearities at the look-up table\'s edges\r\n\t// see: http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html\r\n\t// "Shader Analysis" section\r\n\tuv = uv * LUT_SCALE + LUT_BIAS;\r\n\r\n\treturn uv;\r\n\r\n}\r\n\r\n// Real-Time Area Lighting: a Journey from Research to Production\r\n// By: Stephen Hill & Eric Heitz\r\n// http://advances.realtimerendering.com/s2016/s2016_ltc_rnd.pdf\r\n// An approximation for the form factor of a clipped rectangle.\r\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\r\n\r\n\tfloat l = length( f );\r\n\r\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\r\n\r\n}\r\n\r\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\r\n// also Real-Time Area Lighting: a Journey from Research to Production\r\n// http://advances.realtimerendering.com/s2016/s2016_ltc_rnd.pdf\r\n// Normalization by 2*PI is incorporated in this function itself.\r\n// theta/sin(theta) is approximated by rational polynomial\r\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\r\n\r\n\tfloat x = dot( v1, v2 );\r\n\r\n\tfloat y = abs( x );\r\n\tfloat a = 0.86267 + (0.49788 + 0.01436 * y ) * y;\r\n\tfloat b = 3.45068 + (4.18814 + y) * y;\r\n\tfloat v = a / b;\r\n\r\n\tfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt( 1.0 - x * x ) - v;\r\n\r\n\treturn cross( v1, v2 ) * theta_sintheta;\r\n\r\n}\r\n\r\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\r\n\r\n\t// bail if point is on back side of plane of light\r\n\t// assumes ccw winding order of light vertices\r\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\r\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\r\n\tvec3 lightNormal = cross( v1, v2 );\r\n\r\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\r\n\r\n\t// construct orthonormal basis around N\r\n\tvec3 T1, T2;\r\n\tT1 = normalize( V - N * dot( V, N ) );\r\n\tT2 = - cross( N, T1 ); // negated from paper; possibly due to a different assumed handedness of world coordinate system\r\n\r\n\t// compute transform\r\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\r\n\r\n\t// transform rect\r\n\tvec3 coords[ 4 ];\r\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\r\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\r\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\r\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\r\n\r\n\t// project rect onto sphere\r\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\r\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\r\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\r\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\r\n\r\n\t// calculate vector form factor\r\n\tvec3 vectorFormFactor = vec3( 0.0 );\r\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\r\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\r\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\r\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\r\n\r\n\t// adjust for horizon clipping\r\n\tvec3 result = vec3( LTC_ClippedSphereFormFactor( vectorFormFactor ) );\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\n// End Rect Area Light\r\n\r\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\r\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\r\n\r\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\r\n\r\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\r\n\r\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\r\n\r\n\tvec4 r = roughness * c0 + c1;\r\n\r\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\r\n\r\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\r\n\r\n\treturn specularColor * AB.x + AB.y;\r\n\r\n} // validated\r\n\r\n\r\nfloat G_BlinnPhong_Implicit( ) {\r\n\r\n\t// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\r\n\treturn 0.25;\r\n\r\n}\r\n\r\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\r\n\r\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\r\n\r\n}\r\n\r\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\r\n\r\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\r\n\r\n\t//float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\r\n\t//float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\r\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\r\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\r\n\r\n\tvec3 F = F_Schlick( specularColor, dotLH );\r\n\r\n\tfloat G = G_BlinnPhong_Implicit( );\r\n\r\n\tfloat D = D_BlinnPhong( shininess, dotNH );\r\n\r\n\treturn F * ( G * D );\r\n\r\n} // validated\r\n\r\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\r\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\r\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\r\n}\r\n\r\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\r\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\r\n}\r\n',bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\r\n\r\n\tuniform sampler2D bumpMap;\r\n\tuniform float bumpScale;\r\n\r\n\t// Derivative maps - bump mapping unparametrized surfaces by Morten Mikkelsen\r\n\t// http://mmikkelsen3d.blogspot.sk/2011/07/derivative-maps.html\r\n\r\n\t// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\r\n\r\n\tvec2 dHdxy_fwd() {\r\n\r\n\t\tvec2 dSTdx = dFdx( vUv );\r\n\t\tvec2 dSTdy = dFdy( vUv );\r\n\r\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\r\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\r\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\r\n\r\n\t\treturn vec2( dBx, dBy );\r\n\r\n\t}\r\n\r\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\r\n\r\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\r\n\r\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\r\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\r\n\t\tvec3 vN = surf_norm;\t\t// normalized\r\n\r\n\t\tvec3 R1 = cross( vSigmaY, vN );\r\n\t\tvec3 R2 = cross( vN, vSigmaX );\r\n\r\n\t\tfloat fDet = dot( vSigmaX, R1 );\r\n\r\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\r\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\r\n\r\n\t}\r\n\r\n#endif\r\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\r\n\r\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\r\n\r\n\t\tvec4 plane = clippingPlanes[ i ];\r\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\r\n\r\n\t}\r\n\t\t\r\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\r\n\r\n\t\tbool clipped = true;\r\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\r\n\t\t\tvec4 plane = clippingPlanes[ i ];\r\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\r\n\t\t}\r\n\r\n\t\tif ( clipped ) discard;\r\n\t\r\n\t#endif\r\n\r\n#endif\r\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\r\n\r\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\r\n\t\tvarying vec3 vViewPosition;\r\n\t#endif\r\n\r\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\r\n\r\n#endif\r\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\r\n\tvarying vec3 vViewPosition;\r\n#endif\r\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\r\n\tvViewPosition = - mvPosition.xyz;\r\n#endif\r\n\r\n",color_fragment:"#ifdef USE_COLOR\r\n\r\n\tdiffuseColor.rgb *= vColor;\r\n\r\n#endif",color_pars_fragment:"#ifdef USE_COLOR\r\n\r\n\tvarying vec3 vColor;\r\n\r\n#endif\r\n",color_pars_vertex:"#ifdef USE_COLOR\r\n\r\n\tvarying vec3 vColor;\r\n\r\n#endif",color_vertex:"#ifdef USE_COLOR\r\n\r\n\tvColor.xyz = color.xyz;\r\n\r\n#endif",common:"#define PI 3.14159265359\r\n#define PI2 6.28318530718\r\n#define PI_HALF 1.5707963267949\r\n#define RECIPROCAL_PI 0.31830988618\r\n#define RECIPROCAL_PI2 0.15915494\r\n#define LOG2 1.442695\r\n#define EPSILON 1e-6\r\n\r\n#define saturate(a) clamp( a, 0.0, 1.0 )\r\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\r\n\r\nfloat pow2( const in float x ) { return x*x; }\r\nfloat pow3( const in float x ) { return x*x*x; }\r\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\r\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\r\n// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.\r\n// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\r\nhighp float rand( const in vec2 uv ) {\r\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\r\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\r\n\treturn fract(sin(sn) * c);\r\n}\r\n\r\nstruct IncidentLight {\r\n\tvec3 color;\r\n\tvec3 direction;\r\n\tbool visible;\r\n};\r\n\r\nstruct ReflectedLight {\r\n\tvec3 directDiffuse;\r\n\tvec3 directSpecular;\r\n\tvec3 indirectDiffuse;\r\n\tvec3 indirectSpecular;\r\n};\r\n\r\nstruct GeometricContext {\r\n\tvec3 position;\r\n\tvec3 normal;\r\n\tvec3 viewDir;\r\n};\r\n\r\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\r\n\r\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\r\n\r\n}\r\n\r\n// http://en.wikibooks.org/wiki/GLSL_Programming/Applying_Matrix_Transformations\r\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\r\n\r\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\r\n\r\n}\r\n\r\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\r\n\r\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\r\n\r\n\treturn - distance * planeNormal + point;\r\n\r\n}\r\n\r\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\r\n\r\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\r\n\r\n}\r\n\r\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\r\n\r\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\r\n\r\n}\r\n\r\nmat3 transpose( const in mat3 v ) {\r\n\r\n\tmat3 tmp;\r\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\r\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\r\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\r\n\r\n\treturn tmp;\r\n\r\n}\r\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\r\n\r\n#define cubeUV_textureSize (1024.0)\r\n\r\nint getFaceFromDirection(vec3 direction) {\r\n\tvec3 absDirection = abs(direction);\r\n\tint face = -1;\r\n\tif( absDirection.x > absDirection.z ) {\r\n\t\tif(absDirection.x > absDirection.y )\r\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\r\n\t\telse\r\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\r\n\t}\r\n\telse {\r\n\t\tif(absDirection.z > absDirection.y )\r\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\r\n\t\telse\r\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\r\n\t}\r\n\treturn face;\r\n}\r\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\r\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\r\n\r\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\r\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\r\n\tfloat dxRoughness = dFdx(roughness);\r\n\tfloat dyRoughness = dFdy(roughness);\r\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\r\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\r\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\r\n\t// Clamp the value to the max mip level counts. hard coded to 6 mips\r\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\r\n\tfloat mipLevel = 0.5 * log2(d);\r\n\treturn vec2(floor(mipLevel), fract(mipLevel));\r\n}\r\n\r\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\r\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\r\n\r\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\r\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\r\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\r\n\r\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\r\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\r\n\t// float powScale = exp2(roughnessLevel + mipLevel);\r\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\r\n\t// float scale = 1.0 / exp2(roughnessLevel + 2.0 + mipLevel);\r\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\r\n\t// float mipOffset = 0.75*(1.0 - 1.0/exp2(mipLevel))/exp2(roughnessLevel);\r\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\r\n\r\n\tbool bRes = mipLevel == 0.0;\r\n\tscale = bRes && (scale < a) ? a : scale;\r\n\r\n\tvec3 r;\r\n\tvec2 offset;\r\n\tint face = getFaceFromDirection(direction);\r\n\r\n\tfloat rcpPowScale = 1.0 / powScale;\r\n\r\n\tif( face == 0) {\r\n\t\tr = vec3(direction.x, -direction.z, direction.y);\r\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\r\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\r\n\t}\r\n\telse if( face == 1) {\r\n\t\tr = vec3(direction.y, direction.x, direction.z);\r\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\r\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\r\n\t}\r\n\telse if( face == 2) {\r\n\t\tr = vec3(direction.z, direction.x, direction.y);\r\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\r\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\r\n\t}\r\n\telse if( face == 3) {\r\n\t\tr = vec3(direction.x, direction.z, direction.y);\r\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\r\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\r\n\t}\r\n\telse if( face == 4) {\r\n\t\tr = vec3(direction.y, direction.x, -direction.z);\r\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\r\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\r\n\t}\r\n\telse {\r\n\t\tr = vec3(direction.z, -direction.x, direction.y);\r\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\r\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\r\n\t}\r\n\tr = normalize(r);\r\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\r\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\r\n\tvec2 base = offset + vec2( texelOffset );\r\n\treturn base + s * ( scale - 2.0 * texelOffset );\r\n}\r\n\r\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\r\n\r\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\r\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\r\n\tfloat r1 = floor(roughnessVal);\r\n\tfloat r2 = r1 + 1.0;\r\n\tfloat t = fract(roughnessVal);\r\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\r\n\tfloat s = mipInfo.y;\r\n\tfloat level0 = mipInfo.x;\r\n\tfloat level1 = level0 + 1.0;\r\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\r\n\r\n\t// round to nearest mipmap if we are not interpolating.\r\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\r\n\r\n\t// Tri linear interpolation.\r\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\r\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\r\n\r\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\r\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\r\n\r\n\tvec4 result = mix(color10, color20, t);\r\n\r\n\treturn vec4(result.rgb, 1.0);\r\n}\r\n\r\n#endif\r\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\r\n\r\n#ifdef FLIP_SIDED\r\n\r\n\ttransformedNormal = - transformedNormal;\r\n\r\n#endif\r\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\r\n\r\n\tuniform sampler2D displacementMap;\r\n\tuniform float displacementScale;\r\n\tuniform float displacementBias;\r\n\r\n#endif\r\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\r\n\r\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\r\n\r\n#endif\r\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\r\n\r\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\r\n\r\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\r\n\r\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\r\n\r\n#endif\r\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\r\n\r\n\tuniform sampler2D emissiveMap;\r\n\r\n#endif\r\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\r\n",encodings_pars_fragment:"// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/\r\n\r\nvec4 LinearToLinear( in vec4 value ) {\r\n\treturn value;\r\n}\r\n\r\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\r\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\r\n}\r\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\r\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\r\n}\r\n\r\nvec4 sRGBToLinear( in vec4 value ) {\r\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\r\n}\r\nvec4 LinearTosRGB( in vec4 value ) {\r\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\r\n}\r\n\r\nvec4 RGBEToLinear( in vec4 value ) {\r\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\r\n}\r\nvec4 LinearToRGBE( in vec4 value ) {\r\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\r\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\r\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\r\n// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );\r\n}\r\n\r\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\r\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\r\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\r\n}\r\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\r\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\r\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\r\n\tM = ceil( M * 255.0 ) / 255.0;\r\n\treturn vec4( value.rgb / ( M * maxRange ), M );\r\n}\r\n\r\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\r\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\r\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\r\n}\r\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\r\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\r\n\tfloat D = max( maxRange / maxRGB, 1.0 );\r\n\tD = min( floor( D ) / 255.0, 1.0 );\r\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\r\n}\r\n\r\n// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html\r\n\r\n// M matrix, for encoding\r\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\r\nvec4 LinearToLogLuv( in vec4 value ) {\r\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\r\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\r\n\tvec4 vResult;\r\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\r\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\r\n\tvResult.w = fract(Le);\r\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\r\n\treturn vResult;\r\n}\r\n\r\n// Inverse M matrix, for decoding\r\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\r\nvec4 LogLuvToLinear( in vec4 value ) {\r\n\tfloat Le = value.z * 255.0 + value.w;\r\n\tvec3 Xp_Y_XYZp;\r\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\r\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\r\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\r\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\r\n\treturn vec4( max(vRGB, 0.0), 1.0 );\r\n}\r\n",envmap_fragment:"#ifdef USE_ENVMAP\r\n\r\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\r\n\r\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\r\n\r\n\t\t// Transforming Normal Vectors with the Inverse Transformation\r\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\r\n\r\n\t\t#ifdef ENVMAP_MODE_REFLECTION\r\n\r\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\r\n\r\n\t\t#else\r\n\r\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\r\n\r\n\t\t#endif\r\n\r\n\t#else\r\n\r\n\t\tvec3 reflectVec = vReflect;\r\n\r\n\t#endif\r\n\r\n\t#ifdef ENVMAP_TYPE_CUBE\r\n\r\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\r\n\r\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\r\n\r\n\t\tvec2 sampleUV;\r\n\t\tsampleUV.y = asin( flipNormal * reflectVec.y ) * RECIPROCAL_PI + 0.5;\r\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\r\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\r\n\r\n\t#elif defined( ENVMAP_TYPE_SPHERE )\r\n\r\n\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\r\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\r\n\r\n\t#else\r\n\r\n\t\tvec4 envColor = vec4( 0.0 );\r\n\r\n\t#endif\r\n\r\n\tenvColor = envMapTexelToLinear( envColor );\r\n\r\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\r\n\r\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\r\n\r\n\t#elif defined( ENVMAP_BLENDING_MIX )\r\n\r\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\r\n\r\n\t#elif defined( ENVMAP_BLENDING_ADD )\r\n\r\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\r\n\r\n\t#endif\r\n\r\n#endif\r\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\r\n\tuniform float reflectivity;\r\n\tuniform float envMapIntensity;\r\n#endif\r\n\r\n#ifdef USE_ENVMAP\r\n\r\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\r\n\t\tvarying vec3 vWorldPosition;\r\n\t#endif\r\n\r\n\t#ifdef ENVMAP_TYPE_CUBE\r\n\t\tuniform samplerCube envMap;\r\n\t#else\r\n\t\tuniform sampler2D envMap;\r\n\t#endif\r\n\tuniform float flipEnvMap;\r\n\r\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\r\n\t\tuniform float refractionRatio;\r\n\t#else\r\n\t\tvarying vec3 vReflect;\r\n\t#endif\r\n\r\n#endif\r\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\r\n\r\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\r\n\t\tvarying vec3 vWorldPosition;\r\n\r\n\t#else\r\n\r\n\t\tvarying vec3 vReflect;\r\n\t\tuniform float refractionRatio;\r\n\r\n\t#endif\r\n\r\n#endif\r\n",envmap_vertex:"#ifdef USE_ENVMAP\r\n\r\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\r\n\r\n\t\tvWorldPosition = worldPosition.xyz;\r\n\r\n\t#else\r\n\r\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\r\n\r\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\r\n\r\n\t\t#ifdef ENVMAP_MODE_REFLECTION\r\n\r\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\r\n\r\n\t\t#else\r\n\r\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\r\n\r\n\t\t#endif\r\n\r\n\t#endif\r\n\r\n#endif\r\n",fog_vertex:"\r\n#ifdef USE_FOG\r\nfogDepth = -mvPosition.z;\r\n#endif",fog_pars_vertex:"#ifdef USE_FOG\r\n\r\n varying float fogDepth;\r\n\r\n#endif\r\n",fog_fragment:"#ifdef USE_FOG\r\n\r\n\t#ifdef FOG_EXP2\r\n\r\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\r\n\r\n\t#else\r\n\r\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\r\n\r\n\t#endif\r\n\r\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\r\n\r\n#endif\r\n",fog_pars_fragment:"#ifdef USE_FOG\r\n\r\n\tuniform vec3 fogColor;\r\n\tvarying float fogDepth;\r\n\r\n\t#ifdef FOG_EXP2\r\n\r\n\t\tuniform float fogDensity;\r\n\r\n\t#else\r\n\r\n\t\tuniform float fogNear;\r\n\t\tuniform float fogFar;\r\n\r\n\t#endif\r\n\r\n#endif\r\n",gradientmap_pars_fragment:"#ifdef TOON\r\n\r\n\tuniform sampler2D gradientMap;\r\n\r\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\r\n\r\n\t\t// dotNL will be from -1.0 to 1.0\r\n\t\tfloat dotNL = dot( normal, lightDirection );\r\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\r\n\r\n\t\t#ifdef USE_GRADIENTMAP\r\n\r\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\r\n\r\n\t\t#else\r\n\r\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\r\n\r\n\t\t#endif\r\n\r\n\r\n\t}\r\n\r\n#endif\r\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\r\n\r\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage\r\n\r\n#endif\r\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\r\n\r\n\tuniform sampler2D lightMap;\r\n\tuniform float lightMapIntensity;\r\n\r\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\r\n\r\nGeometricContext geometry;\r\ngeometry.position = mvPosition.xyz;\r\ngeometry.normal = normalize( transformedNormal );\r\ngeometry.viewDir = normalize( -mvPosition.xyz );\r\n\r\nGeometricContext backGeometry;\r\nbackGeometry.position = geometry.position;\r\nbackGeometry.normal = -geometry.normal;\r\nbackGeometry.viewDir = geometry.viewDir;\r\n\r\nvLightFront = vec3( 0.0 );\r\n\r\n#ifdef DOUBLE_SIDED\r\n\tvLightBack = vec3( 0.0 );\r\n#endif\r\n\r\nIncidentLight directLight;\r\nfloat dotNL;\r\nvec3 directLightColor_Diffuse;\r\n\r\n#if NUM_POINT_LIGHTS > 0\r\n\r\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\r\n\r\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\r\n\r\n\t\tdotNL = dot( geometry.normal, directLight.direction );\r\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\r\n\r\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\r\n\r\n\t\t#ifdef DOUBLE_SIDED\r\n\r\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\r\n\r\n\t\t#endif\r\n\r\n\t}\r\n\r\n#endif\r\n\r\n#if NUM_SPOT_LIGHTS > 0\r\n\r\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\r\n\r\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\r\n\r\n\t\tdotNL = dot( geometry.normal, directLight.direction );\r\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\r\n\r\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\r\n\r\n\t\t#ifdef DOUBLE_SIDED\r\n\r\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\r\n\r\n\t\t#endif\r\n\t}\r\n\r\n#endif\r\n\r\n\r\n\r\n#if NUM_DIR_LIGHTS > 0\r\n\r\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n\r\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\r\n\r\n\t\tdotNL = dot( geometry.normal, directLight.direction );\r\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\r\n\r\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\r\n\r\n\t\t#ifdef DOUBLE_SIDED\r\n\r\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\r\n\r\n\t\t#endif\r\n\r\n\t}\r\n\r\n#endif\r\n\r\n#if NUM_HEMI_LIGHTS > 0\r\n\r\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\r\n\r\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\r\n\r\n\t\t#ifdef DOUBLE_SIDED\r\n\r\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\r\n\r\n\t\t#endif\r\n\r\n\t}\r\n\r\n#endif\r\n",lights_pars:"uniform vec3 ambientLightColor;\r\n\r\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\r\n\r\n\tvec3 irradiance = ambientLightColor;\r\n\r\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\r\n\r\n\t\tirradiance *= PI;\r\n\r\n\t#endif\r\n\r\n\treturn irradiance;\r\n\r\n}\r\n\r\n#if NUM_DIR_LIGHTS > 0\r\n\r\n\tstruct DirectionalLight {\r\n\t\tvec3 direction;\r\n\t\tvec3 color;\r\n\r\n\t\tint shadow;\r\n\t\tfloat shadowBias;\r\n\t\tfloat shadowRadius;\r\n\t\tvec2 shadowMapSize;\r\n\t};\r\n\r\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\r\n\r\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\r\n\r\n\t\tdirectLight.color = directionalLight.color;\r\n\t\tdirectLight.direction = directionalLight.direction;\r\n\t\tdirectLight.visible = true;\r\n\r\n\t}\r\n\r\n#endif\r\n\r\n\r\n#if NUM_POINT_LIGHTS > 0\r\n\r\n\tstruct PointLight {\r\n\t\tvec3 position;\r\n\t\tvec3 color;\r\n\t\tfloat distance;\r\n\t\tfloat decay;\r\n\r\n\t\tint shadow;\r\n\t\tfloat shadowBias;\r\n\t\tfloat shadowRadius;\r\n\t\tvec2 shadowMapSize;\r\n\t};\r\n\r\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\r\n\r\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\r\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\r\n\r\n\t\tvec3 lVector = pointLight.position - geometry.position;\r\n\t\tdirectLight.direction = normalize( lVector );\r\n\r\n\t\tfloat lightDistance = length( lVector );\r\n\r\n\t\tdirectLight.color = pointLight.color;\r\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\r\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\r\n\r\n\t}\r\n\r\n#endif\r\n\r\n\r\n#if NUM_SPOT_LIGHTS > 0\r\n\r\n\tstruct SpotLight {\r\n\t\tvec3 position;\r\n\t\tvec3 direction;\r\n\t\tvec3 color;\r\n\t\tfloat distance;\r\n\t\tfloat decay;\r\n\t\tfloat coneCos;\r\n\t\tfloat penumbraCos;\r\n\r\n\t\tint shadow;\r\n\t\tfloat shadowBias;\r\n\t\tfloat shadowRadius;\r\n\t\tvec2 shadowMapSize;\r\n\t};\r\n\r\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\r\n\r\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\r\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\r\n\r\n\t\tvec3 lVector = spotLight.position - geometry.position;\r\n\t\tdirectLight.direction = normalize( lVector );\r\n\r\n\t\tfloat lightDistance = length( lVector );\r\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\r\n\r\n\t\tif ( angleCos > spotLight.coneCos ) {\r\n\r\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\r\n\r\n\t\t\tdirectLight.color = spotLight.color;\r\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\r\n\t\t\tdirectLight.visible = true;\r\n\r\n\t\t} else {\r\n\r\n\t\t\tdirectLight.color = vec3( 0.0 );\r\n\t\t\tdirectLight.visible = false;\r\n\r\n\t\t}\r\n\t}\r\n\r\n#endif\r\n\r\n\r\n#if NUM_RECT_AREA_LIGHTS > 0\r\n\r\n\tstruct RectAreaLight {\r\n\t\tvec3 color;\r\n\t\tvec3 position;\r\n\t\tvec3 halfWidth;\r\n\t\tvec3 halfHeight;\r\n\t};\r\n\r\n\t// Pre-computed values of LinearTransformedCosine approximation of BRDF\r\n\t// BRDF approximation Texture is 64x64\r\n\tuniform sampler2D ltcMat; // RGBA Float\r\n\tuniform sampler2D ltcMag; // Alpha Float (only has w component)\r\n\r\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\r\n\r\n#endif\r\n\r\n\r\n#if NUM_HEMI_LIGHTS > 0\r\n\r\n\tstruct HemisphereLight {\r\n\t\tvec3 direction;\r\n\t\tvec3 skyColor;\r\n\t\tvec3 groundColor;\r\n\t};\r\n\r\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\r\n\r\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\r\n\r\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\r\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\r\n\r\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\r\n\r\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\r\n\r\n\t\t\tirradiance *= PI;\r\n\r\n\t\t#endif\r\n\r\n\t\treturn irradiance;\r\n\r\n\t}\r\n\r\n#endif\r\n\r\n\r\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\r\n\r\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\r\n\r\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\r\n\r\n\t\t#ifdef ENVMAP_TYPE_CUBE\r\n\r\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\r\n\r\n\t\t\t// TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level\r\n\t\t\t// of a specular cubemap, or just the default level of a specially created irradiance cubemap.\r\n\r\n\t\t\t#ifdef TEXTURE_LOD_EXT\r\n\r\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\r\n\r\n\t\t\t#else\r\n\r\n\t\t\t\t// force the bias high to get the last LOD level as it is the most blurred.\r\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\r\n\r\n\t\t\t#endif\r\n\r\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\r\n\r\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\r\n\r\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\r\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\r\n\r\n\t\t#else\r\n\r\n\t\t\tvec4 envMapColor = vec4( 0.0 );\r\n\r\n\t\t#endif\r\n\r\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\r\n\r\n\t}\r\n\r\n\t// taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html\r\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\r\n\r\n\t\t//float envMapWidth = pow( 2.0, maxMIPLevelScalar );\r\n\t\t//float desiredMIPLevel = log2( envMapWidth * sqrt( 3.0 ) ) - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\r\n\r\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\r\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\r\n\r\n\t\t// clamp to allowable LOD ranges.\r\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\r\n\r\n\t}\r\n\r\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\r\n\r\n\t\t#ifdef ENVMAP_MODE_REFLECTION\r\n\r\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\r\n\r\n\t\t#else\r\n\r\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\r\n\r\n\t\t#endif\r\n\r\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\r\n\r\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\r\n\r\n\t\t#ifdef ENVMAP_TYPE_CUBE\r\n\r\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\r\n\r\n\t\t\t#ifdef TEXTURE_LOD_EXT\r\n\r\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\r\n\r\n\t\t\t#else\r\n\r\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\r\n\r\n\t\t\t#endif\r\n\r\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\r\n\r\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\r\n\r\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\r\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\r\n\r\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\r\n\r\n\t\t\tvec2 sampleUV;\r\n\t\t\tsampleUV.y = saturate( reflectVec.y * 0.5 + 0.5 );\r\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\r\n\r\n\t\t\t#ifdef TEXTURE_LOD_EXT\r\n\r\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\r\n\r\n\t\t\t#else\r\n\r\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\r\n\r\n\t\t\t#endif\r\n\r\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\r\n\r\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\r\n\r\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\r\n\r\n\t\t\t#ifdef TEXTURE_LOD_EXT\r\n\r\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\r\n\r\n\t\t\t#else\r\n\r\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\r\n\r\n\t\t\t#endif\r\n\r\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\r\n\r\n\t\t#endif\r\n\r\n\t\treturn envMapColor.rgb * envMapIntensity;\r\n\r\n\t}\r\n\r\n#endif\r\n",lights_phong_fragment:"BlinnPhongMaterial material;\r\nmaterial.diffuseColor = diffuseColor.rgb;\r\nmaterial.specularColor = specular;\r\nmaterial.specularShininess = shininess;\r\nmaterial.specularStrength = specularStrength;\r\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\r\n\r\n#ifndef FLAT_SHADED\r\n\r\n\tvarying vec3 vNormal;\r\n\r\n#endif\r\n\r\n\r\nstruct BlinnPhongMaterial {\r\n\r\n\tvec3\tdiffuseColor;\r\n\tvec3\tspecularColor;\r\n\tfloat\tspecularShininess;\r\n\tfloat\tspecularStrength;\r\n\r\n};\r\n\r\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n\r\n\t#ifdef TOON\r\n\r\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\r\n\r\n\t#else\r\n\r\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\r\n\t\tvec3 irradiance = dotNL * directLight.color;\r\n\r\n\t#endif\r\n\r\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\r\n\r\n\t\tirradiance *= PI; // punctual light\r\n\r\n\t#endif\r\n\r\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n\r\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\r\n\r\n}\r\n\r\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n\r\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n\r\n}\r\n\r\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\r\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\r\n\r\n#define Material_LightProbeLOD( material )\t(0)\r\n",lights_physical_fragment:"PhysicalMaterial material;\r\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\r\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\r\n#ifdef STANDARD\r\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\r\n#else\r\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\r\n\tmaterial.clearCoat = saturate( clearCoat ); // Burley clearcoat model\r\n\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\r\n#endif\r\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\r\n\r\n\tvec3\tdiffuseColor;\r\n\tfloat\tspecularRoughness;\r\n\tvec3\tspecularColor;\r\n\r\n\t#ifndef STANDARD\r\n\t\tfloat clearCoat;\r\n\t\tfloat clearCoatRoughness;\r\n\t#endif\r\n\r\n};\r\n\r\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\r\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\r\n\r\n// Clear coat directional hemishperical reflectance (this approximation should be improved)\r\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\r\n\r\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\r\n\r\n}\r\n\r\n#if NUM_RECT_AREA_LIGHTS > 0\r\n\r\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\r\n\r\n\t\tvec3 normal = geometry.normal;\r\n\t\tvec3 viewDir = geometry.viewDir;\r\n\t\tvec3 position = geometry.position;\r\n\t\tvec3 lightPos = rectAreaLight.position;\r\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\r\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\r\n\t\tvec3 lightColor = rectAreaLight.color;\r\n\t\tfloat roughness = material.specularRoughness;\r\n\r\n\t\tvec3 rectCoords[ 4 ];\r\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight; // counterclockwise\r\n\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\r\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\r\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\r\n\r\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\r\n\r\n\t\tfloat norm = texture2D( ltcMag, uv ).a;\r\n\r\n\t\tvec4 t = texture2D( ltcMat, uv );\r\n\r\n\t\tmat3 mInv = mat3(\r\n\t\t\tvec3( 1, 0, t.y ),\r\n\t\t\tvec3( 0, t.z, 0 ),\r\n\t\t\tvec3( t.w, 0, t.x )\r\n\t\t);\r\n\r\n\t\treflectedLight.directSpecular += lightColor * material.specularColor * norm * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); // no fresnel\r\n\r\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1 ), rectCoords );\r\n\r\n\t}\r\n\r\n#endif\r\n\r\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\r\n\r\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\r\n\r\n\tvec3 irradiance = dotNL * directLight.color;\r\n\r\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\r\n\r\n\t\tirradiance *= PI; // punctual light\r\n\r\n\t#endif\r\n\r\n\t#ifndef STANDARD\r\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\r\n\t#else\r\n\t\tfloat clearCoatDHR = 0.0;\r\n\t#endif\r\n\r\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\r\n\r\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n\r\n\t#ifndef STANDARD\r\n\r\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\r\n\r\n\t#endif\r\n\r\n}\r\n\r\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\r\n\r\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n\r\n}\r\n\r\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\r\n\r\n\t#ifndef STANDARD\r\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\r\n\t\tfloat dotNL = dotNV;\r\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\r\n\t#else\r\n\t\tfloat clearCoatDHR = 0.0;\r\n\t#endif\r\n\r\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\r\n\r\n\t#ifndef STANDARD\r\n\r\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\r\n\r\n\t#endif\r\n\r\n}\r\n\r\n#define RE_Direct\t\t\t\tRE_Direct_Physical\r\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\r\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\r\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\r\n\r\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\r\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\r\n\r\n// ref: http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr_v2.pdf\r\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\r\n\r\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\r\n\r\n}\r\n",lights_template:"\r\n\r\nGeometricContext geometry;\r\n\r\ngeometry.position = - vViewPosition;\r\ngeometry.normal = normal;\r\ngeometry.viewDir = normalize( vViewPosition );\r\n\r\nIncidentLight directLight;\r\n\r\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\r\n\r\n\tPointLight pointLight;\r\n\r\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\r\n\r\n\t\tpointLight = pointLights[ i ];\r\n\r\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\r\n\r\n\t\t#ifdef USE_SHADOWMAP\r\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\r\n\t\t#endif\r\n\r\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\r\n\r\n\t}\r\n\r\n#endif\r\n\r\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\r\n\r\n\tSpotLight spotLight;\r\n\r\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\r\n\r\n\t\tspotLight = spotLights[ i ];\r\n\r\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\r\n\r\n\t\t#ifdef USE_SHADOWMAP\r\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\r\n\t\t#endif\r\n\r\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\r\n\r\n\t}\r\n\r\n#endif\r\n\r\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\r\n\r\n\tDirectionalLight directionalLight;\r\n\r\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n\r\n\t\tdirectionalLight = directionalLights[ i ];\r\n\r\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\r\n\r\n\t\t#ifdef USE_SHADOWMAP\r\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\r\n\t\t#endif\r\n\r\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\r\n\r\n\t}\r\n\r\n#endif\r\n\r\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\r\n\r\n\tRectAreaLight rectAreaLight;\r\n\r\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\r\n\r\n\t\trectAreaLight = rectAreaLights[ i ];\r\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\r\n\r\n\t}\r\n\r\n#endif\r\n\r\n#if defined( RE_IndirectDiffuse )\r\n\r\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\r\n\r\n\t#ifdef USE_LIGHTMAP\r\n\r\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\r\n\r\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\r\n\r\n\t\t\tlightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage\r\n\r\n\t\t#endif\r\n\r\n\t\tirradiance += lightMapIrradiance;\r\n\r\n\t#endif\r\n\r\n\t#if ( NUM_HEMI_LIGHTS > 0 )\r\n\r\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\r\n\r\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\r\n\r\n\t\t}\r\n\r\n\t#endif\r\n\r\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\r\n\r\n\t\t// TODO, replace 8 with the real maxMIPLevel\r\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\r\n\r\n\t#endif\r\n\r\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\r\n\r\n#endif\r\n\r\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\r\n\r\n\t// TODO, replace 8 with the real maxMIPLevel\r\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\r\n\r\n\t#ifndef STANDARD\r\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\r\n\t#else\r\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\r\n\t#endif\r\n\r\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\r\n\r\n#endif\r\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\r\n\r\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\r\n\r\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\r\n\r\n\tuniform float logDepthBufFC;\r\n\r\n\t#ifdef USE_LOGDEPTHBUF_EXT\r\n\r\n\t\tvarying float vFragDepth;\r\n\r\n\t#endif\r\n\r\n#endif\r\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\r\n\r\n\t#ifdef USE_LOGDEPTHBUF_EXT\r\n\r\n\t\tvarying float vFragDepth;\r\n\r\n\t#endif\r\n\r\n\tuniform float logDepthBufFC;\r\n\r\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\r\n\r\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\r\n\r\n\t#ifdef USE_LOGDEPTHBUF_EXT\r\n\r\n\t\tvFragDepth = 1.0 + gl_Position.w;\r\n\r\n\t#else\r\n\r\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\r\n\r\n\t#endif\r\n\r\n#endif\r\n",map_fragment:"#ifdef USE_MAP\r\n\r\n\tvec4 texelColor = texture2D( map, vUv );\r\n\r\n\ttexelColor = mapTexelToLinear( texelColor );\r\n\tdiffuseColor *= texelColor;\r\n\r\n#endif\r\n",map_pars_fragment:"#ifdef USE_MAP\r\n\r\n\tuniform sampler2D map;\r\n\r\n#endif\r\n",map_particle_fragment:"#ifdef USE_MAP\r\n\r\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\r\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\r\n\r\n#endif\r\n",map_particle_pars_fragment:"#ifdef USE_MAP\r\n\r\n\tuniform vec4 offsetRepeat;\r\n\tuniform sampler2D map;\r\n\r\n#endif\r\n",metalnessmap_fragment:"float metalnessFactor = metalness;\r\n\r\n#ifdef USE_METALNESSMAP\r\n\r\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\r\n\r\n\t// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\r\n\tmetalnessFactor *= texelMetalness.b;\r\n\r\n#endif\r\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\r\n\r\n\tuniform sampler2D metalnessMap;\r\n\r\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\r\n\r\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\r\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\r\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\r\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\r\n\r\n#endif\r\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\r\n\r\n\t#ifndef USE_MORPHNORMALS\r\n\r\n\tuniform float morphTargetInfluences[ 8 ];\r\n\r\n\t#else\r\n\r\n\tuniform float morphTargetInfluences[ 4 ];\r\n\r\n\t#endif\r\n\r\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\r\n\r\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\r\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\r\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\r\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\r\n\r\n\t#ifndef USE_MORPHNORMALS\r\n\r\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\r\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\r\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\r\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\r\n\r\n\t#endif\r\n\r\n#endif\r\n",normal_flip:"#ifdef DOUBLE_SIDED\r\n\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\r\n#else\r\n\tfloat flipNormal = 1.0;\r\n#endif\r\n",normal_fragment:"#ifdef FLAT_SHADED\r\n\r\n\t// Workaround for Adreno/Nexus5 not able able to do dFdx( vViewPosition ) ...\r\n\r\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\r\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\r\n\tvec3 normal = normalize( cross( fdx, fdy ) );\r\n\r\n#else\r\n\r\n\tvec3 normal = normalize( vNormal ) * flipNormal;\r\n\r\n#endif\r\n\r\n#ifdef USE_NORMALMAP\r\n\r\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\r\n\r\n#elif defined( USE_BUMPMAP )\r\n\r\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\r\n\r\n#endif\r\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\r\n\r\n\tuniform sampler2D normalMap;\r\n\tuniform vec2 normalScale;\r\n\r\n\t// Per-Pixel Tangent Space Normal Mapping\r\n\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\r\n\r\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\r\n\r\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\r\n\r\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\r\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\r\n\t\tvec2 st0 = dFdx( vUv.st );\r\n\t\tvec2 st1 = dFdy( vUv.st );\r\n\r\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\r\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\r\n\t\tvec3 N = normalize( surf_norm );\r\n\r\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\r\n\t\tmapN.xy = normalScale * mapN.xy;\r\n\t\tmat3 tsn = mat3( S, T, N );\r\n\t\treturn normalize( tsn * mapN );\r\n\r\n\t}\r\n\r\n#endif\r\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\r\n\treturn normalize( normal ) * 0.5 + 0.5;\r\n}\r\n\r\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\r\n\treturn 1.0 - 2.0 * rgb.xyz;\r\n}\r\n\r\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\r\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\r\n\r\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\r\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\r\n\r\nconst float ShiftRight8 = 1. / 256.;\r\n\r\nvec4 packDepthToRGBA( const in float v ) {\r\n\tvec4 r = vec4( fract( v * PackFactors ), v );\r\n\tr.yzw -= r.xyz * ShiftRight8; // tidy overflow\r\n\treturn r * PackUpscale;\r\n}\r\n\r\nfloat unpackRGBAToDepth( const in vec4 v ) {\r\n\treturn dot( v, UnpackFactors );\r\n}\r\n\r\n// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions\r\n\r\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\r\n\treturn ( viewZ + near ) / ( near - far );\r\n}\r\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\r\n\treturn linearClipZ * ( near - far ) - near;\r\n}\r\n\r\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\r\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\r\n}\r\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\r\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\r\n}\r\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\r\n\r\n\t// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.\r\n\tgl_FragColor.rgb *= gl_FragColor.a;\r\n\r\n#endif\r\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\r\n\r\ngl_Position = projectionMatrix * mvPosition;\r\n",dithering_fragment:"#if defined( DITHERING )\r\n\r\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\r\n\r\n#endif\r\n",dithering_pars_fragment:"#if defined( DITHERING )\r\n\r\n\t// based on https://www.shadertoy.com/view/MslGR8\r\n\tvec3 dithering( vec3 color ) {\r\n\t\t//Calculate grid position\r\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\r\n\r\n\t\t//Shift the individual colors differently, thus making it even harder to see the dithering pattern\r\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\r\n\r\n\t\t//modify shift acording to grid position.\r\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\r\n\r\n\t\t//shift the color by dither_shift\r\n\t\treturn color + dither_shift_RGB;\r\n\t}\r\n\r\n#endif\r\n",roughnessmap_fragment:"float roughnessFactor = roughness;\r\n\r\n#ifdef USE_ROUGHNESSMAP\r\n\r\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\r\n\r\n\t// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\r\n\troughnessFactor *= texelRoughness.g;\r\n\r\n#endif\r\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\r\n\r\n\tuniform sampler2D roughnessMap;\r\n\r\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\r\n\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\r\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\r\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\r\n\r\n\t#endif\r\n\r\n\t#if NUM_SPOT_LIGHTS > 0\r\n\r\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\r\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\r\n\r\n\t#endif\r\n\r\n\t#if NUM_POINT_LIGHTS > 0\r\n\r\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\r\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\r\n\r\n\t#endif\r\n\r\n\r\n\r\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\r\n\r\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\r\n\r\n\t}\r\n\r\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\r\n\r\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\r\n\r\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\r\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\r\n\r\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\r\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\r\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\r\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\r\n\r\n\t\tvec2 f = fract( uv * size + 0.5 );\r\n\r\n\t\tfloat a = mix( lb, lt, f.y );\r\n\t\tfloat b = mix( rb, rt, f.y );\r\n\t\tfloat c = mix( a, b, f.x );\r\n\r\n\t\treturn c;\r\n\r\n\t}\r\n\r\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\r\n\r\n\t\tfloat shadow = 1.0;\r\n\r\n\t\tshadowCoord.xyz /= shadowCoord.w;\r\n\t\tshadowCoord.z += shadowBias;\r\n\r\n\t\t// if ( something && something ) breaks ATI OpenGL shader compiler\r\n\t\t// if ( all( something, something ) ) using this instead\r\n\r\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\r\n\t\tbool inFrustum = all( inFrustumVec );\r\n\r\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\r\n\r\n\t\tbool frustumTest = all( frustumTestVec );\r\n\r\n\t\tif ( frustumTest ) {\r\n\r\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\r\n\r\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\r\n\r\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\r\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\r\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\r\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\r\n\r\n\t\t\tshadow = (\r\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\r\n\t\t\t) * ( 1.0 / 9.0 );\r\n\r\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\r\n\r\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\r\n\r\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\r\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\r\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\r\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\r\n\r\n\t\t\tshadow = (\r\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\r\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\r\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\r\n\t\t\t) * ( 1.0 / 9.0 );\r\n\r\n\t\t#else // no percentage-closer filtering:\r\n\r\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\r\n\r\n\t\t#endif\r\n\r\n\t\t}\r\n\r\n\t\treturn shadow;\r\n\r\n\t}\r\n\r\n\t// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D\r\n\t// vector suitable for 2D texture mapping. This code uses the following layout for the\r\n\t// 2D texture:\r\n\t//\r\n\t// xzXZ\r\n\t// y Y\r\n\t//\r\n\t// Y - Positive y direction\r\n\t// y - Negative y direction\r\n\t// X - Positive x direction\r\n\t// x - Negative x direction\r\n\t// Z - Positive z direction\r\n\t// z - Negative z direction\r\n\t//\r\n\t// Source and test bed:\r\n\t// https://gist.github.com/tschw/da10c43c467ce8afd0c4\r\n\r\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\r\n\r\n\t\t// Number of texels to avoid at the edge of each square\r\n\r\n\t\tvec3 absV = abs( v );\r\n\r\n\t\t// Intersect unit cube\r\n\r\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\r\n\t\tabsV *= scaleToCube;\r\n\r\n\t\t// Apply scale to avoid seams\r\n\r\n\t\t// two texels less per square (one texel will do for NEAREST)\r\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\r\n\r\n\t\t// Unwrap\r\n\r\n\t\t// space: -1 ... 1 range for each square\r\n\t\t//\r\n\t\t// #X##\t\tdim := ( 4 , 2 )\r\n\t\t// # #\t\tcenter := ( 1 , 1 )\r\n\r\n\t\tvec2 planar = v.xy;\r\n\r\n\t\tfloat almostATexel = 1.5 * texelSizeY;\r\n\t\tfloat almostOne = 1.0 - almostATexel;\r\n\r\n\t\tif ( absV.z >= almostOne ) {\r\n\r\n\t\t\tif ( v.z > 0.0 )\r\n\t\t\t\tplanar.x = 4.0 - v.x;\r\n\r\n\t\t} else if ( absV.x >= almostOne ) {\r\n\r\n\t\t\tfloat signX = sign( v.x );\r\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\r\n\r\n\t\t} else if ( absV.y >= almostOne ) {\r\n\r\n\t\t\tfloat signY = sign( v.y );\r\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\r\n\t\t\tplanar.y = v.z * signY - 2.0;\r\n\r\n\t\t}\r\n\r\n\t\t// Transform to UV space\r\n\r\n\t\t// scale := 0.5 / dim\r\n\t\t// translate := ( center + 0.5 ) / dim\r\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\r\n\r\n\t}\r\n\r\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\r\n\r\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\r\n\r\n\t\t// for point lights, the uniform @vShadowCoord is re-purposed to hold\r\n\t\t// the distance from the light to the world-space position of the fragment.\r\n\t\tvec3 lightToPosition = shadowCoord.xyz;\r\n\r\n\t\t// bd3D = base direction 3D\r\n\t\tvec3 bd3D = normalize( lightToPosition );\r\n\t\t// dp = distance from light to fragment position\r\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\r\n\r\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\r\n\r\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\r\n\r\n\t\t\treturn (\r\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\r\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\r\n\t\t\t) * ( 1.0 / 9.0 );\r\n\r\n\t\t#else // no percentage-closer filtering\r\n\r\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\r\n\r\n\t\t#endif\r\n\r\n\t}\r\n\r\n#endif\r\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\r\n\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\r\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\r\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\r\n\r\n\t#endif\r\n\r\n\t#if NUM_SPOT_LIGHTS > 0\r\n\r\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\r\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\r\n\r\n\t#endif\r\n\r\n\t#if NUM_POINT_LIGHTS > 0\r\n\r\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\r\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\r\n\r\n\t#endif\r\n\r\n\r\n\r\n#endif\r\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\r\n\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\r\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n\r\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\r\n\r\n\t}\r\n\r\n\t#endif\r\n\r\n\t#if NUM_SPOT_LIGHTS > 0\r\n\r\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\r\n\r\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\r\n\r\n\t}\r\n\r\n\t#endif\r\n\r\n\t#if NUM_POINT_LIGHTS > 0\r\n\r\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\r\n\r\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\r\n\r\n\t}\r\n\r\n\t#endif\r\n\r\n\r\n\r\n#endif\r\n",shadowmask_pars_fragment:"float getShadowMask() {\r\n\r\n\tfloat shadow = 1.0;\r\n\r\n\t#ifdef USE_SHADOWMAP\r\n\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\r\n\tDirectionalLight directionalLight;\r\n\r\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n\r\n\t\tdirectionalLight = directionalLights[ i ];\r\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\r\n\r\n\t}\r\n\r\n\t#endif\r\n\r\n\t#if NUM_SPOT_LIGHTS > 0\r\n\r\n\tSpotLight spotLight;\r\n\r\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\r\n\r\n\t\tspotLight = spotLights[ i ];\r\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\r\n\r\n\t}\r\n\r\n\t#endif\r\n\r\n\t#if NUM_POINT_LIGHTS > 0\r\n\r\n\tPointLight pointLight;\r\n\r\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\r\n\r\n\t\tpointLight = pointLights[ i ];\r\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\r\n\r\n\t}\r\n\r\n\t#endif\r\n\r\n\r\n\r\n\t#endif\r\n\r\n\treturn shadow;\r\n\r\n}\r\n",skinbase_vertex:"#ifdef USE_SKINNING\r\n\r\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\r\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\r\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\r\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\r\n\r\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\r\n\r\n\tuniform mat4 bindMatrix;\r\n\tuniform mat4 bindMatrixInverse;\r\n\r\n\t#ifdef BONE_TEXTURE\r\n\r\n\t\tuniform sampler2D boneTexture;\r\n\t\tuniform int boneTextureSize;\r\n\r\n\t\tmat4 getBoneMatrix( const in float i ) {\r\n\r\n\t\t\tfloat j = i * 4.0;\r\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\r\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\r\n\r\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\r\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\r\n\r\n\t\t\ty = dy * ( y + 0.5 );\r\n\r\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\r\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\r\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\r\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\r\n\r\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\r\n\r\n\t\t\treturn bone;\r\n\r\n\t\t}\r\n\r\n\t#else\r\n\r\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\r\n\r\n\t\tmat4 getBoneMatrix( const in float i ) {\r\n\r\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\r\n\t\t\treturn bone;\r\n\r\n\t\t}\r\n\r\n\t#endif\r\n\r\n#endif\r\n",skinning_vertex:"#ifdef USE_SKINNING\r\n\r\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\r\n\r\n\tvec4 skinned = vec4( 0.0 );\r\n\tskinned += boneMatX * skinVertex * skinWeight.x;\r\n\tskinned += boneMatY * skinVertex * skinWeight.y;\r\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\r\n\tskinned += boneMatW * skinVertex * skinWeight.w;\r\n\r\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\r\n\r\n#endif\r\n",skinnormal_vertex:"#ifdef USE_SKINNING\r\n\r\n\tmat4 skinMatrix = mat4( 0.0 );\r\n\tskinMatrix += skinWeight.x * boneMatX;\r\n\tskinMatrix += skinWeight.y * boneMatY;\r\n\tskinMatrix += skinWeight.z * boneMatZ;\r\n\tskinMatrix += skinWeight.w * boneMatW;\r\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\r\n\r\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\r\n\r\n#endif\r\n",specularmap_fragment:"float specularStrength;\r\n\r\n#ifdef USE_SPECULARMAP\r\n\r\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\r\n\tspecularStrength = texelSpecular.r;\r\n\r\n#else\r\n\r\n\tspecularStrength = 1.0;\r\n\r\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\r\n\r\n\tuniform sampler2D specularMap;\r\n\r\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\r\n\r\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\r\n\r\n#endif\r\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\r\n\r\nuniform float toneMappingExposure;\r\nuniform float toneMappingWhitePoint;\r\n\r\n// exposure only\r\nvec3 LinearToneMapping( vec3 color ) {\r\n\r\n\treturn toneMappingExposure * color;\r\n\r\n}\r\n\r\n// source: https://www.cs.utah.edu/~reinhard/cdrom/\r\nvec3 ReinhardToneMapping( vec3 color ) {\r\n\r\n\tcolor *= toneMappingExposure;\r\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\r\n\r\n}\r\n\r\n// source: http://filmicgames.com/archives/75\r\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\r\nvec3 Uncharted2ToneMapping( vec3 color ) {\r\n\r\n\t// John Hable's filmic operator from Uncharted 2 video game\r\n\tcolor *= toneMappingExposure;\r\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\r\n\r\n}\r\n\r\n// source: http://filmicgames.com/archives/75\r\nvec3 OptimizedCineonToneMapping( vec3 color ) {\r\n\r\n\t// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson\r\n\tcolor *= toneMappingExposure;\r\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\r\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\r\n\r\n}\r\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\r\n\r\n\tvarying vec2 vUv;\r\n\r\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\r\n\r\n\tvarying vec2 vUv;\r\n\tuniform vec4 offsetRepeat;\r\n\r\n#endif\r\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\r\n\r\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\r\n\r\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\r\n\r\n\tvarying vec2 vUv2;\r\n\r\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\r\n\r\n\tattribute vec2 uv2;\r\n\tvarying vec2 vUv2;\r\n\r\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\r\n\r\n\tvUv2 = uv2;\r\n\r\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\r\n\r\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\r\n\r\n#endif\r\n",cube_frag:"uniform samplerCube tCube;\r\nuniform float tFlip;\r\nuniform float opacity;\r\n\r\nvarying vec3 vWorldPosition;\r\n\r\n#include <common>\r\n\r\nvoid main() {\r\n\r\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\r\n\tgl_FragColor.a *= opacity;\r\n\r\n}\r\n",cube_vert:"varying vec3 vWorldPosition;\r\n\r\n#include <common>\r\n\r\nvoid main() {\r\n\r\n\tvWorldPosition = transformDirection( position, modelMatrix );\r\n\r\n\t#include <begin_vertex>\r\n\t#include <project_vertex>\r\n\r\n}\r\n",depth_frag:"#if DEPTH_PACKING == 3200\r\n\r\n\tuniform float opacity;\r\n\r\n#endif\r\n\r\n#include <common>\r\n#include <packing>\r\n#include <uv_pars_fragment>\r\n#include <map_pars_fragment>\r\n#include <alphamap_pars_fragment>\r\n#include <logdepthbuf_pars_fragment>\r\n#include <clipping_planes_pars_fragment>\r\n\r\nvoid main() {\r\n\r\n\t#include <clipping_planes_fragment>\r\n\r\n\tvec4 diffuseColor = vec4( 1.0 );\r\n\r\n\t#if DEPTH_PACKING == 3200\r\n\r\n\t\tdiffuseColor.a = opacity;\r\n\r\n\t#endif\r\n\r\n\t#include <map_fragment>\r\n\t#include <alphamap_fragment>\r\n\t#include <alphatest_fragment>\r\n\r\n\t#include <logdepthbuf_fragment>\r\n\r\n\t#if DEPTH_PACKING == 3200\r\n\r\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\r\n\r\n\t#elif DEPTH_PACKING == 3201\r\n\r\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\r\n\r\n\t#endif\r\n\r\n}\r\n",depth_vert:"#include <common>\r\n#include <uv_pars_vertex>\r\n#include <displacementmap_pars_vertex>\r\n#include <morphtarget_pars_vertex>\r\n#include <skinning_pars_vertex>\r\n#include <logdepthbuf_pars_vertex>\r\n#include <clipping_planes_pars_vertex>\r\n\r\nvoid main() {\r\n\r\n\t#include <uv_vertex>\r\n\r\n\t#include <skinbase_vertex>\r\n\r\n\t#ifdef USE_DISPLACEMENTMAP\r\n\r\n\t\t#include <beginnormal_vertex>\r\n\t\t#include <morphnormal_vertex>\r\n\t\t#include <skinnormal_vertex>\r\n\r\n\t#endif\r\n\r\n\t#include <begin_vertex>\r\n\t#include <morphtarget_vertex>\r\n\t#include <skinning_vertex>\r\n\t#include <displacementmap_vertex>\r\n\t#include <project_vertex>\r\n\t#include <logdepthbuf_vertex>\r\n\t#include <clipping_planes_vertex>\r\n\r\n}\r\n",distanceRGBA_frag:"uniform vec3 lightPos;\r\nvarying vec4 vWorldPosition;\r\n\r\n#include <common>\r\n#include <packing>\r\n#include <clipping_planes_pars_fragment>\r\n\r\nvoid main () {\r\n\r\n\t#include <clipping_planes_fragment>\r\n\r\n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\r\n\r\n}\r\n",distanceRGBA_vert:"varying vec4 vWorldPosition;\r\n\r\n#include <common>\r\n#include <morphtarget_pars_vertex>\r\n#include <skinning_pars_vertex>\r\n#include <clipping_planes_pars_vertex>\r\n\r\nvoid main() {\r\n\r\n\t#include <skinbase_vertex>\r\n\t#include <begin_vertex>\r\n\t#include <morphtarget_vertex>\r\n\t#include <skinning_vertex>\r\n\t#include <project_vertex>\r\n\t#include <worldpos_vertex>\r\n\t#include <clipping_planes_vertex>\r\n\r\n\tvWorldPosition = worldPosition;\r\n\r\n}\r\n",equirect_frag:"uniform sampler2D tEquirect;\r\nuniform float tFlip;\r\n\r\nvarying vec3 vWorldPosition;\r\n\r\n#include <common>\r\n\r\nvoid main() {\r\n\r\n\t// \tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\r\n\tvec3 direction = normalize( vWorldPosition );\r\n\tvec2 sampleUV;\r\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\r\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\r\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\r\n\r\n}\r\n",equirect_vert:"varying vec3 vWorldPosition;\r\n\r\n#include <common>\r\n\r\nvoid main() {\r\n\r\n\tvWorldPosition = transformDirection( position, modelMatrix );\r\n\r\n\t#include <begin_vertex>\r\n\t#include <project_vertex>\r\n\r\n}\r\n",linedashed_frag:"uniform vec3 diffuse;\r\nuniform float opacity;\r\n\r\nuniform float dashSize;\r\nuniform float totalSize;\r\n\r\nvarying float vLineDistance;\r\n\r\n#include <common>\r\n#include <color_pars_fragment>\r\n#include <fog_pars_fragment>\r\n#include <logdepthbuf_pars_fragment>\r\n#include <clipping_planes_pars_fragment>\r\n\r\nvoid main() {\r\n\r\n\t#include <clipping_planes_fragment>\r\n\r\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\r\n\r\n\t\tdiscard;\r\n\r\n\t}\r\n\r\n\tvec3 outgoingLight = vec3( 0.0 );\r\n\tvec4 diffuseColor = vec4( diffuse, opacity );\r\n\r\n\t#include <logdepthbuf_fragment>\r\n\t#include <color_fragment>\r\n\r\n\toutgoingLight = diffuseColor.rgb; // simple shader\r\n\r\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\r\n\r\n\t#include <premultiplied_alpha_fragment>\r\n\t#include <tonemapping_fragment>\r\n\t#include <encodings_fragment>\r\n\t#include <fog_fragment>\r\n\r\n}\r\n",linedashed_vert:"uniform float scale;\r\nattribute float lineDistance;\r\n\r\nvarying float vLineDistance;\r\n\r\n#include <common>\r\n#include <color_pars_vertex>\r\n#include <fog_pars_vertex>\r\n#include <logdepthbuf_pars_vertex>\r\n#include <clipping_planes_pars_vertex>\r\n\r\nvoid main() {\r\n\r\n\t#include <color_vertex>\r\n\r\n\tvLineDistance = scale * lineDistance;\r\n\r\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\r\n\tgl_Position = projectionMatrix * mvPosition;\r\n\r\n\t#include <logdepthbuf_vertex>\r\n\t#include <clipping_planes_vertex>\r\n\t#include <fog_vertex>\r\n\r\n}\r\n",meshbasic_frag:"uniform vec3 diffuse;\r\nuniform float opacity;\r\n\r\n#ifndef FLAT_SHADED\r\n\r\n\tvarying vec3 vNormal;\r\n\r\n#endif\r\n\r\n#include <common>\r\n#include <color_pars_fragment>\r\n#include <uv_pars_fragment>\r\n#include <uv2_pars_fragment>\r\n#include <map_pars_fragment>\r\n#include <alphamap_pars_fragment>\r\n#include <aomap_pars_fragment>\r\n#include <lightmap_pars_fragment>\r\n#include <envmap_pars_fragment>\r\n#include <fog_pars_fragment>\r\n#include <specularmap_pars_fragment>\r\n#include <logdepthbuf_pars_fragment>\r\n#include <clipping_planes_pars_fragment>\r\n\r\nvoid main() {\r\n\r\n\t#include <clipping_planes_fragment>\r\n\r\n\tvec4 diffuseColor = vec4( diffuse, opacity );\r\n\r\n\t#include <logdepthbuf_fragment>\r\n\t#include <map_fragment>\r\n\t#include <color_fragment>\r\n\t#include <alphamap_fragment>\r\n\t#include <alphatest_fragment>\r\n\t#include <specularmap_fragment>\r\n\r\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\r\n\r\n\t// accumulation (baked indirect lighting only)\r\n\t#ifdef USE_LIGHTMAP\r\n\r\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\r\n\r\n\t#else\r\n\r\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\r\n\r\n\t#endif\r\n\r\n\t// modulation\r\n\t#include <aomap_fragment>\r\n\r\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\r\n\r\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\r\n\r\n\t#include <normal_flip>\r\n\t#include <envmap_fragment>\r\n\r\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\r\n\r\n\t#include <premultiplied_alpha_fragment>\r\n\t#include <tonemapping_fragment>\r\n\t#include <encodings_fragment>\r\n\t#include <fog_fragment>\r\n\r\n}\r\n",meshbasic_vert:"#include <common>\r\n#include <uv_pars_vertex>\r\n#include <uv2_pars_vertex>\r\n#include <envmap_pars_vertex>\r\n#include <color_pars_vertex>\r\n#include <fog_pars_vertex>\r\n#include <morphtarget_pars_vertex>\r\n#include <skinning_pars_vertex>\r\n#include <logdepthbuf_pars_vertex>\r\n#include <clipping_planes_pars_vertex>\r\n\r\nvoid main() {\r\n\r\n\t#include <uv_vertex>\r\n\t#include <uv2_vertex>\r\n\t#include <color_vertex>\r\n\t#include <skinbase_vertex>\r\n\r\n\t#ifdef USE_ENVMAP\r\n\r\n\t#include <beginnormal_vertex>\r\n\t#include <morphnormal_vertex>\r\n\t#include <skinnormal_vertex>\r\n\t#include <defaultnormal_vertex>\r\n\r\n\t#endif\r\n\r\n\t#include <begin_vertex>\r\n\t#include <morphtarget_vertex>\r\n\t#include <skinning_vertex>\r\n\t#include <project_vertex>\r\n\t#include <logdepthbuf_vertex>\r\n\r\n\t#include <worldpos_vertex>\r\n\t#include <clipping_planes_vertex>\r\n\t#include <envmap_vertex>\r\n\t#include <fog_vertex>\r\n\r\n}\r\n",meshlambert_frag:"uniform vec3 diffuse;\r\nuniform vec3 emissive;\r\nuniform float opacity;\r\n\r\nvarying vec3 vLightFront;\r\n\r\n#ifdef DOUBLE_SIDED\r\n\r\n\tvarying vec3 vLightBack;\r\n\r\n#endif\r\n\r\n#include <common>\r\n#include <packing>\r\n#include <dithering_pars_fragment>\r\n#include <color_pars_fragment>\r\n#include <uv_pars_fragment>\r\n#include <uv2_pars_fragment>\r\n#include <map_pars_fragment>\r\n#include <alphamap_pars_fragment>\r\n#include <aomap_pars_fragment>\r\n#include <lightmap_pars_fragment>\r\n#include <emissivemap_pars_fragment>\r\n#include <envmap_pars_fragment>\r\n#include <bsdfs>\r\n#include <lights_pars>\r\n#include <fog_pars_fragment>\r\n#include <shadowmap_pars_fragment>\r\n#include <shadowmask_pars_fragment>\r\n#include <specularmap_pars_fragment>\r\n#include <logdepthbuf_pars_fragment>\r\n#include <clipping_planes_pars_fragment>\r\n\r\nvoid main() {\r\n\r\n\t#include <clipping_planes_fragment>\r\n\r\n\tvec4 diffuseColor = vec4( diffuse, opacity );\r\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\r\n\tvec3 totalEmissiveRadiance = emissive;\r\n\r\n\t#include <logdepthbuf_fragment>\r\n\t#include <map_fragment>\r\n\t#include <color_fragment>\r\n\t#include <alphamap_fragment>\r\n\t#include <alphatest_fragment>\r\n\t#include <specularmap_fragment>\r\n\t#include <emissivemap_fragment>\r\n\r\n\t// accumulation\r\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\r\n\r\n\t#include <lightmap_fragment>\r\n\r\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\r\n\r\n\t#ifdef DOUBLE_SIDED\r\n\r\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\r\n\r\n\t#else\r\n\r\n\t\treflectedLight.directDiffuse = vLightFront;\r\n\r\n\t#endif\r\n\r\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\r\n\r\n\t// modulation\r\n\t#include <aomap_fragment>\r\n\r\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\r\n\r\n\t#include <normal_flip>\r\n\t#include <envmap_fragment>\r\n\r\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\r\n\r\n\t#include <tonemapping_fragment>\r\n\t#include <encodings_fragment>\r\n\t#include <fog_fragment>\r\n\t#include <premultiplied_alpha_fragment>\r\n\t#include <dithering_fragment>\r\n\r\n}\r\n",meshlambert_vert:"#define LAMBERT\r\n\r\nvarying vec3 vLightFront;\r\n\r\n#ifdef DOUBLE_SIDED\r\n\r\n\tvarying vec3 vLightBack;\r\n\r\n#endif\r\n\r\n#include <common>\r\n#include <uv_pars_vertex>\r\n#include <uv2_pars_vertex>\r\n#include <envmap_pars_vertex>\r\n#include <bsdfs>\r\n#include <lights_pars>\r\n#include <color_pars_vertex>\r\n#include <fog_pars_vertex>\r\n#include <morphtarget_pars_vertex>\r\n#include <skinning_pars_vertex>\r\n#include <shadowmap_pars_vertex>\r\n#include <logdepthbuf_pars_vertex>\r\n#include <clipping_planes_pars_vertex>\r\n\r\nvoid main() {\r\n\r\n\t#include <uv_vertex>\r\n\t#include <uv2_vertex>\r\n\t#include <color_vertex>\r\n\r\n\t#include <beginnormal_vertex>\r\n\t#include <morphnormal_vertex>\r\n\t#include <skinbase_vertex>\r\n\t#include <skinnormal_vertex>\r\n\t#include <defaultnormal_vertex>\r\n\r\n\t#include <begin_vertex>\r\n\t#include <morphtarget_vertex>\r\n\t#include <skinning_vertex>\r\n\t#include <project_vertex>\r\n\t#include <logdepthbuf_vertex>\r\n\t#include <clipping_planes_vertex>\r\n\r\n\t#include <worldpos_vertex>\r\n\t#include <envmap_vertex>\r\n\t#include <lights_lambert_vertex>\r\n\t#include <shadowmap_vertex>\r\n\t#include <fog_vertex>\r\n\r\n}\r\n",meshphong_frag:"#define PHONG\r\n\r\nuniform vec3 diffuse;\r\nuniform vec3 emissive;\r\nuniform vec3 specular;\r\nuniform float shininess;\r\nuniform float opacity;\r\n\r\n#include <common>\r\n#include <packing>\r\n#include <dithering_pars_fragment>\r\n#include <color_pars_fragment>\r\n#include <uv_pars_fragment>\r\n#include <uv2_pars_fragment>\r\n#include <map_pars_fragment>\r\n#include <alphamap_pars_fragment>\r\n#include <aomap_pars_fragment>\r\n#include <lightmap_pars_fragment>\r\n#include <emissivemap_pars_fragment>\r\n#include <envmap_pars_fragment>\r\n#include <gradientmap_pars_fragment>\r\n#include <fog_pars_fragment>\r\n#include <bsdfs>\r\n#include <lights_pars>\r\n#include <lights_phong_pars_fragment>\r\n#include <shadowmap_pars_fragment>\r\n#include <bumpmap_pars_fragment>\r\n#include <normalmap_pars_fragment>\r\n#include <specularmap_pars_fragment>\r\n#include <logdepthbuf_pars_fragment>\r\n#include <clipping_planes_pars_fragment>\r\n\r\nvoid main() {\r\n\r\n\t#include <clipping_planes_fragment>\r\n\r\n\tvec4 diffuseColor = vec4( diffuse, opacity );\r\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\r\n\tvec3 totalEmissiveRadiance = emissive;\r\n\r\n\t#include <logdepthbuf_fragment>\r\n\t#include <map_fragment>\r\n\t#include <color_fragment>\r\n\t#include <alphamap_fragment>\r\n\t#include <alphatest_fragment>\r\n\t#include <specularmap_fragment>\r\n\t#include <normal_flip>\r\n\t#include <normal_fragment>\r\n\t#include <emissivemap_fragment>\r\n\r\n\t// accumulation\r\n\t#include <lights_phong_fragment>\r\n\t#include <lights_template>\r\n\r\n\t// modulation\r\n\t#include <aomap_fragment>\r\n\r\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\r\n\r\n\t#include <envmap_fragment>\r\n\r\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\r\n\r\n\t#include <tonemapping_fragment>\r\n\t#include <encodings_fragment>\r\n\t#include <fog_fragment>\r\n\t#include <premultiplied_alpha_fragment>\r\n\t#include <dithering_fragment>\r\n\r\n}\r\n",meshphong_vert:"#define PHONG\r\n\r\nvarying vec3 vViewPosition;\r\n\r\n#ifndef FLAT_SHADED\r\n\r\n\tvarying vec3 vNormal;\r\n\r\n#endif\r\n\r\n#include <common>\r\n#include <uv_pars_vertex>\r\n#include <uv2_pars_vertex>\r\n#include <displacementmap_pars_vertex>\r\n#include <envmap_pars_vertex>\r\n#include <color_pars_vertex>\r\n#include <fog_pars_vertex>\r\n#include <morphtarget_pars_vertex>\r\n#include <skinning_pars_vertex>\r\n#include <shadowmap_pars_vertex>\r\n#include <logdepthbuf_pars_vertex>\r\n#include <clipping_planes_pars_vertex>\r\n\r\nvoid main() {\r\n\r\n\t#include <uv_vertex>\r\n\t#include <uv2_vertex>\r\n\t#include <color_vertex>\r\n\r\n\t#include <beginnormal_vertex>\r\n\t#include <morphnormal_vertex>\r\n\t#include <skinbase_vertex>\r\n\t#include <skinnormal_vertex>\r\n\t#include <defaultnormal_vertex>\r\n\r\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\r\n\r\n\tvNormal = normalize( transformedNormal );\r\n\r\n#endif\r\n\r\n\t#include <begin_vertex>\r\n\t#include <morphtarget_vertex>\r\n\t#include <skinning_vertex>\r\n\t#include <displacementmap_vertex>\r\n\t#include <project_vertex>\r\n\t#include <logdepthbuf_vertex>\r\n\t#include <clipping_planes_vertex>\r\n\r\n\tvViewPosition = - mvPosition.xyz;\r\n\r\n\t#include <worldpos_vertex>\r\n\t#include <envmap_vertex>\r\n\t#include <shadowmap_vertex>\r\n\t#include <fog_vertex>\r\n\r\n}\r\n",meshphysical_frag:"#define PHYSICAL\r\n\r\nuniform vec3 diffuse;\r\nuniform vec3 emissive;\r\nuniform float roughness;\r\nuniform float metalness;\r\nuniform float opacity;\r\n\r\n#ifndef STANDARD\r\n\tuniform float clearCoat;\r\n\tuniform float clearCoatRoughness;\r\n#endif\r\n\r\nvarying vec3 vViewPosition;\r\n\r\n#ifndef FLAT_SHADED\r\n\r\n\tvarying vec3 vNormal;\r\n\r\n#endif\r\n\r\n#include <common>\r\n#include <packing>\r\n#include <dithering_pars_fragment>\r\n#include <color_pars_fragment>\r\n#include <uv_pars_fragment>\r\n#include <uv2_pars_fragment>\r\n#include <map_pars_fragment>\r\n#include <alphamap_pars_fragment>\r\n#include <aomap_pars_fragment>\r\n#include <lightmap_pars_fragment>\r\n#include <emissivemap_pars_fragment>\r\n#include <envmap_pars_fragment>\r\n#include <fog_pars_fragment>\r\n#include <bsdfs>\r\n#include <cube_uv_reflection_fragment>\r\n#include <lights_pars>\r\n#include <lights_physical_pars_fragment>\r\n#include <shadowmap_pars_fragment>\r\n#include <bumpmap_pars_fragment>\r\n#include <normalmap_pars_fragment>\r\n#include <roughnessmap_pars_fragment>\r\n#include <metalnessmap_pars_fragment>\r\n#include <logdepthbuf_pars_fragment>\r\n#include <clipping_planes_pars_fragment>\r\n\r\nvoid main() {\r\n\r\n\t#include <clipping_planes_fragment>\r\n\r\n\tvec4 diffuseColor = vec4( diffuse, opacity );\r\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\r\n\tvec3 totalEmissiveRadiance = emissive;\r\n\r\n\t#include <logdepthbuf_fragment>\r\n\t#include <map_fragment>\r\n\t#include <color_fragment>\r\n\t#include <alphamap_fragment>\r\n\t#include <alphatest_fragment>\r\n\t#include <roughnessmap_fragment>\r\n\t#include <metalnessmap_fragment>\r\n\t#include <normal_flip>\r\n\t#include <normal_fragment>\r\n\t#include <emissivemap_fragment>\r\n\r\n\t// accumulation\r\n\t#include <lights_physical_fragment>\r\n\t#include <lights_template>\r\n\r\n\t// modulation\r\n\t#include <aomap_fragment>\r\n\r\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\r\n\r\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\r\n\r\n\t#include <tonemapping_fragment>\r\n\t#include <encodings_fragment>\r\n\t#include <fog_fragment>\r\n\t#include <premultiplied_alpha_fragment>\r\n\t#include <dithering_fragment>\r\n\r\n}\r\n",meshphysical_vert:"#define PHYSICAL\r\n\r\nvarying vec3 vViewPosition;\r\n\r\n#ifndef FLAT_SHADED\r\n\r\n\tvarying vec3 vNormal;\r\n\r\n#endif\r\n\r\n#include <common>\r\n#include <uv_pars_vertex>\r\n#include <uv2_pars_vertex>\r\n#include <displacementmap_pars_vertex>\r\n#include <color_pars_vertex>\r\n#include <fog_pars_vertex>\r\n#include <morphtarget_pars_vertex>\r\n#include <skinning_pars_vertex>\r\n#include <shadowmap_pars_vertex>\r\n#include <logdepthbuf_pars_vertex>\r\n#include <clipping_planes_pars_vertex>\r\n\r\nvoid main() {\r\n\r\n\t#include <uv_vertex>\r\n\t#include <uv2_vertex>\r\n\t#include <color_vertex>\r\n\r\n\t#include <beginnormal_vertex>\r\n\t#include <morphnormal_vertex>\r\n\t#include <skinbase_vertex>\r\n\t#include <skinnormal_vertex>\r\n\t#include <defaultnormal_vertex>\r\n\r\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\r\n\r\n\tvNormal = normalize( transformedNormal );\r\n\r\n#endif\r\n\r\n\t#include <begin_vertex>\r\n\t#include <morphtarget_vertex>\r\n\t#include <skinning_vertex>\r\n\t#include <displacementmap_vertex>\r\n\t#include <project_vertex>\r\n\t#include <logdepthbuf_vertex>\r\n\t#include <clipping_planes_vertex>\r\n\r\n\tvViewPosition = - mvPosition.xyz;\r\n\r\n\t#include <worldpos_vertex>\r\n\t#include <shadowmap_vertex>\r\n\t#include <fog_vertex>\r\n\r\n}\r\n",normal_frag:"#define NORMAL\r\n\r\nuniform float opacity;\r\n\r\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\r\n\r\n\tvarying vec3 vViewPosition;\r\n\r\n#endif\r\n\r\n#ifndef FLAT_SHADED\r\n\r\n\tvarying vec3 vNormal;\r\n\r\n#endif\r\n\r\n#include <packing>\r\n#include <uv_pars_fragment>\r\n#include <bumpmap_pars_fragment>\r\n#include <normalmap_pars_fragment>\r\n#include <logdepthbuf_pars_fragment>\r\n\r\nvoid main() {\r\n\r\n\t#include <logdepthbuf_fragment>\r\n\t#include <normal_flip>\r\n\t#include <normal_fragment>\r\n\r\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\r\n\r\n}\r\n",normal_vert:"#define NORMAL\r\n\r\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\r\n\r\n\tvarying vec3 vViewPosition;\r\n\r\n#endif\r\n\r\n#ifndef FLAT_SHADED\r\n\r\n\tvarying vec3 vNormal;\r\n\r\n#endif\r\n\r\n#include <uv_pars_vertex>\r\n#include <displacementmap_pars_vertex>\r\n#include <morphtarget_pars_vertex>\r\n#include <skinning_pars_vertex>\r\n#include <logdepthbuf_pars_vertex>\r\n\r\nvoid main() {\r\n\r\n\t#include <uv_vertex>\r\n\r\n\t#include <beginnormal_vertex>\r\n\t#include <morphnormal_vertex>\r\n\t#include <skinbase_vertex>\r\n\t#include <skinnormal_vertex>\r\n\t#include <defaultnormal_vertex>\r\n\r\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\r\n\r\n\tvNormal = normalize( transformedNormal );\r\n\r\n#endif\r\n\r\n\t#include <begin_vertex>\r\n\t#include <morphtarget_vertex>\r\n\t#include <skinning_vertex>\r\n\t#include <displacementmap_vertex>\r\n\t#include <project_vertex>\r\n\t#include <logdepthbuf_vertex>\r\n\r\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\r\n\r\n\tvViewPosition = - mvPosition.xyz;\r\n\r\n#endif\r\n\r\n}\r\n",points_frag:"uniform vec3 diffuse;\r\nuniform float opacity;\r\n\r\n#include <common>\r\n#include <packing>\r\n#include <color_pars_fragment>\r\n#include <map_particle_pars_fragment>\r\n#include <fog_pars_fragment>\r\n#include <shadowmap_pars_fragment>\r\n#include <logdepthbuf_pars_fragment>\r\n#include <clipping_planes_pars_fragment>\r\n\r\nvoid main() {\r\n\r\n\t#include <clipping_planes_fragment>\r\n\r\n\tvec3 outgoingLight = vec3( 0.0 );\r\n\tvec4 diffuseColor = vec4( diffuse, opacity );\r\n\r\n\t#include <logdepthbuf_fragment>\r\n\t#include <map_particle_fragment>\r\n\t#include <color_fragment>\r\n\t#include <alphatest_fragment>\r\n\r\n\toutgoingLight = diffuseColor.rgb;\r\n\r\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\r\n\r\n\t#include <premultiplied_alpha_fragment>\r\n\t#include <tonemapping_fragment>\r\n\t#include <encodings_fragment>\r\n\t#include <fog_fragment>\r\n\r\n}\r\n",points_vert:"uniform float size;\r\nuniform float scale;\r\n\r\n#include <common>\r\n#include <color_pars_vertex>\r\n#include <fog_pars_vertex>\r\n#include <shadowmap_pars_vertex>\r\n#include <logdepthbuf_pars_vertex>\r\n#include <clipping_planes_pars_vertex>\r\n\r\nvoid main() {\r\n\r\n\t#include <color_vertex>\r\n\t#include <begin_vertex>\r\n\t#include <project_vertex>\r\n\r\n\t#ifdef USE_SIZEATTENUATION\r\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\r\n\t#else\r\n\t\tgl_PointSize = size;\r\n\t#endif\r\n\r\n\t#include <logdepthbuf_vertex>\r\n\t#include <clipping_planes_vertex>\r\n\t#include <worldpos_vertex>\r\n\t#include <shadowmap_vertex>\r\n\t#include <fog_vertex>\r\n\r\n}\r\n",shadow_frag:"uniform float opacity;\r\n\r\n#include <common>\r\n#include <packing>\r\n#include <bsdfs>\r\n#include <lights_pars>\r\n#include <shadowmap_pars_fragment>\r\n#include <shadowmask_pars_fragment>\r\n\r\nvoid main() {\r\n\r\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\r\n\r\n}\r\n",shadow_vert:"#include <shadowmap_pars_vertex>\r\n\r\nvoid main() {\r\n\r\n\t#include <begin_vertex>\r\n\t#include <project_vertex>\r\n\t#include <worldpos_vertex>\r\n\t#include <shadowmap_vertex>\r\n\r\n}\r\n"},ih={basic:{uniforms:rh.merge([eh.common,eh.aomap,eh.lightmap,eh.fog]),vertexShader:nh.meshbasic_vert,fragmentShader:nh.meshbasic_frag},lambert:{uniforms:rh.merge([eh.common,eh.aomap,eh.lightmap,eh.emissivemap,eh.fog,eh.lights,{emissive:{value:new c(0)}}]),vertexShader:nh.meshlambert_vert,fragmentShader:nh.meshlambert_frag},phong:{uniforms:rh.merge([eh.common,eh.aomap,eh.lightmap,eh.emissivemap,eh.bumpmap,eh.normalmap,eh.displacementmap,eh.gradientmap,eh.fog,eh.lights,{emissive:{value:new c(0)},specular:{value:new c(1118481)},shininess:{value:30}}]),vertexShader:nh.meshphong_vert,fragmentShader:nh.meshphong_frag},standard:{uniforms:rh.merge([eh.common,eh.aomap,eh.lightmap,eh.emissivemap,eh.bumpmap,eh.normalmap,eh.displacementmap,eh.roughnessmap,eh.metalnessmap,eh.fog,eh.lights,{emissive:{value:new c(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:nh.meshphysical_vert,fragmentShader:nh.meshphysical_frag},points:{uniforms:rh.merge([eh.points,eh.fog]),vertexShader:nh.points_vert,fragmentShader:nh.points_frag},dashed:{uniforms:rh.merge([eh.common,eh.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:nh.linedashed_vert,fragmentShader:nh.linedashed_frag},depth:{uniforms:rh.merge([eh.common,eh.displacementmap]),vertexShader:nh.depth_vert,fragmentShader:nh.depth_frag},normal:{uniforms:rh.merge([eh.common,eh.bumpmap,eh.normalmap,eh.displacementmap,{opacity:{value:1}}]),vertexShader:nh.normal_vert,fragmentShader:nh.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:nh.cube_vert,fragmentShader:nh.cube_frag},equirect:{uniforms:{tEquirect:{value:null},tFlip:{value:-1}},vertexShader:nh.equirect_vert,fragmentShader:nh.equirect_frag},distanceRGBA:{uniforms:{lightPos:{value:new n}},vertexShader:nh.distanceRGBA_vert,fragmentShader:nh.distanceRGBA_frag}};ih.physical={uniforms:rh.merge([ih.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:nh.meshphysical_vert,fragmentShader:nh.meshphysical_frag},Object.assign(et.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:function(){var t=new h;return function(e,r){var n=t.copy(r).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(t){var e=t||new h;return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){var e=t||new h;return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new h).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)},clampPoint:function(t,e){return(e||new h).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new h;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}});var ah=0;Object.assign(it.prototype,l.prototype,{isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){if(void 0!==t)for(var e in t){var r=t[e];if(void 0!==r){var n=this[e];void 0!==n?n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.copy(r):this[e]="overdraw"===e?Number(r):r:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}else console.warn("THREE.Material: '"+e+"' parameter is undefined.")}},toJSON:function(t){function e(t){var e=[];for(var r in t){var n=t[r];delete n.metadata,e.push(n)}return e}var r=void 0===t;r&&(t={textures:{},images:{}});var n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearCoat&&(n.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(n.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,n.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(n.size=this.size),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==ic&&(n.blending=this.blending),this.shading!==$s&&(n.shading=this.shading),this.side!==Zs&&(n.side=this.side),this.vertexColors!==tc&&(n.vertexColors=this.vertexColors),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),n.skinning=this.skinning,n.morphTargets=this.morphTargets,n.dithering=this.dithering,r){var i=e(t.textures),a=e(t.images);i.length>0&&(n.textures=i),a.length>0&&(n.images=a)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.shading=t.shading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,r=null;if(null!==e){var n=e.length;r=new Array(n);for(var i=0;i!==n;++i)r[i]=e[i].clone()}return this.clippingPlanes=r,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),at.prototype=Object.create(it.prototype),at.prototype.constructor=at,at.prototype.isShaderMaterial=!0,at.prototype.copy=function(t){return it.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=rh.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},at.prototype.toJSON=function(t){var e=it.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},ot.prototype=Object.create(it.prototype),ot.prototype.constructor=ot,ot.prototype.isMeshDepthMaterial=!0,ot.prototype.copy=function(t){return it.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},Object.assign(st.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.length;s<c;s+=3){var l=t[s],h=t[s+1],u=t[s+2];l<e&&(e=l),h<r&&(r=h),u<n&&(n=u),l>i&&(i=l),h>a&&(a=h),u>o&&(o=u)}return this.min.set(e,r,n),this.max.set(i,a,o),this},setFromBufferAttribute:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.count;s<c;s++){var l=t.getX(s),h=t.getY(s),u=t.getZ(s);l<e&&(e=l),h<r&&(r=h),u<n&&(n=u),l>i&&(i=l),h>a&&(a=h),u>o&&(o=u)}return this.min.set(e,r,n),this.max.set(i,a,o),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:function(){var t=new n;return function(e,r){var n=t.copy(r).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}}(),setFromObject:function(t){return this.makeEmpty(),this.expandByObject(t)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(t){var e=t||new n;return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){var e=t||new n;return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},expandByObject:function(){var t=new n;return function(e){var r=this;return e.updateMatrixWorld(!0),e.traverse(function(e){var n,i,a=e.geometry;if(void 0!==a)if(a.isGeometry){var o=a.vertices;for(n=0,i=o.length;n<i;n++)t.copy(o[n]),t.applyMatrix4(e.matrixWorld),r.expandByPoint(t)}else if(a.isBufferGeometry){var s=a.attributes.position;if(void 0!==s)for(n=0,i=s.count;n<i;n++)t.fromBufferAttribute(s,n).applyMatrix4(e.matrixWorld),r.expandByPoint(t)}}),this}}(),containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new n).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},intersectsSphere:function(){var t=new n;return function(e){return this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.radius}}(),intersectsPlane:function(t){var e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=t.constant&&r>=t.constant},clampPoint:function(t,e){return(e||new n).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new n;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new n;return function(e){var r=e||new ct;return this.getCenter(r.center),r.radius=.5*this.getSize(t).length(),r}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(){var t=[new n,new n,new n,new n,new n,new n,new n,new n];return function(e){return this.isEmpty()?this:(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t),this)}}(),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.assign(ct.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t=new st;return function(e,r){var n=this.center;void 0!==r?n.copy(r):t.setFromPoints(e).getCenter(n);for(var i=0,a=0,o=e.length;a<o;a++)i=Math.max(i,n.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.center.copy(t.center),this.radius=t.radius,this},empty:function(){return this.radius<=0},containsPoint:function(t){return t.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(t){return t.distanceTo(this.center)-this.radius},intersectsSphere:function(t){var e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e},intersectsBox:function(t){return t.intersectsSphere(this)},intersectsPlane:function(t){return Math.abs(this.center.dot(t.normal)-t.constant)<=this.radius},clampPoint:function(t,e){var r=this.center.distanceToSquared(t),i=e||new n;return i.copy(t),r>this.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i},getBoundingBox:function(t){var e=t||new st;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}}),Object.assign(lt.prototype,{isMatrix3:!0,set:function(t,e,r,n,i,a,o,s,c){var l=this.elements;return l[0]=t,l[1]=n,l[2]=o,l[3]=e,l[4]=i,l[5]=s,l[6]=r,l[7]=a,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:function(){var t=new n;return function(e){for(var r=0,n=e.count;r<n;r++)t.x=e.getX(r),t.y=e.getY(r),t.z=e.getZ(r),t.applyMatrix3(this),e.setXYZ(r,t.x,t.y,t.z);return e}}(),multiply:function(t){return this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,n=e.elements,i=this.elements,a=r[0],o=r[3],s=r[6],c=r[1],l=r[4],h=r[7],u=r[2],d=r[5],p=r[8],f=n[0],m=n[3],g=n[6],v=n[1],y=n[4],x=n[7],b=n[2],w=n[5],_=n[8];return i[0]=a*f+o*v+s*b,i[3]=a*m+o*y+s*w,i[6]=a*g+o*x+s*_,i[1]=c*f+l*v+h*b,i[4]=c*m+l*y+h*w,i[7]=c*g+l*x+h*_,i[2]=u*f+d*v+p*b,i[5]=u*m+d*y+p*w,i[8]=u*g+d*x+p*_,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},determinant:function(){var t=this.elements,e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8];return e*a*l-e*o*c-r*i*l+r*o*s+n*i*c-n*a*s},getInverse:function(t,e){t&&t.isMatrix4&&console.error("THREE.Matrix3.getInverse no longer takes a Matrix4 argument.");var r=t.elements,n=this.elements,i=r[0],a=r[1],o=r[2],s=r[3],c=r[4],l=r[5],h=r[6],u=r[7],d=r[8],p=d*c-l*u,f=l*h-d*s,m=u*s-c*h,g=i*p+a*f+o*m;if(0===g){var v="THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0";if(!0===e)throw new Error(v);return console.warn(v),this.identity()}var y=1/g;return n[0]=p*y,n[1]=(o*u-d*a)*y,n[2]=(l*a-o*c)*y,n[3]=f*y,n[4]=(d*i-o*h)*y,n[5]=(o*s-l*i)*y,n[6]=m*y,n[7]=(a*h-u*i)*y,n[8]=(c*i-a*s)*y,this},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},getNormalMatrix:function(t){return this.setFromMatrix4(t).getInverse(this).transpose()},transposeIntoArray:function(t){var e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this},equals:function(t){for(var e=this.elements,r=t.elements,n=0;n<9;n++)if(e[n]!==r[n])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var r=0;r<9;r++)this.elements[r]=t[r+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}}),Object.assign(ht.prototype,{set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,r,n){return this.normal.set(t,e,r),this.constant=n,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(){var t=new n,e=new n;return function(r,n,i){var a=t.subVectors(i,n).cross(e.subVectors(r,n)).normalize();return this.setFromNormalAndCoplanarPoint(a,r),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return this.orthoPoint(t,e).sub(t).negate()},orthoPoint:function(t,e){var r=this.distanceToPoint(t);return(e||new n).copy(this.normal).multiplyScalar(r)},intersectLine:function(){var t=new n;return function(e,r){var i=r||new n,a=e.delta(t),o=this.normal.dot(a);if(0!==o){var s=-(e.start.dot(this.normal)+this.constant)/o;if(!(s<0||s>1))return i.copy(a).multiplyScalar(s).add(e.start)}else if(0===this.distanceToPoint(e.start))return i.copy(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new n).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new n,e=new lt;return function(r,n){var i=this.coplanarPoint(t).applyMatrix4(r),a=n||e.getNormalMatrix(r),o=this.normal.applyMatrix3(a).normalize();return this.constant=-i.dot(o),this}}(),translate:function(t){return this.constant=this.constant-t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}),Object.assign(ut.prototype,{set:function(t,e,r,n,i,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(r),o[3].copy(n),o[4].copy(i),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,r=0;r<6;r++)e[r].copy(t.planes[r]);return this},setFromMatrix:function(t){var e=this.planes,r=t.elements,n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],c=r[5],l=r[6],h=r[7],u=r[8],d=r[9],p=r[10],f=r[11],m=r[12],g=r[13],v=r[14],y=r[15];return e[0].setComponents(o-n,h-s,f-u,y-m).normalize(),e[1].setComponents(o+n,h+s,f+u,y+m).normalize(),e[2].setComponents(o+i,h+c,f+d,y+g).normalize(),e[3].setComponents(o-i,h-c,f-d,y-g).normalize(),e[4].setComponents(o-a,h-l,f-p,y-v).normalize(),e[5].setComponents(o+a,h+l,f+p,y+v).normalize(),this},intersectsObject:function(){var t=new ct;return function(e){var r=e.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),t.copy(r.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new ct;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSphere:function(t){for(var e=this.planes,r=t.center,n=-t.radius,i=0;i<6;i++)if(e[i].distanceToPoint(r)<n)return!1;return!0},intersectsBox:function(){var t=new n,e=new n;return function(r){for(var n=this.planes,i=0;i<6;i++){var a=n[i];t.x=a.normal.x>0?r.min.x:r.max.x,e.x=a.normal.x>0?r.max.x:r.min.x,t.y=a.normal.y>0?r.min.y:r.max.y,e.y=a.normal.y>0?r.max.y:r.min.y,t.z=a.normal.z>0?r.min.z:r.max.z,e.z=a.normal.z>0?r.max.z:r.min.z;var o=a.distanceToPoint(t),s=a.distanceToPoint(e);if(o<0&&s<0)return!1}return!0}}(),containsPoint:function(t){for(var e=this.planes,r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}}),ft.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ft.DefaultOrder="XYZ",Object.defineProperties(ft.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback()}}}),Object.assign(ft.prototype,{isEuler:!0,set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._order=n||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,r){var n=Ko.clamp,i=t.elements,a=i[0],o=i[4],s=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],p=i[10];return e=e||this._order,"XYZ"===e?(this._y=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(d,l),this._z=0)):"YXZ"===e?(this._x=Math.asin(-n(h,-1,1)),Math.abs(h)<.99999?(this._y=Math.atan2(s,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,a),this._z=0)):"ZXY"===e?(this._x=Math.asin(n(d,-1,1)),Math.abs(d)<.99999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,a))):"ZYX"===e?(this._y=Math.asin(-n(u,-1,1)),Math.abs(u)<.99999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,l))):"YZX"===e?(this._z=Math.asin(n(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,a)):(this._x=0,this._y=Math.atan2(s,p))):"XZY"===e?(this._z=Math.asin(-n(o,-1,1)),Math.abs(o)<.99999?(this._x=Math.atan2(d,l),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-h,p),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var t=new e;return function(e,r,n){return t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,r,n)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new r;return function(e){return t.setFromEuler(this),this.setFromQuaternion(t,e)}}(),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new n(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(mt.prototype,{set:function(t){this.mask=1<<t|0},enable:function(t){this.mask|=1<<t|0},toggle:function(t){this.mask^=1<<t|0},disable:function(t){this.mask&=~(1<<t|0)},test:function(t){return 0!=(this.mask&t.mask)}});var oh=0;gt.DefaultUp=new n(0,1,0),gt.DefaultMatrixAutoUpdate=!0,Object.assign(gt.prototype,l.prototype,{isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix:function(t){this.matrix.multiplyMatrices(t,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(){var t=new r;return function(e,r){return t.setFromAxisAngle(e,r),this.quaternion.multiply(t),this}}(),rotateX:function(){var t=new n(1,0,0);return function(e){return this.rotateOnAxis(t,e)}}(),rotateY:function(){var t=new n(0,1,0);return function(e){return this.rotateOnAxis(t,e)}}(),rotateZ:function(){var t=new n(0,0,1);return function(e){return this.rotateOnAxis(t,e)}}(),translateOnAxis:function(){var t=new n;return function(e,r){return t.copy(e).applyQuaternion(this.quaternion),this.position.add(t.multiplyScalar(r)),this}}(),translateX:function(){var t=new n(1,0,0);return function(e){return this.translateOnAxis(t,e)}}(),translateY:function(){var t=new n(0,1,0);return function(e){return this.translateOnAxis(t,e)}}(),translateZ:function(){var t=new n(0,0,1);return function(e){return this.translateOnAxis(t,e)}}(),localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var t=new e;return function(e){return e.applyMatrix4(t.getInverse(this.matrixWorld))}}(),lookAt:function(){var t=new e;return function(e){this.isCamera?t.lookAt(this.position,e,this.up):t.lookAt(e,this.position,this.up),this.quaternion.setFromRotationMatrix(t)}}(),add:function(t){if(arguments.length>1){for(var e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,t.dispatchEvent({type:"added"}),this.children.push(t)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){if(arguments.length>1){for(var e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}var r=this.children.indexOf(t);return-1!==r&&(t.parent=null,t.dispatchEvent({type:"removed"}),this.children.splice(r,1)),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(var r=0,n=this.children.length;r<n;r++){var i=this.children[r].getObjectByProperty(t,e);if(void 0!==i)return i}},getWorldPosition:function(t){var e=t||new n;return this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var t=new n,e=new n;return function(n){var i=n||new r;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(t,i,e),i}}(),getWorldRotation:function(){var t=new r;return function(e){var r=e||new ft;return this.getWorldQuaternion(t),r.setFromQuaternion(t,this.rotation.order,!1)}}(),getWorldScale:function(){var t=new n,e=new r;return function(r){var i=r||new n;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(t,e,i),i}}(),getWorldDirection:function(){var t=new r;return function(e){var r=e||new n;return this.getWorldQuaternion(t),r.set(0,0,1).applyQuaternion(t)}}(),raycast:function(){},traverse:function(t){t(this);for(var e=this.children,r=0,n=e.length;r<n;r++)e[r].traverse(t)},traverseVisible:function(t){if(!1!==this.visible){t(this);for(var e=this.children,r=0,n=e.length;r<n;r++)e[r].traverseVisible(t)}},traverseAncestors:function(t){var e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(var e=this.children,r=0,n=e.length;r<n;r++)e[r].updateMatrixWorld(t)},toJSON:function(t){function e(e,r){return void 0===e[r.uuid]&&(e[r.uuid]=r.toJSON(t)),r.uuid}function r(t){var e=[];for(var r in t){var n=t[r];delete n.metadata,e.push(n)}return e}var n=void 0===t||""===t,i={};n&&(t={geometries:{},materials:{},textures:{},images:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var a={};if(a.uuid=this.uuid,a.type=this.type,""!==this.name&&(a.name=this.name),"{}"!==JSON.stringify(this.userData)&&(a.userData=this.userData),!0===this.castShadow&&(a.castShadow=!0),!0===this.receiveShadow&&(a.receiveShadow=!0),!1===this.visible&&(a.visible=!1),a.matrix=this.matrix.toArray(),void 0!==this.geometry&&(a.geometry=e(t.geometries,this.geometry)),void 0!==this.material)if(Array.isArray(this.material)){for(var o=[],s=0,c=this.material.length;s<c;s++)o.push(e(t.materials,this.material[s]));a.material=o}else a.material=e(t.materials,this.material);if(this.children.length>0){a.children=[];for(s=0;s<this.children.length;s++)a.children.push(this.children[s].toJSON(t).object)}if(n){var l=r(t.geometries),h=r(t.materials),u=r(t.textures),d=r(t.images);l.length>0&&(i.geometries=l),h.length>0&&(i.materials=h),u.length>0&&(i.textures=u),d.length>0&&(i.images=d)}return i.object=a,i},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var r=0;r<t.children.length;r++){var n=t.children[r];this.add(n.clone())}return this}}),vt.prototype=Object.assign(Object.create(gt.prototype),{constructor:vt,isCamera:!0,copy:function(t,e){return gt.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this},getWorldDirection:function(){var t=new r;return function(e){var r=e||new n;return this.getWorldQuaternion(t),r.set(0,0,-1).applyQuaternion(t)}}(),updateMatrixWorld:function(t){gt.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),yt.prototype=Object.assign(Object.create(vt.prototype),{constructor:yt,isOrthographicCamera:!0,copy:function(t,e){return vt.prototype.copy.call(this,t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this},setViewOffset:function(t,e,r,n,i,a){this.view={fullWidth:t,fullHeight:e,offsetX:r,offsetY:n,width:i,height:a},this.updateProjectionMatrix()},clearViewOffset:function(){this.view=null,this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,n=(this.top+this.bottom)/2,i=r-t,a=r+t,o=n+e,s=n-e;if(null!==this.view){var c=this.zoom/(this.view.width/this.view.fullWidth),l=this.zoom/(this.view.height/this.view.fullHeight),h=(this.right-this.left)/this.view.width,u=(this.top-this.bottom)/this.view.height;a=(i+=h*(this.view.offsetX/c))+h*(this.view.width/c),s=(o-=u*(this.view.offsetY/l))-u*(this.view.height/l)}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far)},toJSON:function(t){var e=gt.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}),xt.prototype=Object.assign(Object.create(vt.prototype),{constructor:xt,isPerspectiveCamera:!0,copy:function(t,e){return vt.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){var e=.5*this.getFilmHeight()/t;this.fov=2*Ko.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*Ko.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*Ko.RAD2DEG*Math.atan(Math.tan(.5*Ko.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,r,n,i,a){this.aspect=t/e,this.view={fullWidth:t,fullHeight:e,offsetX:r,offsetY:n,width:i,height:a},this.updateProjectionMatrix()},clearViewOffset:function(){this.view=null,this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*Ko.DEG2RAD*this.fov)/this.zoom,r=2*e,n=this.aspect*r,i=-.5*n,a=this.view;if(null!==a){var o=a.fullWidth,s=a.fullHeight;i+=a.offsetX*n/o,e-=a.offsetY*r/s,n*=a.width/o,r*=a.height/s}var c=this.filmOffset;0!==c&&(i+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+n,e,e-r,t,this.far)},toJSON:function(t){var e=gt.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}),Object.assign(bt.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(var e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(var e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}});var sh=0;Object.assign(_t.prototype,l.prototype,{isGeometry:!0,applyMatrix:function(t){for(var e=(new lt).getNormalMatrix(t),r=0,n=this.vertices.length;r<n;r++)this.vertices[r].applyMatrix4(t);for(var r=0,n=this.faces.length;r<n;r++){var i=this.faces[r];i.normal.applyMatrix3(e).normalize();for(var a=0,o=i.vertexNormals.length;a<o;a++)i.vertexNormals[a].applyMatrix3(e).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(){var t=new e;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new e;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new e;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new e;return function(e,r,n){return t.makeTranslation(e,r,n),this.applyMatrix(t),this}}(),scale:function(){var t=new e;return function(e,r,n){return t.makeScale(e,r,n),this.applyMatrix(t),this}}(),lookAt:function(){var t=new gt;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),fromBufferGeometry:function(t){function e(t,e,n,i){var a=new bt(t,e,n,void 0!==s?[p[t].clone(),p[e].clone(),p[n].clone()]:[],void 0!==l?[r.colors[t].clone(),r.colors[e].clone(),r.colors[n].clone()]:[],i);r.faces.push(a),void 0!==u&&r.faceVertexUvs[0].push([f[t].clone(),f[e].clone(),f[n].clone()]),void 0!==d&&r.faceVertexUvs[1].push([m[t].clone(),m[e].clone(),m[n].clone()])}var r=this,i=null!==t.index?t.index.array:void 0,a=t.attributes,o=a.position.array,s=void 0!==a.normal?a.normal.array:void 0,l=void 0!==a.color?a.color.array:void 0,u=void 0!==a.uv?a.uv.array:void 0,d=void 0!==a.uv2?a.uv2.array:void 0;void 0!==d&&(this.faceVertexUvs[1]=[]);for(var p=[],f=[],m=[],g=0,v=0;g<o.length;g+=3,v+=2)r.vertices.push(new n(o[g],o[g+1],o[g+2])),void 0!==s&&p.push(new n(s[g],s[g+1],s[g+2])),void 0!==l&&r.colors.push(new c(l[g],l[g+1],l[g+2])),void 0!==u&&f.push(new h(u[v],u[v+1])),void 0!==d&&m.push(new h(d[v],d[v+1]));var y=t.groups;if(y.length>0)for(g=0;g<y.length;g++)for(var x=y[g],b=x.start,v=b,w=b+x.count;v<w;v+=3)void 0!==i?e(i[v],i[v+1],i[v+2],x.materialIndex):e(v,v+1,v+2,x.materialIndex);else if(void 0!==i)for(g=0;g<i.length;g+=3)e(i[g],i[g+1],i[g+2]);else for(g=0;g<o.length/3;g+=3)e(g,g+1,g+2);return this.computeFaceNormals(),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},normalize:function(){this.computeBoundingSphere();var t=this.boundingSphere.center,r=this.boundingSphere.radius,n=0===r?1:1/r,i=new e;return i.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix(i),this},computeFaceNormals:function(){for(var t=new n,e=new n,r=0,i=this.faces.length;r<i;r++){var a=this.faces[r],o=this.vertices[a.a],s=this.vertices[a.b],c=this.vertices[a.c];t.subVectors(c,s),e.subVectors(o,s),t.cross(e),t.normalize(),a.normal.copy(t)}},computeVertexNormals:function(t){void 0===t&&(t=!0);var e,r,i,a,o,s;for(s=new Array(this.vertices.length),e=0,r=this.vertices.length;e<r;e++)s[e]=new n;if(t){var c,l,h,u=new n,d=new n;for(i=0,a=this.faces.length;i<a;i++)o=this.faces[i],c=this.vertices[o.a],l=this.vertices[o.b],h=this.vertices[o.c],u.subVectors(h,l),d.subVectors(c,l),u.cross(d),s[o.a].add(u),s[o.b].add(u),s[o.c].add(u)}else for(this.computeFaceNormals(),i=0,a=this.faces.length;i<a;i++)s[(o=this.faces[i]).a].add(o.normal),s[o.b].add(o.normal),s[o.c].add(o.normal);for(e=0,r=this.vertices.length;e<r;e++)s[e].normalize();for(i=0,a=this.faces.length;i<a;i++){var p=(o=this.faces[i]).vertexNormals;3===p.length?(p[0].copy(s[o.a]),p[1].copy(s[o.b]),p[2].copy(s[o.c])):(p[0]=s[o.a].clone(),p[1]=s[o.b].clone(),p[2]=s[o.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,r;for(this.computeFaceNormals(),t=0,e=this.faces.length;t<e;t++){var n=(r=this.faces[t]).vertexNormals;3===n.length?(n[0].copy(r.normal),n[1].copy(r.normal),n[2].copy(r.normal)):(n[0]=r.normal.clone(),n[1]=r.normal.clone(),n[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,r,i,a;for(r=0,i=this.faces.length;r<i;r++)for((a=this.faces[r]).__originalFaceNormal?a.__originalFaceNormal.copy(a.normal):a.__originalFaceNormal=a.normal.clone(),a.__originalVertexNormals||(a.__originalVertexNormals=[]),t=0,e=a.vertexNormals.length;t<e;t++)a.__originalVertexNormals[t]?a.__originalVertexNormals[t].copy(a.vertexNormals[t]):a.__originalVertexNormals[t]=a.vertexNormals[t].clone();var o=new _t;for(o.faces=this.faces,t=0,e=this.morphTargets.length;t<e;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];var s=this.morphNormals[t].faceNormals,c=this.morphNormals[t].vertexNormals;for(r=0,i=this.faces.length;r<i;r++)h=new n,u={a:new n,b:new n,c:new n},s.push(h),c.push(u)}var l=this.morphNormals[t];o.vertices=this.morphTargets[t].vertices,o.computeFaceNormals(),o.computeVertexNormals();var h,u;for(r=0,i=this.faces.length;r<i;r++)a=this.faces[r],h=l.faceNormals[r],u=l.vertexNormals[r],h.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}for(r=0,i=this.faces.length;r<i;r++)(a=this.faces[r]).normal=a.__originalFaceNormal,a.vertexNormals=a.__originalVertexNormals},computeLineDistances:function(){for(var t=0,e=this.vertices,r=0,n=e.length;r<n;r++)r>0&&(t+=e[r].distanceTo(e[r-1])),this.lineDistances[r]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new st),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new ct),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,r){if(!t||!t.isGeometry)return void console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);var n,i=this.vertices.length,a=this.vertices,o=t.vertices,s=this.faces,c=t.faces,l=this.faceVertexUvs[0],h=t.faceVertexUvs[0],u=this.colors,d=t.colors;void 0===r&&(r=0),void 0!==e&&(n=(new lt).getNormalMatrix(e));for(var p=0,f=o.length;p<f;p++){var m=o[p].clone();void 0!==e&&m.applyMatrix4(e),a.push(m)}for(var p=0,f=d.length;p<f;p++)u.push(d[p].clone());for(p=0,f=c.length;p<f;p++){var g,v,y,x=c[p],b=x.vertexNormals,w=x.vertexColors;(g=new bt(x.a+i,x.b+i,x.c+i)).normal.copy(x.normal),void 0!==n&&g.normal.applyMatrix3(n).normalize();for(var _=0,M=b.length;_<M;_++)v=b[_].clone(),void 0!==n&&v.applyMatrix3(n).normalize(),g.vertexNormals.push(v);g.color.copy(x.color);for(var _=0,M=w.length;_<M;_++)y=w[_],g.vertexColors.push(y.clone());g.materialIndex=x.materialIndex+r,s.push(g)}for(p=0,f=h.length;p<f;p++){var E=h[p],S=[];if(void 0!==E){for(var _=0,M=E.length;_<M;_++)S.push(E[_].clone());l.push(S)}}},mergeMesh:function(t){if(!t||!t.isMesh)return void console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)},mergeVertices:function(){var t,e,r,n,i,a,o,s,c={},l=[],h=[],u=Math.pow(10,4);for(r=0,n=this.vertices.length;r<n;r++)t=this.vertices[r],void 0===c[e=Math.round(t.x*u)+"_"+Math.round(t.y*u)+"_"+Math.round(t.z*u)]?(c[e]=r,l.push(this.vertices[r]),h[r]=l.length-1):h[r]=h[c[e]];var d=[];for(r=0,n=this.faces.length;r<n;r++){(i=this.faces[r]).a=h[i.a],i.b=h[i.b],i.c=h[i.c],a=[i.a,i.b,i.c];for(var p=0;p<3;p++)if(a[p]===a[(p+1)%3]){d.push(r);break}}for(r=d.length-1;r>=0;r--){var f=d[r];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o<s;o++)this.faceVertexUvs[o].splice(f,1)}var m=this.vertices.length-l.length;return this.vertices=l,m},sortFacesByMaterialIndex:function(){function t(t,e){return t.materialIndex-e.materialIndex}for(var e=this.faces,r=e.length,n=0;n<r;n++)e[n]._id=n;e.sort(t);var i,a,o=this.faceVertexUvs[0],s=this.faceVertexUvs[1];o&&o.length===r&&(i=[]),s&&s.length===r&&(a=[]);for(n=0;n<r;n++){var c=e[n]._id;i&&i.push(o[c]),a&&a.push(s[c])}i&&(this.faceVertexUvs[0]=i),a&&(this.faceVertexUvs[1]=a)},toJSON:function(){function t(t,e,r){return r?t|1<<e:t&~(1<<e)}function e(t){var e=t.x.toString()+t.y.toString()+t.z.toString();return void 0!==d[e]?d[e]:(d[e]=u.length/3,u.push(t.x,t.y,t.z),d[e])}function r(t){var e=t.r.toString()+t.g.toString()+t.b.toString();return void 0!==f[e]?f[e]:(f[e]=p.length,p.push(t.getHex()),f[e])}function n(t){var e=t.x.toString()+t.y.toString();return void 0!==g[e]?g[e]:(g[e]=m.length/2,m.push(t.x,t.y),g[e])}var i={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),void 0!==this.parameters){var a=this.parameters;for(var o in a)void 0!==a[o]&&(i[o]=a[o]);return i}for(var s=[],c=0;c<this.vertices.length;c++){var l=this.vertices[c];s.push(l.x,l.y,l.z)}for(var h=[],u=[],d={},p=[],f={},m=[],g={},c=0;c<this.faces.length;c++){var v=this.faces[c],y=void 0!==this.faceVertexUvs[0][c],x=v.normal.length()>0,b=v.vertexNormals.length>0,w=1!==v.color.r||1!==v.color.g||1!==v.color.b,_=v.vertexColors.length>0,M=0;if(M=t(M,0,0),M=t(M,1,!0),M=t(M,2,!1),M=t(M,3,y),M=t(M,4,x),M=t(M,5,b),M=t(M,6,w),M=t(M,7,_),h.push(M),h.push(v.a,v.b,v.c),h.push(v.materialIndex),y){var E=this.faceVertexUvs[0][c];h.push(n(E[0]),n(E[1]),n(E[2]))}if(x&&h.push(e(v.normal)),b){var S=v.vertexNormals;h.push(e(S[0]),e(S[1]),e(S[2]))}if(w&&h.push(r(v.color)),_){var T=v.vertexColors;h.push(r(T[0]),r(T[1]),r(T[2]))}}return i.data={},i.data.vertices=s,i.data.normals=u,p.length>0&&(i.data.colors=p),m.length>0&&(i.data.uvs=[m]),i.data.faces=h,i},clone:function(){return(new _t).copy(this)},copy:function(t){var e,r,n,i,a,o;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.name=t.name;var s=t.vertices;for(e=0,r=s.length;e<r;e++)this.vertices.push(s[e].clone());var c=t.colors;for(e=0,r=c.length;e<r;e++)this.colors.push(c[e].clone());var l=t.faces;for(e=0,r=l.length;e<r;e++)this.faces.push(l[e].clone());for(e=0,r=t.faceVertexUvs.length;e<r;e++){var h=t.faceVertexUvs[e];for(void 0===this.faceVertexUvs[e]&&(this.faceVertexUvs[e]=[]),n=0,i=h.length;n<i;n++){var u=h[n],d=[];for(a=0,o=u.length;a<o;a++){var p=u[a];d.push(p.clone())}this.faceVertexUvs[e].push(d)}}var f=t.morphTargets;for(e=0,r=f.length;e<r;e++){var m={};if(m.name=f[e].name,void 0!==f[e].vertices)for(m.vertices=[],n=0,i=f[e].vertices.length;n<i;n++)m.vertices.push(f[e].vertices[n].clone());if(void 0!==f[e].normals)for(m.normals=[],n=0,i=f[e].normals.length;n<i;n++)m.normals.push(f[e].normals[n].clone());this.morphTargets.push(m)}var g=t.morphNormals;for(e=0,r=g.length;e<r;e++){var v={};if(void 0!==g[e].vertexNormals)for(v.vertexNormals=[],n=0,i=g[e].vertexNormals.length;n<i;n++){var y=g[e].vertexNormals[n],x={};x.a=y.a.clone(),x.b=y.b.clone(),x.c=y.c.clone(),v.vertexNormals.push(x)}if(void 0!==g[e].faceNormals)for(v.faceNormals=[],n=0,i=g[e].faceNormals.length;n<i;n++)v.faceNormals.push(g[e].faceNormals[n].clone());this.morphNormals.push(v)}var b=t.skinWeights;for(e=0,r=b.length;e<r;e++)this.skinWeights.push(b[e].clone());var w=t.skinIndices;for(e=0,r=w.length;e<r;e++)this.skinIndices.push(w[e].clone());var _=t.lineDistances;for(e=0,r=_.length;e<r;e++)this.lineDistances.push(_[e]);var M=t.boundingBox;null!==M&&(this.boundingBox=M.clone());var E=t.boundingSphere;return null!==E&&(this.boundingSphere=E.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Mt.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Mt.prototype,{isBufferAttribute:!0,setArray:function(t){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==t?t.length/this.itemSize:0,this.array=t},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.dynamic=t.dynamic,this},copyAt:function(t,e,r){t*=this.itemSize,r*=e.itemSize;for(var n=0,i=this.itemSize;n<i;n++)this.array[t+n]=e.array[r+n];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){for(var e=this.array,r=0,n=0,i=t.length;n<i;n++){var a=t[n];void 0===a&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),a=new c),e[r++]=a.r,e[r++]=a.g,e[r++]=a.b}return this},copyIndicesArray:function(t){for(var e=this.array,r=0,n=0,i=t.length;n<i;n++){var a=t[n];e[r++]=a.a,e[r++]=a.b,e[r++]=a.c}return this},copyVector2sArray:function(t){for(var e=this.array,r=0,n=0,i=t.length;n<i;n++){var a=t[n];void 0===a&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),a=new h),e[r++]=a.x,e[r++]=a.y}return this},copyVector3sArray:function(t){for(var e=this.array,r=0,i=0,a=t.length;i<a;i++){var o=t[i];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),o=new n),e[r++]=o.x,e[r++]=o.y,e[r++]=o.z}return this},copyVector4sArray:function(t){for(var e=this.array,r=0,n=0,i=t.length;n<i;n++){var a=t[n];void 0===a&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),a=new y),e[r++]=a.x,e[r++]=a.y,e[r++]=a.z,e[r++]=a.w}return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=r,this},setXYZ:function(t,e,r,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=n,this},setXYZW:function(t,e,r,n,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=n,this.array[t+3]=i,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)}}),Et.prototype=Object.create(Mt.prototype),Et.prototype.constructor=Et,St.prototype=Object.create(Mt.prototype),St.prototype.constructor=St,Tt.prototype=Object.create(Mt.prototype),Tt.prototype.constructor=Tt,Object.assign(At.prototype,{computeGroups:function(t){for(var e,r=[],n=void 0,i=t.faces,a=0;a<i.length;a++){var o=i[a];o.materialIndex!==n&&(n=o.materialIndex,void 0!==e&&(e.count=3*a-e.start,r.push(e)),e={start:3*a,materialIndex:n})}void 0!==e&&(e.count=3*a-e.start,r.push(e)),this.groups=r},fromGeometry:function(t){var e,r=t.faces,n=t.vertices,i=t.faceVertexUvs,a=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(v=0;v<c;v++)e[v]=[];this.morphTargets.position=e}var l,u=t.morphNormals,d=u.length;if(d>0){l=[];for(v=0;v<d;v++)l[v]=[];this.morphTargets.normal=l}for(var p=t.skinIndices,f=t.skinWeights,m=p.length===n.length,g=f.length===n.length,v=0;v<r.length;v++){var y=r[v];this.vertices.push(n[y.a],n[y.b],n[y.c]);var x=y.vertexNormals;if(3===x.length)this.normals.push(x[0],x[1],x[2]);else{var b=y.normal;this.normals.push(b,b,b)}var w=y.vertexColors;if(3===w.length)this.colors.push(w[0],w[1],w[2]);else{var _=y.color;this.colors.push(_,_,_)}if(!0===a&&(void 0!==(M=i[0][v])?this.uvs.push(M[0],M[1],M[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",v),this.uvs.push(new h,new h,new h))),!0===o){var M=i[1][v];void 0!==M?this.uvs2.push(M[0],M[1],M[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",v),this.uvs2.push(new h,new h,new h))}for(S=0;S<c;S++){var E=s[S].vertices;e[S].push(E[y.a],E[y.b],E[y.c])}for(var S=0;S<d;S++){var T=u[S].vertexNormals[v];l[S].push(T.a,T.b,T.c)}m&&this.skinIndices.push(p[y.a],p[y.b],p[y.c]),g&&this.skinWeights.push(f[y.a],f[y.b],f[y.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}}),Ct.MaxIndex=65535,Object.assign(Ct.prototype,l.prototype,{isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){Array.isArray(t)?this.index=new(Lt(t)>65535?St:Et)(t,1):this.index=t},addAttribute:function(t,e){return e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),void this.setIndex(e)):(this.attributes[t]=e,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(t,new Mt(arguments[1],arguments[2])))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,r){this.groups.push({start:t,count:e,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var r=this.attributes.normal;return void 0!==r&&((new lt).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t=new e;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new e;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new e;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new e;return function(e,r,n){return t.makeTranslation(e,r,n),this.applyMatrix(t),this}}(),scale:function(){var t=new e;return function(e,r,n){return t.makeScale(e,r,n),this.applyMatrix(t),this}}(),lookAt:function(){var t=new gt;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var r=new Tt(3*e.vertices.length,3),n=new Tt(3*e.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(e.vertices)),this.addAttribute("color",n.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new Tt(e.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},updateFromObject:function(t){var e=t.geometry;if(t.isMesh){var r=e.__directGeometry;if(!0===e.elementsNeedUpdate&&(r=void 0,e.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(e);r.verticesNeedUpdate=e.verticesNeedUpdate,r.normalsNeedUpdate=e.normalsNeedUpdate,r.colorsNeedUpdate=e.colorsNeedUpdate,r.uvsNeedUpdate=e.uvsNeedUpdate,r.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=r}var n;return!0===e.verticesNeedUpdate&&(void 0!==(n=this.attributes.position)&&(n.copyVector3sArray(e.vertices),n.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(void 0!==(n=this.attributes.normal)&&(n.copyVector3sArray(e.normals),n.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(void 0!==(n=this.attributes.color)&&(n.copyColorsArray(e.colors),n.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(void 0!==(n=this.attributes.uv)&&(n.copyVector2sArray(e.uvs),n.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(void 0!==(n=this.attributes.lineDistance)&&(n.copyArray(e.lineDistances),n.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new At).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new Mt(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new Mt(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new Mt(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new Mt(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new Mt(a,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var o=new(Lt(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new Mt(o,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var s in t.morphTargets){for(var c=[],l=t.morphTargets[s],h=0,u=l.length;h<u;h++){var d=l[h],p=new Tt(3*d.length,3);c.push(p.copyVector3sArray(d))}this.morphAttributes[s]=c}if(t.skinIndices.length>0){var f=new Tt(4*t.skinIndices.length,4);this.addAttribute("skinIndex",f.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new Tt(4*t.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new st);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var t=new st,e=new n;return function(){null===this.boundingSphere&&(this.boundingSphere=new ct);var r=this.attributes.position;if(r){var n=this.boundingSphere.center;t.setFromBufferAttribute(r),t.getCenter(n);for(var i=0,a=0,o=r.count;a<o;a++)e.x=r.getX(a),e.y=r.getY(a),e.z=r.getZ(a),i=Math.max(i,n.distanceToSquared(e));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var t=this.index,e=this.attributes,r=this.groups;if(e.position){var i=e.position.array;if(void 0===e.normal)this.addAttribute("normal",new Mt(new Float32Array(i.length),3));else for(var a=e.normal.array,o=0,s=a.length;o<s;o++)a[o]=0;var c,l,h,u=e.normal.array,d=new n,p=new n,f=new n,m=new n,g=new n;if(t){var v=t.array;0===r.length&&this.addGroup(0,v.length);for(var y=0,x=r.length;y<x;++y)for(var b=r[y],w=b.start,o=w,s=w+b.count;o<s;o+=3)c=3*v[o+0],l=3*v[o+1],h=3*v[o+2],d.fromArray(i,c),p.fromArray(i,l),f.fromArray(i,h),m.subVectors(f,p),g.subVectors(d,p),m.cross(g),u[c]+=m.x,u[c+1]+=m.y,u[c+2]+=m.z,u[l]+=m.x,u[l+1]+=m.y,u[l+2]+=m.z,u[h]+=m.x,u[h+1]+=m.y,u[h+2]+=m.z}else for(var o=0,s=i.length;o<s;o+=9)d.fromArray(i,o),p.fromArray(i,o+3),f.fromArray(i,o+6),m.subVectors(f,p),g.subVectors(d,p),m.cross(g),u[o]=m.x,u[o+1]=m.y,u[o+2]=m.z,u[o+3]=m.x,u[o+4]=m.y,u[o+5]=m.z,u[o+6]=m.x,u[o+7]=m.y,u[o+8]=m.z;this.normalizeNormals(),e.normal.needsUpdate=!0}},merge:function(t,e){if(!t||!t.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t);void 0===e&&(e=0);var r=this.attributes;for(var n in r)if(void 0!==t.attributes[n])for(var i=r[n].array,a=t.attributes[n],o=a.array,s=0,c=a.itemSize*e;s<o.length;s++,c++)i[c]=o[s];return this},normalizeNormals:function(){for(var t,e,r,n,i=this.attributes.normal,a=0,o=i.count;a<o;a++)t=i.getX(a),e=i.getY(a),r=i.getZ(a),n=1/Math.sqrt(t*t+e*e+r*r),i.setXYZ(a,t*n,e*n,r*n)},toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var t=new Ct,e=this.index.array,r=this.attributes;for(var n in r){for(var i=r[n],a=i.array,o=i.itemSize,s=new a.constructor(e.length*o),c=0,l=0,h=0,u=e.length;h<u;h++){c=e[h]*o;for(var d=0;d<o;d++)s[l++]=a[c++]}t.addAttribute(n,new Mt(s,o))}return t},toJSON:function(){var t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),void 0!==this.parameters){var e=this.parameters;for(var r in e)void 0!==e[r]&&(t[r]=e[r]);return t}t.data={attributes:{}};var n=this.index;if(null!==n){o=Array.prototype.slice.call(n.array);t.data.index={type:n.array.constructor.name,array:o}}var i=this.attributes;for(var r in i){var a=i[r],o=Array.prototype.slice.call(a.array);t.data.attributes[r]={itemSize:a.itemSize,type:a.array.constructor.name,array:o,normalized:a.normalized}}var s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new Ct).copy(this)},copy:function(t){var e,r,n;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var a=t.attributes;for(e in a){var o=a[e];this.addAttribute(e,o.clone())}var s=t.morphAttributes;for(e in s){var c=[],l=s[e];for(r=0,n=l.length;r<n;r++)c.push(l[r].clone());this.morphAttributes[e]=c}var h=t.groups;for(r=0,n=h.length;r<n;r++){var u=h[r];this.addGroup(u.start,u.count,u.materialIndex)}var d=t.boundingBox;null!==d&&(this.boundingBox=d.clone());var p=t.boundingSphere;return null!==p&&(this.boundingSphere=p.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Rt.prototype=Object.create(_t.prototype),Rt.prototype.constructor=Rt,Pt.prototype=Object.create(Ct.prototype),Pt.prototype.constructor=Pt,It.prototype=Object.create(_t.prototype),It.prototype.constructor=It,Ot.prototype=Object.create(Ct.prototype),Ot.prototype.constructor=Ot,Nt.prototype=Object.create(it.prototype),Nt.prototype.constructor=Nt,Nt.prototype.isMeshBasicMaterial=!0,Nt.prototype.copy=function(t){return it.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this},Object.assign(Dt.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return(e||new n).copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(){var t=new n;return function(e){return this.origin.copy(this.at(e,t)),this}}(),closestPointToPoint:function(t,e){var r=e||new n;r.subVectors(t,this.origin);var i=r.dot(this.direction);return i<0?r.copy(this.origin):r.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(){var t=new n;return function(e){var r=t.subVectors(e,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(e):(t.copy(this.direction).multiplyScalar(r).add(this.origin),t.distanceToSquared(e))}}(),distanceSqToSegment:function(){var t=new n,e=new n,r=new n;return function(n,i,a,o){t.copy(n).add(i).multiplyScalar(.5),e.copy(i).sub(n).normalize(),r.copy(this.origin).sub(t);var s,c,l,h,u=.5*n.distanceTo(i),d=-this.direction.dot(e),p=r.dot(this.direction),f=-r.dot(e),m=r.lengthSq(),g=Math.abs(1-d*d);if(g>0)if(s=d*f-p,c=d*p-f,h=u*g,s>=0)if(c>=-h)if(c<=h){var v=1/g;l=(s*=v)*(s+d*(c*=v)+2*p)+c*(d*s+c+2*f)+m}else c=u,l=-(s=Math.max(0,-(d*c+p)))*s+c*(c+2*f)+m;else c=-u,l=-(s=Math.max(0,-(d*c+p)))*s+c*(c+2*f)+m;else c<=-h?l=-(s=Math.max(0,-(-d*u+p)))*s+(c=s>0?-u:Math.min(Math.max(-u,-f),u))*(c+2*f)+m:c<=h?(s=0,l=(c=Math.min(Math.max(-u,-f),u))*(c+2*f)+m):l=-(s=Math.max(0,-(d*u+p)))*s+(c=s>0?u:Math.min(Math.max(-u,-f),u))*(c+2*f)+m;else c=d>0?-u:u,l=-(s=Math.max(0,-(d*c+p)))*s+c*(c+2*f)+m;return a&&a.copy(this.direction).multiplyScalar(s).add(this.origin),o&&o.copy(e).multiplyScalar(c).add(t),l}}(),intersectSphere:function(){var t=new n;return function(e,r){t.subVectors(e.center,this.origin);var n=t.dot(this.direction),i=t.dot(t)-n*n,a=e.radius*e.radius;if(i>a)return null;var o=Math.sqrt(a-i),s=n-o,c=n+o;return s<0&&c<0?null:s<0?this.at(c,r):this.at(s,r)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,n,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,h=1/this.direction.z,u=this.origin;return c>=0?(r=(t.min.x-u.x)*c,n=(t.max.x-u.x)*c):(r=(t.max.x-u.x)*c,n=(t.min.x-u.x)*c),l>=0?(i=(t.min.y-u.y)*l,a=(t.max.y-u.y)*l):(i=(t.max.y-u.y)*l,a=(t.min.y-u.y)*l),r>a||i>n?null:((i>r||r!==r)&&(r=i),(a<n||n!==n)&&(n=a),h>=0?(o=(t.min.z-u.z)*h,s=(t.max.z-u.z)*h):(o=(t.max.z-u.z)*h,s=(t.min.z-u.z)*h),r>s||o>n?null:((o>r||r!==r)&&(r=o),(s<n||n!==n)&&(n=s),n<0?null:this.at(r>=0?r:n,e)))},intersectsBox:function(){var t=new n;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new n,e=new n,r=new n,i=new n;return function(n,a,o,s,c){e.subVectors(a,n),r.subVectors(o,n),i.crossVectors(e,r);var l,h=this.direction.dot(i);if(h>0){if(s)return null;l=1}else{if(!(h<0))return null;l=-1,h=-h}t.subVectors(this.origin,n);var u=l*this.direction.dot(r.crossVectors(t,r));if(u<0)return null;var d=l*this.direction.dot(e.cross(t));if(d<0)return null;if(u+d>h)return null;var p=-l*t.dot(i);return p<0?null:this.at(p/h,c)}}(),applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}),Object.assign(Ut.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return(t||new n).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new n).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){var r=e||new n;return this.delta(r).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(){var t=new n,e=new n;return function(r,n){t.subVectors(r,this.start),e.subVectors(this.end,this.start);var i=e.dot(e),a=e.dot(t)/i;return n&&(a=Ko.clamp(a,0,1)),a}}(),closestPointToPoint:function(t,e,r){var i=this.closestPointToPointParameter(t,e),a=r||new n;return this.delta(a).multiplyScalar(i).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),Object.assign(zt,{normal:function(){var t=new n;return function(e,r,i,a){var o=a||new n;o.subVectors(i,r),t.subVectors(e,r),o.cross(t);var s=o.lengthSq();return s>0?o.multiplyScalar(1/Math.sqrt(s)):o.set(0,0,0)}}(),barycoordFromPoint:function(){var t=new n,e=new n,r=new n;return function(i,a,o,s,c){t.subVectors(s,a),e.subVectors(o,a),r.subVectors(i,a);var l=t.dot(t),h=t.dot(e),u=t.dot(r),d=e.dot(e),p=e.dot(r),f=l*d-h*h,m=c||new n;if(0===f)return m.set(-2,-1,-1);var g=1/f,v=(d*u-h*p)*g,y=(l*p-h*u)*g;return m.set(1-v-y,y,v)}}(),containsPoint:function(){var t=new n;return function(e,r,n,i){var a=zt.barycoordFromPoint(e,r,n,i,t);return a.x>=0&&a.y>=0&&a.x+a.y<=1}}()}),Object.assign(zt.prototype,{set:function(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this},setFromPointsAndIndices:function(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:function(){var t=new n,e=new n;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),midpoint:function(t){return(t||new n).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return zt.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new ht).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return zt.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return zt.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t=new ht,e=[new Ut,new Ut,new Ut],r=new n,i=new n;return function(a,o){var s=o||new n,c=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(a,r),!0===this.containsPoint(r))s.copy(r);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var l=0;l<e.length;l++){e[l].closestPointToPoint(r,!0,i);var h=r.distanceToSquared(i);h<c&&(c=h,s.copy(i))}}return s}}(),equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}),Bt.prototype=Object.assign(Object.create(gt.prototype),{constructor:Bt,isMesh:!0,setDrawMode:function(t){this.drawMode=t},copy:function(t){return gt.prototype.copy.call(this,t),this.drawMode=t.drawMode,this},updateMorphTargets:function(){var t,e,r,n=this.geometry;if(n.isBufferGeometry){var i=n.morphAttributes,a=Object.keys(i);if(a.length>0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t<e;t++)r=o[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[r]=t}}else{var s=n.morphTargets;if(void 0!==s&&s.length>0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;t<e;t++)r=s[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[r]=t}},raycast:function(){function t(t,e,r,n,i,a,o){return zt.barycoordFromPoint(t,e,r,n,y),i.multiplyScalar(y.x),a.multiplyScalar(y.y),o.multiplyScalar(y.z),i.add(a).add(o),i.clone()}function r(t,e,r,n,i,a,o){var s=t.material;if(null===(s.side===Js?r.intersectTriangle(a,i,n,!0,o):r.intersectTriangle(n,i,a,s.side!==Qs,o)))return null;b.copy(o),b.applyMatrix4(t.matrixWorld);var c=e.ray.origin.distanceTo(b);return c<e.near||c>e.far?null:{distance:c,point:b.clone(),object:t}}function i(e,n,i,a,o,s,h,d){c.fromBufferAttribute(a,s),l.fromBufferAttribute(a,h),u.fromBufferAttribute(a,d);var p=r(e,n,i,c,l,u,x);return p&&(o&&(m.fromBufferAttribute(o,s),g.fromBufferAttribute(o,h),v.fromBufferAttribute(o,d),p.uv=t(x,c,l,u,m,g,v)),p.face=new bt(s,h,d,zt.normal(c,l,u)),p.faceIndex=s),p}var a=new e,o=new Dt,s=new ct,c=new n,l=new n,u=new n,d=new n,p=new n,f=new n,m=new h,g=new h,v=new h,y=new n,x=new n,b=new n;return function(e,n){var h=this.geometry,y=this.material,b=this.matrixWorld;if(void 0!==y&&(null===h.boundingSphere&&h.computeBoundingSphere(),s.copy(h.boundingSphere),s.applyMatrix4(b),!1!==e.ray.intersectsSphere(s)&&(a.getInverse(b),o.copy(e.ray).applyMatrix4(a),null===h.boundingBox||!1!==o.intersectsBox(h.boundingBox)))){var w;if(h.isBufferGeometry){var _,M,E,S,T,A=h.index,L=h.attributes.position,C=h.attributes.uv;if(null!==A)for(S=0,T=A.count;S<T;S+=3)_=A.getX(S),M=A.getX(S+1),E=A.getX(S+2),(w=i(this,e,o,L,C,_,M,E))&&(w.faceIndex=Math.floor(S/3),n.push(w));else for(S=0,T=L.count;S<T;S+=3)(w=i(this,e,o,L,C,_=S,M=S+1,E=S+2))&&(w.index=_,n.push(w))}else if(h.isGeometry){var R,P,I,O,N=Array.isArray(y),D=h.vertices,U=h.faces,z=h.faceVertexUvs[0];z.length>0&&(O=z);for(var B=0,F=U.length;B<F;B++){var k=U[B],G=N?y[k.materialIndex]:y;if(void 0!==G){if(R=D[k.a],P=D[k.b],I=D[k.c],!0===G.morphTargets){var V=h.morphTargets,H=this.morphTargetInfluences;c.set(0,0,0),l.set(0,0,0),u.set(0,0,0);for(var j=0,W=V.length;j<W;j++){var X=H[j];if(0!==X){var Y=V[j].vertices;c.addScaledVector(d.subVectors(Y[k.a],R),X),l.addScaledVector(p.subVectors(Y[k.b],P),X),u.addScaledVector(f.subVectors(Y[k.c],I),X)}}c.add(R),l.add(P),u.add(I),R=c,P=l,I=u}if(w=r(this,e,o,R,P,I,x)){if(O&&O[B]){var q=O[B];m.copy(q[0]),g.copy(q[1]),v.copy(q[2]),w.uv=t(x,R,P,I,m,g,v)}w.face=k,w.faceIndex=B,n.push(w)}}}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var ch=0;fe.prototype=Object.assign(Object.create(xt.prototype),{constructor:fe,isArrayCamera:!0}),xe.prototype.isFogExp2=!0,xe.prototype.clone=function(){return new xe(this.color.getHex(),this.density)},xe.prototype.toJSON=function(t){return{type:"FogExp2",color:this.color.getHex(),density:this.density}},be.prototype.isFog=!0,be.prototype.clone=function(){return new be(this.color.getHex(),this.near,this.far)},be.prototype.toJSON=function(t){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}},we.prototype=Object.assign(Object.create(gt.prototype),{constructor:we,copy:function(t,e){return gt.prototype.copy.call(this,t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this},toJSON:function(t){var e=gt.prototype.toJSON.call(this,t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}),_e.prototype=Object.assign(Object.create(gt.prototype),{constructor:_e,isLensFlare:!0,copy:function(t){gt.prototype.copy.call(this,t),this.positionScreen.copy(t.positionScreen),this.customUpdateCallback=t.customUpdateCallback;for(var e=0,r=t.lensFlares.length;e<r;e++)this.lensFlares.push(t.lensFlares[e]);return this},add:function(t,e,r,n,i,a){void 0===e&&(e=-1),void 0===r&&(r=0),void 0===a&&(a=1),void 0===i&&(i=new c(16777215)),void 0===n&&(n=ic),r=Math.min(r,Math.max(0,r)),this.lensFlares.push({texture:t,size:e,distance:r,x:0,y:0,z:0,scale:1,rotation:0,opacity:a,color:i,blending:n})},updateLensFlares:function(){var t,e,r=this.lensFlares.length,n=2*-this.positionScreen.x,i=2*-this.positionScreen.y;for(t=0;t<r;t++)(e=this.lensFlares[t]).x=this.positionScreen.x+n*e.distance,e.y=this.positionScreen.y+i*e.distance,e.wantedRotation=e.x*Math.PI*.25,e.rotation+=.25*(e.wantedRotation-e.rotation)}}),Me.prototype=Object.create(it.prototype),Me.prototype.constructor=Me,Me.prototype.isSpriteMaterial=!0,Me.prototype.copy=function(t){return it.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.rotation=t.rotation,this},Ee.prototype=Object.assign(Object.create(gt.prototype),{constructor:Ee,isSprite:!0,raycast:function(){var t=new n,e=new n,r=new n;return function(n,i){e.setFromMatrixPosition(this.matrixWorld),n.ray.closestPointToPoint(e,t),r.setFromMatrixScale(this.matrixWorld);var a=r.x*r.y/4;if(!(e.distanceToSquared(t)>a)){var o=n.ray.origin.distanceTo(t);o<n.near||o>n.far||i.push({distance:o,point:t.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),Se.prototype=Object.assign(Object.create(gt.prototype),{constructor:Se,copy:function(t){gt.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r<n;r++){var i=e[r];this.addLevel(i.object.clone(),i.distance)}return this},addLevel:function(t,e){void 0===e&&(e=0),e=Math.abs(e);for(var r=this.levels,n=0;n<r.length&&!(e<r[n].distance);n++);r.splice(n,0,{distance:e,object:t}),this.add(t)},getObjectForDistance:function(t){for(var e=this.levels,r=1,n=e.length;r<n&&!(t<e[r].distance);r++);return e[r-1].object},raycast:function(){var t=new n;return function(e,r){t.setFromMatrixPosition(this.matrixWorld);var n=e.ray.origin.distanceTo(t);this.getObjectForDistance(n).raycast(e,r)}}(),update:function(){var t=new n,e=new n;return function(r){var n=this.levels;if(n.length>1){t.setFromMatrixPosition(r.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var i=t.distanceTo(e);n[0].object.visible=!0;for(var a=1,o=n.length;a<o&&i>=n[a].distance;a++)n[a-1].object.visible=!1,n[a].object.visible=!0;for(;a<o;a++)n[a].object.visible=!1}}}(),toJSON:function(t){var e=gt.prototype.toJSON.call(this,t);e.object.levels=[];for(var r=this.levels,n=0,i=r.length;n<i;n++){var a=r[n];e.object.levels.push({object:a.object.uuid,distance:a.distance})}return e}}),Object.assign(Te.prototype,{calculateInverses:function(){this.boneInverses=[];for(var t=0,r=this.bones.length;t<r;t++){var n=new e;this.bones[t]&&n.getInverse(this.bones[t].matrixWorld),this.boneInverses.push(n)}},pose:function(){var t,e,r;for(e=0,r=this.bones.length;e<r;e++)(t=this.bones[e])&&t.matrixWorld.getInverse(this.boneInverses[e]);for(e=0,r=this.bones.length;e<r;e++)(t=this.bones[e])&&(t.parent&&t.parent.isBone?(t.matrix.getInverse(t.parent.matrixWorld),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))},update:function(){var t=new e,r=new e;return function(){for(var e=this.bones,n=this.boneInverses,i=this.boneMatrices,a=this.boneTexture,o=0,s=e.length;o<s;o++){var c=e[o]?e[o].matrixWorld:r;t.multiplyMatrices(c,n[o]),t.toArray(i,16*o)}void 0!==a&&(a.needsUpdate=!0)}}(),clone:function(){return new Te(this.bones,this.boneInverses)}}),Ae.prototype=Object.assign(Object.create(gt.prototype),{constructor:Ae,isBone:!0}),Le.prototype=Object.assign(Object.create(Bt.prototype),{constructor:Le,isSkinnedMesh:!0,initBones:function(){var t,e,r,n,i=[];if(this.geometry&&void 0!==this.geometry.bones){for(r=0,n=this.geometry.bones.length;r<n;r++)e=this.geometry.bones[r],t=new Ae,i.push(t),t.name=e.name,t.position.fromArray(e.pos),t.quaternion.fromArray(e.rotq),void 0!==e.scl&&t.scale.fromArray(e.scl);for(r=0,n=this.geometry.bones.length;r<n;r++)-1!==(e=this.geometry.bones[r]).parent&&null!==e.parent&&void 0!==i[e.parent]?i[e.parent].add(i[r]):this.add(i[r])}return this.updateMatrixWorld(!0),i},bind:function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){var t,e;if(this.geometry&&this.geometry.isGeometry)for(e=0;e<this.geometry.skinWeights.length;e++){var r=this.geometry.skinWeights[e];(t=1/r.lengthManhattan())!==1/0?r.multiplyScalar(t):r.set(1,0,0,0)}else if(this.geometry&&this.geometry.isBufferGeometry){var n=new y,i=this.geometry.attributes.skinWeight;for(e=0;e<i.count;e++)n.x=i.getX(e),n.y=i.getY(e),n.z=i.getZ(e),n.w=i.getW(e),(t=1/n.lengthManhattan())!==1/0?n.multiplyScalar(t):n.set(1,0,0,0),i.setXYZW(e,n.x,n.y,n.z,n.w)}},updateMatrixWorld:function(t){Bt.prototype.updateMatrixWorld.call(this,t),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Ce.prototype=Object.create(it.prototype),Ce.prototype.constructor=Ce,Ce.prototype.isLineBasicMaterial=!0,Ce.prototype.copy=function(t){return it.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this},Re.prototype=Object.assign(Object.create(gt.prototype),{constructor:Re,isLine:!0,raycast:function(){var t=new e,r=new Dt,i=new ct;return function(e,a){var o=e.linePrecision,s=o*o,c=this.geometry,l=this.matrixWorld;if(null===c.boundingSphere&&c.computeBoundingSphere(),i.copy(c.boundingSphere),i.applyMatrix4(l),!1!==e.ray.intersectsSphere(i)){t.getInverse(l),r.copy(e.ray).applyMatrix4(t);var h=new n,u=new n,d=new n,p=new n,f=this&&this.isLineSegments?2:1;if(c.isBufferGeometry){var m=c.index,g=c.attributes.position.array;if(null!==m)for(var v=m.array,y=0,x=v.length-1;y<x;y+=f){var b=v[y],w=v[y+1];h.fromArray(g,3*b),u.fromArray(g,3*w),(E=r.distanceSqToSegment(h,u,p,d))>s||(p.applyMatrix4(this.matrixWorld),(S=e.ray.origin.distanceTo(p))<e.near||S>e.far||a.push({distance:S,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this}))}else for(var y=0,x=g.length/3-1;y<x;y+=f)h.fromArray(g,3*y),u.fromArray(g,3*y+3),(E=r.distanceSqToSegment(h,u,p,d))>s||(p.applyMatrix4(this.matrixWorld),(S=e.ray.origin.distanceTo(p))<e.near||S>e.far||a.push({distance:S,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this}))}else if(c.isGeometry)for(var _=c.vertices,M=_.length,y=0;y<M-1;y+=f){var E=r.distanceSqToSegment(_[y],_[y+1],p,d);if(!(E>s)){p.applyMatrix4(this.matrixWorld);var S=e.ray.origin.distanceTo(p);S<e.near||S>e.far||a.push({distance:S,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Pe.prototype=Object.assign(Object.create(Re.prototype),{constructor:Pe,isLineSegments:!0}),Ie.prototype=Object.assign(Object.create(Re.prototype),{constructor:Ie,isLineLoop:!0}),Oe.prototype=Object.create(it.prototype),Oe.prototype.constructor=Oe,Oe.prototype.isPointsMaterial=!0,Oe.prototype.copy=function(t){return it.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},Ne.prototype=Object.assign(Object.create(gt.prototype),{constructor:Ne,isPoints:!0,raycast:function(){var t=new e,r=new Dt,i=new ct;return function(e,a){function o(t,n){var i=r.distanceSqToPoint(t);if(i<d){var o=r.closestPointToPoint(t);o.applyMatrix4(l);var c=e.ray.origin.distanceTo(o);if(c<e.near||c>e.far)return;a.push({distance:c,distanceToRay:Math.sqrt(i),point:o.clone(),index:n,face:null,object:s})}}var s=this,c=this.geometry,l=this.matrixWorld,h=e.params.Points.threshold;if(null===c.boundingSphere&&c.computeBoundingSphere(),i.copy(c.boundingSphere),i.applyMatrix4(l),i.radius+=h,!1!==e.ray.intersectsSphere(i)){t.getInverse(l),r.copy(e.ray).applyMatrix4(t);var u=h/((this.scale.x+this.scale.y+this.scale.z)/3),d=u*u,p=new n;if(c.isBufferGeometry){var f=c.index,m=c.attributes.position.array;if(null!==f)for(var g=f.array,v=0,y=g.length;v<y;v++){var x=g[v];p.fromArray(m,3*x),o(p,x)}else for(var v=0,b=m.length/3;v<b;v++)p.fromArray(m,3*v),o(p,v)}else for(var w=c.vertices,v=0,b=w.length;v<b;v++)o(w[v],v)}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),De.prototype=Object.assign(Object.create(gt.prototype),{constructor:De}),Ue.prototype=Object.create(u.prototype),Ue.prototype.constructor=Ue,Ue.prototype.isCompressedTexture=!0,ze.prototype=Object.create(u.prototype),ze.prototype.constructor=ze,Be.prototype=Object.create(Ct.prototype),Be.prototype.constructor=Be,Fe.prototype=Object.create(_t.prototype),Fe.prototype.constructor=Fe,ke.prototype=Object.create(Ct.prototype),ke.prototype.constructor=ke,Ge.prototype=Object.create(_t.prototype),Ge.prototype.constructor=Ge,Ve.prototype=Object.create(Ct.prototype),Ve.prototype.constructor=Ve,He.prototype=Object.create(_t.prototype),He.prototype.constructor=He,je.prototype=Object.create(Ve.prototype),je.prototype.constructor=je,We.prototype=Object.create(_t.prototype),We.prototype.constructor=We,Xe.prototype=Object.create(Ve.prototype),Xe.prototype.constructor=Xe,Ye.prototype=Object.create(_t.prototype),Ye.prototype.constructor=Ye,qe.prototype=Object.create(Ve.prototype),qe.prototype.constructor=qe,Ze.prototype=Object.create(_t.prototype),Ze.prototype.constructor=Ze,Je.prototype=Object.create(Ve.prototype),Je.prototype.constructor=Je,Qe.prototype=Object.create(_t.prototype),Qe.prototype.constructor=Qe,Ke.prototype=Object.create(Ct.prototype),Ke.prototype.constructor=Ke,$e.prototype=Object.create(_t.prototype),$e.prototype.constructor=$e,tr.prototype=Object.create(Ct.prototype),tr.prototype.constructor=tr,er.prototype=Object.create(_t.prototype),er.prototype.constructor=er,rr.prototype=Object.create(Ct.prototype),rr.prototype.constructor=rr;var lh={area:function(t){for(var e=t.length,r=0,n=e-1,i=0;i<e;n=i++)r+=t[n].x*t[i].y-t[i].x*t[n].y;return.5*r},triangulate:function(){function t(t,e,r,n,i,a){var o,s,c,l,h,u,d,p,f;if(s=t[a[e]].x,c=t[a[e]].y,l=t[a[r]].x,h=t[a[r]].y,u=t[a[n]].x,d=t[a[n]].y,(l-s)*(d-c)-(h-c)*(u-s)<=0)return!1;var m,g,v,y,x,b,w,_,M,E,S,T,A,L,C;for(m=u-l,g=d-h,v=s-u,y=c-d,x=l-s,b=h-c,o=0;o<i;o++)if(p=t[a[o]].x,f=t[a[o]].y,!(p===s&&f===c||p===l&&f===h||p===u&&f===d)&&(w=p-s,_=f-c,M=p-l,E=f-h,S=p-u,T=f-d,C=m*E-g*M,A=x*_-b*w,L=v*T-y*S,C>=-Number.EPSILON&&L>=-Number.EPSILON&&A>=-Number.EPSILON))return!1;return!0}return function(e,r){var n=e.length;if(n<3)return null;var i,a,o,s=[],c=[],l=[];if(lh.area(e)>0)for(a=0;a<n;a++)c[a]=a;else for(a=0;a<n;a++)c[a]=n-1-a;var h=n,u=2*h;for(a=h-1;h>2;){if(u--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),r?l:s;if(i=a,h<=i&&(i=0),a=i+1,h<=a&&(a=0),o=a+1,h<=o&&(o=0),t(e,i,a,o,h,c)){var d,p,f,m,g;for(d=c[i],p=c[a],f=c[o],s.push([e[d],e[p],e[f]]),l.push([c[i],c[a],c[o]]),m=a,g=a+1;g<h;m++,g++)c[m]=c[g];u=2*--h}}return r?l:s}}(),triangulateShape:function(t,e){function r(t){var e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function n(t,e,r){return t.x!==e.x?t.x<e.x?t.x<=r.x&&r.x<=e.x:e.x<=r.x&&r.x<=t.x:t.y<e.y?t.y<=r.y&&r.y<=e.y:e.y<=r.y&&r.y<=t.y}function i(t,e,r,i,a){var o=e.x-t.x,s=e.y-t.y,c=i.x-r.x,l=i.y-r.y,h=t.x-r.x,u=t.y-r.y,d=s*c-o*l,p=s*h-o*u;if(Math.abs(d)>Number.EPSILON){var f;if(d>0){if(p<0||p>d)return[];if((f=l*h-c*u)<0||f>d)return[]}else{if(p>0||p<d)return[];if((f=l*h-c*u)>0||f<d)return[]}if(0===f)return!a||0!==p&&p!==d?[t]:[];if(f===d)return!a||0!==p&&p!==d?[e]:[];if(0===p)return[r];if(p===d)return[i];var m=f/d;return[{x:t.x+m*o,y:t.y+m*s}]}if(0!==p||l*h!=c*u)return[];var g=0===o&&0===s,v=0===c&&0===l;if(g&&v)return t.x!==r.x||t.y!==r.y?[]:[t];if(g)return n(r,i,t)?[t]:[];if(v)return n(t,e,r)?[r]:[];var y,x,b,w,_,M,E,S;return 0!==o?(t.x<e.x?(y=t,b=t.x,x=e,w=e.x):(y=e,b=e.x,x=t,w=t.x),r.x<i.x?(_=r,E=r.x,M=i,S=i.x):(_=i,E=i.x,M=r,S=r.x)):(t.y<e.y?(y=t,b=t.y,x=e,w=e.y):(y=e,b=e.y,x=t,w=t.y),r.y<i.y?(_=r,E=r.y,M=i,S=i.y):(_=i,E=i.y,M=r,S=r.y)),b<=E?w<E?[]:w===E?a?[]:[_]:w<=S?[_,x]:[_,M]:b>S?[]:b===S?a?[]:[y]:w<=S?[y,x]:[y,M]}function a(t,e,r,n){var i=e.x-t.x,a=e.y-t.y,o=r.x-t.x,s=r.y-t.y,c=n.x-t.x,l=n.y-t.y,h=i*s-a*o,u=i*l-a*c;if(Math.abs(h)>Number.EPSILON){var d=c*s-l*o;return h>0?u>=0&&d>=0:u>=0||d>=0}return u>0}r(t),e.forEach(r);for(var o,s,c,l,h,u,d={},p=t.concat(),f=0,m=e.length;f<m;f++)Array.prototype.push.apply(p,e[f]);for(o=0,s=p.length;o<s;o++)void 0!==d[h=p[o].x+":"+p[o].y]&&console.warn("THREE.ShapeUtils: Duplicate point",h,o),d[h]=o;var g=function(t,e){for(var r,n,o,s,c,l,h,u,d,p,f,m=t.concat(),g=[],v=[],y=0,x=e.length;y<x;y++)g.push(y);for(var b=0,w=2*g.length;g.length>0;){if(--w<0){console.log("Infinite Loop! Holes left:"+g.length+", Probably Hole outside Shape!");break}for(o=b;o<m.length;o++){s=m[o],n=-1;for(y=0;y<g.length;y++)if(l=g[y],h=s.x+":"+s.y+":"+l,void 0===v[h]){r=e[l];for(var _=0;_<r.length;_++)if(c=r[_],function(t,e){var n=m.length-1,i=t-1;i<0&&(i=n);var o=t+1;o>n&&(o=0);var s=a(m[t],m[i],m[o],r[e]);if(!s)return!1;var c=r.length-1,l=e-1;l<0&&(l=c);var h=e+1;return h>c&&(h=0),!!(s=a(r[e],r[l],r[h],m[t]))}(o,_)&&!function(t,e){var r,n;for(r=0;r<m.length;r++)if(n=r+1,n%=m.length,i(t,e,m[r],m[n],!0).length>0)return!0;return!1}(s,c)&&!function(t,r){var n,a,o,s;for(n=0;n<g.length;n++)for(a=e[g[n]],o=0;o<a.length;o++)if(s=o+1,s%=a.length,i(t,r,a[o],a[s],!0).length>0)return!0;return!1}(s,c)){n=_,g.splice(y,1),u=m.slice(0,o+1),d=m.slice(o),p=r.slice(n),f=r.slice(0,n+1),m=u.concat(p).concat(f).concat(d),b=o;break}if(n>=0)break;v[h]=!0}if(n>=0)break}}return m}(t,e),v=lh.triangulate(g,!1);for(o=0,s=v.length;o<s;o++)for(l=v[o],c=0;c<3;c++)void 0!==(u=d[h=l[c].x+":"+l[c].y])&&(l[c]=u);return v.concat()},isClockWise:function(t){return lh.area(t)<0}};nr.prototype=Object.create(_t.prototype),nr.prototype.constructor=nr,ir.prototype=Object.create(Ct.prototype),ir.prototype.constructor=ir,ir.prototype.getArrays=function(){var t=this.getAttribute("position"),e=t?Array.prototype.slice.call(t.array):[],r=this.getAttribute("uv"),n=r?Array.prototype.slice.call(r.array):[],i=this.index;return{position:e,uv:n,index:i?Array.prototype.slice.call(i.array):[]}},ir.prototype.addShapeList=function(t,e){var r=t.length;e.arrays=this.getArrays();for(var n=0;n<r;n++){var i=t[n];this.addShape(i,e)}this.setIndex(e.arrays.index),this.addAttribute("position",new Tt(e.arrays.position,3)),this.addAttribute("uv",new Tt(e.arrays.uv,2))},ir.prototype.addShape=function(t,e){function r(t,e,r){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(r).add(t)}function i(t,e,r){var n,i,a,o=t.x-e.x,s=t.y-e.y,c=r.x-t.x,l=r.y-t.y,u=o*o+s*s,d=o*l-s*c;if(Math.abs(d)>Number.EPSILON){var p=Math.sqrt(u),f=Math.sqrt(c*c+l*l),m=e.x-s/p,g=e.y+o/p,v=((r.x-l/f-m)*l-(r.y+c/f-g)*c)/(o*l-s*c),y=(n=m+o*v-t.x)*n+(i=g+s*v-t.y)*i;if(y<=2)return new h(n,i);a=Math.sqrt(y/2)}else{var x=!1;o>Number.EPSILON?c>Number.EPSILON&&(x=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(x=!0):Math.sign(s)===Math.sign(l)&&(x=!0),x?(n=-s,i=o,a=Math.sqrt(u)):(n=o,i=s,a=Math.sqrt(u/2))}return new h(n/a,i/a)}function a(t,e){var r,n;for(J=t.length;--J>=0;){r=J,(n=J-1)<0&&(n=t.length-1);var i=0,a=L+2*S;for(i=0;i<a;i++){var o=Y*i,s=Y*(i+1);c(e+r+o,e+n+o,e+n+s,e+r+s,t,i,a,r,n)}}}function o(t,e,r){w.push(t),w.push(e),w.push(r)}function s(t,e,r){l(t),l(e),l(r);var n=y.length/3,i=P.generateTopUV(D,y,n-3,n-2,n-1);u(i[0]),u(i[1]),u(i[2])}function c(t,e,r,n,i,a,o,s,c){l(t),l(e),l(n),l(e),l(r),l(n);var h=y.length/3,d=P.generateSideWallUV(D,y,h-6,h-3,h-2,h-1);u(d[0]),u(d[1]),u(d[3]),u(d[1]),u(d[2]),u(d[3])}function l(t){x.push(y.length/3),y.push(w[3*t+0]),y.push(w[3*t+1]),y.push(w[3*t+2])}function u(t){b.push(t.x),b.push(t.y)}var d,p,f,m,g,v=e.arrays?e.arrays:this.getArrays(),y=v.position,x=v.index,b=v.uv,w=[],_=void 0!==e.amount?e.amount:100,M=void 0!==e.bevelThickness?e.bevelThickness:6,E=void 0!==e.bevelSize?e.bevelSize:M-2,S=void 0!==e.bevelSegments?e.bevelSegments:3,T=void 0===e.bevelEnabled||e.bevelEnabled,A=void 0!==e.curveSegments?e.curveSegments:12,L=void 0!==e.steps?e.steps:1,C=e.extrudePath,R=!1,P=void 0!==e.UVGenerator?e.UVGenerator:nr.WorldUVGenerator;C&&(d=C.getSpacedPoints(L),R=!0,T=!1,p=void 0!==e.frames?e.frames:C.computeFrenetFrames(L,!1),f=new n,m=new n,g=new n),T||(S=0,M=0,E=0);var I,O,N,D=this,U=t.extractPoints(A),z=U.shape,B=U.holes;if(!lh.isClockWise(z))for(z=z.reverse(),O=0,N=B.length;O<N;O++)I=B[O],lh.isClockWise(I)&&(B[O]=I.reverse());var F=lh.triangulateShape(z,B),k=z;for(O=0,N=B.length;O<N;O++)I=B[O],z=z.concat(I);for(var G,V,H,j,W,X,Y=z.length,q=F.length,Z=[],J=0,Q=k.length,K=Q-1,$=J+1;J<Q;J++,K++,$++)K===Q&&(K=0),$===Q&&($=0),Z[J]=i(k[J],k[K],k[$]);var tt,et=[],rt=Z.concat();for(O=0,N=B.length;O<N;O++){for(I=B[O],tt=[],J=0,K=(Q=I.length)-1,$=J+1;J<Q;J++,K++,$++)K===Q&&(K=0),$===Q&&($=0),tt[J]=i(I[J],I[K],I[$]);et.push(tt),rt=rt.concat(tt)}for(G=0;G<S;G++){for(H=G/S,j=M*Math.cos(H*Math.PI/2),V=E*Math.sin(H*Math.PI/2),J=0,Q=k.length;J<Q;J++)o((W=r(k[J],Z[J],V)).x,W.y,-j);for(O=0,N=B.length;O<N;O++)for(I=B[O],tt=et[O],J=0,Q=I.length;J<Q;J++)o((W=r(I[J],tt[J],V)).x,W.y,-j)}for(V=E,J=0;J<Y;J++)W=T?r(z[J],rt[J],V):z[J],R?(m.copy(p.normals[0]).multiplyScalar(W.x),f.copy(p.binormals[0]).multiplyScalar(W.y),g.copy(d[0]).add(m).add(f),o(g.x,g.y,g.z)):o(W.x,W.y,0);var nt;for(nt=1;nt<=L;nt++)for(J=0;J<Y;J++)W=T?r(z[J],rt[J],V):z[J],R?(m.copy(p.normals[nt]).multiplyScalar(W.x),f.copy(p.binormals[nt]).multiplyScalar(W.y),g.copy(d[nt]).add(m).add(f),o(g.x,g.y,g.z)):o(W.x,W.y,_/L*nt);for(G=S-1;G>=0;G--){for(H=G/S,j=M*Math.cos(H*Math.PI/2),V=E*Math.sin(H*Math.PI/2),J=0,Q=k.length;J<Q;J++)o((W=r(k[J],Z[J],V)).x,W.y,_+j);for(O=0,N=B.length;O<N;O++)for(I=B[O],tt=et[O],J=0,Q=I.length;J<Q;J++)W=r(I[J],tt[J],V),R?o(W.x,W.y+d[L-1].y,d[L-1].x+j):o(W.x,W.y,_+j)}!function(){var t=y.length/3;if(T){var r=0,n=Y*r;for(J=0;J<q;J++)s((X=F[J])[2]+n,X[1]+n,X[0]+n);for(n=Y*(r=L+2*S),J=0;J<q;J++)s((X=F[J])[0]+n,X[1]+n,X[2]+n)}else{for(J=0;J<q;J++)s((X=F[J])[2],X[1],X[0]);for(J=0;J<q;J++)s((X=F[J])[0]+Y*L,X[1]+Y*L,X[2]+Y*L)}D.addGroup(t,y.length/3-t,void 0!==e.material?e.material:0)}(),function(){var t=y.length/3,r=0;for(a(k,r),r+=k.length,O=0,N=B.length;O<N;O++)a(I=B[O],r),r+=I.length;D.addGroup(t,y.length/3-t,void 0!==e.extrudeMaterial?e.extrudeMaterial:1)}(),e.arrays||(this.setIndex(x),this.addAttribute("position",new Tt(y,3)),this.addAttribute("uv",new Tt(e.arrays.uv,2)))},nr.WorldUVGenerator={generateTopUV:function(t,e,r,n,i){var a=e[3*r],o=e[3*r+1],s=e[3*n],c=e[3*n+1],l=e[3*i],u=e[3*i+1];return[new h(a,o),new h(s,c),new h(l,u)]},generateSideWallUV:function(t,e,r,n,i,a){var o=e[3*r],s=e[3*r+1],c=e[3*r+2],l=e[3*n],u=e[3*n+1],d=e[3*n+2],p=e[3*i],f=e[3*i+1],m=e[3*i+2],g=e[3*a],v=e[3*a+1],y=e[3*a+2];return Math.abs(s-u)<.01?[new h(o,1-c),new h(l,1-d),new h(p,1-m),new h(g,1-y)]:[new h(s,1-c),new h(u,1-d),new h(f,1-m),new h(v,1-y)]}},ar.prototype=Object.create(_t.prototype),ar.prototype.constructor=ar,or.prototype=Object.create(ir.prototype),or.prototype.constructor=or,sr.prototype=Object.create(_t.prototype),sr.prototype.constructor=sr,cr.prototype=Object.create(Ct.prototype),cr.prototype.constructor=cr,lr.prototype=Object.create(_t.prototype),lr.prototype.constructor=lr,hr.prototype=Object.create(Ct.prototype),hr.prototype.constructor=hr,ur.prototype=Object.create(_t.prototype),ur.prototype.constructor=ur,dr.prototype=Object.create(Ct.prototype),dr.prototype.constructor=dr,pr.prototype=Object.create(_t.prototype),pr.prototype.constructor=pr,fr.prototype=Object.create(Ct.prototype),fr.prototype.constructor=fr,mr.prototype=Object.create(Ct.prototype),mr.prototype.constructor=mr,gr.prototype=Object.create(_t.prototype),gr.prototype.constructor=gr,vr.prototype=Object.create(Ct.prototype),vr.prototype.constructor=vr,yr.prototype=Object.create(gr.prototype),yr.prototype.constructor=yr,xr.prototype=Object.create(vr.prototype),xr.prototype.constructor=xr,br.prototype=Object.create(_t.prototype),br.prototype.constructor=br,wr.prototype=Object.create(Ct.prototype),wr.prototype.constructor=wr;var hh=Object.freeze({WireframeGeometry:Be,ParametricGeometry:Fe,ParametricBufferGeometry:ke,TetrahedronGeometry:He,TetrahedronBufferGeometry:je,OctahedronGeometry:We,OctahedronBufferGeometry:Xe,IcosahedronGeometry:Ye,IcosahedronBufferGeometry:qe,DodecahedronGeometry:Ze,DodecahedronBufferGeometry:Je,PolyhedronGeometry:Ge,PolyhedronBufferGeometry:Ve,TubeGeometry:Qe,TubeBufferGeometry:Ke,TorusKnotGeometry:$e,TorusKnotBufferGeometry:tr,TorusGeometry:er,TorusBufferGeometry:rr,TextGeometry:ar,TextBufferGeometry:or,SphereGeometry:sr,SphereBufferGeometry:cr,RingGeometry:lr,RingBufferGeometry:hr,PlaneGeometry:It,PlaneBufferGeometry:Ot,LatheGeometry:ur,LatheBufferGeometry:dr,ShapeGeometry:pr,ShapeBufferGeometry:fr,ExtrudeGeometry:nr,ExtrudeBufferGeometry:ir,EdgesGeometry:mr,ConeGeometry:yr,ConeBufferGeometry:xr,CylinderGeometry:gr,CylinderBufferGeometry:vr,CircleGeometry:br,CircleBufferGeometry:wr,BoxGeometry:Rt,BoxBufferGeometry:Pt});_r.prototype=Object.create(at.prototype),_r.prototype.constructor=_r,_r.prototype.isShadowMaterial=!0,Mr.prototype=Object.create(at.prototype),Mr.prototype.constructor=Mr,Mr.prototype.isRawShaderMaterial=!0,Er.prototype=Object.create(it.prototype),Er.prototype.constructor=Er,Er.prototype.isMeshStandardMaterial=!0,Er.prototype.copy=function(t){return it.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Sr.prototype=Object.create(Er.prototype),Sr.prototype.constructor=Sr,Sr.prototype.isMeshPhysicalMaterial=!0,Sr.prototype.copy=function(t){return Er.prototype.copy.call(this,t),this.defines={PHYSICAL:""},this.reflectivity=t.reflectivity,this.clearCoat=t.clearCoat,this.clearCoatRoughness=t.clearCoatRoughness,this},Tr.prototype=Object.create(it.prototype),Tr.prototype.constructor=Tr,Tr.prototype.isMeshPhongMaterial=!0,Tr.prototype.copy=function(t){return it.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Ar.prototype=Object.create(Tr.prototype),Ar.prototype.constructor=Ar,Ar.prototype.isMeshToonMaterial=!0,Ar.prototype.copy=function(t){return Tr.prototype.copy.call(this,t),this.gradientMap=t.gradientMap,this},Lr.prototype=Object.create(it.prototype),Lr.prototype.constructor=Lr,Lr.prototype.isMeshNormalMaterial=!0,Lr.prototype.copy=function(t){return it.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Cr.prototype=Object.create(it.prototype),Cr.prototype.constructor=Cr,Cr.prototype.isMeshLambertMaterial=!0,Cr.prototype.copy=function(t){return it.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Rr.prototype=Object.create(it.prototype),Rr.prototype.constructor=Rr,Rr.prototype.isLineDashedMaterial=!0,Rr.prototype.copy=function(t){return it.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var uh=Object.freeze({ShadowMaterial:_r,SpriteMaterial:Me,RawShaderMaterial:Mr,ShaderMaterial:at,PointsMaterial:Oe,MeshPhysicalMaterial:Sr,MeshStandardMaterial:Er,MeshPhongMaterial:Tr,MeshToonMaterial:Ar,MeshNormalMaterial:Lr,MeshLambertMaterial:Cr,MeshDepthMaterial:ot,MeshBasicMaterial:Nt,LineDashedMaterial:Rr,LineBasicMaterial:Ce,Material:it}),dh={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}},ph=new Pr;Object.assign(Ir.prototype,{load:function(t,e,r,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t);var i=this,a=dh.get(t);if(void 0!==a)return i.manager.itemStart(t),setTimeout(function(){e&&e(a),i.manager.itemEnd(t)},0),a;var o=t.match(/^data:(.*?)(;base64)?,(.*)$/);if(o){var s=o[1],c=!!o[2],l=o[3];l=window.decodeURIComponent(l),c&&(l=window.atob(l));try{var h,u=(this.responseType||"").toLowerCase();switch(u){case"arraybuffer":case"blob":h=new ArrayBuffer(l.length);for(var d=new Uint8Array(h),p=0;p<l.length;p++)d[p]=l.charCodeAt(p);"blob"===u&&(h=new Blob([h],{type:s}));break;case"document":var f=new DOMParser;h=f.parseFromString(l,s);break;case"json":h=JSON.parse(l);break;default:h=l}window.setTimeout(function(){e&&e(h),i.manager.itemEnd(t)},0)}catch(e){window.setTimeout(function(){n&&n(e),i.manager.itemEnd(t),i.manager.itemError(t)},0)}}else{var m=new XMLHttpRequest;m.open("GET",t,!0),m.addEventListener("load",function(r){var a=r.target.response;dh.add(t,a),200===this.status?(e&&e(a),i.manager.itemEnd(t)):0===this.status?(console.warn("THREE.FileLoader: HTTP Status 0 received."),e&&e(a),i.manager.itemEnd(t)):(n&&n(r),i.manager.itemEnd(t),i.manager.itemError(t))},!1),void 0!==r&&m.addEventListener("progress",function(t){r(t)},!1),m.addEventListener("error",function(e){n&&n(e),i.manager.itemEnd(t),i.manager.itemError(t)},!1),void 0!==this.responseType&&(m.responseType=this.responseType),void 0!==this.withCredentials&&(m.withCredentials=this.withCredentials),m.overrideMimeType&&m.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(var g in this.requestHeader)m.setRequestHeader(g,this.requestHeader[g]);m.send(null)}return i.manager.itemStart(t),m},setPath:function(t){return this.path=t,this},setResponseType:function(t){return this.responseType=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setMimeType:function(t){return this.mimeType=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}}),Object.assign(Or.prototype,{load:function(t,e,r,n){var i=this,a=[],o=new Ue;o.image=a;var s=new Ir(this.manager);if(s.setPath(this.path),s.setResponseType("arraybuffer"),Array.isArray(t))for(var c=0,l=0,h=t.length;l<h;++l)!function(l){s.load(t[l],function(t){var r=i._parser(t,!0);a[l]={width:r.width,height:r.height,format:r.format,mipmaps:r.mipmaps},6===(c+=1)&&(1===r.mipmapCount&&(o.minFilter=tl),o.format=r.format,o.needsUpdate=!0,e&&e(o))},r,n)}(l);else s.load(t,function(t){var r=i._parser(t,!0);if(r.isCubemap)for(var n=r.mipmaps.length/r.mipmapCount,s=0;s<n;s++){a[s]={mipmaps:[]};for(var c=0;c<r.mipmapCount;c++)a[s].mipmaps.push(r.mipmaps[s*r.mipmapCount+c]),a[s].format=r.format,a[s].width=r.width,a[s].height=r.height}else o.image.width=r.width,o.image.height=r.height,o.mipmaps=r.mipmaps;1===r.mipmapCount&&(o.minFilter=tl),o.format=r.format,o.needsUpdate=!0,e&&e(o)},r,n);return o},setPath:function(t){return this.path=t,this}}),Object.assign(Nr.prototype,{load:function(t,e,r,n){var i=this,a=new d,o=new Ir(this.manager);return o.setResponseType("arraybuffer"),o.load(t,function(t){var r=i._parser(t);r&&(void 0!==r.image?a.image=r.image:void 0!==r.data&&(a.image.width=r.width,a.image.height=r.height,a.image.data=r.data),a.wrapS=void 0!==r.wrapS?r.wrapS:Zc,a.wrapT=void 0!==r.wrapT?r.wrapT:Zc,a.magFilter=void 0!==r.magFilter?r.magFilter:tl,a.minFilter=void 0!==r.minFilter?r.minFilter:rl,a.anisotropy=void 0!==r.anisotropy?r.anisotropy:1,void 0!==r.format&&(a.format=r.format),void 0!==r.type&&(a.type=r.type),void 0!==r.mipmaps&&(a.mipmaps=r.mipmaps),1===r.mipmapCount&&(a.minFilter=tl),a.needsUpdate=!0,e&&e(a,r))},r,n),a}}),Object.assign(Dr.prototype,{load:function(t,e,r,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t);var i=this,a=dh.get(t);if(void 0!==a)return i.manager.itemStart(t),setTimeout(function(){e&&e(a),i.manager.itemEnd(t)},0),a;var o=document.createElementNS("http://www.w3.org/1999/xhtml","img");return o.addEventListener("load",function(){dh.add(t,this),e&&e(this),i.manager.itemEnd(t)},!1),o.addEventListener("error",function(e){n&&n(e),i.manager.itemEnd(t),i.manager.itemError(t)},!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(t),o.src=t,o},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(Ur.prototype,{load:function(t,e,r,n){var i=new b,a=new Dr(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);for(var o=0,s=0;s<t.length;++s)!function(r){a.load(t[r],function(t){i.images[r]=t,6==++o&&(i.needsUpdate=!0,e&&e(i))},void 0,n)}(s);return i},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(zr.prototype,{load:function(t,e,r,n){var i=new Dr(this.manager);i.setCrossOrigin(this.crossOrigin),i.setPath(this.path);var a=new u;return a.image=i.load(t,function(){var r=t.search(/\.(jpg|jpeg)$/)>0||0===t.search(/^data\:image\/jpeg/);a.format=r?gl:vl,a.needsUpdate=!0,void 0!==e&&e(a)},r,n),a},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Br.prototype=Object.assign(Object.create(gt.prototype),{constructor:Br,isLight:!0,copy:function(t){return gt.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=gt.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),Fr.prototype=Object.assign(Object.create(Br.prototype),{constructor:Fr,isHemisphereLight:!0,copy:function(t){return Br.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(kr.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),Gr.prototype=Object.assign(Object.create(kr.prototype),{constructor:Gr,isSpotLightShadow:!0,update:function(t){var e=this.camera,r=2*Ko.RAD2DEG*t.angle,n=this.mapSize.width/this.mapSize.height,i=t.distance||e.far;r===e.fov&&n===e.aspect&&i===e.far||(e.fov=r,e.aspect=n,e.far=i,e.updateProjectionMatrix())}}),Vr.prototype=Object.assign(Object.create(Br.prototype),{constructor:Vr,isSpotLight:!0,copy:function(t){return Br.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Hr.prototype=Object.assign(Object.create(Br.prototype),{constructor:Hr,isPointLight:!0,copy:function(t){return Br.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),jr.prototype=Object.assign(Object.create(kr.prototype),{constructor:jr}),Wr.prototype=Object.assign(Object.create(Br.prototype),{constructor:Wr,isDirectionalLight:!0,copy:function(t){return Br.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Xr.prototype=Object.assign(Object.create(Br.prototype),{constructor:Xr,isAmbientLight:!0}),Yr.prototype=Object.assign(Object.create(Br.prototype),{constructor:Yr,isRectAreaLight:!0,copy:function(t){return Br.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=Br.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var fh={arraySlice:function(t,e,r){return fh.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==r?r:t.length)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){function e(e,r){return t[e]-t[r]}for(var r=t.length,n=new Array(r),i=0;i!==r;++i)n[i]=i;return n.sort(e),n},sortedArray:function(t,e,r){for(var n=t.length,i=new t.constructor(n),a=0,o=0;o!==n;++a)for(var s=r[a]*e,c=0;c!==e;++c)i[o++]=t[s+c];return i},flattenJSON:function(t,e,r,n){for(var i=1,a=t[0];void 0!==a&&void 0===a[n];)a=t[i++];if(void 0!==a){var o=a[n];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[n])&&(e.push(a.time),r.push.apply(r,o)),a=t[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[n])&&(e.push(a.time),o.toArray(r,r.length)),a=t[i++]}while(void 0!==a);else do{void 0!==(o=a[n])&&(e.push(a.time),r.push(o)),a=t[i++]}while(void 0!==a)}}};Object.assign(qr.prototype,{evaluate:function(t){var e=this.parameterPositions,r=this._cachedIndex,n=e[r],i=e[r-1];t:{e:{var a;r:{n:if(!(t<n)){for(s=r+2;;){if(void 0===n){if(t<i)break n;return r=e.length,this._cachedIndex=r,this.afterEnd_(r-1,t,i)}if(r===s)break;if(i=n,n=e[++r],t<n)break e}a=e.length;break r}{if(t>=i)break t;var o=e[1];t<o&&(r=2,i=o);for(var s=r-2;;){if(void 0===i)return this._cachedIndex=0,this.beforeStart_(0,t,n);if(r===s)break;if(n=i,i=e[--r-1],t>=i)break e}a=r,r=0}}for(;r<a;){var c=r+a>>>1;t<e[c]?a=c:r=c+1}if(n=e[r],void 0===(i=e[r-1]))return this._cachedIndex=0,this.beforeStart_(0,t,n);if(void 0===n)return r=e.length,this._cachedIndex=r,this.afterEnd_(r-1,i,t)}this._cachedIndex=r,this.intervalChanged_(r,i,n)}return this.interpolate_(r,i,t,n)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){for(var e=this.resultBuffer,r=this.sampleValues,n=this.valueSize,i=t*n,a=0;a!==n;++a)e[a]=r[i+a];return e},interpolate_:function(t,e,r,n){throw new Error("call to abstract method")},intervalChanged_:function(t,e,r){}}),Object.assign(qr.prototype,{beforeStart_:qr.prototype.copySampleValue_,afterEnd_:qr.prototype.copySampleValue_}),Zr.prototype=Object.assign(Object.create(qr.prototype),{constructor:Zr,DefaultSettings_:{endingStart:Il,endingEnd:Il},intervalChanged_:function(t,e,r){var n=this.parameterPositions,i=t-2,a=t+1,o=n[i],s=n[a];if(void 0===o)switch(this.getSettings_().endingStart){case 2401:i=t,o=2*e-r;break;case 2402:o=e+n[i=n.length-2]-n[i+1];break;default:i=t,o=r}if(void 0===s)switch(this.getSettings_().endingEnd){case 2401:a=t,s=2*r-e;break;case 2402:a=1,s=r+n[1]-n[0];break;default:a=t-1,s=e}var c=.5*(r-e),l=this.valueSize;this._weightPrev=c/(e-o),this._weightNext=c/(s-r),this._offsetPrev=i*l,this._offsetNext=a*l},interpolate_:function(t,e,r,n){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=t*o,c=s-o,l=this._offsetPrev,h=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(r-e)/(n-e),f=p*p,m=f*p,g=-u*m+2*u*f-u*p,v=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f,b=0;b!==o;++b)i[b]=g*a[l+b]+v*a[c+b]+y*a[s+b]+x*a[h+b];return i}}),Jr.prototype=Object.assign(Object.create(qr.prototype),{constructor:Jr,interpolate_:function(t,e,r,n){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=t*o,c=s-o,l=(r-e)/(n-e),h=1-l,u=0;u!==o;++u)i[u]=a[c+u]*h+a[s+u]*l;return i}}),Qr.prototype=Object.assign(Object.create(qr.prototype),{constructor:Qr,interpolate_:function(t,e,r,n){return this.copySampleValue_(t-1)}});var mh;mh={TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:2301,InterpolantFactoryMethodDiscrete:function(t){return new Qr(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodLinear:function(t){return new Jr(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:function(t){return new Zr(this.times,this.values,this.getValueSize(),t)},setInterpolation:function(t){var e;switch(t){case 2300:e=this.InterpolantFactoryMethodDiscrete;break;case 2301:e=this.InterpolantFactoryMethodLinear;break;case 2302:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){var r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(r);this.setInterpolation(this.DefaultInterpolation)}return void console.warn("THREE.KeyframeTrackPrototype:",r)}this.createInterpolant=e},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}},getValueSize:function(){return this.values.length/this.times.length},shift:function(t){if(0!==t)for(var e=this.times,r=0,n=e.length;r!==n;++r)e[r]+=t;return this},scale:function(t){if(1!==t)for(var e=this.times,r=0,n=e.length;r!==n;++r)e[r]*=t;return this},trim:function(t,e){for(var r=this.times,n=r.length,i=0,a=n-1;i!==n&&r[i]<t;)++i;for(;-1!==a&&r[a]>e;)--a;if(++a,0!==i||a!==n){i>=a&&(a=Math.max(a,1),i=a-1);var o=this.getValueSize();this.times=fh.arraySlice(r,i,a),this.values=fh.arraySlice(this.values,i*o,a*o)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrackPrototype: Invalid value size in track.",this),t=!1);var r=this.times,n=this.values,i=r.length;0===i&&(console.error("THREE.KeyframeTrackPrototype: Track is empty.",this),t=!1);for(var a=null,o=0;o!==i;o++){var s=r[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrackPrototype: Time is not a valid number.",this,o,s),t=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrackPrototype: Out of order keys.",this,o,s,a),t=!1;break}a=s}if(void 0!==n&&fh.isTypedArray(n))for(var o=0,c=n.length;o!==c;++o){var l=n[o];if(isNaN(l)){console.error("THREE.KeyframeTrackPrototype: Value is not a valid number.",this,o,l),t=!1;break}}return t},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),n=2302===this.getInterpolation(),i=1,a=t.length-1,o=1;o<a;++o){var s=!1,c=t[o];if(c!==t[o+1]&&(1!==o||c!==c[0]))if(n)s=!0;else for(var l=o*r,h=l-r,u=l+r,d=0;d!==r;++d){var p=e[l+d];if(p!==e[h+d]||p!==e[u+d]){s=!0;break}}if(s){if(o!==i){t[i]=t[o];for(var f=o*r,m=i*r,d=0;d!==r;++d)e[m+d]=e[f+d]}++i}}if(a>0){t[i]=t[a];for(var f=a*r,m=i*r,d=0;d!==r;++d)e[m+d]=e[f+d];++i}return i!==t.length&&(this.times=fh.arraySlice(t,0,i),this.values=fh.arraySlice(e,0,i*r)),this}},$r.prototype=Object.assign(Object.create(mh),{constructor:$r,ValueTypeName:"vector"}),tn.prototype=Object.assign(Object.create(qr.prototype),{constructor:tn,interpolate_:function(t,e,n,i){for(var a=this.resultBuffer,o=this.sampleValues,s=this.valueSize,c=t*s,l=(n-e)/(i-e),h=c+s;c!==h;c+=4)r.slerpFlat(a,0,o,c-s,o,c,l);return a}}),en.prototype=Object.assign(Object.create(mh),{constructor:en,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new tn(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),rn.prototype=Object.assign(Object.create(mh),{constructor:rn,ValueTypeName:"number"}),nn.prototype=Object.assign(Object.create(mh),{constructor:nn,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),an.prototype=Object.assign(Object.create(mh),{constructor:an,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),on.prototype=Object.assign(Object.create(mh),{constructor:on,ValueTypeName:"color"}),sn.prototype=mh,mh.constructor=sn,Object.assign(sn,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=sn._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],n=[];fh.flattenJSON(t.keys,r,n,"value"),t.times=r,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,r=t.constructor;if(void 0!==r.toJSON)e=r.toJSON(t);else{e={name:t.name,times:fh.convertArray(t.times,Array),values:fh.convertArray(t.values,Array)};var n=t.getInterpolation();n!==t.DefaultInterpolation&&(e.interpolation=n)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return rn;case"vector":case"vector2":case"vector3":case"vector4":return $r;case"color":return on;case"quaternion":return en;case"bool":case"boolean":return an;case"string":return nn}throw new Error("Unsupported typeName: "+t)}}),Object.assign(cn,{parse:function(t){for(var e=[],r=t.tracks,n=1/(t.fps||1),i=0,a=r.length;i!==a;++i)e.push(sn.parse(r[i]).scale(n));return new cn(t.name,t.duration,e)},toJSON:function(t){for(var e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e},i=0,a=r.length;i!==a;++i)e.push(sn.toJSON(r[i]));return n},CreateFromMorphTargetSequence:function(t,e,r,n){for(var i=e.length,a=[],o=0;o<i;o++){var s=[],c=[];s.push((o+i-1)%i,o,(o+1)%i),c.push(0,1,0);var l=fh.getKeyframeOrder(s);s=fh.sortedArray(s,1,l),c=fh.sortedArray(c,1,l),n||0!==s[0]||(s.push(i),c.push(c[0])),a.push(new rn(".morphTargetInfluences["+e[o].name+"]",s,c).scale(1/r))}return new cn(t,-1,a)},findByName:function(t,e){var r=t;if(!Array.isArray(t)){var n=t;r=n.geometry&&n.geometry.animations||n.animations}for(var i=0;i<r.length;i++)if(r[i].name===e)return r[i];return null},CreateClipsFromMorphTargetSequences:function(t,e,r){for(var n={},i=0,a=t.length;i<a;i++){var o=t[i],s=o.name.match(/^([\w-]*?)([\d]+)$/);if(s&&s.length>1){var c=n[h=s[1]];c||(n[h]=c=[]),c.push(o)}}var l=[];for(var h in n)l.push(cn.CreateFromMorphTargetSequence(h,n[h],e,r));return l},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var r=function(t,e,r,n,i){if(0!==r.length){var a=[],o=[];fh.flattenJSON(r,a,o,n),0!==a.length&&i.push(new t(e,a,o))}},n=[],i=t.name||"default",a=t.length||-1,o=t.fps||30,s=t.hierarchy||[],c=0;c<s.length;c++){var l=s[c].keys;if(l&&0!==l.length)if(l[0].morphTargets){for(var h={},u=0;u<l.length;u++)if(l[u].morphTargets)for(m=0;m<l[u].morphTargets.length;m++)h[l[u].morphTargets[m]]=-1;for(var d in h){for(var p=[],f=[],m=0;m!==l[u].morphTargets.length;++m){var g=l[u];p.push(g.time),f.push(g.morphTarget===d?1:0)}n.push(new rn(".morphTargetInfluence["+d+"]",p,f))}a=h.length*(o||1)}else{var v=".bones["+e[c].name+"]";r($r,v+".position",l,"pos",n),r(en,v+".quaternion",l,"rot",n),r($r,v+".scale",l,"scl",n)}}return 0===n.length?null:new cn(i,a,n)}}),Object.assign(cn.prototype,{resetDuration:function(){for(var t=0,e=0,r=this.tracks.length;e!==r;++e){var n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}this.duration=t},trim:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this},optimize:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}}),Object.assign(ln.prototype,{load:function(t,e,r,n){var i=this;new Ir(i.manager).load(t,function(t){e(i.parse(JSON.parse(t)))},r,n)},setTextures:function(t){this.textures=t},parse:function(t){function e(t){return void 0===r[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),r[t]}var r=this.textures,n=new uh[t.type];if(void 0!==t.uuid&&(n.uuid=t.uuid),void 0!==t.name&&(n.name=t.name),void 0!==t.color&&n.color.setHex(t.color),void 0!==t.roughness&&(n.roughness=t.roughness),void 0!==t.metalness&&(n.metalness=t.metalness),void 0!==t.emissive&&n.emissive.setHex(t.emissive),void 0!==t.specular&&n.specular.setHex(t.specular),void 0!==t.shininess&&(n.shininess=t.shininess),void 0!==t.clearCoat&&(n.clearCoat=t.clearCoat),void 0!==t.clearCoatRoughness&&(n.clearCoatRoughness=t.clearCoatRoughness),void 0!==t.uniforms&&(n.uniforms=t.uniforms),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.vertexColors&&(n.vertexColors=t.vertexColors),void 0!==t.fog&&(n.fog=t.fog),void 0!==t.shading&&(n.shading=t.shading),void 0!==t.blending&&(n.blending=t.blending),void 0!==t.side&&(n.side=t.side),void 0!==t.opacity&&(n.opacity=t.opacity),void 0!==t.transparent&&(n.transparent=t.transparent),void 0!==t.alphaTest&&(n.alphaTest=t.alphaTest),void 0!==t.depthTest&&(n.depthTest=t.depthTest),void 0!==t.depthWrite&&(n.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(n.colorWrite=t.colorWrite),void 0!==t.wireframe&&(n.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(n.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(n.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(n.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.skinning&&(n.skinning=t.skinning),void 0!==t.morphTargets&&(n.morphTargets=t.morphTargets),void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=e(t.map)),void 0!==t.alphaMap&&(n.alphaMap=e(t.alphaMap),n.transparent=!0),void 0!==t.bumpMap&&(n.bumpMap=e(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=e(t.normalMap)),void 0!==t.normalScale){var i=t.normalScale;!1===Array.isArray(i)&&(i=[i,i]),n.normalScale=(new h).fromArray(i)}return void 0!==t.displacementMap&&(n.displacementMap=e(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=e(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=e(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=e(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=e(t.specularMap)),void 0!==t.envMap&&(n.envMap=e(t.envMap)),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.lightMap&&(n.lightMap=e(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=e(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=e(t.gradientMap)),n}}),Object.assign(hn.prototype,{load:function(t,e,r,n){var i=this;new Ir(i.manager).load(t,function(t){e(i.parse(JSON.parse(t)))},r,n)},parse:function(t){var e=new Ct,r=t.data.index;if(void 0!==r){s=new gh[r.type](r.array);e.setIndex(new Mt(s,1))}var i=t.data.attributes;for(var a in i){var o=i[a],s=new gh[o.type](o.array);e.addAttribute(a,new Mt(s,o.itemSize,o.normalized))}var c=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==c)for(var l=0,h=c.length;l!==h;++l){var u=c[l];e.addGroup(u.start,u.count,u.materialIndex)}var d=t.data.boundingSphere;if(void 0!==d){var p=new n;void 0!==d.center&&p.fromArray(d.center),e.boundingSphere=new ct(p,d.radius)}return e}});var gh={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};un.Handlers={handlers:[],add:function(t,e){this.handlers.push(t,e)},get:function(t){for(var e=this.handlers,r=0,n=e.length;r<n;r+=2){var i=e[r],a=e[r+1];if(i.test(t))return a}return null}},Object.assign(un.prototype,{crossOrigin:void 0,extractUrlBase:function(t){var e=t.split("/");return 1===e.length?"./":(e.pop(),e.join("/")+"/")},initMaterials:function(t,e,r){for(var n=[],i=0;i<t.length;++i)n[i]=this.createMaterial(t[i],e,r);return n},createMaterial:function(){var t={NoBlending:nc,NormalBlending:ic,AdditiveBlending:ac,SubtractiveBlending:oc,MultiplyBlending:sc,CustomBlending:cc},e=new c,r=new zr,n=new ln;return function(i,a,o){function s(t,e,n,i,s){var l,h=a+t,u=un.Handlers.get(h);null!==u?l=u.load(h):(r.setCrossOrigin(o),l=r.load(h)),void 0!==e&&(l.repeat.fromArray(e),1!==e[0]&&(l.wrapS=qc),1!==e[1]&&(l.wrapT=qc)),void 0!==n&&l.offset.fromArray(n),void 0!==i&&("repeat"===i[0]&&(l.wrapS=qc),"mirror"===i[0]&&(l.wrapS=Jc),"repeat"===i[1]&&(l.wrapT=qc),"mirror"===i[1]&&(l.wrapT=Jc)),void 0!==s&&(l.anisotropy=s);var d=Ko.generateUUID();return c[d]=l,d}var c={},l={uuid:Ko.generateUUID(),type:"MeshLambertMaterial"};for(var h in i){var u=i[h];switch(h){case"DbgColor":case"DbgIndex":case"opticalDensity":case"illumination":break;case"DbgName":l.name=u;break;case"blending":l.blending=t[u];break;case"colorAmbient":case"mapAmbient":console.warn("THREE.Loader.createMaterial:",h,"is no longer supported.");break;case"colorDiffuse":l.color=e.fromArray(u).getHex();break;case"colorSpecular":l.specular=e.fromArray(u).getHex();break;case"colorEmissive":l.emissive=e.fromArray(u).getHex();break;case"specularCoef":l.shininess=u;break;case"shading":"basic"===u.toLowerCase()&&(l.type="MeshBasicMaterial"),"phong"===u.toLowerCase()&&(l.type="MeshPhongMaterial"),"standard"===u.toLowerCase()&&(l.type="MeshStandardMaterial");break;case"mapDiffuse":l.map=s(u,i.mapDiffuseRepeat,i.mapDiffuseOffset,i.mapDiffuseWrap,i.mapDiffuseAnisotropy);break;case"mapDiffuseRepeat":case"mapDiffuseOffset":case"mapDiffuseWrap":case"mapDiffuseAnisotropy":break;case"mapEmissive":l.emissiveMap=s(u,i.mapEmissiveRepeat,i.mapEmissiveOffset,i.mapEmissiveWrap,i.mapEmissiveAnisotropy);break;case"mapEmissiveRepeat":case"mapEmissiveOffset":case"mapEmissiveWrap":case"mapEmissiveAnisotropy":break;case"mapLight":l.lightMap=s(u,i.mapLightRepeat,i.mapLightOffset,i.mapLightWrap,i.mapLightAnisotropy);break;case"mapLightRepeat":case"mapLightOffset":case"mapLightWrap":case"mapLightAnisotropy":break;case"mapAO":l.aoMap=s(u,i.mapAORepeat,i.mapAOOffset,i.mapAOWrap,i.mapAOAnisotropy);break;case"mapAORepeat":case"mapAOOffset":case"mapAOWrap":case"mapAOAnisotropy":break;case"mapBump":l.bumpMap=s(u,i.mapBumpRepeat,i.mapBumpOffset,i.mapBumpWrap,i.mapBumpAnisotropy);break;case"mapBumpScale":l.bumpScale=u;break;case"mapBumpRepeat":case"mapBumpOffset":case"mapBumpWrap":case"mapBumpAnisotropy":break;case"mapNormal":l.normalMap=s(u,i.mapNormalRepeat,i.mapNormalOffset,i.mapNormalWrap,i.mapNormalAnisotropy);break;case"mapNormalFactor":l.normalScale=[u,u];break;case"mapNormalRepeat":case"mapNormalOffset":case"mapNormalWrap":case"mapNormalAnisotropy":break;case"mapSpecular":l.specularMap=s(u,i.mapSpecularRepeat,i.mapSpecularOffset,i.mapSpecularWrap,i.mapSpecularAnisotropy);break;case"mapSpecularRepeat":case"mapSpecularOffset":case"mapSpecularWrap":case"mapSpecularAnisotropy":break;case"mapMetalness":l.metalnessMap=s(u,i.mapMetalnessRepeat,i.mapMetalnessOffset,i.mapMetalnessWrap,i.mapMetalnessAnisotropy);break;case"mapMetalnessRepeat":case"mapMetalnessOffset":case"mapMetalnessWrap":case"mapMetalnessAnisotropy":break;case"mapRoughness":l.roughnessMap=s(u,i.mapRoughnessRepeat,i.mapRoughnessOffset,i.mapRoughnessWrap,i.mapRoughnessAnisotropy);break;case"mapRoughnessRepeat":case"mapRoughnessOffset":case"mapRoughnessWrap":case"mapRoughnessAnisotropy":break;case"mapAlpha":l.alphaMap=s(u,i.mapAlphaRepeat,i.mapAlphaOffset,i.mapAlphaWrap,i.mapAlphaAnisotropy);break;case"mapAlphaRepeat":case"mapAlphaOffset":case"mapAlphaWrap":case"mapAlphaAnisotropy":break;case"flipSided":l.side=Js;break;case"doubleSided":l.side=Qs;break;case"transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity"),l.opacity=u;break;case"depthTest":case"depthWrite":case"colorWrite":case"opacity":case"reflectivity":case"transparent":case"visible":case"wireframe":l[h]=u;break;case"vertexColors":!0===u&&(l.vertexColors=rc),"face"===u&&(l.vertexColors=ec);break;default:console.error("THREE.Loader.createMaterial: Unsupported",h,u)}}return"MeshBasicMaterial"===l.type&&delete l.emissive,"MeshPhongMaterial"!==l.type&&delete l.specular,l.opacity<1&&(l.transparent=!0),n.setTextures(c),n.parse(l)}}()}),Object.assign(dn.prototype,{load:function(t,e,r,n){var i=this,a=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:un.prototype.extractUrlBase(t),o=new Ir(this.manager);o.setWithCredentials(this.withCredentials),o.load(t,function(r){var n=JSON.parse(r),o=n.metadata;if(void 0!==o){var s=o.type;if(void 0!==s){if("object"===s.toLowerCase())return void console.error("THREE.JSONLoader: "+t+" should be loaded with THREE.ObjectLoader instead.");if("scene"===s.toLowerCase())return void console.error("THREE.JSONLoader: "+t+" should be loaded with THREE.SceneLoader instead.")}}var c=i.parse(n,a);e(c.geometry,c.materials)},r,n)},setTexturePath:function(t){this.texturePath=t},parse:function(){function t(t,e){function r(t,e){return t&1<<e}var i,a,o,s,l,u,d,p,f,m,g,v,y,x,b,w,_,M,E,S,T,A,L,C,R,P=t.faces,I=t.vertices,O=t.normals,N=t.colors,D=t.scale,U=0;if(void 0!==t.uvs){for(i=0;i<t.uvs.length;i++)t.uvs[i].length&&U++;for(i=0;i<U;i++)e.faceVertexUvs[i]=[]}for(s=0,l=I.length;s<l;)(M=new n).x=I[s++]*D,M.y=I[s++]*D,M.z=I[s++]*D,e.vertices.push(M);for(s=0,l=P.length;s<l;)if(m=P[s++],g=r(m,0),v=r(m,1),y=r(m,3),x=r(m,4),b=r(m,5),w=r(m,6),_=r(m,7),g){if(S=new bt,S.a=P[s],S.b=P[s+1],S.c=P[s+3],T=new bt,T.a=P[s+1],T.b=P[s+2],T.c=P[s+3],s+=4,v&&(f=P[s++],S.materialIndex=f,T.materialIndex=f),o=e.faces.length,y)for(i=0;i<U;i++)for(C=t.uvs[i],e.faceVertexUvs[i][o]=[],e.faceVertexUvs[i][o+1]=[],a=0;a<4;a++)R=new h(C[2*(p=P[s++])],C[2*p+1]),2!==a&&e.faceVertexUvs[i][o].push(R),0!==a&&e.faceVertexUvs[i][o+1].push(R);if(x&&(d=3*P[s++],S.normal.set(O[d++],O[d++],O[d]),T.normal.copy(S.normal)),b)for(i=0;i<4;i++)d=3*P[s++],L=new n(O[d++],O[d++],O[d]),2!==i&&S.vertexNormals.push(L),0!==i&&T.vertexNormals.push(L);if(w&&(A=N[u=P[s++]],S.color.setHex(A),T.color.setHex(A)),_)for(i=0;i<4;i++)A=N[u=P[s++]],2!==i&&S.vertexColors.push(new c(A)),0!==i&&T.vertexColors.push(new c(A));e.faces.push(S),e.faces.push(T)}else{if(E=new bt,E.a=P[s++],E.b=P[s++],E.c=P[s++],v&&(f=P[s++],E.materialIndex=f),o=e.faces.length,y)for(i=0;i<U;i++)for(C=t.uvs[i],e.faceVertexUvs[i][o]=[],a=0;a<3;a++)R=new h(C[2*(p=P[s++])],C[2*p+1]),e.faceVertexUvs[i][o].push(R);if(x&&(d=3*P[s++],E.normal.set(O[d++],O[d++],O[d])),b)for(i=0;i<3;i++)d=3*P[s++],L=new n(O[d++],O[d++],O[d]),E.vertexNormals.push(L);if(w&&(u=P[s++],E.color.setHex(N[u])),_)for(i=0;i<3;i++)u=P[s++],E.vertexColors.push(new c(N[u]));e.faces.push(E)}}function e(t,e){var r=void 0!==t.influencesPerVertex?t.influencesPerVertex:2;if(t.skinWeights)for(var n=0,i=t.skinWeights.length;n<i;n+=r){var a=t.skinWeights[n],o=r>1?t.skinWeights[n+1]:0,s=r>2?t.skinWeights[n+2]:0,c=r>3?t.skinWeights[n+3]:0;e.skinWeights.push(new y(a,o,s,c))}if(t.skinIndices)for(var n=0,i=t.skinIndices.length;n<i;n+=r){var l=t.skinIndices[n],h=r>1?t.skinIndices[n+1]:0,u=r>2?t.skinIndices[n+2]:0,d=r>3?t.skinIndices[n+3]:0;e.skinIndices.push(new y(l,h,u,d))}e.bones=t.bones,e.bones&&e.bones.length>0&&(e.skinWeights.length!==e.skinIndices.length||e.skinIndices.length!==e.vertices.length)&&console.warn("When skinning, number of vertices ("+e.vertices.length+"), skinIndices ("+e.skinIndices.length+"), and skinWeights ("+e.skinWeights.length+") should match.")}function r(t,e){var r=t.scale;if(void 0!==t.morphTargets)for(var i=0,a=t.morphTargets.length;i<a;i++){e.morphTargets[i]={},e.morphTargets[i].name=t.morphTargets[i].name,e.morphTargets[i].vertices=[];for(var o=e.morphTargets[i].vertices,s=t.morphTargets[i].vertices,c=0,l=s.length;c<l;c+=3){var h=new n;h.x=s[c]*r,h.y=s[c+1]*r,h.z=s[c+2]*r,o.push(h)}}if(void 0!==t.morphColors&&t.morphColors.length>0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var u=e.faces,d=t.morphColors[0].colors,i=0,a=u.length;i<a;i++)u[i].color.fromArray(d,3*i)}}function i(t,e){var r=[],n=[];void 0!==t.animation&&n.push(t.animation),void 0!==t.animations&&(t.animations.length?n=n.concat(t.animations):n.push(t.animations));for(var i=0;i<n.length;i++){var a=cn.parseAnimation(n[i],e.bones);a&&r.push(a)}if(e.morphTargets){var o=cn.CreateClipsFromMorphTargetSequences(e.morphTargets,10);r=r.concat(o)}r.length>0&&(e.animations=r)}return function(n,a){void 0!==n.data&&(n=n.data),void 0!==n.scale?n.scale=1/n.scale:n.scale=1;var o=new _t;return t(n,o),e(n,o),r(n,o),i(n,o),o.computeFaceNormals(),o.computeBoundingSphere(),void 0===n.materials||0===n.materials.length?{geometry:o}:{geometry:o,materials:un.prototype.initMaterials(n.materials,a,this.crossOrigin)}}}()}),Object.assign(pn.prototype,{load:function(t,e,r,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new Ir(i.manager).load(t,function(r){var a=null;try{a=JSON.parse(r)}catch(e){return void 0!==n&&n(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}var o=a.metadata;if(void 0===o||void 0===o.type||"geometry"===o.type.toLowerCase())return void console.error("THREE.ObjectLoader: Can't load "+t+". Use THREE.JSONLoader instead.");i.parse(a,e)},r,n)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var r=this.parseGeometries(t.geometries),n=this.parseImages(t.images,function(){void 0!==e&&e(o)}),i=this.parseTextures(t.textures,n),a=this.parseMaterials(t.materials,i),o=this.parseObject(t.object,r,a);return t.animations&&(o.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(o),o},parseGeometries:function(t){var e={};if(void 0!==t)for(var r=new dn,n=new hn,i=0,a=t.length;i<a;i++){var o,s=t[i];switch(s.type){case"PlaneGeometry":case"PlaneBufferGeometry":o=new hh[s.type](s.width,s.height,s.widthSegments,s.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":o=new hh[s.type](s.width,s.height,s.depth,s.widthSegments,s.heightSegments,s.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":o=new hh[s.type](s.radius,s.segments,s.thetaStart,s.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":o=new hh[s.type](s.radiusTop,s.radiusBottom,s.height,s.radialSegments,s.heightSegments,s.openEnded,s.thetaStart,s.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":o=new hh[s.type](s.radius,s.height,s.radialSegments,s.heightSegments,s.openEnded,s.thetaStart,s.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":o=new hh[s.type](s.radius,s.widthSegments,s.heightSegments,s.phiStart,s.phiLength,s.thetaStart,s.thetaLength);break;case"DodecahedronGeometry":case"IcosahedronGeometry":case"OctahedronGeometry":case"TetrahedronGeometry":o=new hh[s.type](s.radius,s.detail);break;case"RingGeometry":case"RingBufferGeometry":o=new hh[s.type](s.innerRadius,s.outerRadius,s.thetaSegments,s.phiSegments,s.thetaStart,s.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":o=new hh[s.type](s.radius,s.tube,s.radialSegments,s.tubularSegments,s.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":o=new hh[s.type](s.radius,s.tube,s.tubularSegments,s.radialSegments,s.p,s.q);break;case"LatheGeometry":case"LatheBufferGeometry":o=new hh[s.type](s.points,s.segments,s.phiStart,s.phiLength);break;case"BufferGeometry":o=n.parse(s);break;case"Geometry":o=r.parse(s,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+s.type+'"');continue}o.uuid=s.uuid,void 0!==s.name&&(o.name=s.name),e[s.uuid]=o}return e},parseMaterials:function(t,e){var r={};if(void 0!==t){var n=new ln;n.setTextures(e);for(var i=0,a=t.length;i<a;i++){var o=t[i];if("MultiMaterial"===o.type){for(var s=[],c=0;c<o.materials.length;c++)s.push(n.parse(o.materials[c]));r[o.uuid]=s}else r[o.uuid]=n.parse(o)}}return r},parseAnimations:function(t){for(var e=[],r=0;r<t.length;r++){var n=cn.parse(t[r]);e.push(n)}return e},parseImages:function(t,e){var r=this,n={};if(void 0!==t&&t.length>0){var i=new Dr(new Pr(e));i.setCrossOrigin(this.crossOrigin);for(var a=0,o=t.length;a<o;a++){var s=t[a],c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(s.url)?s.url:r.texturePath+s.url;n[s.uuid]=function(t){return r.manager.itemStart(t),i.load(t,function(){r.manager.itemEnd(t)},void 0,function(){r.manager.itemEnd(t),r.manager.itemError(t)})}(c)}}return n},parseTextures:function(t,e){function r(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}var n={};if(void 0!==t)for(var i=0,a=t.length;i<a;i++){var o=t[i];void 0===o.image&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),void 0===e[o.image]&&console.warn("THREE.ObjectLoader: Undefined image",o.image);var s=new u(e[o.image]);s.needsUpdate=!0,s.uuid=o.uuid,void 0!==o.name&&(s.name=o.name),void 0!==o.mapping&&(s.mapping=r(o.mapping,vh)),void 0!==o.offset&&s.offset.fromArray(o.offset),void 0!==o.repeat&&s.repeat.fromArray(o.repeat),void 0!==o.wrap&&(s.wrapS=r(o.wrap[0],yh),s.wrapT=r(o.wrap[1],yh)),void 0!==o.minFilter&&(s.minFilter=r(o.minFilter,xh)),void 0!==o.magFilter&&(s.magFilter=r(o.magFilter,xh)),void 0!==o.anisotropy&&(s.anisotropy=o.anisotropy),void 0!==o.flipY&&(s.flipY=o.flipY),n[o.uuid]=s}return n},parseObject:function(){var t=new e;return function(e,r,n){function i(t){return void 0===r[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),r[t]}function a(t){if(void 0!==t){if(Array.isArray(t)){for(var e=[],r=0,i=t.length;r<i;r++){var a=t[r];void 0===n[a]&&console.warn("THREE.ObjectLoader: Undefined material",a),e.push(n[a])}return e}return void 0===n[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),n[t]}}var o;switch(e.type){case"Scene":o=new we,void 0!==e.background&&Number.isInteger(e.background)&&(o.background=new c(e.background)),void 0!==e.fog&&("Fog"===e.fog.type?o.fog=new be(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(o.fog=new xe(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":o=new xt(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(o.focus=e.focus),void 0!==e.zoom&&(o.zoom=e.zoom),void 0!==e.filmGauge&&(o.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(o.filmOffset=e.filmOffset),void 0!==e.view&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new yt(e.left,e.right,e.top,e.bottom,e.near,e.far);break;case"AmbientLight":o=new Xr(e.color,e.intensity);break;case"DirectionalLight":o=new Wr(e.color,e.intensity);break;case"PointLight":o=new Hr(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new Yr(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new Vr(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new Fr(e.color,e.groundColor,e.intensity);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":var s=i(e.geometry),l=a(e.material);o=s.bones&&s.bones.length>0?new Le(s,l):new Bt(s,l);break;case"LOD":o=new Se;break;case"Line":o=new Re(i(e.geometry),a(e.material),e.mode);break;case"LineLoop":o=new Ie(i(e.geometry),a(e.material));break;case"LineSegments":o=new Pe(i(e.geometry),a(e.material));break;case"PointCloud":case"Points":o=new Ne(i(e.geometry),a(e.material));break;case"Sprite":o=new Ee(a(e.material));break;case"Group":o=new De;break;default:o=new gt}if(o.uuid=e.uuid,void 0!==e.name&&(o.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(o.position,o.quaternion,o.scale)):(void 0!==e.position&&o.position.fromArray(e.position),void 0!==e.rotation&&o.rotation.fromArray(e.rotation),void 0!==e.quaternion&&o.quaternion.fromArray(e.quaternion),void 0!==e.scale&&o.scale.fromArray(e.scale)),void 0!==e.castShadow&&(o.castShadow=e.castShadow),void 0!==e.receiveShadow&&(o.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(o.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(o.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&o.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(o.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(o.visible=e.visible),void 0!==e.userData&&(o.userData=e.userData),void 0!==e.children)for(var h in e.children)o.add(this.parseObject(e.children[h],r,n));if("LOD"===e.type)for(var u=e.levels,d=0;d<u.length;d++){var p=u[d];void 0!==(h=o.getObjectByProperty("uuid",p.object))&&o.addLevel(h,p.distance)}return o}}()});var vh={UVMapping:300,CubeReflectionMapping:Gc,CubeRefractionMapping:Vc,EquirectangularReflectionMapping:Hc,EquirectangularRefractionMapping:jc,SphericalReflectionMapping:Wc,CubeUVReflectionMapping:Xc,CubeUVRefractionMapping:Yc},yh={RepeatWrapping:qc,ClampToEdgeWrapping:Zc,MirroredRepeatWrapping:Jc},xh={NearestFilter:Qc,NearestMipMapNearestFilter:Kc,NearestMipMapLinearFilter:$c,LinearFilter:tl,LinearMipMapNearestFilter:el,LinearMipMapLinearFilter:rl};Object.assign(En.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t){var e=this.getUtoTmapping(t);return this.getPoint(e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],r=0;r<=t;r++)e.push(this.getPoint(r/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,r,n=[],i=this.getPoint(0),a=0;for(n.push(0),r=1;r<=t;r++)a+=(e=this.getPoint(r/t)).distanceTo(i),n.push(a),i=e;return this.cacheArcLengths=n,n},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var r,n=this.getLengths(),i=0,a=n.length;r=e||t*n[a-1];for(var o,s=0,c=a-1;s<=c;)if(i=Math.floor(s+(c-s)/2),(o=n[i]-r)<0)s=i+1;else{if(!(o>0)){c=i;break}c=i-1}if(i=c,n[i]===r)return i/(a-1);var l=n[i];return(i+(r-l)/(n[i+1]-l))/(a-1)},getTangent:function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),r>1&&(r=1);var n=this.getPoint(e);return this.getPoint(r).clone().sub(n).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,r){var i,a,o,s=new n,c=[],l=[],h=[],u=new n,d=new e;for(i=0;i<=t;i++)a=i/t,c[i]=this.getTangentAt(a),c[i].normalize();l[0]=new n,h[0]=new n;var p=Number.MAX_VALUE,f=Math.abs(c[0].x),m=Math.abs(c[0].y),g=Math.abs(c[0].z);for(f<=p&&(p=f,s.set(1,0,0)),m<=p&&(p=m,s.set(0,1,0)),g<=p&&s.set(0,0,1),u.crossVectors(c[0],s).normalize(),l[0].crossVectors(c[0],u),h[0].crossVectors(c[0],l[0]),i=1;i<=t;i++)l[i]=l[i-1].clone(),h[i]=h[i-1].clone(),u.crossVectors(c[i-1],c[i]),u.length()>Number.EPSILON&&(u.normalize(),o=Math.acos(Ko.clamp(c[i-1].dot(c[i]),-1,1)),l[i].applyMatrix4(d.makeRotationAxis(u,o))),h[i].crossVectors(c[i],l[i]);if(!0===r)for(o=Math.acos(Ko.clamp(l[0].dot(l[t]),-1,1)),o/=t,c[0].dot(u.crossVectors(l[0],l[t]))>0&&(o=-o),i=1;i<=t;i++)l[i].applyMatrix4(d.makeRotationAxis(c[i],o*i)),h[i].crossVectors(c[i],l[i]);return{tangents:c,normals:l,binormals:h}}}),Sn.prototype=Object.create(En.prototype),Sn.prototype.constructor=Sn,Sn.prototype.isLineCurve=!0,Sn.prototype.getPoint=function(t){if(1===t)return this.v2.clone();var e=this.v2.clone().sub(this.v1);return e.multiplyScalar(t).add(this.v1),e},Sn.prototype.getPointAt=function(t){return this.getPoint(t)},Sn.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},Tn.prototype=Object.assign(Object.create(En.prototype),{constructor:Tn,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Sn(e,t))},getPoint:function(t){for(var e=t*this.getLength(),r=this.getCurveLengths(),n=0;n<r.length;){if(r[n]>=e){var i=r[n]-e,a=this.curves[n],o=a.getLength(),s=0===o?0:1-i/o;return a.getPointAt(s)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,r=0,n=this.curves.length;r<n;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e},getPoints:function(t){t=t||12;for(var e,r=[],n=0,i=this.curves;n<i.length;n++)for(var a=i[n],o=a&&a.isEllipseCurve?2*t:a&&a.isLineCurve?1:a&&a.isSplineCurve?t*a.points.length:t,s=a.getPoints(o),c=0;c<s.length;c++){var l=s[c];e&&e.equals(l)||(r.push(l),e=l)}return this.autoClose&&r.length>1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new _t,r=0,i=t.length;r<i;r++){var a=t[r];e.vertices.push(new n(a.x,a.y,a.z||0))}return e}}),An.prototype=Object.create(En.prototype),An.prototype.constructor=An,An.prototype.isEllipseCurve=!0,An.prototype.getPoint=function(t){for(var e=2*Math.PI,r=this.aEndAngle-this.aStartAngle,n=Math.abs(r)<Number.EPSILON;r<0;)r+=e;for(;r>e;)r-=e;r<Number.EPSILON&&(r=n?0:e),!0!==this.aClockwise||n||(r===e?r=-e:r-=e);var i=this.aStartAngle+t*r,a=this.aX+this.xRadius*Math.cos(i),o=this.aY+this.yRadius*Math.sin(i);if(0!==this.aRotation){var s=Math.cos(this.aRotation),c=Math.sin(this.aRotation),l=a-this.aX,u=o-this.aY;a=l*s-u*c+this.aX,o=l*c+u*s+this.aY}return new h(a,o)},Ln.prototype=Object.create(En.prototype),Ln.prototype.constructor=Ln,Ln.prototype.isSplineCurve=!0,Ln.prototype.getPoint=function(t){var e=this.points,r=(e.length-1)*t,n=Math.floor(r),i=r-n,a=e[0===n?n:n-1],o=e[n],s=e[n>e.length-2?e.length-1:n+1],c=e[n>e.length-3?e.length-1:n+2];return new h(fn(i,a.x,o.x,s.x,c.x),fn(i,a.y,o.y,s.y,c.y))},Cn.prototype=Object.create(En.prototype),Cn.prototype.constructor=Cn,Cn.prototype.getPoint=function(t){var e=this.v0,r=this.v1,n=this.v2,i=this.v3;return new h(Mn(t,e.x,r.x,n.x,i.x),Mn(t,e.y,r.y,n.y,i.y))},Rn.prototype=Object.create(En.prototype),Rn.prototype.constructor=Rn,Rn.prototype.getPoint=function(t){var e=this.v0,r=this.v1,n=this.v2;return new h(yn(t,e.x,r.x,n.x),yn(t,e.y,r.y,n.y))};var bh=Object.assign(Object.create(Tn.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y)},moveTo:function(t,e){this.currentPoint.set(t,e)},lineTo:function(t,e){var r=new Sn(this.currentPoint.clone(),new h(t,e));this.curves.push(r),this.currentPoint.set(t,e)},quadraticCurveTo:function(t,e,r,n){var i=new Rn(this.currentPoint.clone(),new h(t,e),new h(r,n));this.curves.push(i),this.currentPoint.set(r,n)},bezierCurveTo:function(t,e,r,n,i,a){var o=new Cn(this.currentPoint.clone(),new h(t,e),new h(r,n),new h(i,a));this.curves.push(o),this.currentPoint.set(i,a)},splineThru:function(t){var e=new Ln([this.currentPoint.clone()].concat(t));this.curves.push(e),this.currentPoint.copy(t[t.length-1])},arc:function(t,e,r,n,i,a){var o=this.currentPoint.x,s=this.currentPoint.y;this.absarc(t+o,e+s,r,n,i,a)},absarc:function(t,e,r,n,i,a){this.absellipse(t,e,r,r,n,i,a)},ellipse:function(t,e,r,n,i,a,o,s){var c=this.currentPoint.x,l=this.currentPoint.y;this.absellipse(t+c,e+l,r,n,i,a,o,s)},absellipse:function(t,e,r,n,i,a,o,s){var c=new An(t,e,r,n,i,a,o,s);if(this.curves.length>0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var h=c.getPoint(1);this.currentPoint.copy(h)}});Pn.prototype=bh,bh.constructor=Pn,In.prototype=Object.assign(Object.create(bh),{constructor:In,getPointsHoles:function(t){for(var e=[],r=0,n=this.holes.length;r<n;r++)e[r]=this.holes[r].getPoints(t);return e},extractAllPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},extractPoints:function(t){return this.extractAllPoints(t)}}),Object.assign(On.prototype,{moveTo:function(t,e){this.currentPath=new Pn,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e)},lineTo:function(t,e){this.currentPath.lineTo(t,e)},quadraticCurveTo:function(t,e,r,n){this.currentPath.quadraticCurveTo(t,e,r,n)},bezierCurveTo:function(t,e,r,n,i,a){this.currentPath.bezierCurveTo(t,e,r,n,i,a)},splineThru:function(t){this.currentPath.splineThru(t)},toShapes:function(t,e){function r(t){for(var e=[],r=0,n=t.length;r<n;r++){var i=t[r],a=new In;a.curves=i.curves,e.push(a)}return e}var n=lh.isClockWise,i=this.subPaths;if(0===i.length)return[];if(!0===e)return r(i);var a,o,s,c=[];if(1===i.length)return o=i[0],s=new In,s.curves=o.curves,c.push(s),c;var l=!n(i[0].getPoints());l=t?!l:l;var h,u=[],d=[],p=[],f=0;d[f]=void 0,p[f]=[];for(var m=0,g=i.length;m<g;m++)a=n(h=(o=i[m]).getPoints()),(a=t?!a:a)?(!l&&d[f]&&f++,d[f]={s:new In,p:h},d[f].s.curves=o.curves,l&&f++,p[f]=[]):p[f].push({h:o,p:h[0]});if(!d[0])return r(i);if(d.length>1){for(var v=!1,y=[],x=0,b=d.length;x<b;x++)u[x]=[];for(var x=0,b=d.length;x<b;x++)for(var w=p[x],_=0;_<w.length;_++){for(var M=w[_],E=!0,S=0;S<d.length;S++)(function(t,e){for(var r=e.length,n=!1,i=r-1,a=0;a<r;i=a++){var o=e[i],s=e[a],c=s.x-o.x,l=s.y-o.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(o=e[a],c=-c,s=e[i],l=-l),t.y<o.y||t.y>s.y)continue;if(t.y===o.y){if(t.x===o.x)return!0}else{var h=l*(t.x-o.x)-c*(t.y-o.y);if(0===h)return!0;if(h<0)continue;n=!n}}else{if(t.y!==o.y)continue;if(s.x<=t.x&&t.x<=o.x||o.x<=t.x&&t.x<=s.x)return!0}}return n})(M.p,d[S].p)&&(x!==S&&y.push({froms:x,tos:S,hole:_}),E?(E=!1,u[S].push(M)):v=!0);E&&u[x].push(M)}y.length>0&&(v||(p=u))}for(var T,m=0,A=d.length;m<A;m++){s=d[m].s,c.push(s);for(var L=0,C=(T=p[m]).length;L<C;L++)s.holes.push(T[L].h)}return c}}),Object.assign(Nn.prototype,{isFont:!0,generateShapes:function(t,e,r){function n(t,e,n,a){var o=i.glyphs[t]||i.glyphs["?"];if(o){var s,c,l,h,u,d,p,f,m,g,v,y=new On,x=[];if(o.o)for(var b=o._cachedOutline||(o._cachedOutline=o.o.split(" ")),w=0,_=b.length;w<_;)switch(b[w++]){case"m":s=b[w++]*e+n,c=b[w++]*e+a,y.moveTo(s,c);break;case"l":s=b[w++]*e+n,c=b[w++]*e+a,y.lineTo(s,c);break;case"q":if(l=b[w++]*e+n,h=b[w++]*e+a,p=b[w++]*e+n,f=b[w++]*e+a,y.quadraticCurveTo(p,f,l,h),v=x[x.length-1]){u=v.x,d=v.y;for(M=1;M<=r;M++)yn(E=M/r,u,p,l),yn(E,d,f,h)}break;case"b":if(l=b[w++]*e+n,h=b[w++]*e+a,p=b[w++]*e+n,f=b[w++]*e+a,m=b[w++]*e+n,g=b[w++]*e+a,y.bezierCurveTo(p,f,m,g,l,h),v=x[x.length-1]){u=v.x,d=v.y;for(var M=1;M<=r;M++){var E=M/r;Mn(E,u,p,m,l),Mn(E,d,f,g,h)}}}return{offsetX:o.ha*e,path:y}}}void 0===e&&(e=100),void 0===r&&(r=4);for(var i=this.data,a=function(t){for(var r=String(t).split(""),a=e/i.resolution,o=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*a,s=0,c=0,l=[],h=0;h<r.length;h++){var u=r[h];if("\n"===u)s=0,c-=o;else{var d=n(u,a,s,c);s+=d.offsetX,l.push(d.path)}}return l}(t),o=[],s=0,c=a.length;s<c;s++)Array.prototype.push.apply(o,a[s].toShapes());return o}}),Object.assign(Dn.prototype,{load:function(t,e,r,n){var i=this;new Ir(this.manager).load(t,function(t){var r;try{r=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),r=JSON.parse(t.substring(65,t.length-2))}var n=i.parse(r);e&&e(n)},r,n)},parse:function(t){return new Nn(t)}});var wh,_h={getContext:function(){return void 0===wh&&(wh=new(window.AudioContext||window.webkitAudioContext)),wh},setContext:function(t){wh=t}};Object.assign(Un.prototype,{load:function(t,e,r,n){var i=new Ir(this.manager);i.setResponseType("arraybuffer"),i.load(t,function(t){_h.getContext().decodeAudioData(t,function(t){e(t)})},r,n)}}),Object.assign(zn.prototype,{update:function(){var t,r,n,i,a,o,s,c,l=new e,h=new e;return function(e){if(t!==this||r!==e.focus||n!==e.fov||i!==e.aspect*this.aspect||a!==e.near||o!==e.far||s!==e.zoom||c!==this.eyeSep){t=this,r=e.focus,n=e.fov,i=e.aspect*this.aspect,a=e.near,o=e.far,s=e.zoom;var u,d,p=e.projectionMatrix.clone(),f=(c=this.eyeSep/2)*a/r,m=a*Math.tan(Ko.DEG2RAD*n*.5)/s;h.elements[12]=-c,l.elements[12]=c,u=-m*i+f,d=m*i+f,p.elements[0]=2*a/(d-u),p.elements[8]=(d+u)/(d-u),this.cameraL.projectionMatrix.copy(p),u=-m*i-f,d=m*i-f,p.elements[0]=2*a/(d-u),p.elements[8]=(d+u)/(d-u),this.cameraR.projectionMatrix.copy(p)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(h),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(l)}}()}),Bn.prototype=Object.assign(Object.create(gt.prototype),{constructor:Bn,getInput:function(){return this.gain},removeFilter:function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null)},getFilter:function(){return this.filter},setFilter:function(t){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination)},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(t){this.gain.gain.value=t},updateMatrixWorld:function(){var t=new n,e=new r,i=new n,a=new n;return function(r){gt.prototype.updateMatrixWorld.call(this,r);var n=this.context.listener,o=this.up;this.matrixWorld.decompose(t,e,i),a.set(0,0,-1).applyQuaternion(e),n.positionX?(n.positionX.setValueAtTime(t.x,this.context.currentTime),n.positionY.setValueAtTime(t.y,this.context.currentTime),n.positionZ.setValueAtTime(t.z,this.context.currentTime),n.forwardX.setValueAtTime(a.x,this.context.currentTime),n.forwardY.setValueAtTime(a.y,this.context.currentTime),n.forwardZ.setValueAtTime(a.z,this.context.currentTime),n.upX.setValueAtTime(o.x,this.context.currentTime),n.upY.setValueAtTime(o.y,this.context.currentTime),n.upZ.setValueAtTime(o.z,this.context.currentTime)):(n.setPosition(t.x,t.y,t.z),n.setOrientation(a.x,a.y,a.z,o.x,o.y,o.z))}}()}),Fn.prototype=Object.assign(Object.create(gt.prototype),{constructor:Fn,getOutput:function(){return this.gain},setNodeSource:function(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this},setBuffer:function(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");var t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.onended=this.onEnded.bind(this),t.playbackRate.setValueAtTime(this.playbackRate,this.startTime),t.start(0,this.startTime),this.isPlaying=!0,this.source=t,this.connect()},pause:function(){return!1===this.hasPlaybackControl?void console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),this.startTime=this.context.currentTime,this.isPlaying=!1,this)},stop:function(){return!1===this.hasPlaybackControl?void console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),this.startTime=0,this.isPlaying=!1,this)},connect:function(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(t){return t||(t=[]),!0===this.isPlaying?(this.disconnect(),this.filters=t,this.connect()):this.filters=t,this},getFilter:function(){return this.getFilters()[0]},setFilter:function(t){return this.setFilters(t?[t]:[])},setPlaybackRate:function(t){return!1===this.hasPlaybackControl?void console.warn("THREE.Audio: this Audio has no playback control."):(this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setValueAtTime(this.playbackRate,this.context.currentTime),this)},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(t){return!1===this.hasPlaybackControl?void console.warn("THREE.Audio: this Audio has no playback control."):(this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this)},getVolume:function(){return this.gain.gain.value},setVolume:function(t){return this.gain.gain.value=t,this}}),kn.prototype=Object.assign(Object.create(Fn.prototype),{constructor:kn,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(t){this.panner.refDistance=t},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(t){this.panner.rolloffFactor=t},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(t){this.panner.distanceModel=t},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(t){this.panner.maxDistance=t},updateMatrixWorld:function(){var t=new n;return function(e){gt.prototype.updateMatrixWorld.call(this,e),t.setFromMatrixPosition(this.matrixWorld),this.panner.setPosition(t.x,t.y,t.z)}}()}),Object.assign(Gn.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var t=0,e=this.getFrequencyData(),r=0;r<e.length;r++)t+=e[r];return t/e.length}}),Object.assign(Vn.prototype,{accumulate:function(t,e){var r=this.buffer,n=this.valueSize,i=t*n+n,a=this.cumulativeWeight;if(0===a){for(var o=0;o!==n;++o)r[i+o]=r[o];a=e}else{var s=e/(a+=e);this._mixBufferRegion(r,i,0,s,n)}this.cumulativeWeight=a},apply:function(t){var e=this.valueSize,r=this.buffer,n=t*e+e,i=this.cumulativeWeight,a=this.binding;if(this.cumulativeWeight=0,i<1){var o=3*e;this._mixBufferRegion(r,n,o,1-i,e)}for(var s=e,c=e+e;s!==c;++s)if(r[s]!==r[s+e]){a.setValue(r,n);break}},saveOriginalState:function(){var t=this.binding,e=this.buffer,r=this.valueSize,n=3*r;t.getValue(e,n);for(var i=r,a=n;i!==a;++i)e[i]=e[n+i%r];this.cumulativeWeight=0},restoreOriginalState:function(){var t=3*this.valueSize;this.binding.setValue(this.buffer,t)},_select:function(t,e,r,n,i){if(n>=.5)for(var a=0;a!==i;++a)t[e+a]=t[r+a]},_slerp:function(t,e,n,i){r.slerpFlat(t,e,t,e,t,n,i)},_lerp:function(t,e,r,n,i){for(var a=1-n,o=0;o!==i;++o){var s=e+o;t[s]=t[s]*a+t[r+o]*n}}}),Object.assign(Hn.prototype,{getValue:function(t,e){this.bind();var r=this._targetGroup.nCachedObjects_,n=this._bindings[r];void 0!==n&&n.getValue(t,e)},setValue:function(t,e){for(var r=this._bindings,n=this._targetGroup.nCachedObjects_,i=r.length;n!==i;++n)r[n].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}}),Object.assign(jn,{Composite:Hn,create:function(t,e,r){return t&&t.isAnimationObjectGroup?new jn.Composite(t,e,r):new jn(t,e,r)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:function(){var t=new RegExp("^"+/((?:[\w-]+[\/:])*)/.source+/([\w-\.]+)?/.source+/(?:\.([\w-]+)(?:\[(.+)\])?)?/.source+/\.([\w-]+)(?:\[(.+)\])?/.source+"$"),e=["material","materials","bones"];return function(r){var n=t.exec(r);if(!n)throw new Error("PropertyBinding: Cannot parse trackName: "+r);var i={nodeName:n[2],objectName:n[3],objectIndex:n[4],propertyName:n[5],propertyIndex:n[6]},a=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==a&&-1!==a){var o=i.nodeName.substring(a+1);-1!==e.indexOf(o)&&(i.nodeName=i.nodeName.substring(0,a),i.objectName=o)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+r);return i}}(),findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var r=function(t){for(var r=0;r<t.bones.length;r++){var n=t.bones[r];if(n.name===e)return n}return null}(t.skeleton);if(r)return r}if(t.children){var n=function(t){for(var r=0;r<t.length;r++){var i=t[r];if(i.name===e||i.uuid===e)return i;var a=n(i.children);if(a)return a}return null},i=n(t.children);if(i)return i}return null}}),Object.assign(jn.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){for(var r=this.resolvedProperty,n=0,i=r.length;n!==i;++n)t[e++]=r[n]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.node[this.propertyName]=t[e]},function(t,e){this.node[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.node[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){for(var r=this.resolvedProperty,n=0,i=r.length;n!==i;++n)r[n]=t[e++]},function(t,e){for(var r=this.resolvedProperty,n=0,i=r.length;n!==i;++n)r[n]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){for(var r=this.resolvedProperty,n=0,i=r.length;n!==i;++n)r[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){var t=this.node,e=this.parsedPath,r=e.objectName,n=e.propertyName,i=e.propertyIndex;if(t||(t=jn.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(r){var a=e.objectIndex;switch(r){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(h=0;h<t.length;h++)if(t[h].name===a){a=h;break}break;default:if(void 0===t[r])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[r]}if(void 0!==a){if(void 0===t[a])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[a]}}var o=t[n];if(void 0===o){var s=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+s+"."+n+" but it wasn't found.",t)}var c=this.Versioning.None;void 0!==t.needsUpdate?(c=this.Versioning.NeedsUpdate,this.targetObject=t):void 0!==t.matrixWorldNeedsUpdate&&(c=this.Versioning.MatrixWorldNeedsUpdate,this.targetObject=t);var l=this.BindingType.Direct;if(void 0!==i){if("morphTargetInfluences"===n){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(t.geometry.isBufferGeometry){if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);for(h=0;h<this.node.geometry.morphAttributes.position.length;h++)if(t.geometry.morphAttributes.position[h].name===i){i=h;break}}else{if(!t.geometry.morphTargets)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",this);for(var h=0;h<this.node.geometry.morphTargets.length;h++)if(t.geometry.morphTargets[h].name===i){i=h;break}}}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=i}else void 0!==o.fromArray&&void 0!==o.toArray?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][c]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(jn.prototype,{_getValue_unbound:jn.prototype.getValue,_setValue_unbound:jn.prototype.setValue}),Object.assign(Wn.prototype,{isAnimationObjectGroup:!0,add:function(t){for(var e=this._objects,r=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,a=this._paths,o=this._parsedPaths,s=this._bindings,c=s.length,l=0,h=arguments.length;l!==h;++l){var u=arguments[l],d=u.uuid,p=i[d],f=void 0;if(void 0===p){p=r++,i[d]=p,e.push(u);for(var m=0,g=c;m!==g;++m)s[m].push(new jn(u,a[m],o[m]))}else if(p<n){f=e[p];var v=--n,y=e[v];i[y.uuid]=p,e[p]=y,i[d]=v,e[v]=u;for(var m=0,g=c;m!==g;++m){var x=s[m],b=x[v],w=x[p];x[p]=b,void 0===w&&(w=new jn(u,a[m],o[m])),x[v]=w}}else e[p]!==f&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=n},remove:function(t){for(var e=this._objects,r=this.nCachedObjects_,n=this._indicesByUUID,i=this._bindings,a=i.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o],l=c.uuid,h=n[l];if(void 0!==h&&h>=r){var u=r++,d=e[u];n[d.uuid]=h,e[h]=d,n[l]=u,e[u]=c;for(var p=0,f=a;p!==f;++p){var m=i[p],g=m[u],v=m[h];m[h]=g,m[u]=v}}}this.nCachedObjects_=r},uncache:function(t){for(var e=this._objects,r=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,a=this._bindings,o=a.length,s=0,c=arguments.length;s!==c;++s){var l=arguments[s].uuid,h=i[l];if(void 0!==h)if(delete i[l],h<n){var u=--n,d=e[u],p=e[y=--r];i[d.uuid]=h,e[h]=d,i[p.uuid]=u,e[u]=p,e.pop();for(var f=0,m=o;f!==m;++f){var g=(x=a[f])[u],v=x[y];x[h]=g,x[u]=v,x.pop()}}else{var y=--r;i[(p=e[y]).uuid]=h,e[h]=p,e.pop();for(var f=0,m=o;f!==m;++f){var x=a[f];x[h]=x[y],x.pop()}}}this.nCachedObjects_=n},subscribe_:function(t,e){var r=this._bindingsIndicesByPath,n=r[t],i=this._bindings;if(void 0!==n)return i[n];var a=this._paths,o=this._parsedPaths,s=this._objects,c=s.length,l=this.nCachedObjects_,h=new Array(c);n=i.length,r[t]=n,a.push(t),o.push(e),i.push(h);for(var u=l,d=s.length;u!==d;++u){var p=s[u];h[u]=new jn(p,t,e)}return h},unsubscribe_:function(t){var e=this._bindingsIndicesByPath,r=e[t];if(void 0!==r){var n=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o];e[t[o]]=r,a[r]=s,a.pop(),i[r]=i[o],i.pop(),n[r]=n[o],n.pop()}}}),Object.assign(Xn.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(t){return this._startTime=t,this},setLoop:function(t,e){return this.loop=t,this.repetitions=e,this},setEffectiveWeight:function(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(t){return this._scheduleFading(t,0,1)},fadeOut:function(t){return this._scheduleFading(t,1,0)},crossFadeFrom:function(t,e,r){if(t.fadeOut(e),this.fadeIn(e),r){var n=this._clip.duration,i=t._clip.duration,a=i/n,o=n/i;t.warp(1,a,e),this.warp(o,1,e)}return this},crossFadeTo:function(t,e,r){return t.crossFadeFrom(this,e,r)},stopFading:function(){var t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},setEffectiveTimeScale:function(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(t){return this.timeScale=this._clip.duration/t,this.stopWarping()},syncWith:function(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()},halt:function(t){return this.warp(this._effectiveTimeScale,0,t)},warp:function(t,e,r){var n=this._mixer,i=n.time,a=this._timeScaleInterpolant,o=this.timeScale;null===a&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);var s=a.parameterPositions,c=a.sampleValues;return s[0]=i,s[1]=i+r,c[0]=t/o,c[1]=e/o,this},stopWarping:function(){var t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(t,e,r,n){if(!this.enabled)return void this._updateWeight(t);var i=this._startTime;if(null!==i){var a=(t-i)*r;if(a<0||0===r)return;this._startTime=null,e=r*a}e*=this._updateTimeScale(t);var o=this._updateTime(e),s=this._updateWeight(t);if(s>0)for(var c=this._interpolants,l=this._propertyBindings,h=0,u=c.length;h!==u;++h)c[h].evaluate(o),l[h].accumulate(n,s)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var r=this._weightInterpolant;if(null!==r){var n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var r=this._timeScaleInterpolant;null!==r&&(e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var r=this._clip.duration,n=this.loop,i=this._loopCount;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=r)e=r;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var a=2202===n;if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),e>=r||e<0){var o=Math.floor(e/r);e-=r*o,i+=Math.abs(o);var s=this.repetitions-i;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}if(a&&1==(1&i))return this.time=e,r-e}return this.time=e,e},_setEndings:function(t,e,r){var n=this._interpolantSettings;r?(n.endingStart=2401,n.endingEnd=2401):(n.endingStart=t?this.zeroSlopeAtStart?2401:Il:2402,n.endingEnd=e?this.zeroSlopeAtEnd?2401:Il:2402)},_scheduleFading:function(t,e,r){var n=this._mixer,i=n.time,a=this._weightInterpolant;null===a&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=e,o[1]=i+t,s[1]=r,this}}),Object.assign(Yn.prototype,l.prototype,{_bindAction:function(t,e){var r=t._localRoot||this._root,n=t._clip.tracks,i=n.length,a=t._propertyBindings,o=t._interpolants,s=r.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var h=0;h!==i;++h){var u=n[h],d=u.name,p=l[d];if(void 0!==p)a[h]=p;else{if(void 0!==(p=a[h])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=e&&e._propertyBindings[h].binding.parsedPath;++(p=new Vn(jn.create(r,d,f),u.ValueTypeName,u.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),a[h]=p}o[h].resultBuffer=p.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,r=t._clip.uuid,n=this._actionsByClip[r];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,r,e)}for(var i=t._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,r=0,n=e.length;r!==n;++r){var i=e[r];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e<this._nActiveActions},_addInactiveAction:function(t,e,r){var n=this._actions,i=this._actionsByClip,a=i[e];if(void 0===a)a={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,i[e]=a;else{var o=a.knownActions;t._byClipCacheIndex=o.length,o.push(t)}t._cacheIndex=n.length,n.push(t),a.actionByRoot[r]=t},_removeInactiveAction:function(t){var e=this._actions,r=e[e.length-1],n=t._cacheIndex;r._cacheIndex=n,e[n]=r,e.pop(),t._cacheIndex=null;var i=t._clip.uuid,a=this._actionsByClip,o=a[i],s=o.knownActions,c=s[s.length-1],l=t._byClipCacheIndex;c._byClipCacheIndex=l,s[l]=c,s.pop(),t._byClipCacheIndex=null,delete o.actionByRoot[(t._localRoot||this._root).uuid],0===s.length&&delete a[i],this._removeInactiveBindingsForAction(t)},_removeInactiveBindingsForAction:function(t){for(var e=t._propertyBindings,r=0,n=e.length;r!==n;++r){var i=e[r];0==--i.referenceCount&&this._removeInactiveBinding(i)}},_lendAction:function(t){var e=this._actions,r=t._cacheIndex,n=this._nActiveActions++,i=e[n];t._cacheIndex=n,e[n]=t,i._cacheIndex=r,e[r]=i},_takeBackAction:function(t){var e=this._actions,r=t._cacheIndex,n=--this._nActiveActions,i=e[n];t._cacheIndex=n,e[n]=t,i._cacheIndex=r,e[r]=i},_addInactiveBinding:function(t,e,r){var n=this._bindingsByRootAndName,i=n[e],a=this._bindings;void 0===i&&(i={},n[e]=i),i[r]=t,t._cacheIndex=a.length,a.push(t)},_removeInactiveBinding:function(t){var e=this._bindings,r=t.binding,n=r.rootNode.uuid,i=r.path,a=this._bindingsByRootAndName,o=a[n],s=e[e.length-1],c=t._cacheIndex;s._cacheIndex=c,e[c]=s,e.pop(),delete o[i];t:{for(var l in o)break t;delete a[n]}},_lendBinding:function(t){var e=this._bindings,r=t._cacheIndex,n=this._nActiveBindings++,i=e[n];t._cacheIndex=n,e[n]=t,i._cacheIndex=r,e[r]=i},_takeBackBinding:function(t){var e=this._bindings,r=t._cacheIndex,n=--this._nActiveBindings,i=e[n];t._cacheIndex=n,e[n]=t,i._cacheIndex=r,e[r]=i},_lendControlInterpolant:function(){var t=this._controlInterpolants,e=this._nActiveControlInterpolants++,r=t[e];return void 0===r&&((r=new Jr(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=e,t[e]=r),r},_takeBackControlInterpolant:function(t){var e=this._controlInterpolants,r=t.__cacheIndex,n=--this._nActiveControlInterpolants,i=e[n];t.__cacheIndex=n,e[n]=t,i.__cacheIndex=r,e[r]=i},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(t,e){var r=e||this._root,n=r.uuid,i="string"==typeof t?cn.findByName(r,t):t,a=null!==i?i.uuid:t,o=this._actionsByClip[a],s=null;if(void 0!==o){var c=o.actionByRoot[n];if(void 0!==c)return c;s=o.knownActions[0],null===i&&(i=s._clip)}if(null===i)return null;var l=new Xn(this,i,e);return this._bindAction(l,s),this._addInactiveAction(l,a,n),l},existingAction:function(t,e){var r=e||this._root,n=r.uuid,i="string"==typeof t?cn.findByName(r,t):t,a=i?i.uuid:t,o=this._actionsByClip[a];return void 0!==o?o.actionByRoot[n]||null:null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,r=this._bindings,n=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(i=0;i!==e;++i)t[i].reset();for(var i=0;i!==n;++i)r[i].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,r=this._nActiveActions,n=this.time+=t,i=Math.sign(t),a=this._accuIndex^=1,o=0;o!==r;++o)e[o]._update(n,t,i,a);for(var s=this._bindings,c=this._nActiveBindings,o=0;o!==c;++o)s[o].apply(a);return this},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,r=t.uuid,n=this._actionsByClip,i=n[r];if(void 0!==i){for(var a=i.knownActions,o=0,s=a.length;o!==s;++o){var c=a[o];this._deactivateAction(c);var l=c._cacheIndex,h=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=l,e[l]=h,e.pop(),this._removeInactiveBindingsForAction(c)}delete n[r]}},uncacheRoot:function(t){var e=t.uuid,r=this._actionsByClip;for(var n in r){var i=r[n].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}var a=this._bindingsByRootAndName[e];if(void 0!==a)for(var o in a){var s=a[o];s.restoreOriginalState(),this._removeInactiveBinding(s)}},uncacheAction:function(t,e){var r=this.existingAction(t,e);null!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}}),qn.prototype.clone=function(){return new qn(void 0===this.value.clone?this.value:this.value.clone())},Zn.prototype=Object.assign(Object.create(Ct.prototype),{constructor:Zn,isInstancedBufferGeometry:!0,addGroup:function(t,e,r){this.groups.push({start:t,count:e,materialIndex:r})},copy:function(t){var e=t.index;null!==e&&this.setIndex(e.clone());var r=t.attributes;for(var n in r){var i=r[n];this.addAttribute(n,i.clone())}for(var a=t.groups,o=0,s=a.length;o<s;o++){var c=a[o];this.addGroup(c.start,c.count,c.materialIndex)}return this}}),Object.defineProperties(Jn.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(Jn.prototype,{isInterleavedBufferAttribute:!0,setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=r,this},setXYZ:function(t,e,r,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this},setXYZW:function(t,e,r,n,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this.data.array[t+3]=i,this}}),Object.defineProperty(Qn.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Qn.prototype,{isInterleavedBuffer:!0,setArray:function(t){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==t?t.length/this.stride:0,this.array=t},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.dynamic=t.dynamic,this},copyAt:function(t,e,r){t*=this.stride,r*=e.stride;for(var n=0,i=this.stride;n<i;n++)this.array[t+n]=e.array[r+n];return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(t){return this.onUploadCallback=t,this}}),Kn.prototype=Object.assign(Object.create(Qn.prototype),{constructor:Kn,isInstancedInterleavedBuffer:!0,copy:function(t){return Qn.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}}),$n.prototype=Object.assign(Object.create(Mt.prototype),{constructor:$n,isInstancedBufferAttribute:!0,copy:function(t){return Mt.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}}),Object.assign(ti.prototype,{linePrecision:1,set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize()):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(t,e){var r=[];return ri(t,this,r,e),r.sort(ei),r},intersectObjects:function(t,e){var r=[];if(!1===Array.isArray(t))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),r;for(var n=0,i=t.length;n<i;n++)ri(t[n],this,r,e);return r.sort(ei),r}}),Object.assign(ni.prototype,{start:function(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var e=("undefined"==typeof performance?Date:performance).now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}),Object.assign(ii.prototype,{set:function(t,e,r){return this.radius=t,this.phi=e,this.theta=r,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this},makeSafe:function(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this},setFromVector3:function(t){return this.radius=t.length(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t.x,t.z),this.phi=Math.acos(Ko.clamp(t.y/this.radius,-1,1))),this}}),Object.assign(ai.prototype,{set:function(t,e,r){return this.radius=t,this.theta=e,this.y=r,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this},setFromVector3:function(t){return this.radius=Math.sqrt(t.x*t.x+t.z*t.z),this.theta=Math.atan2(t.x,t.z),this.y=t.y,this}}),oi.prototype=Object.create(Pe.prototype),oi.prototype.constructor=oi,oi.prototype.update=function(){var t=new n,e=new n,r=new lt;return function(){var n=["a","b","c"];this.object.updateMatrixWorld(!0),r.getNormalMatrix(this.object.matrixWorld);var i=this.object.matrixWorld,a=this.geometry.attributes.position,o=this.object.geometry;if(o&&o.isGeometry)for(var s=o.vertices,c=o.faces,l=0,h=0,u=c.length;h<u;h++)for(var d=c[h],p=0,f=d.vertexNormals.length;p<f;p++){var m=s[d[n[p]]],g=d.vertexNormals[p];t.copy(m).applyMatrix4(i),e.copy(g).applyMatrix3(r).normalize().multiplyScalar(this.size).add(t),a.setXYZ(l,t.x,t.y,t.z),l+=1,a.setXYZ(l,e.x,e.y,e.z),l+=1}else if(o&&o.isBufferGeometry)for(var v=o.attributes.position,y=o.attributes.normal,l=0,p=0,f=v.count;p<f;p++)t.set(v.getX(p),v.getY(p),v.getZ(p)).applyMatrix4(i),e.set(y.getX(p),y.getY(p),y.getZ(p)),e.applyMatrix3(r).normalize().multiplyScalar(this.size).add(t),a.setXYZ(l,t.x,t.y,t.z),l+=1,a.setXYZ(l,e.x,e.y,e.z),l+=1;a.needsUpdate=!0}}(),ci.prototype=Object.create(Pe.prototype),ci.prototype.constructor=ci,ci.prototype.onBeforeRender=function(){var t=new n,r=new e,i=new e;return function(){var e=this.bones,n=this.geometry,a=n.getAttribute("position");i.getInverse(this.root.matrixWorld);for(var o=0,s=0;o<e.length;o++){var c=e[o];c.parent&&c.parent.isBone&&(r.multiplyMatrices(i,c.matrixWorld),t.setFromMatrixPosition(r),a.setXYZ(s,t.x,t.y,t.z),r.multiplyMatrices(i,c.parent.matrixWorld),t.setFromMatrixPosition(r),a.setXYZ(s+1,t.x,t.y,t.z),s+=2)}n.getAttribute("position").needsUpdate=!0}}(),li.prototype=Object.create(gt.prototype),li.prototype.constructor=li,li.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},li.prototype.update=function(){var t=new n,e=new c,r=new c;return function(){var n=this.children[0],i=n.geometry.getAttribute("color");e.copy(this.light.color),r.copy(this.light.groundColor);for(var a=0,o=i.count;a<o;a++){var s=a<o/2?e:r;i.setXYZ(a,s.r,s.g,s.b)}n.lookAt(t.setFromMatrixPosition(this.light.matrixWorld).negate()),i.needsUpdate=!0}}(),hi.prototype=Object.create(Pe.prototype),hi.prototype.constructor=hi,hi.prototype.update=function(){var t=new n,e=new n,r=new lt;return function(){this.object.updateMatrixWorld(!0),r.getNormalMatrix(this.object.matrixWorld);for(var n=this.object.matrixWorld,i=this.geometry.attributes.position,a=this.object.geometry,o=a.vertices,s=a.faces,c=0,l=0,h=s.length;l<h;l++){var u=s[l],d=u.normal;t.copy(o[u.a]).add(o[u.b]).add(o[u.c]).divideScalar(3).applyMatrix4(n),e.copy(d).applyMatrix3(r).normalize().multiplyScalar(this.size).add(t),i.setXYZ(c,t.x,t.y,t.z),c+=1,i.setXYZ(c,e.x,e.y,e.z),c+=1}i.needsUpdate=!0}}(),ui.prototype=Object.create(Pe.prototype),ui.prototype.constructor=ui,ui.prototype.update=function(){function t(t,n,o,s){i.set(n,o,s).unproject(a);var c=r[t];if(void 0!==c)for(var l=e.getAttribute("position"),h=0,u=c.length;h<u;h++)l.setXYZ(c[h],i.x,i.y,i.z)}var e,r,i=new n,a=new vt;return function(){e=this.geometry,r=this.pointMap;a.projectionMatrix.copy(this.camera.projectionMatrix),t("c",0,0,-1),t("t",0,0,1),t("n1",-1,-1,-1),t("n2",1,-1,-1),t("n3",-1,1,-1),t("n4",1,1,-1),t("f1",-1,-1,1),t("f2",1,-1,1),t("f3",-1,1,1),t("f4",1,1,1),t("u1",.7,1.1,-1),t("u2",-.7,1.1,-1),t("u3",0,2,-1),t("cf1",-1,0,1),t("cf2",1,0,1),t("cf3",0,-1,1),t("cf4",0,1,1),t("cn1",-1,0,-1),t("cn2",1,0,-1),t("cn3",0,-1,-1),t("cn4",0,1,-1),e.getAttribute("position").needsUpdate=!0}}();var Mh=new n,Eh=new di,Sh=new di,Th=new di;pi.prototype=Object.create(En.prototype),pi.prototype.constructor=pi,pi.prototype.getPoint=function(t){var e=this.points,r=e.length,i=(r-(this.closed?0:1))*t,a=Math.floor(i),o=i-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/e.length)+1)*e.length:0===o&&a===r-1&&(a=r-2,o=1);var s,c,l,h;if(this.closed||a>0?s=e[(a-1)%r]:(Mh.subVectors(e[0],e[1]).add(e[0]),s=Mh),c=e[a%r],l=e[(a+1)%r],this.closed||a+2<r?h=e[(a+2)%r]:(Mh.subVectors(e[r-1],e[r-2]).add(e[r-1]),h=Mh),void 0===this.type||"centripetal"===this.type||"chordal"===this.type){var u="chordal"===this.type?.5:.25,d=Math.pow(s.distanceToSquared(c),u),p=Math.pow(c.distanceToSquared(l),u),f=Math.pow(l.distanceToSquared(h),u);p<1e-4&&(p=1),d<1e-4&&(d=p),f<1e-4&&(f=p),Eh.initNonuniformCatmullRom(s.x,c.x,l.x,h.x,d,p,f),Sh.initNonuniformCatmullRom(s.y,c.y,l.y,h.y,d,p,f),Th.initNonuniformCatmullRom(s.z,c.z,l.z,h.z,d,p,f)}else if("catmullrom"===this.type){var m=void 0!==this.tension?this.tension:.5;Eh.initCatmullRom(s.x,c.x,l.x,h.x,m),Sh.initCatmullRom(s.y,c.y,l.y,h.y,m),Th.initCatmullRom(s.z,c.z,l.z,h.z,m)}return new n(Eh.calc(o),Sh.calc(o),Th.calc(o))},fi.prototype=Object.create(En.prototype),fi.prototype.constructor=fi,fi.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2,a=this.v3;return new n(Mn(t,e.x,r.x,i.x,a.x),Mn(t,e.y,r.y,i.y,a.y),Mn(t,e.z,r.z,i.z,a.z))},En.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(En.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},mi.prototype=Object.create(pi.prototype),Object.assign(mi.prototype,{initFromArray:function(t){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(t){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(t){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),ci.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign(et.prototype,{center:function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},size:function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(st.prototype,{center:function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionSphere:function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},size:function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)}}),Ut.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)},Ko.random16=function(){return console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead."),Math.random()},Object.assign(lt.prototype,{flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(t){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBuffer:function(t,e,r){return console.warn("THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(t,e,r){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(e.prototype,{extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},getPosition:function(){var t;return function(){return void 0===t&&(t=new n),console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),t.setFromMatrixColumn(this,3)}}(),setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(t){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBuffer:function(t,e,r){return console.warn("THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(t,e,r){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(t,e,r,n,i,a){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,n,r,i,a)}}),ht.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},r.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},Object.assign(Dt.prototype,{isIntersectionBox:function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionPlane:function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},isIntersectionSphere:function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)}}),Object.assign(In.prototype,{extrude:function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new nr(this,t)},makeGeometry:function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new pr(this,t)}}),Object.assign(h.prototype,{fromAttribute:function(t,e,r){return console.error("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,r)}}),Object.assign(n.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},applyProjection:function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},fromAttribute:function(t,e,r){return console.error("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,r)}}),Object.assign(y.prototype,{fromAttribute:function(t,e,r){return console.error("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,r)}}),_t.prototype.computeTangents=function(){console.warn("THREE.Geometry: .computeTangents() has been removed.")},Object.assign(gt.prototype,{getChildByName:function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)}}),Object.defineProperties(gt.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.defineProperties(Se.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(Te.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Object.defineProperty(En.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}}),xt.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties(Br.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(Mt.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}}}),Object.assign(Ct.prototype,{addIndex:function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},addDrawCall:function(t,e,r){void 0!==r&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}),Object.defineProperties(Ct.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(qn.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(it.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new c}}}),Object.defineProperties(Tr.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(at.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),Object.assign(ye.prototype,{getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}}),Object.defineProperties(ye.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace."),this.shadowMap.cullFace=t}}}),Object.defineProperties(dt.prototype,{cullFace:{get:function(){return this.renderReverseSided?Ws:js},set:function(t){var e=t!==js;console.warn("WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to "+e+"."),this.renderReverseSided=e}}}),Object.defineProperties(x.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),Fn.prototype.load=function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var e=this;return(new Un).load(t,function(t){e.setBuffer(t)}),this},Gn.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},gi.prototype=Object.create(De.prototype),Object.assign(gi.prototype,s.prototype),gi.prototype.constructor=gi,gi.prototype.set=function(){var t=new n,e=new n(1,0,0);return function(r){r.getWorldDirection(t);var n=Math.PI/2-t.angleTo(zs);n!==this.lastPitch&&(this.globe.rotateOnAxis(e,n-this.lastPitch),this.lastPitch=n,this.txt.textContent=Math.round(Ko.radToDeg(n))+"°")}}(),vi.prototype=Object.create(Bt.prototype),Object.assign(vi.prototype,s.prototype),vi.prototype.constructor=vi,yi.prototype=Object.create(De.prototype),Object.assign(yi.prototype,s.prototype),yi.prototype.constructor=yi,yi.prototype.set=function(){var t=new n,e=new n(0,1,0),r=new n(0,0,-1);return function(n){if(n.getWorldDirection(t),0!==t.x||0!==t.y){t.z=0;var i=t.angleTo(e);if(t.x>=0&&(i=2*Math.PI-i),i!==this.lastRotation){var a=360-Math.round(Ko.radToDeg(i));this.txt.textContent=a.toString().padStart(3,"0")+"°",this.rotateOnAxis(r,i-this.lastRotation),this.lastRotation=i}}}}();var Ah={cursorVertexShader:"\r\n#ifdef SURFACE\r\n\r\nuniform vec3 uLight;\r\nvarying vec3 vNormal;\r\nvarying vec3 lNormal;\r\n\r\n#else\r\n\t\r\nvarying vec3 vColor;\r\n\r\n#endif\r\n\r\nvarying float height;\r\n\r\nvoid main() {\r\n\r\n#ifdef SURFACE\r\n\r\n\tvNormal = normalMatrix * normal;\r\n\tlNormal = uLight;\r\n\r\n#else\r\n\r\n\tvColor = color;\r\n\r\n#endif\r\n\r\n\theight = position.z;\r\n\r\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n\r\n}\r\n",cursorFragmentShader:"\r\nuniform float cursor;\r\nuniform float cursorWidth;\r\n\r\nuniform vec3 baseColor;\r\nuniform vec3 cursorColor;\r\n\r\nvarying float height;\r\n\r\n#ifdef SURFACE\r\n\r\nvarying vec3 vNormal;\r\nvarying vec3 lNormal;\r\n\r\n#else\r\n\r\nvarying vec3 vColor;\r\n\r\n#endif\r\n\r\nvoid main() {\r\n\r\n#ifdef SURFACE\r\n\r\n\tfloat nDot = dot( normalize( vNormal ), normalize( lNormal ) );\r\n\tfloat light;\r\n\tlight = 0.5 * ( nDot + 1.0 );\r\n\r\n#else\r\n\r\n\tfloat light = 1.0;\r\n\r\n#endif\r\n\r\n\tfloat delta = abs( height - cursor );\r\n\tfloat ss = smoothstep( 0.0, cursorWidth, cursorWidth - delta );\r\n\r\n\r\n#ifdef SURFACE\r\n\r\n\tif ( delta < cursorWidth * 0.05 ) {\r\n\r\n\t\tgl_FragColor = vec4( 1.0, 1.0, 1.0, 1.0 ) * light;\r\n\r\n\t} else {\r\n\r\n\t\tgl_FragColor = vec4( mix( baseColor, cursorColor, ss ) * light, 1.0 );\r\n\r\n\t}\r\n\r\n#else\r\n\r\n\tif ( delta < cursorWidth * 0.05 ) {\r\n\r\n\t\tgl_FragColor = vec4( 1.0, 1.0, 1.0, 1.0 ) * light * vec4( vColor, 1.0 );\r\n\r\n\t} else {\r\n\r\n\t\tgl_FragColor = vec4( mix( baseColor, cursorColor, ss ) * light, 1.0 ) * vec4( vColor, 1.0 );\r\n\r\n\t}\r\n\r\n#endif\r\n\r\n}\r\n",depthMapVertexShader:"\r\nuniform float minZ;\r\nuniform float scaleZ;\r\n\r\nvarying float vHeight;\r\n\r\nvoid main() {\r\n\r\n\tvHeight = ( position.z - minZ ) * scaleZ;\r\n\r\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n\r\n}\r\n",depthMapFragmentShader:"\r\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\r\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\r\n\r\nconst float ShiftRight8 = 1. / 256.;\r\n\r\nvec4 packFloatToRGBA( const in float v ) {\r\n\r\n\tvec4 r = vec4( fract( v * PackFactors ), v );\r\n\r\n\tr.yzw -= r.xyz * ShiftRight8; // tidy overflow\r\n\r\n\treturn r * PackUpscale;\r\n\r\n}\r\n\r\nvarying float vHeight;\r\n\r\nvoid main() {\r\n\r\n\tgl_FragColor = packFloatToRGBA( vHeight );\r\n\r\n}\r\n",depthVertexShader:"const float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\r\n\r\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\r\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\r\n\r\nfloat unpackRGBAToFloat( const in vec4 v ) {\r\n\treturn dot( v, UnpackFactors );\r\n}\r\n\r\nuniform float minX;\r\nuniform float minY;\r\nuniform float minZ;\r\n\r\nuniform float scaleX;\r\nuniform float scaleY;\r\nuniform float rangeZ;\r\n\r\nuniform float depthScale;\r\n\r\nuniform sampler2D depthMap;\r\nuniform float datumShift;\r\n\r\n#ifdef SURFACE\r\n\r\nuniform vec3 uLight;\r\n\r\nvarying vec3 vNormal;\r\nvarying vec3 lNormal;\r\n\r\n#else\r\n\r\nvarying vec3 vColor;\r\n\r\n#endif\r\n\r\nvarying float vDepth;\r\n\r\nvoid main() {\r\n\r\n#ifdef SURFACE\r\n\r\n\tvNormal = normalMatrix * normal;\r\n\tlNormal = uLight;\r\n\r\n#else\r\n\r\n\tvColor = color;\r\n\r\n#endif\r\n\r\n\t// get terrain height in model space\r\n\r\n\tvec2 terrainCoords = vec2( ( position.x - minX ) * scaleX, ( position.y - minY ) * scaleY );\r\n\tfloat terrainHeight = unpackRGBAToFloat( texture2D( depthMap, terrainCoords ) );\r\n\r\n\tterrainHeight = terrainHeight * rangeZ + minZ + datumShift;\r\n\r\n\t// depth below terrain for this vertex, scaled in 0.0 - 1.0 range\r\n\r\n\tvDepth = ( terrainHeight - position.z ) * depthScale;\r\n\r\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n\r\n}\r\n",depthFragmentShader:"\r\nuniform sampler2D cmap;\r\nvarying float vDepth;\r\n\r\n#ifdef SURFACE\r\n\r\nvarying vec3 vNormal;\r\nvarying vec3 lNormal;\r\n\r\n#else\r\n\r\nvarying vec3 vColor;\r\n\r\n#endif\r\n\r\nvoid main() {\r\n\r\n#ifdef SURFACE\r\n\r\n\tfloat nDot = dot( normalize( vNormal ), normalize( lNormal ) );\r\n\tfloat light;\r\n\tlight = 0.5 * ( nDot + 1.0 );\r\n\r\n\tgl_FragColor = texture2D( cmap, vec2( vDepth, 1.0 ) ) * light;\r\n\r\n#else\r\n\r\n\tgl_FragColor = texture2D( cmap, vec2( vDepth, 1.0 ) ) * vec4( vColor, 1.0 );\r\n\r\n#endif\r\n\r\n}\r\n",depthCursorVertexShader:"\r\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\r\n\r\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\r\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\r\n\r\nfloat unpackRGBAToFloat( const in vec4 v ) {\r\n\treturn dot( v, UnpackFactors );\r\n}\r\n\r\nuniform float minX;\r\nuniform float minY;\r\nuniform float minZ;\r\n\r\nuniform float scaleX;\r\nuniform float scaleY;\r\nuniform float rangeZ;\r\n\r\nuniform sampler2D depthMap;\r\nuniform float datumShift;\r\n\r\n#ifdef SURFACE\r\n\r\nuniform vec3 uLight;\r\n\r\nvarying vec3 vNormal;\r\nvarying vec3 lNormal;\r\n\r\n#else\r\n\t\r\nvarying vec3 vColor;\r\n\r\n#endif\r\n\r\nvarying float vDepth;\r\n\r\nvoid main() {\r\n\r\n#ifdef SURFACE\r\n\r\n\tvNormal = normalMatrix * normal;\r\n\tlNormal = uLight;\r\n\r\n#else\r\n\r\n\tvColor = color;\r\n\r\n#endif\r\n\r\n\tvec2 terrainCoords = vec2( ( position.x - minX ) * scaleX, ( position.y - minY ) * scaleY );\r\n\tfloat terrainHeight = unpackRGBAToFloat( texture2D( depthMap, terrainCoords ) );\r\n\r\n\tvDepth = terrainHeight * rangeZ + datumShift + minZ - position.z;\r\n\r\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n",depthCursorFragmentShader:"\r\nuniform float cursor;\r\nuniform float cursorWidth;\r\n\r\nuniform vec3 baseColor;\r\nuniform vec3 cursorColor;\r\n\r\nvarying float vDepth;\r\n\r\n#ifdef SURFACE\r\n\r\nvarying vec3 vNormal;\r\nvarying vec3 lNormal;\r\n\r\n#else\r\n\r\nvarying vec3 vColor;\r\n\r\n#endif\r\n\r\nvoid main() {\r\n\r\n\tfloat light;\r\n#ifdef SURFACE\r\n\r\n\tfloat nDot = dot( normalize( vNormal ), normalize( lNormal ) );\r\n\tlight = 0.5 * ( nDot + 1.0 );\r\n\r\n#else\r\n\r\n\tlight = 1.0;\r\n\r\n#endif\r\n\r\n\tfloat delta = abs( vDepth - cursor );\r\n\tfloat ss = smoothstep( 0.0, cursorWidth, cursorWidth - delta );\r\n\r\n#ifdef SURFACE\r\n\r\n\tif ( delta < cursorWidth * 0.05 ) {\r\n\r\n\t\tgl_FragColor = vec4( 1.0, 1.0, 1.0, 1.0 ) * light;\r\n\r\n\t} else {\r\n\r\n\t\tgl_FragColor = vec4( mix( baseColor, cursorColor, ss ) * light, 1.0 );\r\n\r\n\t}\r\n\r\n#else\r\n\r\n\tif ( delta < cursorWidth * 0.05 ) {\r\n\r\n\t\tgl_FragColor = vec4( 1.0, 1.0, 1.0, 1.0 ) * light * vec4( vColor, 1.0 );\r\n\r\n\t} else {\r\n\r\n\t\tgl_FragColor = vec4( mix( baseColor, cursorColor, ss ) * light, 1.0 ) * vec4( vColor, 1.0 );\r\n\r\n\t}\r\n\r\n#endif\r\n\r\n}",extendedPointsVertexShader:"uniform float size;\r\nuniform float scale;\r\nuniform float pScale;\r\n\r\nattribute float pSize;\r\n\r\n#include <common>\r\n#include <color_pars_vertex>\r\n#include <shadowmap_pars_vertex>\r\n#include <logdepthbuf_pars_vertex>\r\n#include <clipping_planes_pars_vertex>\r\n\r\nvoid main() {\r\n\r\n\t#include <color_vertex>\r\n\t#include <begin_vertex>\r\n\t#include <project_vertex>\r\n\r\n\t#ifdef USE_SIZEATTENUATION\r\n\t\tgl_PointSize = pScale * pSize * ( scale / - mvPosition.z );\r\n\t#else\r\n\t\tgl_PointSize = pScale * pSize;\r\n\t#endif\r\n\r\n\t#include <logdepthbuf_vertex>\r\n\t#include <clipping_planes_vertex>\r\n\t#include <worldpos_vertex>\r\n\t#include <shadowmap_vertex>\r\n\r\n}\r\n",extendedPointsFragmentShader:"uniform vec3 diffuse;\r\nuniform float opacity;\r\n\r\n#include <common>\r\n#include <packing>\r\n#include <color_pars_fragment>\r\n#include <map_particle_pars_fragment>\r\n#include <fog_pars_fragment>\r\n#include <shadowmap_pars_fragment>\r\n#include <logdepthbuf_pars_fragment>\r\n#include <clipping_planes_pars_fragment>\r\n\r\nvoid main() {\r\n\r\n\t#include <clipping_planes_fragment>\r\n\r\n\tvec3 outgoingLight = vec3( 0.0 );\r\n\tvec4 diffuseColor = vec4( diffuse, opacity );\r\n\r\n\t#include <logdepthbuf_fragment>\r\n\t#include <map_particle_fragment>\r\n\t#include <color_fragment>\r\n\t#include <alphatest_fragment>\r\n\r\n\toutgoingLight = diffuseColor.rgb;\r\n\r\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\r\n\r\n\t#include <premultiplied_alpha_fragment>\r\n\t#include <tonemapping_fragment>\r\n\t#include <encodings_fragment>\r\n\t#include <fog_fragment>\r\n\r\n}\r\n",glyphVertexShader:"\r\n\r\n// glyph shader, each instance represents one glyph.\r\n\r\nuniform float cellScale;\r\nuniform mat2 rotate;\r\nuniform float scale;\r\n\r\nattribute vec2 instanceUvs;\r\nattribute float instanceOffsets;\r\nattribute float instanceWidths;\r\n\r\nvarying vec2 vUv;\r\nvarying vec3 vColor;\r\n\r\nvoid main() {\r\n\r\n\tvColor = color;\r\n\r\n\t// select glyph from atlas ( with proportional spacing ).\r\n\r\n\tvUv = instanceUvs + vec2( position.x * cellScale * instanceWidths, position.y * cellScale );\r\n\r\n\t// scale by glyph width ( vertices form unit square with (0,0) origin )\r\n\r\n\tvec2 newPosition = vec2( position.x * instanceWidths, position.y );\r\n\r\n\t// move to correct offset in string\r\n\r\n\tnewPosition.x += instanceOffsets;\r\n\r\n\t// rotate as required\r\n\r\n\tnewPosition = rotate * newPosition;\r\n\r\n\t// position of GlyphString object on screeno\r\n\r\n\tvec4 offset = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\r\n\r\n\t// scale glyphs\r\n\r\n\tnewPosition.xy *= 0.0625;\r\n\r\n\t// correct for aspect ratio\r\n\r\n\tnewPosition.x *= scale;\r\n\r\n\t// move to clip space\r\n\r\n\tnewPosition.xy *= offset.w;\r\n\r\n\tgl_Position = vec4( newPosition, 0.0, 0.0 ) + offset;\r\n\r\n}\r\n",glyphFragmentShader:"\r\nuniform sampler2D atlas;\r\n\r\nvarying vec2 vUv;\r\nvarying vec3 vColor;\r\n\r\nvoid main() {\r\n\r\n\tgl_FragColor = texture2D( atlas, vUv ) * vec4( vColor, 1.0 );\r\n\r\n}",heightVertexShader:"\r\nuniform sampler2D cmap;\r\n\r\nuniform float minZ;\r\nuniform float scaleZ;\r\n\r\n#ifdef SURFACE\r\n\r\nuniform vec3 uLight;\r\n\r\nvarying vec3 vNormal;\r\nvarying vec3 lNormal;\r\n\r\n#else\r\n\r\nvarying vec3 vColor;\r\n\r\n#endif\r\n\r\nvarying float zMap;\r\n\r\nvoid main() {\r\n\r\n#ifdef SURFACE\r\n\r\n\tvNormal = normalMatrix * normal;\r\n\tlNormal = uLight;\r\n\r\n#else\r\n\r\n\tvColor = color;\r\n\r\n#endif\r\n\r\n\tzMap = ( position.z - minZ ) * scaleZ;\r\n\r\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n\r\n}\r\n",heightFragmentShader:"\r\nuniform sampler2D cmap;\r\n\r\nvarying float zMap;\r\n\r\n#ifdef SURFACE\r\n\r\nvarying vec3 vNormal;\r\nvarying vec3 lNormal;\r\n\r\n#else\r\n\r\nvarying vec3 vColor;\r\n\r\n#endif\r\n\r\nvoid main() {\r\n\r\n#ifdef SURFACE\r\n\r\n\tfloat nDot = dot( normalize( vNormal ), normalize( lNormal ) );\r\n\tfloat light;\r\n\tlight = 0.5 * ( nDot + 1.0 );\r\n\r\n\tgl_FragColor = texture2D( cmap, vec2( 1.0 - zMap, 1.0 ) ) * vec4( light, light, light, 1.0 );\r\n\r\n#else\r\n\r\n\tgl_FragColor = texture2D( cmap, vec2( 1.0 - zMap, 1.0 ) ) * vec4( vColor, 1.0 );\r\n\r\n#endif\r\n\r\n}\r\n",waterVertexShader:"\r\nattribute vec3 sinks;\r\n\r\nvarying vec3 vPosition;\r\nvarying vec3 vSink;\r\n\r\nvoid main() {\r\n\r\n\tvPosition = position;\r\n\tvSink = sinks;\r\n\r\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n\r\n}\r\n",waterFragmentShader:"\r\nuniform float offset;\r\n\r\nvarying vec3 vPosition;\r\nvarying vec3 vSink;\r\n\r\nvoid main() {\r\n\r\n\tgl_FragColor = vec4( 0.1, 0.1, sin( offset + distance( vPosition, vSink ) ) * 0.4 + 0.6, 0.0 );\r\n\r\n}\r\n"};xi.prototype=Object.create(at.prototype),xi.prototype.constructor=xi,xi.prototype.setCursor=function(t){var e=Math.max(Math.min(t,this.halfRange),-this.halfRange);return this.uniforms.cursor.value=e,e},xi.prototype.getCursor=function(){return this.uniforms.cursor.value},bi.prototype=Object.create(at.prototype),bi.prototype.constructor=bi,bi.prototype.setDatumShift=function(t){this.uniforms.datumShift.value=t},wi.prototype=Object.create(at.prototype),wi.prototype.constructor=wi,wi.prototype.setCursor=function(t){var e=Math.max(Math.min(t,this.max),0);return this.uniforms.cursor.value=e,e},wi.prototype.getCursor=function(){return this.uniforms.cursor.value},wi.prototype.setDatumShift=function(t){this.uniforms.datumShift.value=t},_i.prototype=Object.create(at.prototype),_i.prototype.constructor=_i,Mi.prototype=Object.create(at.prototype),Mi.prototype.constructor=Mi,Ei.prototype.constructor=Ei,Ei.prototype.getTexture=function(){return this.texture},Ei.prototype.getCellScale=function(){return this.cellScale},Ei.prototype.getGlyph=function(t){var e=this.map[t];return void 0===e&&(console.warn("unavailable glyph ["+t+"]",t.codePointAt()),e=this.map["☐"]),e};var Lh={},Ch={};Ch.getAtlas=function(t){var e=Lh[t];return void 0===e&&(e=new Ei(t),Lh[t]=e),e},Si.prototype=Object.create(at.prototype),Si.prototype.constructor=Si,Si.prototype.getAtlas=function(){return this.atlas};var Rh,Ph=new Map,Ih=[],Oh=[],Nh={},Dh={getHeightMaterial:Ci,getDepthMapMaterial:Ri,getDepthMaterial:Pi,getDepthCursorMaterial:Oi,getCursorMaterial:Ii,getSurfaceMaterial:Ni,getLineMaterial:Di,getGlyphMaterial:Ui,setTerrain:zi,initCache:Bi,flushCache:Fi};ki.prototype=Object.create(Bt.prototype),Object.assign(ki.prototype,s.prototype),ki.prototype.constructor=ki,ki.prototype.setRange=function(t,e,r){return this.maxDiv.textContent=Math.round(e)+"m",this.minDiv.textContent=Math.round(t)+"m",this.setCaption(r),this},ki.prototype.setCaption=function(t){return this.caption.textContent=t,this},ki.prototype.setMaterial=function(t){return this.material=t,this},Gi.prototype=Object.create(Bt.prototype),Object.assign(Gi.prototype,s.prototype),Gi.prototype.constructor=Gi,Gi.prototype.setRange=function(t,e,r){return this.maxDiv.textContent=Math.round(e)+"m",this.minDiv.textContent=Math.round(t)+"m",this.caption.textContent=r,this},Gi.prototype.setCursor=function(t){return this.cursor.position.setY(this.barHeight*t),this},Vi.prototype=Object.create(Bt.prototype),Object.assign(Vi.prototype,s.prototype),Vi.prototype.constructor=Vi,Vi.prototype.set=function(t){this.progress=t;for(var e=2*Math.floor(Math.min(100,Math.round(t))/2),r=this.geometry.faces,n=0;n<e;n++)r[99-n].color.set(65280);this.geometry.colorsNeedUpdate=!0},Vi.prototype.add=function(t){this.set(this.progress+t)},Vi.prototype.start=function(){for(var t=this.geometry.faces,e=0;e<100;e++)t[e].color.set(3355443);this.geometry.colorsNeedUpdate=!0,this.progress=0,this.visible=this.isVisible},Vi.prototype.end=function(){var t=this;setTimeout(function(){t.visible=!1,ed.renderView()},500)},Vi.prototype.setVisibility=function(t){this.isVisible=t,this.visible=this.visible&&t},Hi.prototype=Object.create(De.prototype),Object.assign(Hi.prototype,s.prototype),Hi.prototype.constructor=Hi,Hi.prototype.setVisibility=function(t){s.prototype.setVisibility.call(this,t),0!==this.currentLength&&(this.scaleBars[this.currentLength].mesh.visible=t)},Hi.prototype.setScale=function(t){var e,r=this.scaleBars,i=0,a=this,o=this.scaleMax/(t*this.hScale),s=Math.ceil(Math.log(o)/Math.LN10)-1,c=o/Math.pow(10,s);if(c<2?(i=10,s-=1):i=c<5?2:5,e=s>=3?i*Math.pow(10,s-3)+"km":i*Math.pow(10,s)+"m",t*=Math.pow(10,s),this.currentLength!==i){if(!r[i]){var l=function(t){var e,r,i=t*a.hScale,o=new It(i,4,t),s=new It(i,4,10*t),c=new _t;c.vertices.push(new n(-i/2,0,1)),c.vertices.push(new n(i/2,0,1));var l=new Bt(o,new Nt({color:16777215,vertexColors:ec,side:Zs})),h=new Bt(s,new Nt({color:16777215,vertexColors:ec,side:Zs})),u=new Pe(c,new Ce({color:16711680}));for(e=0,r=o.faces.length;e<r;e+=4)o.faces[e].color=Yl.red,o.faces[e+1].color=Yl.red;for(e=0,r=s.faces.length;e<r;e+=4)s.faces[e].color=Yl.red,s.faces[e+1].color=Yl.red;o.translate(i/2,7,0),s.translate(i/2,2,0),c.translate(i/2,4,0),o.computeBoundingBox();var d=new De;return d.add(l),d.add(h),d.add(u),{mesh:d,topRight:o.boundingBox.max.x}}(i);r[i]=l,this.add(l.mesh)}this.currentLength>0&&(r[this.currentLength].mesh.visible=!1),r[i].mesh.visible=this.visible,this.currentLength=i}r[i].mesh.scale.x=t;var h=this.legend;return h.style.display=this.visible?"block":"none",h.style.left=t*r[i].topRight-h.clientWidth+"px",h.textContent=e,this};var Uh,zh,Bh,Fh,kh,Gh,Vh,Hh,jh,Wh=0,Xh=null,Yh=null,qh=null,Zh=null,Jh=!0,Qh={init:ji,renderHUD:Qi,update:Ji,setVisibility:Wi,getVisibility:Xi,getProgressDial:Yi,setScale:qi};na.prototype.constructor=na,na.prototype.prepare=function(t,e){if(0===this.frameCount){if(this.skipNext=!1,e&&e.isBox3){var r,n=e.getSize(),i=this.controls.object;if(e=e.getCenter(),i.isPerspectiveCamera){var a=Math.tan(.5*Ko.DEG2RAD*i.getEffectiveFOV()),o=1.5*a*n.y/2+n.z,s=a*i.aspect*n.x/2+n.z;r=Math.max(o,s),this.targetZoom=1,0===r&&(r=100)}else{var c=(i.right-i.left)/n.x,l=(i.top-i.bottom)/n.y;this.targetZoom=Math.min(c,l),r=600}(t=e.clone()).z=t.z+r}this.cameraTarget=t,this.targetPOI=e,this.moveRequired=null!==this.cameraTarget||null!==this.targetPOI;var h=this.controls.target,u=this.controls.object.position;if(null!==t)if(t.equals(u))this.moveRequired=!1,null===e&&(this.skipNext=!0);else{null===e&&(e=h);var d=u.distanceTo(t),p=this.getControlPoint(h,u,t,d),f=this.getControlPoint(e,t,u,d);this.curve=new fi(u,p,f,t)}}},na.prototype.getControlPoint=function(t,e,r,i){for(var a=new n,o=new n,s=new n,c=0;0===c;)a.copy(e).sub(t),o.copy(r).sub(t),s.crossVectors(a,o),0===(c=s.length())&&t.addScalar(-1);var l=(new n).crossVectors(s,a).setLength(Math.min(i,a.length())/3),h=(new n).copy(l).add(a),u=(new n).copy(l).negate().add(a);return o.distanceTo(h)<o.distanceTo(u)?h:u},na.prototype.start=function(t){0!==this.frameCount||this.skipNext||(this.frameCount=t+1,this.frames=this.frameCount,this.controls.enabled=!this.moveRequired,this.animate())},na.prototype.animate=function(){var t=--this.frameCount,e=this.controls,r=this.curve;if(t<0)return this.frameCount=0,void this.endAnimation();if(this.moveRequired){var n=e.object,i=1-t/this.frames;e.target.lerp(this.targetPOI,i),null!==r&&n.position.copy(this.curve.getPoint(i)),n.zoom=n.zoom+(this.targetZoom-n.zoom)*i,n.updateProjectionMatrix()}if(e.update(),0===t)return void this.endAnimation();var a=this;requestAnimationFrame(function(){a.animate()}),this.renderFunction()},na.prototype.endAnimation=function(){this.controls.enabled=!0,this.moveRequired=!1,this.cameraTarget=null,this.targetPOI=null,this.renderFunction(),this.endCallback()},na.prototype.stop=function(){this.frameCount=1},na.prototype.cancel=function(){this.frameCount=0,this.skipNext=!1},na.prototype.isActive=function(){return this.frameCount>0},ia.prototype.constructor=ia,ia.prototype.traverse=function(t){var e=this.children;t(this);for(var r=0;r<e.length;r++)e[r].traverse(t)},ia.prototype.traverseDepthFirst=function(t){for(var e=this.children,r=0;r<e.length;r++)e[r].traverseDepthFirst(t);t(this)},ia.prototype.forEachChild=function(t,e){for(var r,n=this.children,i=0;i<n.length;i++)t(r=n[i]),!0===e&&r.forEachChild(t,!0)},ia.prototype.addById=function(t,e,r,n){var i=this.findById(r);if(i){var a=new ia(t,e,this.root,i);void 0!==n&&Object.assign(a,n),i.children.push(a);var o=this.root;return o.maxId=Math.max(o.maxId,e),a.id}return null},ia.prototype.findById=function(t){if(this.id==t)return this;for(var e=0,r=this.children.length;e<r;e++){var n=this.children[e].findById(t);if(n)return n}},ia.prototype.getByPath=function(t){var e=t.split("."),r=this.getByPathArray(e);return 0===e.length?r:void 0},ia.prototype.getByPathArray=function(t){for(var e=this,r=!0;r&&t.length>0;){r=!1;for(var n=0,i=e.children.length;n<i;n++){var a=e.children[n];if(a.name===t[0]){e=a,t.shift(),r=!0;break}}}return e},ia.prototype.addPath=function(t,e){var r,n;if(r=this.getByPathArray(t),0===t.length)return r;for(;t.length>0;)n=new ia(t.shift(),null,this.root,r),r.children.push(n),r=n;return void 0!==e&&Object.assign(r,e),r},ia.prototype.getPath=function(t){var e=this,r=[];void 0===t&&(t=this.root);do{r.push(e.name),e=e.parent}while(e!==t);return r.reverse().join(".")},ia.prototype.getSubtreeIds=function(t,e){function r(t){e.add(t.id)}this.findById(t).traverse(r)},ia.prototype.getIdByPath=function(t){var e=this.getByPathArray(t);return 0===t.length?e.id:void 0},aa.prototype.type="Box3Helper",aa.prototype=Object.create(Pe.prototype),aa.prototype.constructor=aa,aa.prototype.update=function(t){if(this.box3=t,!t.isEmpty()){var e=t.min,r=t.max,n=this.geometry.attributes.position,i=n.array;i[0]=r.x,i[1]=r.y,i[2]=r.z,i[3]=e.x,i[4]=r.y,i[5]=r.z,i[6]=e.x,i[7]=e.y,i[8]=r.z,i[9]=r.x,i[10]=e.y,i[11]=r.z,i[12]=r.x,i[13]=r.y,i[14]=e.z,i[15]=e.x,i[16]=r.y,i[17]=e.z,i[18]=e.x,i[19]=e.y,i[20]=e.z,i[21]=r.x,i[22]=e.y,i[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}},aa.prototype.removed=function(){this.geometry&&this.geometry.dispose()},oa.indexAttribute=null,oa.positionAttribute=null,oa.prototype=Object.assign(Object.create(Zn.prototype),{constructor:oa}),sa.prototype=Object.assign(Object.create(Bt.prototype),{constructor:sa,isGlyphString:!0,getWidth:function(){return this.geometry.width}}),ca.prototype=Object.create(Ne.prototype),ca.prototype.constructor=ca;var Kh=new n,$h=new n,tu=new n,eu=new n,ru=new zt(Kh,$h,tu),nu=new zt(Kh,tu,eu),iu=[];ua.prototype.addNode=function(t,e){var r=0,n=t.position;if(this.markers.push(t),this.centroid.add(t.position),this.count++,0!=e--){var i=(this.xMin+this.xMax)/2,a=(this.yMin+this.yMax)/2;n.x>i&&(r+=1),n.y>a&&(r+=2);var o=this.nodes[r];if(void 0===o){switch(r){case 0:o=new ua(this.xMin,i,this.yMin,a);break;case 1:o=new ua(i,this.xMax,this.yMin,a);break;case 2:o=new ua(this.xMin,i,a,this.yMax);break;case 3:o=new ua(i,this.xMax,a,this.yMax)}this.nodes[r]=o}o.addNode(t,e)}},ua.prototype.check=function(t){for(var e,r=0;r<4;r++)if(void 0!==(e=this.nodes[r])){if(e.count<2){this.nodes[r]=void 0;continue}e.projectedArea(t)<.8?e.clusterMarkers(t):(e.showMarkers(),e.check(t))}},ua.prototype.showMarkers=function(){for(var t=this.markers,e=0,r=t.length;e<r;e++)t[e].visible=!0;null!==this.quadMarker&&(this.quadMarker.visible=!1)},ua.prototype.clusterMarkers=function(t){var e,r,n,i=this.markers;for(e=0,r=i.length;e<r;e++)i[e].visible=!1;for(e=0;e<4;e++)void 0!==(n=this.nodes[e])&&n.hideQuadMarkers();if(null===this.quadMarker){var a=ha(this.count);a.position.copy(this.centroid).divideScalar(this.count),a.layers.set(Ls),t.add(a),this.quadMarker=a}this.quadMarker.visible=!0},ua.prototype.hideQuadMarkers=function(){var t;this.quadMarker&&(this.quadMarker.visible=!1);for(var e=0;e<4;e++)void 0!==(t=this.nodes[e])&&t.hideQuadMarkers()},ua.prototype.projectedArea=function(t){var e=t.camera,r=t.matrixWorld,n=this.centroid.z/this.count;return Kh.set(this.xMin,this.yMin,n).applyMatrix4(r).project(e),$h.set(this.xMin,this.yMax,n).applyMatrix4(r).project(e),tu.set(this.xMax,this.yMax,n).applyMatrix4(r).project(e),eu.set(this.xMax,this.yMin,n).applyMatrix4(r).project(e),ru.area()+nu.area()},da.prototype=Object.create(gt.prototype),da.prototype.constructor=da,da.prototype.onRemoved=function(){this.traverse(function(t){"GlyphString"===t.type&&t.geometry.dispose()})},da.prototype.addMarker=function(t,e){var r=new sa(e,Dh.getGlyphMaterial("normal helvetica,sans-serif",Math.PI/4));return r.layers.set(Ls),r.position.copy(t),this.quadTree.addNode(r,this.maxDepth),this.add(r),r},da.prototype.cluster=function(t){this.children.length<2||(this.camera=t,this.quadTree.check(this))},pa.prototype=Object.create(at.prototype),pa.prototype.constructor=pa,fa.prototype=Object.create(Ne.prototype),fa.prototype.constructor=fa,fa.prototype.addStation=function(t){var e=t.p;this.vertices.push(e),this.colors.push(this.baseColor),this.pointSizes.push(e.type===Us?8:0),this.map.set(e.x.toString()+":"+e.y.toString()+":"+e.z.toString(),t),this.stations.push(t),t.hitCount=0,t.stationVertexIndex=this.stationCount++,t.linkedSegments=[]},fa.prototype.getStation=function(t){return this.map.get(t.x.toString()+":"+t.y.toString()+":"+t.z.toString())},fa.prototype.getStationByIndex=function(t){return this.stations[t]},fa.prototype.clearSelected=function(){if(null!==this.selected){var t=this.geometry.getAttribute("pSize");t.setX(this.selected,this.selectedSize),t.needsUpdate=!0,this.selected=null}},fa.prototype.selectStation=function(t){this.selectStationByIndex(t.stationVertexIndex)},fa.prototype.selectStationByIndex=function(t){var e=this.geometry.getAttribute("pSize");null!==this.selected&&e.setX(this.selected,this.selectedSize),this.selectedSize=e.getX(t),e.setX(t,2*this.selectedSize),e.needsUpdate=!0,this.selected=t},fa.prototype.updateStation=function(t){var e=this.getStation(t);void 0!==e&&(++e.hitCount>2?(this.colors[e.stationVertexIndex]=this.junctionColor,this.pointSizes[e.stationVertexIndex]=4):e.hitCount>0&&(this.pointSizes[e.stationVertexIndex]=2))},fa.prototype.finalise=function(){var t=this.geometry,e=new Tt(3*this.vertices.length,3),r=new Tt(3*this.colors.length,3);t.addAttribute("pSize",new Tt(this.pointSizes,1)),t.addAttribute("position",e.copyVector3sArray(this.vertices)),t.addAttribute("color",r.copyColorsArray(this.colors)),this.pointSizes=null,this.vertices=null,this.colors=null},fa.prototype.setScale=function(t){this.material.uniforms.pScale.value=t,this.material.needsUpdate=!0};var au=new n;ma.prototype=Object.create(De.prototype),ma.prototype.constructor=ma,ma.prototype.addStation=function(t){var e;e=0===t.hitCount?this.splayLabelMaterial:t.hitCount<3?this.defaultLabelMaterial:this.junctionLabelMaterial;var r=new sa(t.name,e);r.layers.set(Ns),r.position.copy(t.p),r.hitCount=t.hitCount,r.visible=!1,this.add(r)},ma.prototype.update=function(t,e,r){var n=au.copy(t.position);t.isOrthographicCamera&&(n.sub(e),n.setLength(ns/t.zoom),n.add(e)),n.applyMatrix4(r);for(var i,a,o=t.layers.mask&1<<Es,s=this.children,c=0,l=s.length;c<l;c++)0!==(i=s[c]).hitCount||o?(a=i.hitCount<3?5e3:4e4,i.visible=i.position.distanceToSquared(n)<a):i.visible=!1},ga.prototype.constructor=ga,Object.assign(ga.prototype,l.prototype),ga.prototype.mapSurvey=function(t,e,r){this.surveyTree=r;var n,i,a,o,s,c=this.segmentMap,l=!0,h=0,u=this.vertexPairToSegment,d=this.segmentToInfo,p=e.length;for(o=0;o<p;o+=2){if(i=e[o],a=e[o+1],u.push(h),l){if(void 0===(n=t.getStation(i)))continue;s={segment:h,startStation:n,endStation:null},n.linkedSegments.push(h),l=!1}((n=t.getStation(a))&&n.hitCount>2||o+2<p&&!a.equals(e[o+2]))&&(s.endStation=n,c.set(s.startStation.id+":"+n.id,s),d[h]=s,n.linkedSegments.push(h),h++,l=!0)}return l||(s.endStation=n,c.set(s.startStation.id+":"+n.id,s),n.linkedSegments.push(h)),this},ga.prototype.createWireframe=function(){function t(t){r.push(t.startStation.p),r.push(t.endStation.p)}var e=new _t,r=e.vertices;return this.segmentMap.forEach(t),new Pe(e,new Ce({color:65280}))},ga.prototype.addRoute=function(t){t!==this.currentRouteName&&void 0!==t&&(this.routeNames.indexOf(t)<0&&(this.routeNames.push(t),this.routes.set(t,[])),this.loadRoute(t))},ga.prototype.loadRoute=function(t){var e,r,n=this,i=this.surveyTree,a=this.currentRoute,o=this.segmentMap,s=this.routes.get(t);if(!s)return alert("route "+t+" does not exist"),!1;a.clear();for(var c=0;c<s.length;c++)r=s[c],void 0!==(e=o.get(i.getIdByPath(r.start.split("."))+":"+i.getIdByPath(r.end.split("."))))&&a.add(e.segment);return this.currentRouteName=t,n.dispatchEvent({type:"changed",name:""}),!0},ga.prototype.getCurrentRoute=function(){return this.currentRoute},ga.prototype.saveCurrent=function(){function t(t){n.has(t.segment)&&i.push({start:t.startStation.getPath(),end:t.endStation.getPath()})}var e=this.currentRouteName;if(e){var r=this.segmentMap,n=this.currentRoute,i=[];r.forEach(t),this.routes.set(e,i),this.metadataSource.saveRoute(e,{segments:i})}},ga.prototype.getRouteNames=function(){return this.routeNames},ga.prototype.toggleSegment=function(t){function e(t){n.has(t)||r.adjacentSegments.add(t)}var r=this,n=this.currentRoute,i=this.vertexPairToSegment[t/2];if(this.adjacentSegments.clear(),n.has(i))n.delete(i);else{n.add(i);var a=this.segmentToInfo[i];void 0!==a&&(a.startStation.linkedSegments.forEach(e),a.endStation.linkedSegments.forEach(e))}},ga.prototype.inCurrentRoute=function(t){return this.currentRoute.has(this.vertexPairToSegment[t/2])},ga.prototype.adjacentToRoute=function(t){return this.adjacentSegments.has(this.vertexPairToSegment[t/2])};var ou=new Ce({color:4473924,vertexColors:rc});xa.prototype=Object.create(Pe.prototype),xa.prototype.constructor=xa,xa.prototype.addLegs=function(t,e,r){var n=this.geometry;return 0===n.vertices.length?(n.vertices=t,n.colors=e):console.error("Walls: appending not yet implemented"),n.computeBoundingBox(),this.legRuns=r,this.computeStats(),this},xa.prototype.cutRuns=function(t){var e=this.legRuns;if(e){for(var r=this.geometry,n=r.vertices,i=r.colors,a=new _t,o=a.vertices,s=a.colors,c=[],l=0,h=0,u=e.length;h<u;h++){var d=e[h],p=d.survey,f=d.start,m=d.end;if(t.has(p)){for(var g=f;g<m;g++)o.push(n[g]),s.push(i[g]);d.start=l,l+=m-f,d.end=l,c.push(d)}}return 0!==a.vertices.length&&(a.computeBoundingBox(),a.name=r.name,this.geometry=a,this.legRuns=c,r.dispose(),this.computeStats(),!0)}},xa.prototype.computeStats=function(){for(var t,e,r,n={maxLegLength:-1/0,minLegLength:1/0,legCount:0,legLength:0},i=this.geometry.vertices,a=i.length,o=0;o<a;o+=2)t=i[o],e=i[o+1],r=Math.abs(t.distanceTo(e)),n.legLength=n.legLength+r,n.maxLegLength=Math.max(n.maxLegLength,r),n.minLegLength=Math.min(n.minLegLength,r);n.legLengthRange=n.maxLegLength-n.minLegLength,n.legCount=a/2,this.stats=n},xa.prototype.setShading=function(t,e,r){this.material=r;var n,i,a,o=this.geometry,s=this.legRuns,c=o.colors;if(t.size&&s)for(i=0,n=s.length;i<n;i++){var l=s[i],h=l.survey,u=l.start,d=l.end;if(t.has(h))for(a=u;a<d;a+=2)e(o,a,a+1,h);else for(a=u;a<d;a+=2)c[a]=Yl.grey,c[a+1]=Yl.grey}else for(a=0,n=o.vertices.length;a<n;a+=2)e(o,a,a+1);o.colorsNeedUpdate=!0};var su=new Cr({color:4473924,vertexColors:ec});ba.prototype=Object.create(Bt.prototype),ba.prototype.constructor=ba,ba.prototype.addWalls=function(t,e,r){var n=this.geometry;if(void 0===n.getAttribute("position")){var i=new Tt(3*t.length,3);n.addAttribute("position",i.copyVector3sArray(t)),n.setIndex(e)}else console.error("Walls: appending not yet implemented");return n.computeVertexNormals(),n.computeBoundingBox(),this.indexRuns=r,this},ba.prototype.setShading=function(t,e){var r=this.geometry;r.clearGroups();var n=this.indexRuns;if(t.size&&n){this.material=[e,su];for(var i,a=n[0],o=a.start,s=a.count,c=t.has(a.survey)?0:1,l=1,h=n.length;l<h;l++)a=n[l],(i=t.has(a.survey)?0:1)===c&&a.start===o+s?s+=a.count:(r.addGroup(o,s,c),o=a.start,s=a.count,c=i);r.addGroup(o,s,c)}else this.material=e},ba.prototype.cutRuns=function(t){for(var e,r,n,i=this.indexRuns,a=this.geometry,o=a.getAttribute("position"),s=a.index,c=[],l=[],h=[],u=0,d=new Map,p=0,f=0,m=i.length;f<m;f++){var g=i[f];if(t.has(g.survey)){for(var v=g.start,y=g.count,x=v+y,b=o.itemSize,w=o.array,_=v;_<x;_++)e=s.getX(_),void 0===(r=d.get(e))&&(r=p++,d.set(e,r),n=e*b,l.push(w[n],w[n+1],w[n+2])),c.push(r);g.start=u,u+=y,h.push(g)}}return 0!==c.length&&(a.index.setArray(new s.array.constructor(c)),a.index.needsUpdate=!0,o.setArray(new Float32Array(l)),o.needsUpdate=!0,a.computeVertexNormals(),a.computeBoundingBox(),this.indexRuns=h,!0)},wa.prototype=Object.create(at.prototype),wa.prototype.constructor=wa,Ma.prototype=Object.create(Bt.prototype),Ma.prototype.constructor=Ma,Ma.prototype.finish=function(){var t=this.geometry,e=this.vertices,r=this.ends,n=new Tt(3*e.length,3),i=new Tt(3*r.length,3);return t.addAttribute("position",n.copyVector3sArray(e)),t.addAttribute("sinks",i.copyVector3sArray(r)),this},Ma.prototype.addTrace=function(t,e){var r=this.vertices,i=this.ends,a=(new n).copy(e),o=(new n).subVectors(e,t).cross(zs).setLength(2),s=(new n).add(t).add(o),c=(new n).add(t).sub(o);r.push(s),r.push(c),r.push(a),i.push(a),i.push(a),i.push(a)},Ea.prototype.constructor=Ea,Ea.prototype.getTraces=function(){return this.traces},Ea.prototype.getRoutes=function(){return this.routes},Ea.prototype.saveRoute=function(t,e){this.routes[t]=e,this.saveLocal()},Ea.prototype.saveLocal=function(){var t={routes:this.routes,traces:this.traces};localStorage.setItem(this.name,JSON.stringify(t))},Ea.prototype.getURL=function(){var t={name:"test",version:1,routes:this.routes,traces:this.traces};return"data:text/json;charset=utf8,"+encodeURIComponent(JSON.stringify(t))};var cu=[],lu=0,hu={};hu.clearMap=function(){cu=[],lu=0},hu.getSurveyColour=function(t){var e=Yl.getColors("survey");return e[t%e.length]},hu.getSurveyColourMap=function(t,e){function r(t){void 0===t.p&&(cu[t.id]=a)}if(lu===e&&cu.length>0)return cu;cu=[];var n=0===(lu=e)?t.id:lu,i=t.findById(n),a=this.getSurveyColour(n);r(i);for(var o=i.children;1===o.length;)r(i=o[0]),o=i.children;for(var s=0,c=o.length;s<c;s++){var l=o[s].id;i=t.findById(l),a=this.getSurveyColour(l),i.traverse(r)}return cu};var uu=255/65536/16777216,du=255/65536/65536,pu=255/65536/256,fu=255/65536/1;Ta.prototype=Object.create(De.prototype),Ta.prototype.constructor=Ta,Ta.prototype.shadingMode=xs,Ta.prototype.opacity=.5,Ta.prototype.removed=function(){},Ta.prototype.getOpacity=function(){return this.opacity},Ta.prototype.commonRemoved=function(){var t=this.activeOverlay;null!==t&&(t.flushCache(),t.hideAttribution()),null!==this.renderTarget&&this.renderTarget.dispose()},Ta.prototype.setShadingMode=function(t,e){var r,n=!0,i=this.activeOverlay;switch(t){case ds:r=Dh.getHeightMaterial(2);break;case ys:this.setOverlay(null===i?this.defaultOverlay:i,e),n=!1;break;case xs:r=new Cr({color:16777215,vertexColors:rc,side:Zs,transparent:!0,opacity:this.opacity});break;default:return console.warn("unknown mode",t),!1}return n&&null!==i&&(i.flushCache(),i.hideAttribution(),this.activeOverlay=null),void 0!==r&&this.setMaterial(r),this.shadingMode=t,!0},Ta.prototype.setVisibility=function(t){null!==this.activeOverlay&&(t?this.activeOverlay.showAttribution():this.activeOverlay.hideAttribution())},Ta.prototype.applyDatumShift=function(t){t&&0===this.activeDatumShift?(this.translateZ(this.datumShift),this.activeDatumShift=this.datumShift):t||0===this.activeDatumShift||(this.translateZ(-this.datumShift),this.activeDatumShift=0),this.dispatchEvent({type:"datumShiftChange",value:this.activeDatumShift})},Ta.prototype.computeBoundingBox=function(){function t(t){t.isTile&&e.union(t.geometry.boundingBox)}var e=new st;return this.traverse(t),this.boundingBox=e,e},Ta.prototype.addHeightMap=function(t,e){this.depthTexture=e.texture,this.renderer=t,this.renderTarget=e},Ta.prototype.getHeight=function(){var t=new n,e=new n,r=new Uint8Array(4);return function(n){var i=this.renderTarget;null===this.terrainBase&&(void 0===this.boundingBox&&this.computeBoundingBox(),this.terrainBase=this.boundingBox.min,this.terrainRange=this.boundingBox.getSize(),e.set(i.width,i.height,1).divide(this.terrainRange));var a=this.terrainBase;return t.copy(n).sub(a).multiply(e).round(),this.renderer.readRenderTargetPixels(i,t.x,t.y,1,1,r),Sa(r)*this.terrainRange.z+a.z}}(),Aa.prototype=Object.create(Ct.prototype),Aa.prototype.constructor=Aa,Aa.prototype.setupUVs=function(t,e,r){var n=t.xx*t.yy-t.xy*t.yx;if(0===n)return!1;for(var i,a,o,s,c=t.yy/n,l=-t.xy/n,h=-t.yx/n,u=t.xx/n,d=this.getAttribute("position").array,p=e.naturalWidth,f=e.naturalHeight,m=-(c*t.xOrigin+l*t.yOrigin),g=-(h*t.xOrigin+u*t.yOrigin),v=[],y=0;y<d.length;y+=3)o=((i=d[y]+r.x)*c+(a=d[y+1]+r.y)*l+m)/p,s=(i*h+a*u+g)/f,v.push(o,s);void 0!==this.getAttribute("uv")&&console.alert("replacing attribute uv"),this.addAttribute("uv",new Tt(v,2))};var mu={onBeforeRender:function(t){var e=t.state.buffers.stencil,r=t.context;e.setTest(!0),e.setOp(r.KEEP,r.KEEP,r.KEEP),e.setFunc(r.EQUAL,0,65535)},onAfterRender:function(t){t.state.buffers.stencil.setTest(!1)}};La.prototype=Object.create(Ta.prototype),La.prototype.constructor=La,La.prototype.isTiled=!1,La.prototype.isLoaded=function(){return!0},La.prototype.setOverlay=function(t,e){function r(){var t=i.bitmap;i.tile.geometry.setupUVs(t,n.image,i.offsets),i.overlayMaterial=new Cr({map:n,transparent:!0,opacity:i.opacity}),t.data=null,i.setMaterial(i.overlayMaterial),e()}if(null!==this.overlayMaterial)return this.setMaterial(this.overlayMaterial),void e();var n=(new zr).load(this.bitmap.image,r),i=this},La.prototype.removed=function(){var t=this.overlayMaterial;null!==t&&(t.map.dispose(),t.dispose()),this.commonRemoved()},La.prototype.setMaterial=function(t){this.tile.material=t},La.prototype.setOpacity=function(t){var e=this.tile.material;e.opacity=t,e.needsUpdate=!0,this.opacity=t},Ca.workers={},Ca.prototype.constructor=Ca,Ca.prototype.getWorker=function(){return 0===this.workers.length?new Worker(this.script):this.workers.pop()},Ca.prototype.putWorker=function(t){this.workers.length<4?this.workers.push(t):t.terminate()},Ca.prototype.dispose=function(){for(var t=0;t<this.workers.length;t++)this.workers[t].terminate()};var gu=new n;Ra.prototype=Object.create(gt.prototype),Ra.prototype.constructor=Ra,Ra.prototype.onRemoved=function(){function t(t){t.geometry&&t.geometry.dispose()}if(this.cutInProgress)return void(this.cutInProgress=!1);this.remove(this.stations),this.traverse(t)},Ra.prototype.loadEntrances=function(){function t(t){var e;t.type===Us&&(e=n.addMarker(t.p,t.getPath(i)),r.pointTargets.push(e))}for(var e=this.surveyTree,r=this,n=new da(this.modelLimits,4),i=e;1===i.children.length;)i=i.children[0];e.traverse(t),this.addFeature(n,Ls,"CV.Survey:entrances")},Ra.prototype.calibrateTerrain=function(t){function e(e){if(e.type===Us){var a=e.p.z-t.getHeight(e.p);r+=a,n+=a*a,i++}}var r=0,n=0,i=0;if(this.surveyTree.traverse(e),i>0){var a=Math.sqrt(n/i-Math.pow(r/i,2));t.datumShift=r/i,console.log("Adjustmenting terrain height by ",t.datumShift,a)}null===this.terrain&&(this.terrain=t)},Ra.prototype.loadCave=function(t){var e=this;!function(t){function r(t){Object.assign(t,ia.prototype)}void 0===t.forEachChild&&(r(t),t.forEachChild(r,!0)),null===e.surveyTree?e.surveyTree=t:e.surveyTree.children.push(t)}(t.surveyTree),function(t){function r(t,r){var n=i[t];if(0!==n.vertices.length){var a=e.getFeature(t,xa);a.addLegs(n.vertices,n.colors,n.runs),e.addFeature(a,t,r+":g")}}var i=[];i[Ms]={vertices:[],colors:[],runs:[]},i[Ss]={vertices:[],colors:[],runs:[]},i[Es]={vertices:[],colors:[],runs:[]};var a,o,s,c,l=t.length;if(0===l)return null;for(var h,u,d=new n,p=0;p<l;p++){var f=t[p],m=f.type,g=f.survey;if(h=d.equals(f.from)?d:new n(f.from.x,f.from.y,f.from.z),u=new n(f.to.x,f.to.y,f.to.z),d=u,a=i[m],void 0===f){console.warn("unknown segment type: ",m);break}if(g!==s||m!==o){if(void 0!==c){var v=i[o];c.end=v.vertices.length,v.runs.push(c)}(c={}).survey=g,c.start=a.vertices.length,s=g,o=m}a.vertices.push(h),a.vertices.push(u),a.colors.push(Yl.white),a.colors.push(Yl.white)}void 0===c.end&&(c.end=a.vertices.length,a.runs.push(c)),r(Ms,"CV.Survey:cave:cave"),r(Ss,"CV.Survey:surface:surface"),r(Es,"CV.Survey:cave:splay")}(t.lineSegments),this.loadStations(t.surveyTree),function(t){var r=t.length;if(0===r)return null;for(var i=e.getFeature(Os,ba),a=[],o=[],s=[],c=0,l=0,h=0;h<r;h++)!function(t){var e,r;for(e=0,r=t.vertices.length;e<r;e++){var i=t.vertices[e];o.push(new n(i.x,i.y,i.z))}for(e=0,r=t.faces.length;e<r;e++){var h=t.faces[e];a.push(h[0]+c,h[2]+c,h[1]+c)}var u=a.length;s.push({start:l,count:u-l,survey:t.survey}),l=u,c+=t.vertices.length}(t[h]);i.addWalls(o,a,s),e.addFeature(i,Os,"CV.Survey:faces:scraps")}(t.scraps),function(t){function r(t){var e=t.end,r=t.lrud,i=new n(e.x,e.y,e.z);M.subVectors(t.start,t.end).cross(zs);var a,o,s,c;return M.equals(gu)?E.equals(gu)?(a=i,o=i):(a=E.clone().setLength(r.l).add(i),o=E.clone().setLength(-r.r).add(i)):(a=M.clone().setLength(r.l).add(i),o=M.clone().setLength(-r.r).add(i)),s=new n(e.x,e.y,e.z+r.u),c=new n(e.x,e.y,e.z-r.d),E.copy(M),{l:a,r:o,u:s,d:c}}var i,a,o,s,c,l,h,u,d,p,f,m,g=e.getFeature(Is,ba),v=[],y=[],x=0,b=t.length,w=[],_=0,M=new n,E=new n,S=null;if(0!==b){for(f=0;f<b;f++){var T=t[f],A=T.length;if(!(A<2)){for(p=r(T[0]),y.push(p.l),y.push(p.r),y.push(p.u),y.push(p.d),m=0;m<A;m++){var L=T[m].survey;p=r(T[m]),L!==i&&(i=L,null!==S&&(v.push(u,h,d),v.push(u,d,l),_=v.length,S.count=_-S.start,w.push(S),S=null)),y.push(p.l),y.push(p.r),y.push(p.u),y.push(p.d),a=x++,o=x++,s=x++,c=x++,l=x++,h=x++,u=x++,d=x++,v.push(s,o,h),v.push(s,h,u),v.push(s,u,l),v.push(s,l,a),v.push(c,h,o),v.push(c,d,h),v.push(c,l,d),v.push(c,a,l),x-=4,null===S&&(S={start:_,survey:L},v.push(s,o,c),v.push(s,c,a))}i=null,x+=4}}null!==S&&(v.push(u,h,d),v.push(u,d,l),S.count=v.length-S.start,w.push(S)),0!==(b=v.length)&&(g.addWalls(y,v,w),e.addFeature(g,Is,"CV.Survey:faces:walls"))}}(t.crossSections),function(t){if(!1!==t.hasTerrain){var r=new La(t.terrain,e.offsets),n=(new st).copy(r.tile.geometry.boundingBox),i=e.modelLimits;n.min.z=i.min.z,n.max.z=i.max.z,i.union(n),e.terrain=r}}(t),this.computeBoundingBoxes(t.surveyTree),this.pointTargets.push(this.stations);var r=new Ea(this.name,t.metadata);this.metadata=r,this.loadDyeTraces(),this.routes=new ga(r).mapSurvey(this.stations,this.getLegs(),this.surveyTree)},Ra.prototype.getFeature=function(t,e){var r=this.features[t];return void 0===r&&e&&(r=new e(t)),r},Ra.prototype.update=function(t,r){var n=t.layers;this.features[Ls]&&n.mask&1<<Ls&&this.getFeature(Ls).cluster(t),this.features[Ns]&&n.mask&1<<Ns&&(null===this.inverseWorld&&(this.inverseWorld=(new e).getInverse(this.matrixWorld)),this.getFeature(Ns).update(t,r,this.inverseWorld))},Ra.prototype.addFeature=function(t,e,r){t.name=r,this.features[e]=t,this.add(t)},Ra.prototype.removeFeature=function(t){this.layers.mask&=~t.layers.mask;for(var e=this.features,r=0,n=e.length;r<n;r++)e[r]===t&&delete e[r]},Ra.prototype.hasFeature=function(t){return!(void 0===this.features[t])},Ra.prototype.loadStations=function(t){function e(t){void 0!==t.p&&i.addStation(t)}var r,n,i=new fa,a=new ma;t.traverse(e);var o=this.getLegs();for(r=0;r<o.length;r++)i.updateStation(o[r]);for(i.finalise(),r=0,n=i.count;r<n;r++)a.addStation(i.getStationByIndex(r));this.addFeature(i,Rs,"CV.Stations"),this.addFeature(a,Ns,"CV.StationLabels"),this.stations=i},Ra.prototype.computeBoundingBoxes=function(t){function e(t){var e=t.parent;if(e&&void 0===e.boundingBox&&(e.boundingBox=new st),void 0!==t.p)e.boundingBox.expandByPoint(t.p);else if(e){if(0===t.children.length||void 0!==t.boundingBox&&t.boundingBox.isEmpty())return;e.boundingBox.expandByPoint(t.boundingBox.min),e.boundingBox.expandByPoint(t.boundingBox.max)}}t.traverseDepthFirst(e)},Ra.prototype.loadDyeTraces=function(){var t=this.metadata.getTraces();if(0!==t.length){for(var e=this.surveyTree,r=new Ma,n=0,i=t.length;n<i;n++){var a=t[n],o=e.getByPath(a.start),s=e.getByPath(a.end);void 0!==s&&void 0!==o&&r.addTrace(o.p,s.p)}r.finish(),this.addFeature(r,Ps,"CV.DyeTraces")}},Ra.prototype.loadFromEntrance=function(t,e){function r(t){var r=t.data;n.workerPool.putWorker(c),n.loadCave(r.survey),e()}var n=this,i=o(t.name,"3d"),s=a("surveyDirectory","");if(!t.loaded){t.loaded=!0,console.log("load: ",i);var c=this.workerPool.getWorker();c.onmessage=r,c.postMessage(s+i)}},Ra.prototype.getMetadataURL=function(){return this.metadata.getURL()},Ra.prototype.getLegs=function(){return this.getFeature(Ms).geometry.vertices},Ra.prototype.getRoutes=function(){return this.routes},Ra.prototype.setScale=function(t){this.stations.setScale(t)},Ra.prototype.getWorldPosition=function(t){return(new n).copy(t).applyMatrix4(this.matrixWorld)},Ra.prototype.getGeographicalPosition=function(t){var e=this.offsets,r=this.projection,n={x:t.x+e.x,y:t.y+e.y,z:0};return null!==r&&(n=r.forward(n)),n.z=t.z+e.z,n},Ra.prototype.selectStation=function(t){var e=this.stations,r=e.getStationByIndex(t);return e.selectStation(r),r},Ra.prototype.clearSelection=function(){this.selectedSection=0,this.selectedSectionIds.clear(),this.stations.clearSelected();var t=this.selectedBox;null!==t&&(t.visible=!1)},Ra.prototype.boxSection=function(t,e,r){return null===e?((e=new aa(t.boundingBox,r)).layers.set(As),this.add(e)):(e.visible=!0,e.update(t.boundingBox)),e},Ra.prototype.highlightSelection=function(t){var e,r=this.surveyTree,n=this.highlightBox;if(t){if(void 0===(e=r.findById(t)).p&&void 0!==e.boundingBox)this.highlightBox=this.boxSection(e,n,16776960);else if(e.p){var i=this.stationHighlight;i.position.copy(e.p),i.visible=!0}}else null!==n&&(n.visible=!1)},Ra.prototype.selectSection=function(t){var e,r=this.selectedSectionIds,n=this.surveyTree;return this.clearSelection(),t&&(void 0===(e=n.findById(t)).p&&void 0!==e.boundingBox?(this.selectedBox=this.boxSection(e,this.selectedBox,65280),n.getSubtreeIds(t,r)):void 0!==e.p&&this.stations.selectStation(e)),this.selectedSection=t,e},Ra.prototype.setFeatureBox=function(){if(null===this.featureBox){var t=new aa(this.modelLimits,16777215);t.layers.set(Ts),t.name="survey-boundingbox",this.featureBox=t,this.add(t)}else this.featureBox.update(this.modelLimits)},Ra.prototype.cutSection=function(t){function e(t){switch(t.type){case"Legs":case"Walls":t.cutRuns(r.selectedSectionIds)||n.push(t);break;case"Box3Helper":case"CV.Stations":case"CV.StationLabels":case"CV.ClusterMarker":n.push(t)}}var r=this;if(0!==this.selectedSectionIds.size){this.PointTargets=[],this.legTargets=[],this.terrain=null;var n=[];this.traverse(e);for(var i=0,a=n.length;i<a;i++){var o=n[i],s=o.parent;s&&s.remove(o),o.geometry&&o.geometry.dispose(),this.removeFeature(o)}this.surveyTree=this.surveyTree.findById(t),this.surveyTree.parent=null,this.loadStations(this.surveyTree),this.clearSelection(),this.highlightSelection(0),this.modelLimits=this.getBounds(),this.limits.copy(this.modelLimits),this.limits.min.add(this.offsets),this.limits.max.add(this.offsets),this.setFeatureBox(),this.loadEntrances(),this.cutInProgress=!0}},Ra.prototype.getBounds=function(){function t(t){if("CV.Survey"!==t.type){var e=t.geometry;e&&e.boundingBox&&(r.min(e.boundingBox.min),n.max(e.boundingBox.max))}}var e=new st,r=e.min,n=e.max;return this.traverse(t),e},Ra.prototype.setShadingMode=function(t){var e;switch(t){case ds:e=Dh.getHeightMaterial(2,this.modelLimits);break;case ms:e=Dh.getCursorMaterial(2,this.modelLimits);break;case gs:e=Dh.getSurfaceMaterial();break;case vs:break;case bs:if(!(e=Dh.getDepthMaterial(2,this.modelLimits,this.terrain)))return!1;break;case _s:if(!(e=Dh.getDepthCursorMaterial(2,this.modelLimits,this.terrain)))return!1}return!!this.setLegShading(Ms,t)&&(this.setWallShading(this.features[Is],t,e),this.setWallShading(this.features[Os],t,e),!0)},Ra.prototype.setWallShading=function(t,e,r){t&&(r?(t.setShading(this.selectedSectionIds,r),t.visible=!0):t.visible=!1)},Ra.prototype.setLegShading=function(t,e){var r=this.features[t];if(void 0!==r){switch(e){case ds:this.setLegColourByHeight(r);break;case ps:this.setLegColourByLength(r);break;case fs:this.setLegColourByInclination(r,zs);break;case ms:this.setLegColourByCursor(r);break;case _s:this.setLegColourByDepthCursor(r);break;case gs:this.setLegColourByColour(r,Yl.white);break;case vs:this.setLegColourBySurvey(r);break;case ws:this.setLegColourByPath(r);break;case ys:case xs:break;case bs:this.setLegColourByDepth(r);break;default:return console.warn("invalid leg shading mode"),!1}return!0}},Ra.prototype.setLegColourByMaterial=function(t,e){function r(t,e,r){t.colors[e]=Yl.white,t.colors[r]=Yl.white}e.needsUpdate=!0,t.setShading(this.selectedSectionIds,r,e)},Ra.prototype.setLegColourByDepth=function(t){this.setLegColourByMaterial(t,Dh.getDepthMaterial(ts,this.modelLimits,this.terrain))},Ra.prototype.setLegColourByDepthCursor=function(t){this.setLegColourByMaterial(t,Dh.getDepthCursorMaterial(ts,this.modelLimits,this.terrain))},Ra.prototype.setLegColourByHeight=function(t){this.setLegColourByMaterial(t,Dh.getHeightMaterial(ts,this.modelLimits))},Ra.prototype.setLegColourByCursor=function(t){this.setLegColourByMaterial(t,Dh.getCursorMaterial(ts,this.modelLimits))},Ra.prototype.setLegColourByColour=function(t,e){function r(t,r,n){t.colors[r]=e,t.colors[n]=e}t.setShading(this.selectedSectionIds,r,Dh.getLineMaterial())},Ra.prototype.setLegColourByLength=function(t){function e(t,e,a){var o=t.vertices[e],s=t.vertices[a],c=(Math.abs(o.distanceTo(s))-i.minLegLength)/i.legLengthRange,l=r[Math.floor((1-c)*n)];t.colors[e]=l,t.colors[a]=l}var r=Yl.getColors("gradient"),n=r.length-1,i=t.stats;t.setShading(this.selectedSectionIds,e,Dh.getLineMaterial())},Ra.prototype.setLegColourBySurvey=function(t){function e(t,e,r,n){var a=i[n];t.colors[e]=a,t.colors[r]=a}var r=this.surveyTree,n=this.selectedSection;0===n&&(n=r.id);var i=hu.getSurveyColourMap(r,n);0===this.selectedSectionIds.size&&this.surveyTree.getSubtreeIds(n,this.selectedSectionIds),t.setShading(this.selectedSectionIds,e,Dh.getLineMaterial())},Ra.prototype.setLegColourByPath=function(t){function e(t,e,s){r=n.inCurrentRoute(e)?i:n.adjacentToRoute(e)?a:o,t.colors[e]=r,t.colors[s]=r}var r,n=this.getRoutes(),i=Yl.yellow,a=Yl.red,o=Yl.white;t.setShading(this.selectedSectionIds,e,Dh.getLineMaterial())},Ra.prototype.setLegColourByInclination=function(t,e){function r(t,r,n){var s=t.vertices[r],c=t.vertices[n];o.subVectors(s,c).normalize();var l=o.dot(e),h=Math.floor(a*Math.acos(Math.abs(l))),u=i[h];t.colors[r]=u,t.colors[n]=u}var i=Yl.getColors("inclination"),a=2*(i.length-1)/Math.PI,o=new n;t.setShading(this.selectedSectionIds,r,Dh.getLineMaterial())},Pa.prototype.constructor=Pa,Pa.prototype.display=function(t,e,r,i,a){function o(){i.updateMatrixWorld(),l.copy(a),l.project(i);var e=t.clientWidth*(l.x+1)/2,r=t.clientHeight*(1-l.y)/2;e+c.clientWidth>t.clientWidth||r+c.clientHeight>t.clientHeight?s():(c.style.left=e+"px",c.style.top=r+"px")}function s(){t.removeChild(c),t.removeEventListener("mousemove",o),t.removeEventListener("mouseup",s)}var c=this.div,l=new n;c.style.left=e+"px",c.style.top=r+"px",t.appendChild(c),t.addEventListener("mouseup",s),t.addEventListener("mousemove",o)},Pa.prototype.addLine=function(t){var e=document.createElement("div");return e.textContent=t,this.div.appendChild(e),this},Ia.prototype=Object.create(Pa.prototype),Ia.prototype.constructor=Ia;var vu=new n,yu=new n,xu=new n,bu=new n,wu=new zt(vu,yu,xu),_u=new zt(vu,xu,bu);Na.liveTiles=0,Na.prototype=Object.create(Bt.prototype),Na.prototype.constructor=Na,Na.prototype.type="Tile",Na.prototype.isTile=!0,Na.prototype.createFromBufferAttributes=function(t,e,r,i){var a,o,s=this.geometry;for(a in e)o=e[a],s.addAttribute(a,new Tt(o.array,o.itemSize));s.setIndex(new Et(t,1)),s.boundingBox=new st(new n(r.min.x,r.min.y,r.min.z),new n(r.max.x,r.max.y,r.max.z)),e=s.attributes;for(var c in e)e[c].onUpload(Oa);return this.geometry.index.onUpload(Oa),this.layers.set(Cs),this.material=i,this},Na.prototype.getWorldBoundingBox=function(){var t;return null===this.worldBoundingBox&&(this.updateMatrixWorld(),(t=this.getBoundingBox().clone()).applyMatrix4(this.matrixWorld),this.worldBoundingBox=t),this.worldBoundingBox},Na.prototype.getBoundingBox=function(){var t;if(null===this.boundingBox){(t=this.geometry.boundingBox.clone()).min.x+=5,t.min.y+=5,t.max.x-=5,t.max.y-=5,this.boundingBox=t}return this.boundingBox},Na.prototype.empty=function(){this.isMesh=!1,this.boundingBox||(console.warn("FIXUP :",this.x,this.y),this.getWorldBoundingBox()),this.geometry&&(this.geometry.dispose(),this.geometry=new Ct),--Na.liveTiles},Na.prototype.evict=function(){this.evictionCount++,this.evicted=!0,this.replaced=!1,this.empty()},Na.prototype.setReplaced=function(){this.evicted=!1,this.replaced=!0,this.empty()},Na.prototype.setPending=function(t){t&&null===this.parent&&t.add(this),this.parent.childrenLoading++,this.isMesh=!1,this.evicted=!1},Na.prototype.setFailed=function(){var t=this.parent;t.childErrors++,t.childrenLoading--,t.canZoom=!1,t.remove(this)},Na.prototype.setLoaded=function(t,e,r){function n(t){t.isMesh=!0,Na.liveTiles++,0==--a&&r()}var i=this.parent,a=0;if(0==--i.childrenLoading){if(0===i.childErrors){i.isTile&&i.setReplaced();for(var o=i.children,s=0,c=o.length;s<c;s++){var l=o[s];l.replaced||l.evicted||(null===t?(l.isMesh=!0,Na.liveTiles++):(l.setOverlay(t,e,n),a++))}return 0===a&&r(),!0}i.remove(this)}return!1},Na.prototype.removed=function(){this.geometry&&this.geometry.dispose()},Na.prototype.setMaterial=function(t){this.material=t},Na.prototype.setOpacity=function(t){var e=this.material;e.opacity=t,e.needsUpdate=!0},Na.prototype.setOverlay=function(t,e,r){function n(t){i.material=t,r(i)}var i=this;t.getTile(this.x,this.y,this.zoom,e,n)},Na.prototype.projectedArea=function(t){var e=this.getWorldBoundingBox(),r=e.max.z;return vu.copy(e.min).setZ(r),xu.copy(e.max),yu.set(vu.x,xu.y,r),bu.set(xu.x,vu.y,r),vu.project(t),yu.project(t),xu.project(t),bu.project(t),wu.area()+_u.area()};var Mu=6378137*Math.PI;Da.prototype=Object.create(Ta.prototype),Da.prototype.constructor=Da,Da.prototype.isTiled=!0,Da.prototype.isLoaded=function(){return this.terrainLoaded},Da.prototype.hasCoverage=function(){var t,e,r=this.limits,n=this.tileSets;if(void 0===n)return!1;for(var i=a("terrainDirectory",""),o=0,s=n.length;o<s;o++)if(t=n[o],(e=this.getCoverage(r,t.minZoom)).min_x>=t.minX&&e.max_x<=t.maxX&&e.min_y>=t.minY&&e.max_y<=t.maxY)return t.directory=i+t.subdirectory,this.tileSet=t,!0;return!1},Da.prototype.getCoverage=function(t,e){var r={zoom:e},n=Mu,i=-Mu,a=Math.pow(2,e-1)/Mu;return r.min_x=Math.floor((t.min.x-i)*a),r.max_x=Math.floor((t.max.x-i)*a),r.max_y=Math.floor((n-t.min.y)*a),r.min_y=Math.floor((n-t.max.y)*a),r.count=(r.max_x-r.min_x+1)*(r.max_y-r.min_y+1),r},Da.prototype.pickCoverage=function(t){var e,r=this.tileSet,n=r.maxZoom+1;do{--n,e=this.getCoverage(t,n)}while(e.count>4&&n>r.minZoom);return e},Da.prototype.loadTile=function(t,e,r,n,i){function a(t){var e=t.data;return c.workerPool.putWorker(b),--c.tilesLoading,c.dying?void c.progressDial.end():"ok"!==e.status||0!==y.parent.childErrors?(y.setFailed(),void(c.progressDial&&c.progressDial.end())):(c.progressDial&&c.progressDial.add(c.progressInc),y.createFromBufferAttributes(e.index,e.attributes,e.boundingBox,c.material),c.progressDial&&c.progressDial.add(c.progressInc),y.setLoaded(c.activeOverlay,c.opacity,c.onLoaded)&&c.progressDial&&c.progressDial.end(),void(c.terrainLoaded=!0))}var o=this.tileSet,s=r>o.dtmMaxZoom?Math.pow(2,o.dtmMaxZoom-r):1;if(1===s||null!==this.activeOverlay||null===this.currentZoom){console.log("load: [ ",r+"/"+t+"/"+e,"]");var c=this,l=this.limits,h=Mu/Math.pow(2,r-1),u={top:0,bottom:0,left:0,right:0},d=h*t-Mu,p=d+h,f=Mu-h*e,m=f-h,g=o.divisions*s,v=h/g;++this.tilesLoading,f>l.max.y&&(u.top=Math.floor((f-l.max.y)/v)),m<l.min.y&&(u.bottom=Math.floor((l.min.y-m)/v)),d<l.min.x&&(u.left=Math.floor((l.min.x-d)/v)),p>l.max.x&&(u.right=Math.floor((p-l.max.x)/v));var y=n||new Na(t,e,r,c.tileSet,u),x=i||this;y.setPending(x);var b=this.workerPool.getWorker();b.onmessage=a,b.postMessage({tileSet:o,divisions:g,resolution:v,x:t,y:e,z:r,clip:u,offsets:this.offsets})}},Da.prototype.resurrectTile=function(t){if(t.isMesh)return void console.warn("resurrecting the undead!");this.loadTile(t.x,t.y,t.zoom,t)},Da.prototype.tileArea=function(t,e){var r=this.pickCoverage(t),n=r.zoom;if(e&&e.zoom==n)return void console.error("ERROR - looping on tile replacement");this.currentLimits=t,null===this.initialZoom&&(this.initialZoom=n);for(var i=r.min_x;i<r.max_x+1;i++)for(var a=r.min_y;a<r.max_y+1;a++)this.loadTile(i,a,n,null,e);this.tilesLoading>0&&void 0!==this.progressDial&&(this.progressDial.start("Loading "+this.tilesLoading+" terrain tiles"),this.progressInc=100/(2*this.tilesLoading)),this.currentZoom=n},Da.prototype.setDefaultOverlay=function(t){this.defaultOverlay=t},Da.prototype.setOverlay=function(t,e){function r(e){e.isTile&&(e.setOverlay(t,i.opacity,n),i.overlaysLoading++)}function n(){0==--i.overlaysLoading&&e()}if(!(this.tilesLoading>0)){var i=this,a=this.activeOverlay;if(null!==a){if(a===t)return;a.flushCache(),a.hideAttribution()}this.activeOverlay=t,this.defaultOverlay=t,t.showAttribution(),this.traverse(r)}},Da.prototype.removed=function(){function t(t){t!==e&&t.removed(t)}if(this.dying=!0,!(this.tilesLoading>0)){var e=this;this.traverse(t),this.commonRemoved()}},Da.prototype.setMaterial=function(t){function e(e){e.isTile&&e.setMaterial(t)}this.tilesLoading>0||(this.traverse(e),this.activeOverlay=null,t.opacity=this.opacity,t.needsUpdate=!0,this.material=t)},Da.prototype.setOpacity=function(t){function e(e){e.isTile&&e.setOpacity(t)}this.shadingMode===ys?this.traverse(e):this.material&&(this.material.opacity=t,this.material.needsUpdate=!0),this.opacity=t},Da.prototype.zoomCheck=function(t){function r(e){e!==c&&e.isTile&&(l.intersectsBox(e.getWorldBoundingBox())?0===e.children.length?e.isMesh?e.canZoom&&h.push({tile:e,area:e.projectedArea(t)}):d.push(e):(e.isMesh||!e.evicted||this.parent.resurrectionPending||(e.resurrectionPending=!0,d.push(e)),e.parent.ResurrectionPending&&this.isMesh&&console.warn(" should not get here")):e.isMesh&&u.push(e))}var n,i,a,o=this.tileSet.maxZoom,s=this.initialZoom,c=this,l=new ut,h=[],u=[],d=[],p=!1;if(this.tilesLoading>0)return!0;t.updateMatrix(),t.updateMatrixWorld(),t.matrixWorldInverse.getInverse(t.matrixWorld),l.setFromMatrix((new e).multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),this.traverse(r);var f=d.length,m=h.length;if(function(){function t(t,e){return t.evictionCount/t.zoom-e.evictionCount/e.zoom}var e,r=u.length;if(0!==r)for(u.sort(t),e=0;e<r;e++){var n=u[e];Na.liveTiles/5>n.evictionCount*Math.pow(2,s-n.zoom)&&n.evict()}}(),0!==f){for(this.progressDial&&this.progressDial.start("Resurrecting tiles"),a=0;a<f;a++)this.resurrectTile(d[a]),p=!0;this.progressInc=100/(2*f)}else if(0!==m)for(n=h.reduce(function(t,e){return{area:t.area+e.area}}),a=0;a<m;a++)if(h[a].area/n.area>.3&&(i=h[a].tile).zoom<o){var g=i.getBoundingBox().clone();g.min.add(this.offsets),g.max.add(this.offsets),this.tileArea(g,i),p=!0}return p},Ua.prototype.showAttribution=function(){var t=this.attribution;void 0!==t&&this.container.appendChild(t)},Ua.prototype.hideAttribution=function(){var t=this.attribution,e=t.parentNode;null!==e&&e.removeChild(t)},Ua.prototype.getTile=function(t,e,r,n,i){function a(t){var e=new Cr({transparent:!0,opacity:n,color:16777215});e.map=t,e.needsUpdate=!0,o.materialCache[s]=e,i(e)}var o=this,s=t+":"+e+":"+r,c=this.materialCache[s];if(void 0!==c)return void i(c);var l=this.provider.getUrl(t,e,r);null!==l&&(new zr).setCrossOrigin("anonymous").load(l,a)},Ua.prototype.flushCache=function(){var t,e=this.materialCache;for(var r in e)(t=e[r]).map.dispose(),t.dispose();this.materialCache={}},Ua.prototype.constructor=Ua,za.prototype=Object.create(l.prototype),za.prototype.constructor=za;var Eu,Su,Tu,Au,Lu,Cu,Ru,Pu,Iu,Ou,Nu,Du,Uu,zu,Bu,Fu,ku=new n(-1,-1,.5),Gu=150,Vu=!1,Hu=new we,ju=new h,Wu=hs,Xu=[],Yu=null,qu={},Zu=gs,Ju={},Qu=null,Ku=0,$u=new n,td=0,ed=Object.create(l.prototype),rd=function(){var t=new n,e=new ft;return function(){Vu&&(Lu.getWorldRotation(e),t.copy(ku),Ru.position.copy(t.applyAxisAngle(zs,e.z)),Pu.update(Lu,Bu.target),Su.clear(),Su.render(Hu,Lu),Qh.renderHUD(),uo())}}();Object.assign(ed,{init:Ba,clearView:ao,loadCave:oo,getMetadata:wo,getRoutes:_o,getStats:xo,getSurveyTree:Mo,getControls:bo,getState:ed,renderView:rd,addOverlay:to}),Eo.pages=[],Eo.listeners=[],Eo.position=0,Eo.inHandler=!1,Eo.controls=[],Eo.frame=null,Eo.reset=function(){Eo.listeners=[],Eo.pages=[],Eo.position=0,Eo.inHandler=!1,Eo.controls=[],Eo.frame=null},Eo.clear=function(){function t(e){var r=e.target;r.removeEventListener("transitionend",t),null!==r&&r.parentElement.removeChild(r)}Eo.frame.addEventListener("transitionend",t),Eo.frame.classList.remove("onscreen");var e,r,n;for(e=0,r=Eo.listeners.length;e<r;e++)(n=Eo.listeners[e]).obj.removeEventListener(n.name,n.handler);Eo.listeners=[]},Eo.addListener=function(t,e,r){t.addEventListener(e,r),Eo.listeners.push({obj:t,name:e,handler:r})},Eo.handleChange=function(t){var e=t.target,r=t.name;if(!Eo.inHandle&&Eo.controls[r]){var n=Eo.controls[r];switch(n.type){case"checkbox":n.checked=e[r];break;case"select-one":case"range":n.value=e[r];break;case"download":n.href=e[r]}}},Eo.prototype.constructor=Eo,Eo.prototype.addListener=function(t,e,r){Eo.addListener(t,e,r)},Eo.prototype.tabHandleClick=function(t){var e=t.target,r=Eo.pages;e.classList.add("toptab"),e.parentElement.classList.add("onscreen");for(var n=0,i=r.length;n<i;n++){var a=r[n].tab,o=r[n].page;a===e?o.style.display="block":(a.classList.remove("toptab"),o.style.display="none")}},Eo.prototype.appendChild=function(t){this.page.appendChild(t)},Eo.prototype.addHeader=function(t){var e=document.createElement("div");return e.classList.add("header"),e.textContent=t,this.page.appendChild(e),e},Eo.prototype.addText=function(t){var e=document.createElement("p");return e.textContent=t,this.page.appendChild(e),e},Eo.prototype.addSelect=function(t,e,r,n,i){var a,o=document.createElement("div"),s=document.createElement("label"),c=document.createElement("select");if(o.classList.add("control"),e instanceof Array)for(var l=0,h=e.length;l<h;l++)(a=document.createElement("option")).value=e[l],a.text=e[l],a.text===r[n]&&(a.selected=!0),c.add(a,null);else for(var u in e)(a=document.createElement("option")).text=u,a.value=e[u],a.value==r[n]&&(a.selected=!0),c.add(a,null);return this.addListener(c,"change",function(t){Eo.inHandler=!0,r[n]=t.target.value,Eo.inHandler=!1}),s.textContent=t,Eo.controls[n]=c,o.appendChild(s),o.appendChild(c),void 0===i?this.page.appendChild(o):this.page.replaceChild(o,i),o},Eo.prototype.addCheckbox=function(t,e,r){function n(t){Eo.inHandler=!0,e[r]=t.target.checked,Eo.inHandler=!1}var i=document.createElement("label"),a=document.createElement("input");return i.textContent=t,a.type="checkbox",a.checked=e[r],this.addListener(a,"change",n),Eo.controls[r]=a,i.appendChild(a),this.page.appendChild(i),i},Eo.prototype.addRange=function(t,e,r){function n(t){Eo.inHandler=!0,e[r]=t.target.value,Eo.inHandler=!1}var i=document.createElement("div"),a=document.createElement("label"),o=document.createElement("input");return i.classList.add("control"),o.type="range",o.min=0,o.max=1,o.step=.05,o.value=e[r],this.addListener(o,"input",n),this.addListener(o,"change",n),a.textContent=t,Eo.controls[r]=o,i.appendChild(a),i.appendChild(o),this.page.appendChild(i),i},Eo.prototype.addSlide=function(t,e,r){var n=document.createElement("div");return n.classList.add("slide"),n.style.zIndex=200-e,n.addEventListener("click",r),n.appendChild(t),this.page.appendChild(n),this.slide=n,this.slideDepth=e,n},Eo.prototype.replaceSlide=function(t,e,r){function n(){o.removeEventListener("transitionend",n),s.removeChild(o)}function i(){s.removeChild(o),a.removeEventListener("transitionend",i)}var a=document.createElement("div"),o=this.slide,s=this.page;a.classList.add("slide"),a.style.zIndex=200-e,a.addEventListener("click",r),e<this.slideDepth&&a.classList.add("slide-out"),a.appendChild(t),s.appendChild(a),e>this.slideDepth?(o.addEventListener("transitionend",n),o.classList.add("slide-out"),o.clientHeight):e<this.slideDepth?(a.addEventListener("transitionend",i),a.clientHeight,a.classList.remove("slide-out")):s.removeChild(o),this.slide=a,this.slideDepth=e},Eo.prototype.addButton=function(t,e){var r=document.createElement("button");return r.type="button",r.textContent=t,this.addListener(r,"click",e),this.page.appendChild(r),r},Eo.prototype.addTextBox=function(t,e,r){function n(){return s.value="",o}var i=document.createElement("div"),a=document.createElement("label");a.textContent=t;var o,s=document.createElement("input");return s.type="text",s.placeholder=e,i.appendChild(a),i.appendChild(s),this.page.appendChild(i),this.addListener(s,"change",function(t){return o=t.target.value,!0}),r(n),i},Eo.prototype.addDownloadButton=function(t,e,r){function n(){i.href=e()}var i=document.createElement("a");return void 0===i.download?null:(this.addListener(i,"click",n),i.textContent=t,i.type="download",i.download=r,i.href="javascript:void();",i.classList.add("download"),this.page.appendChild(i),i)},So.prototype.constructor=So,So.prototype.Start=function(t){var e=this.statusText,r=this.progressBar;e.textContent=t,r.value=0,this.container.appendChild(e),this.container.appendChild(r)},So.prototype.Update=function(t){this.progressBar.value=t},So.prototype.Add=function(t){this.progressBar.value+=t},So.prototype.End=function(){var t=this.container;t.removeChild(this.statusText),t.removeChild(this.progressBar)},To.prototype.constructor=To,To.prototype.type="arraybuffer",To.prototype.isRegion="false",To.prototype.parse=function(t,e){function r(){return n()[0]}function n(){var t,e=new Uint8Array(i,0),r=[],n=[];do{10===(t=e[a++])||0===t?(n.push(String.fromCharCode.apply(null,r).trim()),r=[]):r.push(t)}while(10!=t);return n}this.metadata=e;var i=t,a=0;r();var o=r(),s=n();r();var c=void 0===s[1]?null:s[1];if(null!==c){var l=c.match(/\+init=(.*)\s/);if(l&&2===l.length)switch(l[1]){case"epsg:27700":c="+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs";break;default:c=null,console.warn("unsupported projection")}}switch(null!==c&&(console.log("Reprojecting from",c,"to",this.targetCRS),this.sourceCRS=c,this.projection=proj4(this.sourceCRS,this.targetCRS)),console.log("Survex .3d version ",o),o){case"Bv0.01":this.handleOld(i,a,1);break;case"v3":case"v4":case"v5":case"v6":case"v7":case"v8":this.handleVx(i,a,Number(o.charAt(1)));break;default:alert("unknown .3d version "+o)}return this},To.prototype.handleOld=function(t,e,r){function n(t){return console.warn("unhandled command: ",t.toString(16)),!1}function i(t){var e=t.p;void 0!==e&&(e.x-=k.x,e.y-=k.y,e.z-=k.z)}function a(){return!0}function o(){return console.log("SKIP"),!1}function s(){for(var t=[],r=L[e++];10!==r;)t.push(r),r=L[e++];92===t[0]&&t.shift(),S=String.fromCharCode.apply(null,t);var n=w.addPath(S.split("."),{p:R,type:Ds});return T.set(R.x+":"+R.y+":"+R.z,n),!0}function c(){return console.log("LABEL_V2"),!1}function l(){return console.log("LABEL_V3"),!1}function h(){return console.log("LABEL_V4"),!1}function u(){var t=I();return R=t,1===r&&2===P.getInt32(e,!0)||(E.length>1&&b.push(E),(E=[]).push({coords:t}),!0)}function d(){var t=I();return E.push({coords:t,type:Ms,survey:A}),R=t,!0}function p(){return console.log("LINE_V2"),!1}function f(){var r=new DataView(t,e),n=_.projection.forward({x:r.getInt32(0,!0)/100,y:r.getInt32(4,!0)/100}),i={x:n.x,y:n.y,z:r.getInt32(8,!0)/100};return O.x=Math.min(i.x,O.x),O.y=Math.min(i.y,O.y),O.z=Math.min(i.z,O.z),N.x=Math.max(i.x,N.x),N.y=Math.max(i.y,N.y),N.z=Math.max(i.z,N.z),e+=12,i}function m(){var r=new DataView(t,e),n={x:r.getInt32(0,!0)/100,y:r.getInt32(4,!0)/100,z:r.getInt32(8,!0)/100};return O.x=Math.min(n.x,O.x),O.y=Math.min(n.y,O.y),O.z=Math.min(n.z,O.z),N.x=Math.max(n.x,N.x),N.y=Math.max(n.y,N.y),N.z=Math.max(n.z,N.z),e+=12,n}var g,v,y,x,b=this.groups,w=this.surveyTree,_=this,M=[],E=[],S="",T=new Map,A=0,L=new Uint8Array(t,0),C=L.length,R={x:0,y:0,z:0},P=new DataView(t,0),I=null===this.projection?m:f,O={x:1/0,y:1/0,z:1/0},N={x:-1/0,y:-1/0,z:-1/0};for(g=0;g<256;g++)M[g]=n;for(M[0]=a,M[-1]=a,M[1]=o,M[2]=s,M[3]=s,M[4]=u,M[5]=d,M[6]=c,M[7]=l,g=64;g<128;g++)M[g]=h;for(g=128;g<256;g++)M[g]=p;if(1===r)for(;e<C;){var D=P.getInt32(e,!0);if(e+=4,!M[D]())break}else for(alert("Unsupported version"+r);e<C&&M[L[e]](L[e++]););b.push(E);var U,z,B,F;for(g=0,y=b.length;g<y;g++)for(v=0,x=(U=b[g]).length;v<x;v++)B=(z=U[v]).coords,void 0!==(F=T.get(B.x+":"+B.y+":"+B.z))&&(z.survey=F.parent.id);var k={x:(O.x+N.x)/2,y:(O.y+N.y)/2,z:(O.z+N.z)/2};w.traverse(i),this.offsets=k,this.limits={min:O,max:N}},To.prototype.handleVx=function(t,e,r){function n(t){return console.warn("unhandled command: ",t.toString(16)),!1}function i(t){var e=t.p;void 0!==e&&(e.x-=J.x,e.y-=J.y,e.z-=J.z)}function a(){var r=0;switch(H[e]){case 254:r=new DataView(t,e).getUint16(0,!0)+H[e],e+=2;break;case 255:r=new DataView(t,e).getUint32(0,!0),e+=4;break;default:r=H[e++]}if(0!==r){for(var n=[],i=0;i<r;i++)n.push(H[e++]);z+=String.fromCharCode.apply(null,n),X=!0}}function o(r){if(32&r)return!1;var n=H[e++],i=0,a=0;if(0!==n?(a=n>>4,i=15&n):(255!==(n=H[e++])?a=n:(a=new DataView(t,e).getUint32(0,!0),e+=4),255!==(n=H[e++])?i=n:(i=new DataView(t,e).getUint32(0,!0),e+=4)),0!==i||0!==a){if(a&&(z=z.slice(0,-a)),i){for(var o=[],s=0;s<i;s++)o.push(H[e++]);z+=String.fromCharCode.apply(null,o)}X=!0}}function s(){return z&&(z=""),!0}function c(t){"."===(z=z.slice(0,-16)).charAt(z.length-1)&&(z=z.slice(0,-1));var e=z.split(".");return e.splice(-t),(z=e.join("."))&&(z+="."),X=!0,!0}function l(t){var e=t-15;return z=z.slice(0,-e),X=!0,!0}function h(){return e+=4,!0}function u(){return e+=2,!0}function d(){return e+=4,!0}function p(){return e+=8,!0}function f(){return e+=3,!0}function m(){return!0}function g(){return e+=2,!0}function v(){return e+=3,!0}function y(){return e+=4,!0}function x(){return!0}function b(t){var e=63&t;if(R(e),X&&""!==z){var r=z.split("."),n=r[0];V.add(n);for(var i=1,a=r.length;i<a;i++)n=n+"."+r[i],V.add(n);G=O.addPath(r).id,X=!1}var o=Y();return 1&e?U.push({coords:o,type:Ss,survey:G}):4&e?U.push({coords:o,type:Es,survey:G}):U.push({coords:o,type:Ms,survey:G}),W=o,!0}function w(){U.length>1&&P.push(U),U=[],F.add(W.x+":"+W.y+":"+W.z);var t=Y();return U.push({coords:t}),W=t,!0}function _(){return e+=20,!0}function M(t){var r=127&t;if(R(0),!(14&r)||32&r)return e+=12,!0;var n=Y(),i=z.split("."),a=i.slice(0,-1).join(".");if(i.length>1&&!V.has(a)){for(var o=0,s=i[o];V.has(s);)s=s+"."+i[++o];var c=i.slice(o).join(".");(i=i.slice(0,o)).push(c)}return B.set(z,n),O.addPath(i,{p:n,type:4&r?Us:Ds}),!0}function E(r){var n=1&r;R(n);var i=new DataView(t,e);return e+=8,T(n,{l:i.getInt16(0,!0)/100,r:i.getInt16(2,!0)/100,u:i.getInt16(4,!0)/100,d:i.getInt16(6,!0)/100})}function S(r){var n=1&r;R(n);var i=new DataView(t,e);return e+=16,T(n,{l:i.getInt32(0,!0)/100,r:i.getInt32(0,!0)/100,u:i.getInt32(0,!0)/100,d:i.getInt32(0,!0)/100})}function T(t,e){var r=B.get(z);if(r){var n=z.split(".");n.pop();var i=O.getIdByPath(n);k.push({start:W,end:r,lrud:e,survey:i}),W=r;var a=!1;return t?a=!0:F.has([r.x,r.y,r.z].toString())&&(a=!0),a&&(k.length>0&&I.push(k),W={x:0,y:0,z:0},k=[]),!0}}function A(){var r=new DataView(t,e),n=N.projection.forward({x:r.getInt32(0,!0)/100,y:r.getInt32(4,!0)/100}),i={x:n.x,y:n.y,z:r.getInt32(8,!0)/100};return q.x=Math.min(i.x,q.x),q.y=Math.min(i.y,q.y),q.z=Math.min(i.z,q.z),Z.x=Math.max(i.x,Z.x),Z.y=Math.max(i.y,Z.y),Z.z=Math.max(i.z,Z.z),e+=12,i}function L(){var r=new DataView(t,e),n={x:r.getInt32(0,!0)/100,y:r.getInt32(4,!0)/100,z:r.getInt32(8,!0)/100};return q.x=Math.min(n.x,q.x),q.y=Math.min(n.y,q.y),q.z=Math.min(n.z,q.z),Z.x=Math.max(n.x,Z.x),Z.y=Math.max(n.y,Z.y),Z.z=Math.max(n.z,Z.z),e+=12,n}var C,R,P=this.groups,I=this.xGroups,O=this.surveyTree,N=this,D=[],U=[],z="",B=new Map,F=new Set,k=[],G=0,V=new Set,H=new Uint8Array(t,0),j=H.length,W={x:0,y:0,z:0},X=!1,Y=null===this.projection?L:A,q={x:1/0,y:1/0,z:1/0},Z={x:-1/0,y:-1/0,z:-1/0};for(C=0;C<256;C++)D[C]=n;if(8===r){for(D[0]=m,D[1]=m,D[2]=m,D[3]=m,D[4]=m,D[15]=w,D[16]=x,D[17]=g,D[18]=v,D[19]=y,D[31]=_,D[48]=E,D[49]=E,D[50]=S,D[51]=S,C=64;C<128;C++)D[C]=b;for(C=128;C<256;C++)D[C]=M;R=o,e++}else{for(C=1;C<15;C++)D[C]=c;for(D[15]=w,C=16;C<32;C++)D[C]=l;for(D[0]=s,D[32]=u,D[33]=f,D[35]=d,D[36]=x,D[34]=_,D[48]=E,D[49]=E,D[50]=S,D[51]=S,C=64;C<128;C++)D[C]=M;for(C=128;C<192;C++)D[C]=b;R=a}for(6===r&&(D[32]=h,D[33]=p);e<j&&D[H[e]](H[e++]););k.length>1&&I.push(k),P.push(U);var J={x:(q.x+Z.x)/2,y:(q.y+Z.y)/2,z:(q.z+Z.z)/2};O.traverse(i),this.offsets=J,this.limits={min:q,max:Z}},To.prototype.getLineSegments=function(){for(var t=[],e=this.groups,r=this.offsets,n=0,i=e.length;n<i;n++){for(var a=e[n],o=0,s=a.length-1;o<s;o++){var c=a[o],l=a[o+1];c.coords.x-=r.x,c.coords.y-=r.y,c.coords.z-=r.z;var h=c.coords,u=l.coords;h.x===u.x&&h.y===u.y&&h.z===u.z||t.push({from:h,to:u,type:l.type,survey:l.survey})}l.coords.x-=r.x,l.coords.y-=r.y,l.coords.z-=r.z}return t},To.prototype.getTerrainDimensions=function(){return{lines:0,samples:0}},To.prototype.getTerrainBitmap=function(){return!1},To.prototype.getSurvey=function(){return{title:this.fileName,surveyTree:this.surveyTree,sourceCRS:this.sourceCRS,targetCRS:this.targetCRS,limits:this.limits,offsets:this.offsets,lineSegments:this.getLineSegments(),crossSections:this.xGroups,scraps:[],hasTerrain:!1,metadata:this.metadata}},Ao.prototype.constructor=Ao,Ao.prototype.type="arraybuffer",Ao.prototype.isRegion="false",Ao.prototype.parse=function(t,e){function r(){var t=E.getUint32(M,!0);return M+=4,t}function n(t){M+=t}function i(){var t=r(),e=a(),n=r(),i=a();n!=t&&(w.addById(o(e),t,n)||console.warn("error constructing survey tree for",o(i)))}function a(){return{position:r(),size:r()}}function o(t){var e=new Uint8Array(_,g+t.position,t.size-1);return String.fromCharCode.apply(null,e)}function s(){var t=r(),e=r(),n=a();a();var i=r(),s=c();x[t]=s,w.addById(o(n),-t,e,{p:s,type:2&i?Us:Ds})}function c(){var t=new DataView(_,M);return M+=24,I={x:t.getFloat64(0,!0),y:t.getFloat64(8,!0),z:t.getFloat64(16,!0)},A.x=Math.min(I.x,A.x),A.y=Math.min(I.y,A.y),A.z=Math.min(I.z,A.z),L.x=Math.max(I.x,L.x),L.y=Math.max(I.y,L.y),L.z=Math.max(I.z,L.z),I}function l(){var t=r(),e=r(),n=h(),i=h(),a=r(),o=r(),s=r();E.getFloat64(M,!0);var c=Ms;M+=8,1&a&&(c=Ss),8&a&&(c=Es);var l=x[t],u=x[e];0!==o&&(t!==v&&(T=[],b.xGroups.push(T),T.push({start:u,end:l,lrud:n,survey:s})),T.push({start:l,end:u,lrud:i,survey:s})),l.x===u.x&&l.y===u.y&&l.z===u.z||(y.push({from:l,to:u,type:c,survey:s}),v=e)}function h(){var t=new DataView(_,M);return M+=32,{l:t.getFloat64(0,!0),r:t.getFloat64(8,!0),u:t.getFloat64(16,!0),d:t.getFloat64(24,!0)}}function u(){r();var t,e,n,i,o=r(),s=r(),c=a(),l=r(),h=a(),u={vertices:[],faces:[],survey:o};for(e=0;e<s;e++)n=g+c.position+24*e,i=new DataView(_,n),u.vertices.push({x:i.getFloat64(0,!0),y:i.getFloat64(8,!0),z:i.getFloat64(16,!0)});for(e=0;e<l;e++){n=g+h.position+12*e;var d=[(i=new DataView(_,n)).getUint32(0,!0),i.getUint32(4,!0),i.getUint32(8,!0)];t:if(void 0!==t){var p;for(p=0;p<3;p++)if(d[p]==t[(p+2)%3]&&d[(p+1)%3]==t[(p+3)%3]){d.reverse();break t}for(p=0;p<3;p++)if(d[p]==t[p]&&d[(p+1)%3]==t[(p+1)%3]){d.reverse();break t}for(p=0;p<3;p++)if(d[p]==t[(p+1)%3]&&d[(p+1)%3]==t[(p+2)%3]){d.reverse();break t}}u.faces.push(d),t=d}b.scraps.push(u)}function d(){r();for(var t=r(),e=r(),n=a(),i=p(),o=_.slice(M,M+n.size),s=new Float64Array(o,0),c=[],l=0;l<e;l++)for(var h=(e-1-l)*t,u=0;u<t;u++)c.push(s[h+u]);b.terrain.dtm={data:c,samples:t,lines:e,xOrigin:i[0],yOrigin:i[1],xx:i[2],xy:i[3],yx:i[4],yy:i[5]},b.hasTerrain=!0}function p(){var t=new DataView(_,M),e=[];return e[0]=t.getFloat64(0,!0),e[1]=t.getFloat64(8,!0),e[2]=t.getFloat64(16,!0),e[3]=t.getFloat64(24,!0),e[4]=t.getFloat64(32,!0),e[5]=t.getFloat64(40,!0),M+=48,e}function f(){r(),r();var t=a(),e=p();b.terrain.bitmap={image:m(t),xOrigin:e[0],yOrigin:e[1],xx:e[2],xy:e[3],yx:e[4],yy:e[5]}}function m(t){var e,r=new Uint8Array(_,g+t.position,t.size),n=r[0],i=r[1];if(255===n&&216===i?e="image/jpeg":137===n&&80===i&&(e="image/png"),!e)return"";var a=new Blob([r],{type:e});return URL.createObjectURL(a)}this.metadata=e;for(var g,v,y=[],x=[],b=this,w=this.surveyTree,_=t,M=0,E=new DataView(_,0),S=_.byteLength,T=[],A={x:1/0,y:1/0,z:1/0},L={x:-1/0,y:-1/0,z:-1/0};M<S;)!function(){var t,e=r(),a=r(),o=r(),c=r();switch(g=M+a,e){case 1:t=i;break;case 2:t=s;break;case 3:t=l;break;case 4:t=u;break;case 5:t=d;break;case 6:t=f;break;default:console.warn("unknown chunk header. type : ",e)}if(void 0!==t)for(var h=0;h<o;h++)t();n(c)}();this.lineSegments=y,_=null,this.limits={min:A,max:L};var C={x:(A.x+L.x)/2,y:(A.y+L.y)/2,z:(A.z+L.z)/2};this.offsets=C;var R,P,I,O;for(R=0;R<x.length;R++)(I=x[R]).x-=C.x,I.y-=C.y,I.z-=C.z;var N=this.scraps;for(R=0;R<N.length;R++)for(O=N[R].vertices,P=0;P<O.length;P++)(I=O[P]).x-=C.x,I.y-=C.y,I.z-=C.z;return this},Ao.prototype.getSurvey=function(){return{title:this.fileName,surveyTree:this.surveyTree,sourceCRS:null,targetCRS:null,lineSegments:this.lineSegments,crossSections:this.xGroups,scraps:this.scraps,hasTerrain:this.hasTerrain,metadata:this.metadata,terrain:this.terrain,limits:this.limits,offsets:this.offsets}},Lo.prototype.constructor=Lo,Lo.prototype.type="document",Lo.prototype.isRegion="false",Lo.prototype.mimeType="text/xml",Lo.prototype.parse=function(t,e){this.metadata=e,console.log("x",t);for(var r in t)console.log(":",r);return this},Lo.prototype.getLineSegments=function(){for(var t=[],e=this.groups,r=this.offsets,n=0,i=e.length;n<i;n++){for(var a=e[n],o=0,s=a.length-1;o<s;o++){var c=a[o],l=a[o+1];c.coords.x-=r.x,c.coords.y-=r.y,c.coords.z-=r.z;var h=c.coords,u=l.coords;h.x===u.x&&h.y===u.y&&h.z===u.z||t.push({from:h,to:u,type:l.type,survey:l.survey})}l.coords.x-=r.x,l.coords.y-=r.y,l.coords.z-=r.z}return t},Lo.prototype.getTerrainDimensions=function(){return{lines:0,samples:0}},Lo.prototype.getTerrainBitmap=function(){return!1},Lo.prototype.getSurvey=function(){return{title:this.fileName,surveyTree:this.surveyTree,sourceCRS:this.sourceCRS,targetCRS:this.targetCRS,limits:this.limits,offsets:this.offsets,lineSegments:this.getLineSegments(),crossSections:this.xGroups,scraps:[],hasTerrain:!1,metadata:this.metadata}},Co.prototype.constructor=Co,Co.prototype.type="json",Co.prototype.isRegion="true",Co.prototype.parse=function(t){this.data=t;var e,r=[],n=this.data.caves,i=this.box.min,a=this.box.max;for(e in n){var o,s=n[e].entrances;for(o=0;o<s.length;o++){var c=s[o];i.min(c.position),a.max(c.position),r.push(c)}}this.data.entrances=r,this.data.surveyTree=new ia(this.data.title)},Co.prototype.getSurvey=function(){return this.data},Co.prototype.getLimits=function(){return this.box},Ro.prototype.constructor=Ro,Ro.prototype.setHandler=function(t){var e=t.split(".").reverse();this.extention=e.shift().toLowerCase();var r;switch(this.extention){case"3d":r=new To(t);break;case"lox":r=new Ao(t);break;case"kml":r=new Lo(t);break;case"reg":case"json":r=new Co(t);break;default:return console.warn("Cave: unknown response extension [",self.extention,"]"),!1}return this.handler=r,!0},Ro.prototype.loadURL=function(t){function e(t){c.doneCount++,c.dataResponse=t,c.doneCount===c.taskCount&&c.callHandler()}function r(t){c.doneCount++,c.metadataResponse=t,c.doneCount===c.taskCount&&c.callHandler()}function n(t){c.progress&&c.progress(Math.round(100*t.loaded/t.total))}function i(e){c.doneCount++,console.warn(" error event",e),c.doneCount===c.taskCount&&c.callHandler(t)}function s(){++c.doneCount===c.taskCount&&c.callHandler(t)}var c=this,l=a("surveyDirectory","");if(!this.setHandler(t))return alert("Cave: unknown file extension ["+c.extention+"]"),!1;var h=this.handler;this.doneCount=0,this.taskCount=h.isRegion?1:2;var u=(new Ir).setPath(l);return h.isRegion||u.setResponseType("json").load(o(t,"json"),r,void 0,s),void 0!==h.mimeType&&u.setMimeType("text/xml"),u.setResponseType(h.type),u.load(t,e,n,i),!0},Ro.prototype.loadFile=function(t){function e(){n.dataResponse=o.result,n.callHandler()}function r(t){n.progress&&n.progress(Math.round(100*t.loaded/t.total))}var n=this,i=t.name;if(!this.setHandler(i))return alert("Cave: unknown file extension ["+this.extention+"]"),!1;var a=this.handler.type,o=new FileReader;switch(o.addEventListener("load",e),o.addEventListener("progress",r),a){case"arraybuffer":o.readAsArrayBuffer(t);break;default:return alert("unknown file data type"),!1}return!0},Ro.prototype.callHandler=function(){if(null===this.dataResponse)return void this.callback(!1);var t=this.dataResponse,e=this.metadataResponse;this.dataResponse=null,this.metadataResponse=null,this.callback(this.handler.parse(t,e))};var nd,id,ad,od,sd,cd,ld,hd=null,ud=1/0,dd=[],pd={},fd=!1,md=[],gd=[],vd=null,yd={"by height":ds,"by leg length":ps,"by leg inclination":fs,"height cursor":ms,fixed:gs,survey:vs,route:ws},xd={"by height":ds,"by leg inclination":fs,"height cursor":ms,fixed:gs},bd={"Relief shading":xs,"by height":ds},wd={"<select viewpoint>":is,Plan:as,"N Elevation":os,"S Elevation":ss,"E Elevation":cs,"W Elevation":ls},_d={Orthographic:es,Perspective:rs},Md={init:Po,loadCave:Xo,loadCaveList:jo};t.setEnvironment=i,t.Viewer=ed,t.UI=Md,t.CaveLoader=Ro,t.VERSION=$o,t.MATERIAL_LINE=ts,t.MATERIAL_SURFACE=2,t.CAMERA_ORTHOGRAPHIC=es,t.CAMERA_PERSPECTIVE=rs,t.CAMERA_OFFSET=ns,t.VIEW_NONE=is,t.VIEW_PLAN=as,t.VIEW_ELEVATION_N=os,t.VIEW_ELEVATION_S=ss,t.VIEW_ELEVATION_E=cs,t.VIEW_ELEVATION_W=ls,t.MOUSE_MODE_NORMAL=hs,t.MOUSE_MODE_ROUTE_EDIT=us,t.SHADING_HEIGHT=ds,t.SHADING_LENGTH=ps,t.SHADING_INCLINATION=fs,t.SHADING_CURSOR=ms,t.SHADING_SINGLE=gs,t.SHADING_SURVEY=vs,t.SHADING_OVERLAY=ys,t.SHADING_SHADED=xs,t.SHADING_DEPTH=bs,t.SHADING_PATH=ws,t.SHADING_DEPTH_CURSOR=_s,t.LEG_CAVE=Ms,t.LEG_SPLAY=Es,t.LEG_SURFACE=Ss,t.FEATURE_BOX=Ts,t.FEATURE_SELECTED_BOX=As,t.FEATURE_ENTRANCES=Ls,t.FEATURE_TERRAIN=Cs,t.FEATURE_STATIONS=Rs,t.FEATURE_TRACES=Ps,t.FACE_WALLS=Is,t.FACE_SCRAPS=Os,t.LABEL_STATION=Ns,t.NORMAL=0,t.SURFACE=1,t.SPLAY=2,t.DIVING=3,t.STATION_NORMAL=Ds,t.STATION_ENTRANCE=Us,t.upAxis=zs,Object.defineProperty(t,"__esModule",{value:!0})});
|