From 216779d0c86f168096da9b4c4f38ae402675d64a Mon Sep 17 00:00:00 2001 From: CaseyNelson314 Date: Thu, 4 Jan 2024 16:00:10 +0000 Subject: [PATCH] deploy: 9c2dc6809f7b98b3192ee0f4ad23afa027f7edc3 --- assets/{index-b0ZzByBm.js => index-Qxij50Ws.js} | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename assets/{index-b0ZzByBm.js => index-Qxij50Ws.js} (98%) diff --git a/assets/index-b0ZzByBm.js b/assets/index-Qxij50Ws.js similarity index 98% rename from assets/index-b0ZzByBm.js rename to assets/index-Qxij50Ws.js index 62f2aed..93c5d16 100644 --- a/assets/index-b0ZzByBm.js +++ b/assets/index-Qxij50Ws.js @@ -3642,4 +3642,4 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function pp(i,e,t){let n=new Go;const r=new Re,s=new Re,a=new gt,o=new hp({depthPacking:Yc}),c=new up,l={},h=t.maxTextureSize,d={[Mn]:Ct,[Ct]:Mn,[Zt]:Zt},f=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Re},radius:{value:4}},vertexShader:dp,fragmentShader:fp}),m=f.clone();m.defines.HORIZONTAL_PASS=1;const g=new yt;g.setAttribute("position",new Kt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new he(g,f),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xo;let u=this.type;this.render=function(E,w,R){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||E.length===0)return;const I=i.getRenderTarget(),x=i.getActiveCubeFace(),A=i.getActiveMipmapLevel(),k=i.state;k.setBlending(gn),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);const B=u!==rn&&this.type===rn,K=u===rn&&this.type!==rn;for(let L=0,N=E.length;Lh||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/ee.x),r.x=s.x*ee.x,V.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/ee.y),r.y=s.y*ee.y,V.mapSize.y=s.y)),V.map===null||B===!0||K===!0){const j=this.type!==rn?{minFilter:Rt,magFilter:Rt}:{};V.map!==null&&V.map.dispose(),V.map=new Fn(r.x,r.y,j),V.map.texture.name=Y.name+".shadowMap",V.camera.updateProjectionMatrix()}i.setRenderTarget(V.map),i.clear();const q=V.getViewportCount();for(let j=0;j0||w.map&&w.alphaTest>0){const k=x.uuid,B=w.uuid;let K=l[k];K===void 0&&(K={},l[k]=K);let L=K[B];L===void 0&&(L=x.clone(),K[B]=L),x=L}if(x.visible=w.visible,x.wireframe=w.wireframe,I===rn?x.side=w.shadowSide!==null?w.shadowSide:w.side:x.side=w.shadowSide!==null?w.shadowSide:d[w.side],x.alphaMap=w.alphaMap,x.alphaTest=w.alphaTest,x.map=w.map,x.clipShadows=w.clipShadows,x.clippingPlanes=w.clippingPlanes,x.clipIntersection=w.clipIntersection,x.displacementMap=w.displacementMap,x.displacementScale=w.displacementScale,x.displacementBias=w.displacementBias,x.wireframeLinewidth=w.wireframeLinewidth,x.linewidth=w.linewidth,R.isPointLight===!0&&x.isMeshDistanceMaterial===!0){const k=i.properties.get(x);k.light=R}return x}function T(E,w,R,I,x){if(E.visible===!1)return;if(E.layers.test(w.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&x===rn)&&(!E.frustumCulled||n.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,E.matrixWorld);const B=e.update(E),K=E.material;if(Array.isArray(K)){const L=B.groups;for(let N=0,Y=L.length;N=1):j.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),ee=q>=2);let re=null,ae={};const W=i.getParameter(i.SCISSOR_BOX),$=i.getParameter(i.VIEWPORT),de=new gt().fromArray(W),ve=new gt().fromArray($);function Me(D,ce,Q,X){const ie=new Uint8Array(4),Ee=i.createTexture();i.bindTexture(D,Ee),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ge=0;Ge"u"?!1:/OculusBrowser/g.test(navigator.userAgent),g=new WeakMap;let _;const p=new WeakMap;let u=!1;try{u=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(b,M){return u?new OffscreenCanvas(b,M):vr("canvas")}function v(b,M,O,te){let J=1;if((b.width>te||b.height>te)&&(J=te/Math.max(b.width,b.height)),J<1||M===!0)if(typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&b instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&b instanceof ImageBitmap){const ne=M?gr:Math.floor,_e=ne(J*b.width),oe=ne(J*b.height);_===void 0&&(_=S(_e,oe));const ue=O?S(_e,oe):_;return ue.width=_e,ue.height=oe,ue.getContext("2d").drawImage(b,0,0,_e,oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+b.width+"x"+b.height+") to ("+_e+"x"+oe+")."),ue}else return"data"in b&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+b.width+"x"+b.height+")."),b;return b}function T(b){return xs(b.width)&&xs(b.height)}function E(b){return o?!1:b.wrapS!==Wt||b.wrapT!==Wt||b.minFilter!==Rt&&b.minFilter!==Ft}function w(b,M){return b.generateMipmaps&&M&&b.minFilter!==Rt&&b.minFilter!==Ft}function R(b){i.generateMipmap(b)}function I(b,M,O,te,J=!1){if(o===!1)return M;if(b!==null){if(i[b]!==void 0)return i[b];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+b+"'")}let ne=M;if(M===i.RED&&(O===i.FLOAT&&(ne=i.R32F),O===i.HALF_FLOAT&&(ne=i.R16F),O===i.UNSIGNED_BYTE&&(ne=i.R8)),M===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(ne=i.R8UI),O===i.UNSIGNED_SHORT&&(ne=i.R16UI),O===i.UNSIGNED_INT&&(ne=i.R32UI),O===i.BYTE&&(ne=i.R8I),O===i.SHORT&&(ne=i.R16I),O===i.INT&&(ne=i.R32I)),M===i.RG&&(O===i.FLOAT&&(ne=i.RG32F),O===i.HALF_FLOAT&&(ne=i.RG16F),O===i.UNSIGNED_BYTE&&(ne=i.RG8)),M===i.RGBA){const _e=J?fr:Ye.getTransfer(te);O===i.FLOAT&&(ne=i.RGBA32F),O===i.HALF_FLOAT&&(ne=i.RGBA16F),O===i.UNSIGNED_BYTE&&(ne=_e===Ke?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT_4_4_4_4&&(ne=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(ne=i.RGB5_A1)}return(ne===i.R16F||ne===i.R32F||ne===i.RG16F||ne===i.RG32F||ne===i.RGBA16F||ne===i.RGBA32F)&&e.get("EXT_color_buffer_float"),ne}function x(b,M,O){return w(b,O)===!0||b.isFramebufferTexture&&b.minFilter!==Rt&&b.minFilter!==Ft?Math.log2(Math.max(M.width,M.height))+1:b.mipmaps!==void 0&&b.mipmaps.length>0?b.mipmaps.length:b.isCompressedTexture&&Array.isArray(b.image)?M.mipmaps.length:1}function A(b){return b===Rt||b===Gs||b===Dr?i.NEAREST:i.LINEAR}function k(b){const M=b.target;M.removeEventListener("dispose",k),K(M),M.isVideoTexture&&g.delete(M)}function B(b){const M=b.target;M.removeEventListener("dispose",B),N(M)}function K(b){const M=n.get(b);if(M.__webglInit===void 0)return;const O=b.source,te=p.get(O);if(te){const J=te[M.__cacheKey];J.usedTimes--,J.usedTimes===0&&L(b),Object.keys(te).length===0&&p.delete(O)}n.remove(b)}function L(b){const M=n.get(b);i.deleteTexture(M.__webglTexture);const O=b.source,te=p.get(O);delete te[M.__cacheKey],a.memory.textures--}function N(b){const M=b.texture,O=n.get(b),te=n.get(M);if(te.__webglTexture!==void 0&&(i.deleteTexture(te.__webglTexture),a.memory.textures--),b.depthTexture&&b.depthTexture.dispose(),b.isWebGLCubeRenderTarget)for(let J=0;J<6;J++){if(Array.isArray(O.__webglFramebuffer[J]))for(let ne=0;ne=c&&console.warn("THREE.WebGLTextures: Trying to use "+b+" texture units while this GPU supports only "+c),Y+=1,b}function q(b){const M=[];return M.push(b.wrapS),M.push(b.wrapT),M.push(b.wrapR||0),M.push(b.magFilter),M.push(b.minFilter),M.push(b.anisotropy),M.push(b.internalFormat),M.push(b.format),M.push(b.type),M.push(b.generateMipmaps),M.push(b.premultiplyAlpha),M.push(b.flipY),M.push(b.unpackAlignment),M.push(b.colorSpace),M.join()}function j(b,M){const O=n.get(b);if(b.isVideoTexture&&at(b),b.isRenderTargetTexture===!1&&b.version>0&&O.__version!==b.version){const te=b.image;if(te===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(te.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ce(O,b,M);return}}t.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+M)}function re(b,M){const O=n.get(b);if(b.version>0&&O.__version!==b.version){Ce(O,b,M);return}t.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+M)}function ae(b,M){const O=n.get(b);if(b.version>0&&O.__version!==b.version){Ce(O,b,M);return}t.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+M)}function W(b,M){const O=n.get(b);if(b.version>0&&O.__version!==b.version){Ae(O,b,M);return}t.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+M)}const $={[_s]:i.REPEAT,[Wt]:i.CLAMP_TO_EDGE,[gs]:i.MIRRORED_REPEAT},de={[Rt]:i.NEAREST,[Gs]:i.NEAREST_MIPMAP_NEAREST,[Dr]:i.NEAREST_MIPMAP_LINEAR,[Ft]:i.LINEAR,[Fc]:i.LINEAR_MIPMAP_NEAREST,[wi]:i.LINEAR_MIPMAP_LINEAR},ve={[Zc]:i.NEVER,[tl]:i.ALWAYS,[Kc]:i.LESS,[Po]:i.LEQUAL,[$c]:i.EQUAL,[el]:i.GEQUAL,[Qc]:i.GREATER,[Jc]:i.NOTEQUAL};function Me(b,M,O){if(O?(i.texParameteri(b,i.TEXTURE_WRAP_S,$[M.wrapS]),i.texParameteri(b,i.TEXTURE_WRAP_T,$[M.wrapT]),(b===i.TEXTURE_3D||b===i.TEXTURE_2D_ARRAY)&&i.texParameteri(b,i.TEXTURE_WRAP_R,$[M.wrapR]),i.texParameteri(b,i.TEXTURE_MAG_FILTER,de[M.magFilter]),i.texParameteri(b,i.TEXTURE_MIN_FILTER,de[M.minFilter])):(i.texParameteri(b,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(b,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),(b===i.TEXTURE_3D||b===i.TEXTURE_2D_ARRAY)&&i.texParameteri(b,i.TEXTURE_WRAP_R,i.CLAMP_TO_EDGE),(M.wrapS!==Wt||M.wrapT!==Wt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(b,i.TEXTURE_MAG_FILTER,A(M.magFilter)),i.texParameteri(b,i.TEXTURE_MIN_FILTER,A(M.minFilter)),M.minFilter!==Rt&&M.minFilter!==Ft&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),M.compareFunction&&(i.texParameteri(b,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(b,i.TEXTURE_COMPARE_FUNC,ve[M.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const te=e.get("EXT_texture_filter_anisotropic");if(M.magFilter===Rt||M.minFilter!==Dr&&M.minFilter!==wi||M.type===_n&&e.has("OES_texture_float_linear")===!1||o===!1&&M.type===Ri&&e.has("OES_texture_half_float_linear")===!1)return;(M.anisotropy>1||n.get(M).__currentAnisotropy)&&(i.texParameterf(b,te.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,r.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy)}}function De(b,M){let O=!1;b.__webglInit===void 0&&(b.__webglInit=!0,M.addEventListener("dispose",k));const te=M.source;let J=p.get(te);J===void 0&&(J={},p.set(te,J));const ne=q(M);if(ne!==b.__cacheKey){J[ne]===void 0&&(J[ne]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,O=!0),J[ne].usedTimes++;const _e=J[b.__cacheKey];_e!==void 0&&(J[b.__cacheKey].usedTimes--,_e.usedTimes===0&&L(M)),b.__cacheKey=ne,b.__webglTexture=J[ne].texture}return O}function Ce(b,M,O){let te=i.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(te=i.TEXTURE_2D_ARRAY),M.isData3DTexture&&(te=i.TEXTURE_3D);const J=De(b,M),ne=M.source;t.bindTexture(te,b.__webglTexture,i.TEXTURE0+O);const _e=n.get(ne);if(ne.version!==_e.__version||J===!0){t.activeTexture(i.TEXTURE0+O);const oe=Ye.getPrimaries(Ye.workingColorSpace),ue=M.colorSpace===Bt?null:Ye.getPrimaries(M.colorSpace),P=M.colorSpace===Bt||oe===ue?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,P);const se=E(M)&&T(M.image)===!1;let Z=v(M.image,se,!1,h);Z=ot(M,Z);const Te=T(Z)||o,ge=s.convert(M.format,M.colorSpace);let ye=s.convert(M.type),me=I(M.internalFormat,ge,ye,M.colorSpace,M.isVideoTexture);Me(te,M,Te);let pe;const He=M.mipmaps,D=o&&M.isVideoTexture!==!0&&me!==Ro,ce=_e.__version===void 0||J===!0,Q=x(M,Z,Te);if(M.isDepthTexture)me=i.DEPTH_COMPONENT,o?M.type===_n?me=i.DEPTH_COMPONENT32F:M.type===mn?me=i.DEPTH_COMPONENT24:M.type===Un?me=i.DEPTH24_STENCIL8:me=i.DEPTH_COMPONENT16:M.type===_n&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),M.format===In&&me===i.DEPTH_COMPONENT&&M.type!==ys&&M.type!==mn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),M.type=mn,ye=s.convert(M.type)),M.format===hi&&me===i.DEPTH_COMPONENT&&(me=i.DEPTH_STENCIL,M.type!==Un&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),M.type=Un,ye=s.convert(M.type))),ce&&(D?t.texStorage2D(i.TEXTURE_2D,1,me,Z.width,Z.height):t.texImage2D(i.TEXTURE_2D,0,me,Z.width,Z.height,0,ge,ye,null));else if(M.isDataTexture)if(He.length>0&&Te){D&&ce&&t.texStorage2D(i.TEXTURE_2D,Q,me,He[0].width,He[0].height);for(let X=0,ie=He.length;X>=1,ie>>=1}}else if(He.length>0&&Te){D&&ce&&t.texStorage2D(i.TEXTURE_2D,Q,me,He[0].width,He[0].height);for(let X=0,ie=He.length;X0&&ce++,t.texStorage2D(i.TEXTURE_CUBE_MAP,ce,pe,Z[0].width,Z[0].height));for(let X=0;X<6;X++)if(se){He?t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,0,0,Z[X].width,Z[X].height,ye,me,Z[X].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,pe,Z[X].width,Z[X].height,0,ye,me,Z[X].data);for(let ie=0;ie>ne),Z=Math.max(1,M.height>>ne);J===i.TEXTURE_3D||J===i.TEXTURE_2D_ARRAY?t.texImage3D(J,ne,ue,se,Z,M.depth,0,_e,oe,null):t.texImage2D(J,ne,ue,se,Z,0,_e,oe,null)}t.bindFramebuffer(i.FRAMEBUFFER,b),We(M)?f.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,te,J,n.get(O).__webglTexture,0,Pe(M)):(J===i.TEXTURE_2D||J>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&J<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,te,J,n.get(O).__webglTexture,ne),t.bindFramebuffer(i.FRAMEBUFFER,null)}function F(b,M,O){if(i.bindRenderbuffer(i.RENDERBUFFER,b),M.depthBuffer&&!M.stencilBuffer){let te=o===!0?i.DEPTH_COMPONENT24:i.DEPTH_COMPONENT16;if(O||We(M)){const J=M.depthTexture;J&&J.isDepthTexture&&(J.type===_n?te=i.DEPTH_COMPONENT32F:J.type===mn&&(te=i.DEPTH_COMPONENT24));const ne=Pe(M);We(M)?f.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ne,te,M.width,M.height):i.renderbufferStorageMultisample(i.RENDERBUFFER,ne,te,M.width,M.height)}else i.renderbufferStorage(i.RENDERBUFFER,te,M.width,M.height);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,b)}else if(M.depthBuffer&&M.stencilBuffer){const te=Pe(M);O&&We(M)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,te,i.DEPTH24_STENCIL8,M.width,M.height):We(M)?f.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,te,i.DEPTH24_STENCIL8,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,b)}else{const te=M.isWebGLMultipleRenderTargets===!0?M.texture:[M.texture];for(let J=0;J0){O.__webglFramebuffer[oe]=[];for(let ue=0;ue0){O.__webglFramebuffer=[];for(let oe=0;oe0&&We(b)===!1){const oe=ne?M:[M];O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let ue=0;ue0)for(let ue=0;ue0)for(let ue=0;ue0&&We(b)===!1){const M=b.isWebGLMultipleRenderTargets?b.texture:[b.texture],O=b.width,te=b.height;let J=i.COLOR_BUFFER_BIT;const ne=[],_e=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=n.get(b),ue=b.isWebGLMultipleRenderTargets===!0;if(ue)for(let P=0;P0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function at(b){const M=a.render.frame;g.get(b)!==M&&(g.set(b,M),b.update())}function ot(b,M){const O=b.colorSpace,te=b.format,J=b.type;return b.isCompressedTexture===!0||b.isVideoTexture===!0||b.format===vs||O!==on&&O!==Bt&&(Ye.getTransfer(O)===Ke?o===!1?e.has("EXT_sRGB")===!0&&te===Xt?(b.format=vs,b.minFilter=Ft,b.generateMipmaps=!1):M=Do.sRGBToLinear(M):(te!==Xt||J!==xn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",O)),M}this.allocateTextureUnit=ee,this.resetTextureUnits=V,this.setTexture2D=j,this.setTexture2DArray=re,this.setTexture3D=ae,this.setTextureCube=W,this.rebindTextures=Oe,this.setupRenderTarget=we,this.updateRenderTargetMipmap=Ze,this.updateMultisampleRenderTarget=Ne,this.setupDepthRenderbuffer=Se,this.setupFrameBufferTexture=Ie,this.useMultisampledRTT=We}function gp(i,e,t){const n=t.isWebGL2;function r(s,a=Bt){let o;const c=Ye.getTransfer(a);if(s===xn)return i.UNSIGNED_BYTE;if(s===yo)return i.UNSIGNED_SHORT_4_4_4_4;if(s===To)return i.UNSIGNED_SHORT_5_5_5_1;if(s===Oc)return i.BYTE;if(s===Bc)return i.SHORT;if(s===ys)return i.UNSIGNED_SHORT;if(s===Eo)return i.INT;if(s===mn)return i.UNSIGNED_INT;if(s===_n)return i.FLOAT;if(s===Ri)return n?i.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===zc)return i.ALPHA;if(s===Xt)return i.RGBA;if(s===Hc)return i.LUMINANCE;if(s===Gc)return i.LUMINANCE_ALPHA;if(s===In)return i.DEPTH_COMPONENT;if(s===hi)return i.DEPTH_STENCIL;if(s===vs)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===Vc)return i.RED;if(s===bo)return i.RED_INTEGER;if(s===kc)return i.RG;if(s===Ao)return i.RG_INTEGER;if(s===wo)return i.RGBA_INTEGER;if(s===Ur||s===Ir||s===Nr||s===Fr)if(c===Ke)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===Ur)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ir)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Nr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Fr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===Ur)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ir)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Nr)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Fr)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Vs||s===ks||s===Ws||s===Xs)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===Vs)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===ks)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Ws)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Xs)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Ro)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Ys||s===qs)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===Ys)return c===Ke?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===qs)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===js||s===Zs||s===Ks||s===$s||s===Qs||s===Js||s===ea||s===ta||s===na||s===ia||s===ra||s===sa||s===aa||s===oa)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===js)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Zs)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Ks)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===$s)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Qs)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Js)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===ea)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===ta)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===na)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===ia)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===ra)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===sa)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===aa)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===oa)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Or||s===ca||s===la)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===Or)return c===Ke?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===ca)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===la)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Wc||s===ha||s===ua||s===da)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(s===Or)return o.COMPRESSED_RED_RGTC1_EXT;if(s===ha)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===ua)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===da)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Un?n?i.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):i[s]!==void 0?i[s]:null}return{convert:r}}class vp extends Ot{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class ir extends st{constructor(){super(),this.isGroup=!0,this.type="Group"}}const xp={type:"move"};class as{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ir,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ir,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ir,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const _ of e.hand.values()){const p=t.getJointPose(_,n),u=this._getHandJoint(l,_);p!==null&&(u.matrix.fromArray(p.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,u.jointRadius=p.radius),u.visible=p!==null}const h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],f=h.position.distanceTo(d.position),m=.02,g=.005;l.inputState.pinching&&f>m+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=m-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(xp)))}return o!==null&&(o.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new ir;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Mp extends Bn{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",c=1,l=null,h=null,d=null,f=null,m=null,g=null;const _=t.getContextAttributes();let p=null,u=null;const S=[],v=[],T=new Re;let E=null;const w=new Ot;w.layers.enable(1),w.viewport=new gt;const R=new Ot;R.layers.enable(2),R.viewport=new gt;const I=[w,R],x=new vp;x.layers.enable(1),x.layers.enable(2);let A=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let $=S[W];return $===void 0&&($=new as,S[W]=$),$.getTargetRaySpace()},this.getControllerGrip=function(W){let $=S[W];return $===void 0&&($=new as,S[W]=$),$.getGripSpace()},this.getHand=function(W){let $=S[W];return $===void 0&&($=new as,S[W]=$),$.getHandSpace()};function B(W){const $=v.indexOf(W.inputSource);if($===-1)return;const de=S[$];de!==void 0&&(de.update(W.inputSource,W.frame,l||a),de.dispatchEvent({type:W.type,data:W.inputSource}))}function K(){r.removeEventListener("select",B),r.removeEventListener("selectstart",B),r.removeEventListener("selectend",B),r.removeEventListener("squeeze",B),r.removeEventListener("squeezestart",B),r.removeEventListener("squeezeend",B),r.removeEventListener("end",K),r.removeEventListener("inputsourceschange",L);for(let W=0;W=0&&(v[ve]=null,S[ve].disconnect(de))}for(let $=0;$=v.length){v.push(de),ve=De;break}else if(v[De]===null){v[De]=de,ve=De;break}if(ve===-1)break}const Me=S[ve];Me&&Me.connect(de)}}const N=new C,Y=new C;function V(W,$,de){N.setFromMatrixPosition($.matrixWorld),Y.setFromMatrixPosition(de.matrixWorld);const ve=N.distanceTo(Y),Me=$.projectionMatrix.elements,De=de.projectionMatrix.elements,Ce=Me[14]/(Me[10]-1),Ae=Me[14]/(Me[10]+1),Ie=(Me[9]+1)/Me[5],F=(Me[9]-1)/Me[5],ht=(Me[8]-1)/Me[0],Se=(De[8]+1)/De[0],Oe=Ce*ht,we=Ce*Se,Ze=ve/(-ht+Se),Ne=Ze*-ht;$.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(Ne),W.translateZ(Ze),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert();const Pe=Ce+Ze,We=Ae+Ze,at=Oe-Ne,ot=we+(ve-Ne),b=Ie*Ae/We*Pe,M=F*Ae/We*Pe;W.projectionMatrix.makePerspective(at,ot,b,M,Pe,We),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}function ee(W,$){$===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices($.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(r===null)return;x.near=R.near=w.near=W.near,x.far=R.far=w.far=W.far,(A!==x.near||k!==x.far)&&(r.updateRenderState({depthNear:x.near,depthFar:x.far}),A=x.near,k=x.far);const $=W.parent,de=x.cameras;ee(x,$);for(let ve=0;ve0&&(p.alphaTest.value=u.alphaTest);const S=e.get(u).envMap;if(S&&(p.envMap.value=S,p.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=u.reflectivity,p.ior.value=u.ior,p.refractionRatio.value=u.refractionRatio),u.lightMap){p.lightMap.value=u.lightMap;const v=i._useLegacyLights===!0?Math.PI:1;p.lightMapIntensity.value=u.lightMapIntensity*v,t(u.lightMap,p.lightMapTransform)}u.aoMap&&(p.aoMap.value=u.aoMap,p.aoMapIntensity.value=u.aoMapIntensity,t(u.aoMap,p.aoMapTransform))}function a(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform))}function o(p,u){p.dashSize.value=u.dashSize,p.totalSize.value=u.dashSize+u.gapSize,p.scale.value=u.scale}function c(p,u,S,v){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.size.value=u.size*S,p.scale.value=v*.5,u.map&&(p.map.value=u.map,t(u.map,p.uvTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function l(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.rotation.value=u.rotation,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function h(p,u){p.specular.value.copy(u.specular),p.shininess.value=Math.max(u.shininess,1e-4)}function d(p,u){u.gradientMap&&(p.gradientMap.value=u.gradientMap)}function f(p,u){p.metalness.value=u.metalness,u.metalnessMap&&(p.metalnessMap.value=u.metalnessMap,t(u.metalnessMap,p.metalnessMapTransform)),p.roughness.value=u.roughness,u.roughnessMap&&(p.roughnessMap.value=u.roughnessMap,t(u.roughnessMap,p.roughnessMapTransform)),e.get(u).envMap&&(p.envMapIntensity.value=u.envMapIntensity)}function m(p,u,S){p.ior.value=u.ior,u.sheen>0&&(p.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),p.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(p.sheenColorMap.value=u.sheenColorMap,t(u.sheenColorMap,p.sheenColorMapTransform)),u.sheenRoughnessMap&&(p.sheenRoughnessMap.value=u.sheenRoughnessMap,t(u.sheenRoughnessMap,p.sheenRoughnessMapTransform))),u.clearcoat>0&&(p.clearcoat.value=u.clearcoat,p.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(p.clearcoatMap.value=u.clearcoatMap,t(u.clearcoatMap,p.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,t(u.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(p.clearcoatNormalMap.value=u.clearcoatNormalMap,t(u.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===Ct&&p.clearcoatNormalScale.value.negate())),u.iridescence>0&&(p.iridescence.value=u.iridescence,p.iridescenceIOR.value=u.iridescenceIOR,p.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(p.iridescenceMap.value=u.iridescenceMap,t(u.iridescenceMap,p.iridescenceMapTransform)),u.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=u.iridescenceThicknessMap,t(u.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),u.transmission>0&&(p.transmission.value=u.transmission,p.transmissionSamplerMap.value=S.texture,p.transmissionSamplerSize.value.set(S.width,S.height),u.transmissionMap&&(p.transmissionMap.value=u.transmissionMap,t(u.transmissionMap,p.transmissionMapTransform)),p.thickness.value=u.thickness,u.thicknessMap&&(p.thicknessMap.value=u.thicknessMap,t(u.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=u.attenuationDistance,p.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(p.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(p.anisotropyMap.value=u.anisotropyMap,t(u.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=u.specularIntensity,p.specularColor.value.copy(u.specularColor),u.specularColorMap&&(p.specularColorMap.value=u.specularColorMap,t(u.specularColorMap,p.specularColorMapTransform)),u.specularIntensityMap&&(p.specularIntensityMap.value=u.specularIntensityMap,t(u.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,u){u.matcap&&(p.matcap.value=u.matcap)}function _(p,u){const S=e.get(u).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Ep(i,e,t,n){let r={},s={},a=[];const o=t.isWebGL2?i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,v){const T=v.program;n.uniformBlockBinding(S,T)}function l(S,v){let T=r[S.id];T===void 0&&(g(S),T=h(S),r[S.id]=T,S.addEventListener("dispose",p));const E=v.program;n.updateUBOMapping(S,E);const w=e.render.frame;s[S.id]!==w&&(f(S),s[S.id]=w)}function h(S){const v=d();S.__bindingPointIndex=v;const T=i.createBuffer(),E=S.__size,w=S.usage;return i.bindBuffer(i.UNIFORM_BUFFER,T),i.bufferData(i.UNIFORM_BUFFER,E,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,v,T),T}function d(){for(let S=0;S0){w=T%E;const B=E-w;w!==0&&B-A.boundary<0&&(T+=E-w,x.__offset=T)}T+=A.storage}return w=T%E,w>0&&(T+=E-w),S.__size=T,S.__cache={},this}function _(S){const v={boundary:0,storage:0};return typeof S=="number"?(v.boundary=4,v.storage=4):S.isVector2?(v.boundary=8,v.storage=8):S.isVector3||S.isColor?(v.boundary=16,v.storage=12):S.isVector4?(v.boundary=16,v.storage=16):S.isMatrix3?(v.boundary=48,v.storage=48):S.isMatrix4?(v.boundary=64,v.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),v}function p(S){const v=S.target;v.removeEventListener("dispose",p);const T=a.indexOf(v.__bindingPointIndex);a.splice(T,1),i.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function u(){for(const S in r)i.deleteBuffer(r[S]);a=[],r={},s={}}return{bind:c,update:l,dispose:u}}class Zo{constructor(e={}){const{canvas:t=gl(),context:n=null,depth:r=!0,stencil:s=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let f;n!==null?f=n.getContextAttributes().alpha:f=a;const m=new Uint32Array(4),g=new Int32Array(4);let _=null,p=null;const u=[],S=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=mt,this._useLegacyLights=!1,this.toneMapping=vn,this.toneMappingExposure=1;const v=this;let T=!1,E=0,w=0,R=null,I=-1,x=null;const A=new gt,k=new gt;let B=null;const K=new Xe(0);let L=0,N=t.width,Y=t.height,V=1,ee=null,q=null;const j=new gt(0,0,N,Y),re=new gt(0,0,N,Y);let ae=!1;const W=new Go;let $=!1,de=!1,ve=null;const Me=new rt,De=new Re,Ce=new C,Ae={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ie(){return R===null?V:1}let F=n;function ht(y,U){for(let H=0;H{function fe(){if(G.forEach(function(xe){Ne.get(xe).currentProgram.isReady()&&G.delete(xe)}),G.size===0){z(y);return}setTimeout(fe,10)}Se.get("KHR_parallel_shader_compile")!==null?fe():setTimeout(fe,10)})};let Ge=null;function ut(y){Ge&&Ge(y)}function Tt(){bt.stop()}function je(){bt.start()}const bt=new Vo;bt.setAnimationLoop(ut),typeof self<"u"&&bt.setContext(self),this.setAnimationLoop=function(y){Ge=y,pe.setAnimationLoop(y),y===null?bt.stop():bt.start()},pe.addEventListener("sessionstart",Tt),pe.addEventListener("sessionend",je),this.render=function(y,U){if(U!==void 0&&U.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),pe.enabled===!0&&pe.isPresenting===!0&&(pe.cameraAutoUpdate===!0&&pe.updateCamera(U),U=pe.getCamera()),y.isScene===!0&&y.onBeforeRender(v,y,U,R),p=ne.get(y,S.length),p.init(),S.push(p),Me.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),W.setFromProjectionMatrix(Me),de=this.localClippingEnabled,$=_e.init(this.clippingPlanes,de),_=J.get(y,u.length),_.init(),u.push(_),Yt(y,U,0,v.sortObjects),_.finish(),v.sortObjects===!0&&_.sort(ee,q),this.info.render.frame++,$===!0&&_e.beginShadows();const H=p.state.shadowsArray;if(oe.render(H,y,U),$===!0&&_e.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(_,y),p.setupLights(v._useLegacyLights),U.isArrayCamera){const G=U.cameras;for(let z=0,fe=G.length;z0?p=S[S.length-1]:p=null,u.pop(),u.length>0?_=u[u.length-1]:_=null};function Yt(y,U,H,G){if(y.visible===!1)return;if(y.layers.test(U.layers)){if(y.isGroup)H=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(U);else if(y.isLight)p.pushLight(y),y.castShadow&&p.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||W.intersectsSprite(y)){G&&Ce.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Me);const xe=M.update(y),be=y.material;be.visible&&_.push(y,xe,be,H,Ce.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||W.intersectsObject(y))){const xe=M.update(y),be=y.material;if(G&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Ce.copy(y.boundingSphere.center)):(xe.boundingSphere===null&&xe.computeBoundingSphere(),Ce.copy(xe.boundingSphere.center)),Ce.applyMatrix4(y.matrixWorld).applyMatrix4(Me)),Array.isArray(be)){const Le=xe.groups;for(let ze=0,Ue=Le.length;ze0&&Qo(z,fe,U,H),G&&we.viewport(A.copy(G)),z.length>0&&Ui(z,U,H),fe.length>0&&Ui(fe,U,H),xe.length>0&&Ui(xe,U,H),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1)}function Qo(y,U,H,G){if((H.isScene===!0?H.overrideMaterial:null)!==null)return;const fe=Oe.isWebGL2;ve===null&&(ve=new Fn(1,1,{generateMipmaps:!0,type:Se.has("EXT_color_buffer_half_float")?Ri:xn,minFilter:wi,samples:fe?4:0})),v.getDrawingBufferSize(De),fe?ve.setSize(De.x,De.y):ve.setSize(gr(De.x),gr(De.y));const xe=v.getRenderTarget();v.setRenderTarget(ve),v.getClearColor(K),L=v.getClearAlpha(),L<1&&v.setClearColor(16777215,.5),v.clear();const be=v.toneMapping;v.toneMapping=vn,Ui(y,H,G),Pe.updateMultisampleRenderTarget(ve),Pe.updateRenderTargetMipmap(ve);let Le=!1;for(let ze=0,Ue=U.length;ze0),Fe=!!H.morphAttributes.position,tt=!!H.morphAttributes.normal,Pt=!!H.morphAttributes.color;let dt=vn;G.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(dt=v.toneMapping);const $t=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Je=$t!==void 0?$t.length:0,Ve=Ne.get(G),Rr=p.state.lights;if($===!0&&(de===!0||y!==x)){const It=y===x&&G.id===I;_e.setState(G,y,It)}let et=!1;G.version===Ve.__version?(Ve.needsLights&&Ve.lightsStateVersion!==Rr.state.version||Ve.outputColorSpace!==be||z.isBatchedMesh&&Ve.batching===!1||!z.isBatchedMesh&&Ve.batching===!0||z.isInstancedMesh&&Ve.instancing===!1||!z.isInstancedMesh&&Ve.instancing===!0||z.isSkinnedMesh&&Ve.skinning===!1||!z.isSkinnedMesh&&Ve.skinning===!0||z.isInstancedMesh&&Ve.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&Ve.instancingColor===!1&&z.instanceColor!==null||Ve.envMap!==Le||G.fog===!0&&Ve.fog!==fe||Ve.numClippingPlanes!==void 0&&(Ve.numClippingPlanes!==_e.numPlanes||Ve.numIntersection!==_e.numIntersection)||Ve.vertexAlphas!==ze||Ve.vertexTangents!==Ue||Ve.morphTargets!==Fe||Ve.morphNormals!==tt||Ve.morphColors!==Pt||Ve.toneMapping!==dt||Oe.isWebGL2===!0&&Ve.morphTargetsCount!==Je)&&(et=!0):(et=!0,Ve.__version=G.version);let Sn=Ve.currentProgram;et===!0&&(Sn=Ii(G,U,z));let Us=!1,pi=!1,Cr=!1;const vt=Sn.getUniforms(),En=Ve.uniforms;if(we.useProgram(Sn.program)&&(Us=!0,pi=!0,Cr=!0),G.id!==I&&(I=G.id,pi=!0),Us||x!==y){vt.setValue(F,"projectionMatrix",y.projectionMatrix),vt.setValue(F,"viewMatrix",y.matrixWorldInverse);const It=vt.map.cameraPosition;It!==void 0&&It.setValue(F,Ce.setFromMatrixPosition(y.matrixWorld)),Oe.logarithmicDepthBuffer&&vt.setValue(F,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&vt.setValue(F,"isOrthographic",y.isOrthographicCamera===!0),x!==y&&(x=y,pi=!0,Cr=!0)}if(z.isSkinnedMesh){vt.setOptional(F,z,"bindMatrix"),vt.setOptional(F,z,"bindMatrixInverse");const It=z.skeleton;It&&(Oe.floatVertexTextures?(It.boneTexture===null&&It.computeBoneTexture(),vt.setValue(F,"boneTexture",It.boneTexture,Pe)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}z.isBatchedMesh&&(vt.setOptional(F,z,"batchingTexture"),vt.setValue(F,"batchingTexture",z._matricesTexture,Pe));const Pr=H.morphAttributes;if((Pr.position!==void 0||Pr.normal!==void 0||Pr.color!==void 0&&Oe.isWebGL2===!0)&&P.update(z,H,Sn),(pi||Ve.receiveShadow!==z.receiveShadow)&&(Ve.receiveShadow=z.receiveShadow,vt.setValue(F,"receiveShadow",z.receiveShadow)),G.isMeshGouraudMaterial&&G.envMap!==null&&(En.envMap.value=Le,En.flipEnvMap.value=Le.isCubeTexture&&Le.isRenderTargetTexture===!1?-1:1),pi&&(vt.setValue(F,"toneMappingExposure",v.toneMappingExposure),Ve.needsLights&&ec(En,Cr),fe&&G.fog===!0&&te.refreshFogUniforms(En,fe),te.refreshMaterialUniforms(En,G,V,Y,ve),lr.upload(F,Ls(Ve),En,Pe)),G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(lr.upload(F,Ls(Ve),En,Pe),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&vt.setValue(F,"center",z.center),vt.setValue(F,"modelViewMatrix",z.modelViewMatrix),vt.setValue(F,"normalMatrix",z.normalMatrix),vt.setValue(F,"modelMatrix",z.matrixWorld),G.isShaderMaterial||G.isRawShaderMaterial){const It=G.uniformsGroups;for(let Lr=0,nc=It.length;Lr0&&Pe.useMultisampledRTT(y)===!1?z=Ne.get(y).__webglMultisampledFramebuffer:Array.isArray(Ue)?z=Ue[H]:z=Ue,A.copy(y.viewport),k.copy(y.scissor),B=y.scissorTest}else A.copy(j).multiplyScalar(V).floor(),k.copy(re).multiplyScalar(V).floor(),B=ae;if(we.bindFramebuffer(F.FRAMEBUFFER,z)&&Oe.drawBuffers&&G&&we.drawBuffers(y,z),we.viewport(A),we.scissor(k),we.setScissorTest(B),fe){const Le=Ne.get(y.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+U,Le.__webglTexture,H)}else if(xe){const Le=Ne.get(y.texture),ze=U||0;F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,Le.__webglTexture,H||0,ze)}I=-1},this.readRenderTargetPixels=function(y,U,H,G,z,fe,xe){if(!(y&&y.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=Ne.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&xe!==void 0&&(be=be[xe]),be){we.bindFramebuffer(F.FRAMEBUFFER,be);try{const Le=y.texture,ze=Le.format,Ue=Le.type;if(ze!==Xt&&Te.convert(ze)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Fe=Ue===Ri&&(Se.has("EXT_color_buffer_half_float")||Oe.isWebGL2&&Se.has("EXT_color_buffer_float"));if(Ue!==xn&&Te.convert(Ue)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ue===_n&&(Oe.isWebGL2||Se.has("OES_texture_float")||Se.has("WEBGL_color_buffer_float")))&&!Fe){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=y.width-G&&H>=0&&H<=y.height-z&&F.readPixels(U,H,G,z,Te.convert(ze),Te.convert(Ue),fe)}finally{const Le=R!==null?Ne.get(R).__webglFramebuffer:null;we.bindFramebuffer(F.FRAMEBUFFER,Le)}}},this.copyFramebufferToTexture=function(y,U,H=0){const G=Math.pow(2,-H),z=Math.floor(U.image.width*G),fe=Math.floor(U.image.height*G);Pe.setTexture2D(U,0),F.copyTexSubImage2D(F.TEXTURE_2D,H,0,0,y.x,y.y,z,fe),we.unbindTexture()},this.copyTextureToTexture=function(y,U,H,G=0){const z=U.image.width,fe=U.image.height,xe=Te.convert(H.format),be=Te.convert(H.type);Pe.setTexture2D(H,0),F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,H.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,H.unpackAlignment),U.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,G,y.x,y.y,z,fe,xe,be,U.image.data):U.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,G,y.x,y.y,U.mipmaps[0].width,U.mipmaps[0].height,xe,U.mipmaps[0].data):F.texSubImage2D(F.TEXTURE_2D,G,y.x,y.y,xe,be,U.image),G===0&&H.generateMipmaps&&F.generateMipmap(F.TEXTURE_2D),we.unbindTexture()},this.copyTextureToTexture3D=function(y,U,H,G,z=0){if(v.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const fe=y.max.x-y.min.x+1,xe=y.max.y-y.min.y+1,be=y.max.z-y.min.z+1,Le=Te.convert(G.format),ze=Te.convert(G.type);let Ue;if(G.isData3DTexture)Pe.setTexture3D(G,0),Ue=F.TEXTURE_3D;else if(G.isDataArrayTexture)Pe.setTexture2DArray(G,0),Ue=F.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,G.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,G.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,G.unpackAlignment);const Fe=F.getParameter(F.UNPACK_ROW_LENGTH),tt=F.getParameter(F.UNPACK_IMAGE_HEIGHT),Pt=F.getParameter(F.UNPACK_SKIP_PIXELS),dt=F.getParameter(F.UNPACK_SKIP_ROWS),$t=F.getParameter(F.UNPACK_SKIP_IMAGES),Je=H.isCompressedTexture?H.mipmaps[0]:H.image;F.pixelStorei(F.UNPACK_ROW_LENGTH,Je.width),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,Je.height),F.pixelStorei(F.UNPACK_SKIP_PIXELS,y.min.x),F.pixelStorei(F.UNPACK_SKIP_ROWS,y.min.y),F.pixelStorei(F.UNPACK_SKIP_IMAGES,y.min.z),H.isDataTexture||H.isData3DTexture?F.texSubImage3D(Ue,z,U.x,U.y,U.z,fe,xe,be,Le,ze,Je.data):H.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),F.compressedTexSubImage3D(Ue,z,U.x,U.y,U.z,fe,xe,be,Le,Je.data)):F.texSubImage3D(Ue,z,U.x,U.y,U.z,fe,xe,be,Le,ze,Je),F.pixelStorei(F.UNPACK_ROW_LENGTH,Fe),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,tt),F.pixelStorei(F.UNPACK_SKIP_PIXELS,Pt),F.pixelStorei(F.UNPACK_SKIP_ROWS,dt),F.pixelStorei(F.UNPACK_SKIP_IMAGES,$t),z===0&&G.generateMipmaps&&F.generateMipmap(Ue),we.unbindTexture()},this.initTexture=function(y){y.isCubeTexture?Pe.setTextureCube(y,0):y.isData3DTexture?Pe.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?Pe.setTexture2DArray(y,0):Pe.setTexture2D(y,0),we.unbindTexture()},this.resetState=function(){E=0,w=0,R=null,we.reset(),ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return sn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Ts?"display-p3":"srgb",t.unpackColorSpace=Ye.workingColorSpace===Mr?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===mt?Nn:Co}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Nn?mt:on}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class yp extends Zo{}yp.prototype.isWebGL1Renderer=!0;class Tp extends st{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class br extends Di{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Xe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const to=new C,no=new C,io=new rt,os=new Er,rr=new Sr;class Vt extends st{constructor(e=new yt,t=new br){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;rc)continue;f.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(f);Ie.far||t.push({distance:I,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{const u=Math.max(0,a.start),S=Math.min(p.count,a.start+a.count);for(let v=u,T=S-1;vc)continue;f.applyMatrix4(this.matrixWorld);const w=e.ray.origin.distanceTo(f);we.far||t.push({distance:w,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s0&&v(!0),t>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new $e(d,3)),this.setAttribute("normal",new $e(f,3)),this.setAttribute("uv",new $e(m,2));function S(){const T=new C,E=new C;let w=0;const R=(t-e)/n;for(let I=0;I<=s;I++){const x=[],A=I/s,k=A*(t-e)+e;for(let B=0;B<=r;B++){const K=B/r,L=K*c+o,N=Math.sin(L),Y=Math.cos(L);E.x=k*N,E.y=-A*n+p,E.z=k*Y,d.push(E.x,E.y,E.z),T.set(N,R,Y).normalize(),f.push(T.x,T.y,T.z),m.push(K,1-A),x.push(g++)}_.push(x)}for(let I=0;I.9&&R<.1&&(v<.2&&(a[S+0]+=1),T<.2&&(a[S+2]+=1),E<.2&&(a[S+4]+=1))}}function f(S){s.push(S.x,S.y,S.z)}function m(S,v){const T=S*3;v.x=e[T+0],v.y=e[T+1],v.z=e[T+2]}function g(){const S=new C,v=new C,T=new C,E=new C,w=new Re,R=new Re,I=new Re;for(let x=0,A=0;x0)&&m.push(v,T,w),(u!==n-1||cMath.PI&&(ce-=me),Q<-Math.PI?Q+=me:Q>Math.PI&&(Q-=me),ce<=Q?o.theta=Math.max(ce,Math.min(Q,o.theta)):o.theta=o.theta>(ce+Q)/2?Math.max(ce,o.theta):Math.min(Q,o.theta)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi)),o.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(h,n.dampingFactor):n.target.add(h),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&w||n.object.isOrthographicCamera?o.radius=q(o.radius):o.radius=q(o.radius*l),P.setFromSpherical(o),P.applyQuaternion(Z),D.copy(n.target).add(P),n.object.lookAt(n.target),n.enableDamping===!0?(c.theta*=1-n.dampingFactor,c.phi*=1-n.dampingFactor,h.multiplyScalar(1-n.dampingFactor)):(c.set(0,0,0),h.set(0,0,0));let X=!1;if(n.zoomToCursor&&w){let ie=null;if(n.object.isPerspectiveCamera){const Ee=P.length();ie=q(Ee*l);const Ge=Ee-ie;n.object.position.addScaledVector(T,Ge),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const Ee=new C(E.x,E.y,0);Ee.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/l)),n.object.updateProjectionMatrix(),X=!0;const Ge=new C(E.x,E.y,0);Ge.unproject(n.object),n.object.position.sub(Ge).add(Ee),n.object.updateMatrixWorld(),ie=P.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;ie!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(ie).add(n.object.position):(sr.origin.copy(n.object.position),sr.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(sr.direction))a||8*(1-ge.dot(n.object.quaternion))>a||ye.distanceToSquared(n.target)>0?(n.dispatchEvent(co),Te.copy(n.object.position),ge.copy(n.object.quaternion),ye.copy(n.target),!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",J),n.domElement.removeEventListener("pointerdown",Ne),n.domElement.removeEventListener("pointercancel",We),n.domElement.removeEventListener("wheel",b),n.domElement.removeEventListener("pointermove",Pe),n.domElement.removeEventListener("pointerup",We),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener("keydown",M),n._domElementKeyEvents=null)};const n=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=r.NONE;const a=1e-6,o=new oo,c=new oo;let l=1;const h=new C,d=new Re,f=new Re,m=new Re,g=new Re,_=new Re,p=new Re,u=new Re,S=new Re,v=new Re,T=new C,E=new Re;let w=!1;const R=[],I={};function x(P){return P!==null?2*Math.PI/60*n.autoRotateSpeed*P:2*Math.PI/60/60*n.autoRotateSpeed}function A(){return Math.pow(.95,n.zoomSpeed)}function k(P){c.theta-=P}function B(P){c.phi-=P}const K=function(){const P=new C;return function(Z,Te){P.setFromMatrixColumn(Te,0),P.multiplyScalar(-Z),h.add(P)}}(),L=function(){const P=new C;return function(Z,Te){n.screenSpacePanning===!0?P.setFromMatrixColumn(Te,1):(P.setFromMatrixColumn(Te,0),P.crossVectors(n.object.up,P)),P.multiplyScalar(Z),h.add(P)}}(),N=function(){const P=new C;return function(Z,Te){const ge=n.domElement;if(n.object.isPerspectiveCamera){const ye=n.object.position;P.copy(ye).sub(n.target);let me=P.length();me*=Math.tan(n.object.fov/2*Math.PI/180),K(2*Z*me/ge.clientHeight,n.object.matrix),L(2*Te*me/ge.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(K(Z*(n.object.right-n.object.left)/n.object.zoom/ge.clientWidth,n.object.matrix),L(Te*(n.object.top-n.object.bottom)/n.object.zoom/ge.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function Y(P){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l/=P:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function V(P){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l*=P:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ee(P){if(!n.zoomToCursor)return;w=!0;const se=n.domElement.getBoundingClientRect(),Z=P.clientX-se.left,Te=P.clientY-se.top,ge=se.width,ye=se.height;E.x=Z/ge*2-1,E.y=-(Te/ye)*2+1,T.set(E.x,E.y,1).unproject(n.object).sub(n.object.position).normalize()}function q(P){return Math.max(n.minDistance,Math.min(n.maxDistance,P))}function j(P){d.set(P.clientX,P.clientY)}function re(P){ee(P),u.set(P.clientX,P.clientY)}function ae(P){g.set(P.clientX,P.clientY)}function W(P){f.set(P.clientX,P.clientY),m.subVectors(f,d).multiplyScalar(n.rotateSpeed);const se=n.domElement;k(2*Math.PI*m.x/se.clientHeight),B(2*Math.PI*m.y/se.clientHeight),d.copy(f),n.update()}function $(P){S.set(P.clientX,P.clientY),v.subVectors(S,u),v.y>0?Y(A()):v.y<0&&V(A()),u.copy(S),n.update()}function de(P){_.set(P.clientX,P.clientY),p.subVectors(_,g).multiplyScalar(n.panSpeed),N(p.x,p.y),g.copy(_),n.update()}function ve(P){ee(P),P.deltaY<0?V(A()):P.deltaY>0&&Y(A()),n.update()}function Me(P){let se=!1;switch(P.code){case n.keys.UP:P.ctrlKey||P.metaKey||P.shiftKey?B(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(0,n.keyPanSpeed),se=!0;break;case n.keys.BOTTOM:P.ctrlKey||P.metaKey||P.shiftKey?B(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(0,-n.keyPanSpeed),se=!0;break;case n.keys.LEFT:P.ctrlKey||P.metaKey||P.shiftKey?k(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(n.keyPanSpeed,0),se=!0;break;case n.keys.RIGHT:P.ctrlKey||P.metaKey||P.shiftKey?k(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(-n.keyPanSpeed,0),se=!0;break}se&&(P.preventDefault(),n.update())}function De(){if(R.length===1)d.set(R[0].pageX,R[0].pageY);else{const P=.5*(R[0].pageX+R[1].pageX),se=.5*(R[0].pageY+R[1].pageY);d.set(P,se)}}function Ce(){if(R.length===1)g.set(R[0].pageX,R[0].pageY);else{const P=.5*(R[0].pageX+R[1].pageX),se=.5*(R[0].pageY+R[1].pageY);g.set(P,se)}}function Ae(){const P=R[0].pageX-R[1].pageX,se=R[0].pageY-R[1].pageY,Z=Math.sqrt(P*P+se*se);u.set(0,Z)}function Ie(){n.enableZoom&&Ae(),n.enablePan&&Ce()}function F(){n.enableZoom&&Ae(),n.enableRotate&&De()}function ht(P){if(R.length==1)f.set(P.pageX,P.pageY);else{const Z=ue(P),Te=.5*(P.pageX+Z.x),ge=.5*(P.pageY+Z.y);f.set(Te,ge)}m.subVectors(f,d).multiplyScalar(n.rotateSpeed);const se=n.domElement;k(2*Math.PI*m.x/se.clientHeight),B(2*Math.PI*m.y/se.clientHeight),d.copy(f)}function Se(P){if(R.length===1)_.set(P.pageX,P.pageY);else{const se=ue(P),Z=.5*(P.pageX+se.x),Te=.5*(P.pageY+se.y);_.set(Z,Te)}p.subVectors(_,g).multiplyScalar(n.panSpeed),N(p.x,p.y),g.copy(_)}function Oe(P){const se=ue(P),Z=P.pageX-se.x,Te=P.pageY-se.y,ge=Math.sqrt(Z*Z+Te*Te);S.set(0,ge),v.set(0,Math.pow(S.y/u.y,n.zoomSpeed)),Y(v.y),u.copy(S)}function we(P){n.enableZoom&&Oe(P),n.enablePan&&Se(P)}function Ze(P){n.enableZoom&&Oe(P),n.enableRotate&&ht(P)}function Ne(P){n.enabled!==!1&&(R.length===0&&(n.domElement.setPointerCapture(P.pointerId),n.domElement.addEventListener("pointermove",Pe),n.domElement.addEventListener("pointerup",We)),ne(P),P.pointerType==="touch"?O(P):at(P))}function Pe(P){n.enabled!==!1&&(P.pointerType==="touch"?te(P):ot(P))}function We(P){_e(P),R.length===0&&(n.domElement.releasePointerCapture(P.pointerId),n.domElement.removeEventListener("pointermove",Pe),n.domElement.removeEventListener("pointerup",We)),n.dispatchEvent(lo),s=r.NONE}function at(P){let se;switch(P.button){case 0:se=n.mouseButtons.LEFT;break;case 1:se=n.mouseButtons.MIDDLE;break;case 2:se=n.mouseButtons.RIGHT;break;default:se=-1}switch(se){case zn.DOLLY:if(n.enableZoom===!1)return;re(P),s=r.DOLLY;break;case zn.ROTATE:if(P.ctrlKey||P.metaKey||P.shiftKey){if(n.enablePan===!1)return;ae(P),s=r.PAN}else{if(n.enableRotate===!1)return;j(P),s=r.ROTATE}break;case zn.PAN:if(P.ctrlKey||P.metaKey||P.shiftKey){if(n.enableRotate===!1)return;j(P),s=r.ROTATE}else{if(n.enablePan===!1)return;ae(P),s=r.PAN}break;default:s=r.NONE}s!==r.NONE&&n.dispatchEvent(cs)}function ot(P){switch(s){case r.ROTATE:if(n.enableRotate===!1)return;W(P);break;case r.DOLLY:if(n.enableZoom===!1)return;$(P);break;case r.PAN:if(n.enablePan===!1)return;de(P);break}}function b(P){n.enabled===!1||n.enableZoom===!1||s!==r.NONE||(P.preventDefault(),n.dispatchEvent(cs),ve(P),n.dispatchEvent(lo))}function M(P){n.enabled===!1||n.enablePan===!1||Me(P)}function O(P){switch(oe(P),R.length){case 1:switch(n.touches.ONE){case Hn.ROTATE:if(n.enableRotate===!1)return;De(),s=r.TOUCH_ROTATE;break;case Hn.PAN:if(n.enablePan===!1)return;Ce(),s=r.TOUCH_PAN;break;default:s=r.NONE}break;case 2:switch(n.touches.TWO){case Hn.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Ie(),s=r.TOUCH_DOLLY_PAN;break;case Hn.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;F(),s=r.TOUCH_DOLLY_ROTATE;break;default:s=r.NONE}break;default:s=r.NONE}s!==r.NONE&&n.dispatchEvent(cs)}function te(P){switch(oe(P),s){case r.TOUCH_ROTATE:if(n.enableRotate===!1)return;ht(P),n.update();break;case r.TOUCH_PAN:if(n.enablePan===!1)return;Se(P),n.update();break;case r.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;we(P),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Ze(P),n.update();break;default:s=r.NONE}}function J(P){n.enabled!==!1&&P.preventDefault()}function ne(P){R.push(P)}function _e(P){delete I[P.pointerId];for(let se=0;se.9&&(a.visible=!1)),this.axis==="Y"&&(Qe.setFromEuler(ar.set(0,0,Math.PI/2)),a.quaternion.copy(n).multiply(Qe),Math.abs(qe.copy(Cn).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Z"&&(Qe.setFromEuler(ar.set(0,Math.PI/2,0)),a.quaternion.copy(n).multiply(Qe),Math.abs(qe.copy(yi).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="XYZE"&&(Qe.setFromEuler(ar.set(0,Math.PI/2,0)),qe.copy(this.rotationAxis),a.quaternion.setFromRotationMatrix(go.lookAt(_o,qe,Cn)),a.quaternion.multiply(Qe),a.visible=this.dragging),this.axis==="E"&&(a.visible=!1)):a.name==="START"?(a.position.copy(this.worldPositionStart),a.visible=this.dragging):a.name==="END"?(a.position.copy(this.worldPosition),a.visible=this.dragging):a.name==="DELTA"?(a.position.copy(this.worldPositionStart),a.quaternion.copy(this.worldQuaternionStart),St.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),St.applyQuaternion(this.worldQuaternionStart.clone().invert()),a.scale.copy(St),a.visible=this.dragging):(a.quaternion.copy(n),this.dragging?a.position.copy(this.worldPositionStart):a.position.copy(this.worldPosition),this.axis&&(a.visible=this.axis.search(a.name)!==-1));continue}a.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(a.name==="X"&&Math.abs(qe.copy(Ei).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Y"&&Math.abs(qe.copy(Cn).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Z"&&Math.abs(qe.copy(yi).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XY"&&Math.abs(qe.copy(yi).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="YZ"&&Math.abs(qe.copy(Ei).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XZ"&&Math.abs(qe.copy(Cn).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1)):this.mode==="rotate"&&(or.copy(n),qe.copy(this.eye).applyQuaternion(Qe.copy(n).invert()),a.name.search("E")!==-1&&a.quaternion.setFromRotationMatrix(go.lookAt(this.eye,_o,Cn)),a.name==="X"&&(Qe.setFromAxisAngle(Ei,Math.atan2(-qe.y,qe.z)),Qe.multiplyQuaternions(or,Qe),a.quaternion.copy(Qe)),a.name==="Y"&&(Qe.setFromAxisAngle(Cn,Math.atan2(qe.x,qe.z)),Qe.multiplyQuaternions(or,Qe),a.quaternion.copy(Qe)),a.name==="Z"&&(Qe.setFromAxisAngle(yi,Math.atan2(qe.y,qe.x)),Qe.multiplyQuaternions(or,Qe),a.quaternion.copy(Qe))),a.visible=a.visible&&(a.name.indexOf("X")===-1||this.showX),a.visible=a.visible&&(a.name.indexOf("Y")===-1||this.showY),a.visible=a.visible&&(a.name.indexOf("Z")===-1||this.showZ),a.visible=a.visible&&(a.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),a.material._color=a.material._color||a.material.color.clone(),a.material._opacity=a.material._opacity||a.material.opacity,a.material.color.copy(a.material._color),a.material.opacity=a.material._opacity,this.enabled&&this.axis&&(a.name===this.axis||this.axis.split("").some(function(c){return a.name===c}))&&(a.material.color.setHex(16776960),a.material.opacity=1)}super.updateMatrixWorld(e)}}class Fp extends he{constructor(){super(new yr(1e5,1e5,2,2),new an({visible:!1,wireframe:!0,side:Zt,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),cr.copy(Ei).applyQuaternion(t==="local"?this.worldQuaternion:hr),xi.copy(Cn).applyQuaternion(t==="local"?this.worldQuaternion:hr),Mi.copy(yi).applyQuaternion(t==="local"?this.worldQuaternion:hr),qe.copy(xi),this.mode){case"translate":case"scale":switch(this.axis){case"X":qe.copy(this.eye).cross(cr),qt.copy(cr).cross(qe);break;case"Y":qe.copy(this.eye).cross(xi),qt.copy(xi).cross(qe);break;case"Z":qe.copy(this.eye).cross(Mi),qt.copy(Mi).cross(qe);break;case"XY":qt.copy(Mi);break;case"YZ":qt.copy(cr);break;case"XZ":qe.copy(Mi),qt.copy(xi);break;case"XYZ":case"E":qt.set(0,0,0);break}break;case"rotate":default:qt.set(0,0,0)}qt.length()===0?this.quaternion.copy(this.cameraQuaternion):(vo.lookAt(St.set(0,0,0),qt,qe),this.quaternion.setFromRotationMatrix(vo)),super.updateMatrixWorld(e)}}const Op=()=>{const i=new Tp;return i.background=new Xe(2829099),i},Bp=i=>{const e=new Zo({antialias:!1});return e.setSize(i.offsetWidth,i.offsetHeight),e.setPixelRatio(window.devicePixelRatio),i.appendChild(e.domElement),e},zp=i=>{const e=i.offsetWidth/i.offsetHeight,t=new Ot(50,e);return t.position.set(100,100,100),t},Hp=(i,e)=>{const t=new Rp(i,e);return t.autoRotate=!0,t.autoRotateSpeed=1,t.enableDamping=!0,t.dampingFactor=.2,t},Gp=(i,e,t,n)=>{const r=new Cp(i,e);return r.addEventListener("dragging-changed",s=>{t.enablePan=!s.value,t.enableRotate=!s.value}),n.add(r),r},Vp=(i,e,t)=>{new ResizeObserver(r=>{if(r.length===0)return;const{width:s,height:a}=r[0].contentRect;e.setSize(s,a),t.aspect=s/a,t.updateProjectionMatrix()}).observe(i)};class kp{constructor(e,t,n,r,s){this.setEvent=()=>{const a=o=>{this.pointer.x=o.clientX/this.dom.offsetWidth*2-1,this.pointer.y=-(o.clientY/this.dom.offsetHeight)*2+1,this.ray.setFromCamera(this.pointer,this.camera);const c=this.pointCharges.map(h=>h.mesh),l=this.ray.intersectObjects(c,!1);if(l.length>0){const h=l[0].object;h!==this.transControls.object&&this.transControls.attach(h);const d=this.pointCharges.find(f=>f.mesh===h);for(let f of this.listeners)f.type==="object-selected"&&f.listener(d);this.selected=d||null}};this.dom.addEventListener("click",a),this.dom.addEventListener("pointerdown",o=>{this.onDownPosition.x=o.clientX,this.onDownPosition.y=o.clientY}),this.dom.addEventListener("pointerup",o=>{if(this.onUpPosition.x=o.clientX,this.onUpPosition.y=o.clientY,this.onDownPosition.distanceTo(this.onUpPosition)===0){this.transControls.detach(),this.selected=null;for(let c of this.listeners)c.type==="object-unselected"&&c.listener()}})},this.getSelected=()=>this.selected,this.attach=a=>{this.transControls.attach(a.mesh),this.selected=a},this.removeSelected=()=>{this.selected!==null&&(this.transControls.detach(),this.scene.remove(this.selected.mesh),this.pointCharges.splice(this.pointCharges.indexOf(this.selected),1),this.selected=null)},this.addEventListener=(a,o)=>{this.listeners.push({type:a,listener:o}),a==="object-change"&&this.transControls.addEventListener("objectChange",c=>{o(c.target.object)})},this.transControls=Gp(t,n,r,s),this.pointCharges=e,this.camera=t,this.dom=n,this.controls=r,this.scene=s,this.ray=new Ko,this.pointer=new Re,this.listeners=[],this.selected=null,this.onDownPosition=new Re,this.onUpPosition=new Re,this.setEvent()}}var ur=(i=>(i[i.Plus=0]="Plus",i[i.Minus=1]="Minus",i[i.Neutral=2]="Neutral",i))(ur||{});class us{constructor(e,t){this.chargeType=()=>this.charge>0?0:this.charge<0?1:2,this.mesh=e,this.charge=t,this.position=e.position}}const Wp=89875517923e-1,Xp=i=>{if(i<1)return[];if(i===1)return[];let e=0;const t=[];for(let n=1;n<=i;n++){const r=-1+2*(n-1)/(i-1),s=Math.acos(r);r*r===1?e=0:e=e+3.6/Math.sqrt(i)/Math.sqrt(1-r*r);const a=Math.sin(s),o=a*Math.cos(e),c=a*Math.sin(e),l=-Math.cos(s);t.push(new C(o,l,c))}return i>20&&(t[0]=new C().add(t[1]).add(t[2]).add(t[4]).add(t[5]).add(t[6]).normalize(),t[i-1]=new C().add(t[i-2]).add(t[i-3]).add(t[i-4]).add(t[i-5]).add(t[i-6]).normalize()),t},Yp=(i,e,t=Number.EPSILON)=>Math.abs(i.x-e.x){if(Yp(i,e.position))return new C;const t=new C;t.subVectors(i,e.position);const n=t.lengthSq()**2;return t.multiplyScalar(Wp*e.charge/n),t},$o=(i,e)=>{let t=new C;for(const n of e)t.add(qp(i,n));return t},jp=(i,e,t,n)=>{const r=[i.position.clone()],s=r[0].clone().add(t);for(;;){const a=$o(s,e).normalize();i.charge<0&&a.multiplyScalar(-1);for(const o of e)if(o!==i&&s.distanceToSquared(o.position)<.5)return r;if(s.add(a),s.lengthSq()>n**2)break;r.push(s.clone())}return r};class Zp extends st{constructor(e){super(),this.pointCharges=e,this.lineMaterial=new br({color:13421823}),this.coneGeometry=new Ar(1,3,10),this.coneMaterial=new an({color:11448014,opacity:1}),this.createELines()}createELines(){for(const e of this.pointCharges){if(e.charge===0)continue;const n=Xp(25);for(const r of n){const s=jp(e,this.pointCharges,r,300),a=new yt().setFromPoints(s),o=new Vt(a,this.lineMaterial);this.add(o);const c=s.length/3;for(let l=c;l+1{const t=(r,s)=>{const a=new an({color:16777215,transparent:!0,opacity:s}),o=new he(this.coneGeometry,a);o.position.copy(r);const c=$o(r,this.pointCharges);o.quaternion.setFromUnitVectors(new C(0,1,0),c.normalize()),this.add(o)};for(let r of this.pointCharges)if(r.charge!==0)for(let s=-4;s<=4;s++)for(let a=-4;a<=4;a++)for(let o=-4;o<=4;o++){const c=s**2+a**2+o**2;if(c>4**2||s===0&&a===0&&o===0)continue;const l=Math.abs(1-c/4**2);t(new C(s*20,a*20,o*20).add(r.position),l)}},this.pointCharges=e,this.coneGeometry=new Ar(1,5,10),this.createEFVectorGeometry()}update(){this.children=[],this.createEFVectorGeometry()}}class $p extends st{constructor(e){super(),this.update=()=>{var t,n;this.children.find(r=>r===this.electric_lines_3d)!=null&&((t=this.electric_lines_3d)==null||t.update()),this.children.find(r=>r===this.electric_field_vectors_3d)!=null&&((n=this.electric_field_vectors_3d)==null||n.update())},this.enableElectricLines=t=>{t?(this.electric_lines_3d==null?this.electric_lines_3d=new Zp(this.pointCharges):this.electric_lines_3d.update(),this.add(this.electric_lines_3d)):this.remove(this.electric_lines_3d)},this.enableElectricFieldVectors=t=>{t?(this.electric_field_vectors_3d==null&&(this.electric_field_vectors_3d=new Kp(this.pointCharges)),this.electric_field_vectors_3d.update(),this.add(this.electric_field_vectors_3d)):this.remove(this.electric_field_vectors_3d)},this.pointCharges=e,this.electric_lines_3d=null,this.electric_field_vectors_3d=null}}function Qp(i,e,t){var n=t||{},r=n.noTrailing,s=r===void 0?!1:r,a=n.noLeading,o=a===void 0?!1:a,c=n.debounceMode,l=c===void 0?void 0:c,h,d=!1,f=0;function m(){h&&clearTimeout(h)}function g(p){var u=p||{},S=u.upcomingOnly,v=S===void 0?!1:S;m(),d=!v}function _(){for(var p=arguments.length,u=new Array(p),S=0;Si?o?(f=Date.now(),s||(h=setTimeout(l?w:E,i))):E():s!==!0&&(h=setTimeout(l?w:E,l===void 0?i-T:i))}return _.cancel=g,_}const Jp=()=>{const i=document.getElementById("canvas"),e=Op(),t=Bp(i),n=zp(i),r=Hp(n,i);Vp(i,t,n);const s=[],a=new an({color:16711680}),o=new an({color:255}),c=new an({color:16776960}),l=new wr(2,32,32);{{const m=new he(l,a);m.position.set(-30,20,0),e.add(m),s.push(new us(m,1))}{const m=new he(l,o);m.position.set(30,0,0),e.add(m),s.push(new us(m,-1))}}const h=new $p(s),d=new kp(s,n,i,r,e);{document.getElementById("point_charge_position_x").addEventListener("input",E=>{const w=d.getSelected();w&&(w.position.x=Number(E.target.value)),h.update()}),document.getElementById("point_charge_position_y").addEventListener("input",E=>{const w=d.getSelected();w&&(w.position.y=Number(E.target.value)),h.update()}),document.getElementById("point_charge_position_z").addEventListener("input",E=>{const w=d.getSelected();w&&(w.position.z=Number(E.target.value)),h.update()});const m=(E,w)=>{switch(E.charge=w,E.chargeType()){case ur.Plus:E.mesh.material=a;break;case ur.Minus:E.mesh.material=o;break;case ur.Neutral:E.mesh.material=c;break}},g=(E,w)=>{switch(w){case"c":return E;case"uc":return E*1e-6;case"nc":return E*1e-9;case"pc":return E*1e-12;default:throw new Error("invalid unit")}},_=E=>{const w=Math.abs(E);return w>=.001?{value:E,unit:"c"}:w>=1e-6?{value:E*1e6,unit:"uc"}:w>=1e-9?{value:E*1e9,unit:"nc"}:{value:E*1e12,unit:"pc"}},p=document.getElementById("point_charge_charge_value"),u=document.getElementById("point_charge_unit"),S=()=>{const E=d.getSelected();E&&m(E,g(Number(p.value),u.value)),h.update()};p.addEventListener("input",S),u.addEventListener("change",S),d.addEventListener("object-change",Qp(50,h.update));const v=E=>{document.getElementById("point_charge_position_x").value=E.position.x.toFixed(2),document.getElementById("point_charge_position_y").value=E.position.y.toFixed(2),document.getElementById("point_charge_position_z").value=E.position.z.toFixed(2)},T=E=>{const{value:w,unit:R}=_(E.charge);p.value=w.toFixed(2),u.value=R};d.addEventListener("object-change",v),d.addEventListener("object-selected",E=>{v(E.mesh),T(E)}),d.addEventListener("object-selected",()=>{document.getElementById("settings_point_charge").style.display="block"}),d.addEventListener("object-unselected",()=>{document.getElementById("settings_point_charge").style.display="none"}),d.attach(s[0]),v(s[0].mesh),T(s[0])}{const m=new Ap(600,100,8947848,8947848);m.material.opacity=0,e.add(m);const g=p=>{m.visible=p},_=document.getElementById("checkbox_show_grid");g(_.checked),_.addEventListener("change",p=>{g(p.target.checked)})}{const m=document.getElementById("checkbox_auto_rotate");r.autoRotate=m.checked,m.addEventListener("change",g=>{r.autoRotate=g.target.checked})}{const m=document.getElementById("dimension_toggle_switch"),g=_=>{_?e.add(h):e.remove(h)};g(m.checked),m.addEventListener("change",_=>{g(_.target.checked)})}{const m=document.getElementById("checkbox_electric_lines");h.enableElectricLines(m.checked),m.addEventListener("change",g=>{h.enableElectricLines(g.target.checked)})}{const m=document.getElementById("checkbox_electric_field_vectors");h.enableElectricFieldVectors(m.checked),m.addEventListener("change",g=>{h.enableElectricFieldVectors(g.target.checked)})}document.getElementById("button_add_point_charge").addEventListener("click",()=>{const m=Math.random()>.5?1:-1,g=m>0?a:m<0?o:c,_=new he(l,g),p=Math.floor(Math.random()*100-50),u=Math.floor(Math.random()*100-50),S=Math.floor(Math.random()*100-50);_.position.set(p,u,S),e.add(_);const v=new us(_,m);s.push(v),d.attach(v),h.update()}),document.getElementById("button_remove_point_charge").addEventListener("click",()=>{d.getSelected()&&(d.removeSelected(),h.update())}),document.getElementById("button_remove_all_point_charges").addEventListener("click",()=>{for(let m of s)e.remove(m.mesh);s.splice(0,s.length),d.removeSelected(),h.update()});const f=()=>{requestAnimationFrame(f),t.render(e,n),r.update()};f()};window.addEventListener("load",()=>{Jp()}); +}`;function pp(i,e,t){let n=new Go;const r=new Re,s=new Re,a=new gt,o=new hp({depthPacking:Yc}),c=new up,l={},h=t.maxTextureSize,d={[Mn]:Ct,[Ct]:Mn,[Zt]:Zt},f=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Re},radius:{value:4}},vertexShader:dp,fragmentShader:fp}),m=f.clone();m.defines.HORIZONTAL_PASS=1;const g=new yt;g.setAttribute("position",new Kt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new he(g,f),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xo;let u=this.type;this.render=function(E,w,R){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||E.length===0)return;const I=i.getRenderTarget(),x=i.getActiveCubeFace(),A=i.getActiveMipmapLevel(),k=i.state;k.setBlending(gn),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);const B=u!==rn&&this.type===rn,K=u===rn&&this.type!==rn;for(let L=0,N=E.length;Lh||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/ee.x),r.x=s.x*ee.x,V.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/ee.y),r.y=s.y*ee.y,V.mapSize.y=s.y)),V.map===null||B===!0||K===!0){const j=this.type!==rn?{minFilter:Rt,magFilter:Rt}:{};V.map!==null&&V.map.dispose(),V.map=new Fn(r.x,r.y,j),V.map.texture.name=Y.name+".shadowMap",V.camera.updateProjectionMatrix()}i.setRenderTarget(V.map),i.clear();const q=V.getViewportCount();for(let j=0;j0||w.map&&w.alphaTest>0){const k=x.uuid,B=w.uuid;let K=l[k];K===void 0&&(K={},l[k]=K);let L=K[B];L===void 0&&(L=x.clone(),K[B]=L),x=L}if(x.visible=w.visible,x.wireframe=w.wireframe,I===rn?x.side=w.shadowSide!==null?w.shadowSide:w.side:x.side=w.shadowSide!==null?w.shadowSide:d[w.side],x.alphaMap=w.alphaMap,x.alphaTest=w.alphaTest,x.map=w.map,x.clipShadows=w.clipShadows,x.clippingPlanes=w.clippingPlanes,x.clipIntersection=w.clipIntersection,x.displacementMap=w.displacementMap,x.displacementScale=w.displacementScale,x.displacementBias=w.displacementBias,x.wireframeLinewidth=w.wireframeLinewidth,x.linewidth=w.linewidth,R.isPointLight===!0&&x.isMeshDistanceMaterial===!0){const k=i.properties.get(x);k.light=R}return x}function T(E,w,R,I,x){if(E.visible===!1)return;if(E.layers.test(w.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&x===rn)&&(!E.frustumCulled||n.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,E.matrixWorld);const B=e.update(E),K=E.material;if(Array.isArray(K)){const L=B.groups;for(let N=0,Y=L.length;N=1):j.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),ee=q>=2);let re=null,ae={};const W=i.getParameter(i.SCISSOR_BOX),$=i.getParameter(i.VIEWPORT),de=new gt().fromArray(W),ve=new gt().fromArray($);function Me(D,ce,Q,X){const ie=new Uint8Array(4),Ee=i.createTexture();i.bindTexture(D,Ee),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ge=0;Ge"u"?!1:/OculusBrowser/g.test(navigator.userAgent),g=new WeakMap;let _;const p=new WeakMap;let u=!1;try{u=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(b,M){return u?new OffscreenCanvas(b,M):vr("canvas")}function v(b,M,O,te){let J=1;if((b.width>te||b.height>te)&&(J=te/Math.max(b.width,b.height)),J<1||M===!0)if(typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&b instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&b instanceof ImageBitmap){const ne=M?gr:Math.floor,_e=ne(J*b.width),oe=ne(J*b.height);_===void 0&&(_=S(_e,oe));const ue=O?S(_e,oe):_;return ue.width=_e,ue.height=oe,ue.getContext("2d").drawImage(b,0,0,_e,oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+b.width+"x"+b.height+") to ("+_e+"x"+oe+")."),ue}else return"data"in b&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+b.width+"x"+b.height+")."),b;return b}function T(b){return xs(b.width)&&xs(b.height)}function E(b){return o?!1:b.wrapS!==Wt||b.wrapT!==Wt||b.minFilter!==Rt&&b.minFilter!==Ft}function w(b,M){return b.generateMipmaps&&M&&b.minFilter!==Rt&&b.minFilter!==Ft}function R(b){i.generateMipmap(b)}function I(b,M,O,te,J=!1){if(o===!1)return M;if(b!==null){if(i[b]!==void 0)return i[b];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+b+"'")}let ne=M;if(M===i.RED&&(O===i.FLOAT&&(ne=i.R32F),O===i.HALF_FLOAT&&(ne=i.R16F),O===i.UNSIGNED_BYTE&&(ne=i.R8)),M===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(ne=i.R8UI),O===i.UNSIGNED_SHORT&&(ne=i.R16UI),O===i.UNSIGNED_INT&&(ne=i.R32UI),O===i.BYTE&&(ne=i.R8I),O===i.SHORT&&(ne=i.R16I),O===i.INT&&(ne=i.R32I)),M===i.RG&&(O===i.FLOAT&&(ne=i.RG32F),O===i.HALF_FLOAT&&(ne=i.RG16F),O===i.UNSIGNED_BYTE&&(ne=i.RG8)),M===i.RGBA){const _e=J?fr:Ye.getTransfer(te);O===i.FLOAT&&(ne=i.RGBA32F),O===i.HALF_FLOAT&&(ne=i.RGBA16F),O===i.UNSIGNED_BYTE&&(ne=_e===Ke?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT_4_4_4_4&&(ne=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(ne=i.RGB5_A1)}return(ne===i.R16F||ne===i.R32F||ne===i.RG16F||ne===i.RG32F||ne===i.RGBA16F||ne===i.RGBA32F)&&e.get("EXT_color_buffer_float"),ne}function x(b,M,O){return w(b,O)===!0||b.isFramebufferTexture&&b.minFilter!==Rt&&b.minFilter!==Ft?Math.log2(Math.max(M.width,M.height))+1:b.mipmaps!==void 0&&b.mipmaps.length>0?b.mipmaps.length:b.isCompressedTexture&&Array.isArray(b.image)?M.mipmaps.length:1}function A(b){return b===Rt||b===Gs||b===Dr?i.NEAREST:i.LINEAR}function k(b){const M=b.target;M.removeEventListener("dispose",k),K(M),M.isVideoTexture&&g.delete(M)}function B(b){const M=b.target;M.removeEventListener("dispose",B),N(M)}function K(b){const M=n.get(b);if(M.__webglInit===void 0)return;const O=b.source,te=p.get(O);if(te){const J=te[M.__cacheKey];J.usedTimes--,J.usedTimes===0&&L(b),Object.keys(te).length===0&&p.delete(O)}n.remove(b)}function L(b){const M=n.get(b);i.deleteTexture(M.__webglTexture);const O=b.source,te=p.get(O);delete te[M.__cacheKey],a.memory.textures--}function N(b){const M=b.texture,O=n.get(b),te=n.get(M);if(te.__webglTexture!==void 0&&(i.deleteTexture(te.__webglTexture),a.memory.textures--),b.depthTexture&&b.depthTexture.dispose(),b.isWebGLCubeRenderTarget)for(let J=0;J<6;J++){if(Array.isArray(O.__webglFramebuffer[J]))for(let ne=0;ne=c&&console.warn("THREE.WebGLTextures: Trying to use "+b+" texture units while this GPU supports only "+c),Y+=1,b}function q(b){const M=[];return M.push(b.wrapS),M.push(b.wrapT),M.push(b.wrapR||0),M.push(b.magFilter),M.push(b.minFilter),M.push(b.anisotropy),M.push(b.internalFormat),M.push(b.format),M.push(b.type),M.push(b.generateMipmaps),M.push(b.premultiplyAlpha),M.push(b.flipY),M.push(b.unpackAlignment),M.push(b.colorSpace),M.join()}function j(b,M){const O=n.get(b);if(b.isVideoTexture&&at(b),b.isRenderTargetTexture===!1&&b.version>0&&O.__version!==b.version){const te=b.image;if(te===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(te.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ce(O,b,M);return}}t.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+M)}function re(b,M){const O=n.get(b);if(b.version>0&&O.__version!==b.version){Ce(O,b,M);return}t.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+M)}function ae(b,M){const O=n.get(b);if(b.version>0&&O.__version!==b.version){Ce(O,b,M);return}t.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+M)}function W(b,M){const O=n.get(b);if(b.version>0&&O.__version!==b.version){Ae(O,b,M);return}t.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+M)}const $={[_s]:i.REPEAT,[Wt]:i.CLAMP_TO_EDGE,[gs]:i.MIRRORED_REPEAT},de={[Rt]:i.NEAREST,[Gs]:i.NEAREST_MIPMAP_NEAREST,[Dr]:i.NEAREST_MIPMAP_LINEAR,[Ft]:i.LINEAR,[Fc]:i.LINEAR_MIPMAP_NEAREST,[wi]:i.LINEAR_MIPMAP_LINEAR},ve={[Zc]:i.NEVER,[tl]:i.ALWAYS,[Kc]:i.LESS,[Po]:i.LEQUAL,[$c]:i.EQUAL,[el]:i.GEQUAL,[Qc]:i.GREATER,[Jc]:i.NOTEQUAL};function Me(b,M,O){if(O?(i.texParameteri(b,i.TEXTURE_WRAP_S,$[M.wrapS]),i.texParameteri(b,i.TEXTURE_WRAP_T,$[M.wrapT]),(b===i.TEXTURE_3D||b===i.TEXTURE_2D_ARRAY)&&i.texParameteri(b,i.TEXTURE_WRAP_R,$[M.wrapR]),i.texParameteri(b,i.TEXTURE_MAG_FILTER,de[M.magFilter]),i.texParameteri(b,i.TEXTURE_MIN_FILTER,de[M.minFilter])):(i.texParameteri(b,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(b,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),(b===i.TEXTURE_3D||b===i.TEXTURE_2D_ARRAY)&&i.texParameteri(b,i.TEXTURE_WRAP_R,i.CLAMP_TO_EDGE),(M.wrapS!==Wt||M.wrapT!==Wt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(b,i.TEXTURE_MAG_FILTER,A(M.magFilter)),i.texParameteri(b,i.TEXTURE_MIN_FILTER,A(M.minFilter)),M.minFilter!==Rt&&M.minFilter!==Ft&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),M.compareFunction&&(i.texParameteri(b,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(b,i.TEXTURE_COMPARE_FUNC,ve[M.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const te=e.get("EXT_texture_filter_anisotropic");if(M.magFilter===Rt||M.minFilter!==Dr&&M.minFilter!==wi||M.type===_n&&e.has("OES_texture_float_linear")===!1||o===!1&&M.type===Ri&&e.has("OES_texture_half_float_linear")===!1)return;(M.anisotropy>1||n.get(M).__currentAnisotropy)&&(i.texParameterf(b,te.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,r.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy)}}function De(b,M){let O=!1;b.__webglInit===void 0&&(b.__webglInit=!0,M.addEventListener("dispose",k));const te=M.source;let J=p.get(te);J===void 0&&(J={},p.set(te,J));const ne=q(M);if(ne!==b.__cacheKey){J[ne]===void 0&&(J[ne]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,O=!0),J[ne].usedTimes++;const _e=J[b.__cacheKey];_e!==void 0&&(J[b.__cacheKey].usedTimes--,_e.usedTimes===0&&L(M)),b.__cacheKey=ne,b.__webglTexture=J[ne].texture}return O}function Ce(b,M,O){let te=i.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(te=i.TEXTURE_2D_ARRAY),M.isData3DTexture&&(te=i.TEXTURE_3D);const J=De(b,M),ne=M.source;t.bindTexture(te,b.__webglTexture,i.TEXTURE0+O);const _e=n.get(ne);if(ne.version!==_e.__version||J===!0){t.activeTexture(i.TEXTURE0+O);const oe=Ye.getPrimaries(Ye.workingColorSpace),ue=M.colorSpace===Bt?null:Ye.getPrimaries(M.colorSpace),P=M.colorSpace===Bt||oe===ue?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,P);const se=E(M)&&T(M.image)===!1;let Z=v(M.image,se,!1,h);Z=ot(M,Z);const Te=T(Z)||o,ge=s.convert(M.format,M.colorSpace);let ye=s.convert(M.type),me=I(M.internalFormat,ge,ye,M.colorSpace,M.isVideoTexture);Me(te,M,Te);let pe;const He=M.mipmaps,D=o&&M.isVideoTexture!==!0&&me!==Ro,ce=_e.__version===void 0||J===!0,Q=x(M,Z,Te);if(M.isDepthTexture)me=i.DEPTH_COMPONENT,o?M.type===_n?me=i.DEPTH_COMPONENT32F:M.type===mn?me=i.DEPTH_COMPONENT24:M.type===Un?me=i.DEPTH24_STENCIL8:me=i.DEPTH_COMPONENT16:M.type===_n&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),M.format===In&&me===i.DEPTH_COMPONENT&&M.type!==ys&&M.type!==mn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),M.type=mn,ye=s.convert(M.type)),M.format===hi&&me===i.DEPTH_COMPONENT&&(me=i.DEPTH_STENCIL,M.type!==Un&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),M.type=Un,ye=s.convert(M.type))),ce&&(D?t.texStorage2D(i.TEXTURE_2D,1,me,Z.width,Z.height):t.texImage2D(i.TEXTURE_2D,0,me,Z.width,Z.height,0,ge,ye,null));else if(M.isDataTexture)if(He.length>0&&Te){D&&ce&&t.texStorage2D(i.TEXTURE_2D,Q,me,He[0].width,He[0].height);for(let X=0,ie=He.length;X>=1,ie>>=1}}else if(He.length>0&&Te){D&&ce&&t.texStorage2D(i.TEXTURE_2D,Q,me,He[0].width,He[0].height);for(let X=0,ie=He.length;X0&&ce++,t.texStorage2D(i.TEXTURE_CUBE_MAP,ce,pe,Z[0].width,Z[0].height));for(let X=0;X<6;X++)if(se){He?t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,0,0,Z[X].width,Z[X].height,ye,me,Z[X].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,pe,Z[X].width,Z[X].height,0,ye,me,Z[X].data);for(let ie=0;ie>ne),Z=Math.max(1,M.height>>ne);J===i.TEXTURE_3D||J===i.TEXTURE_2D_ARRAY?t.texImage3D(J,ne,ue,se,Z,M.depth,0,_e,oe,null):t.texImage2D(J,ne,ue,se,Z,0,_e,oe,null)}t.bindFramebuffer(i.FRAMEBUFFER,b),We(M)?f.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,te,J,n.get(O).__webglTexture,0,Pe(M)):(J===i.TEXTURE_2D||J>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&J<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,te,J,n.get(O).__webglTexture,ne),t.bindFramebuffer(i.FRAMEBUFFER,null)}function F(b,M,O){if(i.bindRenderbuffer(i.RENDERBUFFER,b),M.depthBuffer&&!M.stencilBuffer){let te=o===!0?i.DEPTH_COMPONENT24:i.DEPTH_COMPONENT16;if(O||We(M)){const J=M.depthTexture;J&&J.isDepthTexture&&(J.type===_n?te=i.DEPTH_COMPONENT32F:J.type===mn&&(te=i.DEPTH_COMPONENT24));const ne=Pe(M);We(M)?f.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ne,te,M.width,M.height):i.renderbufferStorageMultisample(i.RENDERBUFFER,ne,te,M.width,M.height)}else i.renderbufferStorage(i.RENDERBUFFER,te,M.width,M.height);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,b)}else if(M.depthBuffer&&M.stencilBuffer){const te=Pe(M);O&&We(M)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,te,i.DEPTH24_STENCIL8,M.width,M.height):We(M)?f.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,te,i.DEPTH24_STENCIL8,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,b)}else{const te=M.isWebGLMultipleRenderTargets===!0?M.texture:[M.texture];for(let J=0;J0){O.__webglFramebuffer[oe]=[];for(let ue=0;ue0){O.__webglFramebuffer=[];for(let oe=0;oe0&&We(b)===!1){const oe=ne?M:[M];O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let ue=0;ue0)for(let ue=0;ue0)for(let ue=0;ue0&&We(b)===!1){const M=b.isWebGLMultipleRenderTargets?b.texture:[b.texture],O=b.width,te=b.height;let J=i.COLOR_BUFFER_BIT;const ne=[],_e=b.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=n.get(b),ue=b.isWebGLMultipleRenderTargets===!0;if(ue)for(let P=0;P0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function at(b){const M=a.render.frame;g.get(b)!==M&&(g.set(b,M),b.update())}function ot(b,M){const O=b.colorSpace,te=b.format,J=b.type;return b.isCompressedTexture===!0||b.isVideoTexture===!0||b.format===vs||O!==on&&O!==Bt&&(Ye.getTransfer(O)===Ke?o===!1?e.has("EXT_sRGB")===!0&&te===Xt?(b.format=vs,b.minFilter=Ft,b.generateMipmaps=!1):M=Do.sRGBToLinear(M):(te!==Xt||J!==xn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",O)),M}this.allocateTextureUnit=ee,this.resetTextureUnits=V,this.setTexture2D=j,this.setTexture2DArray=re,this.setTexture3D=ae,this.setTextureCube=W,this.rebindTextures=Oe,this.setupRenderTarget=we,this.updateRenderTargetMipmap=Ze,this.updateMultisampleRenderTarget=Ne,this.setupDepthRenderbuffer=Se,this.setupFrameBufferTexture=Ie,this.useMultisampledRTT=We}function gp(i,e,t){const n=t.isWebGL2;function r(s,a=Bt){let o;const c=Ye.getTransfer(a);if(s===xn)return i.UNSIGNED_BYTE;if(s===yo)return i.UNSIGNED_SHORT_4_4_4_4;if(s===To)return i.UNSIGNED_SHORT_5_5_5_1;if(s===Oc)return i.BYTE;if(s===Bc)return i.SHORT;if(s===ys)return i.UNSIGNED_SHORT;if(s===Eo)return i.INT;if(s===mn)return i.UNSIGNED_INT;if(s===_n)return i.FLOAT;if(s===Ri)return n?i.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===zc)return i.ALPHA;if(s===Xt)return i.RGBA;if(s===Hc)return i.LUMINANCE;if(s===Gc)return i.LUMINANCE_ALPHA;if(s===In)return i.DEPTH_COMPONENT;if(s===hi)return i.DEPTH_STENCIL;if(s===vs)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===Vc)return i.RED;if(s===bo)return i.RED_INTEGER;if(s===kc)return i.RG;if(s===Ao)return i.RG_INTEGER;if(s===wo)return i.RGBA_INTEGER;if(s===Ur||s===Ir||s===Nr||s===Fr)if(c===Ke)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===Ur)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ir)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Nr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Fr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===Ur)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ir)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Nr)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Fr)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Vs||s===ks||s===Ws||s===Xs)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===Vs)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===ks)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Ws)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Xs)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Ro)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Ys||s===qs)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===Ys)return c===Ke?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===qs)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===js||s===Zs||s===Ks||s===$s||s===Qs||s===Js||s===ea||s===ta||s===na||s===ia||s===ra||s===sa||s===aa||s===oa)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===js)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Zs)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Ks)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===$s)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Qs)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Js)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===ea)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===ta)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===na)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===ia)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===ra)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===sa)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===aa)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===oa)return c===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Or||s===ca||s===la)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===Or)return c===Ke?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===ca)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===la)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Wc||s===ha||s===ua||s===da)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(s===Or)return o.COMPRESSED_RED_RGTC1_EXT;if(s===ha)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===ua)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===da)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Un?n?i.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):i[s]!==void 0?i[s]:null}return{convert:r}}class vp extends Ot{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class ir extends st{constructor(){super(),this.isGroup=!0,this.type="Group"}}const xp={type:"move"};class as{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ir,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ir,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ir,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const _ of e.hand.values()){const p=t.getJointPose(_,n),u=this._getHandJoint(l,_);p!==null&&(u.matrix.fromArray(p.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,u.jointRadius=p.radius),u.visible=p!==null}const h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],f=h.position.distanceTo(d.position),m=.02,g=.005;l.inputState.pinching&&f>m+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=m-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(xp)))}return o!==null&&(o.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new ir;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Mp extends Bn{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",c=1,l=null,h=null,d=null,f=null,m=null,g=null;const _=t.getContextAttributes();let p=null,u=null;const S=[],v=[],T=new Re;let E=null;const w=new Ot;w.layers.enable(1),w.viewport=new gt;const R=new Ot;R.layers.enable(2),R.viewport=new gt;const I=[w,R],x=new vp;x.layers.enable(1),x.layers.enable(2);let A=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let $=S[W];return $===void 0&&($=new as,S[W]=$),$.getTargetRaySpace()},this.getControllerGrip=function(W){let $=S[W];return $===void 0&&($=new as,S[W]=$),$.getGripSpace()},this.getHand=function(W){let $=S[W];return $===void 0&&($=new as,S[W]=$),$.getHandSpace()};function B(W){const $=v.indexOf(W.inputSource);if($===-1)return;const de=S[$];de!==void 0&&(de.update(W.inputSource,W.frame,l||a),de.dispatchEvent({type:W.type,data:W.inputSource}))}function K(){r.removeEventListener("select",B),r.removeEventListener("selectstart",B),r.removeEventListener("selectend",B),r.removeEventListener("squeeze",B),r.removeEventListener("squeezestart",B),r.removeEventListener("squeezeend",B),r.removeEventListener("end",K),r.removeEventListener("inputsourceschange",L);for(let W=0;W=0&&(v[ve]=null,S[ve].disconnect(de))}for(let $=0;$=v.length){v.push(de),ve=De;break}else if(v[De]===null){v[De]=de,ve=De;break}if(ve===-1)break}const Me=S[ve];Me&&Me.connect(de)}}const N=new C,Y=new C;function V(W,$,de){N.setFromMatrixPosition($.matrixWorld),Y.setFromMatrixPosition(de.matrixWorld);const ve=N.distanceTo(Y),Me=$.projectionMatrix.elements,De=de.projectionMatrix.elements,Ce=Me[14]/(Me[10]-1),Ae=Me[14]/(Me[10]+1),Ie=(Me[9]+1)/Me[5],F=(Me[9]-1)/Me[5],ht=(Me[8]-1)/Me[0],Se=(De[8]+1)/De[0],Oe=Ce*ht,we=Ce*Se,Ze=ve/(-ht+Se),Ne=Ze*-ht;$.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(Ne),W.translateZ(Ze),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert();const Pe=Ce+Ze,We=Ae+Ze,at=Oe-Ne,ot=we+(ve-Ne),b=Ie*Ae/We*Pe,M=F*Ae/We*Pe;W.projectionMatrix.makePerspective(at,ot,b,M,Pe,We),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}function ee(W,$){$===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices($.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(r===null)return;x.near=R.near=w.near=W.near,x.far=R.far=w.far=W.far,(A!==x.near||k!==x.far)&&(r.updateRenderState({depthNear:x.near,depthFar:x.far}),A=x.near,k=x.far);const $=W.parent,de=x.cameras;ee(x,$);for(let ve=0;ve0&&(p.alphaTest.value=u.alphaTest);const S=e.get(u).envMap;if(S&&(p.envMap.value=S,p.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=u.reflectivity,p.ior.value=u.ior,p.refractionRatio.value=u.refractionRatio),u.lightMap){p.lightMap.value=u.lightMap;const v=i._useLegacyLights===!0?Math.PI:1;p.lightMapIntensity.value=u.lightMapIntensity*v,t(u.lightMap,p.lightMapTransform)}u.aoMap&&(p.aoMap.value=u.aoMap,p.aoMapIntensity.value=u.aoMapIntensity,t(u.aoMap,p.aoMapTransform))}function a(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform))}function o(p,u){p.dashSize.value=u.dashSize,p.totalSize.value=u.dashSize+u.gapSize,p.scale.value=u.scale}function c(p,u,S,v){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.size.value=u.size*S,p.scale.value=v*.5,u.map&&(p.map.value=u.map,t(u.map,p.uvTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function l(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.rotation.value=u.rotation,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function h(p,u){p.specular.value.copy(u.specular),p.shininess.value=Math.max(u.shininess,1e-4)}function d(p,u){u.gradientMap&&(p.gradientMap.value=u.gradientMap)}function f(p,u){p.metalness.value=u.metalness,u.metalnessMap&&(p.metalnessMap.value=u.metalnessMap,t(u.metalnessMap,p.metalnessMapTransform)),p.roughness.value=u.roughness,u.roughnessMap&&(p.roughnessMap.value=u.roughnessMap,t(u.roughnessMap,p.roughnessMapTransform)),e.get(u).envMap&&(p.envMapIntensity.value=u.envMapIntensity)}function m(p,u,S){p.ior.value=u.ior,u.sheen>0&&(p.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),p.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(p.sheenColorMap.value=u.sheenColorMap,t(u.sheenColorMap,p.sheenColorMapTransform)),u.sheenRoughnessMap&&(p.sheenRoughnessMap.value=u.sheenRoughnessMap,t(u.sheenRoughnessMap,p.sheenRoughnessMapTransform))),u.clearcoat>0&&(p.clearcoat.value=u.clearcoat,p.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(p.clearcoatMap.value=u.clearcoatMap,t(u.clearcoatMap,p.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,t(u.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(p.clearcoatNormalMap.value=u.clearcoatNormalMap,t(u.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===Ct&&p.clearcoatNormalScale.value.negate())),u.iridescence>0&&(p.iridescence.value=u.iridescence,p.iridescenceIOR.value=u.iridescenceIOR,p.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(p.iridescenceMap.value=u.iridescenceMap,t(u.iridescenceMap,p.iridescenceMapTransform)),u.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=u.iridescenceThicknessMap,t(u.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),u.transmission>0&&(p.transmission.value=u.transmission,p.transmissionSamplerMap.value=S.texture,p.transmissionSamplerSize.value.set(S.width,S.height),u.transmissionMap&&(p.transmissionMap.value=u.transmissionMap,t(u.transmissionMap,p.transmissionMapTransform)),p.thickness.value=u.thickness,u.thicknessMap&&(p.thicknessMap.value=u.thicknessMap,t(u.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=u.attenuationDistance,p.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(p.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(p.anisotropyMap.value=u.anisotropyMap,t(u.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=u.specularIntensity,p.specularColor.value.copy(u.specularColor),u.specularColorMap&&(p.specularColorMap.value=u.specularColorMap,t(u.specularColorMap,p.specularColorMapTransform)),u.specularIntensityMap&&(p.specularIntensityMap.value=u.specularIntensityMap,t(u.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,u){u.matcap&&(p.matcap.value=u.matcap)}function _(p,u){const S=e.get(u).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Ep(i,e,t,n){let r={},s={},a=[];const o=t.isWebGL2?i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,v){const T=v.program;n.uniformBlockBinding(S,T)}function l(S,v){let T=r[S.id];T===void 0&&(g(S),T=h(S),r[S.id]=T,S.addEventListener("dispose",p));const E=v.program;n.updateUBOMapping(S,E);const w=e.render.frame;s[S.id]!==w&&(f(S),s[S.id]=w)}function h(S){const v=d();S.__bindingPointIndex=v;const T=i.createBuffer(),E=S.__size,w=S.usage;return i.bindBuffer(i.UNIFORM_BUFFER,T),i.bufferData(i.UNIFORM_BUFFER,E,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,v,T),T}function d(){for(let S=0;S0){w=T%E;const B=E-w;w!==0&&B-A.boundary<0&&(T+=E-w,x.__offset=T)}T+=A.storage}return w=T%E,w>0&&(T+=E-w),S.__size=T,S.__cache={},this}function _(S){const v={boundary:0,storage:0};return typeof S=="number"?(v.boundary=4,v.storage=4):S.isVector2?(v.boundary=8,v.storage=8):S.isVector3||S.isColor?(v.boundary=16,v.storage=12):S.isVector4?(v.boundary=16,v.storage=16):S.isMatrix3?(v.boundary=48,v.storage=48):S.isMatrix4?(v.boundary=64,v.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),v}function p(S){const v=S.target;v.removeEventListener("dispose",p);const T=a.indexOf(v.__bindingPointIndex);a.splice(T,1),i.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function u(){for(const S in r)i.deleteBuffer(r[S]);a=[],r={},s={}}return{bind:c,update:l,dispose:u}}class Zo{constructor(e={}){const{canvas:t=gl(),context:n=null,depth:r=!0,stencil:s=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let f;n!==null?f=n.getContextAttributes().alpha:f=a;const m=new Uint32Array(4),g=new Int32Array(4);let _=null,p=null;const u=[],S=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=mt,this._useLegacyLights=!1,this.toneMapping=vn,this.toneMappingExposure=1;const v=this;let T=!1,E=0,w=0,R=null,I=-1,x=null;const A=new gt,k=new gt;let B=null;const K=new Xe(0);let L=0,N=t.width,Y=t.height,V=1,ee=null,q=null;const j=new gt(0,0,N,Y),re=new gt(0,0,N,Y);let ae=!1;const W=new Go;let $=!1,de=!1,ve=null;const Me=new rt,De=new Re,Ce=new C,Ae={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ie(){return R===null?V:1}let F=n;function ht(y,U){for(let H=0;H{function fe(){if(G.forEach(function(xe){Ne.get(xe).currentProgram.isReady()&&G.delete(xe)}),G.size===0){z(y);return}setTimeout(fe,10)}Se.get("KHR_parallel_shader_compile")!==null?fe():setTimeout(fe,10)})};let Ge=null;function ut(y){Ge&&Ge(y)}function Tt(){bt.stop()}function je(){bt.start()}const bt=new Vo;bt.setAnimationLoop(ut),typeof self<"u"&&bt.setContext(self),this.setAnimationLoop=function(y){Ge=y,pe.setAnimationLoop(y),y===null?bt.stop():bt.start()},pe.addEventListener("sessionstart",Tt),pe.addEventListener("sessionend",je),this.render=function(y,U){if(U!==void 0&&U.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),pe.enabled===!0&&pe.isPresenting===!0&&(pe.cameraAutoUpdate===!0&&pe.updateCamera(U),U=pe.getCamera()),y.isScene===!0&&y.onBeforeRender(v,y,U,R),p=ne.get(y,S.length),p.init(),S.push(p),Me.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),W.setFromProjectionMatrix(Me),de=this.localClippingEnabled,$=_e.init(this.clippingPlanes,de),_=J.get(y,u.length),_.init(),u.push(_),Yt(y,U,0,v.sortObjects),_.finish(),v.sortObjects===!0&&_.sort(ee,q),this.info.render.frame++,$===!0&&_e.beginShadows();const H=p.state.shadowsArray;if(oe.render(H,y,U),$===!0&&_e.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(_,y),p.setupLights(v._useLegacyLights),U.isArrayCamera){const G=U.cameras;for(let z=0,fe=G.length;z0?p=S[S.length-1]:p=null,u.pop(),u.length>0?_=u[u.length-1]:_=null};function Yt(y,U,H,G){if(y.visible===!1)return;if(y.layers.test(U.layers)){if(y.isGroup)H=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(U);else if(y.isLight)p.pushLight(y),y.castShadow&&p.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||W.intersectsSprite(y)){G&&Ce.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Me);const xe=M.update(y),be=y.material;be.visible&&_.push(y,xe,be,H,Ce.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||W.intersectsObject(y))){const xe=M.update(y),be=y.material;if(G&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Ce.copy(y.boundingSphere.center)):(xe.boundingSphere===null&&xe.computeBoundingSphere(),Ce.copy(xe.boundingSphere.center)),Ce.applyMatrix4(y.matrixWorld).applyMatrix4(Me)),Array.isArray(be)){const Le=xe.groups;for(let ze=0,Ue=Le.length;ze0&&Qo(z,fe,U,H),G&&we.viewport(A.copy(G)),z.length>0&&Ui(z,U,H),fe.length>0&&Ui(fe,U,H),xe.length>0&&Ui(xe,U,H),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1)}function Qo(y,U,H,G){if((H.isScene===!0?H.overrideMaterial:null)!==null)return;const fe=Oe.isWebGL2;ve===null&&(ve=new Fn(1,1,{generateMipmaps:!0,type:Se.has("EXT_color_buffer_half_float")?Ri:xn,minFilter:wi,samples:fe?4:0})),v.getDrawingBufferSize(De),fe?ve.setSize(De.x,De.y):ve.setSize(gr(De.x),gr(De.y));const xe=v.getRenderTarget();v.setRenderTarget(ve),v.getClearColor(K),L=v.getClearAlpha(),L<1&&v.setClearColor(16777215,.5),v.clear();const be=v.toneMapping;v.toneMapping=vn,Ui(y,H,G),Pe.updateMultisampleRenderTarget(ve),Pe.updateRenderTargetMipmap(ve);let Le=!1;for(let ze=0,Ue=U.length;ze0),Fe=!!H.morphAttributes.position,tt=!!H.morphAttributes.normal,Pt=!!H.morphAttributes.color;let dt=vn;G.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(dt=v.toneMapping);const $t=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Je=$t!==void 0?$t.length:0,Ve=Ne.get(G),Rr=p.state.lights;if($===!0&&(de===!0||y!==x)){const It=y===x&&G.id===I;_e.setState(G,y,It)}let et=!1;G.version===Ve.__version?(Ve.needsLights&&Ve.lightsStateVersion!==Rr.state.version||Ve.outputColorSpace!==be||z.isBatchedMesh&&Ve.batching===!1||!z.isBatchedMesh&&Ve.batching===!0||z.isInstancedMesh&&Ve.instancing===!1||!z.isInstancedMesh&&Ve.instancing===!0||z.isSkinnedMesh&&Ve.skinning===!1||!z.isSkinnedMesh&&Ve.skinning===!0||z.isInstancedMesh&&Ve.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&Ve.instancingColor===!1&&z.instanceColor!==null||Ve.envMap!==Le||G.fog===!0&&Ve.fog!==fe||Ve.numClippingPlanes!==void 0&&(Ve.numClippingPlanes!==_e.numPlanes||Ve.numIntersection!==_e.numIntersection)||Ve.vertexAlphas!==ze||Ve.vertexTangents!==Ue||Ve.morphTargets!==Fe||Ve.morphNormals!==tt||Ve.morphColors!==Pt||Ve.toneMapping!==dt||Oe.isWebGL2===!0&&Ve.morphTargetsCount!==Je)&&(et=!0):(et=!0,Ve.__version=G.version);let Sn=Ve.currentProgram;et===!0&&(Sn=Ii(G,U,z));let Us=!1,pi=!1,Cr=!1;const vt=Sn.getUniforms(),En=Ve.uniforms;if(we.useProgram(Sn.program)&&(Us=!0,pi=!0,Cr=!0),G.id!==I&&(I=G.id,pi=!0),Us||x!==y){vt.setValue(F,"projectionMatrix",y.projectionMatrix),vt.setValue(F,"viewMatrix",y.matrixWorldInverse);const It=vt.map.cameraPosition;It!==void 0&&It.setValue(F,Ce.setFromMatrixPosition(y.matrixWorld)),Oe.logarithmicDepthBuffer&&vt.setValue(F,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&vt.setValue(F,"isOrthographic",y.isOrthographicCamera===!0),x!==y&&(x=y,pi=!0,Cr=!0)}if(z.isSkinnedMesh){vt.setOptional(F,z,"bindMatrix"),vt.setOptional(F,z,"bindMatrixInverse");const It=z.skeleton;It&&(Oe.floatVertexTextures?(It.boneTexture===null&&It.computeBoneTexture(),vt.setValue(F,"boneTexture",It.boneTexture,Pe)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}z.isBatchedMesh&&(vt.setOptional(F,z,"batchingTexture"),vt.setValue(F,"batchingTexture",z._matricesTexture,Pe));const Pr=H.morphAttributes;if((Pr.position!==void 0||Pr.normal!==void 0||Pr.color!==void 0&&Oe.isWebGL2===!0)&&P.update(z,H,Sn),(pi||Ve.receiveShadow!==z.receiveShadow)&&(Ve.receiveShadow=z.receiveShadow,vt.setValue(F,"receiveShadow",z.receiveShadow)),G.isMeshGouraudMaterial&&G.envMap!==null&&(En.envMap.value=Le,En.flipEnvMap.value=Le.isCubeTexture&&Le.isRenderTargetTexture===!1?-1:1),pi&&(vt.setValue(F,"toneMappingExposure",v.toneMappingExposure),Ve.needsLights&&ec(En,Cr),fe&&G.fog===!0&&te.refreshFogUniforms(En,fe),te.refreshMaterialUniforms(En,G,V,Y,ve),lr.upload(F,Ls(Ve),En,Pe)),G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(lr.upload(F,Ls(Ve),En,Pe),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&vt.setValue(F,"center",z.center),vt.setValue(F,"modelViewMatrix",z.modelViewMatrix),vt.setValue(F,"normalMatrix",z.normalMatrix),vt.setValue(F,"modelMatrix",z.matrixWorld),G.isShaderMaterial||G.isRawShaderMaterial){const It=G.uniformsGroups;for(let Lr=0,nc=It.length;Lr0&&Pe.useMultisampledRTT(y)===!1?z=Ne.get(y).__webglMultisampledFramebuffer:Array.isArray(Ue)?z=Ue[H]:z=Ue,A.copy(y.viewport),k.copy(y.scissor),B=y.scissorTest}else A.copy(j).multiplyScalar(V).floor(),k.copy(re).multiplyScalar(V).floor(),B=ae;if(we.bindFramebuffer(F.FRAMEBUFFER,z)&&Oe.drawBuffers&&G&&we.drawBuffers(y,z),we.viewport(A),we.scissor(k),we.setScissorTest(B),fe){const Le=Ne.get(y.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+U,Le.__webglTexture,H)}else if(xe){const Le=Ne.get(y.texture),ze=U||0;F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,Le.__webglTexture,H||0,ze)}I=-1},this.readRenderTargetPixels=function(y,U,H,G,z,fe,xe){if(!(y&&y.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=Ne.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&xe!==void 0&&(be=be[xe]),be){we.bindFramebuffer(F.FRAMEBUFFER,be);try{const Le=y.texture,ze=Le.format,Ue=Le.type;if(ze!==Xt&&Te.convert(ze)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Fe=Ue===Ri&&(Se.has("EXT_color_buffer_half_float")||Oe.isWebGL2&&Se.has("EXT_color_buffer_float"));if(Ue!==xn&&Te.convert(Ue)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ue===_n&&(Oe.isWebGL2||Se.has("OES_texture_float")||Se.has("WEBGL_color_buffer_float")))&&!Fe){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=y.width-G&&H>=0&&H<=y.height-z&&F.readPixels(U,H,G,z,Te.convert(ze),Te.convert(Ue),fe)}finally{const Le=R!==null?Ne.get(R).__webglFramebuffer:null;we.bindFramebuffer(F.FRAMEBUFFER,Le)}}},this.copyFramebufferToTexture=function(y,U,H=0){const G=Math.pow(2,-H),z=Math.floor(U.image.width*G),fe=Math.floor(U.image.height*G);Pe.setTexture2D(U,0),F.copyTexSubImage2D(F.TEXTURE_2D,H,0,0,y.x,y.y,z,fe),we.unbindTexture()},this.copyTextureToTexture=function(y,U,H,G=0){const z=U.image.width,fe=U.image.height,xe=Te.convert(H.format),be=Te.convert(H.type);Pe.setTexture2D(H,0),F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,H.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,H.unpackAlignment),U.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,G,y.x,y.y,z,fe,xe,be,U.image.data):U.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,G,y.x,y.y,U.mipmaps[0].width,U.mipmaps[0].height,xe,U.mipmaps[0].data):F.texSubImage2D(F.TEXTURE_2D,G,y.x,y.y,xe,be,U.image),G===0&&H.generateMipmaps&&F.generateMipmap(F.TEXTURE_2D),we.unbindTexture()},this.copyTextureToTexture3D=function(y,U,H,G,z=0){if(v.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const fe=y.max.x-y.min.x+1,xe=y.max.y-y.min.y+1,be=y.max.z-y.min.z+1,Le=Te.convert(G.format),ze=Te.convert(G.type);let Ue;if(G.isData3DTexture)Pe.setTexture3D(G,0),Ue=F.TEXTURE_3D;else if(G.isDataArrayTexture)Pe.setTexture2DArray(G,0),Ue=F.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,G.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,G.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,G.unpackAlignment);const Fe=F.getParameter(F.UNPACK_ROW_LENGTH),tt=F.getParameter(F.UNPACK_IMAGE_HEIGHT),Pt=F.getParameter(F.UNPACK_SKIP_PIXELS),dt=F.getParameter(F.UNPACK_SKIP_ROWS),$t=F.getParameter(F.UNPACK_SKIP_IMAGES),Je=H.isCompressedTexture?H.mipmaps[0]:H.image;F.pixelStorei(F.UNPACK_ROW_LENGTH,Je.width),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,Je.height),F.pixelStorei(F.UNPACK_SKIP_PIXELS,y.min.x),F.pixelStorei(F.UNPACK_SKIP_ROWS,y.min.y),F.pixelStorei(F.UNPACK_SKIP_IMAGES,y.min.z),H.isDataTexture||H.isData3DTexture?F.texSubImage3D(Ue,z,U.x,U.y,U.z,fe,xe,be,Le,ze,Je.data):H.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),F.compressedTexSubImage3D(Ue,z,U.x,U.y,U.z,fe,xe,be,Le,Je.data)):F.texSubImage3D(Ue,z,U.x,U.y,U.z,fe,xe,be,Le,ze,Je),F.pixelStorei(F.UNPACK_ROW_LENGTH,Fe),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,tt),F.pixelStorei(F.UNPACK_SKIP_PIXELS,Pt),F.pixelStorei(F.UNPACK_SKIP_ROWS,dt),F.pixelStorei(F.UNPACK_SKIP_IMAGES,$t),z===0&&G.generateMipmaps&&F.generateMipmap(Ue),we.unbindTexture()},this.initTexture=function(y){y.isCubeTexture?Pe.setTextureCube(y,0):y.isData3DTexture?Pe.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?Pe.setTexture2DArray(y,0):Pe.setTexture2D(y,0),we.unbindTexture()},this.resetState=function(){E=0,w=0,R=null,we.reset(),ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return sn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Ts?"display-p3":"srgb",t.unpackColorSpace=Ye.workingColorSpace===Mr?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===mt?Nn:Co}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Nn?mt:on}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class yp extends Zo{}yp.prototype.isWebGL1Renderer=!0;class Tp extends st{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class br extends Di{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Xe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const to=new C,no=new C,io=new rt,os=new Er,rr=new Sr;class Vt extends st{constructor(e=new yt,t=new br){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;rc)continue;f.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(f);Ie.far||t.push({distance:I,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{const u=Math.max(0,a.start),S=Math.min(p.count,a.start+a.count);for(let v=u,T=S-1;vc)continue;f.applyMatrix4(this.matrixWorld);const w=e.ray.origin.distanceTo(f);we.far||t.push({distance:w,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s0&&v(!0),t>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new $e(d,3)),this.setAttribute("normal",new $e(f,3)),this.setAttribute("uv",new $e(m,2));function S(){const T=new C,E=new C;let w=0;const R=(t-e)/n;for(let I=0;I<=s;I++){const x=[],A=I/s,k=A*(t-e)+e;for(let B=0;B<=r;B++){const K=B/r,L=K*c+o,N=Math.sin(L),Y=Math.cos(L);E.x=k*N,E.y=-A*n+p,E.z=k*Y,d.push(E.x,E.y,E.z),T.set(N,R,Y).normalize(),f.push(T.x,T.y,T.z),m.push(K,1-A),x.push(g++)}_.push(x)}for(let I=0;I.9&&R<.1&&(v<.2&&(a[S+0]+=1),T<.2&&(a[S+2]+=1),E<.2&&(a[S+4]+=1))}}function f(S){s.push(S.x,S.y,S.z)}function m(S,v){const T=S*3;v.x=e[T+0],v.y=e[T+1],v.z=e[T+2]}function g(){const S=new C,v=new C,T=new C,E=new C,w=new Re,R=new Re,I=new Re;for(let x=0,A=0;x0)&&m.push(v,T,w),(u!==n-1||cMath.PI&&(ce-=me),Q<-Math.PI?Q+=me:Q>Math.PI&&(Q-=me),ce<=Q?o.theta=Math.max(ce,Math.min(Q,o.theta)):o.theta=o.theta>(ce+Q)/2?Math.max(ce,o.theta):Math.min(Q,o.theta)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi)),o.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(h,n.dampingFactor):n.target.add(h),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&w||n.object.isOrthographicCamera?o.radius=q(o.radius):o.radius=q(o.radius*l),P.setFromSpherical(o),P.applyQuaternion(Z),D.copy(n.target).add(P),n.object.lookAt(n.target),n.enableDamping===!0?(c.theta*=1-n.dampingFactor,c.phi*=1-n.dampingFactor,h.multiplyScalar(1-n.dampingFactor)):(c.set(0,0,0),h.set(0,0,0));let X=!1;if(n.zoomToCursor&&w){let ie=null;if(n.object.isPerspectiveCamera){const Ee=P.length();ie=q(Ee*l);const Ge=Ee-ie;n.object.position.addScaledVector(T,Ge),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const Ee=new C(E.x,E.y,0);Ee.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/l)),n.object.updateProjectionMatrix(),X=!0;const Ge=new C(E.x,E.y,0);Ge.unproject(n.object),n.object.position.sub(Ge).add(Ee),n.object.updateMatrixWorld(),ie=P.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;ie!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(ie).add(n.object.position):(sr.origin.copy(n.object.position),sr.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(sr.direction))a||8*(1-ge.dot(n.object.quaternion))>a||ye.distanceToSquared(n.target)>0?(n.dispatchEvent(co),Te.copy(n.object.position),ge.copy(n.object.quaternion),ye.copy(n.target),!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",J),n.domElement.removeEventListener("pointerdown",Ne),n.domElement.removeEventListener("pointercancel",We),n.domElement.removeEventListener("wheel",b),n.domElement.removeEventListener("pointermove",Pe),n.domElement.removeEventListener("pointerup",We),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener("keydown",M),n._domElementKeyEvents=null)};const n=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=r.NONE;const a=1e-6,o=new oo,c=new oo;let l=1;const h=new C,d=new Re,f=new Re,m=new Re,g=new Re,_=new Re,p=new Re,u=new Re,S=new Re,v=new Re,T=new C,E=new Re;let w=!1;const R=[],I={};function x(P){return P!==null?2*Math.PI/60*n.autoRotateSpeed*P:2*Math.PI/60/60*n.autoRotateSpeed}function A(){return Math.pow(.95,n.zoomSpeed)}function k(P){c.theta-=P}function B(P){c.phi-=P}const K=function(){const P=new C;return function(Z,Te){P.setFromMatrixColumn(Te,0),P.multiplyScalar(-Z),h.add(P)}}(),L=function(){const P=new C;return function(Z,Te){n.screenSpacePanning===!0?P.setFromMatrixColumn(Te,1):(P.setFromMatrixColumn(Te,0),P.crossVectors(n.object.up,P)),P.multiplyScalar(Z),h.add(P)}}(),N=function(){const P=new C;return function(Z,Te){const ge=n.domElement;if(n.object.isPerspectiveCamera){const ye=n.object.position;P.copy(ye).sub(n.target);let me=P.length();me*=Math.tan(n.object.fov/2*Math.PI/180),K(2*Z*me/ge.clientHeight,n.object.matrix),L(2*Te*me/ge.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(K(Z*(n.object.right-n.object.left)/n.object.zoom/ge.clientWidth,n.object.matrix),L(Te*(n.object.top-n.object.bottom)/n.object.zoom/ge.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function Y(P){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l/=P:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function V(P){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l*=P:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ee(P){if(!n.zoomToCursor)return;w=!0;const se=n.domElement.getBoundingClientRect(),Z=P.clientX-se.left,Te=P.clientY-se.top,ge=se.width,ye=se.height;E.x=Z/ge*2-1,E.y=-(Te/ye)*2+1,T.set(E.x,E.y,1).unproject(n.object).sub(n.object.position).normalize()}function q(P){return Math.max(n.minDistance,Math.min(n.maxDistance,P))}function j(P){d.set(P.clientX,P.clientY)}function re(P){ee(P),u.set(P.clientX,P.clientY)}function ae(P){g.set(P.clientX,P.clientY)}function W(P){f.set(P.clientX,P.clientY),m.subVectors(f,d).multiplyScalar(n.rotateSpeed);const se=n.domElement;k(2*Math.PI*m.x/se.clientHeight),B(2*Math.PI*m.y/se.clientHeight),d.copy(f),n.update()}function $(P){S.set(P.clientX,P.clientY),v.subVectors(S,u),v.y>0?Y(A()):v.y<0&&V(A()),u.copy(S),n.update()}function de(P){_.set(P.clientX,P.clientY),p.subVectors(_,g).multiplyScalar(n.panSpeed),N(p.x,p.y),g.copy(_),n.update()}function ve(P){ee(P),P.deltaY<0?V(A()):P.deltaY>0&&Y(A()),n.update()}function Me(P){let se=!1;switch(P.code){case n.keys.UP:P.ctrlKey||P.metaKey||P.shiftKey?B(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(0,n.keyPanSpeed),se=!0;break;case n.keys.BOTTOM:P.ctrlKey||P.metaKey||P.shiftKey?B(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(0,-n.keyPanSpeed),se=!0;break;case n.keys.LEFT:P.ctrlKey||P.metaKey||P.shiftKey?k(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(n.keyPanSpeed,0),se=!0;break;case n.keys.RIGHT:P.ctrlKey||P.metaKey||P.shiftKey?k(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):N(-n.keyPanSpeed,0),se=!0;break}se&&(P.preventDefault(),n.update())}function De(){if(R.length===1)d.set(R[0].pageX,R[0].pageY);else{const P=.5*(R[0].pageX+R[1].pageX),se=.5*(R[0].pageY+R[1].pageY);d.set(P,se)}}function Ce(){if(R.length===1)g.set(R[0].pageX,R[0].pageY);else{const P=.5*(R[0].pageX+R[1].pageX),se=.5*(R[0].pageY+R[1].pageY);g.set(P,se)}}function Ae(){const P=R[0].pageX-R[1].pageX,se=R[0].pageY-R[1].pageY,Z=Math.sqrt(P*P+se*se);u.set(0,Z)}function Ie(){n.enableZoom&&Ae(),n.enablePan&&Ce()}function F(){n.enableZoom&&Ae(),n.enableRotate&&De()}function ht(P){if(R.length==1)f.set(P.pageX,P.pageY);else{const Z=ue(P),Te=.5*(P.pageX+Z.x),ge=.5*(P.pageY+Z.y);f.set(Te,ge)}m.subVectors(f,d).multiplyScalar(n.rotateSpeed);const se=n.domElement;k(2*Math.PI*m.x/se.clientHeight),B(2*Math.PI*m.y/se.clientHeight),d.copy(f)}function Se(P){if(R.length===1)_.set(P.pageX,P.pageY);else{const se=ue(P),Z=.5*(P.pageX+se.x),Te=.5*(P.pageY+se.y);_.set(Z,Te)}p.subVectors(_,g).multiplyScalar(n.panSpeed),N(p.x,p.y),g.copy(_)}function Oe(P){const se=ue(P),Z=P.pageX-se.x,Te=P.pageY-se.y,ge=Math.sqrt(Z*Z+Te*Te);S.set(0,ge),v.set(0,Math.pow(S.y/u.y,n.zoomSpeed)),Y(v.y),u.copy(S)}function we(P){n.enableZoom&&Oe(P),n.enablePan&&Se(P)}function Ze(P){n.enableZoom&&Oe(P),n.enableRotate&&ht(P)}function Ne(P){n.enabled!==!1&&(R.length===0&&(n.domElement.setPointerCapture(P.pointerId),n.domElement.addEventListener("pointermove",Pe),n.domElement.addEventListener("pointerup",We)),ne(P),P.pointerType==="touch"?O(P):at(P))}function Pe(P){n.enabled!==!1&&(P.pointerType==="touch"?te(P):ot(P))}function We(P){_e(P),R.length===0&&(n.domElement.releasePointerCapture(P.pointerId),n.domElement.removeEventListener("pointermove",Pe),n.domElement.removeEventListener("pointerup",We)),n.dispatchEvent(lo),s=r.NONE}function at(P){let se;switch(P.button){case 0:se=n.mouseButtons.LEFT;break;case 1:se=n.mouseButtons.MIDDLE;break;case 2:se=n.mouseButtons.RIGHT;break;default:se=-1}switch(se){case zn.DOLLY:if(n.enableZoom===!1)return;re(P),s=r.DOLLY;break;case zn.ROTATE:if(P.ctrlKey||P.metaKey||P.shiftKey){if(n.enablePan===!1)return;ae(P),s=r.PAN}else{if(n.enableRotate===!1)return;j(P),s=r.ROTATE}break;case zn.PAN:if(P.ctrlKey||P.metaKey||P.shiftKey){if(n.enableRotate===!1)return;j(P),s=r.ROTATE}else{if(n.enablePan===!1)return;ae(P),s=r.PAN}break;default:s=r.NONE}s!==r.NONE&&n.dispatchEvent(cs)}function ot(P){switch(s){case r.ROTATE:if(n.enableRotate===!1)return;W(P);break;case r.DOLLY:if(n.enableZoom===!1)return;$(P);break;case r.PAN:if(n.enablePan===!1)return;de(P);break}}function b(P){n.enabled===!1||n.enableZoom===!1||s!==r.NONE||(P.preventDefault(),n.dispatchEvent(cs),ve(P),n.dispatchEvent(lo))}function M(P){n.enabled===!1||n.enablePan===!1||Me(P)}function O(P){switch(oe(P),R.length){case 1:switch(n.touches.ONE){case Hn.ROTATE:if(n.enableRotate===!1)return;De(),s=r.TOUCH_ROTATE;break;case Hn.PAN:if(n.enablePan===!1)return;Ce(),s=r.TOUCH_PAN;break;default:s=r.NONE}break;case 2:switch(n.touches.TWO){case Hn.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Ie(),s=r.TOUCH_DOLLY_PAN;break;case Hn.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;F(),s=r.TOUCH_DOLLY_ROTATE;break;default:s=r.NONE}break;default:s=r.NONE}s!==r.NONE&&n.dispatchEvent(cs)}function te(P){switch(oe(P),s){case r.TOUCH_ROTATE:if(n.enableRotate===!1)return;ht(P),n.update();break;case r.TOUCH_PAN:if(n.enablePan===!1)return;Se(P),n.update();break;case r.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;we(P),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Ze(P),n.update();break;default:s=r.NONE}}function J(P){n.enabled!==!1&&P.preventDefault()}function ne(P){R.push(P)}function _e(P){delete I[P.pointerId];for(let se=0;se.9&&(a.visible=!1)),this.axis==="Y"&&(Qe.setFromEuler(ar.set(0,0,Math.PI/2)),a.quaternion.copy(n).multiply(Qe),Math.abs(qe.copy(Cn).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="Z"&&(Qe.setFromEuler(ar.set(0,Math.PI/2,0)),a.quaternion.copy(n).multiply(Qe),Math.abs(qe.copy(yi).applyQuaternion(n).dot(this.eye))>.9&&(a.visible=!1)),this.axis==="XYZE"&&(Qe.setFromEuler(ar.set(0,Math.PI/2,0)),qe.copy(this.rotationAxis),a.quaternion.setFromRotationMatrix(go.lookAt(_o,qe,Cn)),a.quaternion.multiply(Qe),a.visible=this.dragging),this.axis==="E"&&(a.visible=!1)):a.name==="START"?(a.position.copy(this.worldPositionStart),a.visible=this.dragging):a.name==="END"?(a.position.copy(this.worldPosition),a.visible=this.dragging):a.name==="DELTA"?(a.position.copy(this.worldPositionStart),a.quaternion.copy(this.worldQuaternionStart),St.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),St.applyQuaternion(this.worldQuaternionStart.clone().invert()),a.scale.copy(St),a.visible=this.dragging):(a.quaternion.copy(n),this.dragging?a.position.copy(this.worldPositionStart):a.position.copy(this.worldPosition),this.axis&&(a.visible=this.axis.search(a.name)!==-1));continue}a.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(a.name==="X"&&Math.abs(qe.copy(Ei).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Y"&&Math.abs(qe.copy(Cn).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="Z"&&Math.abs(qe.copy(yi).applyQuaternion(n).dot(this.eye))>.99&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XY"&&Math.abs(qe.copy(yi).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="YZ"&&Math.abs(qe.copy(Ei).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name==="XZ"&&Math.abs(qe.copy(Cn).applyQuaternion(n).dot(this.eye))<.2&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1)):this.mode==="rotate"&&(or.copy(n),qe.copy(this.eye).applyQuaternion(Qe.copy(n).invert()),a.name.search("E")!==-1&&a.quaternion.setFromRotationMatrix(go.lookAt(this.eye,_o,Cn)),a.name==="X"&&(Qe.setFromAxisAngle(Ei,Math.atan2(-qe.y,qe.z)),Qe.multiplyQuaternions(or,Qe),a.quaternion.copy(Qe)),a.name==="Y"&&(Qe.setFromAxisAngle(Cn,Math.atan2(qe.x,qe.z)),Qe.multiplyQuaternions(or,Qe),a.quaternion.copy(Qe)),a.name==="Z"&&(Qe.setFromAxisAngle(yi,Math.atan2(qe.y,qe.x)),Qe.multiplyQuaternions(or,Qe),a.quaternion.copy(Qe))),a.visible=a.visible&&(a.name.indexOf("X")===-1||this.showX),a.visible=a.visible&&(a.name.indexOf("Y")===-1||this.showY),a.visible=a.visible&&(a.name.indexOf("Z")===-1||this.showZ),a.visible=a.visible&&(a.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),a.material._color=a.material._color||a.material.color.clone(),a.material._opacity=a.material._opacity||a.material.opacity,a.material.color.copy(a.material._color),a.material.opacity=a.material._opacity,this.enabled&&this.axis&&(a.name===this.axis||this.axis.split("").some(function(c){return a.name===c}))&&(a.material.color.setHex(16776960),a.material.opacity=1)}super.updateMatrixWorld(e)}}class Fp extends he{constructor(){super(new yr(1e5,1e5,2,2),new an({visible:!1,wireframe:!0,side:Zt,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),cr.copy(Ei).applyQuaternion(t==="local"?this.worldQuaternion:hr),xi.copy(Cn).applyQuaternion(t==="local"?this.worldQuaternion:hr),Mi.copy(yi).applyQuaternion(t==="local"?this.worldQuaternion:hr),qe.copy(xi),this.mode){case"translate":case"scale":switch(this.axis){case"X":qe.copy(this.eye).cross(cr),qt.copy(cr).cross(qe);break;case"Y":qe.copy(this.eye).cross(xi),qt.copy(xi).cross(qe);break;case"Z":qe.copy(this.eye).cross(Mi),qt.copy(Mi).cross(qe);break;case"XY":qt.copy(Mi);break;case"YZ":qt.copy(cr);break;case"XZ":qe.copy(Mi),qt.copy(xi);break;case"XYZ":case"E":qt.set(0,0,0);break}break;case"rotate":default:qt.set(0,0,0)}qt.length()===0?this.quaternion.copy(this.cameraQuaternion):(vo.lookAt(St.set(0,0,0),qt,qe),this.quaternion.setFromRotationMatrix(vo)),super.updateMatrixWorld(e)}}const Op=()=>{const i=new Tp;return i.background=new Xe(2829099),i},Bp=i=>{const e=new Zo({antialias:!1});return e.setSize(i.offsetWidth,i.offsetHeight),e.setPixelRatio(window.devicePixelRatio),i.appendChild(e.domElement),e},zp=i=>{const e=i.offsetWidth/i.offsetHeight,t=new Ot(50,e);return t.position.set(100,100,100),t},Hp=(i,e)=>{const t=new Rp(i,e);return t.autoRotate=!0,t.autoRotateSpeed=1,t.enableDamping=!0,t.dampingFactor=.2,t},Gp=(i,e,t,n)=>{const r=new Cp(i,e);return r.addEventListener("dragging-changed",s=>{t.enablePan=!s.value,t.enableRotate=!s.value}),n.add(r),r},Vp=(i,e,t)=>{new ResizeObserver(r=>{if(r.length===0)return;const{width:s,height:a}=r[0].contentRect;e.setSize(s,a),t.aspect=s/a,t.updateProjectionMatrix()}).observe(i)};class kp{constructor(e,t,n,r,s){this.setEvent=()=>{const a=o=>{this.pointer.x=o.clientX/this.dom.offsetWidth*2-1,this.pointer.y=-(o.clientY/this.dom.offsetHeight)*2+1,this.ray.setFromCamera(this.pointer,this.camera);const c=this.pointCharges.map(h=>h.mesh),l=this.ray.intersectObjects(c,!1);if(l.length>0){const h=l[0].object;h!==this.transControls.object&&this.transControls.attach(h);const d=this.pointCharges.find(f=>f.mesh===h);for(let f of this.listeners)f.type==="object-selected"&&f.listener(d);this.selected=d||null}};this.dom.addEventListener("click",a),this.dom.addEventListener("pointerdown",o=>{this.onDownPosition.x=o.clientX,this.onDownPosition.y=o.clientY}),this.dom.addEventListener("pointerup",o=>{if(this.onUpPosition.x=o.clientX,this.onUpPosition.y=o.clientY,this.onDownPosition.distanceTo(this.onUpPosition)===0){this.transControls.detach(),this.selected=null;for(let c of this.listeners)c.type==="object-unselected"&&c.listener()}})},this.getSelected=()=>this.selected,this.attach=a=>{this.transControls.attach(a.mesh),this.selected=a},this.removeSelected=()=>{this.selected!==null&&(this.transControls.detach(),this.scene.remove(this.selected.mesh),this.pointCharges.splice(this.pointCharges.indexOf(this.selected),1),this.selected=null)},this.addEventListener=(a,o)=>{this.listeners.push({type:a,listener:o}),a==="object-change"&&this.transControls.addEventListener("objectChange",c=>{o(c.target.object)})},this.transControls=Gp(t,n,r,s),this.pointCharges=e,this.camera=t,this.dom=n,this.controls=r,this.scene=s,this.ray=new Ko,this.pointer=new Re,this.listeners=[],this.selected=null,this.onDownPosition=new Re,this.onUpPosition=new Re,this.setEvent()}}var ur=(i=>(i[i.Plus=0]="Plus",i[i.Minus=1]="Minus",i[i.Neutral=2]="Neutral",i))(ur||{});class us{constructor(e,t){this.chargeType=()=>this.charge>0?0:this.charge<0?1:2,this.mesh=e,this.charge=t,this.position=e.position}}const Wp=89875517923e-1,Xp=i=>{if(i<1)return[];if(i===1)return[];let e=0;const t=[];for(let n=1;n<=i;n++){const r=-1+2*(n-1)/(i-1),s=Math.acos(r);r*r===1?e=0:e=e+3.6/Math.sqrt(i)/Math.sqrt(1-r*r);const a=Math.sin(s),o=a*Math.cos(e),c=a*Math.sin(e),l=-Math.cos(s);t.push(new C(o,l,c))}return i>20&&(t[0]=new C().add(t[1]).add(t[2]).add(t[4]).add(t[5]).add(t[6]).normalize(),t[i-1]=new C().add(t[i-2]).add(t[i-3]).add(t[i-4]).add(t[i-5]).add(t[i-6]).normalize()),t},Yp=(i,e,t=Number.EPSILON)=>Math.abs(i.x-e.x){if(Yp(i,e.position))return new C;const t=new C;t.subVectors(i,e.position);const n=t.lengthSq()**2;return t.multiplyScalar(Wp*e.charge/n),t},$o=(i,e)=>{let t=new C;for(const n of e)t.add(qp(i,n));return t},jp=(i,e,t,n)=>{const r=[i.position.clone()],s=r[0].clone().add(t);for(;;){const a=$o(s,e).normalize();i.charge<0&&a.multiplyScalar(-1);for(const o of e)if(o!==i&&s.distanceToSquared(o.position)<.5)return r;if(s.add(a),s.lengthSq()>n**2)break;r.push(s.clone())}return r};class Zp extends st{constructor(e){super(),this.pointCharges=e,this.lineMaterial=new br({color:13421823}),this.coneGeometry=new Ar(1,3,10),this.coneMaterial=new an({color:11448014,opacity:1}),this.createELines()}createELines(){for(const e of this.pointCharges){if(e.charge===0)continue;const n=Xp(25);for(const r of n){const s=jp(e,this.pointCharges,r,300),a=new yt().setFromPoints(s),o=new Vt(a,this.lineMaterial);this.add(o);const c=s.length/3;for(let l=c;l+1{const t=(r,s)=>{const a=new an({color:16777215,transparent:!0,opacity:s}),o=new he(this.coneGeometry,a);o.position.copy(r);const c=$o(r,this.pointCharges);o.quaternion.setFromUnitVectors(new C(0,1,0),c.normalize()),this.add(o)};for(let r of this.pointCharges)if(r.charge!==0)for(let s=-4;s<=4;s++)for(let a=-4;a<=4;a++)for(let o=-4;o<=4;o++){const c=s**2+a**2+o**2;if(c>4**2||s===0&&a===0&&o===0)continue;const l=Math.abs(1-c/4**2);t(new C(s*20,a*20,o*20).add(r.position),l)}},this.pointCharges=e,this.coneGeometry=new Ar(1,5,10),this.createEFVectorGeometry()}update(){this.children=[],this.createEFVectorGeometry()}}class $p extends st{constructor(e){super(),this.update=()=>{var t,n;this.children.find(r=>r===this.electric_lines_3d)!=null&&((t=this.electric_lines_3d)==null||t.update()),this.children.find(r=>r===this.electric_field_vectors_3d)!=null&&((n=this.electric_field_vectors_3d)==null||n.update())},this.enableElectricLines=t=>{t?(this.electric_lines_3d==null?this.electric_lines_3d=new Zp(this.pointCharges):this.electric_lines_3d.update(),this.add(this.electric_lines_3d)):this.remove(this.electric_lines_3d)},this.enableElectricFieldVectors=t=>{t?(this.electric_field_vectors_3d==null&&(this.electric_field_vectors_3d=new Kp(this.pointCharges)),this.electric_field_vectors_3d.update(),this.add(this.electric_field_vectors_3d)):this.remove(this.electric_field_vectors_3d)},this.pointCharges=e,this.electric_lines_3d=null,this.electric_field_vectors_3d=null}}function Qp(i,e,t){var n=t||{},r=n.noTrailing,s=r===void 0?!1:r,a=n.noLeading,o=a===void 0?!1:a,c=n.debounceMode,l=c===void 0?void 0:c,h,d=!1,f=0;function m(){h&&clearTimeout(h)}function g(p){var u=p||{},S=u.upcomingOnly,v=S===void 0?!1:S;m(),d=!v}function _(){for(var p=arguments.length,u=new Array(p),S=0;Si?o?(f=Date.now(),s||(h=setTimeout(l?w:E,i))):E():s!==!0&&(h=setTimeout(l?w:E,l===void 0?i-T:i))}return _.cancel=g,_}const Jp=()=>{const i=document.getElementById("canvas"),e=Op(),t=Bp(i),n=zp(i),r=Hp(n,i);Vp(i,t,n);const s=[],a=new an({color:16711680}),o=new an({color:255}),c=new an({color:16776960}),l=new wr(2,32,32);{{const m=new he(l,a);m.position.set(-30,20,0),e.add(m),s.push(new us(m,1))}{const m=new he(l,o);m.position.set(30,0,0),e.add(m),s.push(new us(m,-1))}}const h=new $p(s),d=new kp(s,n,i,r,e);{document.getElementById("point_charge_position_x").addEventListener("input",E=>{const w=d.getSelected();w&&(w.position.x=Number(E.target.value)),h.update()}),document.getElementById("point_charge_position_y").addEventListener("input",E=>{const w=d.getSelected();w&&(w.position.y=Number(E.target.value)),h.update()}),document.getElementById("point_charge_position_z").addEventListener("input",E=>{const w=d.getSelected();w&&(w.position.z=Number(E.target.value)),h.update()});const m=(E,w)=>{switch(E.charge=w,E.chargeType()){case ur.Plus:E.mesh.material=a;break;case ur.Minus:E.mesh.material=o;break;case ur.Neutral:E.mesh.material=c;break}},g=(E,w)=>{switch(w){case"c":return E;case"uc":return E*1e-6;case"nc":return E*1e-9;case"pc":return E*1e-12;default:throw new Error("invalid unit")}},_=E=>{const w=Math.abs(E);return w>=.001?{value:E,unit:"c"}:w>=1e-6?{value:E*1e6,unit:"uc"}:w>=1e-9?{value:E*1e9,unit:"nc"}:{value:E*1e12,unit:"pc"}},p=document.getElementById("point_charge_charge_value"),u=document.getElementById("point_charge_unit"),S=()=>{const E=d.getSelected();E&&m(E,g(Number(p.value),u.value)),h.update()};p.addEventListener("input",S),u.addEventListener("change",S),d.addEventListener("object-change",Qp(50,h.update));const v=E=>{document.getElementById("point_charge_position_x").value=E.position.x.toFixed(2),document.getElementById("point_charge_position_y").value=E.position.y.toFixed(2),document.getElementById("point_charge_position_z").value=E.position.z.toFixed(2)},T=E=>{const{value:w,unit:R}=_(E.charge);p.value=w.toFixed(2),u.value=R};d.addEventListener("object-change",v),d.addEventListener("object-selected",E=>{v(E.mesh),T(E)}),d.addEventListener("object-selected",()=>{document.getElementById("settings_point_charge").style.display="block"}),d.addEventListener("object-unselected",()=>{document.getElementById("settings_point_charge").style.display="none"}),d.attach(s[0]),v(s[0].mesh),T(s[0])}{const m=new Ap(600,100,8947848,8947848);m.material.opacity=0,e.add(m);const g=p=>{m.visible=p},_=document.getElementById("checkbox_show_grid");g(_.checked),_.addEventListener("change",p=>{g(p.target.checked)})}{const m=document.getElementById("checkbox_auto_rotate");r.autoRotate=m.checked,m.addEventListener("change",g=>{r.autoRotate=g.target.checked})}{const m=document.getElementById("dimension_toggle_switch"),g=_=>{_?e.add(h):e.remove(h)};g(m.checked),m.addEventListener("change",_=>{g(_.target.checked)})}{const m=document.getElementById("checkbox_electric_lines");h.enableElectricLines(m.checked),m.addEventListener("change",g=>{h.enableElectricLines(g.target.checked)})}{const m=document.getElementById("checkbox_electric_field_vectors");h.enableElectricFieldVectors(m.checked),m.addEventListener("change",g=>{h.enableElectricFieldVectors(g.target.checked)})}document.getElementById("button_add_point_charge").addEventListener("click",()=>{const m=Math.random()>.5?1:-1,g=m>0?a:m<0?o:c,_=new he(l,g),p=Math.floor(Math.random()*100-50),u=Math.floor(Math.random()*100-50),S=Math.floor(Math.random()*100-50);_.position.set(p,u,S),e.add(_);const v=new us(_,m);s.push(v),d.attach(v),h.update()}),document.getElementById("button_remove_point_charge").addEventListener("click",()=>{d.getSelected()&&(d.removeSelected(),h.update())}),document.getElementById("button_remove_all_point_charges").addEventListener("click",()=>{for(let m of s)e.remove(m.mesh);s.splice(0,s.length),d.removeSelected(),h.update()});const f=()=>{requestAnimationFrame(f),t.render(e,n),r.update()};f()};window.addEventListener("load",()=>{Jp()}); diff --git a/index.html b/index.html index 54d77a4..5aab734 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ EFSim - +