@splinetool/runtime 0.9.122 → 0.9.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/runtime.cjs +2 -2
- package/build/runtime.js +2 -2
- package/package.json +1 -1
package/build/runtime.cjs
CHANGED
|
@@ -3136,7 +3136,7 @@ void main() {
|
|
|
3136
3136
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3137
3137
|
}`;function XB(r,e,t){let n=new gh,i=new k,s=new k,o=new Xe,a=new vh({depthPacking:Zy}),l=new _y,u={},c=t.maxTextureSize,h={0:xr,1:ti,2:pn},f=new wt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new k},radius:{value:4}},vertexShader:jB,fragmentShader:qB}),d=f.clone();d.defines.HORIZONTAL_PASS=1;let m=new Le;m.setAttribute("position",new We(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new fr(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=bp,this.render=function(S,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||S.length===0)return;let _=r.getRenderTarget(),x=r.getActiveCubeFace(),M=r.getActiveMipmapLevel(),E=r.state;E.setBlending(Ht),E.buffers.color.setClear(1,1,1,1),E.buffers.depth.setTest(!0),E.setScissorTest(!1);for(let C=0,P=S.length;C<P;C++){let L=S[C],D=L.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",L,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;i.copy(D.mapSize);let R=D.getFrameExtents();if(i.multiply(R),s.copy(D.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/R.x),i.x=s.x*R.x,D.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/R.y),i.y=s.y*R.y,D.mapSize.y=s.y)),D.map===null){let U=this.type!==sh?{minFilter:jt,magFilter:jt}:{};D.map=new xt(i.x,i.y,U),D.map.texture.name=L.name+".shadowMap",D.camera.updateProjectionMatrix()}r.setRenderTarget(D.map),r.clear();let N=D.getViewportCount();for(let U=0;U<N;U++){let X=D.getViewport(U);o.set(s.x*X.x,s.y*X.y,s.x*X.z,s.y*X.w),E.viewport(o),D.updateMatrices(L,U),n=D.getFrustum(),b(w,A,D.camera,L,this.type)}D.isPointLightShadow!==!0&&this.type===sh&&v(D,A),D.needsUpdate=!1}g.needsUpdate=!1,r.setRenderTarget(_,x,M)};function v(S,w){let A=e.update(p);f.defines.VSM_SAMPLES!==S.blurSamples&&(f.defines.VSM_SAMPLES=S.blurSamples,d.defines.VSM_SAMPLES=S.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new xt(i.x,i.y)),f.uniforms.shadow_pass.value=S.map.texture,f.uniforms.resolution.value=S.mapSize,f.uniforms.radius.value=S.radius,r.setRenderTarget(S.mapPass),r.clear(),r.renderBufferDirect(w,null,A,f,p,null),d.uniforms.shadow_pass.value=S.mapPass.texture,d.uniforms.resolution.value=S.mapSize,d.uniforms.radius.value=S.radius,r.setRenderTarget(S.map),r.clear(),r.renderBufferDirect(w,null,A,d,p,null)}function y(S,w,A,_,x,M){let E=null,C=A.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(C!==void 0?E=C:E=A.isPointLight===!0?l:a,r.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0){let P=E.uuid,L=w.uuid,D=u[P];D===void 0&&(D={},u[P]=D);let R=D[L];R===void 0&&(R=E.clone(),D[L]=R),E=R}return E.visible=w.visible,E.wireframe=w.wireframe,M===sh?E.side=w.shadowSide!==null?w.shadowSide:w.side:E.side=w.shadowSide!==null?w.shadowSide:h[w.side],E.alphaMap=w.alphaMap,E.alphaTest=w.alphaTest,E.clipShadows=w.clipShadows,E.clippingPlanes=w.clippingPlanes,E.clipIntersection=w.clipIntersection,E.displacementMap=w.displacementMap,E.displacementScale=w.displacementScale,E.displacementBias=w.displacementBias,E.wireframeLinewidth=w.wireframeLinewidth,E.linewidth=w.linewidth,A.isPointLight===!0&&E.isMeshDistanceMaterial===!0&&(E.referencePosition.setFromMatrixPosition(A.matrixWorld),E.nearDistance=_,E.farDistance=x),E}function b(S,w,A,_,x){if(S.visible===!1)return;if(S.layers.test(w.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&x===sh)&&(!S.frustumCulled||n.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,S.matrixWorld);let C=e.update(S),P=S.material;if(Array.isArray(P)){let L=C.groups;for(let D=0,R=L.length;D<R;D++){let N=L[D],U=P[N.materialIndex];if(U&&U.visible){let X=y(S,U,_,A.near,A.far,x);r.renderBufferDirect(A,null,C,X,S,N)}}}else if(P.visible){let L=y(S,P,_,A.near,A.far,x);r.renderBufferDirect(A,null,C,L,S,null)}}let E=S.children;for(let C=0,P=E.length;C<P;C++)b(E[C],w,A,_,x)}}function YB(r,e,t){let n=t.isWebGL2;function i(){let W=!1,be=new Xe,_e=null,et=new Xe(0,0,0,0);return{setMask:function(Fe){_e!==Fe&&!W&&(r.colorMask(Fe,Fe,Fe,Fe),_e=Fe)},setLocked:function(Fe){W=Fe},setClear:function(Fe,nt,Se,it,ht){ht===!0&&(Fe*=it,nt*=it,Se*=it),be.set(Fe,nt,Se,it),et.equals(be)===!1&&(r.clearColor(Fe,nt,Se,it),et.copy(be))},reset:function(){W=!1,_e=null,et.set(-1,0,0,0)}}}function s(){let W=!1,be=null,_e=null,et=null;return{setTest:function(Fe){Fe?Y(2929):H(2929)},setMask:function(Fe){be!==Fe&&!W&&(r.depthMask(Fe),be=Fe)},setFunc:function(Fe){if(_e!==Fe){if(Fe)switch(Fe){case AI:r.depthFunc(512);break;case TI:r.depthFunc(519);break;case _I:r.depthFunc(513);break;case cy:r.depthFunc(515);break;case MI:r.depthFunc(514);break;case EI:r.depthFunc(518);break;case CI:r.depthFunc(516);break;case PI:r.depthFunc(517);break;default:r.depthFunc(515)}else r.depthFunc(515);_e=Fe}},setLocked:function(Fe){W=Fe},setClear:function(Fe){et!==Fe&&(r.clearDepth(Fe),et=Fe)},reset:function(){W=!1,be=null,_e=null,et=null}}}function o(){let W=!1,be=null,_e=null,et=null,Fe=null,nt=null,Se=null,it=null,ht=null;return{setTest:function(Tt){W||(Tt?Y(2960):H(2960))},setMask:function(Tt){be!==Tt&&!W&&(r.stencilMask(Tt),be=Tt)},setFunc:function(Tt,Pt,An){(_e!==Tt||et!==Pt||Fe!==An)&&(r.stencilFunc(Tt,Pt,An),_e=Tt,et=Pt,Fe=An)},setOp:function(Tt,Pt,An){(nt!==Tt||Se!==Pt||it!==An)&&(r.stencilOp(Tt,Pt,An),nt=Tt,Se=Pt,it=An)},setLocked:function(Tt){W=Tt},setClear:function(Tt){ht!==Tt&&(r.clearStencil(Tt),ht=Tt)},reset:function(){W=!1,be=null,_e=null,et=null,Fe=null,nt=null,Se=null,it=null,ht=null}}}let a=new i,l=new s,u=new o,c={},h={},f=new WeakMap,d=[],m=null,p=!1,g=null,v=null,y=null,b=null,S=null,w=null,A=null,_=!1,x=null,M=null,E=null,C=null,P=null,L=r.getParameter(35661),D=!1,R=0,N=r.getParameter(7938);N.indexOf("WebGL")!==-1?(R=parseFloat(/^WebGL (\d)/.exec(N)[1]),D=R>=1):N.indexOf("OpenGL ES")!==-1&&(R=parseFloat(/^OpenGL ES (\d)/.exec(N)[1]),D=R>=2);let U=null,X={},F=r.getParameter(3088),G=r.getParameter(2978),j=new Xe().fromArray(F),z=new Xe().fromArray(G);function V(W,be,_e){let et=new Uint8Array(4),Fe=r.createTexture();r.bindTexture(W,Fe),r.texParameteri(W,10241,9728),r.texParameteri(W,10240,9728);for(let nt=0;nt<_e;nt++)r.texImage2D(be+nt,0,6408,1,1,0,6408,5121,et);return Fe}let q={};q[3553]=V(3553,3553,1),q[34067]=V(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),Y(2929),l.setFunc(cy),Me(!1),ge(HS),Y(2884),ue(Ht);function Y(W){c[W]!==!0&&(r.enable(W),c[W]=!0)}function H(W){c[W]!==!1&&(r.disable(W),c[W]=!1)}function fe(W,be){return h[W]!==be?(r.bindFramebuffer(W,be),h[W]=be,n&&(W===36009&&(h[36160]=be),W===36160&&(h[36009]=be)),!0):!1}function ne(W,be){let _e=d,et=!1;if(W)if(_e=f.get(be),_e===void 0&&(_e=[],f.set(be,_e)),W.isWebGLMultipleRenderTargets){let Fe=W.texture;if(_e.length!==Fe.length||_e[0]!==36064){for(let nt=0,Se=Fe.length;nt<Se;nt++)_e[nt]=36064+nt;_e.length=Fe.length,et=!0}}else _e[0]!==36064&&(_e[0]=36064,et=!0);else _e[0]!==1029&&(_e[0]=1029,et=!0);et&&(t.isWebGL2?r.drawBuffers(_e):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(_e))}function K(W){return m!==W?(r.useProgram(W),m=W,!0):!1}let Q={[Dl]:32774,[fI]:32778,[dI]:32779};if(n)Q[XS]=32775,Q[YS]=32776;else{let W=e.get("EXT_blend_minmax");W!==null&&(Q[XS]=W.MIN_EXT,Q[YS]=W.MAX_EXT)}let ie={[pI]:0,[mI]:1,[gI]:768,[w1]:770,[wI]:776,[bI]:774,[yI]:772,[vI]:769,[A1]:771,[SI]:775,[xI]:773};function ue(W,be,_e,et,Fe,nt,Se,it){if(W===Ht){p===!0&&(H(3042),p=!1);return}if(p===!1&&(Y(3042),p=!0),W!==hI){if(W!==g||it!==_){if((v!==Dl||S!==Dl)&&(r.blendEquation(32774),v=Dl,S=Dl),it)switch(W){case po:r.blendFuncSeparate(1,771,1,771);break;case WS:r.blendFunc(1,1);break;case jS:r.blendFuncSeparate(0,769,0,1);break;case qS:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",W);break}else switch(W){case po:r.blendFuncSeparate(770,771,1,771);break;case WS:r.blendFunc(770,1);break;case jS:r.blendFuncSeparate(0,769,0,1);break;case qS:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",W);break}y=null,b=null,w=null,A=null,g=W,_=it}return}Fe=Fe||be,nt=nt||_e,Se=Se||et,(be!==v||Fe!==S)&&(r.blendEquationSeparate(Q[be],Q[Fe]),v=be,S=Fe),(_e!==y||et!==b||nt!==w||Se!==A)&&(r.blendFuncSeparate(ie[_e],ie[et],ie[nt],ie[Se]),y=_e,b=et,w=nt,A=Se),g=W,_=null}function ae(W,be){W.side===pn?H(2884):Y(2884);let _e=W.side===xr;be&&(_e=!_e),Me(_e),W.blending===po&&W.transparent===!1?ue(Ht):ue(W.blending,W.blendEquation,W.blendSrc,W.blendDst,W.blendEquationAlpha,W.blendSrcAlpha,W.blendDstAlpha,W.premultipliedAlpha),l.setFunc(W.depthFunc),l.setTest(W.depthTest),l.setMask(W.depthWrite),a.setMask(W.colorWrite);let et=W.stencilWrite;u.setTest(et),et&&(u.setMask(W.stencilWriteMask),u.setFunc(W.stencilFunc,W.stencilRef,W.stencilFuncMask),u.setOp(W.stencilFail,W.stencilZFail,W.stencilZPass)),ye(W.polygonOffset,W.polygonOffsetFactor,W.polygonOffsetUnits),W.alphaToCoverage===!0?Y(32926):H(32926)}function Me(W){x!==W&&(W?r.frontFace(2304):r.frontFace(2305),x=W)}function ge(W){W!==lI?(Y(2884),W!==M&&(W===HS?r.cullFace(1029):W===cI?r.cullFace(1028):r.cullFace(1032))):H(2884),M=W}function ve(W){W!==E&&(D&&r.lineWidth(W),E=W)}function ye(W,be,_e){W?(Y(32823),(C!==be||P!==_e)&&(r.polygonOffset(be,_e),C=be,P=_e)):H(32823)}function de(W){W?Y(3089):H(3089)}function Ie(W){W===void 0&&(W=33984+L-1),U!==W&&(r.activeTexture(W),U=W)}function Ge(W,be){U===null&&Ie();let _e=X[U];_e===void 0&&(_e={type:void 0,texture:void 0},X[U]=_e),(_e.type!==W||_e.texture!==be)&&(r.bindTexture(W,be||q[W]),_e.type=W,_e.texture=be)}function tt(){let W=X[U];W!==void 0&&W.type!==void 0&&(r.bindTexture(W.type,null),W.type=void 0,W.texture=void 0)}function B(){try{r.compressedTexImage2D.apply(r,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function I(){try{r.texSubImage2D.apply(r,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function J(){try{r.texSubImage3D.apply(r,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function ce(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function pe(){try{r.texStorage2D.apply(r,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ce(){try{r.texStorage3D.apply(r,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function He(){try{r.texImage2D.apply(r,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function se(){try{r.texImage3D.apply(r,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ve(W){j.equals(W)===!1&&(r.scissor(W.x,W.y,W.z,W.w),j.copy(W))}function Ne(W){z.equals(W)===!1&&(r.viewport(W.x,W.y,W.z,W.w),z.copy(W))}function xe(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),c={},U=null,X={},h={},f=new WeakMap,d=[],m=null,p=!1,g=null,v=null,y=null,b=null,S=null,w=null,A=null,_=!1,x=null,M=null,E=null,C=null,P=null,j.set(0,0,r.canvas.width,r.canvas.height),z.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:Y,disable:H,bindFramebuffer:fe,drawBuffers:ne,useProgram:K,setBlending:ue,setMaterial:ae,setFlipSided:Me,setCullFace:ge,setLineWidth:ve,setPolygonOffset:ye,setScissorTest:de,activeTexture:Ie,bindTexture:Ge,unbindTexture:tt,compressedTexImage2D:B,texImage2D:He,texImage3D:se,texStorage2D:pe,texStorage3D:Ce,texSubImage2D:I,texSubImage3D:J,compressedTexSubImage2D:ce,scissor:Ve,viewport:Ne,reset:xe}}function QB(r,e,t,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,c=i.maxTextureSize,h=i.maxSamples,f=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,d=/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(B,I){return v?new OffscreenCanvas(B,I):rp("canvas")}function b(B,I,J,ce){let pe=1;if((B.width>ce||B.height>ce)&&(pe=ce/Math.max(B.width,B.height)),pe<1||I===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){let Ce=I?tp:Math.floor,He=Ce(pe*B.width),se=Ce(pe*B.height);p===void 0&&(p=y(He,se));let Ve=J?y(He,se):p;return Ve.width=He,Ve.height=se,Ve.getContext("2d").drawImage(B,0,0,He,se),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+He+"x"+se+")."),Ve}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+B.width+"x"+B.height+")."),B;return B}function S(B){return my(B.width)&&my(B.height)}function w(B){return a?!1:B.wrapS!==dn||B.wrapT!==dn||B.minFilter!==jt&&B.minFilter!==pt}function A(B,I){return B.generateMipmaps&&I&&B.minFilter!==jt&&B.minFilter!==pt}function _(B){r.generateMipmap(B)}function x(B,I,J,ce,pe=!1){if(a===!1)return I;if(B!==null){if(r[B]!==void 0)return r[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let Ce=I;return I===6403&&(J===5126&&(Ce=33326),J===5131&&(Ce=33325),J===5121&&(Ce=33321)),I===33319&&(J===5126&&(Ce=33328),J===5131&&(Ce=33327),J===5121&&(Ce=33323)),I===6408&&(J===5126&&(Ce=34836),J===5131&&(Ce=34842),J===5121&&(Ce=ce===Ke&&pe===!1?35907:32856),J===32819&&(Ce=32854),J===32820&&(Ce=32855)),(Ce===33325||Ce===33326||Ce===33327||Ce===33328||Ce===34842||Ce===34836)&&e.get("EXT_color_buffer_float"),Ce}function M(B,I,J){return A(B,J)===!0||B.isFramebufferTexture&&B.minFilter!==jt&&B.minFilter!==pt?Math.log2(Math.max(I.width,I.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?I.mipmaps.length:1}function E(B){return B===jt||B===QS||B===ZS?9728:9729}function C(B){let I=B.target;I.removeEventListener("dispose",C),L(I),I.isVideoTexture&&m.delete(I)}function P(B){let I=B.target;I.removeEventListener("dispose",P),R(I)}function L(B){let I=n.get(B);if(I.__webglInit===void 0)return;let J=B.source,ce=g.get(J);if(ce){let pe=ce[I.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&D(B),Object.keys(ce).length===0&&g.delete(J)}n.remove(B)}function D(B){let I=n.get(B);r.deleteTexture(I.__webglTexture);let J=B.source,ce=g.get(J);delete ce[I.__cacheKey],o.memory.textures--}function R(B){let I=B.texture,J=n.get(B),ce=n.get(I);if(ce.__webglTexture!==void 0&&(r.deleteTexture(ce.__webglTexture),o.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++)r.deleteFramebuffer(J.__webglFramebuffer[pe]),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer[pe]);else{if(r.deleteFramebuffer(J.__webglFramebuffer),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&r.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer)for(let pe=0;pe<J.__webglColorRenderbuffer.length;pe++)J.__webglColorRenderbuffer[pe]&&r.deleteRenderbuffer(J.__webglColorRenderbuffer[pe]);J.__webglDepthRenderbuffer&&r.deleteRenderbuffer(J.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let pe=0,Ce=I.length;pe<Ce;pe++){let He=n.get(I[pe]);He.__webglTexture&&(r.deleteTexture(He.__webglTexture),o.memory.textures--),n.remove(I[pe])}n.remove(I),n.remove(B)}let N=0;function U(){N=0}function X(){let B=N;return B>=l&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+l),N+=1,B}function F(B){let I=[];return I.push(B.wrapS),I.push(B.wrapT),I.push(B.magFilter),I.push(B.minFilter),I.push(B.anisotropy),I.push(B.internalFormat),I.push(B.format),I.push(B.type),I.push(B.generateMipmaps),I.push(B.premultiplyAlpha),I.push(B.flipY),I.push(B.unpackAlignment),I.push(B.encoding),I.join()}function G(B,I){let J=n.get(B);if(B.isVideoTexture&&Ge(B),B.isRenderTargetTexture===!1&&B.version>0&&J.__version!==B.version){let ce=B.image;if(ce===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ce.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ne(J,B,I);return}}t.activeTexture(33984+I),t.bindTexture(3553,J.__webglTexture)}function j(B,I){let J=n.get(B);if(B.version>0&&J.__version!==B.version){ne(J,B,I);return}t.activeTexture(33984+I),t.bindTexture(35866,J.__webglTexture)}function z(B,I){let J=n.get(B);if(B.version>0&&J.__version!==B.version){ne(J,B,I);return}t.activeTexture(33984+I),t.bindTexture(32879,J.__webglTexture)}function V(B,I){let J=n.get(B);if(B.version>0&&J.__version!==B.version){K(J,B,I);return}t.activeTexture(33984+I),t.bindTexture(34067,J.__webglTexture)}let q={[Rl]:10497,[dn]:33071,[fy]:33648},Y={[jt]:9728,[QS]:9984,[ZS]:9986,[pt]:9729,[FI]:9985,[ec]:9987};function H(B,I,J){if(J?(r.texParameteri(B,10242,q[I.wrapS]),r.texParameteri(B,10243,q[I.wrapT]),(B===32879||B===35866)&&r.texParameteri(B,32882,q[I.wrapR]),r.texParameteri(B,10240,Y[I.magFilter]),r.texParameteri(B,10241,Y[I.minFilter])):(r.texParameteri(B,10242,33071),r.texParameteri(B,10243,33071),(B===32879||B===35866)&&r.texParameteri(B,32882,33071),(I.wrapS!==dn||I.wrapT!==dn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(B,10240,E(I.magFilter)),r.texParameteri(B,10241,E(I.minFilter)),I.minFilter!==jt&&I.minFilter!==pt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let ce=e.get("EXT_texture_filter_anisotropic");if(I.type===Ki&&e.has("OES_texture_float_linear")===!1||a===!1&&I.type===fh&&e.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||n.get(I).__currentAnisotropy)&&(r.texParameterf(B,ce.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),n.get(I).__currentAnisotropy=I.anisotropy)}}function fe(B,I){let J=!1;B.__webglInit===void 0&&(B.__webglInit=!0,I.addEventListener("dispose",C));let ce=I.source,pe=g.get(ce);pe===void 0&&(pe={},g.set(ce,pe));let Ce=F(I);if(Ce!==B.__cacheKey){pe[Ce]===void 0&&(pe[Ce]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,J=!0),pe[Ce].usedTimes++;let He=pe[B.__cacheKey];He!==void 0&&(pe[B.__cacheKey].usedTimes--,He.usedTimes===0&&D(I)),B.__cacheKey=Ce,B.__webglTexture=pe[Ce].texture}return J}function ne(B,I,J){let ce=3553;I.isDataArrayTexture&&(ce=35866),I.isData3DTexture&&(ce=32879);let pe=fe(B,I),Ce=I.source;if(t.activeTexture(33984+J),t.bindTexture(ce,B.__webglTexture),Ce.version!==Ce.__currentVersion||pe===!0){r.pixelStorei(37440,I.flipY),r.pixelStorei(37441,I.premultiplyAlpha),r.pixelStorei(3317,I.unpackAlignment),r.pixelStorei(37443,0);let He=w(I)&&S(I.image)===!1,se=b(I.image,He,!1,c);se=tt(I,se);let Ve=S(se)||a,Ne=s.convert(I.format,I.encoding),xe=s.convert(I.type),W=x(I.internalFormat,Ne,xe,I.encoding,I.isVideoTexture);H(ce,I,Ve);let be,_e=I.mipmaps,et=a&&I.isVideoTexture!==!0,Fe=Ce.__currentVersion===void 0||pe===!0,nt=M(I,se,Ve);if(I.isDepthTexture)W=6402,a?I.type===Ki?W=36012:I.type===Us?W=33190:I.type===mo?W=35056:W=33189:I.type===Ki&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===xa&&W===6402&&I.type!==M1&&I.type!==Us&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=Us,xe=s.convert(I.type)),I.format===yo&&W===6402&&(W=34041,I.type!==mo&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=mo,xe=s.convert(I.type))),Fe&&(et?t.texStorage2D(3553,1,W,se.width,se.height):t.texImage2D(3553,0,W,se.width,se.height,0,Ne,xe,null));else if(I.isDataTexture)if(_e.length>0&&Ve){et&&Fe&&t.texStorage2D(3553,nt,W,_e[0].width,_e[0].height);for(let Se=0,it=_e.length;Se<it;Se++)be=_e[Se],et?t.texSubImage2D(3553,Se,0,0,be.width,be.height,Ne,xe,be.data):t.texImage2D(3553,Se,W,be.width,be.height,0,Ne,xe,be.data);I.generateMipmaps=!1}else et?(Fe&&t.texStorage2D(3553,nt,W,se.width,se.height),t.texSubImage2D(3553,0,0,0,se.width,se.height,Ne,xe,se.data)):t.texImage2D(3553,0,W,se.width,se.height,0,Ne,xe,se.data);else if(I.isCompressedTexture){et&&Fe&&t.texStorage2D(3553,nt,W,_e[0].width,_e[0].height);for(let Se=0,it=_e.length;Se<it;Se++)be=_e[Se],I.format!==Ai?Ne!==null?et?t.compressedTexSubImage2D(3553,Se,0,0,be.width,be.height,Ne,be.data):t.compressedTexImage2D(3553,Se,W,be.width,be.height,0,be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):et?t.texSubImage2D(3553,Se,0,0,be.width,be.height,Ne,xe,be.data):t.texImage2D(3553,Se,W,be.width,be.height,0,Ne,xe,be.data)}else if(I.isDataArrayTexture)et?(Fe&&t.texStorage3D(35866,nt,W,se.width,se.height,se.depth),t.texSubImage3D(35866,0,0,0,0,se.width,se.height,se.depth,Ne,xe,se.data)):t.texImage3D(35866,0,W,se.width,se.height,se.depth,0,Ne,xe,se.data);else if(I.isData3DTexture)et?(Fe&&t.texStorage3D(32879,nt,W,se.width,se.height,se.depth),t.texSubImage3D(32879,0,0,0,0,se.width,se.height,se.depth,Ne,xe,se.data)):t.texImage3D(32879,0,W,se.width,se.height,se.depth,0,Ne,xe,se.data);else if(I.isFramebufferTexture){if(Fe)if(et)t.texStorage2D(3553,nt,W,se.width,se.height);else{let Se=se.width,it=se.height;for(let ht=0;ht<nt;ht++)t.texImage2D(3553,ht,W,Se,it,0,Ne,xe,null),Se>>=1,it>>=1}}else if(_e.length>0&&Ve){et&&Fe&&t.texStorage2D(3553,nt,W,_e[0].width,_e[0].height);for(let Se=0,it=_e.length;Se<it;Se++)be=_e[Se],et?t.texSubImage2D(3553,Se,0,0,Ne,xe,be):t.texImage2D(3553,Se,W,Ne,xe,be);I.generateMipmaps=!1}else et?(Fe&&t.texStorage2D(3553,nt,W,se.width,se.height),t.texSubImage2D(3553,0,0,0,Ne,xe,se)):t.texImage2D(3553,0,W,Ne,xe,se);A(I,Ve)&&_(ce),Ce.__currentVersion=Ce.version,I.onUpdate&&I.onUpdate(I)}B.__version=I.version}function K(B,I,J){if(I.image.length!==6)return;let ce=fe(B,I),pe=I.source;if(t.activeTexture(33984+J),t.bindTexture(34067,B.__webglTexture),pe.version!==pe.__currentVersion||ce===!0){r.pixelStorei(37440,I.flipY),r.pixelStorei(37441,I.premultiplyAlpha),r.pixelStorei(3317,I.unpackAlignment),r.pixelStorei(37443,0);let Ce=I.isCompressedTexture||I.image[0].isCompressedTexture,He=I.image[0]&&I.image[0].isDataTexture,se=[];for(let Se=0;Se<6;Se++)!Ce&&!He?se[Se]=b(I.image[Se],!1,!0,u):se[Se]=He?I.image[Se].image:I.image[Se],se[Se]=tt(I,se[Se]);let Ve=se[0],Ne=S(Ve)||a,xe=s.convert(I.format,I.encoding),W=s.convert(I.type),be=x(I.internalFormat,xe,W,I.encoding),_e=a&&I.isVideoTexture!==!0,et=pe.__currentVersion===void 0||ce===!0,Fe=M(I,Ve,Ne);H(34067,I,Ne);let nt;if(Ce){_e&&et&&t.texStorage2D(34067,Fe,be,Ve.width,Ve.height);for(let Se=0;Se<6;Se++){nt=se[Se].mipmaps;for(let it=0;it<nt.length;it++){let ht=nt[it];I.format!==Ai?xe!==null?_e?t.compressedTexSubImage2D(34069+Se,it,0,0,ht.width,ht.height,xe,ht.data):t.compressedTexImage2D(34069+Se,it,be,ht.width,ht.height,0,ht.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_e?t.texSubImage2D(34069+Se,it,0,0,ht.width,ht.height,xe,W,ht.data):t.texImage2D(34069+Se,it,be,ht.width,ht.height,0,xe,W,ht.data)}}}else{nt=I.mipmaps,_e&&et&&(nt.length>0&&Fe++,t.texStorage2D(34067,Fe,be,se[0].width,se[0].height));for(let Se=0;Se<6;Se++)if(He){_e?t.texSubImage2D(34069+Se,0,0,0,se[Se].width,se[Se].height,xe,W,se[Se].data):t.texImage2D(34069+Se,0,be,se[Se].width,se[Se].height,0,xe,W,se[Se].data);for(let it=0;it<nt.length;it++){let Tt=nt[it].image[Se].image;_e?t.texSubImage2D(34069+Se,it+1,0,0,Tt.width,Tt.height,xe,W,Tt.data):t.texImage2D(34069+Se,it+1,be,Tt.width,Tt.height,0,xe,W,Tt.data)}}else{_e?t.texSubImage2D(34069+Se,0,0,0,xe,W,se[Se]):t.texImage2D(34069+Se,0,be,xe,W,se[Se]);for(let it=0;it<nt.length;it++){let ht=nt[it];_e?t.texSubImage2D(34069+Se,it+1,0,0,xe,W,ht.image[Se]):t.texImage2D(34069+Se,it+1,be,xe,W,ht.image[Se])}}}A(I,Ne)&&_(34067),pe.__currentVersion=pe.version,I.onUpdate&&I.onUpdate(I)}B.__version=I.version}function Q(B,I,J,ce,pe){let Ce=s.convert(J.format,J.encoding),He=s.convert(J.type),se=x(J.internalFormat,Ce,He,J.encoding);n.get(I).__hasExternalTextures||(pe===32879||pe===35866?t.texImage3D(pe,0,se,I.width,I.height,I.depth,0,Ce,He,null):t.texImage2D(pe,0,se,I.width,I.height,0,Ce,He,null)),t.bindFramebuffer(36160,B),Ie(I)?f.framebufferTexture2DMultisampleEXT(36160,ce,pe,n.get(J).__webglTexture,0,de(I)):r.framebufferTexture2D(36160,ce,pe,n.get(J).__webglTexture,0),t.bindFramebuffer(36160,null)}function ie(B,I,J){if(r.bindRenderbuffer(36161,B),I.depthBuffer&&!I.stencilBuffer){let ce=33189;if(J||Ie(I)){let pe=I.depthTexture;pe&&pe.isDepthTexture&&(pe.type===Ki?ce=36012:pe.type===Us&&(ce=33190));let Ce=de(I);Ie(I)?f.renderbufferStorageMultisampleEXT(36161,Ce,ce,I.width,I.height):r.renderbufferStorageMultisample(36161,Ce,ce,I.width,I.height)}else r.renderbufferStorage(36161,ce,I.width,I.height);r.framebufferRenderbuffer(36160,36096,36161,B)}else if(I.depthBuffer&&I.stencilBuffer){let ce=de(I);J&&Ie(I)===!1?r.renderbufferStorageMultisample(36161,ce,35056,I.width,I.height):Ie(I)?f.renderbufferStorageMultisampleEXT(36161,ce,35056,I.width,I.height):r.renderbufferStorage(36161,34041,I.width,I.height),r.framebufferRenderbuffer(36160,33306,36161,B)}else{let ce=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let pe=0;pe<ce.length;pe++){let Ce=ce[pe],He=s.convert(Ce.format,Ce.encoding),se=s.convert(Ce.type),Ve=x(Ce.internalFormat,He,se,Ce.encoding),Ne=de(I);J&&Ie(I)===!1?r.renderbufferStorageMultisample(36161,Ne,Ve,I.width,I.height):Ie(I)?f.renderbufferStorageMultisampleEXT(36161,Ne,Ve,I.width,I.height):r.renderbufferStorage(36161,Ve,I.width,I.height)}}r.bindRenderbuffer(36161,null)}function ue(B,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,B),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),G(I.depthTexture,0);let ce=n.get(I.depthTexture).__webglTexture,pe=de(I);if(I.depthTexture.format===xa)Ie(I)?f.framebufferTexture2DMultisampleEXT(36160,36096,3553,ce,0,pe):r.framebufferTexture2D(36160,36096,3553,ce,0);else if(I.depthTexture.format===yo)Ie(I)?f.framebufferTexture2DMultisampleEXT(36160,33306,3553,ce,0,pe):r.framebufferTexture2D(36160,33306,3553,ce,0);else throw new Error("Unknown depthTexture format")}function ae(B){let I=n.get(B),J=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!I.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");ue(I.__webglFramebuffer,B)}else if(J){I.__webglDepthbuffer=[];for(let ce=0;ce<6;ce++)t.bindFramebuffer(36160,I.__webglFramebuffer[ce]),I.__webglDepthbuffer[ce]=r.createRenderbuffer(),ie(I.__webglDepthbuffer[ce],B,!1)}else t.bindFramebuffer(36160,I.__webglFramebuffer),I.__webglDepthbuffer=r.createRenderbuffer(),ie(I.__webglDepthbuffer,B,!1);t.bindFramebuffer(36160,null)}function Me(B,I,J){let ce=n.get(B);I!==void 0&&Q(ce.__webglFramebuffer,B,B.texture,36064,3553),J!==void 0&&ae(B)}function ge(B){let I=B.texture,J=n.get(B),ce=n.get(I);B.addEventListener("dispose",P),B.isWebGLMultipleRenderTargets!==!0&&(ce.__webglTexture===void 0&&(ce.__webglTexture=r.createTexture()),ce.__version=I.version,o.memory.textures++);let pe=B.isWebGLCubeRenderTarget===!0,Ce=B.isWebGLMultipleRenderTargets===!0,He=S(B)||a;if(pe){J.__webglFramebuffer=[];for(let se=0;se<6;se++)J.__webglFramebuffer[se]=r.createFramebuffer()}else{if(J.__webglFramebuffer=r.createFramebuffer(),Ce)if(i.drawBuffers){let se=B.texture;for(let Ve=0,Ne=se.length;Ve<Ne;Ve++){let xe=n.get(se[Ve]);xe.__webglTexture===void 0&&(xe.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&B.samples>0&&Ie(B)===!1){let se=Ce?I:[I];J.__webglMultisampledFramebuffer=r.createFramebuffer(),J.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,J.__webglMultisampledFramebuffer);for(let Ve=0;Ve<se.length;Ve++){let Ne=se[Ve];J.__webglColorRenderbuffer[Ve]=r.createRenderbuffer(),r.bindRenderbuffer(36161,J.__webglColorRenderbuffer[Ve]);let xe=s.convert(Ne.format,Ne.encoding),W=s.convert(Ne.type),be=x(Ne.internalFormat,xe,W,Ne.encoding),_e=de(B);r.renderbufferStorageMultisample(36161,_e,be,B.width,B.height),r.framebufferRenderbuffer(36160,36064+Ve,36161,J.__webglColorRenderbuffer[Ve])}r.bindRenderbuffer(36161,null),B.depthBuffer&&(J.__webglDepthRenderbuffer=r.createRenderbuffer(),ie(J.__webglDepthRenderbuffer,B,!0)),t.bindFramebuffer(36160,null)}}if(pe){t.bindTexture(34067,ce.__webglTexture),H(34067,I,He);for(let se=0;se<6;se++)Q(J.__webglFramebuffer[se],B,I,36064,34069+se);A(I,He)&&_(34067),t.unbindTexture()}else if(Ce){let se=B.texture;for(let Ve=0,Ne=se.length;Ve<Ne;Ve++){let xe=se[Ve],W=n.get(xe);t.bindTexture(3553,W.__webglTexture),H(3553,xe,He),Q(J.__webglFramebuffer,B,xe,36064+Ve,3553),A(xe,He)&&_(3553)}t.unbindTexture()}else{let se=3553;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(a?se=B.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(se,ce.__webglTexture),H(se,I,He),Q(J.__webglFramebuffer,B,I,36064,se),A(I,He)&&_(se),t.unbindTexture()}B.depthBuffer&&ae(B)}function ve(B){let I=S(B)||a,J=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let ce=0,pe=J.length;ce<pe;ce++){let Ce=J[ce];if(A(Ce,I)){let He=B.isWebGLCubeRenderTarget?34067:3553,se=n.get(Ce).__webglTexture;t.bindTexture(He,se),_(He),t.unbindTexture()}}}function ye(B){if(a&&B.samples>0&&Ie(B)===!1){let I=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],J=B.width,ce=B.height,pe=16384,Ce=[],He=B.stencilBuffer?33306:36096,se=n.get(B),Ve=B.isWebGLMultipleRenderTargets===!0;if(Ve)for(let Ne=0;Ne<I.length;Ne++)t.bindFramebuffer(36160,se.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Ne,36161,null),t.bindFramebuffer(36160,se.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Ne,3553,null,0);t.bindFramebuffer(36008,se.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,se.__webglFramebuffer);for(let Ne=0;Ne<I.length;Ne++){Ce.push(36064+Ne),B.depthBuffer&&Ce.push(He);let xe=se.__ignoreDepthValues!==void 0?se.__ignoreDepthValues:!1;if(xe===!1&&(B.depthBuffer&&(pe|=256),B.stencilBuffer&&(pe|=1024)),Ve&&r.framebufferRenderbuffer(36008,36064,36161,se.__webglColorRenderbuffer[Ne]),xe===!0&&(r.invalidateFramebuffer(36008,[He]),r.invalidateFramebuffer(36009,[He])),Ve){let W=n.get(I[Ne]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,W,0)}r.blitFramebuffer(0,0,J,ce,0,0,J,ce,pe,9728),d&&r.invalidateFramebuffer(36008,Ce)}if(t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,null),Ve)for(let Ne=0;Ne<I.length;Ne++){t.bindFramebuffer(36160,se.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Ne,36161,se.__webglColorRenderbuffer[Ne]);let xe=n.get(I[Ne]).__webglTexture;t.bindFramebuffer(36160,se.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Ne,3553,xe,0)}t.bindFramebuffer(36009,se.__webglMultisampledFramebuffer)}}function de(B){return Math.min(h,B.samples)}function Ie(B){let I=n.get(B);return a&&B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Ge(B){let I=o.render.frame;m.get(B)!==I&&(m.set(B,I),B.update())}function tt(B,I){let J=B.encoding,ce=B.format,pe=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===py||J!==Gn&&(J===Ke?a===!1?e.has("EXT_sRGB")===!0&&ce===Ai?(B.format=py,B.minFilter=pt,B.generateMipmaps=!1):I=np.sRGBToLinear(I):(ce!==Ai||pe!==qt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",J)),I}this.allocateTextureUnit=X,this.resetTextureUnits=U,this.setTexture2D=G,this.setTexture2DArray=j,this.setTexture3D=z,this.setTextureCube=V,this.rebindTextures=Me,this.setupRenderTarget=ge,this.updateRenderTargetMipmap=ve,this.updateMultisampleRenderTarget=ye,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=Q,this.useMultisampledRTT=Ie}function ZB(r,e,t){let n=t.isWebGL2;function i(s,o=null){let a;if(s===qt)return 5121;if(s===zI)return 32819;if(s===VI)return 32820;if(s===kI)return 5120;if(s===UI)return 5122;if(s===M1)return 5123;if(s===GI)return 5124;if(s===Us)return 5125;if(s===Ki)return 5126;if(s===fh)return n?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===HI)return 6406;if(s===Ai)return 6408;if(s===jI)return 6409;if(s===qI)return 6410;if(s===xa)return 6402;if(s===yo)return 34041;if(s===XI)return 6403;if(s===WI)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===py)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===YI)return 36244;if(s===QI)return 33319;if(s===ZI)return 33320;if(s===KI)return 36249;if(s===Ev||s===Cv||s===Pv||s===Dv)if(o===Ke)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Ev)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Cv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Pv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Dv)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Ev)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Cv)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Pv)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Dv)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===KS||s===JS||s===$S||s===ew)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===KS)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===JS)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===$S)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===ew)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===JI)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===tw||s===rw)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===tw)return o===Ke?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===rw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===nw||s===iw||s===sw||s===ow||s===aw||s===lw||s===cw||s===uw||s===hw||s===fw||s===dw||s===pw||s===mw||s===gw)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===nw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===iw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===sw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===ow)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===aw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===lw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===cw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===uw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===hw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===fw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===dw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===pw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===mw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===gw)return o===Ke?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===vw)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===vw)return o===Ke?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===mo?n?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}var My=class extends hr{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},fo=class extends yt{constructor(){super(),this.isGroup=!0,this.type="Group"}},KB={type:"move"},ch=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new fo,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 fo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new T,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new T),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new fo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new T,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new T),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}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 i=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(let p of e.hand.values()){let g=t.getJointPose(p,n);if(u.joints[p.jointName]===void 0){let y=new fo;y.matrixAutoUpdate=!1,y.visible=!1,u.joints[p.jointName]=y,u.add(y)}let v=u.joints[p.jointName];g!==null&&(v.matrix.fromArray(g.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.jointRadius=g.radius),v.visible=g!==null}let c=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],f=c.position.distanceTo(h.position),d=.02,m=.005;u.inputState.pinching&&f>d+m?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&f<=d-m&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(KB)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}},bo=class extends er{constructor(e,t,n,i,s,o,a,l,u,c){if(c=c!==void 0?c:xa,c!==xa&&c!==yo)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===xa&&(n=Us),n===void 0&&c===yo&&(n=mo),super(null,i,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:jt,this.minFilter=l!==void 0?l:jt,this.flipY=!1,this.generateMipmaps=!1}},Ey=class extends kt{constructor(e,t){super();let n=this,i=null,s=1,o=null,a="local-floor",l=null,u=null,c=null,h=null,f=null,d=null,m=t.getContextAttributes(),p=null,g=null,v=[],y=[],b=new hr;b.layers.enable(1),b.viewport=new Xe;let S=new hr;S.layers.enable(2),S.viewport=new Xe;let w=[b,S],A=new My;A.layers.enable(1),A.layers.enable(2);let _=null,x=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(F){let G=v[F];return G===void 0&&(G=new ch,v[F]=G),G.getTargetRaySpace()},this.getControllerGrip=function(F){let G=v[F];return G===void 0&&(G=new ch,v[F]=G),G.getGripSpace()},this.getHand=function(F){let G=v[F];return G===void 0&&(G=new ch,v[F]=G),G.getHandSpace()};function M(F){let G=y.indexOf(F.inputSource);if(G===-1)return;let j=v[G];j!==void 0&&j.dispatchEvent({type:F.type,data:F.inputSource})}function E(){i.removeEventListener("select",M),i.removeEventListener("selectstart",M),i.removeEventListener("selectend",M),i.removeEventListener("squeeze",M),i.removeEventListener("squeezestart",M),i.removeEventListener("squeezeend",M),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",C);for(let F=0;F<v.length;F++){let G=y[F];G!==null&&(y[F]=null,v[F].disconnect(G))}_=null,x=null,e.setRenderTarget(p),f=null,h=null,c=null,i=null,g=null,X.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(F){s=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(F){a=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(F){l=F},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return c},this.getFrame=function(){return d},this.getSession=function(){return i},this.setSession=async function(F){if(i=F,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",M),i.addEventListener("selectstart",M),i.addEventListener("selectend",M),i.addEventListener("squeeze",M),i.addEventListener("squeezestart",M),i.addEventListener("squeezeend",M),i.addEventListener("end",E),i.addEventListener("inputsourceschange",C),m.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let G={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(i,t,G),i.updateRenderState({baseLayer:f}),g=new xt(f.framebufferWidth,f.framebufferHeight,{format:Ai,type:qt,encoding:e.outputEncoding})}else{let G=null,j=null,z=null;m.depth&&(z=m.stencil?35056:33190,G=m.stencil?yo:xa,j=m.stencil?mo:Us);let V={colorFormat:32856,depthFormat:z,scaleFactor:s};c=new XRWebGLBinding(i,t),h=c.createProjectionLayer(V),i.updateRenderState({layers:[h]}),g=new xt(h.textureWidth,h.textureHeight,{format:Ai,type:qt,depthTexture:new bo(h.textureWidth,h.textureHeight,j,void 0,void 0,void 0,void 0,void 0,void 0,G),stencilBuffer:m.stencil,encoding:e.outputEncoding,samples:m.antialias?4:0});let q=e.properties.get(g);q.__ignoreDepthValues=h.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(1),l=null,o=await i.requestReferenceSpace(a),X.setContext(i),X.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function C(F){for(let G=0;G<F.removed.length;G++){let j=F.removed[G],z=y.indexOf(j);z>=0&&(y[z]=null,v[z].dispatchEvent({type:"disconnected",data:j}))}for(let G=0;G<F.added.length;G++){let j=F.added[G],z=y.indexOf(j);if(z===-1){for(let q=0;q<v.length;q++)if(q>=y.length){y.push(j),z=q;break}else if(y[q]===null){y[q]=j,z=q;break}if(z===-1)break}let V=v[z];V&&V.dispatchEvent({type:"connected",data:j})}}let P=new T,L=new T;function D(F,G,j){P.setFromMatrixPosition(G.matrixWorld),L.setFromMatrixPosition(j.matrixWorld);let z=P.distanceTo(L),V=G.projectionMatrix.elements,q=j.projectionMatrix.elements,Y=V[14]/(V[10]-1),H=V[14]/(V[10]+1),fe=(V[9]+1)/V[5],ne=(V[9]-1)/V[5],K=(V[8]-1)/V[0],Q=(q[8]+1)/q[0],ie=Y*K,ue=Y*Q,ae=z/(-K+Q),Me=ae*-K;G.matrixWorld.decompose(F.position,F.quaternion,F.scale),F.translateX(Me),F.translateZ(ae),F.matrixWorld.compose(F.position,F.quaternion,F.scale),F.matrixWorldInverse.copy(F.matrixWorld).invert();let ge=Y+ae,ve=H+ae,ye=ie-Me,de=ue+(z-Me),Ie=fe*H/ve*ge,Ge=ne*H/ve*ge;F.projectionMatrix.makePerspective(ye,de,Ie,Ge,ge,ve)}function R(F,G){G===null?F.matrixWorld.copy(F.matrix):F.matrixWorld.multiplyMatrices(G.matrixWorld,F.matrix),F.matrixWorldInverse.copy(F.matrixWorld).invert()}this.updateCamera=function(F){if(i===null)return;A.near=S.near=b.near=F.near,A.far=S.far=b.far=F.far,(_!==A.near||x!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),_=A.near,x=A.far);let G=F.parent,j=A.cameras;R(A,G);for(let V=0;V<j.length;V++)R(j[V],G);A.matrixWorld.decompose(A.position,A.quaternion,A.scale),F.position.copy(A.position),F.quaternion.copy(A.quaternion),F.scale.copy(A.scale),F.matrix.copy(A.matrix),F.matrixWorld.copy(A.matrixWorld);let z=F.children;for(let V=0,q=z.length;V<q;V++)z[V].updateMatrixWorld(!0);j.length===2?D(A,b,S):A.projectionMatrix.copy(b.projectionMatrix)},this.getCamera=function(){return A},this.getFoveation=function(){if(h!==null)return h.fixedFoveation;if(f!==null)return f.fixedFoveation},this.setFoveation=function(F){h!==null&&(h.fixedFoveation=F),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=F)};let N=null;function U(F,G){if(u=G.getViewerPose(l||o),d=G,u!==null){let j=u.views;f!==null&&(e.setRenderTargetFramebuffer(g,f.framebuffer),e.setRenderTarget(g));let z=!1;j.length!==A.cameras.length&&(A.cameras.length=0,z=!0);for(let V=0;V<j.length;V++){let q=j[V],Y=null;if(f!==null)Y=f.getViewport(q);else{let fe=c.getViewSubImage(h,q);Y=fe.viewport,V===0&&(e.setRenderTargetTextures(g,fe.colorTexture,h.ignoreDepthValues?void 0:fe.depthStencilTexture),e.setRenderTarget(g))}let H=w[V];H===void 0&&(H=new hr,H.layers.enable(V),H.viewport=new Xe,w[V]=H),H.matrix.fromArray(q.transform.matrix),H.projectionMatrix.fromArray(q.projectionMatrix),H.viewport.set(Y.x,Y.y,Y.width,Y.height),V===0&&A.matrix.copy(H.matrix),z===!0&&A.cameras.push(H)}}for(let j=0;j<v.length;j++){let z=y[j],V=v[j];z!==null&&V!==void 0&&V.update(z,G,l||o)}N&&N(F,G),d=null}let X=new P1;X.setAnimationLoop(U),this.setAnimationLoop=function(F){N=F},this.dispose=function(){}}};function JB(r,e){function t(p,g){p.fogColor.value.copy(g.color),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function n(p,g,v,y,b){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),c(p,g)):g.isMeshPhongMaterial?(i(p,g),u(p,g)):g.isMeshStandardMaterial?(i(p,g),h(p,g),g.isMeshPhysicalMaterial&&f(p,g,b)):g.isMeshMatcapMaterial?(i(p,g),d(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,v,y):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===xr&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===xr&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let v=e.get(g).envMap;if(v&&(p.envMap.value=v,p.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let S=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*S}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix));let b;g.aoMap?b=g.aoMap:g.lightMap&&(b=g.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),p.uv2Transform.value.copy(b.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,v,y){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*v,p.scale.value=y*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let b;g.map?b=g.map:g.alphaMap&&(b=g.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),p.uvTransform.value.copy(b.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let v;g.map?v=g.map:g.alphaMap&&(v=g.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix))}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function c(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function h(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),e.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function f(p,g,v){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===xr&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=v.texture,p.transmissionSamplerSize.value.set(v.width,v.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function d(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:n}}function $B(){let r=rp("canvas");return r.style.display="block",r}function $y(r={}){this.isWebGLRenderer=!0;let e=r.canvas!==void 0?r.canvas:$B(),t=r.context!==void 0?r.context:null,n=r.depth!==void 0?r.depth:!0,i=r.stencil!==void 0?r.stencil:!0,s=r.antialias!==void 0?r.antialias:!1,o=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,a=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,l=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,c;t!==null?c=t.getContextAttributes().alpha:c=r.alpha!==void 0?r.alpha:!1;let h=null,f=null,d=[],m=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Gn,this.physicallyCorrectLights=!1,this.toneMapping=Gs,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});let p=this,g=!1,v=0,y=0,b=null,S=-1,w=null,A=new Xe,_=new Xe,x=null,M=e.width,E=e.height,C=1,P=null,L=null,D=new Xe(0,0,M,E),R=new Xe(0,0,M,E),N=!1,U=new gh,X=!1,F=!1,G=null,j=new we,z=new k,V=new T,q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return b===null?C:1}let H=t;function fe(O,$){for(let oe=0;oe<O.length;oe++){let re=O[oe],he=e.getContext(re,$);if(he!==null)return he}return null}try{let O={alpha:!0,depth:n,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${La}`),e.addEventListener("webglcontextlost",W,!1),e.addEventListener("webglcontextrestored",be,!1),e.addEventListener("webglcontextcreationerror",_e,!1),H===null){let $=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&$.shift(),H=fe($,O),H===null)throw fe($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}H.getShaderPrecisionFormat===void 0&&(H.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(O){throw console.error("THREE.WebGLRenderer: "+O.message),O}let ne,K,Q,ie,ue,ae,Me,ge,ve,ye,de,Ie,Ge,tt,B,I,J,ce,pe,Ce,He,se,Ve;function Ne(){ne=new b3(H),K=new p3(H,ne,r),ne.init(K),se=new ZB(H,ne,K),Q=new YB(H,ne,K),ie=new A3,ue=new NB,ae=new QB(H,ne,Q,ue,K,se,ie),Me=new g3(p),ge=new x3(p),ve=new BL(H,K),Ve=new f3(H,ne,ve,K),ye=new S3(H,ve,ie,Ve),de=new E3(H,ye,ve,ie),pe=new M3(H,K,ae),I=new m3(ue),Ie=new BB(p,Me,ge,ne,K,Ve,I),Ge=new JB(p,ue),tt=new kB,B=new WB(ne,K),ce=new h3(p,Me,Q,de,c,o),J=new XB(p,de,K),Ce=new d3(H,ne,ie,K),He=new w3(H,ne,ie,K),ie.programs=Ie.programs,p.capabilities=K,p.extensions=ne,p.properties=ue,p.renderLists=tt,p.shadowMap=J,p.state=Q,p.info=ie}Ne();let xe=new Ey(p,H);this.xr=xe,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){let O=ne.get("WEBGL_lose_context");O&&O.loseContext()},this.forceContextRestore=function(){let O=ne.get("WEBGL_lose_context");O&&O.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(O){O!==void 0&&(C=O,this.setSize(M,E,!1))},this.getSize=function(O){return O.set(M,E)},this.setSize=function(O,$,oe){if(xe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=O,E=$,e.width=Math.floor(O*C),e.height=Math.floor($*C),oe!==!1&&(e.style.width=O+"px",e.style.height=$+"px"),this.setViewport(0,0,O,$)},this.getDrawingBufferSize=function(O){return O.set(M*C,E*C).floor()},this.setDrawingBufferSize=function(O,$,oe){M=O,E=$,C=oe,e.width=Math.floor(O*oe),e.height=Math.floor($*oe),this.setViewport(0,0,O,$)},this.getCurrentViewport=function(O){return O.copy(A)},this.getViewport=function(O){return O.copy(D)},this.setViewport=function(O,$,oe,re){O.isVector4?D.set(O.x,O.y,O.z,O.w):D.set(O,$,oe,re),Q.viewport(A.copy(D).multiplyScalar(C).floor())},this.getScissor=function(O){return O.copy(R)},this.setScissor=function(O,$,oe,re){O.isVector4?R.set(O.x,O.y,O.z,O.w):R.set(O,$,oe,re),Q.scissor(_.copy(R).multiplyScalar(C).floor())},this.getScissorTest=function(){return N},this.setScissorTest=function(O){Q.setScissorTest(N=O)},this.setOpaqueSort=function(O){P=O},this.setTransparentSort=function(O){L=O},this.getClearColor=function(O){return O.copy(ce.getClearColor())},this.setClearColor=function(){ce.setClearColor.apply(ce,arguments)},this.getClearAlpha=function(){return ce.getClearAlpha()},this.setClearAlpha=function(){ce.setClearAlpha.apply(ce,arguments)},this.clear=function(O=!0,$=!0,oe=!0){let re=0;O&&(re|=16384),$&&(re|=256),oe&&(re|=1024),H.clear(re)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",W,!1),e.removeEventListener("webglcontextrestored",be,!1),e.removeEventListener("webglcontextcreationerror",_e,!1),tt.dispose(),B.dispose(),ue.dispose(),Me.dispose(),ge.dispose(),de.dispose(),Ve.dispose(),Ie.dispose(),xe.dispose(),xe.removeEventListener("sessionstart",ht),xe.removeEventListener("sessionend",Tt),G&&(G.dispose(),G=null),Pt.stop()};function W(O){O.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function be(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let O=ie.autoReset,$=J.enabled,oe=J.autoUpdate,re=J.needsUpdate,he=J.type;Ne(),ie.autoReset=O,J.enabled=$,J.autoUpdate=oe,J.needsUpdate=re,J.type=he}function _e(O){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",O.statusMessage)}function et(O){let $=O.target;$.removeEventListener("dispose",et),Fe($)}function Fe(O){nt(O),ue.remove(O)}function nt(O){let $=ue.get(O).programs;$!==void 0&&($.forEach(function(oe){Ie.releaseProgram(oe)}),O.isShaderMaterial&&Ie.releaseShaderCache(O))}this.renderBufferDirect=function(O,$,oe,re,he,ot){$===null&&($=q);let lt=he.isMesh&&he.matrixWorld.determinant()<0,dt=$D(O,$,oe,re,he);Q.setMaterial(re,lt);let ft=oe.index,Nt=oe.attributes.position;if(ft===null){if(Nt===void 0||Nt.count===0)return}else if(ft.count===0)return;let St=1;re.wireframe===!0&&(ft=ye.getWireframeAttribute(oe),St=2),Ve.setup(he,re,dt,oe,ft);let _t,Jt=Ce;ft!==null&&(_t=ve.get(ft),Jt=He,Jt.setIndex(_t));let fa=ft!==null?ft.count:Nt.count,dl=oe.drawRange.start*St,pl=oe.drawRange.count*St,Xi=ot!==null?ot.start*St:0,Dt=ot!==null?ot.count*St:1/0,ml=Math.max(dl,Xi),vr=Math.min(fa,dl+pl,Xi+Dt)-1,Yi=Math.max(0,vr-ml+1);if(Yi!==0){if(he.isMesh)re.wireframe===!0?(Q.setLineWidth(re.wireframeLinewidth*Y()),Jt.setMode(1)):Jt.setMode(4);else if(he.isLine){let io=re.linewidth;io===void 0&&(io=1),Q.setLineWidth(io*Y()),he.isLineSegments?Jt.setMode(1):he.isLineLoop?Jt.setMode(2):Jt.setMode(3)}else he.isPoints?Jt.setMode(0):he.isSprite&&Jt.setMode(4);if(he.isInstancedMesh)Jt.renderInstances(ml,Yi,he.count);else if(oe.isInstancedBufferGeometry){let io=Math.min(oe.instanceCount,oe._maxInstanceCount);Jt.renderInstances(ml,Yi,io)}else Jt.render(ml,Yi)}},this.compile=function(O,$){f=B.get(O),f.init(),m.push(f),O.traverseVisible(function(oe){oe.isLight&&oe.layers.test($.layers)&&(f.pushLight(oe),oe.castShadow&&f.pushShadow(oe))}),f.setupLights(p.physicallyCorrectLights),O.traverse(function(oe){let re=oe.material;if(re)if(Array.isArray(re))for(let he=0;he<re.length;he++){let ot=re[he];Av(ot,O,oe)}else Av(re,O,oe)}),m.pop(),f=null};let Se=null;function it(O){Se&&Se(O)}function ht(){Pt.stop()}function Tt(){Pt.start()}let Pt=new P1;Pt.setAnimationLoop(it),typeof self<"u"&&Pt.setContext(self),this.setAnimationLoop=function(O){Se=O,xe.setAnimationLoop(O),O===null?Pt.stop():Pt.start()},xe.addEventListener("sessionstart",ht),xe.addEventListener("sessionend",Tt),this.render=function(O,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;O.autoUpdate===!0&&O.updateMatrixWorld(),$.parent===null&&$.updateMatrixWorld(),xe.enabled===!0&&xe.isPresenting===!0&&(xe.cameraAutoUpdate===!0&&xe.updateCamera($),$=xe.getCamera()),O.isScene===!0&&O.onBeforeRender(p,O,$,b),f=B.get(O,m.length),f.init(),m.push(f),j.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),U.setFromProjectionMatrix(j),F=this.localClippingEnabled,X=I.init(this.clippingPlanes,F,$),h=tt.get(O,d.length),h.init(),d.push(h),An(O,$,0,p.sortObjects),h.finish(),p.sortObjects===!0&&h.sort(P,L),X===!0&&I.beginShadows();let oe=f.state.shadowsArray;if(J.render(oe,O,$),X===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),ce.render(h,O),f.setupLights(p.physicallyCorrectLights),$.isArrayCamera){let re=$.cameras;for(let he=0,ot=re.length;he<ot;he++){let lt=re[he];Sd(h,O,lt,lt.viewport)}}else Sd(h,O,$);b!==null&&(ae.updateMultisampleRenderTarget(b),ae.updateRenderTargetMipmap(b)),O.isScene===!0&&O.onAfterRender(p,O,$),Ve.resetDefaultState(),S=-1,w=null,m.pop(),m.length>0?f=m[m.length-1]:f=null,d.pop(),d.length>0?h=d[d.length-1]:h=null};function An(O,$,oe,re){if(O.visible===!1)return;if(O.layers.test($.layers)){if(O.isGroup)oe=O.renderOrder;else if(O.isLOD)O.autoUpdate===!0&&O.update($);else if(O.isLight)f.pushLight(O),O.castShadow&&f.pushShadow(O);else if(O.isSprite){if(!O.frustumCulled||U.intersectsSprite(O)){re&&V.setFromMatrixPosition(O.matrixWorld).applyMatrix4(j);let lt=de.update(O),dt=O.material;dt.visible&&h.push(O,lt,dt,oe,V.z,null)}}else if((O.isMesh||O.isLine||O.isPoints)&&(O.isSkinnedMesh&&O.skeleton.frame!==ie.render.frame&&(O.skeleton.update(),O.skeleton.frame=ie.render.frame),!O.frustumCulled||U.intersectsObject(O))){re&&V.setFromMatrixPosition(O.matrixWorld).applyMatrix4(j);let lt=de.update(O),dt=O.material;if(Array.isArray(dt)){let ft=lt.groups;for(let Nt=0,St=ft.length;Nt<St;Nt++){let _t=ft[Nt],Jt=dt[_t.materialIndex];Jt&&Jt.visible&&h.push(O,lt,Jt,oe,V.z,_t)}}else dt.visible&&h.push(O,lt,dt,oe,V.z,null)}}let ot=O.children;for(let lt=0,dt=ot.length;lt<dt;lt++)An(ot[lt],$,oe,re)}function Sd(O,$,oe,re){let he=O.opaque,ot=O.transmissive,lt=O.transparent;f.setupLightsView(oe),ot.length>0&&fl(he,$,oe),re&&Q.viewport(A.copy(re)),he.length>0&&wd(he,$,oe),ot.length>0&&wd(ot,$,oe),lt.length>0&&wd(lt,$,oe),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function fl(O,$,oe){let re=K.isWebGL2;G===null&&(G=new xt(1,1,{generateMipmaps:!0,type:ne.has("EXT_color_buffer_half_float")?fh:qt,minFilter:ec,samples:re&&s===!0?4:0})),p.getDrawingBufferSize(z),re?G.setSize(z.x,z.y):G.setSize(tp(z.x),tp(z.y));let he=p.getRenderTarget();p.setRenderTarget(G),p.clear();let ot=p.toneMapping;p.toneMapping=Gs,wd(O,$,oe),p.toneMapping=ot,ae.updateMultisampleRenderTarget(G),ae.updateRenderTargetMipmap(G),p.setRenderTarget(he)}function wd(O,$,oe){let re=$.isScene===!0?$.overrideMaterial:null;for(let he=0,ot=O.length;he<ot;he++){let lt=O[he],dt=lt.object,ft=lt.geometry,Nt=re===null?lt.material:re,St=lt.group;dt.layers.test(oe.layers)&&JD(dt,$,oe,ft,Nt,St)}}function JD(O,$,oe,re,he,ot){O.onBeforeRender(p,$,oe,re,he,ot),O.modelViewMatrix.multiplyMatrices(oe.matrixWorldInverse,O.matrixWorld),O.normalMatrix.getNormalMatrix(O.modelViewMatrix),he.onBeforeRender(p,$,oe,re,O,ot),he.transparent===!0&&he.side===pn?(he.side=xr,he.needsUpdate=!0,p.renderBufferDirect(oe,$,re,he,O,ot),he.side=ti,he.needsUpdate=!0,p.renderBufferDirect(oe,$,re,he,O,ot),he.side=pn):p.renderBufferDirect(oe,$,re,he,O,ot),O.onAfterRender(p,$,oe,re,he,ot)}function Av(O,$,oe){$.isScene!==!0&&($=q);let re=ue.get(O),he=f.state.lights,ot=f.state.shadowsArray,lt=he.state.version,dt=Ie.getParameters(O,he.state,ot,$,oe),ft=Ie.getProgramCacheKey(dt),Nt=re.programs;re.environment=O.isMeshStandardMaterial?$.environment:null,re.fog=$.fog,re.envMap=(O.isMeshStandardMaterial?ge:Me).get(O.envMap||re.environment),Nt===void 0&&(O.addEventListener("dispose",et),Nt=new Map,re.programs=Nt);let St=Nt.get(ft);if(St!==void 0){if(re.currentProgram===St&&re.lightsStateVersion===lt)return GS(O,dt),St}else dt.uniforms=Ie.getUniforms(O),O.onBuild(oe,dt,p),O.onBeforeCompile(dt,p),St=Ie.acquireProgram(dt,ft),Nt.set(ft,St),re.uniforms=dt.uniforms;let _t=re.uniforms;(!O.isShaderMaterial&&!O.isRawShaderMaterial||O.clipping===!0)&&(_t.clippingPlanes=I.uniform),GS(O,dt),re.needsLights=tI(O),re.lightsStateVersion=lt,re.needsLights&&(_t.ambientLightColor.value=he.state.ambient,_t.lightProbe.value=he.state.probe,_t.directionalLights.value=he.state.directional,_t.directionalLightShadows.value=he.state.directionalShadow,_t.spotLights.value=he.state.spot,_t.spotLightShadows.value=he.state.spotShadow,_t.rectAreaLights.value=he.state.rectArea,_t.ltc_1.value=he.state.rectAreaLTC1,_t.ltc_2.value=he.state.rectAreaLTC2,_t.pointLights.value=he.state.point,_t.pointLightShadows.value=he.state.pointShadow,_t.hemisphereLights.value=he.state.hemi,_t.directionalShadowMap.value=he.state.directionalShadowMap,_t.directionalShadowMatrix.value=he.state.directionalShadowMatrix,_t.spotShadowMap.value=he.state.spotShadowMap,_t.spotShadowMatrix.value=he.state.spotShadowMatrix,_t.pointShadowMap.value=he.state.pointShadowMap,_t.pointShadowMatrix.value=he.state.pointShadowMatrix);let Jt=St.getUniforms(),fa=Ol.seqWithValue(Jt.seq,_t);return re.currentProgram=St,re.uniformsList=fa,St}function GS(O,$){let oe=ue.get(O);oe.outputEncoding=$.outputEncoding,oe.instancing=$.instancing,oe.skinning=$.skinning,oe.morphTargets=$.morphTargets,oe.morphNormals=$.morphNormals,oe.morphColors=$.morphColors,oe.morphTargetsCount=$.morphTargetsCount,oe.numClippingPlanes=$.numClippingPlanes,oe.numIntersection=$.numClipIntersection,oe.vertexAlphas=$.vertexAlphas,oe.vertexTangents=$.vertexTangents,oe.toneMapping=$.toneMapping}function $D(O,$,oe,re,he){$.isScene!==!0&&($=q),ae.resetTextureUnits();let ot=$.fog,lt=re.isMeshStandardMaterial?$.environment:null,dt=b===null?p.outputEncoding:b.isXRRenderTarget===!0?b.texture.encoding:Gn,ft=(re.isMeshStandardMaterial?ge:Me).get(re.envMap||lt),Nt=re.vertexColors===!0&&!!oe.attributes.color&&oe.attributes.color.itemSize===4,St=!!re.normalMap&&!!oe.attributes.tangent,_t=!!oe.morphAttributes.position,Jt=!!oe.morphAttributes.normal,fa=!!oe.morphAttributes.color,dl=re.toneMapped?p.toneMapping:Gs,pl=oe.morphAttributes.position||oe.morphAttributes.normal||oe.morphAttributes.color,Xi=pl!==void 0?pl.length:0,Dt=ue.get(re),ml=f.state.lights;if(X===!0&&(F===!0||O!==w)){let Qi=O===w&&re.id===S;I.setState(re,O,Qi)}let vr=!1;re.version===Dt.__version?(Dt.needsLights&&Dt.lightsStateVersion!==ml.state.version||Dt.outputEncoding!==dt||he.isInstancedMesh&&Dt.instancing===!1||!he.isInstancedMesh&&Dt.instancing===!0||he.isSkinnedMesh&&Dt.skinning===!1||!he.isSkinnedMesh&&Dt.skinning===!0||Dt.envMap!==ft||re.fog===!0&&Dt.fog!==ot||Dt.numClippingPlanes!==void 0&&(Dt.numClippingPlanes!==I.numPlanes||Dt.numIntersection!==I.numIntersection)||Dt.vertexAlphas!==Nt||Dt.vertexTangents!==St||Dt.morphTargets!==_t||Dt.morphNormals!==Jt||Dt.morphColors!==fa||Dt.toneMapping!==dl||K.isWebGL2===!0&&Dt.morphTargetsCount!==Xi)&&(vr=!0):(vr=!0,Dt.__version=re.version);let Yi=Dt.currentProgram;vr===!0&&(Yi=Av(re,$,he));let io=!1,Ju=!1,Tv=!1,hn=Yi.getUniforms(),$u=Dt.uniforms;if(Q.useProgram(Yi.program)&&(io=!0,Ju=!0,Tv=!0),re.id!==S&&(S=re.id,Ju=!0),io||w!==O){if(hn.setValue(H,"projectionMatrix",O.projectionMatrix),K.logarithmicDepthBuffer&&hn.setValue(H,"logDepthBufFC",2/(Math.log(O.far+1)/Math.LN2)),w!==O&&(w=O,Ju=!0,Tv=!0),re.isShaderMaterial||re.isMeshPhongMaterial||re.isMeshToonMaterial||re.isMeshStandardMaterial||re.envMap){let Qi=hn.map.cameraPosition;Qi!==void 0&&Qi.setValue(H,V.setFromMatrixPosition(O.matrixWorld))}(re.isMeshPhongMaterial||re.isMeshToonMaterial||re.isMeshLambertMaterial||re.isMeshBasicMaterial||re.isMeshStandardMaterial||re.isShaderMaterial)&&hn.setValue(H,"isOrthographic",O.isOrthographicCamera===!0),(re.isMeshPhongMaterial||re.isMeshToonMaterial||re.isMeshLambertMaterial||re.isMeshBasicMaterial||re.isMeshStandardMaterial||re.isShaderMaterial||re.isShadowMaterial||he.isSkinnedMesh)&&hn.setValue(H,"viewMatrix",O.matrixWorldInverse)}if(he.isSkinnedMesh){hn.setOptional(H,he,"bindMatrix"),hn.setOptional(H,he,"bindMatrixInverse");let Qi=he.skeleton;Qi&&(K.floatVertexTextures?(Qi.boneTexture===null&&Qi.computeBoneTexture(),hn.setValue(H,"boneTexture",Qi.boneTexture,ae),hn.setValue(H,"boneTextureSize",Qi.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let _v=oe.morphAttributes;return(_v.position!==void 0||_v.normal!==void 0||_v.color!==void 0&&K.isWebGL2===!0)&&pe.update(he,oe,re,Yi),(Ju||Dt.receiveShadow!==he.receiveShadow)&&(Dt.receiveShadow=he.receiveShadow,hn.setValue(H,"receiveShadow",he.receiveShadow)),Ju&&(hn.setValue(H,"toneMappingExposure",p.toneMappingExposure),Dt.needsLights&&eI($u,Tv),ot&&re.fog===!0&&Ge.refreshFogUniforms($u,ot),Ge.refreshMaterialUniforms($u,re,C,E,G),Ol.upload(H,Dt.uniformsList,$u,ae)),re.isShaderMaterial&&re.uniformsNeedUpdate===!0&&(Ol.upload(H,Dt.uniformsList,$u,ae),re.uniformsNeedUpdate=!1),re.isSpriteMaterial&&hn.setValue(H,"center",he.center),hn.setValue(H,"modelViewMatrix",he.modelViewMatrix),hn.setValue(H,"normalMatrix",he.normalMatrix),hn.setValue(H,"modelMatrix",he.matrixWorld),Yi}function eI(O,$){O.ambientLightColor.needsUpdate=$,O.lightProbe.needsUpdate=$,O.directionalLights.needsUpdate=$,O.directionalLightShadows.needsUpdate=$,O.pointLights.needsUpdate=$,O.pointLightShadows.needsUpdate=$,O.spotLights.needsUpdate=$,O.spotLightShadows.needsUpdate=$,O.rectAreaLights.needsUpdate=$,O.hemisphereLights.needsUpdate=$}function tI(O){return O.isMeshLambertMaterial||O.isMeshToonMaterial||O.isMeshPhongMaterial||O.isMeshStandardMaterial||O.isShadowMaterial||O.isShaderMaterial&&O.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(O,$,oe){ue.get(O.texture).__webglTexture=$,ue.get(O.depthTexture).__webglTexture=oe;let re=ue.get(O);re.__hasExternalTextures=!0,re.__hasExternalTextures&&(re.__autoAllocateDepthBuffer=oe===void 0,re.__autoAllocateDepthBuffer||ne.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),re.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(O,$){let oe=ue.get(O);oe.__webglFramebuffer=$,oe.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(O,$=0,oe=0){b=O,v=$,y=oe;let re=!0;if(O){let ft=ue.get(O);ft.__useDefaultFramebuffer!==void 0?(Q.bindFramebuffer(36160,null),re=!1):ft.__webglFramebuffer===void 0?ae.setupRenderTarget(O):ft.__hasExternalTextures&&ae.rebindTextures(O,ue.get(O.texture).__webglTexture,ue.get(O.depthTexture).__webglTexture)}let he=null,ot=!1,lt=!1;if(O){let ft=O.texture;(ft.isData3DTexture||ft.isDataArrayTexture)&&(lt=!0);let Nt=ue.get(O).__webglFramebuffer;O.isWebGLCubeRenderTarget?(he=Nt[$],ot=!0):K.isWebGL2&&O.samples>0&&ae.useMultisampledRTT(O)===!1?he=ue.get(O).__webglMultisampledFramebuffer:he=Nt,A.copy(O.viewport),_.copy(O.scissor),x=O.scissorTest}else A.copy(D).multiplyScalar(C).floor(),_.copy(R).multiplyScalar(C).floor(),x=N;if(Q.bindFramebuffer(36160,he)&&K.drawBuffers&&re&&Q.drawBuffers(O,he),Q.viewport(A),Q.scissor(_),Q.setScissorTest(x),ot){let ft=ue.get(O.texture);H.framebufferTexture2D(36160,36064,34069+$,ft.__webglTexture,oe)}else if(lt){let ft=ue.get(O.texture),Nt=$||0;H.framebufferTextureLayer(36160,36064,ft.__webglTexture,oe||0,Nt)}S=-1},this.readRenderTargetPixels=function(O,$,oe,re,he,ot,lt){if(!(O&&O.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let dt=ue.get(O).__webglFramebuffer;if(O.isWebGLCubeRenderTarget&<!==void 0&&(dt=dt[lt]),dt){Q.bindFramebuffer(36160,dt);try{let ft=O.texture,Nt=ft.format,St=ft.type;if(Nt!==Ai&&se.convert(Nt)!==H.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let _t=St===fh&&(ne.has("EXT_color_buffer_half_float")||K.isWebGL2&&ne.has("EXT_color_buffer_float"));if(St!==qt&&se.convert(St)!==H.getParameter(35738)&&!(St===Ki&&(K.isWebGL2||ne.has("OES_texture_float")||ne.has("WEBGL_color_buffer_float")))&&!_t){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=O.width-re&&oe>=0&&oe<=O.height-he&&H.readPixels($,oe,re,he,se.convert(Nt),se.convert(St),ot)}finally{let ft=b!==null?ue.get(b).__webglFramebuffer:null;Q.bindFramebuffer(36160,ft)}}},this.copyFramebufferToTexture=function(O,$,oe=0){let re=Math.pow(2,-oe),he=Math.floor($.image.width*re),ot=Math.floor($.image.height*re);ae.setTexture2D($,0),H.copyTexSubImage2D(3553,oe,0,0,O.x,O.y,he,ot),Q.unbindTexture()},this.copyTextureToTexture=function(O,$,oe,re=0){let he=$.image.width,ot=$.image.height,lt=se.convert(oe.format),dt=se.convert(oe.type);ae.setTexture2D(oe,0),H.pixelStorei(37440,oe.flipY),H.pixelStorei(37441,oe.premultiplyAlpha),H.pixelStorei(3317,oe.unpackAlignment),$.isDataTexture?H.texSubImage2D(3553,re,O.x,O.y,he,ot,lt,dt,$.image.data):$.isCompressedTexture?H.compressedTexSubImage2D(3553,re,O.x,O.y,$.mipmaps[0].width,$.mipmaps[0].height,lt,$.mipmaps[0].data):H.texSubImage2D(3553,re,O.x,O.y,lt,dt,$.image),re===0&&oe.generateMipmaps&&H.generateMipmap(3553),Q.unbindTexture()},this.copyTextureToTexture3D=function(O,$,oe,re,he=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ot=O.max.x-O.min.x+1,lt=O.max.y-O.min.y+1,dt=O.max.z-O.min.z+1,ft=se.convert(re.format),Nt=se.convert(re.type),St;if(re.isData3DTexture)ae.setTexture3D(re,0),St=32879;else if(re.isDataArrayTexture)ae.setTexture2DArray(re,0),St=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(37440,re.flipY),H.pixelStorei(37441,re.premultiplyAlpha),H.pixelStorei(3317,re.unpackAlignment);let _t=H.getParameter(3314),Jt=H.getParameter(32878),fa=H.getParameter(3316),dl=H.getParameter(3315),pl=H.getParameter(32877),Xi=oe.isCompressedTexture?oe.mipmaps[0]:oe.image;H.pixelStorei(3314,Xi.width),H.pixelStorei(32878,Xi.height),H.pixelStorei(3316,O.min.x),H.pixelStorei(3315,O.min.y),H.pixelStorei(32877,O.min.z),oe.isDataTexture||oe.isData3DTexture?H.texSubImage3D(St,he,$.x,$.y,$.z,ot,lt,dt,ft,Nt,Xi.data):oe.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),H.compressedTexSubImage3D(St,he,$.x,$.y,$.z,ot,lt,dt,ft,Xi.data)):H.texSubImage3D(St,he,$.x,$.y,$.z,ot,lt,dt,ft,Nt,Xi),H.pixelStorei(3314,_t),H.pixelStorei(32878,Jt),H.pixelStorei(3316,fa),H.pixelStorei(3315,dl),H.pixelStorei(32877,pl),he===0&&re.generateMipmaps&&H.generateMipmap(St),Q.unbindTexture()},this.initTexture=function(O){O.isCubeTexture?ae.setTextureCube(O,0):O.isData3DTexture?ae.setTexture3D(O,0):O.isDataArrayTexture?ae.setTexture2DArray(O,0):ae.setTexture2D(O,0),Q.unbindTexture()},this.resetState=function(){v=0,y=0,b=null,Q.reset(),Ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var Cy=class extends $y{};Cy.prototype.isWebGL1Renderer=!0;var kl=class{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Be(e),this.near=t,this.far=n}clone(){return new kl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},vn=class extends yt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,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()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}},lp=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=dy,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ji()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ji()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ji()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},fn=new T,wa=class{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i===!0}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)fn.fromBufferAttribute(this,t),fn.applyMatrix4(e),this.setXYZ(t,fn.x,fn.y,fn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)fn.fromBufferAttribute(this,t),fn.applyNormalMatrix(e),this.setXYZ(t,fn.x,fn.y,fn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)fn.fromBufferAttribute(this,t),fn.transformDirection(e),this.setXYZ(t,fn.x,fn.y,fn.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new We(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new wa(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var cp=class extends We{constructor(e,t,n,i=1){typeof n=="number"&&(i=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};var ri=class extends Sa{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Be(16777215),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.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},t1=new T,r1=new T,n1=new we,iy=new Ti,jd=new Fr,Aa=class extends yt{constructor(e=new Le,t=new ri){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=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)t1.fromBufferAttribute(t,i-1),r1.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=t1.distanceTo(r1);e.setAttribute("lineDistance",new Te(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),jd.copy(n.boundingSphere),jd.applyMatrix4(i),jd.radius+=s,e.ray.intersectsSphere(jd)===!1)return;n1.copy(i).invert(),iy.copy(e.ray).applyMatrix4(n1);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new T,c=new T,h=new T,f=new T,d=this.isLineSegments?2:1,m=n.index,g=n.attributes.position;if(m!==null){let v=Math.max(0,o.start),y=Math.min(m.count,o.start+o.count);for(let b=v,S=y-1;b<S;b+=d){let w=m.getX(b),A=m.getX(b+1);if(u.fromBufferAttribute(g,w),c.fromBufferAttribute(g,A),iy.distanceSqToSegment(u,c,f,h)>l)continue;f.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(f);x<e.near||x>e.far||t.push({distance:x,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else{let v=Math.max(0,o.start),y=Math.min(g.count,o.start+o.count);for(let b=v,S=y-1;b<S;b+=d){if(u.fromBufferAttribute(g,b),c.fromBufferAttribute(g,b+1),iy.distanceSqToSegment(u,c,f,h)>l)continue;f.applyMatrix4(this.matrixWorld);let A=e.ray.origin.distanceTo(f);A<e.near||A>e.far||t.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},i1=new T,s1=new T,So=class extends Aa{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)i1.fromBufferAttribute(t,i),s1.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+i1.distanceTo(s1);e.setAttribute("lineDistance",new Te(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var ni=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n=this.getLengths(),i=0,s=n.length,o;t?o=t:o=e*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),u=n[i]-o,u<0)a=i+1;else if(u>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let c=n[i],f=n[i+1]-c,d=(o-c)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new k:new T);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new T,i=[],s=[],o=[],a=new T,l=new we;for(let d=0;d<=e;d++){let m=d/e;i[d]=this.getTangentAt(m,new T)}s[0]=new T,o[0]=new T;let u=Number.MAX_VALUE,c=Math.abs(i[0].x),h=Math.abs(i[0].y),f=Math.abs(i[0].z);c<=u&&(u=c,n.set(1,0,0)),h<=u&&(u=h,n.set(0,1,0)),f<=u&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(i[d-1],i[d]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(Ar(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(l.makeRotationAxis(a,m))}o[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(Ar(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],d*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Ta=class extends ni{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let n=t||new k,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=l-this.aX,d=u-this.aY;l=f*c-d*h+this.aX,u=f*h+d*c+this.aY}return n.set(l,u)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Py=class extends Ta{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function e0(){let r=0,e=0,t=0,n=0;function i(s,o,a,l){r=s,e=a,t=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){i(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,h){let f=(o-s)/u-(a-s)/(u+c)+(a-o)/c,d=(a-o)/c-(l-o)/(c+h)+(l-a)/h;f*=c,d*=c,i(o,a,f,d)},calc:function(s){let o=s*s,a=o*s;return r+e*s+t*o+n*a}}}var qd=new T,sy=new e0,oy=new e0,ay=new e0,Dy=class extends ni{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new T){let n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=i[(a-1)%s]:(qd.subVectors(i[0],i[1]).add(i[0]),u=qd);let h=i[a%s],f=i[(a+1)%s];if(this.closed||a+2<s?c=i[(a+2)%s]:(qd.subVectors(i[s-1],i[s-2]).add(i[s-1]),c=qd),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,m=Math.pow(u.distanceToSquared(h),d),p=Math.pow(h.distanceToSquared(f),d),g=Math.pow(f.distanceToSquared(c),d);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),sy.initNonuniformCatmullRom(u.x,h.x,f.x,c.x,m,p,g),oy.initNonuniformCatmullRom(u.y,h.y,f.y,c.y,m,p,g),ay.initNonuniformCatmullRom(u.z,h.z,f.z,c.z,m,p,g)}else this.curveType==="catmullrom"&&(sy.initCatmullRom(u.x,h.x,f.x,c.x,this.tension),oy.initCatmullRom(u.y,h.y,f.y,c.y,this.tension),ay.initCatmullRom(u.z,h.z,f.z,c.z,this.tension));return n.set(sy.calc(l),oy.calc(l),ay.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new T().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function o1(r,e,t,n,i){let s=(n-e)*.5,o=(i-t)*.5,a=r*r,l=r*a;return(2*t-2*n+s+o)*l+(-3*t+3*n-2*s-o)*a+s*r+t}function eN(r,e){let t=1-r;return t*t*e}function tN(r,e){return 2*(1-r)*r*e}function rN(r,e){return r*r*e}function uh(r,e,t,n){return eN(r,e)+tN(r,t)+rN(r,n)}function nN(r,e){let t=1-r;return t*t*t*e}function iN(r,e){let t=1-r;return 3*t*t*r*e}function sN(r,e){return 3*(1-r)*r*r*e}function oN(r,e){return r*r*r*e}function hh(r,e,t,n,i){return nN(r,e)+iN(r,t)+sN(r,n)+oN(r,i)}var tn=class extends ni{constructor(e=new k,t=new k,n=new k,i=new k){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new k){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(hh(e,i.x,s.x,o.x,a.x),hh(e,i.y,s.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Iy=class extends ni{constructor(e=new T,t=new T,n=new T,i=new T){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new T){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(hh(e,i.x,s.x,o.x,a.x),hh(e,i.y,s.y,o.y,a.y),hh(e,i.z,s.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},rn=class extends ni{constructor(e=new k,t=new k){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new k){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let n=t||new k;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},yh=class extends ni{constructor(e=new T,t=new T){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new T){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},zn=class extends ni{constructor(e=new k,t=new k,n=new k){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new k){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(uh(e,i.x,s.x,o.x),uh(e,i.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ly=class extends ni{constructor(e=new T,t=new T,n=new T){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new T){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(uh(e,i.x,s.x,o.x),uh(e,i.y,s.y,o.y),uh(e,i.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ul=class extends ni{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new k){let n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],u=i[o],c=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(o1(a,l.x,u.x,c.x,h.x),o1(a,l.y,u.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new k().fromArray(i))}return this}},aN=Object.freeze({__proto__:null,ArcCurve:Py,CatmullRomCurve3:Dy,CubicBezierCurve:tn,CubicBezierCurve3:Iy,EllipseCurve:Ta,LineCurve:rn,LineCurve3:yh,QuadraticBezierCurve:zn,QuadraticBezierCurve3:Ly,SplineCurve:Ul}),Oy=class extends ni{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new rn(t,e))}getPoint(e,t){let n=e*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];n&&n.equals(c)||(t.push(c),n=c)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(new aN[i.type]().fromJSON(i))}return this}},_a=class extends Oy{constructor(e){super(),this.type="Path",this.currentPoint=new k,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new rn(this.currentPoint.clone(),new k(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let s=new zn(this.currentPoint.clone(),new k(e,t),new k(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){let a=new tn(this.currentPoint.clone(),new k(e,t),new k(n,i),new k(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new Ul(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+u,t+c,n,i,s,o,a,l),this}absellipse(e,t,n,i,s,o,a,l){let u=new Ta(e,t,n,i,s,o,a,l);if(this.curves.length>0){let h=u.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Gl=class extends Le{constructor(e=[new k(0,.5),new k(.5,0),new k(0,-.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=Ar(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/t,h=new T,f=new k,d=new T,m=new T,p=new T,g=0,v=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,d.x=v*1,d.y=-g,d.z=v*0,p.copy(d),d.normalize(),l.push(d.x,d.y,d.z);break;case e.length-1:l.push(p.x,p.y,p.z);break;default:g=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,d.x=v*1,d.y=-g,d.z=v*0,m.copy(d),d.x+=p.x,d.y+=p.y,d.z+=p.z,d.normalize(),l.push(d.x,d.y,d.z),p.copy(m)}for(let y=0;y<=t;y++){let b=n+y*c*i,S=Math.sin(b),w=Math.cos(b);for(let A=0;A<=e.length-1;A++){h.x=e[A].x*S,h.y=e[A].y,h.z=e[A].x*w,o.push(h.x,h.y,h.z),f.x=y/t,f.y=A/(e.length-1),a.push(f.x,f.y);let _=l[3*A+0]*S,x=l[3*A+1],M=l[3*A+0]*w;u.push(_,x,M)}}for(let y=0;y<t;y++)for(let b=0;b<e.length-1;b++){let S=b+y*e.length,w=S,A=S+e.length,_=S+e.length+1,x=S+1;s.push(w,A,x),s.push(_,x,A)}this.setIndex(s),this.setAttribute("position",new Te(o,3)),this.setAttribute("uv",new Te(a,2)),this.setAttribute("normal",new Te(u,3))}static fromJSON(e){return new Gl(e.points,e.segments,e.phiStart,e.phiLength)}};var Ma=class extends Le{constructor(e=1,t=1,n=1,i=8,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;i=Math.floor(i),s=Math.floor(s);let c=[],h=[],f=[],d=[],m=0,p=[],g=n/2,v=0;y(),o===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(c),this.setAttribute("position",new Te(h,3)),this.setAttribute("normal",new Te(f,3)),this.setAttribute("uv",new Te(d,2));function y(){let S=new T,w=new T,A=0,_=(t-e)/n;for(let x=0;x<=s;x++){let M=[],E=x/s,C=E*(t-e)+e;for(let P=0;P<=i;P++){let L=P/i,D=L*l+a,R=Math.sin(D),N=Math.cos(D);w.x=C*R,w.y=-E*n+g,w.z=C*N,h.push(w.x,w.y,w.z),S.set(R,_,N).normalize(),f.push(S.x,S.y,S.z),d.push(L,1-E),M.push(m++)}p.push(M)}for(let x=0;x<i;x++)for(let M=0;M<s;M++){let E=p[M][x],C=p[M+1][x],P=p[M+1][x+1],L=p[M][x+1];c.push(E,C,L),c.push(C,P,L),A+=6}u.addGroup(v,A,0),v+=A}function b(S){let w=m,A=new k,_=new T,x=0,M=S===!0?e:t,E=S===!0?1:-1;for(let P=1;P<=i;P++)h.push(0,g*E,0),f.push(0,E,0),d.push(.5,.5),m++;let C=m;for(let P=0;P<=i;P++){let D=P/i*l+a,R=Math.cos(D),N=Math.sin(D);_.x=M*N,_.y=g*E,_.z=M*R,h.push(_.x,_.y,_.z),f.push(0,E,0),A.x=R*.5+.5,A.y=N*.5*E+.5,d.push(A.x,A.y),m++}for(let P=0;P<i;P++){let L=w+P,D=C+P;S===!0?c.push(D,D+1,L):c.push(D+1,D,L),x+=3}u.addGroup(v,x,S===!0?1:2),v+=x}}static fromJSON(e){return new Ma(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},zl=class extends Ma{constructor(e=1,t=1,n=8,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new zl(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Vl=class extends Le{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};let s=[],o=[];a(i),u(n),c(),this.setAttribute("position",new Te(s,3)),this.setAttribute("normal",new Te(s.slice(),3)),this.setAttribute("uv",new Te(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(y){let b=new T,S=new T,w=new T;for(let A=0;A<t.length;A+=3)d(t[A+0],b),d(t[A+1],S),d(t[A+2],w),l(b,S,w,y)}function l(y,b,S,w){let A=w+1,_=[];for(let x=0;x<=A;x++){_[x]=[];let M=y.clone().lerp(S,x/A),E=b.clone().lerp(S,x/A),C=A-x;for(let P=0;P<=C;P++)P===0&&x===A?_[x][P]=M:_[x][P]=M.clone().lerp(E,P/C)}for(let x=0;x<A;x++)for(let M=0;M<2*(A-x)-1;M++){let E=Math.floor(M/2);M%2===0?(f(_[x][E+1]),f(_[x+1][E]),f(_[x][E])):(f(_[x][E+1]),f(_[x+1][E+1]),f(_[x+1][E]))}}function u(y){let b=new T;for(let S=0;S<s.length;S+=3)b.x=s[S+0],b.y=s[S+1],b.z=s[S+2],b.normalize().multiplyScalar(y),s[S+0]=b.x,s[S+1]=b.y,s[S+2]=b.z}function c(){let y=new T;for(let b=0;b<s.length;b+=3){y.x=s[b+0],y.y=s[b+1],y.z=s[b+2];let S=g(y)/2/Math.PI+.5,w=v(y)/Math.PI+.5;o.push(S,1-w)}m(),h()}function h(){for(let y=0;y<o.length;y+=6){let b=o[y+0],S=o[y+2],w=o[y+4],A=Math.max(b,S,w),_=Math.min(b,S,w);A>.9&&_<.1&&(b<.2&&(o[y+0]+=1),S<.2&&(o[y+2]+=1),w<.2&&(o[y+4]+=1))}}function f(y){s.push(y.x,y.y,y.z)}function d(y,b){let S=y*3;b.x=e[S+0],b.y=e[S+1],b.z=e[S+2]}function m(){let y=new T,b=new T,S=new T,w=new T,A=new k,_=new k,x=new k;for(let M=0,E=0;M<s.length;M+=9,E+=6){y.set(s[M+0],s[M+1],s[M+2]),b.set(s[M+3],s[M+4],s[M+5]),S.set(s[M+6],s[M+7],s[M+8]),A.set(o[E+0],o[E+1]),_.set(o[E+2],o[E+3]),x.set(o[E+4],o[E+5]),w.copy(y).add(b).add(S).divideScalar(3);let C=g(w);p(A,E+0,y,C),p(_,E+2,b,C),p(x,E+4,S,C)}}function p(y,b,S,w){w<0&&y.x===1&&(o[b]=y.x-1),S.x===0&&S.z===0&&(o[b]=w/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function v(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}static fromJSON(e){return new Vl(e.vertices,e.indices,e.radius,e.details)}},Hl=class extends Vl{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Hl(e.radius,e.detail)}};var Vs=class extends _a{constructor(e){super(e),this.uuid=Ji(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(new _a().fromJSON(i))}return this}},lN={triangulate:function(r,e,t=2){let n=e&&e.length,i=n?e[0]*t:r.length,s=B1(r,0,i,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,h,f,d;if(n&&(s=dN(r,e,s,t)),r.length>80*t){a=u=r[0],l=c=r[1];for(let m=t;m<i;m+=t)h=r[m],f=r[m+1],h<a&&(a=h),f<l&&(l=f),h>u&&(u=h),f>c&&(c=f);d=Math.max(u-a,c-l),d=d!==0?1/d:0}return xh(s,o,t,a,l,d),o}};function B1(r,e,t,n,i){let s,o;if(i===TN(r,e,t,n)>0)for(s=e;s<t;s+=n)o=a1(s,r[s],r[s+1],o);else for(s=t-n;s>=e;s-=n)o=a1(s,r[s],r[s+1],o);return o&&wp(o,o.next)&&(Sh(o),o=o.next),o}function wo(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(wp(t,t.next)||Zt(t.prev,t,t.next)===0)){if(Sh(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function xh(r,e,t,n,i,s,o){if(!r)return;!o&&s&&yN(r,n,i,s);let a=r,l,u;for(;r.prev!==r.next;){if(l=r.prev,u=r.next,s?uN(r,n,i,s):cN(r)){e.push(l.i/t),e.push(r.i/t),e.push(u.i/t),Sh(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=hN(wo(r),e,t),xh(r,e,t,n,i,s,2)):o===2&&fN(r,e,t,n,i,s):xh(wo(r),e,t,n,i,s,1);break}}}function cN(r){let e=r.prev,t=r,n=r.next;if(Zt(e,t,n)>=0)return!1;let i=r.next.next;for(;i!==r.prev;){if(Ll(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&Zt(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function uN(r,e,t,n){let i=r.prev,s=r,o=r.next;if(Zt(i,s,o)>=0)return!1;let a=i.x<s.x?i.x<o.x?i.x:o.x:s.x<o.x?s.x:o.x,l=i.y<s.y?i.y<o.y?i.y:o.y:s.y<o.y?s.y:o.y,u=i.x>s.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,c=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,h=Ry(a,l,e,t,n),f=Ry(u,c,e,t,n),d=r.prevZ,m=r.nextZ;for(;d&&d.z>=h&&m&&m.z<=f;){if(d!==r.prev&&d!==r.next&&Ll(i.x,i.y,s.x,s.y,o.x,o.y,d.x,d.y)&&Zt(d.prev,d,d.next)>=0||(d=d.prevZ,m!==r.prev&&m!==r.next&&Ll(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Zt(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;d&&d.z>=h;){if(d!==r.prev&&d!==r.next&&Ll(i.x,i.y,s.x,s.y,o.x,o.y,d.x,d.y)&&Zt(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;m&&m.z<=f;){if(m!==r.prev&&m!==r.next&&Ll(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Zt(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function hN(r,e,t){let n=r;do{let i=n.prev,s=n.next.next;!wp(i,s)&&N1(i,n,n.next,s)&&bh(i,s)&&bh(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),Sh(n),Sh(n.next),n=r=s),n=n.next}while(n!==r);return wo(n)}function fN(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&SN(o,a)){let l=F1(o,a);o=wo(o,o.next),l=wo(l,l.next),xh(o,e,t,n,i,s),xh(l,e,t,n,i,s);return}a=a.next}o=o.next}while(o!==r)}function dN(r,e,t,n){let i=[],s,o,a,l,u;for(s=0,o=e.length;s<o;s++)a=e[s]*n,l=s<o-1?e[s+1]*n:r.length,u=B1(r,a,l,n,!1),u===u.next&&(u.steiner=!0),i.push(bN(u));for(i.sort(pN),s=0;s<i.length;s++)mN(i[s],t),t=wo(t,t.next);return t}function pN(r,e){return r.x-e.x}function mN(r,e){if(e=gN(r,e),e){let t=F1(e,r);wo(e,e.next),wo(t,t.next)}}function gN(r,e){let t=e,n=r.x,i=r.y,s=-1/0,o;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){let f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>s){if(s=f,f===n){if(i===t.y)return t;if(i===t.next.y)return t.next}o=t.x<t.next.x?t:t.next}}t=t.next}while(t!==e);if(!o)return null;if(n===s)return o;let a=o,l=o.x,u=o.y,c=1/0,h;t=o;do n>=t.x&&t.x>=l&&n!==t.x&&Ll(i<u?n:s,i,l,u,i<u?s:n,i,t.x,t.y)&&(h=Math.abs(i-t.y)/(n-t.x),bh(t,r)&&(h<c||h===c&&(t.x>o.x||t.x===o.x&&vN(o,t)))&&(o=t,c=h)),t=t.next;while(t!==a);return o}function vN(r,e){return Zt(r.prev,r,e.prev)<0&&Zt(e.next,r,r.next)<0}function yN(r,e,t,n){let i=r;do i.z===null&&(i.z=Ry(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,xN(i)}function xN(r){let e,t,n,i,s,o,a,l,u=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<u&&(a++,n=n.nextZ,!!n);e++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,u*=2}while(o>1);return r}function Ry(r,e,t,n,i){return r=32767*(r-t)*i,e=32767*(e-n)*i,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function bN(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function Ll(r,e,t,n,i,s,o,a){return(i-o)*(e-a)-(r-o)*(s-a)>=0&&(r-o)*(n-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(i-o)*(n-a)>=0}function SN(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!wN(r,e)&&(bh(r,e)&&bh(e,r)&&AN(r,e)&&(Zt(r.prev,r,e.prev)||Zt(r,e.prev,e))||wp(r,e)&&Zt(r.prev,r,r.next)>0&&Zt(e.prev,e,e.next)>0)}function Zt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function wp(r,e){return r.x===e.x&&r.y===e.y}function N1(r,e,t,n){let i=Yd(Zt(r,e,t)),s=Yd(Zt(r,e,n)),o=Yd(Zt(t,n,r)),a=Yd(Zt(t,n,e));return!!(i!==s&&o!==a||i===0&&Xd(r,t,e)||s===0&&Xd(r,n,e)||o===0&&Xd(t,r,n)||a===0&&Xd(t,e,n))}function Xd(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Yd(r){return r>0?1:r<0?-1:0}function wN(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&N1(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function bh(r,e){return Zt(r.prev,r,r.next)<0?Zt(r,e,r.next)>=0&&Zt(r,r.prev,e)>=0:Zt(r,e,r.prev)<0||Zt(r,r.next,e)<0}function AN(r,e){let t=r,n=!1,i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function F1(r,e){let t=new By(r.i,r.x,r.y),n=new By(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function a1(r,e,t,n){let i=new By(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Sh(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function By(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function TN(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var Wl=class{static area(e){let t=e.length,n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return Wl.area(e)<0}static triangulateShape(e,t){let n=[],i=[],s=[];l1(e),c1(n,e);let o=e.length;t.forEach(l1);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,c1(n,t[l]);let a=lN.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function l1(r){let e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function c1(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}var jl=class extends Vl{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new jl(e.radius,e.detail)}};var Ea=class extends Le{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],h=new T,f=new T,d=[],m=[],p=[],g=[];for(let v=0;v<=n;v++){let y=[],b=v/n,S=0;v==0&&o==0?S=.5/t:v==n&&l==Math.PI&&(S=-.5/t);for(let w=0;w<=t;w++){let A=w/t;h.x=-e*Math.cos(i+A*s)*Math.sin(o+b*a),h.y=e*Math.cos(o+b*a),h.z=e*Math.sin(i+A*s)*Math.sin(o+b*a),m.push(h.x,h.y,h.z),f.copy(h).normalize(),p.push(f.x,f.y,f.z),g.push(A+S,1-b),y.push(u++)}c.push(y)}for(let v=0;v<n;v++)for(let y=0;y<t;y++){let b=c[v][y+1],S=c[v][y],w=c[v+1][y],A=c[v+1][y+1];(v!==0||o>0)&&d.push(b,S,A),(v!==n-1||l<Math.PI)&&d.push(S,w,A)}this.setIndex(d),this.setAttribute("position",new Te(m,3)),this.setAttribute("normal",new Te(p,3)),this.setAttribute("uv",new Te(g,2))}static fromJSON(e){return new Ea(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};var ql=class extends Le{constructor(e=1,t=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],l=[],u=[],c=[],h=new T,f=new T,d=new T,m=new T,p=new T,g=new T,v=new T;for(let b=0;b<=n;++b){let S=b/n*s*Math.PI*2;y(S,s,o,e,d),y(S+.01,s,o,e,m),g.subVectors(m,d),v.addVectors(m,d),p.crossVectors(g,v),v.crossVectors(p,g),p.normalize(),v.normalize();for(let w=0;w<=i;++w){let A=w/i*Math.PI*2,_=-t*Math.cos(A),x=t*Math.sin(A);h.x=d.x+(_*v.x+x*p.x),h.y=d.y+(_*v.y+x*p.y),h.z=d.z+(_*v.z+x*p.z),l.push(h.x,h.y,h.z),f.subVectors(h,d).normalize(),u.push(f.x,f.y,f.z),c.push(b/n),c.push(w/i)}}for(let b=1;b<=n;b++)for(let S=1;S<=i;S++){let w=(i+1)*(b-1)+(S-1),A=(i+1)*b+(S-1),_=(i+1)*b+S,x=(i+1)*(b-1)+S;a.push(w,A,x),a.push(A,_,x)}this.setIndex(a),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(u,3)),this.setAttribute("uv",new Te(c,2));function y(b,S,w,A,_){let x=Math.cos(b),M=Math.sin(b),E=w/S*b,C=Math.cos(E);_.x=A*(2+C)*.5*x,_.y=A*(2+C)*M*.5,_.z=A*Math.sin(E)*.5}}static fromJSON(e){return new ql(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};var wr={arraySlice:function(r,e,t){return wr.isTypedArray(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)},convertArray:function(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)},isTypedArray:function(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)},getKeyframeOrder:function(r){function e(i,s){return r[i]-r[s]}let t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n},sortedArray:function(r,e,t){let n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i},flattenJSON:function(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)},subclip:function(r,e,t,n,i=30){let s=r.clone();s.name=e;let o=[];for(let l=0;l<s.tracks.length;++l){let u=s.tracks[l],c=u.getValueSize(),h=[],f=[];for(let d=0;d<u.times.length;++d){let m=u.times[d]*i;if(!(m<t||m>=n)){h.push(u.times[d]);for(let p=0;p<c;++p)f.push(u.values[d*c+p])}}h.length!==0&&(u.times=wr.convertArray(h,u.times.constructor),u.values=wr.convertArray(f,u.values.constructor),o.push(u))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(r,e=0,t=r,n=30){n<=0&&(n=30);let i=t.tracks.length,s=e/n;for(let o=0;o<i;++o){let a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;let u=r.tracks.find(function(v){return v.name===a.name&&v.ValueTypeName===l});if(u===void 0)continue;let c=0,h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=h/3);let f=0,d=u.getValueSize();u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);let m=a.times.length-1,p;if(s<=a.times[0]){let v=c,y=h-c;p=wr.arraySlice(a.values,v,y)}else if(s>=a.times[m]){let v=m*h+c,y=v+h-c;p=wr.arraySlice(a.values,v,y)}else{let v=a.createInterpolant(),y=c,b=h-c;v.evaluate(s),p=wr.arraySlice(v.resultBuffer,y,b)}l==="quaternion"&&new ut().fromArray(p).normalize().conjugate().toArray(p);let g=u.times.length;for(let v=0;v<g;++v){let y=v*d+f;if(l==="quaternion")ut.multiplyQuaternionsFlat(u.values,y,p,0,u.values,y);else{let b=d-f*2;for(let S=0;S<b;++S)u.values[y+S]-=p[S]}}}return r.blendMode=$I,r}},Xl=class{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],s=t[n-1];e:{t:{let o;r:{n:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break n;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break t}o=t.length;break r}if(!(e>=s)){let a=t[1];e<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break t}o=n,n=0;break r}break e}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Ny=class extends Xl{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:yw,endingEnd:yw}}intervalChanged_(e,t,n){let i=this.parameterPositions,s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case xw:s=e,a=2*t-n;break;case bw:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case xw:o=e,l=2*n-t;break;case bw:o=1,l=n+i[1]-i[0];break;default:o=e-1,l=t}let u=(n-t)*.5,c=this.valueSize;this._weightPrev=u/(t-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,u=l-a,c=this._offsetPrev,h=this._offsetNext,f=this._weightPrev,d=this._weightNext,m=(n-t)/(i-t),p=m*m,g=p*m,v=-f*g+2*f*p-f*m,y=(1+f)*g+(-1.5-2*f)*p+(-.5+f)*m+1,b=(-1-d)*g+(1.5+d)*p+.5*m,S=d*g-d*p;for(let w=0;w!==a;++w)s[w]=v*o[c+w]+y*o[u+w]+b*o[l+w]+S*o[h+w];return s}},Fy=class extends Xl{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,u=l-a,c=(n-t)/(i-t),h=1-c;for(let f=0;f!==a;++f)s[f]=o[u+f]*h+o[l+f]*c;return s}},ky=class extends Xl{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},Mi=class{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=wr.convertArray(t,this.TimeBufferType),this.values=wr.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:wr.convertArray(e.times,Array),values:wr.convertArray(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new ky(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Fy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Ny(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case $d:t=this.InterpolantFactoryMethodDiscrete;break;case ep:t=this.InterpolantFactoryMethodLinear;break;case Iv:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return $d;case this.InterpolantFactoryMethodLinear:return ep;case this.InterpolantFactoryMethodSmooth:return Iv}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=wr.arraySlice(n,s,o),this.values=wr.arraySlice(this.values,s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&wr.isTypedArray(i))for(let a=0,l=i.length;a!==l;++a){let u=i[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),e=!1;break}}return e}optimize(){let e=wr.arraySlice(this.times),t=wr.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===Iv,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=e[a],c=e[a+1];if(u!==c&&(a!==1||u!==e[0]))if(i)l=!0;else{let h=a*n,f=h-n,d=h+n;for(let m=0;m!==n;++m){let p=t[h+m];if(p!==t[f+m]||p!==t[d+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let h=a*n,f=o*n;for(let d=0;d!==n;++d)t[f+d]=t[h+d]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)t[l+u]=t[a+u];++o}return o!==e.length?(this.times=wr.arraySlice(e,0,o),this.values=wr.arraySlice(t,0,o*n)):(this.times=e,this.values=t),this}clone(){let e=wr.arraySlice(this.times,0),t=wr.arraySlice(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Mi.prototype.TimeBufferType=Float32Array;Mi.prototype.ValueBufferType=Float32Array;Mi.prototype.DefaultInterpolation=ep;var Ca=class extends Mi{};Ca.prototype.ValueTypeName="bool";Ca.prototype.ValueBufferType=Array;Ca.prototype.DefaultInterpolation=$d;Ca.prototype.InterpolantFactoryMethodLinear=void 0;Ca.prototype.InterpolantFactoryMethodSmooth=void 0;var Uy=class extends Mi{};Uy.prototype.ValueTypeName="color";var Gy=class extends Mi{};Gy.prototype.ValueTypeName="number";var zy=class extends Xl{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t),u=e*a;for(let c=u+a;u!==c;u+=4)ut.slerpFlat(s,0,o,u-a,o,u,l);return s}},wh=class extends Mi{InterpolantFactoryMethodLinear(e){return new zy(this.times,this.values,this.getValueSize(),e)}};wh.prototype.ValueTypeName="quaternion";wh.prototype.DefaultInterpolation=ep;wh.prototype.InterpolantFactoryMethodSmooth=void 0;var Pa=class extends Mi{};Pa.prototype.ValueTypeName="string";Pa.prototype.ValueBufferType=Array;Pa.prototype.DefaultInterpolation=$d;Pa.prototype.InterpolantFactoryMethodLinear=void 0;Pa.prototype.InterpolantFactoryMethodSmooth=void 0;var Vy=class extends Mi{};Vy.prototype.ValueTypeName="vector";var u1={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},Ah=class{constructor(e,t,n){let i=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(c){a++,s===!1&&i.onStart!==void 0&&i.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,i.onProgress!==void 0&&i.onProgress(c,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(c){i.onError!==void 0&&i.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,h){return u.push(c,h),this},this.removeHandler=function(c){let h=u.indexOf(c);return h!==-1&&u.splice(h,2),this},this.getHandler=function(c){for(let h=0,f=u.length;h<f;h+=2){let d=u[h],m=u[h+1];if(d.global&&(d.lastIndex=0),d.test(c))return m}return null}}},_N=new Ah,Yl=class{constructor(e){this.manager=e!==void 0?e:_N,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},Fs={},Ql=class extends Yl{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=u1.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Fs[e]!==void 0){Fs[e].push({onLoad:t,onProgress:n,onError:i});return}Fs[e]=[],Fs[e].push({onLoad:t,onProgress:n,onError:i});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=Fs[e],h=u.body.getReader(),f=u.headers.get("Content-Length"),d=f?parseInt(f):0,m=d!==0,p=0,g=new ReadableStream({start(v){y();function y(){h.read().then(({done:b,value:S})=>{if(b)v.close();else{p+=S.byteLength;let w=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:d});for(let A=0,_=c.length;A<_;A++){let x=c[A];x.onProgress&&x.onProgress(w)}v.enqueue(S),y()}})}}});return new Response(g)}else throw Error(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),f=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(f);return u.arrayBuffer().then(m=>d.decode(m))}}}).then(u=>{u1.add(e,u);let c=Fs[e];delete Fs[e];for(let h=0,f=c.length;h<f;h++){let d=c[h];d.onLoad&&d.onLoad(u)}}).catch(u=>{let c=Fs[e];if(c===void 0)throw this.manager.itemError(e),u;delete Fs[e];for(let h=0,f=c.length;h<f;h++){let d=c[h];d.onError&&d.onError(u)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}};var Zl=class extends yt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Be(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},Da=class extends Zl{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(yt.DefaultUp),this.updateMatrix(),this.groundColor=new Be(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},h1=new we,f1=new T,d1=new T,Th=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new k(512,512),this.map=null,this.mapPass=null,this.matrix=new we,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new gh,this._frameExtents=new k(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;f1.setFromMatrixPosition(e.matrixWorld),t.position.copy(f1),d1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(d1),t.updateMatrixWorld(),h1.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(h1),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Hy=class extends Th{constructor(){super(new hr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=dh*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},up=class extends Zl{constructor(e,t,n=0,i=Math.PI/3,s=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(yt.DefaultUp),this.updateMatrix(),this.target=new yt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.shadow=new Hy}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},p1=new we,ih=new T,ly=new T,Wy=class extends Th{constructor(){super(new hr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new k(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(1,0,1,1)],this._cubeDirections=[new T(1,0,0),new T(-1,0,0),new T(0,0,1),new T(0,0,-1),new T(0,1,0),new T(0,-1,0)],this._cubeUps=[new T(0,1,0),new T(0,1,0),new T(0,1,0),new T(0,1,0),new T(0,0,1),new T(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),ih.setFromMatrixPosition(e.matrixWorld),n.position.copy(ih),ly.copy(n.position),ly.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(ly),n.updateMatrixWorld(),i.makeTranslation(-ih.x,-ih.y,-ih.z),p1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(p1)}},hp=class extends Zl{constructor(e,t,n=0,i=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Wy}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},jy=class extends Th{constructor(){super(new Fl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},fp=class extends Zl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(yt.DefaultUp),this.updateMatrix(),this.target=new yt,this.shadow=new jy}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};var qy=class extends Le{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){let e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},Kl=class extends Yl{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new Ql(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){let t={},n={};function i(d,m){if(t[m]!==void 0)return t[m];let g=d.interleavedBuffers[m],v=s(d,g.buffer),y=Td(g.type,v),b=new lp(y,g.stride);return b.uuid=g.uuid,t[m]=b,b}function s(d,m){if(n[m]!==void 0)return n[m];let g=d.arrayBuffers[m],v=new Uint32Array(g).buffer;return n[m]=v,v}let o=e.isInstancedBufferGeometry?new qy:new Le,a=e.data.index;if(a!==void 0){let d=Td(a.type,a.array);o.setIndex(new We(d,1))}let l=e.data.attributes;for(let d in l){let m=l[d],p;if(m.isInterleavedBufferAttribute){let g=i(e.data,m.data);p=new wa(g,m.itemSize,m.offset,m.normalized)}else{let g=Td(m.type,m.array),v=m.isInstancedBufferAttribute?cp:We;p=new v(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(d,p)}let u=e.data.morphAttributes;if(u)for(let d in u){let m=u[d],p=[];for(let g=0,v=m.length;g<v;g++){let y=m[g],b;if(y.isInterleavedBufferAttribute){let S=i(e.data,y.data);b=new wa(S,y.itemSize,y.offset,y.normalized)}else{let S=Td(y.type,y.array);b=new We(S,y.itemSize,y.normalized)}y.name!==void 0&&(b.name=y.name),p.push(b)}o.morphAttributes[d]=p}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let d=0,m=h.length;d!==m;++d){let p=h[d];o.addGroup(p.start,p.count,p.materialIndex)}let f=e.data.boundingSphere;if(f!==void 0){let d=new T;f.center!==void 0&&d.fromArray(f.center),o.boundingSphere=new Fr(d,f.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}};var dp=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=m1(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=m1();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function m1(){return(typeof performance>"u"?Date:performance).now()}var t0="\\[\\]\\.:\\/",MN=new RegExp("["+t0+"]","g"),r0="[^"+t0+"]",EN="[^"+t0.replace("\\.","")+"]",CN=/((?:WC+[\/:])*)/.source.replace("WC",r0),PN=/(WCOD+)?/.source.replace("WCOD",EN),DN=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",r0),IN=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",r0),LN=new RegExp("^"+CN+PN+DN+IN+"$"),ON=["material","materials","bones"],Xy=class{constructor(e,t,n){let i=n||It.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},It=class{constructor(e,t,n){this.path=t,this.parsedPath=n||It.parseTrackName(t),this.node=It.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new It.Composite(e,t,n):new It(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(MN,"")}static parseTrackName(e){let t=LN.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);ON.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,i=t.propertyName,s=t.propertyIndex;if(e||(e=It.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let c=0;c<e.length;c++)if(e[c].name===u){u=c;break}break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(u!==void 0){if(e[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[u]}}let o=e[i];if(o===void 0){let u=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};It.Composite=Xy;It.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};It.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};It.prototype.GetterByBindingType=[It.prototype._getValue_direct,It.prototype._getValue_array,It.prototype._getValue_arrayElement,It.prototype._getValue_toArray];It.prototype.SetterByBindingTypeAndVersioning=[[It.prototype._setValue_direct,It.prototype._setValue_direct_setNeedsUpdate,It.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[It.prototype._setValue_array,It.prototype._setValue_array_setNeedsUpdate,It.prototype._setValue_array_setMatrixWorldNeedsUpdate],[It.prototype._setValue_arrayElement,It.prototype._setValue_arrayElement_setNeedsUpdate,It.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[It.prototype._setValue_fromArray,It.prototype._setValue_fromArray_setNeedsUpdate,It.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Ae=class{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new Ae(this.value.clone===void 0?this.value:this.value.clone())}};var Jl=class{constructor(e,t,n=0,i=1/0){this.ray=new Ti(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new ph,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return Yy(e,this,n,t),n.sort(g1),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Yy(e[i],this,n,t);return n.sort(g1),n}};function g1(r,e){return r.distance-e.distance}function Yy(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)Yy(i[s],e,t,!0)}}var _h=class{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Ar(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var v1=new k,pp=class{constructor(e=new k(1/0,1/0),t=new k(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=v1.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return v1.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},y1=new T,Qd=new T,_r=class{constructor(e=new T,t=new T){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){y1.subVectors(e,this.start),Qd.subVectors(this.end,this.start);let n=Qd.dot(Qd),s=Qd.dot(y1)/n;return t&&(s=Ar(s,0,1)),s}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},x1=new T,mp=class extends yt{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;let n=new Le,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;i.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new Te(i,3));let s=new ri({fog:!1,toneMapped:!1});this.cone=new So(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),x1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(x1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var gp=class extends fr{constructor(e,t,n){let i=new Ea(t,4,2),s=new mh({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.light.updateMatrixWorld(),this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var b1=new T,Zd=new T,S1=new T,vp=class extends yt{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,t===void 0&&(t=1);let i=new Le;i.setAttribute("position",new Te([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new ri({fog:!1,toneMapped:!1});this.lightPlane=new Aa(i,s),this.add(this.lightPlane),i=new Le,i.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new Aa(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){b1.setFromMatrixPosition(this.light.matrixWorld),Zd.setFromMatrixPosition(this.light.target.matrixWorld),S1.subVectors(Zd,b1),this.lightPlane.lookAt(Zd),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Zd),this.targetLine.scale.z=S1.length()}},Kd=new T,$t=new _i,ii=class extends So{constructor(e){let t=new Le,n=new ri({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,p){l(m),l(p)}function l(m){i.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}t.setAttribute("position",new Te(i,3)),t.setAttribute("color",new Te(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Be(16755200),c=new Be(16711680),h=new Be(43775),f=new Be(16777215),d=new Be(3355443);this.setColors(u,c,h,f,d)}setColors(e,t,n,i,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,n=1,i=1;$t.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ur("c",t,e,$t,0,0,-1),ur("t",t,e,$t,0,0,1),ur("n1",t,e,$t,-n,-i,-1),ur("n2",t,e,$t,n,-i,-1),ur("n3",t,e,$t,-n,i,-1),ur("n4",t,e,$t,n,i,-1),ur("f1",t,e,$t,-n,-i,1),ur("f2",t,e,$t,n,-i,1),ur("f3",t,e,$t,-n,i,1),ur("f4",t,e,$t,n,i,1),ur("u1",t,e,$t,n*.7,i*1.1,-1),ur("u2",t,e,$t,-n*.7,i*1.1,-1),ur("u3",t,e,$t,0,i*2,-1),ur("cf1",t,e,$t,-n,0,1),ur("cf2",t,e,$t,n,0,1),ur("cf3",t,e,$t,0,-i,1),ur("cf4",t,e,$t,0,i,1),ur("cn1",t,e,$t,-n,0,-1),ur("cn2",t,e,$t,n,0,-1),ur("cn3",t,e,$t,0,-i,-1),ur("cn4",t,e,$t,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ur(r,e,t,n,i,s,o){Kd.set(i,s,o).unproject(n);let a=e[r];if(a!==void 0){let l=t.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],Kd.x,Kd.y,Kd.z)}}var Ia=class extends So{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Le;s.setIndex(new We(n,1)),s.setAttribute("position",new Te(i,3)),super(s,new ri({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}};var yp=class extends So{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Le;i.setAttribute("position",new Te(t,3)),i.setAttribute("color",new Te(n,3));let s=new ri({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){let i=new Be,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var{floatView:qq,uint32View:Xq,baseTable:Yq,shiftTable:Qq,mantissaTable:Zq,exponentTable:Kq,offsetTable:Jq}=RN();function RN(){let r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){let u=l-127;u<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):u<-14?(n[l]=1024>>-u-14,n[l|256]=1024>>-u-14|32768,i[l]=-u-1,i[l|256]=-u-1):u<=15?(n[l]=u+15<<10,n[l|256]=u+15<<10|32768,i[l]=13,i[l|256]=13):u<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let u=l<<13,c=0;for(;(u&8388608)===0;)u<<=1,c-=8388608;u&=-8388609,c+=947912704,s[l]=u|c}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}var xp=class extends xt{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:La}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=La);var rc=".",Mh=Symbol("target"),n0=Symbol("unsubscribe");function Eh(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function k1(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var Hn=Array.isArray;function Oa(r){return typeof r=="symbol"}var BN={after:(r,e)=>Hn(r)?r.slice(e.length):e===""?r:r.slice(e.length+1),concat:(r,e)=>Hn(r)?(r=[...r],e&&r.push(e),r):e&&e.toString!==void 0?(r!==""&&(r+=rc),Oa(e)?r+e.toString():r+e):r,initial:r=>{if(Hn(r))return r.slice(0,-1);if(r==="")return r;let e=r.lastIndexOf(rc);return e===-1?"":r.slice(0,e)},last:r=>{if(Hn(r))return r[r.length-1]||"";if(r==="")return r;let e=r.lastIndexOf(rc);return e===-1?r:r.slice(e+1)},walk:(r,e)=>{if(Hn(r))for(let t of r)e(t);else if(r!==""){let t=0,n=r.indexOf(rc);if(n===-1)e(r);else for(;t<r.length;)n===-1&&(n=r.length),e(r.slice(t,n)),t=n+1,n=r.indexOf(rc,t)}},get(r,e){return this.walk(e,t=>{r&&(r=r[t])}),r}},yn=BN;function i0(r){return typeof r=="object"&&typeof r.next=="function"}function s0(r,e,t,n,i){let s=r.next;if(e.name==="entries")r.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],e,o.value[0],n),o.value[1]=i(o.value[1],e,o.value[0],n)),o};else if(e.name==="values"){let o=t[Mh].keys();r.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,e,o.next().value,n)),a}}else r.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,e,o.value,n)),o};return r}function Ap(r,e,t){return r.isUnsubscribed||e.ignoreSymbols&&Oa(t)||e.ignoreUnderscores&&t.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(t)}var Ch=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),n=t.get(e);return n===void 0&&(n={},t.set(e,n)),n}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let n=this._getProperties(e),i=n[t];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(e,t),n[t]=i),i}getProxy(e,t,n,i){if(this.isUnsubscribed)return e;let s=e[i],o=s||e;this._pathCache.set(o,t);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(e,n):e,this._proxyCache.set(o,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,yn.get(t,this.getPath(e)))}defineProperty(e,t,n){return Reflect.defineProperty(e,t,n)?(this.isUnsubscribed||(this._getProperties(e)[t]=n),!0):!1}setProperty(e,t,n,i,s){if(!this._equals(s,n)||!(t in e)){let o=this._getOwnPropertyDescriptor(e,t);return o!==void 0&&"set"in o?Reflect.set(e,t,n,i):Reflect.set(e,t,n)}return!0}deleteProperty(e,t,n){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(e);i&&(delete i[t],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(e,t,n){let i=this._getOwnPropertyDescriptor(t,n);return e!==void 0&&i!==void 0&&Object.is(e.value,i.value)&&(e.writable||!1)===(i.writable||!1)&&(e.enumerable||!1)===(i.enumerable||!1)&&(e.configurable||!1)===(i.configurable||!1)&&e.get===i.get&&e.set===i.set}isGetInvariant(e,t){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function nc(r){return toString.call(r)==="[object Object]"}function ic(){return!0}function Ao(r,e){return r.length!==e.length||r.some((t,n)=>e[n]!==t)}var Tp=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var NN=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),o0={push:ic,pop:ic,shift:ic,unshift:ic,copyWithin:Ao,reverse:Ao,sort:Ao,splice:Ao,flat:Ao,fill:Ao},U1=new Set([...Tp,...NN,...Object.keys(o0)]);function sc(r,e){if(r.size!==e.size)return!0;for(let t of r)if(!e.has(t))return!0;return!1}var a0=["keys","values","entries"],l0=new Set(["has","toString"]),c0={add:sc,clear:sc,delete:sc,forEach:sc},G1=new Set([...l0,...Object.keys(c0),...a0]);function oc(r,e){if(r.size!==e.size)return!0;let t;for(let[n,i]of r)if(t=e.get(n),t!==i||t===void 0&&!e.has(n))return!0;return!1}var FN=new Set([...l0,"get"]),u0={set:oc,clear:oc,delete:oc,forEach:oc},z1=new Set([...FN,...Object.keys(u0),...a0]);var Ur=class{constructor(e,t,n,i){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return Tp.has(e)}_shallowClone(e){let t=e;if(nc(e))t={...e};else if(Hn(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(n=>this._shallowClone(n)));else if(e instanceof Map){t=new Map;for(let[n,i]of e.entries())t.set(n,this._shallowClone(i))}return this._clonedCache.add(t),t}preferredThisArg(e,t,n,i){return e?(Hn(i)?this._onIsChanged=o0[t]:i instanceof Set?this._onIsChanged=c0[t]:i instanceof Map&&(this._onIsChanged=u0[t]),i):n}update(e,t,n){let i=yn.after(e,this._path);if(t!=="length"){let s=this.clone;yn.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:t,previous:n}),s&&s[t]&&(s[t]=n)}this._isChanged=!0}undo(e){let t;for(let n=this._changes.length-1;n!==-1;n--)t=this._changes[n],yn.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}};var ac=class extends Ur{static isHandledMethod(e){return U1.has(e)}};var Ph=class extends Ur{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};var lc=class extends Ur{static isHandledMethod(e){return G1.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}};var cc=class extends Ur{static isHandledMethod(e){return z1.has(e)}undo(e){for(let[t,n]of this.clone.entries())e.set(t,n);for(let t of e.keys())this.clone.has(t)||e.delete(t)}};var Dh=class extends Ur{constructor(e,t,n,i){super(void 0,t,n,i),this._arg1=n[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}};var Ih=class extends Ur{constructor(e,t,n,i){super(void 0,t,n,i),this._weakKey=n[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}};var Ci=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return nc(e)||Hn(e)||Eh(e)}static isHandledMethod(e,t){return nc(e)?Ur.isHandledMethod(t):Hn(e)?ac.isHandledMethod(t):e instanceof Set?lc.isHandledMethod(t):e instanceof Map?cc.isHandledMethod(t):Eh(e)}get isCloning(){return this._stack.length>0}start(e,t,n){let i=Ur;Hn(e)?i=ac:e instanceof Date?i=Ph:e instanceof Set?i=lc:e instanceof Map?i=cc:e instanceof WeakSet?i=Dh:e instanceof WeakMap&&(i=Ih),this._stack.push(new i(e,t,n,this._hasOnValidate))}update(e,t,n){this._stack[this._stack.length-1].update(e,t,n)}preferredThisArg(e,t,n){let{name:i}=e,s=Ci.isHandledMethod(n,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,t,n)}isChanged(e,t,n){return this._stack[this._stack.length-1].isChanged(e,t,n)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var kN={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},h0=(r,e,t={})=>{t={...kN,...t};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=t,l=new Ch(i),u=typeof t.onValidate=="function",c=new Ci(u),h=(y,b,S,w,A)=>!u||c.isCloning||t.onValidate(yn.concat(l.getPath(y),b),S,w,A)===!0,f=(y,b,S,w)=>{!Ap(l,t,b)&&!(o&&l.isDetached(y,r))&&d(l.getPath(y),b,S,w)},d=(y,b,S,w,A)=>{c.isCloning?c.update(y,b,w):e(yn.concat(y,b),S,w,A)},m=y=>y&&(y[n]||y),p=(y,b,S,w)=>k1(y)||S==="constructor"||s&&!Ci.isHandledMethod(b,S)||Ap(l,t,S)||l.isGetInvariant(b,S)||o&&l.isDetached(b,r)?y:(w===void 0&&(w=l.getPath(b)),l.getProxy(y,yn.concat(w,S),g,n)),g={get(y,b,S){if(Oa(b)){if(b===n||b===Mh)return y;if(b===n0&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let w=Eh(y)?Reflect.get(y,b):Reflect.get(y,b,S);return p(w,y,b)},set(y,b,S,w){S=m(S);let A=y[n]||y,_=A[b];if(i(_,S)&&b in y)return!0;let x=h(y,b,S,_);return x&&l.setProperty(A,b,S,w,_)?(f(y,b,y[b],_),!0):!x},defineProperty(y,b,S){if(!l.isSameDescriptor(S,y,b)){let w=y[b];h(y,b,S.value,w)&&l.defineProperty(y,b,S,w)&&f(y,b,S.value,w)}return!0},deleteProperty(y,b){if(!Reflect.has(y,b))return!0;let S=Reflect.get(y,b),w=h(y,b,void 0,S);return w&&l.deleteProperty(y,b,S)?(f(y,b,void 0,S),!0):!w},apply(y,b,S){let w=b[n]||b;if(l.isUnsubscribed)return Reflect.apply(y,w,S);if((a===!1||a!==!0&&!a.includes(y.name))&&Ci.isHandledType(w)){let A=yn.initial(l.getPath(y)),_=Ci.isHandledMethod(w,y.name);c.start(w,A,S);let x=Reflect.apply(y,c.preferredThisArg(y,b,w),_?S.map(C=>m(C)):S),M=c.isChanged(w,i),E=c.stop();if(Ci.isHandledType(x)&&_&&(b instanceof Map&&y.name==="get"&&(A=yn.concat(A,S[0])),x=l.getProxy(x,A,g)),M){let C={name:y.name,args:S,result:x},P=c.isCloning?yn.initial(A):A,L=c.isCloning?yn.last(A):"";h(yn.get(r,P),L,w,E,C)?d(P,L,w,E,C):c.undo(w)}return(b instanceof Map||b instanceof Set)&&i0(x)?s0(x,y,b,A,p):x}return Reflect.apply(y,b,S)}},v=l.getProxy(r,t.pathAsArray?[]:"",g);return e=e.bind(v),u&&(t.onValidate=t.onValidate.bind(v)),v};h0.target=r=>r&&r[Mh]||r;h0.unsubscribe=r=>r[n0]||r;var f0=h0;var UN=typeof global=="object"&&global&&global.Object===Object&&global,_p=UN;var GN=typeof self=="object"&&self&&self.Object===Object&&self,zN=_p||GN||Function("return this")(),rr=zN;var VN=rr.Symbol,xn=VN;var V1=Object.prototype,HN=V1.hasOwnProperty,WN=V1.toString,Lh=xn?xn.toStringTag:void 0;function jN(r){var e=HN.call(r,Lh),t=r[Lh];try{r[Lh]=void 0;var n=!0}catch{}var i=WN.call(r);return n&&(e?r[Lh]=t:delete r[Lh]),i}var H1=jN;var qN=Object.prototype,XN=qN.toString;function YN(r){return XN.call(r)}var W1=YN;var QN="[object Null]",ZN="[object Undefined]",j1=xn?xn.toStringTag:void 0;function KN(r){return r==null?r===void 0?ZN:QN:j1&&j1 in Object(r)?H1(r):W1(r)}var Wn=KN;function JN(r){return r!=null&&typeof r=="object"}var nn=JN;var $N="[object Symbol]";function eF(r){return typeof r=="symbol"||nn(r)&&Wn(r)==$N}var To=eF;function tF(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}var Mp=tF;var rF=Array.isArray,Mr=rF;var nF=1/0,q1=xn?xn.prototype:void 0,X1=q1?q1.toString:void 0;function Y1(r){if(typeof r=="string")return r;if(Mr(r))return Mp(r,Y1)+"";if(To(r))return X1?X1.call(r):"";var e=r+"";return e=="0"&&1/r==-nF?"-0":e}var Q1=Y1;var iF=/\s/;function sF(r){for(var e=r.length;e--&&iF.test(r.charAt(e)););return e}var Z1=sF;var oF=/^\s+/;function aF(r){return r&&r.slice(0,Z1(r)+1).replace(oF,"")}var K1=aF;function lF(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var Qt=lF;var J1=0/0,cF=/^[-+]0x[0-9a-f]+$/i,uF=/^0b[01]+$/i,hF=/^0o[0-7]+$/i,fF=parseInt;function dF(r){if(typeof r=="number")return r;if(To(r))return J1;if(Qt(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Qt(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=K1(r);var t=uF.test(r);return t||hF.test(r)?fF(r.slice(2),t?2:8):cF.test(r)?J1:+r}var d0=dF;function pF(r){return r}var Ep=pF;var mF="[object AsyncFunction]",gF="[object Function]",vF="[object GeneratorFunction]",yF="[object Proxy]";function xF(r){if(!Qt(r))return!1;var e=Wn(r);return e==gF||e==vF||e==mF||e==yF}var uc=xF;var bF=rr["__core-js_shared__"],Cp=bF;var $1=function(){var r=/[^.]+$/.exec(Cp&&Cp.keys&&Cp.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function SF(r){return!!$1&&$1 in r}var eA=SF;var wF=Function.prototype,AF=wF.toString;function TF(r){if(r!=null){try{return AF.call(r)}catch{}try{return r+""}catch{}}return""}var Hs=TF;var _F=/[\\^$.*+?()[\]{}|]/g,MF=/^\[object .+?Constructor\]$/,EF=Function.prototype,CF=Object.prototype,PF=EF.toString,DF=CF.hasOwnProperty,IF=RegExp("^"+PF.call(DF).replace(_F,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function LF(r){if(!Qt(r)||eA(r))return!1;var e=uc(r)?IF:MF;return e.test(Hs(r))}var tA=LF;function OF(r,e){return r?.[e]}var rA=OF;function RF(r,e){var t=rA(r,e);return tA(t)?t:void 0}var _n=RF;var BF=_n(rr,"WeakMap"),Pp=BF;var nA=Object.create,NF=function(){function r(){}return function(e){if(!Qt(e))return{};if(nA)return nA(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),iA=NF;function FF(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var sA=FF;function kF(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var Dp=kF;var UF=800,GF=16,zF=Date.now;function VF(r){var e=0,t=0;return function(){var n=zF(),i=GF-(n-t);if(t=n,i>0){if(++e>=UF)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var oA=VF;function HF(r){return function(){return r}}var aA=HF;var WF=function(){try{var r=_n(Object,"defineProperty");return r({},"",{}),r}catch{}}(),hc=WF;var jF=hc?function(r,e){return hc(r,"toString",{configurable:!0,enumerable:!1,value:aA(e),writable:!0})}:Ep,lA=jF;var qF=oA(lA),Ip=qF;function XF(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var cA=XF;var YF=9007199254740991,QF=/^(?:0|[1-9]\d*)$/;function ZF(r,e){var t=typeof r;return e=e??YF,!!e&&(t=="number"||t!="symbol"&&QF.test(r))&&r>-1&&r%1==0&&r<e}var _o=ZF;function KF(r,e,t){e=="__proto__"&&hc?hc(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var fc=KF;function JF(r,e){return r===e||r!==r&&e!==e}var Mo=JF;var $F=Object.prototype,ek=$F.hasOwnProperty;function tk(r,e,t){var n=r[e];(!(ek.call(r,e)&&Mo(n,t))||t===void 0&&!(e in r))&&fc(r,e,t)}var dc=tk;function rk(r,e,t,n){var i=!t;t||(t={});for(var s=-1,o=e.length;++s<o;){var a=e[s],l=n?n(t[a],r[a],a,t,r):void 0;l===void 0&&(l=r[a]),i?fc(t,a,l):dc(t,a,l)}return t}var si=rk;var uA=Math.max;function nk(r,e,t){return e=uA(e===void 0?r.length-1:e,0),function(){for(var n=arguments,i=-1,s=uA(n.length-e,0),o=Array(s);++i<s;)o[i]=n[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=n[i];return a[e]=t(o),sA(r,this,a)}}var Lp=nk;function ik(r,e){return Ip(Lp(r,e,Ep),r+"")}var hA=ik;var sk=9007199254740991;function ok(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=sk}var pc=ok;function ak(r){return r!=null&&pc(r.length)&&!uc(r)}var Eo=ak;function lk(r,e,t){if(!Qt(t))return!1;var n=typeof e;return(n=="number"?Eo(t)&&_o(e,t.length):n=="string"&&e in t)?Mo(t[e],r):!1}var fA=lk;function ck(r){return hA(function(e,t){var n=-1,i=t.length,s=i>1?t[i-1]:void 0,o=i>2?t[2]:void 0;for(s=r.length>3&&typeof s=="function"?(i--,s):void 0,o&&fA(t[0],t[1],o)&&(s=i<3?void 0:s,i=1),e=Object(e);++n<i;){var a=t[n];a&&r(e,a,n,s)}return e})}var dA=ck;var uk=Object.prototype;function hk(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||uk;return r===t}var mc=hk;function fk(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var pA=fk;var dk="[object Arguments]";function pk(r){return nn(r)&&Wn(r)==dk}var p0=pk;var mA=Object.prototype,mk=mA.hasOwnProperty,gk=mA.propertyIsEnumerable,vk=p0(function(){return arguments}())?p0:function(r){return nn(r)&&mk.call(r,"callee")&&!gk.call(r,"callee")},Ws=vk;function yk(){return!1}var gA=yk;var xA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,vA=xA&&typeof module=="object"&&module&&!module.nodeType&&module,xk=vA&&vA.exports===xA,yA=xk?rr.Buffer:void 0,bk=yA?yA.isBuffer:void 0,Sk=bk||gA,gc=Sk;var wk="[object Arguments]",Ak="[object Array]",Tk="[object Boolean]",_k="[object Date]",Mk="[object Error]",Ek="[object Function]",Ck="[object Map]",Pk="[object Number]",Dk="[object Object]",Ik="[object RegExp]",Lk="[object Set]",Ok="[object String]",Rk="[object WeakMap]",Bk="[object ArrayBuffer]",Nk="[object DataView]",Fk="[object Float32Array]",kk="[object Float64Array]",Uk="[object Int8Array]",Gk="[object Int16Array]",zk="[object Int32Array]",Vk="[object Uint8Array]",Hk="[object Uint8ClampedArray]",Wk="[object Uint16Array]",jk="[object Uint32Array]",Xt={};Xt[Fk]=Xt[kk]=Xt[Uk]=Xt[Gk]=Xt[zk]=Xt[Vk]=Xt[Hk]=Xt[Wk]=Xt[jk]=!0;Xt[wk]=Xt[Ak]=Xt[Bk]=Xt[Tk]=Xt[Nk]=Xt[_k]=Xt[Mk]=Xt[Ek]=Xt[Ck]=Xt[Pk]=Xt[Dk]=Xt[Ik]=Xt[Lk]=Xt[Ok]=Xt[Rk]=!1;function qk(r){return nn(r)&&pc(r.length)&&!!Xt[Wn(r)]}var bA=qk;function Xk(r){return function(e){return r(e)}}var vc=Xk;var SA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oh=SA&&typeof module=="object"&&module&&!module.nodeType&&module,Yk=Oh&&Oh.exports===SA,m0=Yk&&_p.process,Qk=function(){try{var r=Oh&&Oh.require&&Oh.require("util").types;return r||m0&&m0.binding&&m0.binding("util")}catch{}}(),js=Qk;var wA=js&&js.isTypedArray,Zk=wA?vc(wA):bA,Op=Zk;var Kk=Object.prototype,Jk=Kk.hasOwnProperty;function $k(r,e){var t=Mr(r),n=!t&&Ws(r),i=!t&&!n&&gc(r),s=!t&&!n&&!i&&Op(r),o=t||n||i||s,a=o?pA(r.length,String):[],l=a.length;for(var u in r)(e||Jk.call(r,u))&&!(o&&(u=="length"||i&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||_o(u,l)))&&a.push(u);return a}var Rp=$k;function eU(r,e){return function(t){return r(e(t))}}var Bp=eU;var tU=Bp(Object.keys,Object),AA=tU;var rU=Object.prototype,nU=rU.hasOwnProperty;function iU(r){if(!mc(r))return AA(r);var e=[];for(var t in Object(r))nU.call(r,t)&&t!="constructor"&&e.push(t);return e}var TA=iU;function sU(r){return Eo(r)?Rp(r):TA(r)}var yc=sU;function oU(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var _A=oU;var aU=Object.prototype,lU=aU.hasOwnProperty;function cU(r){if(!Qt(r))return _A(r);var e=mc(r),t=[];for(var n in r)n=="constructor"&&(e||!lU.call(r,n))||t.push(n);return t}var MA=cU;function uU(r){return Eo(r)?Rp(r,!0):MA(r)}var $i=uU;var hU=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,fU=/^\w*$/;function dU(r,e){if(Mr(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||To(r)?!0:fU.test(r)||!hU.test(r)||e!=null&&r in Object(e)}var EA=dU;var pU=_n(Object,"create"),qs=pU;function mU(){this.__data__=qs?qs(null):{},this.size=0}var CA=mU;function gU(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var PA=gU;var vU="__lodash_hash_undefined__",yU=Object.prototype,xU=yU.hasOwnProperty;function bU(r){var e=this.__data__;if(qs){var t=e[r];return t===vU?void 0:t}return xU.call(e,r)?e[r]:void 0}var DA=bU;var SU=Object.prototype,wU=SU.hasOwnProperty;function AU(r){var e=this.__data__;return qs?e[r]!==void 0:wU.call(e,r)}var IA=AU;var TU="__lodash_hash_undefined__";function _U(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=qs&&e===void 0?TU:e,this}var LA=_U;function xc(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}xc.prototype.clear=CA;xc.prototype.delete=PA;xc.prototype.get=DA;xc.prototype.has=IA;xc.prototype.set=LA;var g0=xc;function MU(){this.__data__=[],this.size=0}var OA=MU;function EU(r,e){for(var t=r.length;t--;)if(Mo(r[t][0],e))return t;return-1}var Co=EU;var CU=Array.prototype,PU=CU.splice;function DU(r){var e=this.__data__,t=Co(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():PU.call(e,t,1),--this.size,!0}var RA=DU;function IU(r){var e=this.__data__,t=Co(e,r);return t<0?void 0:e[t][1]}var BA=IU;function LU(r){return Co(this.__data__,r)>-1}var NA=LU;function OU(r,e){var t=this.__data__,n=Co(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var FA=OU;function bc(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}bc.prototype.clear=OA;bc.prototype.delete=RA;bc.prototype.get=BA;bc.prototype.has=NA;bc.prototype.set=FA;var Po=bc;var RU=_n(rr,"Map"),Do=RU;function BU(){this.size=0,this.__data__={hash:new g0,map:new(Do||Po),string:new g0}}var kA=BU;function NU(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var UA=NU;function FU(r,e){var t=r.__data__;return UA(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Io=FU;function kU(r){var e=Io(this,r).delete(r);return this.size-=e?1:0,e}var GA=kU;function UU(r){return Io(this,r).get(r)}var zA=UU;function GU(r){return Io(this,r).has(r)}var VA=GU;function zU(r,e){var t=Io(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var HA=zU;function Sc(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Sc.prototype.clear=kA;Sc.prototype.delete=GA;Sc.prototype.get=zA;Sc.prototype.has=VA;Sc.prototype.set=HA;var Rh=Sc;var VU="Expected a function";function v0(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(VU);var t=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=t.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return t.cache=s.set(i,o)||s,o};return t.cache=new(v0.Cache||Rh),t}v0.Cache=Rh;var WA=v0;var HU=500;function WU(r){var e=WA(r,function(n){return t.size===HU&&t.clear(),n}),t=e.cache;return e}var jA=WU;var jU=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,qU=/\\(\\)?/g,XU=jA(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(jU,function(t,n,i,s){e.push(i?s.replace(qU,"$1"):n||t)}),e}),qA=XU;function YU(r){return r==null?"":Q1(r)}var XA=YU;function QU(r,e){return Mr(r)?r:EA(r,e)?[r]:qA(XA(r))}var oi=QU;var ZU=1/0;function KU(r){if(typeof r=="string"||To(r))return r;var e=r+"";return e=="0"&&1/r==-ZU?"-0":e}var Lo=KU;function JU(r,e){e=oi(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[Lo(e[t++])];return t&&t==n?r:void 0}var Np=JU;function $U(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var wc=$U;var YA=xn?xn.isConcatSpreadable:void 0;function eG(r){return Mr(r)||Ws(r)||!!(YA&&r&&r[YA])}var QA=eG;function ZA(r,e,t,n,i){var s=-1,o=r.length;for(t||(t=QA),i||(i=[]);++s<o;){var a=r[s];e>0&&t(a)?e>1?ZA(a,e-1,t,n,i):wc(i,a):n||(i[i.length]=a)}return i}var KA=ZA;function tG(r){var e=r==null?0:r.length;return e?KA(r,1):[]}var JA=tG;function rG(r){return Ip(Lp(r,void 0,JA),r+"")}var Fp=rG;var nG=Bp(Object.getPrototypeOf,Object),Ac=nG;var iG="[object Object]",sG=Function.prototype,oG=Object.prototype,$A=sG.toString,aG=oG.hasOwnProperty,lG=$A.call(Object);function cG(r){if(!nn(r)||Wn(r)!=iG)return!1;var e=Ac(r);if(e===null)return!0;var t=aG.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&$A.call(t)==lG}var kp=cG;function uG(r,e,t){var n=-1,i=r.length;e<0&&(e=-e>i?0:i+e),t=t>i?i:t,t<0&&(t+=i),i=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(i);++n<i;)s[n]=r[n+e];return s}var eT=uG;function hG(){this.__data__=new Po,this.size=0}var tT=hG;function fG(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var rT=fG;function dG(r){return this.__data__.get(r)}var nT=dG;function pG(r){return this.__data__.has(r)}var iT=pG;var mG=200;function gG(r,e){var t=this.__data__;if(t instanceof Po){var n=t.__data__;if(!Do||n.length<mG-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new Rh(n)}return t.set(r,e),this.size=t.size,this}var sT=gG;function Tc(r){var e=this.__data__=new Po(r);this.size=e.size}Tc.prototype.clear=tT;Tc.prototype.delete=rT;Tc.prototype.get=nT;Tc.prototype.has=iT;Tc.prototype.set=sT;var Up=Tc;function vG(r,e){return r&&si(e,yc(e),r)}var oT=vG;function yG(r,e){return r&&si(e,$i(e),r)}var aT=yG;var hT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,lT=hT&&typeof module=="object"&&module&&!module.nodeType&&module,xG=lT&&lT.exports===hT,cT=xG?rr.Buffer:void 0,uT=cT?cT.allocUnsafe:void 0;function bG(r,e){if(e)return r.slice();var t=r.length,n=uT?uT(t):new r.constructor(t);return r.copy(n),n}var Gp=bG;function SG(r,e){for(var t=-1,n=r==null?0:r.length,i=0,s=[];++t<n;){var o=r[t];e(o,t,r)&&(s[i++]=o)}return s}var fT=SG;function wG(){return[]}var zp=wG;var AG=Object.prototype,TG=AG.propertyIsEnumerable,dT=Object.getOwnPropertySymbols,_G=dT?function(r){return r==null?[]:(r=Object(r),fT(dT(r),function(e){return TG.call(r,e)}))}:zp,_c=_G;function MG(r,e){return si(r,_c(r),e)}var pT=MG;var EG=Object.getOwnPropertySymbols,CG=EG?function(r){for(var e=[];r;)wc(e,_c(r)),r=Ac(r);return e}:zp,Vp=CG;function PG(r,e){return si(r,Vp(r),e)}var mT=PG;function DG(r,e,t){var n=e(r);return Mr(r)?n:wc(n,t(r))}var Hp=DG;function IG(r){return Hp(r,yc,_c)}var gT=IG;function LG(r){return Hp(r,$i,Vp)}var Wp=LG;var OG=_n(rr,"DataView"),jp=OG;var RG=_n(rr,"Promise"),qp=RG;var BG=_n(rr,"Set"),Xp=BG;var vT="[object Map]",NG="[object Object]",yT="[object Promise]",xT="[object Set]",bT="[object WeakMap]",ST="[object DataView]",FG=Hs(jp),kG=Hs(Do),UG=Hs(qp),GG=Hs(Xp),zG=Hs(Pp),Ra=Wn;(jp&&Ra(new jp(new ArrayBuffer(1)))!=ST||Do&&Ra(new Do)!=vT||qp&&Ra(qp.resolve())!=yT||Xp&&Ra(new Xp)!=xT||Pp&&Ra(new Pp)!=bT)&&(Ra=function(r){var e=Wn(r),t=e==NG?r.constructor:void 0,n=t?Hs(t):"";if(n)switch(n){case FG:return ST;case kG:return vT;case UG:return yT;case GG:return xT;case zG:return bT}return e});var Mc=Ra;var VG=Object.prototype,HG=VG.hasOwnProperty;function WG(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&HG.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var wT=WG;var jG=rr.Uint8Array,y0=jG;function qG(r){var e=new r.constructor(r.byteLength);return new y0(e).set(new y0(r)),e}var Ec=qG;function XG(r,e){var t=e?Ec(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var AT=XG;var YG=/\w*$/;function QG(r){var e=new r.constructor(r.source,YG.exec(r));return e.lastIndex=r.lastIndex,e}var TT=QG;var _T=xn?xn.prototype:void 0,MT=_T?_T.valueOf:void 0;function ZG(r){return MT?Object(MT.call(r)):{}}var ET=ZG;function KG(r,e){var t=e?Ec(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var Yp=KG;var JG="[object Boolean]",$G="[object Date]",ez="[object Map]",tz="[object Number]",rz="[object RegExp]",nz="[object Set]",iz="[object String]",sz="[object Symbol]",oz="[object ArrayBuffer]",az="[object DataView]",lz="[object Float32Array]",cz="[object Float64Array]",uz="[object Int8Array]",hz="[object Int16Array]",fz="[object Int32Array]",dz="[object Uint8Array]",pz="[object Uint8ClampedArray]",mz="[object Uint16Array]",gz="[object Uint32Array]";function vz(r,e,t){var n=r.constructor;switch(e){case oz:return Ec(r);case JG:case $G:return new n(+r);case az:return AT(r,t);case lz:case cz:case uz:case hz:case fz:case dz:case pz:case mz:case gz:return Yp(r,t);case ez:return new n;case tz:case iz:return new n(r);case rz:return TT(r);case nz:return new n;case sz:return ET(r)}}var CT=vz;function yz(r){return typeof r.constructor=="function"&&!mc(r)?iA(Ac(r)):{}}var Qp=yz;var xz="[object Map]";function bz(r){return nn(r)&&Mc(r)==xz}var PT=bz;var DT=js&&js.isMap,Sz=DT?vc(DT):PT,IT=Sz;var wz="[object Set]";function Az(r){return nn(r)&&Mc(r)==wz}var LT=Az;var OT=js&&js.isSet,Tz=OT?vc(OT):LT,RT=Tz;var _z=1,Mz=2,Ez=4,BT="[object Arguments]",Cz="[object Array]",Pz="[object Boolean]",Dz="[object Date]",Iz="[object Error]",NT="[object Function]",Lz="[object GeneratorFunction]",Oz="[object Map]",Rz="[object Number]",FT="[object Object]",Bz="[object RegExp]",Nz="[object Set]",Fz="[object String]",kz="[object Symbol]",Uz="[object WeakMap]",Gz="[object ArrayBuffer]",zz="[object DataView]",Vz="[object Float32Array]",Hz="[object Float64Array]",Wz="[object Int8Array]",jz="[object Int16Array]",qz="[object Int32Array]",Xz="[object Uint8Array]",Yz="[object Uint8ClampedArray]",Qz="[object Uint16Array]",Zz="[object Uint32Array]",Wt={};Wt[BT]=Wt[Cz]=Wt[Gz]=Wt[zz]=Wt[Pz]=Wt[Dz]=Wt[Vz]=Wt[Hz]=Wt[Wz]=Wt[jz]=Wt[qz]=Wt[Oz]=Wt[Rz]=Wt[FT]=Wt[Bz]=Wt[Nz]=Wt[Fz]=Wt[kz]=Wt[Xz]=Wt[Yz]=Wt[Qz]=Wt[Zz]=!0;Wt[Iz]=Wt[NT]=Wt[Uz]=!1;function Zp(r,e,t,n,i,s){var o,a=e&_z,l=e&Mz,u=e&Ez;if(t&&(o=i?t(r,n,i,s):t(r)),o!==void 0)return o;if(!Qt(r))return r;var c=Mr(r);if(c){if(o=wT(r),!a)return Dp(r,o)}else{var h=Mc(r),f=h==NT||h==Lz;if(gc(r))return Gp(r,a);if(h==FT||h==BT||f&&!i){if(o=l||f?{}:Qp(r),!a)return l?mT(r,aT(o,r)):pT(r,oT(o,r))}else{if(!Wt[h])return i?r:{};o=CT(r,h,a)}}s||(s=new Up);var d=s.get(r);if(d)return d;s.set(r,o),RT(r)?r.forEach(function(g){o.add(Zp(g,e,t,g,r,s))}):IT(r)&&r.forEach(function(g,v){o.set(v,Zp(g,e,t,v,r,s))});var m=u?l?Wp:gT:l?$i:yc,p=c?void 0:m(r);return cA(p||r,function(g,v){p&&(v=g,g=r[v]),dc(o,v,Zp(g,e,t,v,r,s))}),o}var Kp=Zp;var Kz=1,Jz=4;function $z(r){return Kp(r,Kz|Jz)}var Bh=$z;function e4(r,e){return r!=null&&e in Object(r)}var kT=e4;function t4(r,e,t){e=oi(e,r);for(var n=-1,i=e.length,s=!1;++n<i;){var o=Lo(e[n]);if(!(s=r!=null&&t(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&pc(i)&&_o(o,i)&&(Mr(r)||Ws(r)))}var UT=t4;function r4(r,e){return r!=null&&UT(r,e,kT)}var GT=r4;function n4(r){return function(e,t,n){for(var i=-1,s=Object(e),o=n(e),a=o.length;a--;){var l=o[r?a:++i];if(t(s[l],l,s)===!1)break}return e}}var zT=n4;var i4=zT(),VT=i4;var s4=function(){return rr.Date.now()},Jp=s4;var o4="Expected a function",a4=Math.max,l4=Math.min;function c4(r,e,t){var n,i,s,o,a,l,u=0,c=!1,h=!1,f=!0;if(typeof r!="function")throw new TypeError(o4);e=d0(e)||0,Qt(t)&&(c=!!t.leading,h="maxWait"in t,s=h?a4(d0(t.maxWait)||0,e):s,f="trailing"in t?!!t.trailing:f);function d(A){var _=n,x=i;return n=i=void 0,u=A,o=r.apply(x,_),o}function m(A){return u=A,a=setTimeout(v,e),c?d(A):o}function p(A){var _=A-l,x=A-u,M=e-_;return h?l4(M,s-x):M}function g(A){var _=A-l,x=A-u;return l===void 0||_>=e||_<0||h&&x>=s}function v(){var A=Jp();if(g(A))return y(A);a=setTimeout(v,p(A))}function y(A){return a=void 0,f&&n?d(A):(n=i=void 0,o)}function b(){a!==void 0&&clearTimeout(a),u=0,n=l=i=a=void 0}function S(){return a===void 0?o:y(Jp())}function w(){var A=Jp(),_=g(A);if(n=arguments,i=this,l=A,_){if(a===void 0)return m(l);if(h)return clearTimeout(a),a=setTimeout(v,e),d(l)}return a===void 0&&(a=setTimeout(v,e)),o}return w.cancel=b,w.flush=S,w}var Nh=c4;function u4(r,e,t){(t!==void 0&&!Mo(r[e],t)||t===void 0&&!(e in r))&&fc(r,e,t)}var Fh=u4;function h4(r){return nn(r)&&Eo(r)}var HT=h4;function f4(r,e){if(!(e==="constructor"&&typeof r[e]=="function")&&e!="__proto__")return r[e]}var kh=f4;function d4(r){return si(r,$i(r))}var WT=d4;function p4(r,e,t,n,i,s,o){var a=kh(r,t),l=kh(e,t),u=o.get(l);if(u){Fh(r,t,u);return}var c=s?s(a,l,t+"",r,e,o):void 0,h=c===void 0;if(h){var f=Mr(l),d=!f&&gc(l),m=!f&&!d&&Op(l);c=l,f||d||m?Mr(a)?c=a:HT(a)?c=Dp(a):d?(h=!1,c=Gp(l,!0)):m?(h=!1,c=Yp(l,!0)):c=[]:kp(l)||Ws(l)?(c=a,Ws(a)?c=WT(a):(!Qt(a)||uc(a))&&(c=Qp(l))):h=!1}h&&(o.set(l,c),i(c,l,n,s,o),o.delete(l)),Fh(r,t,c)}var jT=p4;function qT(r,e,t,n,i){r!==e&&VT(e,function(s,o){if(i||(i=new Up),Qt(s))jT(r,e,o,t,qT,n,i);else{var a=n?n(kh(r,o),s,o+"",r,e,i):void 0;a===void 0&&(a=s),Fh(r,o,a)}},$i)}var XT=qT;function m4(r){var e=r==null?0:r.length;return e?r[e-1]:void 0}var YT=m4;function g4(r,e){return e.length<2?r:Np(r,eT(e,0,-1))}var QT=g4;var v4=dA(function(r,e,t){XT(r,e,t)}),Ba=v4;function y4(r,e){return e=oi(e,r),r=QT(r,e),r==null||delete r[Lo(YT(e))]}var ZT=y4;function x4(r){return kp(r)?void 0:r}var KT=x4;var b4=1,S4=2,w4=4,A4=Fp(function(r,e){var t={};if(r==null)return t;var n=!1;e=Mp(e,function(s){return s=oi(s,r),n||(n=s.length>1),s}),si(r,Wp(r),t),n&&(t=Kp(t,b4|S4|w4,KT));for(var i=e.length;i--;)ZT(t,e[i]);return t}),Cc=A4;function T4(r,e,t,n){if(!Qt(r))return r;e=oi(e,r);for(var i=-1,s=e.length,o=s-1,a=r;a!=null&&++i<s;){var l=Lo(e[i]),u=t;if(l==="__proto__"||l==="constructor"||l==="prototype")return r;if(i!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Qt(c)?c:_o(e[i+1])?[]:{})}dc(a,l,u),a=a[l]}return r}var JT=T4;function _4(r,e,t){for(var n=-1,i=e.length,s={};++n<i;){var o=e[n],a=Np(r,o);t(a,o)&&JT(s,oi(o,r),a)}return s}var $T=_4;function M4(r,e){return $T(r,e,function(t,n){return GT(r,n)})}var e_=M4;var E4=Fp(function(r,e){return r==null?{}:e_(r,e)}),Pc=E4;var r_,n_=new Promise(r=>{r_=r}),t_=!1;async function i_(){if(t_)return;let r=await import("./physics.js");await r.init(),r_(r),t_=!0}var nr=class{modifyById(e,t){let n=this;if(n[e]===void 0)throw new Error("not expected");{let s={...n,[e]:t};return Object.setPrototypeOf(s,nr.prototype),s}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let n=t[e.id],i;n===void 0?i={type:2,id:e.id}:i={type:1,id:e.id,data:n};let{id:s,data:o}=e,a={...t,[s]:o};return Object.setPrototypeOf(a,nr.prototype),{data:a,actual:e,reverse:i}}else if(e.type===2){let{id:n}=e,i=t[n];if(i===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,nr.prototype),delete s[n],{data:s,actual:e,reverse:{type:1,id:n,data:i}}}}throw new Error("illegal arg")}};function Uh(r){if(r.deepFreeze!==void 0){r.deepFreeze(r);return}let e=Object.getOwnPropertyNames(r);for(let t of e){let n=r[t];n&&typeof n=="object"&&Uh(n)}return Object.freeze(r)}function s_(r,e){let t=0;for(;t<r.length&&t<e.length;){if(r[t]<e[t])return-1;if(r[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==r.length?1:0}var $p=class extends Error{};function es(r,e,t){if(r===void 0?e===void 0?(r=0,e=10):r=e-10:e===void 0&&(e=r+10),r>e){let s=r;r=e,e=s}let n=[],i=1/(t+1);for(let s=0;s<t;s++){let o=r+(e-r)*(s+.75+Math.random()*.5)*i;n.push(o)}return n}function Na(r){return r instanceof Uint8Array||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof Float64Array}function o_(){return typeof process<"u"}function a_(r,e){for(let t of r)e(t.id,t.data),a_(t.children,e)}function l_(r,e){e(r.id,r.data);for(let t of r.children)l_(t,e)}var Xr=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Xr.prototype)}deepFreeze(){let t=0;for(;t<this.length;)Uh(this[t]),t++}fillCaches0(t,n){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,n);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}isDescendantOf(t,n){for(;t;){let i=this.parent(t);if(i===n)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}get(t){return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,n){if(t===null)this.traverse(n);else{let i=this.get(t);i&&l_(i,n)}}traverse(t){a_(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this.parent(t),o=this.childrenArray(s),a=o.findIndex(c=>c.id===t);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(t,n){let i=t,s=n;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,Xr.prototype);let o=s;return o.fillCaches(),o}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}}checkDuplicatedIdRec({id:t,children:n}){if(this.get(t)!==void 0)return!0;for(let i of n)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:n,fi:i,id:s,data:o,children:a}=t;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(t))return null;{let l=n,u=this.childrenArray(l),c={fi:i,id:s,data:o,children:a};return u=[...u,c],u.sort((f,d)=>f.fi-d.fi),t.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:t,reverse:{type:8,id:s}}}}deleteOp(t){let{id:n}=t;if(this.get(n)===null)return null;{let i=this.parent(n);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(u=>u.id===n);t.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:t,reverse:{type:7,...a,parent:i}}}}moveOp(t){let{parent:n,fi:i,id:s}=t;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let d=n;for(;d!==null;){if(d===void 0)throw new Error;if(d===s)throw new $p("cyclic tree");d=this.parent(d)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(d=>d.id===s);l=[...l];let c=l.splice(u,1)[0],h=this.modifyArrayBy(o,l);o=n,l=h.childrenArray(o);let f=c.fi;return c={...c,fi:i},l=[...l,c],l.sort((d,m)=>d.fi-m.fi),t.localIndex=l.indexOf(c),h=h.modifyArrayBy(o,l),{data:h,actual:t,reverse:{type:9,parent:a,fi:f,id:s}}}previous(t,n){if(n===null){let s=this.childrenArray(t);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(t)){if(s.id===n)return i;i=s.id}return null}traverseSortNext(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)+1;if(s<i.length)return i[s].id;if(n)return this.traverseSortNext(n)}}sortNext(t){let n=this.childrenArray(t);return n.length>0?n[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let n=this.childrenArray(t);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):t}sortPrevious(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)-1;return s>=0?this.traverseSortPrevious(i[s].id):n}}getAllSorted(t){let n=[];for(let i of t){let s=this.getWithSortKey(i.id);s!==void 0&&n.push({...i,...s})}n.sort((i,s)=>s_(i.sortKey,s.sortKey));for(let i of n)delete i.sortKey;return n}getWithSortKey(t){var n=t;let i=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)i.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:i}}}insertBeforeHelper(t,n,i){return this.insertAfterHelper(t,this.previous(t,n),i)}insertAfterHelper(t,n,i){let s=this.childrenArray(t);if(n===null){if(s.length===0)return es(0,i,i);{let o=s[0].fi;return es(o-i,o,i)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==t)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return es(l,l+i,i)}else return es(o.fi,a.fi,i)}}};var em;(e=>{function r(t,n){if(Array.isArray(t)){let i=n.props,s={},o=[...t],a=!1;if(i)for(let l of Object.keys(i)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=i[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let i=n.props,s={},o={...t},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let u=i[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}e.runOp=r})(em||(em={}));var ct=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,ct.prototype)}deepFreeze(){let t=0;for(;t<this.length;)Uh(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===t);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(t){Object.setPrototypeOf(t,ct.prototype);let n=t;return o_()||n.fillCaches(),n}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}}addOp(t){let{fi:n,id:i,data:s}=t,o=this,a={fi:n,id:i,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),t.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:n}=t,i=this,s=i.findIndex(l=>l.id===n);if(s===-1)return null;t.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...o}}}moveOp(t){let{fi:n,id:i}=t,s=this;s=[...s];let o=s.findIndex(c=>c.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,h)=>c.fi-h.fi),t.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:t,reverse:{type:6,fi:a,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let i of this){if(i.id===t)return n;n=i.id}return null}insertBeforeHelper(t,n){return this.insertAfterHelper(this.previous(t),n)}insertAfterHelper(t,n){let i=this;if(t===null){if(i.length===0)return es(0,n,n);{let s=i[0].fi;return es(s-n,s,n)}}else{let s=this.get(t);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return es(a,a+n,n)}else return es(s.fi,o.fi,n)}}};var Xs=class{unusedFun(e){}runOp(e){let t=[],n=this,i=0,s={};for(;i<e.path.length;)t.push(n),n=n===void 0?void 0:n[e.path[i]],i+=1;n={...n};for(let[l,u]of Object.entries(e.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;i>0;)Object.keys(n).length===0?(n={...t[i-1]},delete n[e.path[i-1]]):n={...t[i-1],[e.path[i-1]]:n},i-=1;let o=Object.setPrototypeOf(n,Xs.prototype),a={...e,props:s};return{data:o,actual:e,reverse:a}}},c_;(t=>{function r(n,i){return Gh(n,i)??n}t.apply=r;function e(n,i){if(i.type===0){let s=Fa.zoom(n,i.path);if(s===void 0)return i;if(typeof s=="string"||typeof s=="number"||Na(s))return;if(s&&typeof s=="object"){let o={...i.props};for(let a of Object.keys(s))delete o[a];return{...i,props:o}}else return}else if(i.type===1||i.type===4||i.type===7){let s=Fa.zoom(n,[...i.path,i.id]);if(s===void 0)return i;if(typeof s=="string"||typeof s=="number"||Na(s))return;if(s&&typeof s=="object"){let o={...i.data,...s};return{...i,data:o}}else return}else return i}t.filterOp=e})(c_||(c_={}));function u_(r,e){if(e===void 0)return;let t=!1,n=r.map(i=>{let s=i.id,o=Gh(i.data,e[s]);t=t||o!==void 0,o===void 0&&(o=i.data);let a=u_(i.children,e);return a!==void 0?t=!0:a=i.children,{...i,id:s,data:o,children:a}});if(t)return n}function C4(r,e){if(e===void 0)return;let t=!1,n=r.map(i=>{let s=i.id,o=Gh(i.data,e[s]);return t=t||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(t)return Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}function Gh(r,e){if(e!==void 0)if(r instanceof Xr){let t=u_(r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}else{if(r instanceof ct)return C4(r,e);if(Array.isArray(r)){let t=!1,n=r.map((i,s)=>{let o=Gh(i,e[s]);return t=t||o!==void 0,o===void 0&&(o=i),o});return t?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else if(r&&typeof r=="object"){let t={},n=!1;for(let[i,s]of Object.entries(r)){let o=Gh(s,e[i]);n=n||o!==void 0,o===void 0&&(o=s),t[i]=o}return n?(Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t):void 0}else return e??r}}var h_=Symbol(),zh=Symbol(),ka=class{reportOp(e,t,n=[]){let i=this;if(t===null)return;i._current=t.data;let s=n;for(;!(i instanceof tm);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let n=t[zh];n&&n(),delete this._children[e]}}}},b0=class extends ka{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,em.runOp(this._current,e),e.path)}},S0=class extends ka{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,nr.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},f_={get(r,e){if(e===zh)return()=>{r._parent=null};if(e===h_)return r._current;let{_current:t,_children:n}=r;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t[e],o=rm(r,e,s);return o!==s?(n===void 0&&(n={},r._children=n),n[e]=o,o):s},has(r,e){return e in r._current},ownKeys(r){return Reflect.ownKeys(r._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(r){return Object.getPrototypeOf(r._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(r,e){let t=r._current,n=Reflect.getOwnPropertyDescriptor(t,e);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:t[e]}}},P4={...f_,set(r,e,t){let n={type:0,props:{[e]:Mn(t)??t}};return r.deleteChildren(e),r.runOp(n),!0},deleteProperty(r,e){let t={type:0,props:{[e]:void 0}};return r.deleteChildren(e),r.runOp(t),!0}},D4={...f_,set(r,e,t){return t===void 0?this.deleteProperty(r,e):(r.deleteChildren(e),r.runOp({type:1,id:e,data:t})),!0},deleteProperty(r,e){return r.runOp({type:2,id:e}),!0}},Dc=class extends ka{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[zh]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,n)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=rm(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}add(e,t,n,i,s){this.runOp({type:7,parent:e,fi:t,id:n,data:i,children:s})}move(e,t,n){this.runOp({type:9,parent:e,fi:t,id:n})}insertAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}insertBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}moveAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}moveBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},w0=class extends ka{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n,this[zh]=()=>{this._parent=null}}feedOp(e){let{path:t,...n}=e;this.reportOp(n,this._current.runOp(e),t)}},Ic=class extends ka{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[zh]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let n=0;n<t;n++){let i=this._current[n].id,s=this._current[n].fi;e(this.data(this._current[n].id),i,s)}}find(e){let t=this.length;for(let n=0;n<t;n++){let i=this._current[n].id;if(e(this.data(i),i))return this.get(i)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=rm(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,n){this.runOp({type:4,fi:e,id:t,data:n})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}insertBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}moveAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}moveBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function x0(r,e,t){if(r.length>0){let n=r[r.length-1];if(n.type===0&&e.type===0&&Fa.equal(n.path,t)){Object.assign(n.props,e.props);return}}r.push({...e,path:t})}var tm=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,n,i){x0(this.ts,t,e),x0(this.actual,n,e),x0(this.reverse,i,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function rm(r,e,t){return t instanceof Xr?new Dc(r,e,t):t instanceof ct?new Ic(r,e,t):t instanceof Xs?new w0(r,e,t):t instanceof nr?new Proxy(new S0(r,e,t),D4):t!==null&&typeof t=="object"?Na(t)?t:new Proxy(new b0(r,e,t),P4):t}function A0(r){let e=new tm(r);return[rm(e,"",r),e]}function T0(r,e){let[t,n]=A0(r);return e(t),n.result()}function Mn(r){return r instanceof Dc||r instanceof Ic?r._current:r!==null&&typeof r=="object"?r[h_]:r}var Fa;(i=>{function r(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=r;function e(s,o,a){let l=n(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}i.removeOverridden=e;function t(s,o){if((s instanceof Xr||s instanceof Dc)&&typeof o=="string")return s.data(o);if((s instanceof ct||s instanceof Ic)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object")return s[o]}i.zoomOnce=t;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=t(s,o[a]),a+=1;return s}i.zoom=n})(Fa||(Fa={}));var nm=class{},Vh=class extends nm{constructor(t){super();this.id=t}},Hh=class extends nm{constructor(t){super();this.data=t}};var M0;try{M0=new TextDecoder}catch{}var Oe,Ro,Z=0;var b_=[],E0=b_,C0=0,En={},Mt,Oo,ai=0,ts=0,jn,Ys,bn=[],Ot,d_={useRecords:!1,mapsAsObjects:!0},Wh=class{},D0=new Wh;D0.name="MessagePack 0xC1";var Lc=!1,rs=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Oe)return __(()=>(sm(),this?this.unpack(e,t):rs.prototype.unpack.call(d_,e,t)));Ro=t>-1?t:e.length,Z=0,C0=0,ts=0,Oo=null,E0=b_,jn=null,Oe=e;try{Ot=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw Oe=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof rs){if(En=this,this.structures)return Mt=this.structures,im();(!Mt||Mt.length>0)&&(Mt=[])}else En=d_,(!Mt||Mt.length>0)&&(Mt=[]);return im()}unpackMultiple(e,t){let n,i=0;try{Lc=!0;let s=e.length,o=this?this.unpack(e,s):lm.unpack(e,s);if(t){for(t(o);Z<s;)if(i=Z,t(im())===!1)return}else{for(n=[o];Z<s;)i=Z,n.push(im());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{Lc=!1,sm()}}_mergeStructures(e,t){e=e||[];for(let n=0,i=e.length;n<i;n++){let s=e[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let i=e[n],s=t[n];s&&(i&&((e.restoreStructures||(e.restoreStructures=[]))[n]=i),e[n]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function im(){try{if(!En.trusted&&!Lc){let e=Mt.sharedLength||0;e<Mt.length&&(Mt.length=e)}let r=ir();if(Z==Ro)Mt.restoreStructures&&p_(),Mt=null,Oe=null,Ys&&(Ys=null);else if(Z>Ro){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!Lc)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw Mt.restoreStructures&&p_(),sm(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function p_(){for(let r in Mt.restoreStructures)Mt[r]=Mt.restoreStructures[r];Mt.restoreStructures=null}function ir(){let r=Oe[Z++];if(r<160)if(r<128){if(r<64)return r;{let e=Mt[r&63]||En.getStructures&&S_()[r&63];return e?(e.read||(e.read=I0(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,En.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[A_()]=ir();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(ir(),ir());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=ir();return e}else if(r<192){let e=r-160;if(ts>=Z)return Oo.slice(Z-ai,(Z+=e)-ai);if(ts==0&&Ro<140){let t=e<16?L0(e):w_(e);if(t!=null)return t}return P0(e)}else{let e;switch(r){case 192:return null;case 193:return jn?(e=ir(),e>0?jn[1].slice(jn.position1,jn.position1+=e):jn[0].slice(jn.position0,jn.position0-=e)):D0;case 194:return!1;case 195:return!0;case 196:return _0(Oe[Z++]);case 197:return e=Ot.getUint16(Z),Z+=2,_0(e);case 198:return e=Ot.getUint32(Z),Z+=4,_0(e);case 199:return Ua(Oe[Z++]);case 200:return e=Ot.getUint16(Z),Z+=2,Ua(e);case 201:return e=Ot.getUint32(Z),Z+=4,Ua(e);case 202:if(e=Ot.getFloat32(Z),En.useFloat32>2){let t=am[(Oe[Z]&127)<<1|Oe[Z+1]>>7];return Z+=4,(t*e+(e>0?.5:-.5)>>0)/t}return Z+=4,e;case 203:return e=Ot.getFloat64(Z),Z+=8,e;case 204:return Oe[Z++];case 205:return e=Ot.getUint16(Z),Z+=2,e;case 206:return e=Ot.getUint32(Z),Z+=4,e;case 207:return En.int64AsNumber?(e=Ot.getUint32(Z)*4294967296,e+=Ot.getUint32(Z+4)):e=Ot.getBigUint64(Z),Z+=8,e;case 208:return Ot.getInt8(Z++);case 209:return e=Ot.getInt16(Z),Z+=2,e;case 210:return e=Ot.getInt32(Z),Z+=4,e;case 211:return En.int64AsNumber?(e=Ot.getInt32(Z)*4294967296,e+=Ot.getUint32(Z+4)):e=Ot.getBigInt64(Z),Z+=8,e;case 212:if(e=Oe[Z++],e==114)return x_(Oe[Z++]&63);{let t=bn[e];if(t)return t.read?(Z++,t.read(ir())):t.noBuffer?(Z++,t()):t(Oe.subarray(Z,++Z));throw new Error("Unknown extension "+e)}case 213:return e=Oe[Z],e==114?(Z++,x_(Oe[Z++]&63,Oe[Z++])):Ua(2);case 214:return Ua(4);case 215:return Ua(8);case 216:return Ua(16);case 217:return e=Oe[Z++],ts>=Z?Oo.slice(Z-ai,(Z+=e)-ai):L4(e);case 218:return e=Ot.getUint16(Z),Z+=2,ts>=Z?Oo.slice(Z-ai,(Z+=e)-ai):O4(e);case 219:return e=Ot.getUint32(Z),Z+=4,ts>=Z?Oo.slice(Z-ai,(Z+=e)-ai):R4(e);case 220:return e=Ot.getUint16(Z),Z+=2,g_(e);case 221:return e=Ot.getUint32(Z),Z+=4,g_(e);case 222:return e=Ot.getUint16(Z),Z+=2,v_(e);case 223:return e=Ot.getUint32(Z),Z+=4,v_(e);default:if(r>=224)return r-256;if(r===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+r)}}}var I4=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function I0(r,e){function t(){if(t.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>I4.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(ir);return r.highByte===0&&(r.read=m_(e,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=ir()}return n}return t.count=0,r.highByte===0?m_(e,t):t}var m_=(r,e)=>function(){let t=Oe[Z++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),i=Mt[n]||S_()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=I0(i,r)),i.read()};function S_(){let r=__(()=>(Oe=null,En.getStructures()));return Mt=En._mergeStructures(r,Mt)}var P0=om,L4=om,O4=om,R4=om;function om(r){let e;if(r<16&&(e=L0(r)))return e;if(r>64&&M0)return M0.decode(Oe.subarray(Z,Z+=r));let t=Z+r,n=[];for(e="";Z<t;){let i=Oe[Z++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=Oe[Z++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=Oe[Z++]&63,o=Oe[Z++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Oe[Z++]&63,o=Oe[Z++]&63,a=Oe[Z++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(i);n.length>=4096&&(e+=Gr.apply(String,n),n.length=0)}return n.length>0&&(e+=Gr.apply(String,n)),e}function g_(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=ir();return e}function v_(r){if(En.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[A_()]=ir();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(ir(),ir());return e}}var Gr=String.fromCharCode;function w_(r){let e=Z,t=new Array(r);for(let n=0;n<r;n++){let i=Oe[Z++];if((i&128)>0){Z=e;return}t[n]=i}return Gr.apply(String,t)}function L0(r){if(r<4)if(r<2){if(r===0)return"";{let e=Oe[Z++];if((e&128)>1){Z-=1;return}return Gr(e)}}else{let e=Oe[Z++],t=Oe[Z++];if((e&128)>0||(t&128)>0){Z-=2;return}if(r<3)return Gr(e,t);let n=Oe[Z++];if((n&128)>0){Z-=3;return}return Gr(e,t,n)}else{let e=Oe[Z++],t=Oe[Z++],n=Oe[Z++],i=Oe[Z++];if((e&128)>0||(t&128)>0||(n&128)>0||(i&128)>0){Z-=4;return}if(r<6){if(r===4)return Gr(e,t,n,i);{let s=Oe[Z++];if((s&128)>0){Z-=5;return}return Gr(e,t,n,i,s)}}else if(r<8){let s=Oe[Z++],o=Oe[Z++];if((s&128)>0||(o&128)>0){Z-=6;return}if(r<7)return Gr(e,t,n,i,s,o);let a=Oe[Z++];if((a&128)>0){Z-=7;return}return Gr(e,t,n,i,s,o,a)}else{let s=Oe[Z++],o=Oe[Z++],a=Oe[Z++],l=Oe[Z++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){Z-=8;return}if(r<10){if(r===8)return Gr(e,t,n,i,s,o,a,l);{let u=Oe[Z++];if((u&128)>0){Z-=9;return}return Gr(e,t,n,i,s,o,a,l,u)}}else if(r<12){let u=Oe[Z++],c=Oe[Z++];if((u&128)>0||(c&128)>0){Z-=10;return}if(r<11)return Gr(e,t,n,i,s,o,a,l,u,c);let h=Oe[Z++];if((h&128)>0){Z-=11;return}return Gr(e,t,n,i,s,o,a,l,u,c,h)}else{let u=Oe[Z++],c=Oe[Z++],h=Oe[Z++],f=Oe[Z++];if((u&128)>0||(c&128)>0||(h&128)>0||(f&128)>0){Z-=12;return}if(r<14){if(r===12)return Gr(e,t,n,i,s,o,a,l,u,c,h,f);{let d=Oe[Z++];if((d&128)>0){Z-=13;return}return Gr(e,t,n,i,s,o,a,l,u,c,h,f,d)}}else{let d=Oe[Z++],m=Oe[Z++];if((d&128)>0||(m&128)>0){Z-=14;return}if(r<15)return Gr(e,t,n,i,s,o,a,l,u,c,h,f,d,m);let p=Oe[Z++];if((p&128)>0){Z-=15;return}return Gr(e,t,n,i,s,o,a,l,u,c,h,f,d,m,p)}}}}}function _0(r){return En.copyBuffers?Uint8Array.prototype.slice.call(Oe,Z,Z+=r):Oe.subarray(Z,Z+=r)}function Ua(r){let e=Oe[Z++];if(bn[e])return bn[e](Oe.subarray(Z,Z+=r));throw new Error("Unknown extension type "+e)}var y_=new Array(4096);function A_(){let r=Oe[Z++];if(r>=160&&r<192){if(r=r-160,ts>=Z)return Oo.slice(Z-ai,(Z+=r)-ai);if(!(ts==0&&Ro<180))return P0(r)}else return Z--,ir();let e=(r<<5^(r>1?Ot.getUint16(Z):r>0?Oe[Z]:0))&4095,t=y_[e],n=Z,i=Z+r-3,s,o=0;if(t&&t.bytes==r){for(;n<i;){if(s=Ot.getUint32(n),s!=t[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=Oe[n++],s!=t[o++]){n=1879048192;break}if(n===i)return Z=n,t.string;i-=3,n=Z}for(t=[],y_[e]=t,t.bytes=r;n<i;)s=Ot.getUint32(n),t.push(s),n+=4;for(i+=3;n<i;)s=Oe[n++],t.push(s);let a=r<16?L0(r):w_(r);return a!=null?t.string=a:t.string=P0(r)}var x_=(r,e)=>{var t=ir();let n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let i=Mt[r];return i&&i.isShared&&((Mt.restoreStructures||(Mt.restoreStructures=[]))[r]=i),Mt[r]=t,t.read=I0(t,n),t.read()},T_=typeof self=="object"?self:global;bn[0]=()=>{};bn[0].noBuffer=!0;bn[101]=()=>{let r=ir();return(T_[r[0]]||Error)(r[1])};bn[105]=r=>{let e=Ot.getUint32(Z-4);Ys||(Ys=new Map);let t=Oe[Z],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let i={target:n};Ys.set(e,i);let s=ir();return i.used?Object.assign(n,s):(i.target=s,s)};bn[112]=r=>{let e=Ot.getUint32(Z-4),t=Ys.get(e);return t.used=!0,t.target};bn[115]=()=>new Set(ir());var O0=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");bn[116]=r=>{let e=r[0],t=O0[e];if(!t)throw new Error("Could not find typed array for code "+e);return new T_[t](Uint8Array.prototype.slice.call(r,1).buffer)};bn[120]=()=>{let r=ir();return new RegExp(r[0],r[1])};bn[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=Z;Z+=e-4,jn=[ir(),ir()],jn.position0=0,jn.position1=0;let n=Z;Z=t;try{return ir()}finally{Z=n}};bn[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function __(r){let e=Ro,t=Z,n=C0,i=ai,s=ts,o=Oo,a=E0,l=Ys,u=jn,c=new Uint8Array(Oe.slice(0,Ro)),h=Mt,f=Mt.slice(0,Mt.length),d=En,m=Lc,p=r();return Ro=e,Z=t,C0=n,ai=i,ts=s,Oo=o,E0=a,Ys=l,jn=u,Oe=c,Lc=m,Mt=h,Mt.splice(0,Mt.length,...f),En=d,Ot=new DataView(Oe.buffer,Oe.byteOffset,Oe.byteLength),p}function sm(){Oe=null,Ys=null,Mt=null}function M_(r){r.unpack?bn[r.type]=r.unpack:bn[r.type]=r}var am=new Array(147);for(let r=0;r<256;r++)am[r]=+("1e"+Math.floor(45.15-r*.30103));var lm=new rs({useRecords:!1}),B4=lm.unpack,N4=lm.unpackMultiple,F4=lm.unpack,cm={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},k4=new Float32Array(1),Vne=new Uint8Array(k4.buffer,0,4);var um;try{um=new TextEncoder}catch{}var hm,B0,fm=typeof Buffer<"u",R0=fm?Buffer.allocUnsafeSlow:Uint8Array,D_=fm?Buffer:Uint8Array,E_=fm?4294967296:2144337920,le,dr,ee=0,ns,is=null,U4=/[\u0080-\uFFFF]/,jh=Symbol("record-id"),Ga=class extends rs{constructor(e){super(e),this.offset=0;let t,n,i,s,o,a,l=0,u=D_.prototype.utf8Write?function(x,M,E){return le.utf8Write(x,M,E)}:um&&um.encodeInto?function(x,M){return um.encodeInto(x,le.subarray(M)).written}:!1,c=this;e||(e={});let h=e&&e.sequential,f=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=f?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=e.maxOwnStructures;m==null&&(m=f?32:64),h&&!e.saveStructures&&(this.structures=[]);let p=d>32||m+d>64,g=d+64,v=d+m+64;if(v>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],b=0,S=0;this.pack=this.encode=function(x,M){if(le||(le=new R0(8192),dr=new DataView(le.buffer,0,8192),ee=0),ns=le.length-10,ns-ee<2048?(le=new R0(le.length),dr=new DataView(le.buffer,0,le.length),ns=le.length-10,ee=0):ee=ee+7&2147483640,n=ee,a=c.structuredClone?new Map:null,c.bundleStrings?(is=["",""],le[ee++]=214,le[ee++]=98,is.position=ee-n,ee+=4):is=null,i=c.structures,i){i.uninitialized&&(i=c._mergeStructures(c.getStructures()));let E=i.sharedLength||0;if(E>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let C=0;C<E;C++){let P=i[C];if(!P)continue;let L,D=i.transitions;for(let R=0,N=P.length;R<N;R++){let U=P[R];L=D[U],L||(L=D[U]=Object.create(null)),D=L}D[jh]=C+64}l=E}h||(i.nextId=E+64)}s&&(s=!1),o=i||[];try{if(w(x),is){dr.setUint32(is.position+n,ee-is.position-n);let E=is;is=null,w(E[0]),w(E[1])}if(c.offset=ee,a&&a.idsToInsert){ee+=a.idsToInsert.length*6,ee>ns&&_(ee),c.offset=ee;let E=z4(le.subarray(n,ee),a.idsToInsert);return a=null,E}return M&L_?(le.start=n,le.end=ee,le):le.subarray(n,ee)}finally{if(i){if(S<10&&S++,b>1e4)i.transitions=null,S=0,b=0,y.length>0&&(y=[]);else if(y.length>0&&!h){for(let E=0,C=y.length;E<C;E++)y[E][jh]=0;y=[]}if(s&&c.saveStructures){let E=i.sharedLength||d;i.length>E&&(i=i.slice(0,E));let C=le.subarray(n,ee);return c.saveStructures(i,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(x)):(l=E,C)}}M&Y4&&(ee=n)}};let w=x=>{ee>ns&&(le=_(ee));var M=typeof x,E;if(M==="string"){let C=x.length;if(is&&C>=8&&C<4096){let D=U4.test(x);is[D?0:1]+=x,le[ee++]=193,w(D?-C:C);return}let P;C<32?P=1:C<256?P=2:C<65536?P=3:P=5;let L=C*3;if(ee+L>ns&&(le=_(ee+L)),C<64||!u){let D,R,N,U=ee+P;for(D=0;D<C;D++)R=x.charCodeAt(D),R<128?le[U++]=R:R<2048?(le[U++]=R>>6|192,le[U++]=R&63|128):(R&64512)===55296&&((N=x.charCodeAt(D+1))&64512)===56320?(R=65536+((R&1023)<<10)+(N&1023),D++,le[U++]=R>>18|240,le[U++]=R>>12&63|128,le[U++]=R>>6&63|128,le[U++]=R&63|128):(le[U++]=R>>12|224,le[U++]=R>>6&63|128,le[U++]=R&63|128);E=U-ee-P}else E=u(x,ee+P,L);E<32?le[ee++]=160|E:E<256?(P<2&&le.copyWithin(ee+2,ee+1,ee+1+E),le[ee++]=217,le[ee++]=E):E<65536?(P<3&&le.copyWithin(ee+3,ee+2,ee+2+E),le[ee++]=218,le[ee++]=E>>8,le[ee++]=E&255):(P<5&&le.copyWithin(ee+5,ee+3,ee+3+E),le[ee++]=219,dr.setUint32(ee,E),ee+=4),ee+=E}else if(M==="number")if(x>>>0===x)x<64?le[ee++]=x:x<256?(le[ee++]=204,le[ee++]=x):x<65536?(le[ee++]=205,le[ee++]=x>>8,le[ee++]=x&255):(le[ee++]=206,dr.setUint32(ee,x),ee+=4);else if(x>>0===x)x>=-32?le[ee++]=256+x:x>=-128?(le[ee++]=208,le[ee++]=x+256):x>=-32768?(le[ee++]=209,dr.setInt16(ee,x),ee+=2):(le[ee++]=210,dr.setInt32(ee,x),ee+=4);else{let C;if((C=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){le[ee++]=202,dr.setFloat32(ee,x);let P;if(C<4||(P=x*am[(le[ee]&127)<<1|le[ee+1]>>7])>>0===P){ee+=4;return}else ee--}le[ee++]=203,dr.setFloat64(ee,x),ee+=8}else if(M==="object")if(!x)le[ee++]=192;else{if(a){let P=a.get(x);if(P){if(!P.id){let L=a.idsToInsert||(a.idsToInsert=[]);P.id=L.push(P)}le[ee++]=214,le[ee++]=112,dr.setUint32(ee,P.id),ee+=4;return}else a.set(x,{offset:ee-n})}let C=x.constructor;if(C===Object)A(x,!0);else if(C===Array){E=x.length,E<16?le[ee++]=144|E:E<65536?(le[ee++]=220,le[ee++]=E>>8,le[ee++]=E&255):(le[ee++]=221,dr.setUint32(ee,E),ee+=4);for(let P=0;P<E;P++)w(x[P])}else if(C===Map){E=x.size,E<16?le[ee++]=128|E:E<65536?(le[ee++]=222,le[ee++]=E>>8,le[ee++]=E&255):(le[ee++]=223,dr.setUint32(ee,E),ee+=4);for(let[P,L]of x)w(P),w(L)}else{for(let P=0,L=hm.length;P<L;P++){let D=B0[P];if(x instanceof D){let R=hm[P];if(R.write){R.type&&(le[ee++]=212,le[ee++]=R.type,le[ee++]=0),w(R.write.call(this,x));return}let N=le,U=dr,X=ee;le=null;let F;try{F=R.pack.call(this,x,G=>(le=N,N=null,ee+=G,ee>ns&&_(ee),{target:le,targetView:dr,position:ee-G}),w)}finally{N&&(le=N,dr=U,ee=X,ns=le.length-10)}F&&(F.length+ee>ns&&_(F.length+ee),ee=G4(F,le,ee,R.type));return}}A(x,!x.hasOwnProperty)}}else if(M==="boolean")le[ee++]=x?195:194;else if(M==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))le[ee++]=211,dr.setBigInt64(ee,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)le[ee++]=207,dr.setBigUint64(ee,x);else if(this.largeBigIntToFloat)le[ee++]=203,dr.setFloat64(ee,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ee+=8}else if(M==="undefined")this.encodeUndefinedAsNil?le[ee++]=192:(le[ee++]=212,le[ee++]=0,le[ee++]=0);else if(M==="function")w(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},A=this.useRecords===!1?this.variableMapSize?x=>{let M=Object.keys(x),E=M.length;E<16?le[ee++]=128|E:E<65536?(le[ee++]=222,le[ee++]=E>>8,le[ee++]=E&255):(le[ee++]=223,dr.setUint32(ee,E),ee+=4);let C;for(let P=0;P<E;P++)w(C=M[P]),w(x[C])}:(x,M)=>{le[ee++]=222;let E=ee-n;ee+=2;let C=0;for(let P in x)(M||x.hasOwnProperty(P))&&(w(P),w(x[P]),C++);le[E+++n]=C>>8,le[E+n]=C&255}:x=>{let M=Object.keys(x),E,C=o.transitions||(o.transitions=Object.create(null)),P=0;for(let D=0,R=M.length;D<R;D++){let N=M[D];E=C[N],E||(E=C[N]=Object.create(null),P++),C=E}let L=C[jh];if(L)L>=96&&p?(le[ee++]=((L-=96)&31)+96,le[ee++]=L>>5):le[ee++]=L;else{L=o.nextId,L||(L=64),L<g&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(L=o.nextOwnId,L<v||(L=g),o.nextOwnId=L+1):(L>=v&&(L=g),o.nextId=L+1);let D=M.highByte=L>=96&&p?L-96>>5:-1;C[jh]=L,o[L-64]=M,L<g?(M.isShared=!0,o.sharedLength=L-63,s=!0,D>=0?(le[ee++]=(L&31)+96,le[ee++]=D):le[ee++]=L):(D>=0?(le[ee++]=213,le[ee++]=114,le[ee++]=(L&31)+96,le[ee++]=D):(le[ee++]=212,le[ee++]=114,le[ee++]=L),P&&(b+=S*P),y.length>=m&&(y.shift()[jh]=0),y.push(C),w(M))}for(let D=0,R=M.length;D<R;D++)w(x[M[D]])},_=x=>{let M;if(x>16777216){if(x-n>E_)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(E_,Math.round(Math.max((x-n)*(x>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(x-n<<2,le.length-1)>>12)+1<<12;let E=new R0(M);return dr=new DataView(E.buffer,0,M),le.copy?le.copy(E,0,n,x):E.set(le.slice(n,x)),ee-=n,n=0,ns=E.length-10,le=E}}useBuffer(e){le=e,dr=new DataView(le.buffer,le.byteOffset,le.byteLength),ee=0}};B0=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Wh];hm=[{pack(r,e,t){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:i,targetView:s,position:o}=e(6);i[o++]=214,i[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:i,targetView:s,position:o}=e(10);i[o++]=215,i[o++]=255,s.setUint32(o,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:i,targetView:s,position:o}=e(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=e(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,r.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(r,e,t){let n=Array.from(r),{target:i,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),t(n)}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=101,n[i++]=0),t([r.name,r.message])}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=120,n[i++]=0),t([r.source,r.flags])}},{pack(r,e){this.structuredClone?C_(r,16,e):P_(fm?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==D_&&this.structuredClone?C_(r,O0.indexOf(t.name),e):P_(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function C_(r,e,t,n){let i=r.byteLength;if(i+1<256){var{target:s,position:o}=t(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=t(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=t(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=e,s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),o)}function P_(r,e){let t=r.byteLength;var n,i;if(t<256){var{target:n,position:i}=e(t+2);n[i++]=196,n[i++]=t}else if(t<65536){var{target:n,position:i}=e(t+3);n[i++]=197,n[i++]=t>>8,n[i++]=t&255}else{var{target:n,position:i,targetView:s}=e(t+5);n[i++]=198,s.setUint32(i,t),i+=4}n.set(r,i)}function G4(r,e,t,n){let i=r.length;switch(i){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:i<256?(e[t++]=199,e[t++]=i):i<65536?(e[t++]=200,e[t++]=i>>8,e[t++]=i&255):(e[t++]=201,e[t++]=i>>24,e[t++]=i>>16&255,e[t++]=i>>8&255,e[t++]=i&255)}return e[t++]=n,e.set(r,t),t+=i,t}function z4(r,e){let t,n=e.length*6,i=r.length-n;for(e.sort((s,o)=>s.offset>o.offset?1:-1);t=e.pop();){let s=t.offset,o=t.id;r.copyWithin(s+n,s,i),n-=6;let a=s+n;r[a++]=214,r[a++]=105,r[a++]=o>>24,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=o&255,i=s}return r}function Bo(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");B0.unshift(r.Class),hm.unshift(r)}M_(r)}var I_=new Ga({useRecords:!1}),V4=I_.pack,H4=I_.pack;var{NEVER:W4,ALWAYS:j4,DECIMAL_ROUND:q4,DECIMAL_FIT:X4}=cm,L_=512,Y4=1024;var O_=new Ga({structuredClone:!0});Bo({Class:nr.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,nr.prototype),r}});Bo({Class:ct.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,ct.prototype),r}});Bo({Class:Xr.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Xr.prototype),r}});Bo({Class:Vh.prototype.constructor,type:4,write(r){return r.id},read(r){return new Vh(r)}});Bo({Class:Hh.prototype.constructor,type:5,write(r){return r.data},read(r){return new Hh(r)}});Bo({Class:Xs.prototype.constructor,type:6,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Xs.prototype),r}});function Q4(r){var e=0;if(r.length===0)return e;for(let t=0;t<r.length;t++){let n=r[t];e=(e<<5)-e+n,e=e&e}return e}function N0(r){if(Na(r))return r;if(Array.isArray(r))return r.map(N0);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=N0(r[t]);return Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else return r}var dm;(n=>{function r(i){return O_.pack(i)}n.serialize=r;function e(i){return O_.unpack(i)}n.deserialize=e;function t(i){return Q4(r(N0(i))).toString()}n.checksum=t})(dm||(dm={}));var mm={["LookAt"]:[],["Follow"]:[],["MouseHover"]:["Transition"],["Scroll"]:["Transition"],["Start"]:["Transition","Audio"],["Conditional"]:["Transition","Audio"],["MouseDown"]:["Transition","Audio","Link"],["MouseUp"]:["Transition","Audio","Link"],["KeyDown"]:["Transition","Audio","Link"],["KeyUp"]:["Transition","Audio","Link"],["GameControl"]:["Transition","Audio"],["Collision"]:["Transition","Audio"]},R_;(t=>{function r(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp"}t.is=r;function e(n){return n==="MouseDown"||n==="MouseUp"?{type:n,toggle:!1,actions:new ct}:{type:n,key:void 0,toggle:!1,actions:new ct}}t.defaultData=e})(R_||(R_={}));var pm;(t=>{function r(n){return{type:"Property",value:[n??null,"position","x"]}}t.propertyDefaultData=r,t.valueDefaultData={type:"Literal",value:0}})(pm||(pm={}));var F0;(n=>{function r(i){return{type:"Comparison",operator:"==",lOperand:pm.propertyDefaultData(i),rOperand:{...pm.valueDefaultData}}}n.comparisonDefaultData=r;function e(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}n.distanceDefaultData=e;function t(i,s){return{type:"State",object:i??null,state:s??null}}n.stateDefaultData=t})(F0||(F0={}));var B_;(t=>{function r(n){return n.type==="Conditional"}t.is=r;function e(n){return{type:"Conditional",inActions:new ct,outActions:new ct,condition:F0.distanceDefaultData(n)}}t.defaultData=e})(B_||(B_={}));var N_;(e=>e.defaultData={type:"Follow"})(N_||(N_={}));var F_;(e=>{function r(){return{type:"LookAt",distance:1e3}}e.defaultData=r})(F_||(F_={}));var k_;(t=>{function r(n){return n.type==="MouseHover"}t.is=r;function e(){return{type:"MouseHover",actions:new ct}}t.defaultData=e})(k_||(k_={}));var U_;(t=>{function r(n){return n.type==="Scroll"}t.is=r;function e(){return{type:"Scroll",steps:100,actions:new ct}}t.defaultData=e})(U_||(U_={}));var G_;(t=>{function r(n){return n.type==="Start"}t.is=r;function e(){return{type:"Start",actions:new ct}}t.defaultData=e})(G_||(G_={}));var z_;(t=>{function r(n){return n.type==="Collision"}t.is=r;function e(){return{type:"Collision",toggle:!1,target:"character",actions:new ct}}t.defaultData=e})(z_||(z_={}));var za;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s]}t.lerp=e})(za||(za={}));var Oc;(i=>{function r(s,o){return s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]}i.isEqual=r;function e(s,o){return[s[0]+o[0],s[1]+o[1],s[2]+o[2]]}i.add=e;function t(s,o){return[s[0]-o[0],s[1]-o[1],s[2]-o[2]]}i.sub=t;function n(s,o,a){return[s[0]+(o[0]-s[0])*a,s[1]+(o[1]-s[1])*a,s[2]+(o[2]-s[2])*a]}i.lerp=n})(Oc||(Oc={}));var qh;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s,n[2]+(i[2]-n[2])*s,n[3]+(i[3]-n[3])*s]}t.lerp=e})(qh||(qh={}));var No;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=e;function t(s){return s??i.identity}i.simplify=t;function n(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}i.applyMatrix4=n})(No||(No={}));var sn;(l=>{l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function n(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:1}}l.toRgb255a1=n;function i(u){return{r:u.r,g:u.g,b:u.b}}l.clone=i;function s(u){return u=Math.floor(u),{r:(u>>16&255)/255,g:(u>>8&255)/255,b:(u&255)/255}}l.fromHex=s;function o(u,c){return u.r===c.r&&u.g===c.g&&u.b===c.b}l.equals=o;function a(u,c,h){return{r:u.r+(c.r-u.r)*h,g:u.g+(c.g-u.g)*h,b:u.b+(c.b-u.b)*h}}l.lerp=a})(sn||(sn={}));var Cn;(a=>{a.white={...sn.white,a:1},a.transparent={...sn.white,a:0};function t(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=t;function n(l,u){return{...sn.fromHex(l),a:u}}a.fromHexAndA=n;function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=i;function s(l,u){return sn.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(Cn||(Cn={}));var gm;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(gm||(gm={}));var V_;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(V_||(V_={}));var H_;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(H_||(H_={}));var ss;(t=>{t.all=["PerspectiveCamera","OrthographicCamera"];function e(n){return t.all.includes(n)}t.is=e})(ss||(ss={}));var Va;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(Va||(Va={}));var vm;(e=>{function r(t,n=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*n,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+n)),useCenter:!0}}}e.defaultData=r})(vm||(vm={}));var Ha;(t=>{let r={opacity:1,blendFunction:13,enabled:!1};t.defaultData={enabled:!1,pixelation:{...r,blendFunction:16,granularity:15},bloom:{...r,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...r,offset:[2,2]},vignette:{...r,darkness:1,offset:0},hueSaturation:{...r,hue:3,saturation:0},brightnessContrast:{...r,brightness:.25,contrast:0},depthOfField:{...r,focalLength:2,focusDistance:2,bokehScale:2},noise:{...r,blendFunction:16}}})(Ha||(Ha={}));var ym;(t=>{t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(n){return t.all.includes(n)}t.is=e})(ym||(ym={}));var xm;(t=>{function r(n){return e(n)}t.defaultData=r;function e(n){if(n==="PointLight")return{type:n,color:Cn.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(n==="SpotLight")return{type:n,color:Cn.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:Cn.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(xm||(xm={}));var k0;(t=>{t.defaultData={castShadow:!0,receiveShadow:!0};function e(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}t.equals=e})(k0||(k0={}));var U0;(t=>{t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(n,i){return n.flatShading===i.flatShading&&n.side===i.side&&n.wireframe===i.wireframe}t.equals=e})(U0||(U0={}));var bm;(e=>e.defaultData={...U0.defaultData,...k0.defaultData,cloner:null,booleanExclude:null})(bm||(bm={}));var Sm=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],W_=["wrapping","image"],Fo;(n=>{function r(i,s){return i==="light"&&s?e(s):t(i)}n.defaultData=r;function e(i){switch(i){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(i){switch(i){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:sn.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...sn.fromHex(6710886),a:1},colorB:{...sn.fromHex(6710886),a:1},colorC:{...sn.fromHex(16777215),a:1},colorD:{...sn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:Cn.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Cn.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:Cn.fromHexAndA(0,1),contourColor:Cn.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(Fo||(Fo={}));var Yr;(a=>{function r(l){return!l.layers.some(c=>{if(c.data.type==="texture"&&c.data.projection!==0||c.data.type==="depth"&&!c.data.isWorldSpace||c.data.type==="noise"||c.data.type==="displace")return!0})&&!t(l)}a.isMergable=r;function e(l){let u="";return l.layers.forEach(c=>{Object.entries(c.data).forEach(([h,f])=>{u+=`${h}${f}`,Array.isArray(f)?f.forEach(d=>u+=`${d}`):typeof f=="object"?Object.values(f).forEach(d=>{typeof d=="number"?u+=`${d.toFixed(4)}`:u+=`${d}`}):u+=`${f}`})}),u}a.getHash=e;function t(l){let u=0;for(let c of l.layers)"alpha"in c.data&&c.data.type!=="light"&&c.data.type!=="fresnel"&&(u+=(1-u)*c.data.alpha);return u<1}a.isTransparent=t;function n(){return{layers:new ct}}a.defaultEmptyData=n;function i(l="layer1",u="layer2"){return s("phong",l,u)}a.defaultData=i;function s(l,u="layer1",c="layer2"){let h=new ct;return h.push({fi:0,data:Fo.defaultData("light",l),id:u}),h.push({fi:1,data:Fo.defaultData("color"),id:c}),{layers:h}}a.defaultTwoLayerData=s;function o(l,u="basic",c="layer1",h="layer2"){let f=Fo.defaultData("texture");Object.assign(f.texture,{image:l});let d=new ct;return d.push({fi:0,data:f,id:c}),d.push({fi:1,data:Fo.defaultData("light",u),id:h}),{layers:d}}a.defaultTwoLayerTextureData=o})(Yr||(Yr={}));var Rc;(e=>{function r(){return{points:new ct,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=r})(Rc||(Rc={}));var wm;(e=>{function r(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=r})(wm||(wm={}));var ko;(e=>{function r(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="VectorGeometry")return{width:1,height:1,type:t,subdivisions:12,shape:Rc.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="BooleanGeometry")return{type:t,operation:2,width:0,height:0,depth:0,phongAngle:35};if(t==="TextGeometry")return{type:t,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};throw new Error("not implemented")}e.defaultData=r})(ko||(ko={}));var Xh;(i=>{i.identity={...gm.identity,hiddenMatrix:No.identity};function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=e;function t(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=t;function n(s,o){return{position:Oc.isEqual(s.position,o.position)?null:o.position,rotation:Oc.isEqual(s.rotation,o.rotation)?null:o.rotation,scale:Oc.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:No.isEqual(s.hiddenMatrix,o.hiddenMatrix)?null:o.hiddenMatrix}}i.diff=n})(Xh||(Xh={}));var G0;(e=>e.defaultData={fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(G0||(G0={}));var Pi;(e=>e.defaultData={states:new ct,events:new ct,visible:!0,raycastLock:!1,physics:null,...Xh.identity})(Pi||(Pi={}));var j_;(e=>e.defaultData={type:"Empty",...Pi.defaultData})(j_||(j_={}));var Wa;(e=>e.defaultData={type:"Mesh",...Pi.defaultData,...bm.defaultData})(Wa||(Wa={}));var Am;(e=>e.defaultData={...Pi.defaultData,...Xh.identity,...Va.defaultData})(Am||(Am={}));var Tm;(e=>{function r(t){return{...Pi.defaultData,...xm.defaultData(t)}}e.defaultData=r})(Tm||(Tm={}));var _m;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:No.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:G0.defaultData,states:new ct,events:new ct,...Va.defaultData},i.defaultMeshObject={name:"Rectangle",...Pi.defaultData,...Wa.defaultData,geometry:ko.defaultData("RectangleGeometry"),material:Yr.defaultTwoLayerData("basic","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...Pi.defaultData,...Wa.defaultData,geometry:ko.defaultData("BooleanGeometry"),material:Yr.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...Pi.defaultData,...Wa.defaultData,geometry:ko.defaultData("TextGeometry"),material:Yr.defaultTwoLayerData("phong","layer1","layer2")}))(_m||(_m={}));var Yh;(t=>{function r(n,i){if(i===void 0)return n;let s={...n};return"material"in s&&"material"in i&&i.material&&(s.material=T0(s.material,o=>{if(typeof o!="string")for(let[a,l]of Object.entries(i.material.layers)){let u=o.layers.data(a);u&&Ba(u,l)}}).data),s.materials&&i.materials&&(s.materials=T0(s.materials,o=>{for(let a=0;a<s.materials.length;a++){let l=i.materials[a];if(typeof l!="string")for(let[u,c]of Object.entries(l.layers)){let h=o[a]?.layers?.data(u);h&&Ba(h,c)}}}).data),s}t.patchMaterialState=r;function e(n,i){if(i===void 0)return n;let s={...n};if(Object.assign(s,Xh.merge(s,i)),ss.is(n.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let o=i;o.orthographic?.zoom!==void 0&&(s.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(s.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(s.targetOffset=o.targetOffset)}else if(n.type==="Mesh")s.geometry={...s.geometry},Object.assign(s.geometry,i.geometry),s=r(s,i);else if(ym.is(n.type)){let o=i;o.intensity!==void 0&&(s.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?s.color=o.color:s.color=sn.clone(o.color))}return s}t.patch=e})(Yh||(Yh={}));var Qh;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:sn.white,near:.1,far:2e3})(Qh||(Qh={}));var Bc;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3})(Bc||(Bc={}));var Qs;(e=>e.defaultData={orbitControls:Bc.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:1,stopMode:"manual",duration:5e3},web:{compress:!0,preset:1,preload:!0}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((t,n)=>{let i=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?i=30:(n===4||n===11||n===9)&&(i=-30),[120,[i,s],"show"]}),gameControlObject:null})(Qs||(Qs={}));var li;(e=>e.defaultData={ambientLight:{enabled:!0,type:"HemisphereLight",color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!1,softShadowQuality:"low"},usePhysics:!1,gravity:-10,pixelsPerMeter:200})(li||(li={}));var Mm;(n=>{function r(){let i=new Xr,s=_m.defaultMeshObject;return i.push({fi:-1,data:{...Tm.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),i.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:s,children:[]}),i}n.defaultData={backgroundColor:Cn.fromHexAndA(1184534,1),postprocessing:Ha.defaultData,fog:Qh.defaultData,objects:r(),environment:li.defaultData,publish:Qs.defaultData},n.emptyData=function(){return{backgroundColor:Cn.fromHexAndA(1184534,1),postprocessing:Ha.defaultData,fog:Qh.defaultData,objects:new Xr,environment:li.defaultData,publish:Qs.defaultData}}})(Mm||(Mm={}));function ja(r,e){return Object.setPrototypeOf(r,e),r}var Z4=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),K4=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),J4=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||qa&&"ontouchend"in document,$4=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,eV=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,tV=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,e=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(e)},rV=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},bse=Z4(),qa=K4(),Zh=J4(),q_=$4(),Er=eV(),Nc=tV(),Fc=Number(rV());function X_(r){return Array.isArray(r)?r:[r]}function Kh(r){return qa?r.metaKey:r.ctrlKey}var st=[],Cm={},Jh={},Em={};function Y_(r){st.includes(r)||st.push(r)}function kc(r){delete Cm[r.pointerId];for(let e=0;e<st.length;e++)if(st[e].pointerId===r.pointerId){st.splice(e,1);break}}function Pm(r){if(r.pointerType!=="touch")return;let e=Cm[r.pointerId];e===void 0&&(e={x:0,y:0},Cm[r.pointerId]=e),e.x=r.pageX,e.y=r.pageY}function Dm(r){let e=r.pointerId===st[0].pointerId?st[1]:st[0];return Cm[e.pointerId]}function Q_(r){Jh[r.key]=!0,Em[r.key]=Em[r.key]===void 0?1:Em[r.key]+1}function Z_(r){if(qa&&Jh.Meta)for(let e in Jh)Jh[e]=!1;else Jh[r.key]=!1;Em={}}function K_(r){r.addEventListener("pointerdown",Y_,!0),r.addEventListener("pointerdown",Pm,!0),r.addEventListener("pointermove",Pm,!0),r.addEventListener("pointerup",kc,!0),r.addEventListener("pointercancel",kc,!0),r.addEventListener("pointerleave",kc,!0),window.addEventListener("keydown",Q_,!0),window.addEventListener("keyup",Z_,!0)}function J_(r){r.removeEventListener("pointerdown",Y_,!0),r.removeEventListener("pointerdown",Pm,!0),r.removeEventListener("pointermove",Pm,!0),r.removeEventListener("pointerup",kc,!0),r.removeEventListener("pointercancel",kc,!0),r.removeEventListener("pointerleave",kc,!0),window.removeEventListener("keydown",Q_,!0),window.removeEventListener("keyup",Z_,!0)}var Uc;(t=>{function r(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},ja(n,nr.prototype)}t.defaultColors=r;function e(){return{materials:new nr,images:new nr,colors:new nr,audios:new nr,fonts:new nr,penumbraSize:[.5,.5,.5]}}t.emptyData=e})(Uc||(Uc={}));function $_(r){r.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let t=e.colorA,n=e.colorB,i=[[t.r,t.g,t.b,t.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)i.push(i[1]),s.push(1);let o={...Pc(Mn(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:i,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(e,o)}else if(e.type==="depth"&&e.gradientType===1&&(e.near<0||e.far<0)){let t={...Mn(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,t)}})}function z0(r,e){Object.values(r.shared.materials).forEach(t=>e(t))}function V0(r,e){r.scene.objects.traverse((t,n)=>{"materials"in n?n.materials.forEach(i=>{typeof i!="string"&&e(i)}):"material"in n&&typeof n.material!="string"&&e(n.material)})}function nV(r){Object.assign(r.scene.publish,{orbitControls:{...Bc.defaultData,...Mn(r.scene.publish.orbitControls)}})}function iV(r){Object.assign(r.scene.publish.settings,{video:{...Qs.defaultData.settings.video,...Mn(r.scene.publish.settings.video)}})}function sV(r){function e(t){if(t.layers){for(let n of Object.values(t.layers))if(n){for(let[i,s]of Object.entries(n))if((Sm.includes(i)||typeof s=="boolean")&&delete n[i],i==="texture")for(let[o,a]of Object.entries(s))(W_.includes(o)||typeof a=="boolean")&&delete s[o]}}}r.scene.objects.traverse((t,n)=>{n.states.forEach(i=>{let s=i;s.material?e(s.material):s.materials&&s.materials.forEach(o=>{e(o)})})})}function oV(r){r.scene.publish.withBackground=!0}function aV(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1}}function lV(r){r.scene.objects.traverse((e,t)=>{let n=t.cloner;n&&(n.radial.scale=n.radial.scale.map(i=>i+1),n.linear.scale=n.linear.scale.map(i=>i+1))})}function cV(r){r.scene.objects.traverse((e,t)=>{let n=t.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function uV(r){r.scene.objects.traverse((e,t)=>{let n=r.scene.objects.parent(e);t.type==="Mesh"&&(!n||r.scene.objects.data(n).geometry?.type!=="BooleanGeometry")&&(t.booleanExclude=null)})}function eM(r){r.layers===void 0&&Object.assign(r,Yr.defaultTwoLayerData("lambert"))}function H0(r){!r.layers||r.layers.forEach(e=>{if(e.type==="depth"&&e.colors.length===10){let t=[...e.colors];t.push(e.colors[9]);let n=[...e.steps];n.push(e.steps[9]);let i={...Mn(e),colors:t,steps:n};Object.assign(e,i)}})}function hV(r){r.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&(t.geometry.type==="BooleanGeometry"||t.geometry.type==="SubdivGeometry")&&(t.geometry.phongAngle=35)})}function tM(r){r.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach(n=>{typeof n!="string"&&H0(n)}):"material"in t&&typeof t.material!="string"&&H0(t.material)}),Object.values(r.shared.materials).forEach(e=>H0(e))}function fV(r){r.scene.environment.ambientLight.softShadows=!1,r.scene.environment.ambientLight.softShadowQuality="low",r.scene.objects.traverse((e,t)=>{(t.type==="DirectionalLight"||t.type==="SpotLight")&&(t.shadowResolution=1024,t.shadowRadius=1,t.depth=1e5)}),r.shared.penumbraSize=new Array(5).fill(.5)}function dV(r){r.shared.audios=ja({},nr.prototype)}function pV(r){let e=r.shared.materials;Object.entries(e).forEach(([t,n])=>{if(!n.layers){let i={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"basic",alpha:1,visible:!0,mode:0},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(e,{[t]:i})}})}function mV(r){Object.entries(Mn(r.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.images[n]}),Object.entries(Mn(r.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.audios[n]})}function gV(r){r.scene.publish.settings.web.preload=!1}function rM(r){r.layers&&r.layers.forEach(e=>{e.type==="depth"&&e.num!==void 0&&(e.colors=e.colors.slice(0,e.num),e.steps=e.steps.slice(0,e.num),delete e.num)})}function vV(r){r.shared.fonts=ja({},nr.prototype)}function yV(r){return r.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function xV(r){let e=[];r.scene.objects.traverse((t,n)=>{let i=n;if(i.type==="TextFrame"){let s=Yr.defaultTwoLayerData("basic"),o=typeof i.color=="string"?r.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=yV(i.font);r.shared.fonts[a]===void 0&&(r.shared.fonts[a]={name:a});let l={name:i.name,...Pi.defaultData,...Wa.defaultData,flatShading:!1,wireframe:!1,geometry:{...ko.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Mn(i.states),events:Mn(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},u=Mn(r.scene.objects).parent(t);r.scene.objects.insertAfter(u??null,t,[{id:t+"new",data:l,children:[]}]),e.push(t)}}),e.forEach(t=>{r.scene.objects.delete(t)})}function bV(r){let e={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};r.scene.objects.traverse((t,n)=>{n.events.forEach(i=>{if(!!e[Number(i.type)])if(Object.assign(i,{type:e[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new ct,move:new ct,jump:new ct}});else{let s=new ct;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:ze.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Pc(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},f={state:o.state,...h,...c},d={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ct({fi:0,id:ze.generateUUID(),data:u},{fi:1,id:ze.generateUUID(),data:f})};s.push({fi:l,id:a,data:d})}),delete i.targets)}})})}function SV(r){r.scene.objects.traverse((e,t)=>{function n(i,s){let o=new ct,a=[];if(t.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(u),l.interaction==="play"?h={...Pc(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(h={...Pc(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:c,id:u,data:h})}}),a.forEach(l=>t.events.delete(l)),o.length){let l=t.events.find(u=>u.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):t.events.insertBefore(null,[{id:ze.generateUUID(),data:{type:i,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}var nM=21;function iM(r){let e=r.schema??0;e!==nM&&(console.warn("updating from ",e,"to ",nM),e<1&&(V0(r,$_),z0(r,$_),r.schema=1),e<2&&(nV(r),r.schema=2),e<3&&(sV(r),r.schema=3),e<4&&(oV(r),r.schema=4),e<5&&(aV(r),r.schema=5),e<6&&(lV(r),r.schema=6),e<7&&(cV(r),r.schema=7),e<8&&(uV(r),r.schema=8),e<9&&(tM(r),r.schema=9),e<10&&(hV(r),r.schema=10),e<11&&(fV(r),r.schema=11),e<12&&(tM(r),r.schema=12),e<13&&(dV(r),r.schema=13),e<14&&(pV(r),r.schema=14),e<15&&(mV(r),r.schema=15),e<16&&(gV(r),r.schema=16),e<17&&(V0(r,rM),z0(r,rM),r.schema=17),e<18&&(V0(r,eM),z0(r,eM),r.schema=18),e<19&&(iV(r),r.schema=19),e<20&&(vV(r),xV(r),r.schema=20),e<21&&(bV(r),SV(r),r.schema=21))}var Im;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(Im||(Im={}));function Zs(r,e=!1){let t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new Le,u=0;for(let c=0;c<r.length;++c){let h=r[c],f=0;if(t!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let d in h.attributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;s[d]===void 0&&(s[d]=[]),s[d].push(h.attributes[d]),f++}if(f!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let d in h.morphAttributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[d]===void 0&&(o[d]=[]),o[d].push(h.morphAttributes[d])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(h.userData),e){let d;if(t)d=h.index.count;else if(h.attributes.position!==void 0)d=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,d,c),u+=d}}if(t){let c=0,h=[];for(let f=0;f<r.length;++f){let d=r[f].index;for(let m=0;m<d.count;++m)h.push(d.getX(m)+c);c+=r[f].attributes.position.count}l.setIndex(h)}for(let c in s){let h=sM(s[c]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,h)}for(let c in o){let h=o[c][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let f=0;f<h;++f){let d=[];for(let p=0;p<o[c].length;++p)d.push(o[c][p][f]);let m=sM(d);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(m)}}return l}function sM(r){let e,t,n,i=0;for(let a=0;a<r.length;++a){let l=r[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=l.array.constructor),e!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=l.itemSize),t!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=l.array.length}let s=new e(i),o=0;for(let a=0;a<r.length;++a)s.set(r[a].array,o),o+=r[a].array.length;return new We(s,t,n)}var oM=Math.pow(2,-24);var Xa=class{constructor(){}};function ci(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function W0(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){let i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function j0(r,e){e.set(r)}function q0(r,e,t){let n,i;for(let s=0;s<3;s++){let o=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[o],i=e[o],t[o]=n>i?n:i}}function $h(r,e,t){for(let n=0;n<3;n++){let i=e[r+2*n],s=e[r+2*n+1],o=i-s,a=i+s;o<t[n]&&(t[n]=o),a>t[n+3]&&(t[n+3]=a)}}function zc(r){let e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function TV(r,e){if(!r.index){let t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;t>65535?i=new Uint32Array(new n(4*t)):i=new Uint16Array(new n(2*t)),r.setIndex(new We(i,1));for(let s=0;s<t;s++)i[s]=s}}function _V(r){if(!r.groups||!r.groups.length)return[{offset:0,count:r.index.count/3}];let e=[],t=new Set;for(let i of r.groups)t.add(i.start),t.add(i.start+i.count);let n=Array.from(t.values()).sort((i,s)=>i-s);for(let i=0;i<n.length-1;i++){let s=n[i],o=n[i+1];e.push({offset:s/3,count:(o-s)/3})}return e}function Y0(r,e,t,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,h=1/0,f=1/0,d=1/0,m=-1/0,p=-1/0,g=-1/0,v=i!==null;for(let y=e*6,b=(e+t)*6;y<b;y+=6){let S=r[y+0],w=r[y+1],A=S-w,_=S+w;A<s&&(s=A),_>l&&(l=_),v&&S<h&&(h=S),v&&S>m&&(m=S);let x=r[y+2],M=r[y+3],E=x-M,C=x+M;E<o&&(o=E),C>u&&(u=C),v&&x<f&&(f=x),v&&x>p&&(p=x);let P=r[y+4],L=r[y+5],D=P-L,R=P+L;D<a&&(a=D),R>c&&(c=R),v&&P<d&&(d=P),v&&P>g&&(g=P)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,v&&(i[0]=h,i[1]=f,i[2]=d,i[3]=m,i[4]=p,i[5]=g)}function MV(r,e,t,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=e*6,h=(e+t)*6;c<h;c+=6){let f=r[c+0];f<i&&(i=f),f>a&&(a=f);let d=r[c+2];d<s&&(s=d),d>l&&(l=d);let m=r[c+4];m<o&&(o=m),m>u&&(u=m)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function EV(r,e,t,n,i){let s=t,o=t+n-1,a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&e[s*6+l]<a;)s++;for(;s<=o&&e[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=r[s*3+u];r[s*3+u]=r[o*3+u],r[o*3+u]=c;let h=e[s*6+u*2+0];e[s*6+u*2+0]=e[o*6+u*2+0],e[o*6+u*2+0]=h;let f=e[s*6+u*2+1];e[s*6+u*2+1]=e[o*6+u*2+1],e[o*6+u*2+1]=f}s++,o--}else return s}}var Ks=32,CV=(r,e)=>r.candidate-e.candidate,Uo=new Array(Ks).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Lm=new Float32Array(6);function PV(r,e,t,n,i,s){let o=-1,a=0;if(s===0)o=W0(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===1)o=W0(r),o!==-1&&(a=DV(t,n,i,o));else if(s===2){let l=zc(r),u=1.25*i,c=n*6,h=(n+i)*6;for(let f=0;f<3;f++){let d=e[f],g=(e[f+3]-d)/Ks;if(i<Ks/4){let v=[...Uo];v.length=i;let y=0;for(let S=c;S<h;S+=6,y++){let w=v[y];w.candidate=t[S+2*f],w.count=0;let{bounds:A,leftCacheBounds:_,rightCacheBounds:x}=w;for(let M=0;M<3;M++)x[M]=1/0,x[M+3]=-1/0,_[M]=1/0,_[M+3]=-1/0,A[M]=1/0,A[M+3]=-1/0;$h(S,t,A)}v.sort(CV);let b=i;for(let S=0;S<b;S++){let w=v[S];for(;S+1<b&&v[S+1].candidate===w.candidate;)v.splice(S+1,1),b--}for(let S=c;S<h;S+=6){let w=t[S+2*f];for(let A=0;A<b;A++){let _=v[A];w>=_.candidate?$h(S,t,_.rightCacheBounds):($h(S,t,_.leftCacheBounds),_.count++)}}for(let S=0;S<b;S++){let w=v[S],A=w.count,_=i-w.count,x=w.leftCacheBounds,M=w.rightCacheBounds,E=0;A!==0&&(E=zc(x)/l);let C=0;_!==0&&(C=zc(M)/l);let P=1+1.25*(E*A+C*_);P<u&&(o=f,u=P,a=w.candidate)}}else{for(let b=0;b<Ks;b++){let S=Uo[b];S.count=0,S.candidate=d+g+b*g;let w=S.bounds;for(let A=0;A<3;A++)w[A]=1/0,w[A+3]=-1/0}for(let b=c;b<h;b+=6){let A=~~((t[b+2*f]-d)/g);A>=Ks&&(A=Ks-1);let _=Uo[A];_.count++,$h(b,t,_.bounds)}let v=Uo[Ks-1];j0(v.bounds,v.rightCacheBounds);for(let b=Ks-2;b>=0;b--){let S=Uo[b],w=Uo[b+1];q0(S.bounds,w.rightCacheBounds,S.rightCacheBounds)}let y=0;for(let b=0;b<Ks-1;b++){let S=Uo[b],w=S.count,A=S.bounds,x=Uo[b+1].rightCacheBounds;w!==0&&(y===0?j0(A,Lm):q0(A,Lm,Lm)),y+=w;let M=0,E=0;y!==0&&(M=zc(Lm)/l);let C=i-y;C!==0&&(E=zc(x)/l);let P=1+1.25*(M*y+E*C);P<u&&(o=f,u=P,a=S.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function DV(r,e,t,n){let i=0;for(let s=e,o=e+t;s<o;s++)i+=r[s*6+n*2];return i/t}function IV(r,e){let t=r.attributes.position,n=t.array,i=r.index.array,s=i.length/3,o=new Float32Array(s*6),a=t.offset||0,l=3;t.isInterleavedBufferAttribute&&(l=t.data.stride);for(let u=0;u<s;u++){let c=u*3,h=u*6,f=i[c+0]*l+a,d=i[c+1]*l+a,m=i[c+2]*l+a;for(let p=0;p<3;p++){let g=n[f+p],v=n[d+p],y=n[m+p],b=g;v<b&&(b=v),y<b&&(b=y);let S=g;v>S&&(S=v),y>S&&(S=y);let w=(S-b)/2,A=p*2;o[h+A+0]=b+w,o[h+A+1]=w+(Math.abs(b)+w)*oM,b<e[p]&&(e[p]=b),S>e[p+3]&&(e[p+3]=S)}}return o}function LV(r,e){function t(v){f&&f(v/d)}function n(v,y,b,S=null,w=0){if(!m&&w>=l&&(m=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(r))),b<=c||w>=l)return t(y+b),v.offset=y,v.count=b,v;let A=PV(v.boundingData,S,o,y,b,h);if(A.axis===-1)return t(y+b),v.offset=y,v.count=b,v;let _=EV(a,o,y,b,A);if(_===y||_===y+b)t(y+b),v.offset=y,v.count=b;else{v.splitAxis=A.axis;let x=new Xa,M=y,E=_-y;v.left=x,x.boundingData=new Float32Array(6),Y0(o,M,E,x.boundingData,s),n(x,M,E,s,w+1);let C=new Xa,P=_,L=b-E;v.right=C,C.boundingData=new Float32Array(6),Y0(o,P,L,C.boundingData,s),n(C,P,L,s,w+1)}return v}TV(r,e);let i=new Float32Array(6),s=new Float32Array(6),o=IV(r,i),a=r.index.array,l=e.maxDepth,u=e.verbose,c=e.maxLeafTris,h=e.strategy,f=e.onProgress,d=r.index.count/3,m=!1,p=[],g=_V(r);if(g.length===1){let v=g[0],y=new Xa;y.boundingData=i,MV(o,v.offset,v.count,s),n(y,v.offset,v.count,s),p.push(y)}else for(let v of g){let y=new Xa;y.boundingData=new Float32Array(6),Y0(o,v.offset,v.count,y.boundingData,s),n(y,v.offset,v.count,s),p.push(y)}return p}function cM(r,e){let t=LV(r,e),n,i,s,o=[],a=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<t.length;c++){let h=t[c],f=l(h),d=new a(32*f);n=new Float32Array(d),i=new Uint32Array(d),s=new Uint16Array(d),u(0,h),o.push(d)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,h){let f=c/4,d=c/2,m=!!h.count,p=h.boundingData;for(let g=0;g<6;g++)n[f+g]=p[g];if(m){let g=h.offset,v=h.count;return i[f+6]=g,s[d+14]=v,s[d+15]=65535,c+32}else{let g=h.left,v=h.right,y=h.splitAxis,b;if(b=u(c+32,g),b/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[f+6]=b/4,b=u(b,v),i[f+7]=y,b}}}var Pn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){let l=e[s][t];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let a=t[s],l=e.dot(a);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}};Pn.prototype.setFromBox=function(){let r=new T;return function(t,n){let i=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){r.x=i.x*l+s.x*(1-l),r.y=i.y*u+s.y*(1-u),r.z=i.z*c+s.z*(1-c);let h=t.dot(r);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var doe=function(){let r=new Pn;return function(t,n){let i=t.points,s=t.satAxes,o=t.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let h=o[c],f=s[c];if(r.setFromPoints(f,a),h.isSeparated(r))return!1}for(let c=0;c<3;c++){let h=u[c],f=l[c];if(r.setFromPoints(f,i),h.isSeparated(r))return!1}}}();var OV=function(){let r=new T,e=new T,t=new T;return function(i,s,o){let a=i.start,l=r,u=s.start,c=e;t.subVectors(a,u),r.subVectors(i.end,s.start),e.subVectors(s.end,s.start);let h=t.dot(c),f=c.dot(l),d=c.dot(c),m=t.dot(l),g=l.dot(l)*d-f*f,v,y;g!==0?v=(h*f-m*d)/g:v=0,y=(h+v*f)/d,o.x=v,o.y=y}}(),ef=function(){let r=new k,e=new T,t=new T;return function(i,s,o,a){OV(i,s,r);let l=r.x,u=r.y;if(l>=0&&l<=1&&u>=0&&u<=1){i.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let h;u<0?h=s.start:h=s.end;let f=e,d=t;if(i.closestPointToPoint(h,!0,e),s.closestPointToPoint(c,!0,t),f.distanceToSquared(h)<=d.distanceToSquared(c)){o.copy(f),a.copy(h);return}else{o.copy(c),a.copy(d);return}}}}(),uM=function(){let r=new T,e=new T,t=new Tr,n=new _r;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:h}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=u,n.end=h,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=h,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;let p=o.getPlane(t);if(Math.abs(p.distanceToPoint(l))<=a){let v=p.projectPoint(l,e);if(o.containsPoint(v))return!0}return!1}}();var RV=1e-15;function Vc(r){return Math.abs(r)<RV}var Dn=class extends Nr{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new T),this.satBounds=new Array(4).fill().map(()=>new Pn),this.points=[this.a,this.b,this.c],this.sphere=new Fr,this.plane=new Tr,this.needsUpdate=!0}intersectsSphere(e){return uM(e,this)}update(){let e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let u=s[1],c=o[1];u.subVectors(e,t),c.setFromPoints(u,i);let h=s[2],f=o[2];h.subVectors(t,n),f.setFromPoints(h,i);let d=s[3],m=o[3];d.subVectors(n,e),m.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};Dn.prototype.closestPointToSegment=function(){let r=new T,e=new T,t=new _r;return function(i,s=null,o=null){let{start:a,end:l}=i,u=this.points,c,h=1/0;for(let f=0;f<3;f++){let d=(f+1)%3;t.start.copy(u[f]),t.end.copy(u[d]),ef(t,i,r,e),c=r.distanceToSquared(e),c<h&&(h=c,s&&s.copy(r),o&&o.copy(e))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<h&&(h=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<h&&(h=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(h)}}();Dn.prototype.intersectsTriangle=function(){let r=new Dn,e=new Array(3),t=new Array(3),n=new Pn,i=new Pn,s=new T,o=new T,a=new T,l=new T,u=new _r,c=new _r,h=new _r;return function(d,m=null){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(r.copy(d),r.update(),d=r);let p=this.plane,g=d.plane;if(Math.abs(p.normal.dot(g.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;t[0]=d.a,t[1]=d.b,t[2]=d.c;for(let w=0;w<4;w++){let A=v[w],_=y[w];if(n.setFromPoints(_,t),A.isSeparated(n))return!1}let b=d.satBounds,S=d.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let w=0;w<4;w++){let A=b[w],_=S[w];if(n.setFromPoints(_,e),A.isSeparated(n))return!1}for(let w=0;w<4;w++){let A=y[w];for(let _=0;_<4;_++){let x=S[_];if(s.crossVectors(A,x),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return m&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{let v=this.points,y=!1,b=0;for(let L=0;L<3;L++){let D=v[L],R=v[(L+1)%3];u.start.copy(D),u.end.copy(R),u.delta(o);let N=y?c.start:c.end,U=Vc(g.distanceToPoint(D));if(Vc(g.normal.dot(o))&&U){c.copy(u),b=2;break}if((g.intersectLine(u,N)||U)&&!Vc(N.distanceTo(R))){if(b++,y)break;y=!0}}if(b===1&&this.containsPoint(c.start))return m&&(m.start.copy(c.start),m.end.copy(c.start)),!0;if(b!==2)return!1;let S=d.points,w=!1,A=0;for(let L=0;L<3;L++){let D=S[L],R=S[(L+1)%3];u.start.copy(D),u.end.copy(R),u.delta(a);let N=w?h.start:h.end,U=Vc(p.distanceToPoint(D));if(Vc(p.normal.dot(a))&&U){h.copy(u),A=2;break}if((p.intersectLine(u,N)||U)&&!Vc(N.distanceTo(R))){if(A++,w)break;w=!0}}if(A===1&&this.containsPoint(h.start))return m&&(m.start.copy(h.start),m.end.copy(h.start)),!0;if(A!==2)return!1;if(c.delta(o),h.delta(a),o.dot(a)<0){let L=h.start;h.start=h.end,h.end=L}let _=c.start.dot(o),x=c.end.dot(o),M=h.start.dot(o),E=h.end.dot(o),C=x<M,P=_<E;return _!==E&&M!==x&&C===P?!1:(m&&(l.subVectors(c.start,h.start),l.dot(o)>0?m.start.copy(c.start):m.start.copy(h.start),l.subVectors(c.end,h.end),l.dot(o)<0?m.end.copy(c.end):m.end.copy(h.end)),!0)}}}();Dn.prototype.distanceToPoint=function(){let r=new T;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();Dn.prototype.distanceToTriangle=function(){let r=new T,e=new T,t=["a","b","c"],n=new _r,i=new _r;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let h=0;h<3;h++){let f,d=t[h],m=o[d];this.closestPointToPoint(m,r),f=m.distanceToSquared(r),f<c&&(c=f,a&&a.copy(r),l&&l.copy(m));let p=this[d];o.closestPointToPoint(p,r),f=p.distanceToSquared(r),f<c&&(c=f,a&&a.copy(p),l&&l.copy(r))}for(let h=0;h<3;h++){let f=t[h],d=t[(h+1)%3];n.set(this[f],this[d]);for(let m=0;m<3;m++){let p=t[m],g=t[(m+1)%3];i.set(o[p],o[g]),ef(n,i,r,e);let v=r.distanceToSquared(e);v<c&&(c=v,a&&a.copy(r),l&&l.copy(e))}}return Math.sqrt(c)}}();var In=class extends Lt{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new we,this.invMatrix=new we,this.points=new Array(8).fill().map(()=>new T),this.satAxes=new Array(3).fill().map(()=>new T),this.satBounds=new Array(3).fill().map(()=>new Pn),this.alignedSatBounds=new Array(3).fill().map(()=>new Pn),this.needsUpdate=!1}set(e,t,n){super.set(e,t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){super.copy(e),this.matrix.copy(e.matrix),this.needsUpdate=!0}};In.prototype.update=function(){return function(){let e=this.matrix,t=this.min,n=this.max,i=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){let f=1*u|2*c|4*h,d=i[f];d.x=u?n.x:t.x,d.y=c?n.y:t.y,d.z=h?n.z:t.z,d.applyMatrix4(e)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let u=0;u<3;u++){let c=o[u],h=s[u],f=1<<u,d=i[f];c.subVectors(a,d),h.setFromPoints(c,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();In.prototype.intersectsBox=function(){let r=new Pn;return function(t){this.needsUpdate&&this.update();let n=t.min,i=t.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(r.setFromBox(u,t),c.isSeparated(r))return!1}return!0}}();In.prototype.intersectsTriangle=function(){let r=new Dn,e=new Array(3),t=new Pn,n=new Pn,i=new T;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);let a=this.satBounds,l=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let f=0;f<3;f++){let d=a[f],m=l[f];if(t.setFromPoints(m,e),d.isSeparated(t))return!1}let u=o.satBounds,c=o.satAxes,h=this.points;for(let f=0;f<3;f++){let d=u[f],m=c[f];if(t.setFromPoints(m,h),d.isSeparated(t))return!1}for(let f=0;f<3;f++){let d=l[f];for(let m=0;m<4;m++){let p=c[m];if(i.crossVectors(d,p),t.setFromPoints(i,e),n.setFromPoints(i,h),t.isSeparated(n))return!1}}return!0}}();In.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();In.prototype.distanceToPoint=function(){let r=new T;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();In.prototype.distanceToBox=function(){let r=["x","y","z"],e=new Array(12).fill().map(()=>new _r),t=new Array(12).fill().map(()=>new _r),n=new T,i=new T;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),u&&u.copy(i)),0;let c=a*a,h=o.min,f=o.max,d=this.points,m=1/0;for(let g=0;g<8;g++){let v=d[g];i.copy(v).clamp(h,f);let y=v.distanceToSquared(i);if(y<m&&(m=y,l&&l.copy(v),u&&u.copy(i),y<c))return Math.sqrt(y)}let p=0;for(let g=0;g<3;g++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){let b=(g+1)%3,S=(g+2)%3,w=v<<b|y<<S,A=1<<g|v<<b|y<<S,_=d[w],x=d[A];e[p].set(_,x);let E=r[g],C=r[b],P=r[S],L=t[p],D=L.start,R=L.end;D[E]=h[E],D[C]=v?h[C]:f[C],D[P]=y?h[P]:f[C],R[E]=f[E],R[C]=v?h[C]:f[C],R[P]=y?h[P]:f[C],p++}for(let g=0;g<=1;g++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){i.x=g?f.x:h.x,i.y=v?f.y:h.y,i.z=y?f.z:h.z,this.closestPointToPoint(i,n);let b=i.distanceToSquared(n);if(b<m&&(m=b,l&&l.copy(n),u&&u.copy(i),b<c))return Math.sqrt(b)}for(let g=0;g<12;g++){let v=e[g];for(let y=0;y<12;y++){let b=t[y];ef(v,b,n,i);let S=n.distanceToSquared(i);if(S<m&&(m=S,l&&l.copy(n),u&&u.copy(i),S<c))return Math.sqrt(S)}}return Math.sqrt(m)}}();var Rm=new T,Bm=new T,Nm=new T,hM=new k,fM=new k,dM=new k,pM=new T;function BV(r,e,t,n,i,s){let o;return s===xr?o=r.intersectTriangle(n,t,e,!0,i):o=r.intersectTriangle(e,t,n,s!==pn,i),o===null?null:{distance:r.origin.distanceTo(i),point:i.clone()}}function NV(r,e,t,n,i,s,o){Rm.fromBufferAttribute(e,n),Bm.fromBufferAttribute(e,i),Nm.fromBufferAttribute(e,s);let a=BV(r,Rm,Bm,Nm,pM,o);if(a){t&&(hM.fromBufferAttribute(t,n),fM.fromBufferAttribute(t,i),dM.fromBufferAttribute(t,s),a.uv=Nr.getUV(pM,Rm,Bm,Nm,hM,fM,dM,new k));let l={a:n,b:i,c:s,normal:new T,materialIndex:0};Nr.getNormal(Rm,Bm,Nm,l.normal),a.face=l,a.faceIndex=n}return a}function Z0(r,e,t,n,i){let s=n*3,o=r.index.getX(s),a=r.index.getX(s+1),l=r.index.getX(s+2),u=NV(t,r.attributes.position,r.attributes.uv,o,a,l,e);return u?(u.faceIndex=n,i&&i.push(u),u):null}function mM(r,e,t,n,i,s){for(let o=n,a=n+i;o<a;o++)Z0(r,e,t,o,s)}function gM(r,e,t,n,i){let s=1/0,o=null;for(let a=n,l=n+i;a<l;a++){let u=Z0(r,e,t,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function K0(r,e,t){return r===null||(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r.distance<t.near||r.distance>t.far)?null:r}function ui(r,e,t,n){let i=r.a,s=r.b,o=r.c,a=e,l=e+1,u=e+2;t&&(a=t.getX(e),l=t.getX(e+1),u=t.getX(e+2)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function J0(r,e,t,n,i,s,o){let a=t.index,l=t.attributes.position;for(let u=r,c=e+r;u<c;u++)if(ui(o,u*3,a,l),o.needsUpdate=!0,n(o,u,i,s))return!0;return!1}var Hc=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function Js(r,e){return e[r+15]===65535}function Ya(r,e){return e[r+6]}function Wc(r,e){return e[r+14]}function jc(r){return r+8}function qc(r,e){return e[r+6]}function vM(r,e){return e[r+7]}var Xc=new Lt,km=new T,kV=["x","y","z"];function Um(r,e,t,n,i){let s=r*2,o=Yc,a=Go,l=zo;if(Js(s,a)){let c=Ya(r,l),h=Wc(s,a);mM(e,t,n,c,h,i)}else{let c=jc(r);zm(c,o,n,km)&&Um(c,e,t,n,i);let h=qc(r,l);zm(h,o,n,km)&&Um(h,e,t,n,i)}}function Gm(r,e,t,n){let i=r*2,s=Yc,o=Go,a=zo;if(Js(i,o)){let u=Ya(r,a),c=Wc(i,o);return gM(e,t,n,u,c)}else{let u=vM(r,a),c=kV[u],f=n.direction[c]>=0,d,m;f?(d=jc(r),m=qc(r,a)):(d=qc(r,a),m=jc(r));let g=zm(d,s,n,km)?Gm(d,e,t,n):null;if(g){let b=g.point[c];if(f?b<=s[m+u]:b>=s[m+u+3])return g}let y=zm(m,s,n,km)?Gm(m,e,t,n):null;return g&&y?g.distance<=y.distance?g:y:g||y||null}}var yM=function(){let r,e,t=[],n=new Hc(()=>new Lt);return function(...o){r=n.getPrimitive(),e=n.getPrimitive(),t.push(r,e);let a=i(...o);n.releasePrimitive(r),n.releasePrimitive(e),t.pop(),t.pop();let l=t.length;return l>0&&(e=t[l-1],r=t[l-2]),a};function i(s,o,a,l,u=null,c=0,h=0){function f(b){let S=b*2,w=Go,A=zo;for(;!Js(S,w);)b=jc(b),S=b*2;return Ya(b,A)}function d(b){let S=b*2,w=Go,A=zo;for(;!Js(S,w);)b=qc(b,A),S=b*2;return Ya(b,A)+Wc(S,w)}let m=s*2,p=Yc,g=Go,v=zo;if(Js(m,g)){let b=Ya(s,v),S=Wc(m,g);return ci(s,p,r),l(b,S,!1,h,c+s,r)}else{let b=jc(s),S=qc(s,v),w=b,A=S,_,x,M,E;if(u&&(M=r,E=e,ci(w,p,M),ci(A,p,E),_=u(M),x=u(E),x<_)){w=S,A=b;let U=_;_=x,x=U,M=E}M||(M=r,ci(w,p,M));let C=Js(w*2,g),P=a(M,C,_,h+1,c+w),L;if(P===2){let U=f(w),F=d(w)-U;L=l(U,F,!0,h+1,c+w,M)}else L=P&&i(w,o,a,l,u,c,h+1);if(L)return!0;E=e,ci(A,p,E);let D=Js(A*2,g),R=a(E,D,x,h+1,c+A),N;if(R===2){let U=f(A),F=d(A)-U;N=l(U,F,!0,h+1,c+A,E)}else N=R&&i(A,o,a,l,u,c,h+1);return!!N}}}(),xM=function(){let r=new Dn,e=new Dn,t=new we,n=new In,i=new In;return function s(o,a,l,u,c=null){let h=o*2,f=Yc,d=Go,m=zo;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),Js(h,d)){let g=a,v=g.index,y=g.attributes.position,b=l.index,S=l.attributes.position,w=Ya(o,m),A=Wc(h,d);if(t.copy(u).invert(),l.boundsTree)return ci(o,f,i),i.matrix.copy(t),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:x=>i.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(u),x.b.applyMatrix4(u),x.c.applyMatrix4(u),x.needsUpdate=!0;for(let M=w*3,E=(A+w)*3;M<E;M+=3)if(ui(e,M,v,y),e.needsUpdate=!0,x.intersectsTriangle(e))return!0;return!1}});for(let _=w*3,x=A+w*3;_<x;_+=3){ui(r,_,v,y),r.a.applyMatrix4(t),r.b.applyMatrix4(t),r.c.applyMatrix4(t),r.needsUpdate=!0;for(let M=0,E=b.count;M<E;M+=3)if(ui(e,M,b,S),e.needsUpdate=!0,r.intersectsTriangle(e))return!0}}else{let g=o+8,v=m[o+6];return ci(g,f,Xc),!!(c.intersectsBox(Xc)&&s(g,a,l,u,c)||(ci(v,f,Xc),c.intersectsBox(Xc)&&s(v,a,l,u,c)))}}}();function zm(r,e,t,n){return ci(r,e,Xc),t.intersectBox(Xc,n)}var $0=[],Fm,Yc,Go,zo;function Qc(r){Fm&&$0.push(Fm),Fm=r,Yc=new Float32Array(r),Go=new Uint16Array(r),zo=new Uint32Array(r)}function tf(){Fm=null,Yc=null,Go=null,zo=null,$0.length&&Qc($0.pop())}var ex=Symbol("skip tree generation"),tx=new Lt,rx=new Lt,Zc=new we,Qa=new In,rf=new In,nf=new T,Vm=new T,UV=new T,GV=new T,zV=new T,bM=new Lt,os=new Hc(()=>new Dn),sr=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),sr.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let n=e.geometry,i=e._roots,s=n.getIndex(),o;return t.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(e,t,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),sr.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:i,roots:s}=e,o=new sr(t,{...n,[ex]:!0});if(o._roots=s,n.setIndex){let a=t.getIndex();if(a===null){let l=new We(e.index,1,!1);t.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[ex]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[ex]||(this._roots=cM(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Lt))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,n=t.index.array,i=t.attributes.position,s=i.array,o=i.offset||0,a=3;i.isInterleavedBufferAttribute&&(a=i.data.stride);let l,u,c,h,f=0,d=this._roots;for(let p=0,g=d.length;p<g;p++)l=d[p],u=new Uint32Array(l),c=new Uint16Array(l),h=new Float32Array(l),m(0,f),f+=l.byteLength;function m(p,g,v=!1){let y=p*2;if(c[y+15]===65535){let S=u[p+6],w=c[y+14],A=1/0,_=1/0,x=1/0,M=-1/0,E=-1/0,C=-1/0;for(let P=3*S,L=3*(S+w);P<L;P++){let D=n[P]*a+o,R=s[D+0],N=s[D+1],U=s[D+2];R<A&&(A=R),R>M&&(M=R),N<_&&(_=N),N>E&&(E=N),U<x&&(x=U),U>C&&(C=U)}return h[p+0]!==A||h[p+1]!==_||h[p+2]!==x||h[p+3]!==M||h[p+4]!==E||h[p+5]!==C?(h[p+0]=A,h[p+1]=_,h[p+2]=x,h[p+3]=M,h[p+4]=E,h[p+5]=C,!0):!1}else{let S=p+8,w=u[p+6],A=S+g,_=w+g,x=v,M=!1,E=!1;e?x||(M=e.has(A),E=e.has(_),x=!M&&!E):(M=!0,E=!0);let C=x||M,P=x||E,L=!1;C&&(L=m(S,g,x));let D=!1;P&&(D=m(w,g,x));let R=L||D;if(R)for(let N=0;N<3;N++){let U=S+N,X=w+N,F=h[U],G=h[U+3],j=h[X],z=h[X+3];h[p+N]=F<j?F:j,h[p+N+3]=G>z?G:z}return R}}}traverse(e,t=0){let n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let h=i[a+6],f=s[u+14];e(l,c,new Float32Array(n,a*4,6),h,f)}else{let h=a+32/4,f=i[a+6],d=i[a+7];e(l,c,new Float32Array(n,a*4,6),d)||(o(h,l+1),o(f,l+1))}}}raycast(e,t=ti){let n=this._roots,i=this.geometry,s=[],o=t.isMaterial,a=Array.isArray(t),l=i.groups,u=o?t.side:t;for(let c=0,h=n.length;c<h;c++){let f=a?t[l[c].materialIndex].side:u,d=s.length;if(Qc(n[c]),Um(0,i,f,e,s),tf(),a){let m=l[c].materialIndex;for(let p=d,g=s.length;p<g;p++)s[p].face.materialIndex=m}}return s}raycastFirst(e,t=ti){let n=this._roots,i=this.geometry,s=t.isMaterial,o=Array.isArray(t),a=null,l=i.groups,u=s?t.side:t;for(let c=0,h=n.length;c<h;c++){let f=o?t[l[c].materialIndex].side:u;Qc(n[c]);let d=Gm(0,i,f,e);tf(),d!=null&&(a==null||d.distance<a.distance)&&(a=d,o&&(d.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(e,t){let n=this.geometry,i=!1;for(let s of this._roots)if(Qc(s),i=xM(0,n,e,t),tf(),i)break;return i}shapecast(e,t,n){let i=this.geometry;if(e instanceof Function){if(t){let f=t;t=(d,m,p,g)=>{let v=m*3;return f(d,v,v+1,v+2,p,g)}}e={boundsTraverseOrder:n,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=os.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=e;if(l&&u){let f=l;l=(d,m,p,g,v)=>f(d,m,p,g,v)?!0:J0(d,m,i,u,p,g,s)}else l||(u?l=(f,d,m,p)=>J0(f,d,i,u,m,p,s):l=(f,d,m)=>m);let c=!1,h=0;for(let f of this._roots){if(Qc(f),c=yM(0,i,a,l,o,h),tf(),c)break;h+=f.byteLength}return os.releasePrimitive(s),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=e.geometry.index,u=e.geometry.attributes.position;Zc.copy(t).invert();let c=os.getPrimitive(),h=os.getPrimitive();if(s){let d=function(m,p,g,v,y,b,S,w){for(let A=g,_=g+v;A<_;A++){ui(h,A*3,l,u),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let x=m,M=m+p;x<M;x++)if(ui(c,x*3,o,a),c.needsUpdate=!0,s(c,h,x,A,y,b,S,w))return!0}return!1};if(i){let m=i;i=function(p,g,v,y,b,S,w,A){return m(p,g,v,y,b,S,w,A)?!0:d(p,g,v,y,b,S,w,A)}}else i=d}e.getBoundingBox(rx),rx.applyMatrix4(t);let f=this.shapecast({intersectsBounds:d=>rx.intersectsBox(d),intersectsRange:(d,m,p,g,v,y)=>(tx.copy(y),tx.applyMatrix4(Zc),e.shapecast({intersectsBounds:b=>tx.intersectsBox(b),intersectsRange:(b,S,w,A,_)=>i(d,m,b,S,g,v,A,_)}))});return os.releasePrimitive(c),os.releasePrimitive(h),f}intersectsBox(e,t){return Qa.set(e.min,e.max,t),Qa.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Qa.intersectsBox(n),intersectsTriangle:n=>Qa.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Qa.set(e.boundingBox.min,e.boundingBox.max,t),Qa.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=e.attributes.position,h=e.index,f=os.getPrimitive(),d=os.getPrimitive(),m=Vm,p=UV,g=null,v=null;i&&(g=GV,v=zV);let y=1/0,b=null,S=null;return Zc.copy(t).invert(),rf.matrix.copy(Zc),this.shapecast({boundsTraverseOrder:w=>Qa.distanceToBox(w),intersectsBounds:(w,A,_)=>_<y&&_<o?(A&&(rf.min.copy(w.min),rf.max.copy(w.max),rf.needsUpdate=!0),!0):!1,intersectsRange:(w,A)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:_=>rf.distanceToBox(_),intersectsBounds:(_,x,M)=>M<y&&M<o,intersectsRange:(_,x)=>{for(let M=_*3,E=(_+x)*3;M<E;M+=3){ui(d,M,h,c),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let C=w*3,P=(w+A)*3;C<P;C+=3){ui(f,C,u,l),f.needsUpdate=!0;let L=f.distanceToTriangle(d,m,g);if(L<y&&(p.copy(m),v&&v.copy(g),y=L,b=C/3,S=M/3),L<s)return!0}}}});{let _=h?h.count:c.count;for(let x=0,M=_;x<M;x+=3){ui(d,x,h,c),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let E=w*3,C=(w+A)*3;E<C;E+=3){ui(f,E,u,l),f.needsUpdate=!0;let P=f.distanceToTriangle(d,m,g);if(P<y&&(p.copy(m),v&&v.copy(g),y=P,b=E/3,S=x/3),P<s)return!0}}}}}),os.releasePrimitive(f),os.releasePrimitive(d),y===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=y,n.faceIndex=b,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(Zc),p.applyMatrix4(Zc),i.distance=p.sub(i.point).length(),i.faceIndex=S),n)}closestPointToPoint(e,t={},n=0,i=1/0){let s=n*n,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(nf.copy(e).clamp(c.min,c.max),nf.distanceToSquared(e)),intersectsBounds:(c,h,f)=>f<a&&f<o,intersectsTriangle:(c,h)=>{c.closestPointToPoint(e,nf);let f=e.distanceToSquared(nf);return f<a&&(Vm.copy(nf),a=f,l=h),f<s}}),a===1/0)return null;let u=Math.sqrt(a);return t.point?t.point.copy(Vm):t.point=Vm.clone(),t.distance=u,t.faceIndex=l,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{ci(0,new Float32Array(n),bM),e.union(bM)}),e}},SM=sr.prototype.raycast;sr.prototype.raycast=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[e,t,n,i]=r;return SM.call(this,n,e.material).forEach(o=>{o=K0(o,e,t),o&&i.push(o)}),i}else return SM.apply(this,r)};var wM=sr.prototype.raycastFirst;sr.prototype.raycastFirst=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[e,t,n]=r;return K0(wM.call(this,n,e.material),e,t)}else return wM.apply(this,r)};var AM=sr.prototype.closestPointToPoint;sr.prototype.closestPointToPoint=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),r.unshift();let e=r[1],t={};return r[1]=t,AM.apply(this,r),e&&e.copy(t.point),t.distance}else return AM.apply(this,r)};var TM=sr.prototype.closestPointToGeometry;sr.prototype.closestPointToGeometry=function(...r){let e=r[2],t=r[3];if(e&&e.isVector3||t&&t.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let n={},i={},s=r[1];return r[2]=n,r[3]=i,TM.apply(this,r),e&&e.copy(n.point),t&&t.copy(i.point).applyMatrix4(s),n.distance}else return TM.apply(this,r)};var _M=sr.prototype.refit;sr.prototype.refit=function(...r){let e=r[0],t=r[1];if(t&&(t instanceof Set||Array.isArray(t))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let n=new Set;t.forEach(i=>n.add(i)),e&&e.forEach(i=>n.add(i)),_M.call(this,n)}else _M.apply(this,r)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(r=>{let e=sr.prototype[r];sr.prototype[r]=function(...t){return(t[0]===null||t[0].isMesh)&&(t.shift(),console.warn(`MeshBVH: The function signature for "${r}" has changed and no longer takes Mesh. See docs for new signature.`)),e.apply(this,t)}});var nx=class extends yt{},Hm=class extends nx{constructor(t){super();this.object=t;this.matrixAutoUpdate=!0}get castShadow(){return this.object.castShadow}set castShadow(t){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(t){}get isMesh(){return!0}get isLight(){return!1}get layers(){return this.object.layers}set layers(t){}get isCamera(){return!1}get geometry(){return this.object.geometry}get material(){return this.object.material}};var sf=class extends yt{constructor(t,n={}){super();this.object=t;let i=t.recursiveBBox.getSize(new T),s=.1;this.parameters=vm.defaultData(i.toArray(),s),Ba(this.parameters,n),this.update(),this.setHideBase(this.parameters.hideBase)}setHideBase(t){this.parameters.hideBase=t}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let n=0,i=t-this.children.length;n<i;++n){let s=new Hm(this.object);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let n=0,i=this.children.length-t;n<i;++n)this.remove(this.children[0])}_updateRadial(t){let n=t.radial,i=n.start*ze.DEG2RAD,s=n.end*ze.DEG2RAD,o=i-s,a=new tr(n.rotation[0]*ze.DEG2RAD,n.rotation[1]*ze.DEG2RAD,n.rotation[2]*ze.DEG2RAD),l;switch(n.axis){case"z":l=new T(0,0,1);break;case"y":l=new T(0,1,0);break;default:case"x":l=new T(1,0,0);break}for(let[u,c]of this.children.entries()){c.scale.x=n.scale[0],c.scale.y=n.scale[1],c.scale.z=n.scale[2],c.position.setScalar(0);let h=o/t.count*u-i;switch(n.axis){case"x":c.rotation.set(0,h,0);break;case"y":c.rotation.set(0,0,h);break;case"z":c.rotation.set(h,0,0);break}c.translateOnAxis(l,n.radius),c.position.x+=n.position[0],c.position.y+=n.position[1],c.position.z+=n.position[2],n.alignment===!0?(c.rotation.x+=a.x,c.rotation.y+=a.y,c.rotation.z+=a.z):c.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let n=t.linear,i=new tr(n.rotation[0]*ze.DEG2RAD,n.rotation[1]*ze.DEG2RAD,n.rotation[2]*ze.DEG2RAD);for(let[s,o]of this.children.entries())o.scale.x=1+(n.scale[0]-1)*s,o.scale.y=1+(n.scale[1]-1)*s,o.scale.z=1+(n.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=n.position[0]*s,o.position.y=n.position[1]*s,o.position.z=n.position[2]*s}_updateGrid(t){let n=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new T(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let u=0;u<i.count[2];u++){let c=this.children[n++];c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=i.size[0]*a-o.x,c.position.y=i.size[1]*l-o.y,c.position.z=i.size[2]*u-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[n++];l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),Ba(this.parameters,t),this.update(),this}};var as=r=>{var e;return e=class extends r{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new Tn(30,30,30),e};var Wm=new Ti,ix=new Fr,MM=new we,ls=(r,e,t,n,i=!1)=>{let s=e,o=r.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),ix.copy(s.boundingSphere),ix.applyMatrix4(o),t.ray.intersectsSphere(ix)===!1||(MM.copy(o).invert(),Wm.copy(t.ray).applyMatrix4(MM),s.boundingBox!==null&&Wm.intersectsBox(s.boundingBox)===!1))return;let a,l,u,c,h=s.index,f=s.attributes.position,d=s.drawRange,m,p;if(i===!1){let v=Math.max(0,d.start),y=Math.min(h.count,d.start+d.count);for(m=v,p=y;m<p;m+=3)if(l=h.getX(m),u=h.getX(m+1),c=h.getX(m+2),a=g(r,t,Wm,f,l,u,c),a){a.faceIndex=Math.floor(m/3),n.push(a);return}}else{let y=s.attributes.position,b=new T,S=new T,w=new T,A=new T,_=2,M=1/((r.scale.x+r.scale.y+r.scale.z)/3),E=M*M,C=Math.max(0,d.start),P=Math.min(y.count,d.start+d.count);for(let L=C,D=P-1;L<D;L+=_){if(b.fromBufferAttribute(y,L),S.fromBufferAttribute(y,L+1),Wm.distanceSqToSegment(b,S,A,w)>E)continue;A.applyMatrix4(r.matrixWorld);let N=t.ray.origin.distanceTo(A);N<t.near||N>t.far||n.push({distance:N,point:w.clone().applyMatrix4(r.matrixWorld),object:r})}}function g(v,y,b,S,w,A,_){let x=new T,M=new T,E=new T,C=new T,P=new T;if(x.fromBufferAttribute(S,w),M.fromBufferAttribute(S,A),E.fromBufferAttribute(S,_),b.intersectTriangle(x,M,E,!1,C)===null)return null;P.copy(C),P.applyMatrix4(v.matrixWorld);let D=y.ray.origin.distanceTo(P);return D<y.near||D>y.far?null:{faceIndex:1,distance:D,point:P.clone(),object:v}}};var jm=new T,hi=new _i,sx=class extends So{constructor(t){let n=new Le,i=new ri({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Be(15711266),u=new Be(15711266),c=new Be(2857471);h("n1","n2",l),h("n2","n4",l),h("n4","n3",l),h("n3","n1",l),h("f1","f2",l),h("f2","f4",l),h("f4","f3",l),h("f3","f1",l),h("n1","f1",l),h("n2","f2",l),h("n3","f3",l),h("n4","f4",l),h("p","n1",u),h("p","n2",u),h("p","n3",u),h("p","n4",u),h("u1","u2",c),h("u2","u3",c),h("u3","u1",c);function h(d,m,p){f(d,p),f(m,p)}function f(d,m){s.push(0,0,0),o.push(m.r,m.g,m.b),a[d]===void 0&&(a[d]=[]),a[d].push(s.length/3-1)}n.setAttribute("position",new Te(s,3)),n.setAttribute("color",new Te(o,3));super(n,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,n=this.pointMap,i=!0;hi.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;Di("n1",n,t,hi,-s,-o,a),Di("n2",n,t,hi,s,-o,a),Di("n3",n,t,hi,-s,o,a),Di("n4",n,t,hi,s,o,a);let l=a;Di("f1",n,t,hi,-s,-o,l),Di("f2",n,t,hi,s,-o,l),Di("f3",n,t,hi,-s,o,l),Di("f4",n,t,hi,s,o,l);let u=l,c=.5;Di("u1",n,t,hi,s*.7*c,o*1.1,u),Di("u2",n,t,hi,-s*.7*c,o*1.1,u),Di("u3",n,t,hi,0,o*(1.1+.9*c),u),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Di(r,e,t,n,i,s,o){jm.set(i,s,o).unproject(n);let a=e[r];if(a!==void 0){let l=t.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],jm.x,jm.y,jm.z)}}var qm=class extends as(sx){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,n){ls(this.object,this.geometry,t,n,!0)}};var Kc=class extends as(vp){constructor(t,n=15,i=10066329){super(t,n,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,n){ls(this.object,Kc.geometryHelper,t,n)}};var Jc=class extends as(yp){constructor(t,n=15){super(n);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,n){ls(this.object,Jc.geometryHelper,t,n)}update(){}};var $c=class extends as(gp){constructor(t,n=15,i=6710886){super(t,n,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,n){ls(this.object,$c.geometryHelper,t,n)}};var Xm=class extends as(mp){constructor(t,n=6710886){super(t,n);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,n){ls(this.object,Xm.geometryHelper,t,n)}update(){if(this.object!==void 0){let t=Xm._vector,n=this.object.distance?this.object.distance:1e3,i=n*Math.tan(this.object.angle);this.cone.scale.set(i,i,n),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},of=Xm;of._vector=new T;var af=1e-12,eu=class{constructor(e){this.position=new k;this.startPosition=new k;this.uuid=ze.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new eu(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},tu=class extends eu{constructor(t){super(t.position);this.parent=t}copy(t){return super.copy(t),this}clone(){return new tu(this.parent).copy(this)}},Ii=class extends eu{constructor(t,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=t,this.controls.push(new tu(this),new tu(this))}static create(t,n){let i=new Ii(t,new k(...n.position));return i.controls[0].position.set(...n.controlPrevious.position),i.controls[1].position.set(...n.controlNext.position),i.roundness=n.roundness,i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,i}getOppositeControl(t){let n=this.controls.indexOf(t);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(t,n=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new Ii(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),n=this.curveAfter?.getTangentAt(0);return[t,n]}computeNormals(t=new k,n=new k){let[i,s]=this.computeTangents();return i&&s&&(EM(i,t),EM(s,n)),[t,n]}computeTangent(t=new k){let[n,i]=this.computeTangents();return n&&i&&t.copy(n).add(i).normalize(),t}computeNormal(t=new k){let[n,i]=this.computeNormals();return t.copy(n).add(i).normalize(),t}};function EM(r,e=new k){let t=r.length();return e.set(-r.y/t,r.x/t)}var ax=r=>r,ru=new k,Ym=new k,HV=new k,WV=new k,jV=new k,qV=new k,PM=new T,DM=new T;function IM(r){let e=new k;e.addVectors(r.v0,ru.subVectors(r.v1,r.v0).multiplyScalar(2/3));let t=new k;return t.addVectors(r.v2,Ym.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new tn(r.v0,e,t,r.v2)}function lf(r,e,t=Number.EPSILON){return Math.abs(r-e)<t}function XV(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function YV(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function lx(r,e,t){let n=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2));return Math.acos((i*i+n*n-s*s)/(2*i*n))}function LM(r,e,t){return CM(r,e)&&CM(e,t)&&ox(r.position,e.position,t.position)}function ox(r,e,t){return ru.copy(e).sub(r).cross(Ym.copy(t).sub(r))===0}function OM(r,e,t,n,i){let s=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),o=(r.y+e.y)/2,a=(r.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(r.y-e.y)/s,u=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-r.x)/s;return n.set(a+l,o+u),i.set(a-l,o-u),[n,i]}function RM(r,e,t){let n=r.distanceTo(t),i=e.distanceTo(t);return n<i?e:r}function BM(r,e,t,n,i,s){let o=e.x-r.x,a=e.y-r.y,l=t.x-r.x,u=t.y-r.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),h;return lx(e,r,t)>Math.PI&&(c*=-1),lf(u,a)?h=(a+u)*(n/c-.5)*8/3/(o-l):h=(o+l)*(n/c-.5)*8/3/(u-a),i.set(e.x-h*a,e.y+h*o),s.set(t.x+h*u,t.y-h*l),[i,s]}function cx(r,e){return r.position.equals(r.controls[1].position)&&e.position.equals(e.controls[0].position)}function CM(r,e){return ox(r.position,r.controls[1].position,e.position)&&ox(r.position,e.controls[0].position,e.position)}function NM(r,e,t,n,i=.5){let s=ru.subVectors(e,r).multiplyScalar(i).add(r),o=Ym.subVectors(t,e).multiplyScalar(i).add(e),a=HV.subVectors(n,t).multiplyScalar(i).add(t),l=s,u=WV.subVectors(o,s).multiplyScalar(i).add(s),c=jV.subVectors(a,o).multiplyScalar(i).add(o),h=a,f=qV.subVectors(c,u).multiplyScalar(i).add(u);return[r.x,r.y,l.x,l.y,u.x,u.y,f.x,f.y,c.x,c.y,h.x,h.y,n.x,n.y]}function FM(r,e,t=12,n=!0){let i=DM.set(0,0,0),s,o=0,a=[];for(let l=0;l<e.length;l++){let u=ax(e[l]),c=ru,h=Vo(u,t);a.push(h);for(let f=0;f<=h;f++)if(u instanceof tn||u instanceof zn||u instanceof rn){if(u.getPoint(f/h,c),i.set(c.x,c.y,0),s!==void 0&&YV(s,i))continue;s===void 0&&(s=PM),s.copy(i),r.setXYZ(o,i.x,i.y,i.z),o++}}return n&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function kM(r,e,t,n=12,i=!0){let s=DM.set(0,0,0),o=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let u,c=ax(e[l]),h=ru,f=Vo(c,n);a.push(f);for(let d=0;d<=f;d++)if(c instanceof tn||c instanceof zn||c instanceof rn){if(c.getPoint(d/f,h),s.set(h.x,h.y,0),u?.equals(s))continue;u===void 0?u=PM:(r.setXYZ(o,u.x,u.y,u.z),o++,r.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return i&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function ux(r,e=12,t=!1){let n=[];for(let i=0,s=r.length;i<s;i++){let o=r[i],a=0;if(t&&o.roundedCurveCorner!==void 0){let l=Vo(o.roundedCurveCorner,e)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Vo(o.curveAfter,e)),n.push(a)}return r.length>0&&t&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=Vo(r[0].roundedCurveCorner,e)*.5),n}function Vo(r,e=12){return r&&r instanceof Ta?e*2:r&&(r instanceof rn||r instanceof yh)?1:r&&r instanceof Ul?e*r.points.length:e}function UM(r,e,t=12,n=!0){let i,s=0;for(let o=0;o<e.length;o++){let a=ax(e[o]),l=Vo(a,t),u=ru;for(let c=0;c<=l;c++)if(a instanceof tn||a instanceof zn||a instanceof rn){if(a.getPoint(c/l,u),i!==void 0&&XV(i,u,af))continue;i===void 0&&(i=Ym),i.copy(u),r.push(u.x,u.y),s++}}return lf(r[0],r[r.length-2],af)&&lf(r[1],r[r.length-1],af)&&(r.pop(),r.pop()),n&&s>1&&!(lf(r[s-1],r[1],af)&&lf(r[s-2],r[0],af))&&(r.push(r[0],r[1]),s++),r}var hx=new k,QV=new k,ZV=new k,KV=new k,JV=new k,$V=new k,At=class extends Vs{constructor(t=100,n=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new kt;this.plane=new Tr(new T(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=ze.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=t,this._height=n}static createFromState(t,n,i){let s=new At;return s.isClosed=t.isClosed,s.points=t.points.map(o=>Ii.create(o.id,o.data)),typeof t.roundness=="number"&&(s.roundness=t.roundness),s.shapeHoles=t.shapeHoles.map(o=>At.createFromState(o)),n!==void 0&&i!==void 0&&s.applySize(n,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let n=0,i=this.points.length;n<i;n++)this.points[n].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(t){let n=this.points.length,i=this.points.findIndex(s=>s.uuid===t);if(i<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(t);if(c<0)s+=u;else return c+s}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0){let n=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=t-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let n=this.points.indexOf(t);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(t);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...t]}applySize(t,n){t===0&&(t=.001),n===0&&(n=.001),this._width=t,this._height=n}applyScale(t,n){let i=hx.set(t,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(t,n);this._update(!1)}createPoint(t,n=0,i=ze.generateUUID()){let s;t instanceof k?s=t:s=new k(t,n);let o=new Ii(i,s);return o.roundness=this.roundness,o}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,n){this.points.splice(n,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(s.uuid===t)return s}for(let n=0,i=this.shapeHoles.length;n<i;n++){let o=this.shapeHoles[n].getPointByUuid(t);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let n=this.points.indexOf(t);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(t){let n=this.points.find(i=>i.uuid===t);n&&this.removePoint(n)}update(t=!0){for(let n=0,i=this.shapeHoles.length;n<i;n++)this.shapeHoles[n].update(!1);this._update(t)}extractShapePointsToBuffer(t,n=12,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return FM(t,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=ux(this.points,t,!1),this.roundedCurveDivisions=ux(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,n,i=12){return kM(t,this.curves,n,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(t,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),UM(t,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(t,n=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=Vo(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=t-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<i+c)return[l,(a-i+1)/c];i+=c}return[0,1]}getCurveT(t,n,i){let s=this.points[t],o=this.points[t>=this.points.length-1?0:t+1],a=this.curveDivisions,l=a[t];if(cx(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(hx.set(i.x,i.y))/h}let u=0;for(let h=0;h<t;h++)u+=a[h];return(n-u)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(t,n){cx(n,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,n.curveAfter=i;let s=i.clone();t.roundedCurveBefore=s,n.roundedCurveAfter=s,t.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(t=!0){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i];if(i===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[i-1];this._applyCurveForPoint(o,a)}}let n=this.getLastPoint();if(n?.curveAfter&&(n.curveAfter=void 0),this.isClosed){let i=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(i,s)}if(this.points.length>2){let i=0;for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s],l=this.points[s-1]??this.points[this.points.length-1],u=this.points[s+1]??this.points[0],c=a.roundness,h=l&&u&&LM(l,a,u);if(!a.controlsMoved()&&c>0&&!h){let f=a.curveBefore,d=a.curveAfter;if(f===void 0||d===void 0)continue;let m=a.roundedCurveBefore,p=a.roundedCurveAfter,g=f.getLength(),v=d.getLength(),y=Math.min(c,g*.499),b=Math.min(c,v*.499),S=Math.min(y,b),w=1-S/g,A=S/v,_=f.getPointAt(w,hx),x=d.getPointAt(A,QV);this._subSplitCurve(f,m,w,_,void 0),this._subSplitCurve(d,p,A,void 0,x);let M;if(this.useCubicForRoundedCorners){let E=lx(_,a.position,x)/2,C=Math.tan(E)*_.distanceTo(a.position),[P,L]=OM(_,x,C,ZV,KV),D=RM(P,L,a.position),[R,N]=BM(D,_,x,C,JV,$V);M=new tn(_.clone(),R.clone(),N.clone(),x.clone())}else M=new zn(_.clone(),a.position.clone(),x.clone());a.roundedCurveCorner=M,this.roundedCurves.splice(s+i,0,M),i++}}}t&&this.eventDispatcher?.dispatchEvent({type:"update"})}_subSplitCurve(t,n,i,s,o){if(t instanceof rn)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=t,l=n,u=a.getUtoTmapping(i,0),c=NM(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return n}clone(){let t=new At(this._width,this._height);return t.points=this.points.map(n=>n.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(n=>n.clone()),t}toJSON(){return{points:this.points.reduce((t,n)=>t.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let n=t.points.length/7;for(let i=0;i<n;i++){let s=i*7,o=t.points[s+0],a=t.points[s+1],l=t.points[s+2],u=t.points[s+3],c=t.points[s+4],h=t.points[s+5],f=t.points[s+6],d=new Ii(ze.generateUUID(),new k(o,a));d.controls[0].position.set(l,u),d.controls[1].position.set(c,h),d.roundness=f,this.points.push(d)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let s=new At;return s.fromJSON(i),s}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t){let n=(s,o)=>{o instanceof tn&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof zn&&(s[a]=IM(s[a]));for(a=0,l=s.length;a<l;a++){let h=s[a],f=a>0?s[a-1]:null,d;h instanceof tn?(d=this.createPoint(h.v0),d.controls[1].position.copy(h.v1)):h instanceof rn&&(d=this.createPoint(h.v1)),d!==void 0&&(f!==null&&n(d,f),o.push(d))}let u=s[s.length-1],c=!1;return u instanceof tn?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof rn&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=i(t.curves),t instanceof Vs&&(this.shapeHoles=t.holes.map(s=>{let o=new At;return o.fromShape(s),o})),this.update(),this}};var Ft;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Ft||(Ft={}));var Cr;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Cr||(Cr={}));function Ye(r,e){if(!r)throw e||"Assertion Failed!"}var je=function(){function r(){}return r.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},r.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},r.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},r.edgeGoesLeft=function(e){return r.vertLeq(e.Dst,e.Org)},r.edgeGoesRight=function(e){return r.vertLeq(e.Org,e.Dst)},r.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},r.edgeEval=function(e,t,n){Ye(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?i<s?t.t-e.t+(e.t-n.t)*(i/(i+s)):t.t-n.t+(n.t-e.t)*(s/(i+s)):0},r.edgeSign=function(e,t,n){Ye(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?(t.t-n.t)*i+(t.t-e.t)*s:0},r.transEval=function(e,t,n){Ye(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?i<s?t.s-e.s+(e.s-n.s)*(i/(i+s)):t.s-n.s+(n.s-e.s)*(s/(i+s)):0},r.transSign=function(e,t,n){Ye(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?(t.s-n.s)*i+(t.s-e.s)*s:0},r.vertCCW=function(e,t,n){return e.s*(t.t-n.t)+t.s*(n.t-e.t)+n.s*(e.t-t.t)>=0},r.interpolate=function(e,t,n,i){return e=e<0?0:e,n=n<0?0:n,e<=n?n===0?(t+i)/2:t+(i-t)*(e/(e+n)):i+(t-i)*(n/(e+n))},r.intersect=function(e,t,n,i,s){var o,a,l;r.vertLeq(e,t)||(l=e,e=t,t=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.vertLeq(n,t)?r.vertLeq(t,i)?(o=r.edgeEval(e,n,t),a=r.edgeEval(n,t,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,t.s)):(o=r.edgeSign(e,n,t),a=-r.edgeSign(e,i,t),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+t.s)/2,r.transLeq(e,t)||(l=e,e=t,t=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.transLeq(n,t)?r.transLeq(t,i)?(o=r.transEval(e,n,t),a=r.transEval(n,t,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,t.t)):(o=r.transSign(e,n,t),a=-r.transSign(e,i,t),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+t.t)/2},r}(),cf=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),Qm=function(){function r(e){this.side=e,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),r}(),nu=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return r}(),GM=function(){function r(){var e=new nu,t=new cf,n=new Qm(0),i=new Qm(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=e,this.fHead=t,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(e){var t=new Qm(0),n=new Qm(1);e.Sym.side<e.side&&(e=e.Sym);var i=e.Sym.next;return n.next=i,i.Sym.next=t,t.next=e,e.Sym.next=n,t.Sym=n,t.Onext=t,t.Lnext=n,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,n.Sym=t,n.Onext=n,n.Lnext=t,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,t},r.prototype.splice_=function(e,t){var n=e.Onext,i=t.Onext;n.Sym.Lnext=t,i.Sym.Lnext=e,e.Onext=i,t.Onext=n},r.prototype.makeVertex_=function(e,t,n){var i=e;Ye(i,"Vertex can't be null!");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t;var o=t;do o.Org=i,o=o.Onext;while(o!==t)},r.prototype.makeFace_=function(e,t,n){var i=e;Ye(i,"Face can't be null");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t,i.trail=null,i.marked=!1,i.inside=n.inside;var o=t;do o.Lface=i,o=o.Lnext;while(o!==t)},r.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,n=e.Sym.next;t.Sym.next=n,n.Sym.next=t},r.prototype.killVertex_=function(e,t){var n=e.anEdge,i=n;do i.Org=t,i=i.Onext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.killFace_=function(e,t){var n=e.anEdge,i=n;do i.Lface=t,i=i.Lnext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.makeEdge=function(){var e=new nu,t=new nu,n=new cf,i=this.makeEdge_(this.eHead);return this.makeVertex_(e,i,this.vHead),this.makeVertex_(t,i.Sym,this.vHead),this.makeFace_(n,i,this.fHead),i},r.prototype.splice=function(e,t){var n=!1,i=!1;if(e!==t){if(t.Org!==e.Org&&(i=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!i){var s=new nu;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!n){var o=new cf;this.makeFace_(o,t,e.Lface),e.Lface.anEdge=e}}},r.prototype.delete=function(e){var t=e.Sym,n=!1;if(e.Lface!==e.Rface&&(n=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!n){var i=new cf;this.makeFace_(i,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},r.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),n=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var i=new nu;return this.makeVertex_(i,n,t.Org),t.Lface=n.Lface=e.Lface,t},r.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),n=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,n),e.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=e.Rface,n.winding=e.winding,n.Sym.winding=e.Sym.winding,n.idx=e.idx,n.Sym.idx=e.Sym.idx,n},r.prototype.connect=function(e,t){var n=!1,i=this.makeEdge_(e),s=i.Sym;if(t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(i,e.Lnext),this.splice_(s,t),i.Org=e.Dst,s.Org=t.Org,i.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!n){var o=new cf;this.makeFace_(o,i,e.Lface)}return i},r.prototype.zapFace=function(e){var t=e.anEdge,n,i,s,o,a;i=t.Lnext;do n=i,i=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=t);o=e.prev,a=e.next,a.prev=o,o.next=a},r.prototype.countFaceVerts_=function(e){var t=e.anEdge,n=0;do n++,t=t.Lnext;while(t!==e.anEdge);return n},r.prototype.mergeConvexFaces=function(e){var t,n,i,s,o,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(n=t.anEdge,o=n.Org;i=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(s.Lface),a+l-2<=e&&je.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&je.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=i;return!0},r.prototype.check=function(){var e=this.fHead,t=this.vHead,n=this.eHead,i,s,o,a,l,u;for(s=e,s=e;(i=s.next)!==e;s=i){Ye(i.prev===s),l=i.anEdge;do Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l),Ye(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(Ye(i.prev===s&&i.anEdge===null),a=t,a=t;(o=a.next)!==t;a=o){Ye(o.prev===a),l=o.anEdge;do Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l),Ye(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(Ye(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)Ye(l.Sym.next===u.Sym),Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Org!==null),Ye(l.Dst!==null),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l);Ye(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},r}(),zM=function(){function r(){this.handle=null}return r}(),VM=function(){function r(){this.key=null,this.node=0}return r}(),eH=function(){function r(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var n=0;n<e+1;n++)this.nodes[n]=new zM,this.handles[n]=new VM;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return r.prototype.floatDown_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e<<1,o<this.size&&this.leq(n[t[o+1].handle].key,n[t[o].handle].key)&&++o,Ye(o<=this.max),s=t[o].handle,o>this.size||this.leq(n[i].key,n[s].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.floatUp_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e>>1,s=t[o].handle,o===0||this.leq(n[s].key,n[i].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(e){var t,n;if(t=++this.size,t*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new zM;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new VM}return this.freeList===0?n=t:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[t].handle=n,this.handles[n].node=t,this.handles[n].key=e,this.initialized&&this.floatUp_(t),n},r.prototype.extractMin=function(){var e=this.nodes,t=this.handles,n=e[1].handle,i=t[n].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[n].key=null,t[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),i},r.prototype.delete=function(e){var t=this.nodes,n=this.handles,i;Ye(e>=1&&e<=this.max&&n[e].key!==null),i=n[e].node,t[i].handle=t[this.size].handle,n[t[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[t[i>>1].handle].key,n[t[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[e].key=null,n[e].node=this.freeList,this.freeList=e},r}(),fx=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),HM=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),tH=function(){function r(e,t){this.frame=e,this.leq=t,this.head=new HM,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(e){return this.insertBefore(this.head,e)},r.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},r.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var n=new HM;return n.key=t,n.next=e.next,e.next.prev=n,n.prev=e,e.next=n,n},r.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},r}(),rH=function(){function r(){}return r.regionBelow=function(e){return e.nodeUp.prev.key},r.regionAbove=function(e){return e.nodeUp.next.key},r.debugEvent=function(e){},r.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.edgeLeq=function(e,t,n){var i=e.event,s=t.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?je.vertLeq(s.Org,o.Org)?je.edgeSign(o.Dst,s.Org,o.Org)<=0:je.edgeSign(s.Dst,o.Org,s.Org)>=0:je.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return je.edgeSign(s.Dst,i,s.Org)>=0;var a=je.edgeEval(s.Dst,i,s.Org),l=je.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(e,t){t.fixUpperEdge&&Ye(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},r.fixUpperEdge=function(e,t,n){Ye(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=n,n.activeRegion=t},r.topLeftRegion=function(e,t){var n=t.eUp.Org,i;do t=r.regionAbove(t);while(t.eUp.Org===n);if(t.fixUpperEdge){if(i=e.mesh.connect(r.regionBelow(t).eUp.Sym,t.eUp.Lnext),i===null)return null;r.fixUpperEdge(e,t,i),t=r.regionAbove(t)}return t},r.topRightRegion=function(e){var t=e.eUp.Dst;do e=r.regionAbove(e);while(e.eUp.Dst===t);return e},r.addRegionBelow=function(e,t,n){var i=new fx;return i.eUp=n,i.nodeUp=e.dict.insertBefore(t.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(e,t){switch(e.windingRule){case Ft.ODD:return(t&1)!==0;case Ft.NONZERO:return t!==0;case Ft.POSITIVE:return t>0;case Ft.NEGATIVE:return t<0;case Ft.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(e,t){t.windingNumber=r.regionAbove(t).windingNumber+t.eUp.winding,t.inside=r.isWindingInside(e,t.windingNumber)},r.finishRegion=function(e,t){var n=t.eUp,i=n.Lface;i.inside=t.inside,i.anEdge=n,r.deleteRegion(e,t)},r.finishLeftRegions=function(e,t,n){for(var i,s=null,o=t,a=t.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(e,o);break}i=e.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(e,s,i)}a.Onext!==i&&(e.mesh.splice(i.Oprev,i),e.mesh.splice(a,i)),r.finishRegion(e,o),a=s.eUp,o=s}return a},r.addRightEdges=function(e,t,n,i,s,o){var a,l,u,c,h=!0;u=n;do Ye(je.vertLeq(u.Org,u.Dst)),r.addRegionBelow(e,t,u.Sym),u=u.Onext;while(u!==i);for(s===null&&(s=r.regionBelow(t).eUp.Rprev),l=t,c=s;a=r.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(e.mesh.splice(u.Oprev,u),e.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=r.isWindingInside(e,a.windingNumber),l.dirty=!0,!h&&r.checkForRightSplice(e,l)&&(r.addWinding(u,c),r.deleteRegion(e,l),e.mesh.delete(c)),h=!1,l=a,c=u;l.dirty=!0,Ye(l.windingNumber-u.winding===a.windingNumber),o&&r.walkDirtyRegions(e,l)},r.spliceMergeVertices=function(e,t,n){e.mesh.splice(t,n)},r.vertexWeights=function(e,t,n){var i=je.vertL1dist(t,e),s=je.vertL1dist(n,e),o=.5*s/(i+s),a=.5*i/(i+s);e.coords[0]+=o*t.coords[0]+a*n.coords[0],e.coords[1]+=o*t.coords[1]+a*n.coords[1],e.coords[2]+=o*t.coords[2]+a*n.coords[2]},r.getIntersectData=function(e,t,n,i,s,o){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,r.vertexWeights(t,n,i),r.vertexWeights(t,s,o)},r.checkForRightSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp;if(je.vertLeq(i.Org,s.Org)){if(je.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;je.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(e.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(e,s.Oprev,i)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(i,s.Oprev),t.dirty=n.dirty=!0)}else{if(je.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o;if(Ye(!je.vertEq(i.Dst,s.Dst)),je.vertLeq(i.Dst,s.Dst)){if(je.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,o=e.mesh.splitEdge(i),e.mesh.splice(s.Sym,o),o.Lface.inside=t.inside}else{if(je.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;t.dirty=n.dirty=!0,o=e.mesh.splitEdge(s),e.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=t.inside}return!0},r.checkForIntersect=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,u=s.Dst,c,h,f=new nu,d,m;if(Ye(!je.vertEq(u,l)),Ye(je.edgeSign(l,e.event,o)<=0),Ye(je.edgeSign(u,e.event,a)>=0),Ye(o!==e.event&&a!==e.event),Ye(!t.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),h=Math.max(a.t,u.t),c>h))return!1;if(je.vertLeq(o,a)){if(je.edgeSign(u,o,a)>0)return!1}else if(je.edgeSign(l,a,o)<0)return!1;return r.debugEvent(e),je.intersect(l,o,u,a,f),Ye(Math.min(o.t,l.t)<=f.t),Ye(f.t<=Math.max(a.t,u.t)),Ye(Math.min(u.s,l.s)<=f.s),Ye(f.s<=Math.max(a.s,o.s)),je.vertLeq(f,e.event)&&(f.s=e.event.s,f.t=e.event.t),d=je.vertLeq(o,a)?o:a,je.vertLeq(d,f)&&(f.s=d.s,f.t=d.t),je.vertEq(f,o)||je.vertEq(f,a)?(r.checkForRightSplice(e,t),!1):!je.vertEq(l,e.event)&&je.edgeSign(l,e.event,f)>=0||!je.vertEq(u,e.event)&&je.edgeSign(u,e.event,f)<=0?u===e.event?(e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Sym,i),t=r.topLeftRegion(e,t),i=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),n),r.addRightEdges(e,t,i.Oprev,i,i,!0),!0):l===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(i.Lnext,s.Oprev),n=t,t=r.topRightRegion(t),m=r.regionBelow(t).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(e,n,null),r.addRightEdges(e,t,s.Onext,i.Rprev,m,!0),!0):(je.edgeSign(l,e.event,f)>=0&&(r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),i.Org.s=e.event.s,i.Org.t=e.event.t),je.edgeSign(u,e.event,f)<=0&&(t.dirty=n.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(i.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,i),i.Org.s=f.s,i.Org.t=f.t,i.Org.pqHandle=e.pq.insert(i.Org),r.getIntersectData(e,i.Org,o,l,a,u),r.regionAbove(t).dirty=t.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(e,t){for(var n=r.regionBelow(t),i,s;;){for(;n.dirty;)t=n,n=r.regionBelow(n);if(!t.dirty&&(n=t,t=r.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,i=t.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(e,t)&&(n.fixUpperEdge?(r.deleteRegion(e,n),e.mesh.delete(s),n=r.regionBelow(t),s=n.eUp):t.fixUpperEdge&&(r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n),i=t.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!t.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===e.event||s.Dst===e.event)){if(r.checkForIntersect(e,t))return}else r.checkForRightSplice(e,t);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n))}},r.connectRightVertex=function(e,t,n){var i,s=n.Onext,o=r.regionBelow(t),a=t.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(e,t),je.vertEq(a.Org,e.event)&&(e.mesh.splice(s.Oprev,a),t=r.topLeftRegion(e,t),s=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),o),u=!0),je.vertEq(l.Org,e.event)&&(e.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(e,o,null),u=!0),u){r.addRightEdges(e,t,n.Onext,s,s,!0);return}je.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=e.mesh.connect(n.Lprev,i),r.addRightEdges(e,t,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(e,t)},r.connectLeftDegenerate=function(e,t,n){var i,s,o,a,l;if(i=t.eUp,je.vertEq(i.Org,n)){Ye(!1),r.spliceMergeVertices(e,i,n.anEdge);return}if(!je.vertEq(i.Dst,n)){e.mesh.splitEdge(i.Sym),t.fixUpperEdge&&(e.mesh.delete(i.Onext),t.fixUpperEdge=!1),e.mesh.splice(n.anEdge,i),r.sweepEvent(e,n);return}Ye(!1),t=r.topRightRegion(t),l=r.regionBelow(t),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(Ye(s!==o),r.deleteRegion(e,l),e.mesh.delete(o),o=s.Oprev),e.mesh.splice(n.anEdge,o),je.edgeGoesLeft(s)||(s=null),r.addRightEdges(e,t,o.Onext,a,s,!0)},r.connectLeftVertex=function(e,t){var n,i,s,o,a,l,u=new fx;if(u.eUp=t.anEdge.Sym,n=e.dict.search(u).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,je.edgeSign(o.Dst,t,o.Org)===0){r.connectLeftDegenerate(e,n,t);return}if(s=je.vertLeq(a.Dst,o.Dst)?n:i,n.inside||s.fixUpperEdge){if(s===n)l=e.mesh.connect(t.anEdge.Sym,o.Lnext);else{var c=e.mesh.connect(a.Dnext,t.anEdge);l=c.Sym}s.fixUpperEdge?r.fixUpperEdge(e,s,l):r.computeWinding(e,r.addRegionBelow(e,n,l)),r.sweepEvent(e,t)}else r.addRightEdges(e,n,t.anEdge,t.anEdge,null,!0)}},r.sweepEvent=function(e,t){e.event=t,r.debugEvent(e);for(var n=t.anEdge;n.activeRegion===null;)if(n=n.Onext,n===t.anEdge){r.connectLeftVertex(e,t);return}var i=r.topLeftRegion(e,n.activeRegion);Ye(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(e,s,null);a.Onext===o?r.connectRightVertex(e,i,a):r.addRightEdges(e,i,a.Onext,o,o,!0)},r.addSentinel=function(e,t,n,i){var s=new fx,o=e.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=t,o.Dst.t=i,e.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},r.initEdgeDict=function(e){e.dict=new tH(e,r.edgeLeq);var t=e.bmax[0]-e.bmin[0],n=e.bmax[1]-e.bmin[1],i=e.bmin[0]-t,s=e.bmax[0]+t,o=e.bmin[1]-n,a=e.bmax[1]+n;r.addSentinel(e,i,s,o),r.addSentinel(e,i,s,a)},r.doneEdgeDict=function(e){for(var t,n=0;(t=e.dict.min().key)!==null;)t.sentinel||(Ye(t.fixUpperEdge),Ye(++n===1)),Ye(t.windingNumber===0),r.deleteRegion(e,t)},r.removeDegenerateEdges=function(e){var t,n,i,s=e.mesh.eHead;for(t=s.next;t!==s;t=n)n=t.next,i=t.Lnext,je.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(r.spliceMergeVertices(e,i,t),e.mesh.delete(t),t=i,i=t.Lnext),i.Lnext===t&&(i!==t&&((i===n||i===n.Sym)&&(n=n.next),e.mesh.delete(i)),(t===n||t===n.Sym)&&(n=n.next),e.mesh.delete(t))},r.initPriorityQ=function(e){var t,n,i,s=0;for(i=e.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,t=e.pq=new eH(s,je.vertLeq),i=e.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=t.insert(n);return n!==i?!1:(t.init(),!0)},r.donePriorityQ=function(e){e.pq=null},r.removeDegenerateFaces=function(e,t){var n,i,s;for(n=t.fHead.next;n!==t.fHead;n=i)i=n.next,s=n.anEdge,Ye(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),e.mesh.delete(s));return!0},r.computeInterior=function(e,t){t===void 0&&(t=!0);var n,i;if(r.removeDegenerateEdges(e),!r.initPriorityQ(e))return!1;for(r.initEdgeDict(e);(n=e.pq.extractMin())!==null;){for(;i=e.pq.min(),!(i===null||!je.vertEq(i,n));)i=e.pq.extractMin(),r.spliceMergeVertices(e,n.anEdge,i.anEdge);r.sweepEvent(e,n)}return e.event=e.dict.min().key.eUp.Org,r.debugEvent(e),r.doneEdgeDict(e),r.donePriorityQ(e),r.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},r}(),nH=function(){function r(){this.mesh=new GM,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=Ft.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return r.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},r.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},r.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},r.prototype.computeNormal_=function(e){var t,n,i,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],h=[0,0,0],f=[0,0,0],d=[null,null,null],m=[null,null,null],p=this.mesh.vHead;t=p.next;for(var g=0;g<3;++g)s=t.coords[g],u[g]=s,m[g]=t,l[g]=s,d[g]=t;for(t=p.next;t!==p;t=t.next)for(var v=0;v<3;++v)s=t.coords[v],s<u[v]&&(u[v]=s,m[v]=t),s>l[v]&&(l[v]=s,d[v]=t);var y=0;if(l[1]-u[1]>l[0]-u[0]&&(y=1),l[2]-u[2]>l[y]-u[y]&&(y=2),u[y]>=l[y]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,n=m[y],i=d[y],c[0]=n.coords[0]-i.coords[0],c[1]=n.coords[1]-i.coords[1],c[2]=n.coords[2]-i.coords[2],t=p.next;t!==p;t=t.next)h[0]=t.coords[0]-i.coords[0],h[1]=t.coords[1]-i.coords[1],h[2]=t.coords[2]-i.coords[2],f[0]=c[1]*h[2]-c[2]*h[1],f[1]=c[2]*h[0]-c[0]*h[2],f[2]=c[0]*h[1]-c[1]*h[0],o=f[0]*f[0]+f[1]*f[1]+f[2]*f[2],o>a&&(a=o,e[0]=f[0],e[1]=f[1],e[2]=f[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(c)]=1)},r.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,n=this.mesh.vHead,i,s=0,o=e.next;o!==e;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(t=n.next;t!==n;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},r.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],n,i,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),n=this.sUnit,i=this.tUnit;var o=this.longAxis_(t);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=t[o]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,u=e.next;u!==e;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},r.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.prototype.tessellateMonoRegion_=function(e,t){var n,i;if(n=t.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;je.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;je.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(je.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(je.edgeGoesLeft(i.Lnext)||je.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=e.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(je.edgeGoesRight(n.Lprev)||je.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=e.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=e.connect(i.Lnext,i),i=s.Sym;return!0},r.prototype.tessellateInterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)if(t=n.next,n.inside&&!this.tessellateMonoRegion_(e,n))return!1;return!0},r.prototype.discardExterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)t=n.next,n.inside||e.zapFace(n)},r.prototype.setWindingNumber_=function(e,t,n){for(var i,s=e.eHead.next;s!==e.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:n?e.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},r.prototype.outputPolymesh_=function(e,t,n,i){var s,o=0,a=0,l;n>3&&e.mergeConvexFaces(n);for(var u=e.vHead.next;u!==e.vHead;u=u.next)u.n=-1;for(var c=e.fHead.next;c!==e.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,t===Cr.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=e.vHead.next;u!==e.vHead;u=u.next)if(u.n!==-1){var h=u.n*i;this.vertices[h+0]=u.coords[0],this.vertices[h+1]=u.coords[1],i>2&&(this.vertices[h+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var f=0,c=e.fHead.next;c!==e.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[f++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var d=l;d<n;++d)this.elements[f++]=-1;if(t===Cr.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[f++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var m=l;m<n;++m)this.elements[f++]=-1}}},r.prototype.outputContours_=function(e,t){var n,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){i=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=0,i=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],t>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==i);this.elements[c++]=s,this.elements[c++]=o,s+=o}},r.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new GM),e<2&&(e=2),e>3&&(e=3);for(var n=null,i=0;i<t.length;i+=e)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=t[i+0],n.Org.coords[1]=t[i+1],e>2?n.Org.coords[2]=t[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(e,t,n,i,s,o){if(e===void 0&&(e=Ft.ODD),t===void 0&&(t=Cr.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),rH.computeInterior(this,o);var a=this.mesh;return t===Cr.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),t===Cr.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,t,n,i),!0},r}();function Za(r){var e=r.windingRule,t=e===void 0?Ft.ODD:e,n=r.elementType,i=n===void 0?Cr.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,u=r.normal,c=u===void 0?[0,0,1]:u,h=r.contours,f=h===void 0?[]:h,d=r.strict,m=d===void 0?!0:d,p=r.debug,g=p===void 0?!1:p;if(!f&&m)throw new Error("Contours can't be empty");if(!!f){var v=new nH;r.edgeCreateCallback&&(v.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(v.vertexIdCallback=r.vertexIdCallback);for(var y=0;y<f.length;y++)v.addContour(l||2,f[y]);return v.tesselate(t,i,o,l,c,m),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var _le=Ft.ODD,Mle=Ft.NONZERO,Ele=Ft.POSITIVE,Cle=Ft.NEGATIVE,Ple=Ft.ABS_GEQ_TWO,Dle=Cr.POLYGONS,Ile=Cr.CONNECTED_POLYGONS,Lle=Cr.BOUNDARY_CONTOURS;var iu=class extends Le{constructor(t,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=Ft.ODD;this.elementType=Cr.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=t,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:Ft.ODD,elementType:Cr.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,h;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,v=s[g+0],y=s[g+1];if(c!==void 0&&v!==c&&(l=!1),h!==void 0&&y!==h&&(u=!1),c=v,h=y,!l&&!u)break}!l&&!u&&(a=Za({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let f=a?.vertexCount??1,d=a?.elementCount??1;if(this._positionAttribute=new We(new Float32Array(f*3),3),this._normalAttribute=new We(new Float32Array(f*3),3),this._uvAttribute=new We(new Float32Array(f*2),2),this._indexAttribute=new We(new Uint32Array(d*3),1),a){let m=1/0,p=-1/0,g=1/0,v=-1/0;for(let S=0,w=f;S<w;S++){let A=S*2,_=a.vertices[A+0],x=a.vertices[A+1];_<m&&(m=_),_>p&&(p=_),x<g&&(g=x),x>v&&(v=x)}let y=p-m,b=v-g;for(let S=0,w=f;S<w;S++){let A=S*2,_=a.vertices[A+0],x=a.vertices[A+1],M=(_-m)/y,E=(x-g)/b;this._positionAttribute.setXYZ(S,_,x,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,M,E)}for(let S=0,w=d;S<w;S++){let A=S*3,_=a.elements[A+0],x=a.elements[A+1],M=a.elements[A+2];this._indexAttribute.setX(A+0,_),this._indexAttribute.setX(A+1,x),this._indexAttribute.setX(A+2,M)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let t=new iu(this._shape,this._curveSegments);return t.userData=Bh(this.userData),t}};var Zm=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let n=e*Zm.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*i,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let n=e*Zm.eSize,i=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*e);o+=3*e;let l=new Float32Array(i,o*s,3*e);o+=3*e;let u=new Float32Array(i,o*s,2*e);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=u,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let i=this.capacity;for(;t>i;)i*=2;this.realloc(i)}let n=this.size;return this.size=t,n}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},uf=Zm;uf.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var dx=(r,e)=>([t,n])=>(n<t&&(n+=e),(r>=t?r:r+e)<=n),su=class extends Le{constructor(t,n,i=0,s=12,o=3,a=Ft.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=t,this._depth=n,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,n/2-1e-12),this._bevelSegments=Math.floor(o));let l=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(x=>{let M=x.extractShapePointsToFlatArray([],s),E=[];for(let C=M.length-1;C>=1;C-=2){let P=M[C-1],L=M[C-0];E.push(P,L)}return E}),c=Za({windingRule:a,elementType:Cr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]}),h=Za({windingRule:Ft.ODD,elementType:Cr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]});if(!c)throw new Error("error generating geometry");let f=c.elementCount;if(h){c.elementCount+=h.elementCount;for(let x=0;x<h.elements.length;x++){let M=h.elements[x],E=x%2===0?c.vertexCount:0;c.elements.push(M+E)}for(let x=0;x<h.vertexIndices.length;x++){let M=h.vertexIndices[x],E=c.vertexCount;c.vertexIndices.push(M+E)}for(let x=0;x<h.vertices.length;x++){let M=h.vertices[x];c.vertices.push(M)}}let d=1/0,m=-1/0,p=1/0,g=-1/0;for(let x=0,M=c.vertexCount;x<M;x++){let E=x*2,C=c.vertices[E+0],P=c.vertices[E+1];C<d&&(d=C),C>m&&(m=C),P<p&&(p=P),P>g&&(g=P)}this._minX=d,this._minY=p,this._width=m-d,this._height=g-p;let v=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new uf(v);let y=[],b=[];for(let x=c.elementCount-1;x>=0;x--){let M=x>=f,E=x*2,C=c.elements[E+0],P=c.elements[E+1],L=C+P,D={start:C,count:P,normals:[],continuous:[],concave:[]},R=C,N=L-1,U=C+1,X=this._shape.roundedCurves.length;do{let z=R-C,V=c.vertices[N*2+0],q=c.vertices[N*2+1],Y=c.vertices[R*2+0],H=c.vertices[R*2+1],fe=c.vertices[U*2+0],ne=c.vertices[U*2+1],K=Y-V,Q=H-q,ie=Math.sqrt(K*K+Q*Q);K/=ie,Q/=ie;let ue=Y-fe,ae=H-ne,Me=Math.sqrt(ue*ue+ae*ae);ue/=Me,ae/=Me,D.normals[z*2+0]=-ae,D.normals[z*2+1]=ue,D.concave[z]=K*ae-Q*ue>0;let ge=c.vertexIndices[R];if(Array.isArray(ge))D.continuous[z]=!1;else{let[ve,ye]=this._shape.getCurveIndexFromVertexId(ge-1,!0);if(ye>0&&ye<1)D.continuous[z]=!0;else{let de=ye===1?ve+1:ve-1;de=(de+X)%X;let Ie=ye===1?0:1,Ge=this._shape.roundedCurves[ve].getTangent(ye),tt=this._shape.roundedCurves[de].getTangent(Ie);D.continuous[z]=Ge.dot(tt)>.95}}M&&(D.normals[z*2+0]*=-1,D.normals[z*2+1]*=-1),[N,R,U]=[R,U,U+1],U>=L&&(U-=P)}while(U!==C+1);let F=[];F.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(C*2,L*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((z,V)=>[V,V]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(C*2,L*2)});for(let z=1;z<=this._bevelSegments;z++){let V=z/this._bevelSegments*Math.PI/2,q=(1-Math.cos(V))*this._bevelSize,Y=[],H=[],fe=[],ne=[],K=0;for(let ie=0;ie<P;ie++){let ue=ie*2,ae=(ie-1+P)%P*2,Me=c.vertices[D.start*2+ue+0],ge=c.vertices[D.start*2+ue+1],ve=-D.normals[ae+0]*q,ye=-D.normals[ae+1]*q,de=-D.normals[ue+0]*q,Ie=-D.normals[ue+1]*q;if(D.concave[ie]||!D.concave[ie]&&M){let Ge=Math.atan2(ye,ve),tt=Math.atan2(Ie,de);tt>Ge&&(tt-=Math.PI*2);let B=tt-Ge;if(D.continuous[ie]||M){let I=Ge+B/2,J=Math.cos(I)*q,ce=Math.sin(I)*q;Y[2*K+0]=Me+J*(M?-1:1),Y[2*K+1]=ge+ce*(M?-1:1),ne[K]=ie,K++}else{let I=Math.max(1,Math.floor(s/4*Math.abs(B)/Math.PI));for(let J=0;J<=I;J++){let ce=Ge+B*(J/I),pe=Math.cos(ce)*q,Ce=Math.sin(ce)*q;Y[2*K+0]=Me+pe,Y[2*K+1]=ge+Ce,ne[K]=ie,K++}}}else Y[2*K+0]=Me+ve,Y[2*K+1]=ge+ye,ne[K]=ie,H[ie]=K,K++,Y[2*K+0]=Me,Y[2*K+1]=ge,ne[K]=ie,K++,Y[2*K+0]=Me+de,Y[2*K+1]=ge+Ie,ne[K]=ie,fe[ie]=K,K++}let Q=Za({windingRule:Ft.POSITIVE,elementType:Cr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Y],edgeCreateCallback:ie=>{let ae=ie.Org.idx,Me=ne[ae],ge=ne[(ae+1)%ne.length];ie.idx=[Me,ge],ie.Sym.idx=[ge,Me]},vertexIdCallback:ie=>{let ue=ie.Lprev.idx;return[ue?ue[1]:0,ie.idx[0]]}});if(!Q)throw console.log("Error"),new Error(`error generating bevel geometry for ${z}'th loop`);if(!Q.vertexCount)break;for(let ie=0;ie<Q.vertexIndices.length;ie++){let[ue,ae]=Q.vertexIndices[ie];if(ue===ae)continue;let Me=ae;ae<ue&&(Me+=P);for(let ge=ue;ge<Me;ge++){let ve=ge%P,ye=(ge+1)%P;if(!D.continuous[ve]||!D.continuous[ye]){Q.vertexIndices[ie]=[ue,ve],Q.vertexIndices.splice(ie+1,0,[ye,ae]),Q.vertices.splice((ie+1)*2,0,Q.vertices[ie*2],Q.vertices[ie*2+1]);break}}}F.push({bevelI:z,angle:V,size:q,boundary:Q,reverseMap:ne,insetPoints:Y})}let G=(z,V,q)=>{let Y=0,H=z.boundary.vertexIndices.length;for(;Y<H&&q(z.boundary.vertexIndices[V]);)V=(V+1)%H,Y++;return Y},j=y.length;for(let z=1;z<F.length;z++){let V=F[z-1],q=F[z],Y=V.boundary.vertexIndices.length,H=q.boundary.vertexIndices.length;if(!Y||!H)break;let fe=D.concave.length,ne=0,K=dx(ne,P);for(;!V.boundary.vertexIndices.filter(K).length||!q.boundary.vertexIndices.filter(K).length;)ne++,K=dx(ne,P);let Q=V.boundary.vertexIndices.findIndex(K),ie=q.boundary.vertexIndices.findIndex(K);do Q=(Q+1)%Y;while(K(V.boundary.vertexIndices[Q]));do ie=(ie+1)%H;while(K(q.boundary.vertexIndices[ie]));ne=(ne+1)%P;let ue=ne,ae=this.buildBevelVert(D,V,(Q-1+Y)%Y),Me=this.buildBevelVert(D,q,(ie-1+H)%H),ge=ae,ve=Me,ye,de,Ie=!1;do{K=dx(ne,P);let Ge=G(V,Q,K),tt=G(q,ie,K),B=Ie;if(Ie=!1,Ge&&!tt){for(let I=0;I<Ge;I++)ye=this.buildBevelVert(D,V,(Q+I)%Y,I/(Ge-1)),y.push(ge.topN,ye.topP,ve.topN),y.push(ye.bottomP,ge.bottomN,ve.bottomN),ge=ye;Ie=!0}else if(!Ge&&tt)for(let I=0;I<tt;I++)de=this.buildBevelVert(D,q,(ie+I)%H,I/(tt-1)),y.push(ve.topN,ge.topP,de.topP),y.push(ge.bottomP,ve.bottomN,de.bottomP),ve=de;else if(Ge&&tt)if(ye=this.buildBevelVert(D,V,Q,0),de=this.buildBevelVert(D,q,ie,0),B?(y.push(ge.topN,de.topP,ve.topN),y.push(ge.topN,ye.topP,de.topP),y.push(de.bottomP,ge.bottomN,ve.bottomN),y.push(de.bottomP,ye.bottomP,ge.bottomN)):(y.push(ve.topN,ge.topN,ye.topP),y.push(ve.topN,ye.topP,de.topP),y.push(ye.bottomP,ge.bottomN,ve.bottomN),y.push(ye.bottomP,ve.bottomN,de.bottomP)),ge=ye,ve=de,Ge===tt)for(let I=1;I<Ge;I++)ye=this.buildBevelVert(D,V,(Q+I)%Y,I/(Ge-1)),de=this.buildBevelVert(D,q,(ie+I)%H,I/(tt-1)),y.push(ge.topN,ye.topP,ve.topN),y.push(ve.topN,ye.topP,de.topP),y.push(ye.bottomP,ge.bottomN,ve.bottomN),y.push(ye.bottomP,ve.bottomN,de.bottomP),ge=ye,ve=de;else if(Ge>tt){let I=Ge/tt,J=0;for(let ce=1;ce<Ge;ce++)ye=this.buildBevelVert(D,V,(Q+ce)%Y,ce/(Ge-1)),y.push(ge.topN,ye.topP,ve.topN),y.push(ye.bottomP,ge.bottomN,ve.bottomN),ge=ye,ce>(J+1)*I&&(J++,de=this.buildBevelVert(D,q,(ie+J)%H,J/(tt-1)),y.push(ve.topN,ye.topP,de.topP),y.push(ye.bottomP,ve.bottomN,de.bottomP),ve=de)}else{let I=tt/Ge,J=0;for(let ce=1;ce<tt;ce++)de=this.buildBevelVert(D,q,(ie+ce)%H,ce/(tt-1)),y.push(ve.topN,ye.topP,de.topP),y.push(ye.bottomP,ve.bottomN,de.bottomP),ve=de,ce>(J+1)*I&&(J++,ye=this.buildBevelVert(D,V,(Q+J)%Y,J/(Ge-1)),y.push(ge.topN,ye.topP,ve.topN),y.push(ye.bottomP,ge.bottomN,ve.bottomN),ge=ye)}Q=(Q+Ge)%Y,ie=(ie+tt)%H,ne=(ne+1)%fe}while(ne!==ue)}{let z=F[0];for(let V=0,q=z.boundary.vertexCount;V<q;V++){let Y=this.buildBevelVert(D,z,V),H=this.buildBevelVert(D,z,(V+1)%q);y.push(H.topP,Y.topN,Y.bottomN),y.push(H.topP,Y.bottomN,H.bottomP)}}if(M){let z=[];for(let V=y.length-1;V>=j+2;V-=3){let q=y[V-2],Y=y[V-1],H=y[V-0];z.push(H,Y,q)}y.splice(j,y.length-j,...z)}if(M){let z=[];for(let V=F[F.length-1].boundary.vertices.length-1;V>=1;V-=2){let q=F[F.length-1].boundary.vertices[V-1],Y=F[F.length-1].boundary.vertices[V-0];z.push(q,Y)}b.push(z)}if(!M){let z=F[F.length-1],V=Za({windingRule:F.length>1?Ft.POSITIVE:Ft.ODD,elementType:Cr.POLYGONS,vertexSize:2,strict:!0,contours:[z.insetPoints,...b]});if(!V)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let q=0;q<V.elementCount*3;q+=3){let Y=this.buildSurfaceVert(V,V.elements[q+0]),H=this.buildSurfaceVert(V,V.elements[q+1]),fe=this.buildSurfaceVert(V,V.elements[q+2]);y.push(Y.top,H.top,fe.top),y.push(fe.bottom,H.bottom,Y.bottom)}}this.vertexCache={}}this._buffer.shrink();let S=new We(Uint32Array.from(y),1),w=new We(this._buffer.positions,3),A=new We(this._buffer.normals,3),_=new We(this._buffer.uvs,2);w.needsUpdate=!0,A.needsUpdate=!0,_.needsUpdate=!0,S.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",A),this.setAttribute("uv",_),this.setIndex(S)}buildSurfaceVert(t,n){let i=n.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=t.vertices[n*2+0],o=t.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,u=this._buffer.get(2),c=u*3,h=u*2,f={top:u+0,bottom:u+1};return this._buffer.positions[c+0]=s,this._buffer.positions[c+1]=o,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[h+0]=a,this._buffer.uvs[h+1]=l,this._buffer.positions[c+3]=s,this._buffer.positions[c+4]=o,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[h+2]=a,this._buffer.uvs[h+3]=l,this.vertexCache[i]=f,f}buildBevelVert(t,n,i,s=1){let o=`${n.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[i],u,c,h,f;a!==l?(c=a,u=l,f=!1,h=t.continuous[c]&&t.continuous[u]):(u=a,c=(u-1+t.count)%t.count,f=t.concave[u]&&n.bevelI>0,h=t.continuous[u]||f);let d=Math.cos(n.angle),m=Math.sin(n.angle),p=i*2,g=u*2,v=c*2,y=n.boundary.vertices[p+0],b=n.boundary.vertices[p+1],S=(1-m)*this._bevelSize,w=(y-this._minX)/this._width,A=(b-this._minY)/this._height,_=t.normals[g+0],x=t.normals[g+1],M=t.normals[v+0],E=t.normals[v+1];if(f){let R=M-_,N=E-x;_=_+R*(1-s),x=x+N*(1-s);let U=Math.sqrt(_*_+x*x);_/=U,x/=U}let C=this._buffer.get(h?2:4),P=C*3,L=C*2,D={i,fi:u,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1};return this._buffer.positions[P+0]=y,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=this._depth-S,this._buffer.normals[P+0]=_*d,this._buffer.normals[P+1]=x*d,this._buffer.normals[P+2]=m,this._buffer.uvs[L+0]=w,this._buffer.uvs[L+1]=A,this._buffer.positions[P+3]=y,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=S,this._buffer.normals[P+3]=_*d,this._buffer.normals[P+4]=x*d,this._buffer.normals[P+5]=-m,this._buffer.uvs[L+2]=A,this._buffer.uvs[L+3]=w,h||(C+=2,P+=6,L+=4,D.topP=C+0,D.bottomP=C+1,this._buffer.positions[P+0]=y,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=this._depth-S,this._buffer.normals[P+0]=M*d,this._buffer.normals[P+1]=E*d,this._buffer.normals[P+2]=m,this._buffer.uvs[L+0]=w,this._buffer.uvs[L+1]=A,this._buffer.positions[P+3]=y,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=S,this._buffer.normals[P+3]=M*d,this._buffer.normals[P+4]=E*d,this._buffer.normals[P+5]=-m,this._buffer.uvs[L+2]=A,this._buffer.uvs[L+3]=w),this.vertexCache[o]=D,D}clone(){let t=new su(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return t.userData=Bh(this.userData),t}};var Qr=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Ft.ODD},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??0),o=r.shape??e?.shape,a=o?.roundness??t.roundness;o!==void 0&&(o instanceof At?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new At(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update(!1));let l=o??new At(n,i);return{parameters:Object.assign(t,{width:n,height:i,depth:s,roundness:a}),shape:l}}static build(r){let{depth:e,extrudeBevelSize:t,extrudeBevelSegments:n,subdivisions:i,roundness:s,windingRule:o}=r.parameters;r.shape.roundness=s;let a;return e<=0?a=new iu(r.shape,i,{windingRule:o}):a=new su(r.shape,e,t,i,n,o),Object.assign(a,{userData:{...r,type:"VectorGeometry"}})}};var jM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},r.parameters),n=t.width/2,i=t.radiusTop??n,s=t.radiusBottom??n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:h,cornerSegments:f,hollow:d}=r.parameters,m;return h||d?m=new hf(u,c,n,i,s,o,a,l*Math.PI/180,h,h,f,d):m=new Ma(u,c,n,i,s,o,a,l*Math.PI/180),m.scale(1,1,t/e),Object.assign(m,{userData:{...r,type:"CylinderGeometry"}})}};function Ho(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function WM(r){return new k(r.y,-r.x)}var hf=class extends Le{constructor(e,t,n,i,s,o,a,l,u,c,h,f,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,n=n||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let m=[],p=[],g=[],v=[],y=0,b=n/2,S=new T,w=new T;d&&e==0&&(e=u),d&&t==0&&(t=c);let A=new k(e,b),_=new k(t,-b),x=null,M=null,E=null,C=null,P=A.clone().sub(_),L=0,D=0,R=0;f>0&&(L=Math.min(e,t)*(1-f),D=e-L,R=t-L);let N=A.clone();N.x-=L;let U=Math.PI-P.angle(),X=P.angle(),F=Math.tan(X/2),G=Math.tan(U/2),j=F+G,z=f?j:G,V=f?j:F;if(u=Math.min(u,(e-D)/z,P.length()/j),c=Math.min(c,(t-R)/V,P.length()/j),u>0){let K=u/F;x=A.clone().sub(new k(K,u)),f&&(E=x.clone(),E.x-=L-j*u),A.sub(P.clone().setLength(K))}if(c>0){let K=c/G;M=_.clone().sub(new k(K,-c)),_.add(P.clone().setLength(K)),f&&(C=M.clone(),C.x-=L-j*c,N.sub(P.clone().setLength(K)))}P=A.clone().sub(_);let q=P.length()<.5,Y=[];for(let K=0;K<=i;K++){let Q=[],ie=K/i,ue=ie*l+a,ae=new k(Math.sin(ue),Math.cos(ue));C&&M?(H(Q,ie,ae,U,c,C,-1,!0),H(Q,ie,ae,X,c,M,-1,!1)):M?(fe(Q,ae,M.x,0,-1),H(Q,ie,ae,X,c,M,-1,!1)):o||fe(Q,ae,t,R,-1);let Me=WM(P).normalize();if(Ho(Me,ae,S),!q)for(let ge=0;ge<=s;ge++){let ve=ge/s,ye=P.clone().multiplyScalar(ve).add(_);Ho(ye,ae,w),p.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),v.push(ie,.5+w.y/n),Q.push(y++)}if(E&&x?(H(Q,ie,ae,U,u,x,1,!1),H(Q,ie,ae,X,u,E,1,!0)):x?(H(Q,ie,ae,U,u,x,1,!1),fe(Q,ae,x.x,0,1)):o||fe(Q,ae,e,D,1),f&&!q){let ge=WM(P).multiplyScalar(-1).normalize();Ho(ge,ae,S);for(let ve=0;ve<=s;ve++){let ye=ve/s,de=P.clone().multiplyScalar(-ye).add(N);Ho(de,ae,w),p.push(w.x,w.y,w.z),g.push(S.x,S.y,S.z),v.push(ie,.5+w.y/n),Q.push(y++)}}f&&!o&&Q.push(Q[0]),Y.push(Q)}for(let K=0;K<Y.length-1;K++)for(let Q=0;Q<Y[0].length-1;Q++){if(o&&f&&Q==s)continue;let ie=Y[K][Q],ue=Y[K+1][Q],ae=Y[K+1][Q+1],Me=Y[K][Q+1],ge=p[ae*3+0],ve=p[ae*3+2];m.push(ie,ue,Me),(ge!=0||ve!=0)&&m.push(ue,ae,Me)}l<Math.PI*2&&(ne(-1,Y[0],a),ne(1,Y[Y.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Te(p,3)),this.setAttribute("normal",new Te(g,3)),this.setAttribute("uv",new Te(v,2));function H(K,Q,ie,ue,ae,Me,ge,ve){for(let ye=0;ye<h+1;ye++){let de=ye/h,Ie=ge<0?de:1-de;ve&&(Ie-=1),Ie*=ue;let Ge=new k(Math.sin(Ie),Math.cos(Ie)*ge),tt=Ge.clone().multiplyScalar(ae).add(Me);Ho(tt,ie,w),p.push(w.x,w.y,w.z),Ho(Ge,ie,S),g.push(S.x,S.y,S.z),v.push(Q,.5+w.y/n),K.push(y++)}}function fe(K,Q,ie,ue,ae){let Me=new T,ge=new k,ve=[ie,ue];ae<0&&ve.reverse();for(let ye of ve)ge.set(ye,b*ae),Ho(ge,Q,Me),p.push(Me.x,Me.y,Me.z),g.push(0,ae,0),v.push(.5,.5),K.push(y++)}function ne(K,Q,ie){let ue=new k(Math.sin(ie),Math.cos(ie)),ae=new k(-Math.cos(ie),Math.sin(ie)),Me=new T,ge=K<0?(de,Ie,Ge)=>m.push(de,Ie,Ge):(de,Ie,Ge)=>m.push(de,Ge,Ie),ve=new k((e+t+D+R)/4,0);Ho(ve,ue,Me),p.push(Me.x,Me.y,Me.z),g.push(ae.x,0,ae.y),v.push(.5,.5);let ye=y++;for(let de of Q){let Ie=p.slice(de*3,de*3+3);p.push(...Ie),g.push(ae.x,0,ae.y);let Ge=v.slice(de*2,de*2+2);v.push(...Ge),y++}for(let de=ye+1;de<y-1;de++)ge(ye,de,de+1);ge(ye,y-1,ye+1)}}};var qM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:h}=r.parameters,f;return u>0||c>0||l<360?f=new hf(0,e/2,n,i,s,o,a,l*Math.PI/180,u,c,h,0,!0):f=new zl(e/2,n,i,s,o),f.scale(1,1,t/e),Object.assign(f,{userData:{...r,type:"ConeGeometry"}})}};var XM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,u;return a==0?u=new Tn(e,t,n,i,s,o):u=new mx(e,t,n,i,s,o,a,l),Object.assign(u,{userData:{...r,type:"CubeGeometry"}})}},px=Math.PI/2,mx=class extends Le{constructor(e=1,t=1,n=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let u=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,e/2,t/2,n/2);let c=[],h=[],f=[],d=[],m=0,p=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,s,4),g("x","y","z",-1,-1,e,t,-n,i,s,5),a>0&&(v("z","y","x",-1,-1,1,n,t,e,o,0),v("z","y","x",1,-1,-1,n,t,e,o,1),v("z","y","x",-1,1,-1,n,t,e,o,1),v("z","y","x",1,1,1,n,t,e,o,0),v("x","y","z",-1,-1,-1,e,t,n,i,0),v("x","y","z",1,-1,1,e,t,n,i,1),v("x","y","z",-1,1,1,e,t,n,i,0),v("x","y","z",1,1,-1,e,t,n,i,1),v("y","x","z",-1,-1,1,t,e,n,s,0),v("y","x","z",1,-1,-1,t,e,n,s,1),v("y","x","z",1,1,1,t,e,n,s,1),v("y","x","z",-1,1,-1,t,e,n,s,0),y(1,1,1),y(-1,1,1),y(1,-1,1),y(-1,-1,1),y(1,1,-1),y(-1,1,-1),y(1,-1,-1),y(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Te(h,3)),this.setAttribute("normal",new Te(f,3)),this.setAttribute("uv",new Te(d,2));function g(b,S,w,A,_,x,M,E,C,P,L){let D=(x-2*a)/C,R=(M-2*a)/P,N=x/2-a,U=M/2-a,X=E/2,F=C+1,G=P+1,j=0,z=0,V=new T;for(let q=0;q<G;q++){let Y=q*R-U;for(let H=0;H<F;H++){let fe=H*D-N;V[b]=fe*A,V[S]=Y*_,V[w]=X,h.push(V.x,V.y,V.z),V[b]=0,V[S]=0,V[w]=E>0?1:-1,f.push(V.x,V.y,V.z),d.push(H/C),d.push(1-q/P),j+=1}}for(let q=0;q<P;q++)for(let Y=0;Y<C;Y++){let H=m+Y+F*q,fe=m+Y+F*(q+1),ne=m+(Y+1)+F*(q+1),K=m+(Y+1)+F*q;c.push(H,fe,K),c.push(fe,ne,K),z+=6}u.addGroup(p,z,L),p+=z,m+=j}function v(b,S,w,A,_,x,M,E,C,P,L){let D=(M-2*a)/P,R=M/2-a,N=E/2-a,U=C/2,X=P+1,F=0,G=0,j=new T,z=new T;for(let V=0;V<l+1;V++){let q=V/l*px,Y=Math.sin(q)*a,H=(1-Math.cos(q))*a,fe=Math.sin(q),ne=Math.cos(q);j[S]=(N+Y)*_,j[w]=(U-H)*x,z[b]=0,z[S]=fe*Math.sign(j[S]),z[w]=ne*Math.sign(j[w]);for(let K=0;K<X;K++){let Q=K*D-R;j[b]=Q*A,h.push(j.x,j.y,j.z),f.push(z.x,z.y,z.z),d.push(K/P),d.push(0),F+=1}}for(let V=0;V<l;V++)for(let q=0;q<P;q++){let Y=m+q+X*V,H=m+q+X*(V+1),fe=m+(q+1)+X*(V+1),ne=m+(q+1)+X*V;c.push(Y,H,ne),c.push(H,fe,ne),G+=6}u.addGroup(p,G,L),p+=G,m+=F}function y(b,S,w){let A=new T,_=new T(e/2,t/2,n/2);_.subScalar(a);let x=[],M=b*S*w>0?(C,P,L)=>c.push(C,P,L):(C,P,L)=>c.push(C,L,P);for(let C=0;C<=l;C++){let P=[],L=px*(1-C/l),D=Math.cos(L),R=Math.sin(L),N=0;for(let U=0;U<=C;U++){let X=Math.cos(N),F=Math.sin(N);A.x=D*X,A.y=R,A.z=D*F;let G=_.clone().addScaledVector(A,a);h.push(b*G.x,S*G.y,w*G.z),f.push(b*A.x,S*A.y,w*A.z),d.push(0,0),P.push(m++),N+=px/C}x.push(P)}let E=x.length-1;for(let C=0;C<E;C++){let P=x[C],L=x[C+1],D=P.length-1;M(P[0],L[1],L[0]);for(let R=1;R<=D;R++)M(P[R-1],P[R],L[R]),M(P[R],L[R+1],L[R])}}}};var Wo=class extends Le{constructor(e=[],t=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),h(),this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(u,3)),this.setAttribute("uv",new Te(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let d={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],m=new T,p=m.clone(),g=new Nr,v=s*i,y=i-v,b=o+1,S=new T,w=(F,G)=>S.subVectors(F,G).normalize(),A=(F,G)=>Array(F).fill(void 0).map(G),_=A(e.length/3,(F,G)=>new T().fromArray(e,G*3).setLength(i)),x=[],M=1e6;for(let F=0;F<_.length;F++){let G=_[F],j=[],z,V,q,Y=1e10,H=-1;for(;(H=t.indexOf(F,H+1))!=-1;){let Q=H-H%3;z=t[Q+(H+1)%3],V=t[Q+(H+2)%3],q=G.distanceToSquared(_[z]),Y=Math.min(Y,q),j.push([z,V,q])}Y+=1e-6;let fe=[],ne=0,K=j.length;for(let Q=0;Q<K;Q++){[z,V,q]=j[ne];let ie=x[z]?.includes(F)==!0;q<=Y&&fe.push(z+ +ie*M),ne=j.findIndex(ue=>ue[0]==V)}x.push(fe)}let E=[];{let F=0,G=0,j,z,V=d==3;for(let q=0;q<=o;q++){j=q*(q+1)/2,z=(q+1)*(q+2)/2;for(let Y=0;Y<o-q;Y++)[F,G]=[j+Y+q+2,z+Y+q+3],E.push(j,z,...V?[G,j]:[F,z],G,F),[j,z]=[F,G];E.push(j,z,j+o+2)}}let C=m.clone(),P=m.clone(),L=m.clone(),D=m.clone(),R=m.clone(),N=[],U=A(_.length,()=>A(d,()=>m.clone()));for(let F=0;F<_.length;F++){m.copy(_[F]).normalize(),C.copy(m).multiplyScalar(y);let G=x[F];for(let fe=0;fe<G.length;fe++){let ne=G[fe],K=G[(fe+1)%d];g.setFromPointsAndIndices(_,F,ne%M,K%M),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,U[F][fe])}let j=[],z=[],V=[],q=new T;o==0&&[...U[F]].reduce((fe,ne)=>fe.add(ne),q).multiplyScalar(1/d);for(let fe=0;fe<d;fe++){let ne=[],K=(fe-1+d)%d,Q=U[F][K],ie=U[F][fe];m.copy(Q).sub(C),p.copy(ie).sub(C);let ue=C.angleTo(m),ae=m.angleTo(p),Me=Math.cos(ue)*v;o==0?P.copy(q):P.copy(C).setLength(y+Me),z.push(Me);let ge=[P,Q,ie];for(let ve=0;ve<2;ve++){let ye=ge[ve],de=ge[ve+1];D.subVectors(ye,C),R.subVectors(de,C),L.crossVectors(D,R).normalize();for(let Ie=0;Ie<b;Ie++){let Ge=[ue,ae][ve]*Ie/b;m.copy(D).applyAxisAngle(L,Ge).add(C),j.push(m.clone()),ve&&(w(m,C),ne.push([Ie==0?ye:m.clone(),S.clone()]))}ve&&(w(de,C),ne.push([de,S.clone()]))}V.push(ne)}N.push(V);let Y=2*b,H=2;for(let fe=0;fe<d;fe++){let ne=Y*fe,K=Y*((fe+1)%d),Q=[j[ne]];for(let ue=1;ue<b;ue++){D=j[ne+ue],R=j[K+ue],Q.push(D);for(let ae=1,Me=ue-H+1;ae<=Me;ae++)m.lerpVectors(D,R,ae/(Me+1)),m.sub(C).setLength(z[fe]).add(C),Q.push(m.clone());Q.push(R)}for(let ue=0;ue<b;ue++)Q.push(j[ue+b+ne]);Q.push(j[K+b]);let ie=E.map(ue=>Q[ue]);a.push(...ie.map(ue=>[ue.x,ue.y,ue.z]).flat()),u.push(...ie.map(ue=>(w(ue,C),[S.x,S.y,S.z])).flat())}}let X=[];for(let F=0;F<x.length;F++)for(let G=0;G<d;G++){let j=x[F][G];if(j<M){let z=x[j].findIndex(Y=>Y%M==F),V=N[F][G],q=N[j][z];for(let Y=0;Y<b;Y++){let H=V[Y],fe=q[b-Y],ne=V[Y+1],K=q[b-(Y+1)];[H,fe,ne,ne,fe,K].forEach(Q=>{a.push(Q[0].x,Q[0].y,Q[0].z),u.push(Q[1].x,Q[1].y,Q[1].z)})}X.push(V[0][0],q[b][0],V[b][0],q[0][0])}}for(;X.length;){let F,G,j,z;[F,G]=X.splice(0,2);let V=[F];for(;F!=G;)V.push(G),j=X.indexOf(G),z=j%2,G=X.splice(j-z,2)[1-z];S.subVectors(V[0],V[1]).cross(m.subVectors(V[0],V[2])).normalize();let q=S.dot(V[0])<0;q&&S.negate();for(let Y=1;Y<=V.length-2;Y++)[V[Y+ +q],V[Y+1-+q],V[0]].forEach(H=>{a.push(H.x,H.y,H.z),u.push(S.x,S.y,S.z)})}}function h(){let f=new T;for(let _=0;_<a.length;_+=3){f.x=a[_+0],f.y=a[_+1],f.z=a[_+2];let x=w(f)/2/Math.PI+.5,M=A(f)/Math.PI+.5;l.push(x,1-M)}let d=new T,m=new T,p=new T,g=new T,v=new k,y=new k,b=new k,S=(_,x,M,E)=>{E<0&&_.x===1&&(l[x]=_.x-1),M.x===0&&M.z===0&&(l[x]=E/2/Math.PI+.5)};for(let _=0,x=0;_<a.length;_+=9,x+=6){d.set(a[_+0],a[_+1],a[_+2]),m.set(a[_+3],a[_+4],a[_+5]),p.set(a[_+6],a[_+7],a[_+8]),v.set(l[x+0],l[x+1]),y.set(l[x+2],l[x+3]),b.set(l[x+4],l[x+5]),g.copy(d).add(m).add(p).divideScalar(3);let M=w(g);S(v,x+0,d,M),S(y,x+2,m,M),S(b,x+4,p,M)}for(let _=0;_<l.length;_+=6){let x=l[_+0],M=l[_+2],E=l[_+4],C=Math.max(x,M,E),P=Math.min(x,M,E);C>.9&&P<.1&&(x<.2&&(l[_+0]+=1),M<.2&&(l[_+2]+=1),E<.2&&(l[_+4]+=1))}function w(_){return Math.atan2(_.z,-_.x)}function A(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(e){return new Wo(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};var YM=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new ff(e*.5,s,o):new Hl(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},ff=class extends Wo{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,e,t,n),this.type=l}static fromJSON(e){return new ff(e.radius,e.corner,e.cornerSides)}};var vx=Math.PI*2;function gx({x:r,y:e},t,n,i,s){return{x:r*t+i,y:e*n+s}}function iH(r,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+e),o=Math.sin(r+e);return[{x:n-i*t,y:i+n*t},{x:s+o*t,y:o-s*t},{x:s,y:o}]}function QM(r,e,t,n){let i=r*n-e*t<0?-1:1,s=Math.min(1,Math.max(-1,r*t+e*n));return i*Math.acos(s)}function sH(r,e,t,n,i,s,o,a,l,u){let c=Math.pow(i,2),h=Math.pow(s,2),f=Math.pow(o,2),d=Math.pow(a,2),m=c*h-c*d-h*f;m<0&&(m=0),m/=c*d+h*f,m=Math.sqrt(m)*(l===u?-1:1);let p=m*i/s*a,g=m*-s/i*o,v=p+(r+t)/2,y=g+(e+n)/2,b=(o-p)/i,S=(a-g)/s,w=(-o-p)/i,A=(-a-g)/s,_=QM(1,0,b,S),x=QM(b,S,w,A);return!u&&x>0&&(x-=vx),u&&x<0&&(x+=vx),{centerx:v,centery:y,ang1:_,ang2:x}}function ZM({px:r,py:e,cx:t,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let u=(r-t)/2,c=(e-n)/2;if(u===0&&c===0)return[];i=Math.abs(i),s=Math.abs(s);let h=Math.pow(u,2)/Math.pow(i,2)+Math.pow(c,2)/Math.pow(s,2);h>1&&(i*=Math.sqrt(h),s*=Math.sqrt(h));let f=sH(r,e,t,n,i,s,u,c,o,a),{ang1:d,ang2:m}=f,{centerx:p,centery:g}=f,v=Math.abs(m)/(vx/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);m/=y;for(let b=0;b<y;b++)l.push(iH(d,m)),d+=m;return l.map(b=>{let{x:S,y:w}=gx(b[0],i,s,p,g),{x:A,y:_}=gx(b[1],i,s,p,g),{x,y:M}=gx(b[2],i,s,p,g);return{x1:S,y1:w,x2:A,y2:_,x,y:M}})}var JM=Math.PI*2,$M=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof At?r.shape:new At,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u=r.shape,c=e*.5,h=t*.5,f=oH(u,c,h,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let d=Qr.create({shape:u,parameters:{subdivisions:f,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(d,{userData:{...r,type:"EllipseGeometry"}})}};function oH(r,e,t,n,i,s){if(n>=JM)return i>30||i%4===0?(lH(r,e,t,s),Math.round(i/4)):KM(r,n,i,e,t,s);let o={x:0,y:t},a=n+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},u=ZM({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%u.length===0?aH(r,o.x,o.y,u,i,e,t,s):KM(r,n,i,e,t,s)}function aH(r,e,t,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(ou(e,t));for(let u=0,c=n.length;u<c;u++){let h=n[u],f=r.points[u],d=ou(h.x,h.y);f.controls[1].position.set(h.x1,h.y1),d.controls[0].position.set(h.x2,h.y2),r.addPoint(d)}return a>0?eE(r,s,o,a):r.addPoint(ou(0,0)),l}function KM(r,e,t,n,i,s){let o=-e/t;for(let a=0;a<=t;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*i;r.addPoint(ou(u,c))}return e<JM?s>0?eE(r,n,i,s):r.addPoint(ou(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&tE(r,n,i,s)),1}function lH(r,e,t,n=0,i=0,s=0){let o=.5522847498,a=e*o,l=t*o;r.addPoint(Km(i-e,s,i-e,s-l,i-e,s+l)),r.addPoint(Km(i,s+t,i-a,s+t,i+a,s+t)),r.addPoint(Km(i+e,s,i+e,s+l,i+e,s-l)),r.addPoint(Km(i,s-t,i+a,s-t,i-a,s-t)),n>0&&tE(r,e,t,n)}function ou(r,e){return new Ii(ze.generateUUID(),new k(r,e))}function Km(r,e,t,n,i,s){let o=ou(r,e);return o.controls[0].position.set(t,n),o.controls[1].position.set(i,s),o}function eE(r,e,t,n){rE(r,e,t,n).forEach(s=>r.addPoint(s))}function tE(r,e,t,n){let i=rE(r,e,t,n),s=new At;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function rE(r,e,t,n){let i=n*e/100,s=i*(Math.abs(t)/Math.abs(e)),o=new k(i/e,s/t),a=r.points.map(l=>{let u=l.clone();return u.uuid=ze.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var nE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??n),s=Math.abs(t.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(t,{width:n,height:i,depth:s,radius:o,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(r){let{width:e,height:t,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:h}=r.parameters,f=new df(!1,e,t,n,i,s,o,a,l,u,c,h);return Object.assign(f,{userData:{...r,type:"HelixGeometry"}})}},df=class extends Le{constructor(e=!0,t=1,n=1,i=1,s=1,o=1,a=1,l=1,u=1,c=1,h=1,f=1){super();let d=e&&o===1;d&&(f=0),h>100&&(h=100);let m=()=>new T,p=new T,g=m(),v=m(),y=m(),b,S,w,A,_,x,M,E,C=m(),P=m(),L=m(),D=m(),R=m(),N=m(),U=m(),X=m(),F=n-2*l+.001,G=F/o,j=Math.ceil(a*o),z=j+1,V=F/j,q=-F/2,Y=c+1,H=2*Math.PI/c,fe=Math.PI/2/f,ne=.01,K=Math.min((1-h/100)*l,l-ne),Q=l-K,ie=0,ue=2,ae=f*ue+ue,Me=Y*ae/ue,ge=Me+Y*z,ve=Y*(z+ae),[ye,de,Ie]=[3,3,2].map(xe=>Array(ve*xe).fill(0)),Ge=[],tt=s-l;function B(xe,W){let be=Math.PI/2;x=W*V,E=2*Math.PI*(x%G)/G+be,x+=q,M=Math.sin(E)*tt,_=Math.cos(E)*tt,e?xe.set(_,M,x):xe.set(_,x,M)}B(p,-1e-10),B(g,0),C.copy(p),B(p,1);let I=p.distanceTo(g),J=Q+K,ce=I*j+2*J,pe=K,Ce=ce-J;for(let xe=0;xe<=j;xe++){B(v,xe),X.subVectors(v,C).normalize(),C.copy(v),N.copy(v).setComponent(+e+1,0).normalize(),U.crossVectors(X,N).normalize();let W=xe===0,be=xe===j,_e=W?3*Math.PI/2:fe,et=W?pe:Ce,Fe=W?Y:ge,nt=W?0:ve-Y,Se=X.clone().multiplyScalar(W?-Q:Q).add(v),it=X.clone().multiplyScalar(W?-1:1).normalize();for(let ht=0;ht<Y;ht++){let Tt=ht*H;if(P.addVectors(p.copy(N).multiplyScalar(l*Math.cos(Tt)),g.copy(U).multiplyScalar(l*Math.sin(Tt))),L.copy(P).normalize(),W||be){d||(ie=nt+ht,[0,1,2].forEach(Pt=>{ye[ie*3+Pt]=Se.getComponent(Pt),de[ie*3+Pt]=it.getComponent(Pt)}),Ie[ie*2]=+be,Ie[ie*2+1]=ht/c),g.copy(L).multiplyScalar(K),y.addVectors(v,g);for(let Pt=0;Pt<f;Pt++){let An=Pt*fe+_e;D.addVectors(p.copy(X).multiplyScalar(Q*Math.sin(An)),g.copy(L).multiplyScalar(Q*Math.cos(An))),R.copy(D).normalize(),g.addVectors(y,D),D.normalize(),ie=Fe+Pt*Y+ht,[0,1,2].forEach(fl=>{ye[ie*3+fl]=g.getComponent(fl),de[ie*3+fl]=R.getComponent(fl)});let Sd=+W+Math.sin(An);Ie[ie*2]=(et+Q*Sd)/ce,Ie[ie*2+1]=ht/c}}g.addVectors(v,P),ie=Me+xe*Y+ht,[0,1,2].forEach(Pt=>{ye[ie*3+Pt]=g.getComponent(Pt),de[ie*3+Pt]=L.getComponent(Pt)}),Ie[ie*2]=(J+xe*I)/ce,Ie[ie*2+1]=ht/c}}let He=z+2*f+ue,se=1,[Ve,Ne]=d?[se,se+z-1]:[0,He-1];for(let xe=Ve;xe<=Ne-1;xe++){let W=d&&xe===Ne-1;for(let be=0;be<Y-1;be++)b=xe*Y+be,S=b+1,w=(W?be:b)+Y,A=(W?be+1:S)+Y,xe===0?Ge.push(S,A,w):xe===He-2?Ge.push(b,S,w):Ge.push(b,S,w,S,A,w)}this.setIndex(Ge),this.setAttribute("position",new Te(ye,3)),this.setAttribute("normal",new Te(de,3)),this.setAttribute("uv",new Te(Ie,2))}};var iE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new pf(e*.5,s,o):new jl(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},pf=class extends Wo{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,e,t,n),this.type=a}static fromJSON(e){return new pf(e.radius,e.corner,e.cornerSides)}};var sE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){(r.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let t=Object.assign({},e?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{points:e,segments:t,verticalSegments:n}=r.parameters,i=new Vs;i.moveTo(e[0].x,e[0].y),i.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new Gl(i.extractPoints(n).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var cs=new we,yx=new yt,Jm=new T,jo=class extends kt{constructor(){super(),this.uuid=ze.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new Kt().getNormalMatrix(e);for(let n=0,i=this.vertices.length;n<i;n++)this.vertices[n].applyMatrix4(e);for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];s.normal.applyMatrix3(t).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return cs.makeRotationX(e),this.applyMatrix4(cs),this}rotateY(e){return cs.makeRotationY(e),this.applyMatrix4(cs),this}rotateZ(e){return cs.makeRotationZ(e),this.applyMatrix4(cs),this}translate(e,t,n){return cs.makeTranslation(e,t,n),this.applyMatrix4(cs),this}scale(e,t,n){return cs.makeScale(e,t,n),this.applyMatrix4(cs),this}lookAt(e){return yx.lookAt(e),yx.updateMatrix(),this.applyMatrix4(yx.matrix),this}fromBufferGeometry(e){let t=this,n=e.index!==null?e.index:void 0,i=e.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,u=i.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let f=0;f<s.count;f++)t.vertices.push(new T().fromBufferAttribute(s,f)),a!==void 0&&t.colors.push(new Be().fromBufferAttribute(a,f));function c(f,d,m,p){let g=a===void 0?[]:[t.colors[f].clone(),t.colors[d].clone(),t.colors[m].clone()],v=o===void 0?[]:[new T().fromBufferAttribute(o,f),new T().fromBufferAttribute(o,d),new T().fromBufferAttribute(o,m)],y=new au(f,d,m,v,g,p);t.faces.push(y),l!==void 0&&t.faceVertexUvs[0].push([new k().fromBufferAttribute(l,f),new k().fromBufferAttribute(l,d),new k().fromBufferAttribute(l,m)]),u!==void 0&&t.faceVertexUvs[1].push([new k().fromBufferAttribute(u,f),new k().fromBufferAttribute(u,d),new k().fromBufferAttribute(u,m)])}let h=e.groups;if(h.length>0)for(let f=0;f<h.length;f++){let d=h[f],m=d.start,p=d.count;for(let g=m,v=m+p;g<v;g+=3)n!==void 0?c(n.getX(g),n.getX(g+1),n.getX(g+2),d.materialIndex):c(g,g+1,g+2,d.materialIndex)}else if(n!==void 0)for(let f=0;f<n.count;f+=3)c(n.getX(f),n.getX(f+1),n.getX(f+2));else for(let f=0;f<s.count;f+=3)c(f,f+1,f+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Jm).negate(),this.translate(Jm.x,Jm.y,Jm.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,n=t===0?1:1/t,i=new we;return i.set(n,0,0,-n*e.x,0,n,0,-n*e.y,0,0,n,-n*e.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let e=new T,t=new T;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];e.subVectors(l,a),t.subVectors(o,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let n=0,i=this.vertices.length;n<i;n++)t[n]=new T;if(e){let n=new T,i=new T;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),i.subVectors(l,u),n.cross(i),t[a.a].add(n),t[a.b].add(n),t[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let n=0,i=this.vertices.length;n<i;n++)t[n].normalize();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(t[s.a]),o[1].copy(t[s.b]),o[2].copy(t[s.c])):(o[0]=t[s.a].clone(),o[1]=t[s.b].clone(),o[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let n=this.faces[e],i=n.vertexNormals;i.length===3?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let e=new jo;e.faces=this.faces;for(let t=0,n=this.morphTargets.length;t<n;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,o=this.morphNormals[t].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new T,c={a:new T,b:new T,c:new T};s.push(u),o.push(c)}}let i=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],u=i.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Lt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Fr),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,n=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let i,s=this.vertices.length,o=this.vertices,a=e.vertices,l=this.faces,u=e.faces,c=this.colors,h=e.colors;t!==void 0&&(i=new Kt().getNormalMatrix(t));for(let f=0,d=a.length;f<d;f++){let p=a[f].clone();t!==void 0&&p.applyMatrix4(t),o.push(p)}for(let f=0,d=h.length;f<d;f++)c.push(h[f].clone());for(let f=0,d=u.length;f<d;f++){let m=u[f],p,g,v=m.vertexNormals,y=m.vertexColors,b=new au(m.a+s,m.b+s,m.c+s);b.normal.copy(m.normal),i!==void 0&&b.normal.applyMatrix3(i).normalize();for(let S=0,w=v.length;S<w;S++)p=v[S].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),b.vertexNormals.push(p);b.color.copy(m.color);for(let S=0,w=y.length;S<w;S++)g=y[S],b.vertexColors.push(g.clone());b.materialIndex=m.materialIndex+n,l.push(b)}for(let f=0,d=e.faceVertexUvs.length;f<d;f++){let m=e.faceVertexUvs[f];this.faceVertexUvs[f]===void 0&&(this.faceVertexUvs[f]=[]);for(let p=0,g=m.length;p<g;p++){let v=m[p],y=[];for(let b=0,S=v.length;b<S;b++)y.push(v[b].clone());this.faceVertexUvs[f].push(y)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},n=[],i=[],s=Math.pow(10,e);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],h=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);t[h]===void 0?(t[h]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[t[h]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=i[c.a],c.b=i[c.b],c.c=i[c.c];let h=[c.a,c.b,c.c];for(let f=0;f<3;f++)if(h[f]===h[(f+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,h=this.faceVertexUvs.length;c<h;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(e){this.vertices=[];for(let t=0,n=e.length;t<n;t++){let i=e[t];this.vertices.push(new T(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let l=0;l<t;l++)e[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}e.sort(n);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===t&&(o=[]),s&&s.length===t&&(a=[]);for(let l=0;l<t;l++){let u=e[l]._id;o&&o.push(i[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let p in m)m[p]!==void 0&&(e[p]=m[p]);return e}let t=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];t.push(p.x,p.y,p.z)}let n=[],i=[],s={},o=[],a={},l=[],u={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,v=!1,y=this.faceVertexUvs[0][m]!==void 0,b=p.normal.length()>0,S=p.vertexNormals.length>0,w=p.color.r!==1||p.color.g!==1||p.color.b!==1,A=p.vertexColors.length>0,_=0;if(_=c(_,0,0),_=c(_,1,g),_=c(_,2,v),_=c(_,3,y),_=c(_,4,b),_=c(_,5,S),_=c(_,6,w),_=c(_,7,A),n.push(_),n.push(p.a,p.b,p.c),n.push(p.materialIndex),y){let x=this.faceVertexUvs[0][m];n.push(d(x[0]),d(x[1]),d(x[2]))}if(b&&n.push(h(p.normal)),S){let x=p.vertexNormals;n.push(h(x[0]),h(x[1]),h(x[2]))}if(w&&n.push(f(p.color)),A){let x=p.vertexColors;n.push(f(x[0]),f(x[1]),f(x[2]))}}function c(m,p,g){return g?m|1<<p:m&~(1<<p)}function h(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(m.x,m.y,m.z)),s[p]}function f(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function d(m){let p=m.x.toString()+m.y.toString();return u[p]!==void 0||(u[p]=l.length/2,l.push(m.x,m.y)),u[p]}return e.data={},e.data.vertices=t,e.data.normals=i,o.length>0&&(e.data.colors=o),l.length>0&&(e.data.uvs=[l]),e.data.faces=n,e}clone(){return new jo().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let f=0,d=t.length;f<d;f++)this.vertices.push(t[f].clone());let n=e.colors;for(let f=0,d=n.length;f<d;f++)this.colors.push(n[f].clone());let i=e.faces;for(let f=0,d=i.length;f<d;f++)this.faces.push(i[f].clone());for(let f=0,d=e.faceVertexUvs.length;f<d;f++){let m=e.faceVertexUvs[f];this.faceVertexUvs[f]===void 0&&(this.faceVertexUvs[f]=[]);for(let p=0,g=m.length;p<g;p++){let v=m[p],y=[];for(let b=0,S=v.length;b<S;b++){let w=v[b];y.push(w.clone())}this.faceVertexUvs[f].push(y)}}let s=e.morphTargets;for(let f=0,d=s.length;f<d;f++){let m={};if(m.name=s[f].name,s[f].vertices!==void 0){m.vertices=[];for(let p=0,g=s[f].vertices.length;p<g;p++)m.vertices.push(s[f].vertices[p].clone())}if(s[f].normals!==void 0){m.normals=[];for(let p=0,g=s[f].normals.length;p<g;p++)m.normals.push(s[f].normals[p].clone())}this.morphTargets.push(m)}let o=e.morphNormals;for(let f=0,d=o.length;f<d;f++){let m={};if(o[f].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[f].vertexNormals.length;p<g;p++){let v=o[f].vertexNormals[p],y={};y.a=v.a.clone(),y.b=v.b.clone(),y.c=v.c.clone(),m.vertexNormals.push(y)}}if(o[f].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[f].faceNormals.length;p<g;p++)m.faceNormals.push(o[f].faceNormals[p].clone())}this.morphNormals.push(m)}let a=e.skinWeights;for(let f=0,d=a.length;f<d;f++)this.skinWeights.push(a[f].clone());let l=e.skinIndices;for(let f=0,d=l.length;f<d;f++)this.skinIndices.push(l[f].clone());let u=e.lineDistances;for(let f=0,d=u.length;f<d;f++)this.lineDistances.push(u[f]);let c=e.boundingBox;c!==null&&(this.boundingBox=c.clone());let h=e.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new xx().fromGeometry(this),t=new Le,n=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",new We(n,3).copyVector3sArray(e.vertices)),e.normals.length>0){let i=new Float32Array(e.normals.length*3);t.setAttribute("normal",new We(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){let i=new Float32Array(e.colors.length*3);t.setAttribute("color",new We(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){let i=new Float32Array(e.uvs.length*2);t.setAttribute("uv",new We(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){let i=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",new We(i,2).copyVector2sArray(e.uvs2))}t.groups=e.groups;for(let i in e.morphTargets){let s=[],o=e.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new Te(u.data.length*3,3);c.name=u.name,s.push(c.copyVector3sArray(u.data))}t.morphAttributes[i]=s}if(e.skinIndices.length>0){let i=new Te(e.skinIndices.length*4,4);t.setAttribute("skinIndex",i.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){let i=new Te(e.skinWeights.length*4,4);t.setAttribute("skinWeight",i.copyVector4sArray(e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new Le,n=e.geometry;if(e.isPoints||e.isLine){let i=new Te(n.vertices.length*3,3),s=new Te(n.colors.length*3,3);if(t.setAttribute("position",i.copyVector3sArray(n.vertices)),t.setAttribute("color",s.copyColorsArray(n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new Te(n.lineDistances.length,1);t.setAttribute("lineDistance",o.copyArray(n.lineDistances))}n.boundingSphere!==null&&(t.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(t.boundingBox=n.boundingBox.clone())}else e.isMesh&&(t=n.toBufferGeometry());return t}};jo.prototype.isGeometry=!0;var xx=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],n,i,s,o=e.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=i*3-n.start,t.push(n)),n={start:i*3,materialIndex:s})}n!==void 0&&(n.count=i*3-n.start,t.push(n)),this.groups=t}fromGeometry(e){let t=e.faces,n=e.vertices,i=e.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=e.morphTargets,l=a.length,u;if(l>0){u=[];for(let v=0;v<l;v++)u[v]={name:a[v].name,data:[]};this.morphTargets.position=u}let c=e.morphNormals,h=c.length,f;if(h>0){f=[];for(let v=0;v<h;v++)f[v]={name:c[v].name,data:[]};this.morphTargets.normal=f}let d=e.skinIndices,m=e.skinWeights,p=d.length===n.length,g=m.length===n.length;n.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let v=0;v<t.length;v++){let y=t[v];this.vertices.push(n[y.a],n[y.b],n[y.c]);let b=y.vertexNormals;if(b.length===3)this.normals.push(b[0],b[1],b[2]);else{let w=y.normal;this.normals.push(w,w,w)}let S=y.vertexColors;if(S.length===3)this.colors.push(S[0],S[1],S[2]);else{let w=y.color;this.colors.push(w,w,w)}if(s===!0){let w=i[0][v];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",v),this.uvs.push(new k,new k,new k))}if(o===!0){let w=i[1][v];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",v),this.uvs2.push(new k,new k,new k))}for(let w=0;w<l;w++){let A=a[w].vertices;u[w].data.push(A[y.a],A[y.b],A[y.c])}for(let w=0;w<h;w++){let A=c[w].vertexNormals[v];f[w].data.push(A.a,A.b,A.c)}p&&this.skinIndices.push(d[y.a],d[y.b],d[y.c]),g&&this.skinWeights.push(m[y.a],m[y.b],m[y.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},au=class{constructor(e,t,n,i,s,o=0){this.a=e,this.b=t,this.c=n,this.normal=i&&i.isVector3?i:new T,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Be,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};var cH=["a","b","c"];function uH(r,e){switch(e){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function bx(r,e,t){let n=Math.min(r,e),i=Math.max(r,e),s=n+"_"+i;return t.get(s)}function Sx(r,e,t,n,i,s){let o=Math.min(r,e),a=Math.max(r,e),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=t[o],h=t[a];u={a:c,b:h,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(i),s[r].edges.push(u),s[e].edges.push(u)}function hH(r,e,t,n){let i,s,o;for(i=0,s=r.length;i<s;i++)t[i]={edges:[]};for(i=0,s=e.length;i<s;i++)o=e[i],Sx(o.a,o.b,r,n,o,t),Sx(o.b,o.c,r,n,o,t),Sx(o.c,o.a,r,n,o,t)}function $m(r,e,t,n,i){r.push(new au(e,t,n,void 0,void 0,i))}function lu(r,e){return Math.abs(e-r)/2+Math.min(r,e)}function eg(r,e,t,n){r.push([e.clone(),t.clone(),n.clone()])}var tg=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Le?e=new jo().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new T,n,i,s,o,a,l=e.vertices,u=e.faces,c=e.faceVertexUvs[0],h=c!==void 0&&c.length>0,f=[],d=new Map;hH(l,u,f,d);let m=[],p,g,v,y,b,S,w;for(let ne of Array.from(d.keys())){for(g=d.get(ne),v=new T,b=3/8,S=1/8,w=g.faces.length,w!=2&&(b=.5,S=0,w!=1),v.addVectors(g.a,g.b).multiplyScalar(b),t.set(0,0,0),o=0;o<w;o++){for(y=g.faces[o],a=0;a<3&&(p=l[uH(y,cH[a])],!(p!==g.a&&p!==g.b));a++);p&&t.add(p)}t.multiplyScalar(S),v.add(t),g.newEdge=m.length,m.push(v)}let A,_,x,M,E,C,P,L=[];for(i=0,s=l.length;i<s;i++){for(C=l[i],E=f[i].edges,n=E.length,n==3?A=3/16:n>3&&(A=3/(8*n)),_=1-n*Number(A),x=A,n<=2&&(n==2?(_=3/4,x=1/8):n==1||n==0),P=C.clone().multiplyScalar(_),t.set(0,0,0),o=0;o<n;o++)M=E[o],p=M.a!==C?M.a:M.b,t.add(p);t.multiplyScalar(Number(x)),P.add(t),L.push(P)}let D=L.concat(m),R=L.length,N,U,X,F=[],G=[],j,z,V,q,Y=new k,H=new k,fe=new k;for(i=0,s=u.length;i<s;i++)y=u[i],N=Number(bx(y.a,y.b,d).newEdge)+R,U=Number(bx(y.b,y.c,d).newEdge)+R,X=Number(bx(y.c,y.a,d).newEdge)+R,$m(F,N,U,X,y.materialIndex),$m(F,y.a,N,X,y.materialIndex),$m(F,y.b,U,N,y.materialIndex),$m(F,y.c,X,U,y.materialIndex),h&&(j=c[i],z=j[0],V=j[1],q=j[2],Y.set(lu(z.x,V.x),lu(z.y,V.y)),H.set(lu(V.x,q.x),lu(V.y,q.y)),fe.set(lu(z.x,q.x),lu(z.y,q.y)),eg(G,Y,H,fe),eg(G,z,Y,fe),eg(G,V,H,Y),eg(G,q,fe,H));e.vertices=D,e.faces=F,h&&(e.faceVertexUvs[0]=G)}};var Pr=new T,oE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=r.geometry??e?.geometry??new Le().copy(new Tn(100,100,100)),n;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(Pr),n={width:Pr.x,height:Pr.y,depth:Pr.z,subdivisions:0}):n=e.parameters;let i={...n,...r.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:t}}static build(r){let{width:e,height:t,depth:n,subdivisions:i}=r.parameters,s=r.geometry??new Le().copy(new Tn(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Pr)):Pr.set(o.width,o.height,o.depth),(e!==Pr.x||t!==Pr.y||n!==Pr.z)&&s.scale(Pr.x===0?1:e/Pr.x,Pr.y===0?1:t/Pr.y,Pr.z===0?1:n/Pr.z);let a=s.originalGeometry;return i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new tg(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,e,t){new Kl(t).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(Pr);let o=100/Pr.x;Object.assign(s.parameters,{width:100,height:Pr.y*o,depth:Pr.z*o}),e(this.build(s))})}};var aE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof At?r.shape:new At,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=r.parameters,l=r.shape,u=e*.5,c=t*.5,h=0,f=0,d=2*Math.PI/n;for(let p=0;p<n;p++){let g=d*p,v=h+Math.sin(g)*u,y=f+Math.cos(g)*c;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=i;l.roundness=i,l.update();let m=Qr.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...r,type:"PolygonGeometry"}})}};var lE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=new Ax(e*.5,t,i,s,o,a,l);return u.scale(1,1,n/e),Object.assign(u,{userData:{...r,type:"PyramidGeometry"}})}};function mf(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function wx(r,e,t,n,i,s){let o=e.clone().sub(r),a=t.clone().sub(r),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===i){let u=o.add(a).normalize();s.copy(r).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(r),s.addScaledVector(o,i/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function fH(r,e,t){let n=r.clone().sub(e),i=t.clone().sub(e);return n.projectOnVector(i),n.add(e)}var Ax=class extends Le{constructor(e=.5,t=1,n=4,i=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),i=Math.floor(i),a=Math.floor(a);let l=[],u=[],c=[],h=[],f=0,d=t/2,m=Math.PI/n,p=e*Math.cos(Math.PI/n),g=2*Math.PI/n,v=(n-2)*Math.PI/n,y=Math.PI-v,b=new T(0,-d,0),S=new T(0,d,0),w=new k(e,-d),A=new k(p,-d),_=new k(0,S.y).sub(A),x=new k(0,S.y).sub(w),M=new k(_.y,-_.x).normalize(),E=new k(x.y,-x.x).normalize(),P=e*Math.cos(Math.PI/n)*Math.tan((Math.PI-_.angle())/2)-1e-8;o=Math.min(o,P);let L;{let G=new T(M.x,M.y,0),j=new T(Math.cos(g)*G.x,G.y,Math.sin(g)*G.x);L=G.angleTo(j)}let D=o/Math.tan((Math.PI-_.angle())/2),R=o/Math.tan((Math.PI-L)/2),N=new T;if(!s){u.push(b.x,b.y,b.z),c.push(0,-1,0),h.push(0,0);let G=f++,j=[],z=w.clone(),V=D/Math.cos(Math.PI/n);z.x-=V;for(let q=0;q<n;q++){let Y=q/n*Math.PI*2+m,H=new k(Math.sin(Y),Math.cos(Y));mf(z,H,N),u.push(N.x,N.y,N.z),c.push(0,-1,0),h.push(0,0),j.push(f++)}for(let q=0;q<j.length;q++)l.push(j[q],G,j[(q+1)%j.length])}let U=[];{let G=new T,j=new T,z=new T,V=new T,q=new T,Y=new T;for(let H=0;H<n;H++){let fe=H/n*Math.PI*2+m,ne=(H+.5)/n*Math.PI*2+m,K=(H+1)/n*Math.PI*2+m,Q=new k(Math.sin(fe),Math.cos(fe)),ie=new k(Math.sin(ne),Math.cos(ne)),ue=new k(Math.sin(K),Math.cos(K));mf(w,Q,j),mf(w,ue,z),mf(M,ie,G),wx(S,j,z,R,R,V),u.push(V.x,V.y,V.z),wx(j,S,z,R,D,q),u.push(q.x,q.y,q.z),wx(z,j,S,D,R,Y),u.push(Y.x,Y.y,Y.z),c.push(G.x,G.y,G.z),c.push(G.x,G.y,G.z),c.push(G.x,G.y,G.z),h.push(0,0),h.push(0,0),h.push(0,0);let ae=f++,Me=f++,ge=f++;if(l.push(ae,Me,ge),o>0){{let de=j.clone().add(z).multiplyScalar(.5),Ie=S.clone().sub(de).normalize(),tt=b.clone().sub(de).normalize().add(Ie).normalize().multiplyScalar(-1),B=Y.clone().sub(q);X(de,B,tt,_.angle())}let ve,ye;{let de=new T;mf(E,ue,de);let Ie=Y.clone().add(V).multiplyScalar(.5);Ie=fH(Ie,z,S);let Ge=Y.clone().sub(V);[ve,ye]=X(Ie,Ge,de,L,V.y)}{let de=ve,Ie=de.clone().setY(0).normalize(),Ge=new T(0,-1,0),tt=Ie.clone().cross(Ge);F(de,Ie,Ge,tt)}U.concat(ye);{let de=_.angle(),Ie=Math.PI-de,Ge=S.clone();Ge.y-=o/Math.sin(de-Math.PI/2);let tt=new T,B=[];for(let J=0;J<a;J++){let ce=[],pe=Math.PI/2-Ie*J/a,Ce=Math.cos(pe),He=Math.sin(pe),se=ne;for(let Ve=0;Ve<=J;Ve++){let Ne=Math.cos(se),xe=Math.sin(se);G.x=Ce*xe,G.y=He,G.z=Ce*Ne,tt.copy(Ge).addScaledVector(G,o),u.push(tt.x,tt.y,tt.z),c.push(G.x,G.y,G.z),h.push(0,0),ce.push(f++),se+=Math.PI*2/J/n}B.push(ce)}ye.reverse(),B.push(ye);let I=B.length-1;for(let J=0;J<I;J++){let ce=B[J],pe=B[J+1],Ce=ce.length-1;l.push(pe[1],ce[0],pe[0]);for(let He=1;He<=Ce;He++)l.push(ce[He],ce[He-1],pe[He]),l.push(pe[He+1],ce[He],pe[He])}}}}}this.setIndex(l),this.setAttribute("position",new Te(u,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(h,2));function X(G,j,z,V,q){let Y=-V/2,H=(Math.PI-V)/2,fe=j.clone().normalize().cross(z);G.addScaledVector(z,-o/Math.sin(H));let ne=new T,K=new T,Q=1,ie=f,ue=[];for(let ae=0;ae<=a;ae++){let Me=Y+ae/a*V;K.set(0,0,0),K.addScaledVector(fe,Math.sin(Me)),K.addScaledVector(z,Math.cos(Me));for(let ge=0;ge<=Q;ge++){let ve=ge/Q-.5;if(ne.copy(G),ne.addScaledVector(j,ve),ne.addScaledVector(K,o),q!=null){let ye=Math.max(0,ne.y-q);ne.addScaledVector(j,-ye/j.y)}u.push(ne.x,ne.y,ne.z),c.push(K.x,K.y,K.z),h.push(0,0),ge===0&&ue.push(f),f++}}for(let ae=0;ae<a;ae++)for(let Me=0;Me<Q;Me++){let ge=ie+Me+(Q+1)*ae,ve=ge+(Q+1),ye=ve+1,de=ge+1;l.push(ge,ve,de),l.push(ve,ye,de)}return[G.clone().addScaledVector(j,.5),ue]}function F(G,j,z,V){let q=Math.PI/2,Y=x.angle()-q,H=[],fe=new T,ne=new T;for(let Q=0;Q<=a;Q++){let ie=[],ue=Q/a;for(let ae=0;ae<=Q;ae++){let ge=((Q?ae/Q:0)-.5)*y,ve=Math.cos(ge),ye=Math.sin(ge),de=Math.atan(Math.tan(Y)*ve),Ie=(q+de)*ue,Ge=Math.cos(Ie),tt=Math.sin(Ie);fe.set(0,0,0),fe.addScaledVector(j,tt*ve),fe.addScaledVector(z,Ge),fe.addScaledVector(V,tt*ye),ne.copy(G).addScaledVector(fe,o),u.push(ne.x,ne.y,ne.z),c.push(fe.x,fe.y,fe.z),h.push(0,0),ie.push(f++)}H.push(ie)}let K=H.length-1;for(let Q=0;Q<K;Q++){let ie=H[Q],ue=H[Q+1],ae=ie.length-1;l.push(ie[0],ue[1],ue[0]);for(let Me=1;Me<=ae;Me++)l.push(ie[Me-1],ie[Me],ue[Me]),l.push(ie[Me],ue[Me+1],ue[Me])}}}};var cE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters),n=Object.assign(e?.ui??{enabledIndieCorners:!1},r.ui);return{shape:r.shape&&r.shape instanceof At?r.shape:new At,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)}),ui:n}}static build(r){let e=r.shape,{width:t,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u={x:t*.5,y:n*.5},c={x:-u.x,y:-u.y},h={x:u.x,y:u.y};function f(S,w,A){return w>t&&A>n?Math.min(S*t/w,S*n/A):w>t?S*t/w:A>n?S*n/A:S}let d=[];d[0]=i[0]===0?0:f(i[0],i[0]+i[3],i[0]+i[1]),d[1]=i[1]===0?0:f(i[1],i[1]+i[2],i[1]+i[0]),d[2]=i[2]===0?0:f(i[2],i[2]+i[1],i[2]+i[3]),d[3]=i[3]===0?0:f(i[3],i[3]+i[0],i[3]+i[2]);let m=c.x,p=h.x,g=h.y,v=c.y;e.addPoint(e.createPoint(m,g)),e.addPoint(e.createPoint(p,g)),e.addPoint(e.createPoint(p,v)),e.addPoint(e.createPoint(m,v)),e.isClosed=!0;let y=!0;for(let S=0,w=e.points.length;S<w;S++)e.points[S].roundness=d[S],S>0&&d[S]!==d[S-1]&&(y=!1);y&&(e.roundness=d[0]),e.useCubicForRoundedCorners=s!==1,e.update();let b=Qr.create({shape:e,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...r,type:"RectangleGeometry"}})}};var uE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e=100,height:t=e,depth:n=e,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=r.parameters,c=new Ea(.5*e,i,s,o,a,l,u);return c.scale(1,t/e,n/e),Object.assign(c,{userData:{...r,type:"SphereGeometry"}})}};var hE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:0})}}static build(r){let{width:e=100,height:t=e,widthSegments:n=8,heightSegments:i=8}=r.parameters,s=new zs(e,t,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var fE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,angle:i,cornerRadius:s,cornerSegments:o}=r.parameters,a=new Tx(e,t,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},Tx=class extends Le{constructor(e=1,t=1,n=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-c,i),i*=Math.PI/180;let h=[],f=Math.PI/2,d=(ne=0,K=0,Q=0)=>new T(ne,K,Q),m=d(),p=d(),[g,v,y]=[t/2,e/2,n/2],b=-v,S=+v,[w,A,_]=[d(b,-g,+y),d(b,-g,-y),d(b,+g,-y)],x=(ne,K=!1)=>Math.sin(ne-Math.PI/(1+ +K)),M=(ne,K=!1)=>Math.cos(ne-Math.PI/(1+ +K));_.y=Math.sin(i)*t-g;let E=Math.cos(i)*t-y,C=w.z-c;i<=f?(_.z=Math.min(E,C),_.z==C&&(_.y-=(E-C)/Math.tan(f-i))):A.z=Math.min(A.z-E-y,w.z-c),m.subVectors(w,A),p.subVectors(_,A);let P=Math.min(m.length(),p.length())*s/100,L=P*Math.tan(i/2),D=P/Math.cos(i/2),R=m.clone().normalize().add(p.normalize()).setLength(D).add(A);m.set(0,x(i,!0),M(i,!0)),h.push([_,m.clone()]);let N=(Math.PI-i)/o;for(let ne=0;ne<=o;ne++){let K=f+i+ne*N;m.set(0,Math.sin(K)*L,Math.cos(K)*L),m.add(R),p.set(0,x(K),M(K)),h.push([m.clone(),p.clone()])}h.push([w,d(0,1,0)]);let U=Math.sin(N/2)*L*2,X=h.length-1,F=h[0][0].distanceTo(h[1][0]),G=h[X-1][0].distanceTo(h[X][0]),j=F+U*o+G;h[0].push(1);for(let ne=0;ne<=o;ne++)h[ne+1].push(1-(F+ne*U)/j);h[X].push(0);let[z,V,q]=h[0],Y,H,fe;for(let ne=1;ne<h.length;ne++)[Y,H,fe]=h[ne],a.push(b,z.y,z.z,b,Y.y,Y.z,S,z.y,z.z,S,z.y,z.z,b,Y.y,Y.z,S,Y.y,Y.z),l.push(0,V.y,V.z,0,H.y,H.z,0,V.y,V.z,0,V.y,V.z,0,H.y,H.z,0,H.y,H.z),u.push(0,q,0,fe,1,q,1,q,0,fe,1,fe),[z,V,q]=[Y,H,fe];this.setAttribute("position",new Te(a,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(u,2))}};var dE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof At?r.shape:new At,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=r.parameters,c=r.shape,h=e*.5,f=t*.5,d=0,m=0,p=o*Math.PI/360/i,g=Math.PI/2*3*-1,v=h*n/100,y=f*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let S=0;S<i;S++){let w=p*S,A=d+Math.sin(w)*h,_=m+Math.cos(w)*f;c.addPoint(c.createPoint(A,_))}}else for(let S=0;S<i;S++){let w=d+Math.cos(g)*h,A=m+Math.sin(g)*f;c.addPoint(c.createPoint(w,A)),g+=p,w=d+Math.cos(g)*v,A=m+Math.sin(g)*y,S<=i,c.addPoint(c.createPoint(w,A)),g+=p}c.isClosed=!0;for(let S=0,w=c.points.length;S<w;S++)c.points[S].roundness=s;c.roundness=s,c.update();let b=Qr.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(b,{userData:{...r,type:"StarGeometry"}})}};var pE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t}=r.parameters,n=new zs(e,t);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var mE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??t.width*.25);return{parameters:Object.assign(t,{width:n,height:i,depth:s})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=dH(e,t,n,e*.5,o,s,0,0,i,a,l);return u.scale(1,t/e,1),Object.assign(u,{userData:{...r,type:"TorusGeometry"}})}};function dH(r,e,t,n,i,s,o,a,l,u,c){return[e,t]=[t,e],o=e/2,i/=2*Math.PI,i==1&&(u=0),new df(!0,r,e,t,n,i,s,o,a,l,u,c)}var gE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),tube:t.tube??t.width*.125})}}static build(r){let{width:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o}=r.parameters,a=e*.5;a!==t&&(a-=t);let l=new ql(a,t,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var vE=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},r.parameters);return{shape:r.shape&&r.shape instanceof At?r.shape:new At,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e=100,height:t,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=r.parameters,l=r.shape,u=e*.5,c=t*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let f=0,d=l.points.length;f<d;f++)l.points[f].roundness=n;l.roundness=n,l.update();let h=Qr.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...r,type:"TriangleGeometry"}})}};function yE(){let r=new Le;return r.setAttribute("position",new We(new Float32Array([]),3)),r.setIndex(new We(new Uint16Array([]),1)),r}var pH=12;var cu=class extends Le{constructor(t,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.vectorShapes=[];let i=yE();Object.entries(i.attributes).forEach(([s,o])=>{this.setAttribute(s,o)}),this.setIndex(i.index),this.updateFont(t.font,n),this.update(t)}async updateFont(t,n){let i=n.getFont(t);i&&(this.font=i,await i.loadingPromise)}async update(t){let n=this.font;if(this.userData={parameters:t,type:"TextGeometry"},!n||!n.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c,subdivisions:h}=t;await n.loadingPromise;let f=c===2?u.toUpperCase():c===3?u.toLowerCase():u,d=mH(t,n,f),{shapes:m,charWidths:p,charCoords:g}=await n.generateShapes(d,t),v=i*.5,y=s*.5,b=m.map(A=>new At().fromShape(A));this.vectorShapes=b;let S=b.map(A=>Qr.create({shape:A,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?Ft.NONZERO:Ft.ODD,subdivisions:h??pH}})),w=S.length?Zs(S):yE();w.translate(-v,y,0),this.dispose(),this.wrappedText=d,this.charCoords=g,this.charWidths=p,Object.entries(w.attributes).forEach(([A,_])=>{this.setAttribute(A,_)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let t=ja(new Le,cu.prototype);return t.copy(this),t}copy(t){return Object.entries(t.attributes).forEach(([n,i])=>{this.setAttribute(n,i)}),this.setIndex(t.index),this.userData={parameters:{...t.userData.parameters},type:"TextGeometry"},this}async setText(t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:t})}get text(){return this.userData.parameters.text??""}};function mH(r,e,t){t=t??r.text;let n=[""],i="";for(let s of t)i+=s,s===" "||s===`
|
|
3138
3138
|
`?(n[n.length-1]+=i,i="",s===`
|
|
3139
|
-
`&&n.push("")):e.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),e.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var bE,rg=new Promise(r=>{bE=r}),xE=!1;async function SE(){if(xE)return;let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.122/build",[t,n]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});bE(s),xE=!0}function ng(r,e){return vH(r)}function vH(r){let e={parameters:r,type:r.type};if(r.type==="VectorGeometry"){let n=At.createFromState(r.shape,r.width,r.height);e.shape=n}else r.type==="NonParametricGeometry"&&(r.data.groups&&r.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),e.geometry=new Kl().parse(r));let t;try{t=gf(e)}catch(n){console.error(n)}if(!t){let n=At.createFromState(Rc.defaultData(),100,100);e.shape=n,t=gf(e)}return t}var Ze;rg.then(r=>{Ze=r});var wE=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),AE=new Uint32Array([0,1,2,3]),TE=new Uint8Array([4]),fi=class{static build(r,e,t,n,i){let s,o,a,l=r?.phongAngle??e?.phongAngle??35;if(n===!1&&(l=-1),r.positionWASM!==void 0){t&&t!==0&&(Ze.free_bvh(t),Ze.free_subdivision_surface(t));try{s=fi.allocate(r,i)}catch(u){console.error(u,r),s=fi.allocate({positionWASM:wE,indexWASM:AE,verticesPerFaceWASM:TE},i)}Ze.set_destination_refinement_level(s,0),o=fi.buildLevel(s,!0,l)}else s=t,r.phongAngle!==void 0&&(o=fi.buildLevel(s,!0,l));return r.subdivisions!==void 0&&(Ze.set_destination_refinement_level(s,r.subdivisions),r.subdivisions>0?a=fi.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(r,e){r.widthSegments>16&&(r.widthSegments=16),r.heightSegments>16&&(r.heightSegments=16),r.depthSegments>16&&(r.depthSegments=16),r.radialSegments>16&&(r.radialSegments=16),r.type==="DodecahedronGeometry"&&(r.detail=0);let t=r.shape!==void 0?e.geometry:ng(r),n,i,s,o;({positions:n,triIndices:o}=vf(t.getAttribute("position"),t.getIndex()));let a;if(r.type==="CylinderGeometry"&&r.cornerRadius===0&&r.hollow===0&&r.openEnded===!1){let l=r.radialSegments*r.heightSegments*3*2,u=l+r.radialSegments*3;a=[l,u]}return{indices:i,verticesPerFace:s}=Cx(n,o,t,a),{positions:n,indices:i,verticesPerFace:s}}static allocate(r,e){let t,n,i,s=[],o=[];r.positionWASM&&r.positionWASM.length>0?(t=r.positionWASM,n=r.indexWASM,i=r.verticesPerFaceWASM):(t=wE,n=AE,i=TE);let a=t.length,l=n.length,u=i.length,c=t.length+s.length+o.length,h=n.length+i.length,f=c*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,d=c*Float32Array.BYTES_PER_ELEMENT,m=h*Uint32Array.BYTES_PER_ELEMENT,p=Ze._malloc(f),g=new Float32Array(Ze.HEAPF32.buffer,p,c),v=new Uint32Array(Ze.HEAPU32.buffer,p+d,h);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),v.set(n,0),v.set(i,n.length);let y;r?.scaleBaked?.some(S=>S!==1)&&(y=new we().makeScale(...r.scaleBaked)),e&&(y?y.premultiply(e):y=e);let b=y?Ze.alloc_subdivision_surface2(p,a,p+d,l,p+d+n.length*Uint32Array.BYTES_PER_ELEMENT,u,y.elements):Ze.alloc_subdivision_surface(p,a,p+d,l,p+d+n.length*Uint32Array.BYTES_PER_ELEMENT,u);return Ze._free(p),b}static buildLevel(r,e,t,n,i){let s=i?Ze.get_mesh_data2(r,e?Ze.Level.CONTROL:Ze.Level.REFINED,t,i.elements):Ze.get_mesh_data(r,e?Ze.Level.CONTROL:Ze.Level.REFINED,t),o=8,a=Ze.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),u=0,c=Ze.HEAPU32[a[u]>>2],h=Ze.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let f=Ze.HEAPU32[a[u]>>2],d=Ze.HEAPF32.subarray(f>>2,(f>>2)+l[u]);u++;let m=Ze.HEAPU32[a[u]>>2],p=Ze.HEAPU32.subarray(m>>2,(m>>2)+l[u]);u++;let g=Ze.HEAPU32[a[u]>>2],v=Ze.HEAPU32.subarray(g>>2,(g>>2)+l[u]);if(u++,n===void 0){let y=new Le;if(y.setIndex(new xo(v,1)),y.setAttribute("position",new Te(h,3)),y.setAttribute("normal",new Te(d,3)),e){y.setAttribute("faceMap",new xo(p,1));let b=new Float32Array(d.length/3*4).fill(0);y.setAttribute("color",new We(b,4))}return Ze.free_mesh_data(s),y.userData.type="SubdivGeometry",y}n.getAttribute("position").copyArray(h),n.getAttribute("normal").copyArray(d),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Ze.free_mesh_data(s)}static buildControlCageWireframe(r,e,t){let n=Ze.get_wireframe_data_for_base_level(r),i=4,s=Ze.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(2,2+2),a=0,l=Ze.HEAPU32[s[a]>>2],u=Ze.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let c=Ze.HEAPU32[s[a]>>2],h=Ze.HEAPU32.subarray(c>>2,(c>>2)+o[a]);if(e===void 0){let f=new Le;f.setAttribute("position",new Te(u,3));let d=new Float32Array(u.length);for(let m=0,p=u.length;m<p;)d[m++]=t.r,d[m++]=t.g,d[m++]=t.b;return f.setAttribute("color",new We(d,3)),f.setIndex(new xo(h,1)),Ze.free_wireframe_data_for_base_level(n),f}e.getAttribute("position").copyArray(u),e.attributes.position.needsUpdate=!0,Ze.free_wireframe_data_for_base_level(n)}static updateCollabMesh(r,e,t){let n=e===0;n||Ze.set_destination_refinement_level(r,e);let i=t?Ze.get_topological_data2(r,n?Ze.Level.CONTROL:Ze.Level.REFINED,t.elements):Ze.get_topological_data(r,n?Ze.Level.CONTROL:Ze.Level.REFINED),s=6,o=Ze.HEAPU32.subarray(i>>2,(i>>2)+s),a=o.subarray(3,3+3),l=0,u=Ze.HEAPU32[o[l]>>2],c=new Float32Array(Ze.HEAPF32.subarray(u>>2,(u>>2)+a[l]));l++;let h=Ze.HEAPU32[o[l]>>2],f=new Uint32Array(Ze.HEAPU32.subarray(h>>2,(h>>2)+a[l]));l++;let d=Ze.HEAPU32[o[l]>>2],m=new Uint8Array(Ze.HEAPU32.subarray(d>>2,(d>>2)+a[l]));return Ze.free_topological_data(i),{positions:c,indices:f,verticesPerFace:m}}};var _E=["getX","getY","getZ"];function vf(r,e){let t={},n=e?e.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=e?e.getX(u):u,h="";for(let f=0;f<3;f++)h+=`${~~(r[_E[f]](c)*a)},`;if(h in t)s.push(t[h]);else{for(let f=0;f<3;f++)o.push(r[_E[f]](c));t[h]=i,s.push(i),i++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var ig=new T,_x=new T,Mx=new T,Ex=new T;function Cx(r,e,t,n){let i=[],s=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0&&t.userData.shape.shapeHoles.length===0){let o=t.userData.shape.extractShapePointsToFlatArray([]),a=0;for(let u=0;u<o.length;u+=2)a+=(o[u]-o[(u===0?o.length:u)-2])*(o[u+1]+o[(u===0?o.length:u)-1]);r.length=0;let l=0;if(a<0)for(let u=0;u<o.length;u+=2)r.push(o[u],o[u+1],0),i.push(l++);else for(let u=o.length-2;u>=0;u-=2)r.push(o[u],o[u+1],0),i.push(l++);return s.push(l),{indices:i,verticesPerFace:s}}for(let o=0,a=t.capStartIndex??e.length;o<a;)if(e[o+1]===e[o+3]&&e[o+2]===e[o+5]||e[o+0]===e[o+3]&&e[o+2]===e[o+4]){ig.set(r[e[o]*3],r[e[o]*3+1],r[e[o]*3+2]),_x.set(r[e[o+1]*3],r[e[o+1]*3+1],r[e[o+1]*3+2]),Mx.set(r[e[o+4]*3],r[e[o+4]*3+1],r[e[o+4]*3+2]),Ex.set(r[e[o+5]*3],r[e[o+5]*3+1],r[e[o+5]*3+2]),_x.sub(ig).normalize(),Mx.sub(ig).normalize(),Ex.sub(ig).normalize();let l=_x.cross(Mx).dot(Ex);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3):(i.push(e[o],e[o+1],e[o+4],e[o+5]),s.push(4),o+=6)}else i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3;if(t.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([t.userData.parameters.depth])[0];for(let c=0,h=0;c<r.length;c+=3,h++)r[c+2]===0&&(o.push(h),l++),r[c+2]===u&&a.push(h);if(t.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var Li={};zS(Li,{calcBoolean:()=>bH,calcBooleanTopological:()=>xH,freeMeshSet:()=>AH,getMeshSet:()=>SH,transformMeshSet:()=>wH});var EE,CE=new Promise(r=>{EE=r}),ME=!1;async function PE(){if(ME)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.122/build",[t,n]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});EE(s),ME=!0}var mt,uu;CE.then(r=>mt=r);function yH(r,e,t){let n,{positions:i,triIndices:s}=vf(r.getAttribute("position"),r.getIndex()),o;if(e&&t){let{indices:a,verticesPerFace:l}=Cx(i,s,r);o=l.length,n=[];for(let u=0,c=0;u<o;u++){n.push(l[u]);for(let h=0;h<l[u];h++)n.push(a[c++])}}else{let a=s.length;n=Array(a+a/3),o=0;for(let l=0,u=0;u<n.length;)n[u++]=3,o++,n[u++]=s[l++],n[u++]=s[l++],n[u++]=s[l++]}return{positions:i,faceIndices:n,nFaces:o}}function DE(r){let e=r.length,t=e*Uint32Array.BYTES_PER_ELEMENT,n=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?t:n,s=mt._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(mt.HEAPU32.buffer,s,e):new Float32Array(mt.HEAPF32.buffer,s,e)).set(r,0),s}function IE(r){switch(r){case 0:return mt.OP.UNION;case 1:return mt.OP.INTERSECTION;case 2:return mt.OP.A_MINUS_B;case 3:return mt.OP.B_MINUS_A;case 4:return mt.OP.SYMMETRIC_DIFFERENCE;case 5:return mt.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function xH(r,e){uu===void 0&&(uu=mt.init_csg());let t=DE(r),n=mt.csg_calc_topological(uu,t,r.length,IE(e));mt._free(t);let i=6,s=mt.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=mt.HEAPU32[s[a]>>2],u=new Float32Array(mt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=mt.HEAPU32[s[a]>>2],h=new Uint32Array(mt.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let f=mt.HEAPU32[s[a]>>2],d=new Uint8Array(mt.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return mt.free_mesh_data(n),{positions:u,indices:h,verticesPerFace:d}}function bH(r,e,t,n){uu===void 0&&(uu=mt.init_csg());let i=DE(r),s=mt.csg_calc(uu,i,r.length,n,IE(e));mt._free(i);let o=5,a=mt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=mt.HEAPU32[a[u]>>2],h=mt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let f=mt.HEAPU32[a[u]>>2],d=mt.HEAPF32.subarray(f>>2,(f>>2)+l[u]);u++;let m=l[u];t.setAttribute("position",new Te(h,3)),t.setAttribute("normal",new Te(d,3));let p=mt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Fr),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},mt.free_mesh_data(s),m}function SH(r,e,t){if(mt===void 0)return-1;let n,i,s;if(e&&r.userData.positions!==void 0){let g=r.userData;s=g.verticesPerFace.length,n=g.positions,i=Array(g.verticesPerFace.reduce((v,y)=>v+y,0)+s);for(let v=0,y=0,b=0;v<g.verticesPerFace.length;v++){i[b++]=g.verticesPerFace[v];for(let S=0;S<g.verticesPerFace[v];S++)i[b++]=g.indices[y++]}}else({positions:n,faceIndices:i,nFaces:s}=yH(r,e,t));let o=n.length,a=i.length,l=n.length,u=i.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,f=u*Uint32Array.BYTES_PER_ELEMENT,d=mt._malloc(c),m=new Float32Array(mt.HEAPF32.buffer,d,l),p=new Uint32Array(mt.HEAPU32.buffer,d+h,u);return m.set(n,0),p.set(i,0),mt.get_csg_mesh(d,o,d+h,a,s)}function wH(r,e){mt.transform_csg_mesh(r,e.elements)}function AH(r){mt.free_csg_mesh(r)}var Px={ConeGeometry:qM,CubeGeometry:XM,CylinderGeometry:jM,DodecahedronGeometry:YM,EllipseGeometry:$M,HelixGeometry:nE,IcosahedronGeometry:iE,LatheGeometry:sE,NonParametricGeometry:oE,PolygonGeometry:aE,PyramidGeometry:lE,RectangleGeometry:cE,SphereGeometry:uE,PlaneGeometry:hE,BackdropGeometry:fE,StarGeometry:dE,TextFrameGeometry:pE,TorusGeometry:mE,TorusKnotGeometry:gE,TriangleGeometry:vE,VectorGeometry:Qr},gf=r=>Px[r.type].create(r);function zr(r,e){return e.color(r)}var di=r=>"isEntity"in r,Gt=r=>"isAbstractMesh"in r,Yt=r=>r!==null&&r.objectType==="BooleanObject",LE=r=>r.objectType==="CombinedCamera",OE=r=>di(r)&&(r.objectType==="LightDirectional"||r.objectType==="LightSpot"||r.objectType==="LightPoint");var Dx=r=>r.objectType==="EmptyObject",sg=r=>"objectHelper"in r;function Ix(r,e){let t=!1;e.position&&(r.position.fromArray(e.position),t=!0),e.rotation&&(r.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,r.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in r&&(t=!0,r.hiddenMatrix.fromArray(e.hiddenMatrix??No.identity)),t&&(r.updateMatrix(),Yt(r.parent)&&Gt(r)&&r.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&r.updateWorldMatrix(!1,!0),r.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(r.isUpVectorFlipped=e.isUpVectorFlipped),r.updateUp())}function TH(r,e){Ix(r,e),e.name!==void 0&&(r.name=e.name),e.visible!==void 0&&(r.visible=e.visible)}function RE(r,e,t){TH(r,e),e.color!==void 0&&(r.color=zr(e.color,t)),e.intensity!==void 0&&(r.intensity=e.intensity),e.shadows!==void 0&&!(r instanceof Da)&&(r.castShadow=e.shadows),r.shadow&&!(r instanceof Da)&&e.depth!==void 0&&(r.shadow.camera.far=e.depth,r.shadow.needsUpdate=!0)}function BE(r,e){r.shadow.camera.right=e/2,r.shadow.camera.left=-e/2,r.shadow.camera.top=e/2,r.shadow.camera.bottom=-e/2,r.shadow.needsUpdate=!0}var og=r=>class extends r{hasEntityChild(){return this.children.some(t=>di(t))}isDescendantOf(t){t instanceof yt&&(t=t.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===t)return!0;n=n.parent}return!1}attach(t,n){this.updateWorldMatrix(!0,!1);let i=new we().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),di(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),n!==void 0&&(this.children.pop(),this.children.splice(n,0,t)),this}copy(t,n=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}};var hu=new Lt,Oi=new T,us=new T,fu=new we,FE=[new T(-1,1,1),new T(-1,-1,1),new T(1,-1,1),new T(1,1,1),new T(-1,1,-1),new T(-1,-1,-1),new T(1,-1,-1),new T(1,1,-1)],_H=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],MH=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function EH(r,e,t=0,n=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t;c<n;c++){let h=e.getX(c),f=e.getY(c),d=e.getZ(c);h<i&&(i=h),f<s&&(s=f),d<o&&(o=d),h>a&&(a=h),f>l&&(l=f),d>u&&(u=d)}return r.min.set(i,s,o),r.max.set(a,l,u),r}var NE=(r,e,t)=>{if(Gt(r)){let n=r.geometry.userData.parameters,i=r.geometry.getAttribute("position");r.geometry.userData.type==="SubdivGeometry"?Oi.copy(r.originalGeometry.boundingSphere.center):r.geometry.userData.type==="TextGeometry"?Oi.set(0,0,n.depth*.5):i!==void 0&&(EH(hu,i,r.geometry.drawRange.start,r.geometry.drawRange.count<1/0?r.geometry.drawRange.count:i.count),hu.getCenter(Oi)),r.forceComputeSize?hu.getSize(us).multiplyScalar(.5):us.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}else if(sg(r)&&r.objectHelper.visible){let n=r.geometryHelper.getAttribute("position");hu.setFromArray(n.array),hu.getCenter(Oi),hu.getSize(us).multiplyScalar(.5)}else Oi.setScalar(0),us.setScalar(0);fu.copy(e).multiply(r.matrixWorld),us.x===0&&us.y===0&&us.z===0?t.push(new T(Oi.x,Oi.y,Oi.z).applyMatrix4(fu)):FE.forEach(n=>{t.push(n.clone().multiply(us).add(Oi).applyMatrix4(fu))})},yf=class extends Lt{constructor(){super(...arguments);this.matrix=new we;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(n=>n.clone()),this.faces=t.faces.map(n=>n.clone()),this.edges=t.edges.map(n=>n.clone()),this.centerEdges=t.centerEdges.map(n=>n.clone()),this}setFromObjectSize(t,n=!1){t.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new we().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,n)}expandByObjectSize(t,n,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&NE(o,n,s)}):NE(t,n,s),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(fu.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(us).multiplyScalar(.5),this.getCenter(Oi),fu.copy(this.matrix).setPosition(Oi),this.vertices=FE.map(t=>t.clone().multiply(us).applyMatrix4(fu))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=_H.map(([t,n])=>new _r(this.vertices[t],this.vertices[n])),this.centerEdges=this.edges.map(t=>t.getCenter(new T))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=MH.map(([t,n])=>this.vertices[t].clone().add(this.vertices[n]).multiplyScalar(.5))}};var hs=r=>"isEntity"in r,kE=r=>"isAbstractMesh"in r,pi=r=>class extends og(r){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new we;this._singleBBox=new yf;this._recursiveBBox=new yf;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1;this.states={};this.currentState=null;this.currentTransitionAction=null}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(n=>{hs(n)&&(n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(n=>{n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0})}traverseEntity(n){n(this);for(let i of this.children)hs(i)&&i.traverseEntity(n)}traverseVisibleEntity(n){n(this);for(let i of this.children)hs(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}clone(n){return new this.constructor().copy(this,n)}copy(n,i=!0){if(super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),i===!0)for(let s of n.children)hs(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let n=new we,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),n.copy(this.matrixWorld).invert(),n.multiply(i);for(let s of this.children)hs(s)&&s.hiddenMatrix.premultiply(n)}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Cc(i,n)}fromObjectTransformState(n){return n.position&&this.position.fromArray(n.position),n.rotation&&this.rotation.fromArray(n.rotation),n.scale&&this.scale.fromArray(n.scale),n.hiddenMatrix&&this.hiddenMatrix.fromArray(n.hiddenMatrix),this.updateMatrix(),this}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return Cc(i,n)}fromState(n,i){return n.name&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.type!=="OrthographicCamera"&&n.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),n.visible!==void 0&&(this.visible=n.visible),this.fromObjectTransformState(n),this}};var xf=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};var Vr=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=ze.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,n){return n=n??{},this.analyze(e,n),this.flow(e,t,n)}flow(e,t,n){n=n??{},e.addFlow(n.slot,n.cache,n.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,n){t=t??this.getType(e,t);let i=e.getNodeData(n??this);return e.analyzing&&this.appendDepsNode(e,i,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,n)}updateFrame(e){}generateReadonly(e,t,n,i,s,o){return""}generate(e,t,n,i,s){return""}parse(e,t,n,i){}appendDepsNode(e,t,n){t.deps=(t.deps||0)+1;let i=e.getTypeLength(n);(i>(t.outputMax||0)||this.getType(e,n))&&(t.outputMax=i,t.output=n)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,n;for(t in this)n=this[t],n instanceof Vr&&(e+='"'+t+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)t=this.hashProperties[i],n=this[t],e+='"'+t+'":"'+String(n)+'",';return e+='"id":"'+this.uuid+'"}',e}};var Lx=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,n){n=n!==void 0?n:!0,this.keywords[e]={callback:t,cache:n}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Dr=new Lx;var qe=class extends Vr{constructor(t,n){super(t);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(t,n,i,s){if(n=n??this.getType(t),this.getShared(t,n)){let o=this.getUnique(t,n);o&&this.uuid===void 0&&(this.uuid=ze.generateUUID()),i=t.getUUID(i??this.getUUID(),!o);let a=t.getNodeData(i),l=a.output||this.getType(t);if(t.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(t,a,n),this.generate(t,n,i)):super.build(t,n,i);if(o)return a.name=a.name||super.build(t,n,i),a.name;if(!this.getLabel()&&(!this.getShared(t,l)||t.context.ignoreCache||a.deps===1))return super.build(t,n,i);i=this.getUUID(!1);let u=this.getTemp(t,i);if(u)return t.format(u,l,n);{u=super.generate(t,n,i,a.output,s);let c=this.generate(t,l,i);return t.addNodeCode(u+" = "+c+";"),t.format(u,l,n)}}return super.build(t,n,i)}getShared(t,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(t,n){return this.unique}setLabel(t){return this.label=t,this}getLabel(){return this.label}getUUID(t){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(t,n){n=n||this.uuid;let i=t.getVars()[n];return i?i.name:void 0}generate(t,n,i,s,o){return this.getShared(t,n)||console.error("TempNode is not shared"),i=i??this.uuid,t.getTempVar(i,s??this.getType(t),o,this.getLabel()).name}};var Ut=class extends qe{constructor(t,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(t,n);this.readonly=!1}setReadonly(t){return this.readonly=t,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(t,n,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(t,n,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,n))}};var Hr=class extends Ut{constructor(t=0,n){super("v2");this.nodeType="Vector2";this.value=t instanceof k?t:new k(t,n)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}generateReadonly(t,n,i,s,o,a){return t.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var Zr=class extends Ut{constructor(t=0,n,i){super("v3");this.nodeType="Vector3";this.value=t instanceof T?t:new T(t,n,i)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}get z(){return this.value.z}set z(t){this.value.z=t}generateReadonly(t,n,i,s,o,a){return t.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var or=class extends Be{constructor(t,n,i,s){super(t,n,i);this.isColorA=!0;this.a=s}setRGBA(t,n,i,s){super.setRGB(t,n,i),this.a=s}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}};var mi=class extends Ut{constructor(t){super("v4");this.nodeType="Vector4";this.value=t instanceof or?t:new or(t.r,t.g,t.b,t.a)}generateReadonly(t,n,i,s,o,a){return t.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var CH=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,UE=/[a-z_0-9]+/gi,Ee=class extends qe{constructor(t,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(t,n,i,s)}getShared(t,n){return!this.isMethod}getType(t){return t.getTypeByFormat(this.type)}getInputByName(t){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}}getIncludeByName(t){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===t)return this.includes[n]}}generate(t,n,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)t.include(this.includes[h],this);for(let h in this.extensions)t.extensions[h]=!0;let c=[];for(;a=UE.exec(this.src);)c.push(a);for(let h=0;h<c.length;h++){let f=c[h],d=f[0],m=this.isMethod?!this.getInputByName(d):!0,p=d;if(this.keywords[d]||this.useKeywords&&m&&Dr.containsKeyword(d)){let g=this.keywords[d];if(!g){let v=Dr.getKeywordData(d);v.cache&&(g=t.keywords[d]),g=g||Dr.getKeyword(d,t),v.cache&&(t.keywords[d]=g)}p=g.build(t)}d!==p&&u[f.index+l-1]!=="."&&(u=u.substring(0,f.index+l)+p+u.substring(f.index+d.length+l),l+=p.length-d.length),this.getIncludeByName(p)===void 0&&Dr.contains(p)&&t.include(Dr.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||t.include(this,void 0,u),this.name):t.format("( "+u+" )",this.getType(t),n)}parse(t,n,i,s){if(this.src=t||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=CH.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(UE);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let h=a[l++];this.inputs.push({name:h,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var PH=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Ox=class extends qe{constructor(t="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(t||Ox.PI,void 0,void 0,void 0,n)}getType(t){return t.getTypeByFormat(this.type)}parse(t,n,i,s,o){this.src=t||"";let a,l,u="",c=PH.exec(t);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(t,n){if(n==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return t.include(this),t.format(this.name,this.getType(t),n)}generate(t,n,i,s,o){return t.format(this.name,this.getType(t),n)}},bt=Ox;bt.PI="PI",bt.PI2="PI2",bt.RECIPROCAL_PI="RECIPROCAL_PI",bt.RECIPROCAL_PI2="RECIPROCAL_PI2",bt.LOG2="LOG2",bt.EPSILON="EPSILON";var DH=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3139
|
+
`&&n.push("")):e.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),e.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var bE,rg=new Promise(r=>{bE=r}),xE=!1;async function SE(){if(xE)return;let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.123/build",[t,n]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});bE(s),xE=!0}function ng(r,e){return vH(r)}function vH(r){let e={parameters:r,type:r.type};if(r.type==="VectorGeometry"){let n=At.createFromState(r.shape,r.width,r.height);e.shape=n}else r.type==="NonParametricGeometry"&&(r.data.groups&&r.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),e.geometry=new Kl().parse(r));let t;try{t=gf(e)}catch(n){console.error(n)}if(!t){let n=At.createFromState(Rc.defaultData(),100,100);e.shape=n,t=gf(e)}return t}var Ze;rg.then(r=>{Ze=r});var wE=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),AE=new Uint32Array([0,1,2,3]),TE=new Uint8Array([4]),fi=class{static build(r,e,t,n,i){let s,o,a,l=r?.phongAngle??e?.phongAngle??35;if(n===!1&&(l=-1),r.positionWASM!==void 0){t&&t!==0&&(Ze.free_bvh(t),Ze.free_subdivision_surface(t));try{s=fi.allocate(r,i)}catch(u){console.error(u,r),s=fi.allocate({positionWASM:wE,indexWASM:AE,verticesPerFaceWASM:TE},i)}Ze.set_destination_refinement_level(s,0),o=fi.buildLevel(s,!0,l)}else s=t,r.phongAngle!==void 0&&(o=fi.buildLevel(s,!0,l));return r.subdivisions!==void 0&&(Ze.set_destination_refinement_level(s,r.subdivisions),r.subdivisions>0?a=fi.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(r,e){r.widthSegments>16&&(r.widthSegments=16),r.heightSegments>16&&(r.heightSegments=16),r.depthSegments>16&&(r.depthSegments=16),r.radialSegments>16&&(r.radialSegments=16),r.type==="DodecahedronGeometry"&&(r.detail=0);let t=r.shape!==void 0?e.geometry:ng(r),n,i,s,o;({positions:n,triIndices:o}=vf(t.getAttribute("position"),t.getIndex()));let a;if(r.type==="CylinderGeometry"&&r.cornerRadius===0&&r.hollow===0&&r.openEnded===!1){let l=r.radialSegments*r.heightSegments*3*2,u=l+r.radialSegments*3;a=[l,u]}return{indices:i,verticesPerFace:s}=Cx(n,o,t,a),{positions:n,indices:i,verticesPerFace:s}}static allocate(r,e){let t,n,i,s=[],o=[];r.positionWASM&&r.positionWASM.length>0?(t=r.positionWASM,n=r.indexWASM,i=r.verticesPerFaceWASM):(t=wE,n=AE,i=TE);let a=t.length,l=n.length,u=i.length,c=t.length+s.length+o.length,h=n.length+i.length,f=c*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,d=c*Float32Array.BYTES_PER_ELEMENT,m=h*Uint32Array.BYTES_PER_ELEMENT,p=Ze._malloc(f),g=new Float32Array(Ze.HEAPF32.buffer,p,c),v=new Uint32Array(Ze.HEAPU32.buffer,p+d,h);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),v.set(n,0),v.set(i,n.length);let y;r?.scaleBaked?.some(S=>S!==1)&&(y=new we().makeScale(...r.scaleBaked)),e&&(y?y.premultiply(e):y=e);let b=y?Ze.alloc_subdivision_surface2(p,a,p+d,l,p+d+n.length*Uint32Array.BYTES_PER_ELEMENT,u,y.elements):Ze.alloc_subdivision_surface(p,a,p+d,l,p+d+n.length*Uint32Array.BYTES_PER_ELEMENT,u);return Ze._free(p),b}static buildLevel(r,e,t,n,i){let s=i?Ze.get_mesh_data2(r,e?Ze.Level.CONTROL:Ze.Level.REFINED,t,i.elements):Ze.get_mesh_data(r,e?Ze.Level.CONTROL:Ze.Level.REFINED,t),o=8,a=Ze.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),u=0,c=Ze.HEAPU32[a[u]>>2],h=Ze.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let f=Ze.HEAPU32[a[u]>>2],d=Ze.HEAPF32.subarray(f>>2,(f>>2)+l[u]);u++;let m=Ze.HEAPU32[a[u]>>2],p=Ze.HEAPU32.subarray(m>>2,(m>>2)+l[u]);u++;let g=Ze.HEAPU32[a[u]>>2],v=Ze.HEAPU32.subarray(g>>2,(g>>2)+l[u]);if(u++,n===void 0){let y=new Le;if(y.setIndex(new xo(v,1)),y.setAttribute("position",new Te(h,3)),y.setAttribute("normal",new Te(d,3)),e){y.setAttribute("faceMap",new xo(p,1));let b=new Float32Array(d.length/3*4).fill(0);y.setAttribute("color",new We(b,4))}return Ze.free_mesh_data(s),y.userData.type="SubdivGeometry",y}n.getAttribute("position").copyArray(h),n.getAttribute("normal").copyArray(d),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Ze.free_mesh_data(s)}static buildControlCageWireframe(r,e,t){let n=Ze.get_wireframe_data_for_base_level(r),i=4,s=Ze.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(2,2+2),a=0,l=Ze.HEAPU32[s[a]>>2],u=Ze.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let c=Ze.HEAPU32[s[a]>>2],h=Ze.HEAPU32.subarray(c>>2,(c>>2)+o[a]);if(e===void 0){let f=new Le;f.setAttribute("position",new Te(u,3));let d=new Float32Array(u.length);for(let m=0,p=u.length;m<p;)d[m++]=t.r,d[m++]=t.g,d[m++]=t.b;return f.setAttribute("color",new We(d,3)),f.setIndex(new xo(h,1)),Ze.free_wireframe_data_for_base_level(n),f}e.getAttribute("position").copyArray(u),e.attributes.position.needsUpdate=!0,Ze.free_wireframe_data_for_base_level(n)}static updateCollabMesh(r,e,t){let n=e===0;n||Ze.set_destination_refinement_level(r,e);let i=t?Ze.get_topological_data2(r,n?Ze.Level.CONTROL:Ze.Level.REFINED,t.elements):Ze.get_topological_data(r,n?Ze.Level.CONTROL:Ze.Level.REFINED),s=6,o=Ze.HEAPU32.subarray(i>>2,(i>>2)+s),a=o.subarray(3,3+3),l=0,u=Ze.HEAPU32[o[l]>>2],c=new Float32Array(Ze.HEAPF32.subarray(u>>2,(u>>2)+a[l]));l++;let h=Ze.HEAPU32[o[l]>>2],f=new Uint32Array(Ze.HEAPU32.subarray(h>>2,(h>>2)+a[l]));l++;let d=Ze.HEAPU32[o[l]>>2],m=new Uint8Array(Ze.HEAPU32.subarray(d>>2,(d>>2)+a[l]));return Ze.free_topological_data(i),{positions:c,indices:f,verticesPerFace:m}}};var _E=["getX","getY","getZ"];function vf(r,e){let t={},n=e?e.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=e?e.getX(u):u,h="";for(let f=0;f<3;f++)h+=`${~~(r[_E[f]](c)*a)},`;if(h in t)s.push(t[h]);else{for(let f=0;f<3;f++)o.push(r[_E[f]](c));t[h]=i,s.push(i),i++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var ig=new T,_x=new T,Mx=new T,Ex=new T;function Cx(r,e,t,n){let i=[],s=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0&&t.userData.shape.shapeHoles.length===0){let o=t.userData.shape.extractShapePointsToFlatArray([]),a=0;for(let u=0;u<o.length;u+=2)a+=(o[u]-o[(u===0?o.length:u)-2])*(o[u+1]+o[(u===0?o.length:u)-1]);r.length=0;let l=0;if(a<0)for(let u=0;u<o.length;u+=2)r.push(o[u],o[u+1],0),i.push(l++);else for(let u=o.length-2;u>=0;u-=2)r.push(o[u],o[u+1],0),i.push(l++);return s.push(l),{indices:i,verticesPerFace:s}}for(let o=0,a=t.capStartIndex??e.length;o<a;)if(e[o+1]===e[o+3]&&e[o+2]===e[o+5]||e[o+0]===e[o+3]&&e[o+2]===e[o+4]){ig.set(r[e[o]*3],r[e[o]*3+1],r[e[o]*3+2]),_x.set(r[e[o+1]*3],r[e[o+1]*3+1],r[e[o+1]*3+2]),Mx.set(r[e[o+4]*3],r[e[o+4]*3+1],r[e[o+4]*3+2]),Ex.set(r[e[o+5]*3],r[e[o+5]*3+1],r[e[o+5]*3+2]),_x.sub(ig).normalize(),Mx.sub(ig).normalize(),Ex.sub(ig).normalize();let l=_x.cross(Mx).dot(Ex);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3):(i.push(e[o],e[o+1],e[o+4],e[o+5]),s.push(4),o+=6)}else i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3;if(t.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([t.userData.parameters.depth])[0];for(let c=0,h=0;c<r.length;c+=3,h++)r[c+2]===0&&(o.push(h),l++),r[c+2]===u&&a.push(h);if(t.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var Li={};zS(Li,{calcBoolean:()=>bH,calcBooleanTopological:()=>xH,freeMeshSet:()=>AH,getMeshSet:()=>SH,transformMeshSet:()=>wH});var EE,CE=new Promise(r=>{EE=r}),ME=!1;async function PE(){if(ME)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.123/build",[t,n]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});EE(s),ME=!0}var mt,uu;CE.then(r=>mt=r);function yH(r,e,t){let n,{positions:i,triIndices:s}=vf(r.getAttribute("position"),r.getIndex()),o;if(e&&t){let{indices:a,verticesPerFace:l}=Cx(i,s,r);o=l.length,n=[];for(let u=0,c=0;u<o;u++){n.push(l[u]);for(let h=0;h<l[u];h++)n.push(a[c++])}}else{let a=s.length;n=Array(a+a/3),o=0;for(let l=0,u=0;u<n.length;)n[u++]=3,o++,n[u++]=s[l++],n[u++]=s[l++],n[u++]=s[l++]}return{positions:i,faceIndices:n,nFaces:o}}function DE(r){let e=r.length,t=e*Uint32Array.BYTES_PER_ELEMENT,n=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?t:n,s=mt._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(mt.HEAPU32.buffer,s,e):new Float32Array(mt.HEAPF32.buffer,s,e)).set(r,0),s}function IE(r){switch(r){case 0:return mt.OP.UNION;case 1:return mt.OP.INTERSECTION;case 2:return mt.OP.A_MINUS_B;case 3:return mt.OP.B_MINUS_A;case 4:return mt.OP.SYMMETRIC_DIFFERENCE;case 5:return mt.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function xH(r,e){uu===void 0&&(uu=mt.init_csg());let t=DE(r),n=mt.csg_calc_topological(uu,t,r.length,IE(e));mt._free(t);let i=6,s=mt.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=mt.HEAPU32[s[a]>>2],u=new Float32Array(mt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=mt.HEAPU32[s[a]>>2],h=new Uint32Array(mt.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let f=mt.HEAPU32[s[a]>>2],d=new Uint8Array(mt.HEAPU32.subarray(f>>2,(f>>2)+o[a]));return mt.free_mesh_data(n),{positions:u,indices:h,verticesPerFace:d}}function bH(r,e,t,n){uu===void 0&&(uu=mt.init_csg());let i=DE(r),s=mt.csg_calc(uu,i,r.length,n,IE(e));mt._free(i);let o=5,a=mt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=mt.HEAPU32[a[u]>>2],h=mt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let f=mt.HEAPU32[a[u]>>2],d=mt.HEAPF32.subarray(f>>2,(f>>2)+l[u]);u++;let m=l[u];t.setAttribute("position",new Te(h,3)),t.setAttribute("normal",new Te(d,3));let p=mt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Fr),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},mt.free_mesh_data(s),m}function SH(r,e,t){if(mt===void 0)return-1;let n,i,s;if(e&&r.userData.positions!==void 0){let g=r.userData;s=g.verticesPerFace.length,n=g.positions,i=Array(g.verticesPerFace.reduce((v,y)=>v+y,0)+s);for(let v=0,y=0,b=0;v<g.verticesPerFace.length;v++){i[b++]=g.verticesPerFace[v];for(let S=0;S<g.verticesPerFace[v];S++)i[b++]=g.indices[y++]}}else({positions:n,faceIndices:i,nFaces:s}=yH(r,e,t));let o=n.length,a=i.length,l=n.length,u=i.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,f=u*Uint32Array.BYTES_PER_ELEMENT,d=mt._malloc(c),m=new Float32Array(mt.HEAPF32.buffer,d,l),p=new Uint32Array(mt.HEAPU32.buffer,d+h,u);return m.set(n,0),p.set(i,0),mt.get_csg_mesh(d,o,d+h,a,s)}function wH(r,e){mt.transform_csg_mesh(r,e.elements)}function AH(r){mt.free_csg_mesh(r)}var Px={ConeGeometry:qM,CubeGeometry:XM,CylinderGeometry:jM,DodecahedronGeometry:YM,EllipseGeometry:$M,HelixGeometry:nE,IcosahedronGeometry:iE,LatheGeometry:sE,NonParametricGeometry:oE,PolygonGeometry:aE,PyramidGeometry:lE,RectangleGeometry:cE,SphereGeometry:uE,PlaneGeometry:hE,BackdropGeometry:fE,StarGeometry:dE,TextFrameGeometry:pE,TorusGeometry:mE,TorusKnotGeometry:gE,TriangleGeometry:vE,VectorGeometry:Qr},gf=r=>Px[r.type].create(r);function zr(r,e){return e.color(r)}var di=r=>"isEntity"in r,Gt=r=>"isAbstractMesh"in r,Yt=r=>r!==null&&r.objectType==="BooleanObject",LE=r=>r.objectType==="CombinedCamera",OE=r=>di(r)&&(r.objectType==="LightDirectional"||r.objectType==="LightSpot"||r.objectType==="LightPoint");var Dx=r=>r.objectType==="EmptyObject",sg=r=>"objectHelper"in r;function Ix(r,e){let t=!1;e.position&&(r.position.fromArray(e.position),t=!0),e.rotation&&(r.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,r.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in r&&(t=!0,r.hiddenMatrix.fromArray(e.hiddenMatrix??No.identity)),t&&(r.updateMatrix(),Yt(r.parent)&&Gt(r)&&r.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&r.updateWorldMatrix(!1,!0),r.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(r.isUpVectorFlipped=e.isUpVectorFlipped),r.updateUp())}function TH(r,e){Ix(r,e),e.name!==void 0&&(r.name=e.name),e.visible!==void 0&&(r.visible=e.visible)}function RE(r,e,t){TH(r,e),e.color!==void 0&&(r.color=zr(e.color,t)),e.intensity!==void 0&&(r.intensity=e.intensity),e.shadows!==void 0&&!(r instanceof Da)&&(r.castShadow=e.shadows),r.shadow&&!(r instanceof Da)&&e.depth!==void 0&&(r.shadow.camera.far=e.depth,r.shadow.needsUpdate=!0)}function BE(r,e){r.shadow.camera.right=e/2,r.shadow.camera.left=-e/2,r.shadow.camera.top=e/2,r.shadow.camera.bottom=-e/2,r.shadow.needsUpdate=!0}var og=r=>class extends r{hasEntityChild(){return this.children.some(t=>di(t))}isDescendantOf(t){t instanceof yt&&(t=t.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===t)return!0;n=n.parent}return!1}attach(t,n){this.updateWorldMatrix(!0,!1);let i=new we().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),di(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),n!==void 0&&(this.children.pop(),this.children.splice(n,0,t)),this}copy(t,n=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}};var hu=new Lt,Oi=new T,us=new T,fu=new we,FE=[new T(-1,1,1),new T(-1,-1,1),new T(1,-1,1),new T(1,1,1),new T(-1,1,-1),new T(-1,-1,-1),new T(1,-1,-1),new T(1,1,-1)],_H=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],MH=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function EH(r,e,t=0,n=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t;c<n;c++){let h=e.getX(c),f=e.getY(c),d=e.getZ(c);h<i&&(i=h),f<s&&(s=f),d<o&&(o=d),h>a&&(a=h),f>l&&(l=f),d>u&&(u=d)}return r.min.set(i,s,o),r.max.set(a,l,u),r}var NE=(r,e,t)=>{if(Gt(r)){let n=r.geometry.userData.parameters,i=r.geometry.getAttribute("position");r.geometry.userData.type==="SubdivGeometry"?Oi.copy(r.originalGeometry.boundingSphere.center):r.geometry.userData.type==="TextGeometry"?Oi.set(0,0,n.depth*.5):i!==void 0&&(EH(hu,i,r.geometry.drawRange.start,r.geometry.drawRange.count<1/0?r.geometry.drawRange.count:i.count),hu.getCenter(Oi)),r.forceComputeSize?hu.getSize(us).multiplyScalar(.5):us.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}else if(sg(r)&&r.objectHelper.visible){let n=r.geometryHelper.getAttribute("position");hu.setFromArray(n.array),hu.getCenter(Oi),hu.getSize(us).multiplyScalar(.5)}else Oi.setScalar(0),us.setScalar(0);fu.copy(e).multiply(r.matrixWorld),us.x===0&&us.y===0&&us.z===0?t.push(new T(Oi.x,Oi.y,Oi.z).applyMatrix4(fu)):FE.forEach(n=>{t.push(n.clone().multiply(us).add(Oi).applyMatrix4(fu))})},yf=class extends Lt{constructor(){super(...arguments);this.matrix=new we;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(n=>n.clone()),this.faces=t.faces.map(n=>n.clone()),this.edges=t.edges.map(n=>n.clone()),this.centerEdges=t.centerEdges.map(n=>n.clone()),this}setFromObjectSize(t,n=!1){t.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new we().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,n)}expandByObjectSize(t,n,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&NE(o,n,s)}):NE(t,n,s),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(fu.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(us).multiplyScalar(.5),this.getCenter(Oi),fu.copy(this.matrix).setPosition(Oi),this.vertices=FE.map(t=>t.clone().multiply(us).applyMatrix4(fu))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=_H.map(([t,n])=>new _r(this.vertices[t],this.vertices[n])),this.centerEdges=this.edges.map(t=>t.getCenter(new T))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=MH.map(([t,n])=>this.vertices[t].clone().add(this.vertices[n]).multiplyScalar(.5))}};var hs=r=>"isEntity"in r,kE=r=>"isAbstractMesh"in r,pi=r=>class extends og(r){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new we;this._singleBBox=new yf;this._recursiveBBox=new yf;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1;this.states={};this.currentState=null;this.currentTransitionAction=null}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(n=>{hs(n)&&(n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(n=>{n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0})}traverseEntity(n){n(this);for(let i of this.children)hs(i)&&i.traverseEntity(n)}traverseVisibleEntity(n){n(this);for(let i of this.children)hs(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}clone(n){return new this.constructor().copy(this,n)}copy(n,i=!0){if(super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),i===!0)for(let s of n.children)hs(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let n=new we,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),n.copy(this.matrixWorld).invert(),n.multiply(i);for(let s of this.children)hs(s)&&s.hiddenMatrix.premultiply(n)}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Cc(i,n)}fromObjectTransformState(n){return n.position&&this.position.fromArray(n.position),n.rotation&&this.rotation.fromArray(n.rotation),n.scale&&this.scale.fromArray(n.scale),n.hiddenMatrix&&this.hiddenMatrix.fromArray(n.hiddenMatrix),this.updateMatrix(),this}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return Cc(i,n)}fromState(n,i){return n.name&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.type!=="OrthographicCamera"&&n.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),n.visible!==void 0&&(this.visible=n.visible),this.fromObjectTransformState(n),this}};var xf=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};var Vr=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=ze.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,n){return n=n??{},this.analyze(e,n),this.flow(e,t,n)}flow(e,t,n){n=n??{},e.addFlow(n.slot,n.cache,n.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,n){t=t??this.getType(e,t);let i=e.getNodeData(n??this);return e.analyzing&&this.appendDepsNode(e,i,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,n)}updateFrame(e){}generateReadonly(e,t,n,i,s,o){return""}generate(e,t,n,i,s){return""}parse(e,t,n,i){}appendDepsNode(e,t,n){t.deps=(t.deps||0)+1;let i=e.getTypeLength(n);(i>(t.outputMax||0)||this.getType(e,n))&&(t.outputMax=i,t.output=n)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,n;for(t in this)n=this[t],n instanceof Vr&&(e+='"'+t+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)t=this.hashProperties[i],n=this[t],e+='"'+t+'":"'+String(n)+'",';return e+='"id":"'+this.uuid+'"}',e}};var Lx=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,n){n=n!==void 0?n:!0,this.keywords[e]={callback:t,cache:n}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Dr=new Lx;var qe=class extends Vr{constructor(t,n){super(t);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(t,n,i,s){if(n=n??this.getType(t),this.getShared(t,n)){let o=this.getUnique(t,n);o&&this.uuid===void 0&&(this.uuid=ze.generateUUID()),i=t.getUUID(i??this.getUUID(),!o);let a=t.getNodeData(i),l=a.output||this.getType(t);if(t.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(t,a,n),this.generate(t,n,i)):super.build(t,n,i);if(o)return a.name=a.name||super.build(t,n,i),a.name;if(!this.getLabel()&&(!this.getShared(t,l)||t.context.ignoreCache||a.deps===1))return super.build(t,n,i);i=this.getUUID(!1);let u=this.getTemp(t,i);if(u)return t.format(u,l,n);{u=super.generate(t,n,i,a.output,s);let c=this.generate(t,l,i);return t.addNodeCode(u+" = "+c+";"),t.format(u,l,n)}}return super.build(t,n,i)}getShared(t,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(t,n){return this.unique}setLabel(t){return this.label=t,this}getLabel(){return this.label}getUUID(t){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(t,n){n=n||this.uuid;let i=t.getVars()[n];return i?i.name:void 0}generate(t,n,i,s,o){return this.getShared(t,n)||console.error("TempNode is not shared"),i=i??this.uuid,t.getTempVar(i,s??this.getType(t),o,this.getLabel()).name}};var Ut=class extends qe{constructor(t,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(t,n);this.readonly=!1}setReadonly(t){return this.readonly=t,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(t,n,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(t,n,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,n))}};var Hr=class extends Ut{constructor(t=0,n){super("v2");this.nodeType="Vector2";this.value=t instanceof k?t:new k(t,n)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}generateReadonly(t,n,i,s,o,a){return t.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var Zr=class extends Ut{constructor(t=0,n,i){super("v3");this.nodeType="Vector3";this.value=t instanceof T?t:new T(t,n,i)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}get z(){return this.value.z}set z(t){this.value.z=t}generateReadonly(t,n,i,s,o,a){return t.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var or=class extends Be{constructor(t,n,i,s){super(t,n,i);this.isColorA=!0;this.a=s}setRGBA(t,n,i,s){super.setRGB(t,n,i),this.a=s}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}};var mi=class extends Ut{constructor(t){super("v4");this.nodeType="Vector4";this.value=t instanceof or?t:new or(t.r,t.g,t.b,t.a)}generateReadonly(t,n,i,s,o,a){return t.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var CH=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,UE=/[a-z_0-9]+/gi,Ee=class extends qe{constructor(t,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(t,n,i,s)}getShared(t,n){return!this.isMethod}getType(t){return t.getTypeByFormat(this.type)}getInputByName(t){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}}getIncludeByName(t){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===t)return this.includes[n]}}generate(t,n,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)t.include(this.includes[h],this);for(let h in this.extensions)t.extensions[h]=!0;let c=[];for(;a=UE.exec(this.src);)c.push(a);for(let h=0;h<c.length;h++){let f=c[h],d=f[0],m=this.isMethod?!this.getInputByName(d):!0,p=d;if(this.keywords[d]||this.useKeywords&&m&&Dr.containsKeyword(d)){let g=this.keywords[d];if(!g){let v=Dr.getKeywordData(d);v.cache&&(g=t.keywords[d]),g=g||Dr.getKeyword(d,t),v.cache&&(t.keywords[d]=g)}p=g.build(t)}d!==p&&u[f.index+l-1]!=="."&&(u=u.substring(0,f.index+l)+p+u.substring(f.index+d.length+l),l+=p.length-d.length),this.getIncludeByName(p)===void 0&&Dr.contains(p)&&t.include(Dr.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||t.include(this,void 0,u),this.name):t.format("( "+u+" )",this.getType(t),n)}parse(t,n,i,s){if(this.src=t||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=CH.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(UE);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let h=a[l++];this.inputs.push({name:h,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var PH=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Ox=class extends qe{constructor(t="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(t||Ox.PI,void 0,void 0,void 0,n)}getType(t){return t.getTypeByFormat(this.type)}parse(t,n,i,s,o){this.src=t||"";let a,l,u="",c=PH.exec(t);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(t,n){if(n==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return t.include(this),t.format(this.name,this.getType(t),n)}generate(t,n,i,s,o){return t.format(this.name,this.getType(t),n)}},bt=Ox;bt.PI="PI",bt.PI2="PI2",bt.RECIPROCAL_PI="RECIPROCAL_PI",bt.RECIPROCAL_PI2="RECIPROCAL_PI2",bt.LOG2="LOG2",bt.EPSILON="EPSILON";var DH=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3140
3140
|
)*?)}`,"gim"),IH=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),du=class extends qe{constructor(t=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(t)}getType(t){return t.getTypeByFormat(this.name)}getInputByName(t){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}generate(t,n,i,s,o){return n==="source"?this.src+";":t.format("( "+this.src+" )",this.getType(t),n)}parse(t=""){this.src=t,this.inputs=[];let n=DH.exec(t);if(n){let i=n[2],s;for(;s=IH.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var pu=class extends qe{constructor(t){super("v2",{shared:!1});this.nodeType="UV";this.index=t??0}generate(t,n){t.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=t.isShader("vertex")?"uv"+i:"vUv"+i;return t.format(s,this.getType(t),n)}};Dr.addKeyword("uv",function(){return new pu});Dr.addKeyword("uv2",function(){return new pu(1)});var Ka=class extends qe{constructor(t,n){super("v4");this.nodeType="ColorSpace";this.input=t,this.method=n??Ka.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(t){switch(t){case Gn:return["Linear"];case Ke:return["sRGB"];default:return[]}}generate(t,n){let i=this.input.build(t,"v4"),s=this.getType(t),o=Ka.Nodes[this.method],a=t.include(o);if(a===Ka.LINEAR_TO_LINEAR)return t.format(i,s,n);if(o.inputs?.length===2){let l=this.factor.build(t,"f");return t.format(a+"( "+i+", "+l+" )",s,n)}else return t.format(a+"( "+i+" )",s,n)}fromEncoding(t){let n=Ka.getEncodingComponents(t);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(t){let n=Ka.getEncodingComponents(t);this.method=n[0]+"ToLinear",this.factor=n[1]}},Sn=Ka;Sn.Nodes={LinearToLinear:new Ee(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3141
3141
|
`)),sRGBToLinear:new Ee(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
3142
3142
|
`)),LinearTosRGB:new Ee(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
|
|
@@ -4913,7 +4913,7 @@ gl_FragColor = vec4(resultColor, vColor.r);
|
|
|
4913
4913
|
<svg width="${R}" height="${w*.4}" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
4914
4914
|
<path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4915
4915
|
</svg>
|
|
4916
|
-
`,D.addEventListener("pointerdown",()=>{y.forEach(N=>{N[0].movementState.jump=1}),i()}),D.addEventListener("touchend",N=>N.preventDefault()),this.joysticks[b]=[void 0,S];return}let P={zone:S,mode:"static",position:M,size:w};_==="hide"&&(P.restOpacity=0);let L=dP.create(P);L.on("move",(D,R)=>{y.forEach(N=>{let U=N[0];N[1]==="pos"?R.force<.2?U.moveForce=0:(U.movementState.movePosZ=Math.sin(-R.angle.radian),U.movementState.movePosX=Math.cos(-R.angle.radian),R.force<.3?U.moveForce=(R.force-.2)/.1:U.moveForce=1):R.force<.2?U.rotForce=0:(U.movementState.rotPosX=R.vector.y,U.movementState.rotPosY=-R.vector.x,R.force<.3?U.rotForce=(R.force-.2)/.1:U.rotForce=1)}),i()}),L.on("end",(D,R)=>{y.forEach(N=>{let U=N[0];N[1]==="pos"?(U.movementState.movePosZ=0,U.movementState.movePosX=0,U.moveForce=1):(U.movementState.rotPosX=0,U.movementState.rotPosY=0,U.rotForce=1)})}),this.joysticks[b]=[L,S]}),this.usePhysics===!1&&this.needsCollisionDetection&&this.initBVH(),this.initializationCounter++}initBVH(){let e=[];this.scene.updateMatrixWorld(!0);let t=new Set;if(this.scene.traverse(n=>{if(!!di(n))if(!n.visible||t.has(n))n.children.forEach(i=>di(i)&&t.add(i));else if(Object.keys(n.states).length||n.data?.events.some(i=>i.data.type==="GameControl")){let i=[];n.matrixWorld.decompose(ln,vi,ji);let s=new we().compose(ln,vi,o7);Gt(n)&&i.push(ia(n.geometry,dd.makeScale(ji.x,ji.y,ji.z))),n.updateMatrixWorld();let o=s.clone().invert();if(n.traverse(a=>{!Gt(a)||(a.updateMatrixWorld(),dd.multiplyMatrices(o,a.matrixWorld),i.push(ia(a.geometry,dd)))}),i.length>0){let a=Zs(i,!1);n.boundsTree=new sr(a),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(n)}}else Gt(n)&&!this.sharedGameControlGlobals.entitiesWithTransformAnim.some(i=>n.isDescendantOf(i))&&e.push(ia(n.geometry,n.matrixWorld))}),e.length>0){let n=Zs(e,!1);this.sharedGameControlGlobals.staticMeshBVH=new sr(n)}}addCollider(e,t,n,i,s=!0){let o=e.rigidBody,a;i!==void 0?i.collider.type==="sphere"?a=cr.ColliderDesc.ball(i.collider.radius/this.pixelsPerMeter):i.collider.type==="capsule"?a=cr.ColliderDesc.capsule((i.collider.height/2-i.collider.radius)/this.pixelsPerMeter,i.collider.radius/this.pixelsPerMeter):a=cr.ColliderDesc.cuboid(i.collider.width/this.pixelsPerMeter/2,i.collider.height/this.pixelsPerMeter/2,i.collider.depth/this.pixelsPerMeter/2):n.colliderType==="trimesh"?a=cr.ColliderDesc.trimesh(t.getAttribute("position").array,t.getIndex().array):a=cr.ColliderDesc.convexMesh(t.getAttribute("position").array,s?t.getIndex().array:void 0),a.setFrictionCombineRule(cr.CoefficientCombineRule.Average).setRestitutionCombineRule(cr.CoefficientCombineRule.Average).setDensity(n.density).setFriction(n.friction).setRestitution(n.restitution);let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,o);if(this.sharedGameControlGlobals.colliderToEntity[l.handle]=e,i!==void 0){ln.fromArray(i.collider.position).multiply(ji.setFromMatrixScale(e.matrixWorld)).divideScalar(this.pixelsPerMeter),l.setTranslationWrtParent(ln);let u=new ut().setFromEuler(new tr().setFromVector3(new T().fromArray(i.collider.rotation)));l.setRotationWrtParent(u),l.setActiveEvents(cr.ActiveEvents.COLLISION_EVENTS)}else n.rigidBody==="dynamic"&&this.sharedGameControlGlobals.eventsPerObjects[e.uuid]?.some(u=>u.target==="scene")&&l.setActiveEvents(cr.ActiveEvents.COLLISION_EVENTS)}initPhysics(e){this.sharedGameControlGlobals.rapierWorld=new cr.World(new cr.Vector3(0,e??-10,0)),this.events=new cr.EventQueue(!0);let t=[],n=[],i=[];if(this.sceneGraph.traverse((u,c)=>{let h=this.scene.find(u);if(h&&di(h)&&h.visible){let f,d=c.states.some(p=>p.data.position!==void 0||p.data.rotation!==void 0||p.data.hiddenMatrix!==void 0),m=!1;for(let p of c.events)if(p.data.type==="GameControl")f=p.data;else if(p.data.type==="Collision"){m=!0;let g=new cv(p.data,h,this.scene,this.sharedAssets);this.sharedGameControlGlobals.eventsPerObjects[h.uuid]?this.sharedGameControlGlobals.eventsPerObjects[h.uuid].push(g):this.sharedGameControlGlobals.eventsPerObjects[h.uuid]=[g]}if(n.some(p=>this.sceneGraph.isDescendantOf(u,p)))return;if(!c.physics){n.push(u);return}if(i.some(p=>this.sceneGraph.isDescendantOf(u,p)))return;if(c.physics.fusedBody===!0&&i.push(u),h.matrixWorld0=void 0,c.physics.rigidBody==="dynamic"&&c.physics.fusedBody===!1&&(h.matrixWorld0=h.matrixWorld.clone()),c.physics.rigidBody==="dynamic"||d||m||f!==void 0){let p=[];Gt(h)&&p.push(ia(h.geometry));let g=h.matrixWorld.clone().invert();if(c.physics.fusedBody&&h.traverse(v=>{!Gt(v)||v===h||(dd.multiplyMatrices(g,v.matrixWorld),p.push(ia(v.geometry,dd)))}),p.length>0){let v=Zs(p);v.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter),h.matrixWorld.decompose(ln,vi,ji),v.scale(ji.x,ji.y,ji.z),ln.divideScalar(this.pixelsPerMeter);let y;f!==void 0?y=cr.RigidBodyDesc.kinematicPositionBased():c.physics.rigidBody==="dynamic"?(y=cr.RigidBodyDesc.dynamic(),y.setLinearDamping(c.physics.damping).setAdditionalMass(0).setGravityScale(c.physics.gravityScale).enabledRotations(...c.physics.enabledRotation).enabledTranslations(...c.physics.enabledTranslation)):d?(y=cr.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(h)):y=cr.RigidBodyDesc.fixed(),y.setTranslation(ln.x,ln.y,ln.z).setRotation({w:vi.w,x:vi.x,y:vi.y,z:vi.z});let b=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);f===void 0&&c.physics.rigidBody==="dynamic"&&this.rigidBodyToMesh.set(b.handle,[h,ji.clone(),c.physics.fusedBody]),h.rigidBody=b;let S=!(c.geometry===void 0||c.geometry.type==="SubdivGeometry"||c.geometry.type==="NonParametricGeometry"||c.geometry.type==="BooleanGeometry"||c.geometry.type==="VectorGeometry"||c.geometry.type==="StarGeometry"||c.geometry.type==="TorusGeometry"||c.geometry.type==="HelixGeometry");this.addCollider(h,v,c.physics,f,S)}}else this.gameControlStates.some(([p])=>h.isDescendantOf(p))||(Gt(h)&&t.push(ia(h.geometry,h.matrixWorld)),c.physics.fusedBody&&h.traverse(p=>{!Gt(p)||p===h||t.push(ia(p.geometry,p.matrixWorld))}))}}),t.length===0)return;let s=Zs(t);s.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let o=cr.RigidBodyDesc.fixed(),a=this.sharedGameControlGlobals.rapierWorld.createRigidBody(o),l=cr.ColliderDesc.trimesh(s.getAttribute("position").array,s.getIndex().array).setFrictionCombineRule(cr.CoefficientCombineRule.Multiply).setRestitutionCombineRule(cr.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(l,a)}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}dispose(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.staticMeshBVH=void 0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.gameControls.forEach(e=>{e.reset(),e.dispose()}),this.gameControls=[],this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls?.dispose(),this.orbitControls=void 0;for(let e of Object.values(this.sharedGameControlGlobals.eventsPerObjects))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.eventsPerObjects={},this.scene.updateMatrixWorld(!0)}update(e){let t=!0;if(this.orbitControls!==void 0&&(t=!this.orbitControls.update(e)),this.initializationCounter>=0&&this.initializationCounter<2)this.initializationCounter++,t=!1;else if(this.initializationCounter===2)for(let n of this.gameControls)t=!n.update(e)&&t;if(this.usePhysics&&(this.gameControls.length===0||this.needsCollisionDetection)){for(let n of this.sharedGameControlGlobals.entitiesWithTransformAnim){n.matrixWorld.decompose(ln,vi,ji),yS.setFromQuaternion(vi);let i=n;i.prevR===void 0?(i.prevR=yS.clone(),i.prevT=ln.clone()):(i.prevR.copy(yS),i.prevT.copy(ln)),n.rigidBody.setNextKinematicTranslation(ln.divideScalar(this.pixelsPerMeter)),n.rigidBody.setNextKinematicRotation(vi)}this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),t=!this.updatePositions()&&t}return t}dispatchCollisionEvent(e,t){t.dispatchEvent(xS),e.dispatch()}};var bS={type:"change"},a7={type:"lock"},l7={type:"unlock"},c7=new T,cl=new T,u7=new T,Rr=new T,Jr=new T,$n=new T,md=new we,SD=new we,h7=new we,f7=new we,Uu=new ut,gd=new ut,d7=new tr(0,0,0,"YXZ"),ul=new T(0,1,0),SS=new T(1,1,1),p7=1,m7=.025,g7=16e-6,v7=12,y7=20,cn=new _r,yi=new Lt,hv=class extends kt{constructor(t,n,i,s,o,a,l,u,c,h){super();this.object=t;this.sceneGraph=n;this.domElement=i;this.sharedGameControlGlobals=a;this.cameraFollow=l;this.camera=u;this.scene=c;this.sharedAssets=h;this.enableDamping=!0;this.position0=new T;this.rotation0=new tr(0,0,0,"XYZ");this.scale0=new T;this.hiddenMatrix0=new we;this.target0=new T;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.euler0=new tr(0,0,0,"YXZ");this.position0Cam=new T;this.quat0Cam=new ut;this.scale0Cam=new T;this.hiddenMatrix0Cam=new we;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.collider={radius:40,segment:new _r(new T(0,-40,0),new T(0,40,0)),matrix:new we,position:new T,rotation:new ut};this.euler=new tr(0,0,0,"YXZ");this.eulerDelta=new T;this.lastQuaternion=new ut;this.lastPosition=new T;this.lastCameraQuaternion=new ut;this.lastCameraPosition=new T;this.PI_2=Math.PI/2;this.prevMouse=new k;this.velocityTarget=new T;this.velocity=new T;this.directionXZ=new T;this.rotVelocityStick=new T;this.rotVelocityTarget=new T;this.rotVelocity=new T;this.rotDirection=new T;this.objectRot={x:0,y:0};this.firstPointerId=-1;this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0};this.onObject=!1;this.actionState={};this.slopeAdjust=!1;this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]];this.collisionEnabled=!0;this.offsetMatrix=new we;this.objectToTarget=new T;this.objectToTarget0=new T;this.objectToCamXZ=new T;this.objectToCamXZ0=new T;this.targetToCamera=new T;this.targetToCamera0=new T;this.cameraPolarAxis0=new T;this.targetPos=new T;this.targetQuat=new ut;this.lerpFactorPos=new T().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new ut;this.objXZQuatInv=new ut;this.objXZRotMat=new we;this.isFirstPerson=!1;this.actions={};this.lastDummyPos=new T;this.lastDummyPosDelta=new T;this.hit=null;this.groundVelocity=new T;this.pushedVelocity=new T;this.groundYRotation=0;this.objectRealQuat=new ut;this.colliderWorldQuat=new ut;this.groundNormal=new T;this.lastHitObj=null;this.isFirstFrame=!0;this.onPointerDown=t=>{t.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=t.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Er&&(!Nc||Fc>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(t.clientX,t.clientY))};this.onPointerUp=t=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),t.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=t=>{if(t.pointerId!==this.firstPointerId)return;let n=t.clientX-this.prevMouse.x,i=t.clientY-this.prevMouse.y;this.prevMouse.set(t.clientX,t.clientY),t.pointerType==="mouse"&&this.rotBy!=="keys"&&(Nc&&Fc<15.5&&!Er?(this.eulerDelta.y=-n*this.mouseOrbitSensitivity,this.eulerDelta.x=-i*this.mouseOrbitSensitivity):(this.eulerDelta.y=-t.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-t.movementY*this.mouseOrbitSensitivity)),t.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-n*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-i*this.mouseOrbitSensitivity*5),this.dispatchEvent(bS)};this.onPointerlockChange=t=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(a7),hv.isLocked=!0):(this.dispatchEvent(l7),hv.isLocked=!1)};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.onKeyDown=t=>{t.preventDefault();for(let n of this.keyAssignments)if(t.key.toUpperCase()===n[1]||t.key===n[1]){this.movementState[n[0]]=1;break}this.dispatchEvent(bS)};this.onKeyUp=t=>{for(let n of this.keyAssignments)if(t.key.toUpperCase()===n[1]||t.key===n[1]||t.code.slice(3,t.code.length).toUpperCase()===n[1]){this.movementState[n[0]]=0;break}};this.resetChildrenToBaseState=(t,n)=>{t!==this.object.uuid&&iS(this.scene.find(t),n,null,this.sharedAssets)};if(t.objectType==="CombinedCamera"&&(this.isFirstPerson=!0),this.position0.copy(this.object.position),this.rotation0.copy(this.object.rotation),this.scale0.copy(this.object.scale),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale),this.object.rotation.reorder("YXZ"),this.euler0.copy(this.object.rotation),this.isFirstPerson===!1){let m=this.object.rotation.y;this.objectRealQuat.copy(this.object.quaternion),this.object.rotation.y=0,this.objXZQuat.copy(this.object.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),this.object.rotation.set(0,m,0)}if(this.object.matrixAutoUpdate=!1,this.isFirstPerson){let m=this.object;this.target0.copy(m.getTarget()),this.zoom0=m.zoom}else this.cameraFollow===!0&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom);if(this.cameraFollow===!0){if(this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera?.parent?.parent){let y=this.camera.matrix.clone().invert().premultiply(this.camera.matrixWorld),b=y.clone().invert();this.camera.hiddenMatrix.multiply(b),this.camera.matrix.premultiply(y),this.camera.matrixWorld.decompose(this.camera.position,this.camera.quaternion,this.camera.scale)}this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let m=new T(0,0,-1).applyQuaternion(this.camera.quaternion),p=new T().subVectors(this.object.position,this.camera.position);this.objectToCamXZ.copy(p),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g;if(Math.abs(m.y)<1e-6){p.y=0,m.y=0;let y=p.projectOnVector(m);this.targetToCamera0.copy(y).negate(),g=this.camera.position.clone().add(y)}else{let y=m.multiplyScalar(p.y/m.y);this.targetToCamera0.copy(y).negate(),g=y.clone().add(this.camera.position)}this.objectToTarget0.subVectors(g,this.object.position);let v=new tr().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-v.x,v.x=0,v.z=0,v.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(v)}if(this.isObjectCamera=this.object.objectType==="CombinedCamera",this.euler.setFromQuaternion(this.object.quaternion,"YXZ"),this.connect(),this.rotByTouch=s.rotByTouch??"joystick",this.rotBy=s.rotBy??"keys",this.rotationMode=s.rotationMode??"normal",this.moveMode=s.moveMode??"walk",this.collisionEnabled=s.collisionEnabled,this.speedTranslate=(s.speedTranslate??250)*p7,this.speedOrbit=(s.speedRotate??100)*m7,this.mouseOrbitSensitivity=(s.speedRotate??100)*g7,this.keyAssignments=s.keyAssignments.map(m=>{let p=[m[0],m[1]];return p[1]==="\u25B2"?p[1]="ArrowUp":p[1]==="\u25C0"?p[1]="ArrowLeft":p[1]==="\u25BC"?p[1]="ArrowDown":p[1]==="\u25B6"?p[1]="ArrowRight":p[1]==="\u21E7"?p[1]="Shift":p[1]==="\u21B5"?p[1]="Enter":p[1]==="Space"?p[1]=" ":p[1]==="\u2318"?p[1]="Meta":p[1]==="Ctrl"?p[1]="Control":p[1]==="Esc"&&(p[1]="Escape"),p}),s.rotBy==="mouse"){let m;m=this.keyAssignments.findIndex(p=>p[0]==="rotNegX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotPosX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotPosY"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotNegY"),m!==-1&&(this.keyAssignments[m][1]="")}this.lerpFactorPosStart=1-.02**(1/((s.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((s.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((s.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((s.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((s.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((s.delayRotCamera??.3)*60)),this.gravity=(o.gravity??li.defaultData.gravity)*v7,this.pixelsPerMeter=o.pixelsPerMeter??li.defaultData.pixelsPerMeter,this.usePhysics=o.usePhysics??li.defaultData.usePhysics,this.jumpPower=s.jumpPower*y7,this.resetYPosition=s.resetYPosition,this.orientMode=s.autoOrientMove?s.orientMode:"none",s.collider.type==="capsule"?(this.collider.radius=s.collider.radius,this.collider.segment.start.y=s.collider.height/2-s.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y):s.collider.type==="sphere"&&(this.collider.radius=s.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0);let f=new T().fromArray(s.collider.position),d=new ut().setFromEuler(new tr().fromArray([...s.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.object.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(f,d,SS),s.cameraXAxis!==void 0&&(this.cameraXAxis=s.cameraXAxis,this.cameraYAxis=s.cameraYAxis,this.minPolarAngle=s.cameraRotXLimits[0],this.maxPolarAngle=s.cameraRotXLimits[1],this.minAzimuthAngleRel=s.cameraRotYLimits[0],this.maxAzimuthAngleRel=s.cameraRotYLimits[1]),s.gameActions!==void 0&&Object.entries(s.gameActions).forEach(([m,p],g)=>{p.forEach(({id:v,data:y})=>{try{this.actions[m]===void 0&&(this.actions[m]=[]),y.type==="Transition"?this.actions[m].push(new Ps(v,y,c,h)):y.type==="Audio"&&this.actions[m].push(new Ms(v,y,t,h))}catch{}})}),this.dispatchStopEvent("move"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle")}reset(t=!1){if(this.object.rotation.copy(this.rotation0),this.object.position.copy(this.position0),this.object.scale.copy(this.scale0),this.object.hiddenMatrix.copy(this.hiddenMatrix0),t===!0){if(this.object.rotation.reorder("YXZ"),this.isFirstPerson===!1){let n=this.object.rotation.y;this.object.rotation.y=0,this.objXZQuat.copy(this.object.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),this.object.rotation.set(0,n,0)}this.euler.setFromQuaternion(this.object.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}this.isObjectCamera?this.object.matrixAutoUpdate=!0:this.object.updateMatrix(),this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.dispatchEvent(bS)}connect(){this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError)}disconnect(){this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError)}dispose(){this.disconnect(),Object.values(this.actions).forEach(t=>{t.forEach(n=>{(n instanceof Ps||n instanceof Ms)&&n.dispose()})})}resetTo(t,n,i){}dispatchStartEvent(t){this.actions[t]!==void 0&&(this.actionState[t]=!0,this.actions[t].forEach(n=>{n instanceof Ps?n.play():n instanceof Ms&&n.dispatchGameControl("start")}))}dispatchStopEvent(t){this.actions[t]!==void 0&&(this.actionState[t]=!1,this.actions[t].forEach(n=>{n instanceof Ps?n.stop():n instanceof Ms&&n.dispatchGameControl("stop")}))}update(t){if(this.gravity<0?this.object.position.y<this.resetYPosition:this.object.position.y>this.resetYPosition)return this.reset(!0),!0;let n=(this.isFirstFrame?16.6:t)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=n*60;if(this.usePhysics){let o=Jr.set(0,-(this.jumpPower+this.gravity*i)*n*.5,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(Rr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,void 0,void 0,void 0,this.object.rigidBody);if(this.slopeAdjust=!1,a){this.slopeAdjust=!1,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),Math.acos(this.groundNormal.y)*180/Math.PI>45?this.onObject=!0:(this.slopeAdjust=!0,this.onObject=!0);let l=a.collider._parent;this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(u.rigidBody===l){u.matrixWorld.decompose(Rr,gd,Jr),this.groundVelocity.subVectors(Rr,u.prevT),this.object.getWorldPosition(Jr).add(this.collider.position).sub(u.position),this.groundYRotation=d7.setFromQuaternion(gd).y-u.prevR.y,$n.copy(Jr).applyAxisAngle(ul,this.groundYRotation),this.groundVelocity.add($n.sub(Jr)).divideScalar(n);break}}else this.onObject=!1}this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("jump"),this.sceneGraph.traverseFrom(this.object.uuid,this.resetChildrenToBaseState),this.dispatchStartEvent("jump"),this.onObject=!1),this.velocityTarget.y+=this.onObject?0:this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.directionXZ.normalize(),this.movementState.moveNegZ||this.movementState.movePosZ?this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce:this.velocityTarget.z=0,this.movementState.moveNegX||this.movementState.movePosX?this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce:this.velocityTarget.x=0,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.hit===null&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),this.sceneGraph.traverseFrom(this.object.uuid,this.resetChildrenToBaseState),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("move")));let s=u7.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1&&this.cameraYAxis!=="Locked"){let o=Jr.copy(s);o.y=0,s.set(0,s.y,o.length()*-1)}if(s.applyQuaternion(this.object.quaternion),this.slopeAdjust&&(gd.setFromUnitVectors(ul,this.groundNormal),s.applyQuaternion(gd)),this.usePhysics===!0){let o=Jr;this.pushedVelocity.set(0,0,0);for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){a.parent?.matrixWorld0?(md.multiplyMatrices(a.parent?.matrixWorld0,a.matrix),$n.setFromMatrixPosition(md)):$n.copy(a.position);let l=$n.sub(a.prevT).divideScalar(n);l.divideScalar(this.pixelsPerMeter);let u=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),Rr.copy(s).divideScalar(this.pixelsPerMeter),n);if(l.multiplyScalar(this.pixelsPerMeter),u!==null){this.pushedVelocity.copy(l),o.copy(u.normal1).applyQuaternion(a.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let a=o.dot(s);a<0&&s.addScaledVector(o,-a),s.add(this.pushedVelocity)}else s.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(n),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*n,this.euler.y+=this.rotVelocity.y*n+this.groundYRotation,this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){let o=Rr,a=Jr.copy(this.directionXZ);a.x*=-1,this.camera.getWorldDirection(o);let l=$n.copy(ul).multiplyScalar(o.dot(ul));if(o.sub(l),$n.copy(this.collider.position).applyQuaternion(this.object.quaternion),this.object.rotation.y=o.angleTo(a)*(o.cross(a).y>0?-1:1),cl.copy(this.collider.position).applyQuaternion(this.object.quaternion),cl.sub($n),this.object.position.sub(cl),this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(ul,this.euler.y-this.euler0.y);let u=Jr.copy(this.objectToCamXZ).normalize(),c=$n.copy(s).multiplyScalar(n);c.y=0;let h=c.sub(Rr.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}if(this.cameraFollow===!0&&this.moveMode==="walk"&&this.isFirstPerson===!1?this.cameraXAxis==="Limit"?this.euler.x=ze.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=ze.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):(this.cameraXAxis==="Limit"||this.isFirstPerson||this.cameraFollow===!0)&&(this.euler.x=ze.clamp(this.euler.x,-this.PI_2,this.PI_2)),(this.isFirstPerson||this.moveMode!=="walk")&&(this.object.rotation.x=this.euler.x),(this.isFirstPerson||this.orientMode==="none"||this.cameraYAxis==="Locked")&&($n.copy(this.collider.position).applyQuaternion(this.object.quaternion),this.object.rotation.y=this.euler.y,cl.copy(this.collider.position).applyQuaternion(this.object.quaternion),cl.sub($n),this.object.position.sub(cl)),this.object.rotation.x=ze.clamp(this.object.rotation.x,-this.PI_2,this.PI_2),this.objectRot.x=this.euler.x,this.objectRot.y=this.euler.y,this.objectRealQuat.multiplyQuaternions(this.object.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){if(this.hit=this.sharedGameControlGlobals.rapierWorld.castShape(Rr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,Jr.copy(s).divideScalar(this.pixelsPerMeter),this.object.rigidBody?.collider(0).shape,n,8,void 0,void 0,this.object.rigidBody),this.hit!==null){let o=this.sharedGameControlGlobals.colliderToEntity[this.hit.collider.handle];if(o!==this.lastHitObj){this.lastHitObj=o;let l=this.sharedGameControlGlobals.eventsPerObjects[o?.uuid];if(l)for(let u of l)u.data.target==="character"&&(o.dispatchEvent(xS),u.dispatch())}let a=Rr.set(this.hit.normal2.x,this.hit.normal2.y,this.hit.normal2.z).applyQuaternion(this.colliderWorldQuat);if(this.hit.toi>0){let l=Jr.copy(s).multiplyScalar(this.hit?.toi).dot(a),u=this.hit.toi;l>2&&(u=this.hit.toi*(l-2)/l,this.object.position.addScaledVector(s,u));let c=Jr.copy(s).multiplyScalar(n-u);a.multiplyScalar(c.dot(a));let h=c.sub(a),f=this.sharedGameControlGlobals.rapierWorld.castShape(Rr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,$n.copy(h).divideScalar(this.pixelsPerMeter),this.object.rigidBody?.collider(0).shape,20,8,void 0,void 0,this.object.rigidBody);if(f===null)this.object.position.add(h);else if(f.toi>1){let d=Rr.set(f.normal2.x,f.normal2.y,f.normal2.z).applyQuaternion(this.colliderWorldQuat);Jr.copy(h).dot(d)>2&&this.object.position.add(h)}this.lastDummyPosDelta.subVectors(this.object.position,this.lastDummyPos),this.lastDummyPos.copy(this.object.position)}}else this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),this.object.position.addScaledVector(s,n);this.object.rigidBody?.setTranslation(Rr.copy(this.object.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Uu.copy(this.object.quaternion).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,a=s.multiplyScalar(n/o);for(let l=0;l<o;l++)this.object.position.add(a),this.collisionAdjustment(n/o)}else this.object.position.addScaledVector(s,n);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.isFirstPerson===!1&&this.object.quaternion.multiply(this.objXZQuat),this.isObjectCamera||this.object.updateMatrix(),this.isFirstPerson===!1&&this.object.quaternion.multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.object.position),a=this.targetToCamera.add(o);md.lookAt(a,o,ul).setPosition(a),md.decompose(this.targetPos,this.targetQuat,Rr),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.matrixWorldNeedsUpdate=!0,this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=ze.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=ze.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.lastPosition.distanceToSquared(this.object.position)<this.threshEndTranslate&&8*(1-this.lastQuaternion.dot(this.object.quaternion))<this.threshEndRotate&&(!this.camera||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode!=="walk"||this.onObject===!0||this.collisionEnabled===!1)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t=Uu.setFromAxisAngle(ul,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?ze.clamp(this.objectRot.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.objectRot.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(t);let n;this.cameraXAxis==="Limit"?n=ze.clamp(this.objectRot.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):n=ze.clamp(this.objectRot.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Rr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(t);let s=gd.setFromAxisAngle(i,n);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(t),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}collisionAdjustment(t){let n=cl.set(0,0,0);this.object.updateMatrix();let i=md.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Rr,Uu,Jr).compose(Rr,Uu,SS);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;yi.makeEmpty();let a=f7.copy(o.matrixWorld).decompose(Rr,Uu,Jr).compose(Rr,Uu,SS),l=SD.copy(a).invert(),u=h7.copy(SD).multiply(i);cn.copy(this.collider.segment),cn.start.applyMatrix4(u),cn.end.applyMatrix4(u);let c=c7.copy(this.object.position).applyMatrix4(l);yi.expandByPoint(cn.start),yi.expandByPoint(cn.end),yi.min.addScalar(-this.collider.radius),yi.max.addScalar(this.collider.radius),o.boundsTree.shapecast({intersectsBounds:h=>h.intersectsBox(yi),intersectsTriangle:h=>{let f=Rr,d=Jr,m=h.closestPointToSegment(cn,f,d);if(m<this.collider.radius){let p=this.collider.radius-m,g=d.sub(f).normalize(),v=$n.copy(c);v.addScaledVector(g,p);let y=v.applyMatrix4(a).sub(this.object.position);n.add(y),cn.start.addScaledVector(g,p),cn.end.addScaledVector(g,p)}}})}),yi.makeEmpty(),cn.copy(this.collider.segment),cn.start.applyMatrix4(i),cn.end.applyMatrix4(i),yi.expandByPoint(cn.start),yi.expandByPoint(cn.end),yi.min.addScalar(-this.collider.radius),yi.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({intersectsBounds:o=>o.intersectsBox(yi),intersectsTriangle:o=>{let a=Rr,l=Jr,u=o.closestPointToSegment(cn,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,h=l.sub(a).normalize();n.addScaledVector(h,c),cn.start.addScaledVector(h,c),cn.end.addScaledVector(h,c)}}}),this.onObject=n.y>Math.abs(t*this.velocity.y*.25),this.onObject&&(this.sceneGraph.traverseFrom(this.object.uuid,this.resetChildrenToBaseState),this.dispatchStopEvent("jump"));let s=Math.max(0,n.length()-1e-5);n.normalize().multiplyScalar(s),this.object.position.add(n)}},pd=hv;pd.isLocked=!1;var wS={type:"change"},wD={type:"changeZoom"},x7={type:"changePan"},Gu={type:"start"},vd={type:"end"},AS=new ut,b7=new k,S7=2*Math.PI,w7=1e-8,A7=.01,AD=2,TS=.125,TD=2,_S=1,MS=1,ES=.1;var ku=class extends kt{constructor(t,n,i=!1){super();this.object=t;this.domElement=n;this.isExport=i;this.enabled=!0;this.useKeyEvents=!0;this.enableDamping=!1;this.enableZoom=!0;this.enableRotate=!0;this.enablePan=!0;this.autoRotate=!1;this.rotationLimitsMode=0;this.panLimitsMode=0;this.rotationSoftLimit=2;this.panSoftLimit=2;this.hoverRotatePanMode=0;this.zoomLimitsEnabled=!1;this.mouseButtons=[0,5];this.mouseButtonsPlay=[3,4,5];this.touches=[null,Vn.DOLLY_ROTATE,Vn.PAN];this.offset=new T;this.eye=new T;this.lastPosition=new T;this.lastQuaternion=new ut;this.current=new k;this.overShoot=new k;this.overRatio=new k;this.spherical=new _h;this.sphericalDelta=new _h;this.panOffset=new T;this.panLeftV=new T;this.panUpV=new T;this.panV=new T;this.rotateStart=new k;this.rotateEnd=new k;this.rotateDelta=new k;this.panStart=new k;this.panEnd=new k;this.panDelta=new k;this.dollyStart=new k;this.dollyEnd=new k;this.dollyDelta=new k;this.rotationRangeFactor=new k;this.panRangeFactor=new k;this.state=-1;this.zoomChanged=!1;this.isPointerDown=!1;this.isFirstHover=!0;this.isThetaFlipped=!1;this.prevScale=0;this.scale=1;this.gesture=!1;this.timer=-1;this.timerHover=-1;this.minDistance=0;this.maxDistance=1/0;this.minZoom=0;this.maxZoom=1/0;this.minPhi=0;this.maxPhi=Math.PI;this.minTheta=-1/0;this.maxTheta=1/0;this.minH=0;this.maxH=Math.PI;this.minV=-1/0;this.maxV=1/0;this.autoRotateClockwise=!0;this.isPanOverShoot=!1;this.isRotateOverShoot=!1;this.update=()=>{let t=this.object.position;this.offset.copy(t).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(AS.copy(this.object.quaternion).invert()),this.panOffset.applyQuaternion(AS),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(this.object.quaternion),this.panOffset.applyQuaternion(this.object.quaternion)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-TS),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),t.copy(this.target).add(this.offset);let n=this.spherical.phi%S7;return this.eye.copy(this.offset).normalize(),this.object.up.copy(yt.DefaultUp).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),n>0&&n>Math.PI||n<0&&n>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0?(this.sphericalDelta.theta*=1-TS,this.sphericalDelta.phi*=1-TS):this.sphericalDelta.set(0,0,0),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>A7||8*(1-this.lastQuaternion.dot(this.object.quaternion))>w7?(this.dispatchEvent(wS),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0):(this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),!1)};this.onPointerDown=t=>{this.enabled!==!1&&(this.isPointerDown=!0,st.length===1&&(this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)),t.pointerType==="touch"||t.pointerType==="pen"&&Er?this.onPointerDownTouch(t):this.onPointerDownMouse(t))};this.onPointerMove=t=>{this.enabled!==!1&&(t.pointerType==="touch"||t.pointerType==="pen"&&Er?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t))};this.onPointerUp=t=>{this.isPointerDown=!1,st.length===0&&(this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)),this.dispatchEvent(vd),this.state=-1};this.onPointerDownMouse=t=>{let n;switch(this.useKeyEvents?n=this.mouseButtons[t.button]:n=this.mouseButtonsPlay[t.button],n){case 0:if(t.altKey===!0&&!t.shiftKey&&!Kh(t)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(Kh(t)||t.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(Kh(t)||t.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Gu)};this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(t);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(t);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(t);break}};this.onPointerDownTouch=t=>{switch(this.touches[st.length-1]){case Vn.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case Vn.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case Vn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case Vn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Gu)};this.onPointerMoveTouch=t=>{switch(this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(t),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}};this.dispatchEndDebounced=Nh(()=>this.dispatchEvent(vd),33);this.onMouseWheel=t=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||(this.isExport===!1&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&t.preventDefault(),this.dispatchEvent(Gu),this.handleMouseWheel(t),this.dispatchEndDebounced())};this.onGesture=t=>{if(this.enabled!==!1)if(t.preventDefault(),t.type==="gesturechange"){if(this.enableZoom===!1)return;this.dispatchEvent(Gu),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update()}else this.dispatchEvent(vd)};this.onContextMenu=t=>{this.enabled!==!1&&t.preventDefault()};this.onTouchEnd=t=>{t.preventDefault()};this.onKeyDown=t=>{this.enabled!==!1&&(this.key=t.key)};this.onKeyUp=()=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&this.onPointerUp(st[0]))};this.onPointerHover=t=>{if(!(t.pointerType!=="mouse"||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot)){if(window.clearTimeout(this.timerHover),this.isPointerDown=!0,this.isFirstHover){let n={clientX:window.innerWidth/2,clientY:window.innerHeight/2};this.hoverRotatePanMode===2?this.handleMouseDownPan(n):this.hoverRotatePanMode===1&&this.handleMouseDownRotate(n),this.isFirstHover=!1}this.hoverRotatePanMode===2?this.handleMouseMovePan(t,ES):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(t,ES),this.timerHover=window.setTimeout(()=>{this.isPointerDown=!1},30)}};this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.connect(),this.update()}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.isUpVectorFlipped=this.isUpVectorFlipped0,this.object.updateProjectionMatrix(),this.dispatchEvent(wS),this.isFirstHover=!0,this.update(),this.state=-1}resetTo(t,n,i,s=!1){this.target.copy(t),this.object.position.copy(n),this.object.zoom=i,this.object.isUpVectorFlipped=s,this.object.updateProjectionMatrix(),this.dispatchEvent(wS),this.update(),this.state=-1}fromJSON(t){this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.isFirstHover=!0,this.hoverRotatePanMode!==0&&this.domElement.addEventListener("pointermove",this.onPointerHover),ES=(t.hoverRotatePanStrength/100)**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/t.zoomLimits.max,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,AD=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let i=this.object.getTarget().applyQuaternion(AS.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+i.y,this.maxV=t.panVerticalOffset.max+i.y,this.minH=-t.panHorizontalOffset.min+i.x,this.maxH=t.panHorizontalOffset.max+i.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=aa(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=aa(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=aa(this.spherical.theta-t.rotationHorizontalOffset.min),this.maxTheta=aa(this.spherical.theta+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,t.orbitTouches===1&&(this.touches[0]=Vn.ROTATE),t.panTouches===1&&(this.touches[0]=Vn.PAN),t.orbitTouches===2&&(this.touches[1]=Vn.DOLLY_ROTATE),t.panTouches===2&&(this.touches[1]=Vn.DOLLY_PAN),t.orbitTouches===3&&(this.touches[2]=Vn.ROTATE),t.panTouches===3&&(this.touches[2]=Vn.PAN)}connect(){this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),Zh||(this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture)),this.domElement.addEventListener("touchend",this.onTouchEnd)}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),Zh||(this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture)),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,n,i,s,o,a,l,u){this.overShoot.set(0,0);let c,h,f;t instanceof T?(c=t.x,h=t.y,this.current.set(this.target.x,this.target.y),f=!0):(c=t.theta,h=t.phi,this.current.set(aa(this.spherical.theta),aa(this.spherical.phi)),f=!1),i===0&&(this.current.x+=c,this.current.y+=h),(n===3||n===2)&&(!f&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x),s===o&&(c=0)),(n===3||n===1)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<l&&(this.overShoot.y=l-this.current.y),a===l&&(h=0)),f||(this.overShoot.x=aa(this.overShoot.x),this.overShoot.y=aa(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(u),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=_D(Math.abs(this.overRatio.x)),this.overRatio.y=_D(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9||this.overRatio.y>.9)?this.isPointerDown=!1:(c*this.overShoot.x<0&&(c*=1-this.overRatio.x),h*this.overShoot.y<0&&(h*=1-this.overRatio.y)):i===2&&(!f&&(this.overRatio.x>.002||this.overRatio.y>.002)||f&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(c=this.overShoot.x*.05,h=this.overShoot.y*.05,f?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):f?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(c+=this.overShoot.x,h+=this.overShoot.y),t instanceof T?(t.x=c,t.y=h):(t.theta=c,t.phi=h)}setEnableDampingSpeed(t){this.enableDamping=t,_S=t===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*AD}getZoomScale(){return Math.pow(.95,TD)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,n){this.panLeftV.setFromMatrixColumn(n,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,n){this.panUpV.setFromMatrixColumn(n,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,n){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrix),this.panUp(2*n*o/i.clientHeight,this.object.matrix)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this.panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix));this.dispatchEvent(x7)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(wD)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(wD)}zoomOut(t=this.getZoomScale()){this.dispatchEvent(Gu),this.dollyOut(t),this.dispatchEvent(vd)}zoomIn(t=this.getZoomScale()){this.dispatchEvent(Gu),this.dollyIn(t),this.dispatchEvent(vd)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,n=1){Nc&&Fc<15.5&&!Er?(this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)):this.rotateDelta.set(t.movementX,t.movementY),this.rotateDelta.multiplyScalar(_S*n).rotateAround(b7,-this.object.angleOffsetFromUp);let i=this.domElement;this.rotateLeft(2*Math.PI*this.rotateDelta.x/i.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/i.clientHeight),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,n=1){Nc&&Fc<15.5&&!Er?(this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)):this.panDelta.set(t.movementX,t.movementY),this.panDelta.multiplyScalar(MS*n),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(t){if(q_===!1&&Kh(t)===!1&&T7(t)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(MS),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1)return;t.deltaY===0?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if(st.length===2){let t=.5*(st[0].pageX+st[1].pageX),n=.5*(st[0].pageY+st[1].pageY);this.rotateStart.set(t,n)}else this.rotateStart.set(st[0].pageX,st[0].pageY)}handleTouchStartPan(){if(st.length===2){let t=.5*(st[0].pageX+st[1].pageX),n=.5*(st[0].pageY+st[1].pageY);this.panStart.set(t,n)}else this.panStart.set(st[0].pageX,st[0].pageY)}handleTouchStartDolly(){let t=st[0].pageX-st[1].pageX,n=st[0].pageY-st[1].pageY,i=Math.sqrt(t*t+n*n);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(st.length===2){let i=Dm(t),s=.5*(t.pageX+i.x),o=.5*(t.pageY+i.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==st[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(_S);let n=this.domElement;n&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/n.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/n.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(st.length===2){let n=Dm(t),i=.5*(t.pageX+n.x),s=.5*(t.pageY+n.y);this.panEnd.set(i,s)}else{if(t.pointerId!==st[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(MS),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let n=Dm(t),i=t.pageX-n.x,s=t.pageY-n.y,o=Math.sqrt(i*i+s*s);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,TD)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}};function aa(r){let e=Math.PI*2;for(;r<=-Math.PI;)r+=e;for(;r>Math.PI;)r-=e;return r}function _D(r){return 1-Math.pow(1-r,4)}function T7(r){return r.wheelDeltaY===0||r.deltaY===0?qa&&r.shiftKey&&Math.abs(r.wheelDeltaX)>=120?!1:r.wheelDeltaX?r.wheelDeltaX===-3*r.deltaX:r.deltaMode===0:r.wheelDeltaY?r.wheelDeltaY===-3*r.deltaY:r.deltaMode===0}var CS=new WeakMap,fv=class extends Yl{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){let s=new Ql(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{let a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,a).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){let s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(let l in t.attributeTypes){let u=t.attributeTypes[l];u.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=u.name)}let n=JSON.stringify(t);if(CS.has(e)){let l=CS.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((u,c)=>{i._callbacks[s]={resolve:u,reject:c},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),CS.set(e,{key:n,promise:a}),a}_createGeometry(e){let t=new Le;e.index&&t.setIndex(new We(e.index.array,1));for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n],s=i.name,o=i.array,a=i.itemSize;t.setAttribute(s,new We(o,a))}return t}_loadLibrary(e,t){let n=new Ql(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{let i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);let s=_7.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
4916
|
+
`,D.addEventListener("pointerdown",()=>{y.forEach(N=>{N[0].movementState.jump=1}),i()}),D.addEventListener("touchend",N=>N.preventDefault()),this.joysticks[b]=[void 0,S];return}let P={zone:S,mode:"static",position:M,size:w};_==="hide"&&(P.restOpacity=0);let L=dP.create(P);L.on("move",(D,R)=>{y.forEach(N=>{let U=N[0];N[1]==="pos"?R.force<.2?U.moveForce=0:(U.movementState.movePosZ=Math.sin(-R.angle.radian),U.movementState.movePosX=Math.cos(-R.angle.radian),R.force<.3?U.moveForce=(R.force-.2)/.1:U.moveForce=1):R.force<.2?U.rotForce=0:(U.movementState.rotPosX=R.vector.y,U.movementState.rotPosY=-R.vector.x,R.force<.3?U.rotForce=(R.force-.2)/.1:U.rotForce=1)}),i()}),L.on("end",(D,R)=>{y.forEach(N=>{let U=N[0];N[1]==="pos"?(U.movementState.movePosZ=0,U.movementState.movePosX=0,U.moveForce=1):(U.movementState.rotPosX=0,U.movementState.rotPosY=0,U.rotForce=1)})}),this.joysticks[b]=[L,S]}),this.usePhysics===!1&&this.needsCollisionDetection&&this.initBVH(),this.initializationCounter++}initBVH(){let e=[];this.scene.updateMatrixWorld(!0);let t=new Set;if(this.scene.traverse(n=>{if(!!di(n))if(!n.visible||t.has(n))n.children.forEach(i=>di(i)&&t.add(i));else if(Object.keys(n.states).length||n.data?.events.some(i=>i.data.type==="GameControl")){let i=[];n.matrixWorld.decompose(ln,vi,ji);let s=new we().compose(ln,vi,o7);Gt(n)&&i.push(ia(n.geometry,dd.makeScale(ji.x,ji.y,ji.z))),n.updateMatrixWorld();let o=s.clone().invert();if(n.traverse(a=>{!Gt(a)||(a.updateMatrixWorld(),dd.multiplyMatrices(o,a.matrixWorld),i.push(ia(a.geometry,dd)))}),i.length>0){let a=Zs(i,!1);n.boundsTree=new sr(a),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(n)}}else Gt(n)&&!this.sharedGameControlGlobals.entitiesWithTransformAnim.some(i=>n.isDescendantOf(i))&&e.push(ia(n.geometry,n.matrixWorld))}),e.length>0){let n=Zs(e,!1);this.sharedGameControlGlobals.staticMeshBVH=new sr(n)}}addCollider(e,t,n,i,s=!0){let o=e.rigidBody,a;i!==void 0?i.collider.type==="sphere"?a=cr.ColliderDesc.ball(i.collider.radius/this.pixelsPerMeter):i.collider.type==="capsule"?a=cr.ColliderDesc.capsule((i.collider.height/2-i.collider.radius)/this.pixelsPerMeter,i.collider.radius/this.pixelsPerMeter):a=cr.ColliderDesc.cuboid(i.collider.width/this.pixelsPerMeter/2,i.collider.height/this.pixelsPerMeter/2,i.collider.depth/this.pixelsPerMeter/2):n.colliderType==="trimesh"?a=cr.ColliderDesc.trimesh(t.getAttribute("position").array,t.getIndex().array):a=cr.ColliderDesc.convexMesh(t.getAttribute("position").array,s?t.getIndex().array:void 0),a.setFrictionCombineRule(cr.CoefficientCombineRule.Average).setRestitutionCombineRule(cr.CoefficientCombineRule.Average).setDensity(n.density).setFriction(n.friction).setRestitution(n.restitution);let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,o);if(this.sharedGameControlGlobals.colliderToEntity[l.handle]=e,i!==void 0){ln.fromArray(i.collider.position).multiply(ji.setFromMatrixScale(e.matrixWorld)).divideScalar(this.pixelsPerMeter),l.setTranslationWrtParent(ln);let u=new ut().setFromEuler(new tr().setFromVector3(new T().fromArray(i.collider.rotation)));l.setRotationWrtParent(u),l.setActiveEvents(cr.ActiveEvents.COLLISION_EVENTS)}else n.rigidBody==="dynamic"&&this.sharedGameControlGlobals.eventsPerObjects[e.uuid]?.some(u=>u.target==="scene")&&l.setActiveEvents(cr.ActiveEvents.COLLISION_EVENTS)}initPhysics(e){this.sharedGameControlGlobals.rapierWorld=new cr.World(new cr.Vector3(0,e??-10,0)),this.events=new cr.EventQueue(!0);let t=[],n=[],i=[];if(this.sceneGraph.traverse((u,c)=>{let h=this.scene.find(u);if(h&&di(h)&&h.visible){let f,d=c.states.some(p=>p.data.position!==void 0||p.data.rotation!==void 0||p.data.hiddenMatrix!==void 0),m=!1;for(let p of c.events)if(p.data.type==="GameControl")f=p.data;else if(p.data.type==="Collision"){m=!0;let g=new cv(p.data,h,this.scene,this.sharedAssets);this.sharedGameControlGlobals.eventsPerObjects[h.uuid]?this.sharedGameControlGlobals.eventsPerObjects[h.uuid].push(g):this.sharedGameControlGlobals.eventsPerObjects[h.uuid]=[g]}if(n.some(p=>this.sceneGraph.isDescendantOf(u,p)))return;if(!c.physics){n.push(u);return}if(i.some(p=>this.sceneGraph.isDescendantOf(u,p)))return;if(c.physics.fusedBody===!0&&i.push(u),h.matrixWorld0=void 0,c.physics.rigidBody==="dynamic"&&c.physics.fusedBody===!1&&(h.matrixWorld0=h.matrixWorld.clone()),c.physics.rigidBody==="dynamic"||d||m||f!==void 0){let p=[];Gt(h)&&p.push(ia(h.geometry));let g=h.matrixWorld.clone().invert();if(c.physics.fusedBody&&h.traverse(v=>{!Gt(v)||v===h||(dd.multiplyMatrices(g,v.matrixWorld),p.push(ia(v.geometry,dd)))}),p.length>0){let v=Zs(p);v.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter),h.matrixWorld.decompose(ln,vi,ji),v.scale(ji.x,ji.y,ji.z),ln.divideScalar(this.pixelsPerMeter);let y;f!==void 0?y=cr.RigidBodyDesc.kinematicPositionBased():c.physics.rigidBody==="dynamic"?(y=cr.RigidBodyDesc.dynamic(),y.setLinearDamping(c.physics.damping).setAdditionalMass(0).setGravityScale(c.physics.gravityScale).enabledRotations(...c.physics.enabledRotation).enabledTranslations(...c.physics.enabledTranslation)):d?(y=cr.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(h)):y=cr.RigidBodyDesc.fixed(),y.setTranslation(ln.x,ln.y,ln.z).setRotation({w:vi.w,x:vi.x,y:vi.y,z:vi.z});let b=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);f===void 0&&c.physics.rigidBody==="dynamic"&&this.rigidBodyToMesh.set(b.handle,[h,ji.clone(),c.physics.fusedBody]),h.rigidBody=b;let S=!(c.geometry===void 0||c.geometry.type==="SubdivGeometry"||c.geometry.type==="NonParametricGeometry"||c.geometry.type==="BooleanGeometry"||c.geometry.type==="VectorGeometry"||c.geometry.type==="StarGeometry"||c.geometry.type==="TorusGeometry"||c.geometry.type==="HelixGeometry");this.addCollider(h,v,c.physics,f,S)}}else this.gameControlStates.some(([p])=>h.isDescendantOf(p))||(Gt(h)&&t.push(ia(h.geometry,h.matrixWorld)),c.physics.fusedBody&&h.traverse(p=>{!Gt(p)||p===h||t.push(ia(p.geometry,p.matrixWorld))}))}}),t.length===0)return;let s=Zs(t);s.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let o=cr.RigidBodyDesc.fixed(),a=this.sharedGameControlGlobals.rapierWorld.createRigidBody(o),l=cr.ColliderDesc.trimesh(s.getAttribute("position").array,s.getIndex().array).setFrictionCombineRule(cr.CoefficientCombineRule.Multiply).setRestitutionCombineRule(cr.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(l,a)}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}dispose(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.staticMeshBVH=void 0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.gameControls.forEach(e=>{e.reset(),e.dispose()}),this.gameControls=[],this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls?.dispose(),this.orbitControls=void 0;for(let e of Object.values(this.sharedGameControlGlobals.eventsPerObjects))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.eventsPerObjects={},this.scene.updateMatrixWorld(!0)}update(e){let t=!0;if(this.orbitControls!==void 0&&(t=!this.orbitControls.update(e)),this.initializationCounter>=0&&this.initializationCounter<2)this.initializationCounter++,t=!1;else if(this.initializationCounter===2)for(let n of this.gameControls)t=!n.update(e)&&t;if(this.usePhysics&&(this.gameControls.length===0||this.needsCollisionDetection)){for(let n of this.sharedGameControlGlobals.entitiesWithTransformAnim){n.matrixWorld.decompose(ln,vi,ji),yS.setFromQuaternion(vi);let i=n;i.prevR===void 0?(i.prevR=yS.clone(),i.prevT=ln.clone()):(i.prevR.copy(yS),i.prevT.copy(ln)),n.rigidBody.setNextKinematicTranslation(ln.divideScalar(this.pixelsPerMeter)),n.rigidBody.setNextKinematicRotation(vi)}this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),t=!this.updatePositions()&&t}return t}dispatchCollisionEvent(e,t){t.dispatchEvent(xS),e.dispatch()}};var bS={type:"change"},a7={type:"lock"},l7={type:"unlock"},c7=new T,cl=new T,u7=new T,Rr=new T,Jr=new T,$n=new T,md=new we,SD=new we,h7=new we,f7=new we,Uu=new ut,gd=new ut,d7=new tr(0,0,0,"YXZ"),ul=new T(0,1,0),SS=new T(1,1,1),p7=1,m7=.025,g7=16e-6,v7=12,y7=20,cn=new _r,yi=new Lt,hv=class extends kt{constructor(t,n,i,s,o,a,l,u,c,h){super();this.object=t;this.sceneGraph=n;this.domElement=i;this.sharedGameControlGlobals=a;this.cameraFollow=l;this.camera=u;this.scene=c;this.sharedAssets=h;this.enableDamping=!0;this.position0=new T;this.rotation0=new tr(0,0,0,"XYZ");this.scale0=new T;this.hiddenMatrix0=new we;this.target0=new T;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.euler0=new tr(0,0,0,"YXZ");this.position0Cam=new T;this.quat0Cam=new ut;this.scale0Cam=new T;this.hiddenMatrix0Cam=new we;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.collider={radius:40,segment:new _r(new T(0,-40,0),new T(0,40,0)),matrix:new we,position:new T,rotation:new ut};this.euler=new tr(0,0,0,"YXZ");this.eulerDelta=new T;this.lastQuaternion=new ut;this.lastPosition=new T;this.lastCameraQuaternion=new ut;this.lastCameraPosition=new T;this.PI_2=Math.PI/2;this.prevMouse=new k;this.velocityTarget=new T;this.velocity=new T;this.directionXZ=new T;this.rotVelocityStick=new T;this.rotVelocityTarget=new T;this.rotVelocity=new T;this.rotDirection=new T;this.objectRot={x:0,y:0};this.firstPointerId=-1;this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0};this.onObject=!1;this.actionState={};this.slopeAdjust=!1;this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]];this.collisionEnabled=!0;this.offsetMatrix=new we;this.objectToTarget=new T;this.objectToTarget0=new T;this.objectToCamXZ=new T;this.objectToCamXZ0=new T;this.targetToCamera=new T;this.targetToCamera0=new T;this.cameraPolarAxis0=new T;this.targetPos=new T;this.targetQuat=new ut;this.lerpFactorPos=new T().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new ut;this.objXZQuatInv=new ut;this.objXZRotMat=new we;this.isFirstPerson=!1;this.actions={};this.lastDummyPos=new T;this.lastDummyPosDelta=new T;this.hit=null;this.groundVelocity=new T;this.pushedVelocity=new T;this.groundYRotation=0;this.objectRealQuat=new ut;this.colliderWorldQuat=new ut;this.groundNormal=new T;this.lastHitObj=null;this.isFirstFrame=!0;this.onPointerDown=t=>{t.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=t.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Er&&(!Nc||Fc>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(t.clientX,t.clientY))};this.onPointerUp=t=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),t.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=t=>{if(t.pointerId!==this.firstPointerId)return;let n=t.clientX-this.prevMouse.x,i=t.clientY-this.prevMouse.y;this.prevMouse.set(t.clientX,t.clientY),t.pointerType==="mouse"&&this.rotBy!=="keys"&&(Nc&&Fc<15.5&&!Er?(this.eulerDelta.y=-n*this.mouseOrbitSensitivity,this.eulerDelta.x=-i*this.mouseOrbitSensitivity):(this.eulerDelta.y=-t.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-t.movementY*this.mouseOrbitSensitivity)),t.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-n*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-i*this.mouseOrbitSensitivity*5),this.dispatchEvent(bS)};this.onPointerlockChange=t=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(a7),hv.isLocked=!0):(this.dispatchEvent(l7),hv.isLocked=!1)};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.onKeyDown=t=>{t.preventDefault();for(let n of this.keyAssignments)if(t.key.toUpperCase()===n[1]||t.key===n[1]){this.movementState[n[0]]=1;break}this.dispatchEvent(bS)};this.onKeyUp=t=>{for(let n of this.keyAssignments)if(t.key.toUpperCase()===n[1]||t.key===n[1]||t.code.slice(3,t.code.length).toUpperCase()===n[1]){this.movementState[n[0]]=0;break}};this.resetChildrenToBaseState=(t,n)=>{if(t===this.object.uuid)return;let i=this.scene.find(t);i.currentState!==null&&iS(i,n,null,this.sharedAssets)};if(t.objectType==="CombinedCamera"&&(this.isFirstPerson=!0),this.position0.copy(this.object.position),this.rotation0.copy(this.object.rotation),this.scale0.copy(this.object.scale),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale),this.object.rotation.reorder("YXZ"),this.euler0.copy(this.object.rotation),this.isFirstPerson===!1){let m=this.object.rotation.y;this.objectRealQuat.copy(this.object.quaternion),this.object.rotation.y=0,this.objXZQuat.copy(this.object.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),this.object.rotation.set(0,m,0)}if(this.object.matrixAutoUpdate=!1,this.isFirstPerson){let m=this.object;this.target0.copy(m.getTarget()),this.zoom0=m.zoom}else this.cameraFollow===!0&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom);if(this.cameraFollow===!0){if(this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera?.parent?.parent){let y=this.camera.matrix.clone().invert().premultiply(this.camera.matrixWorld),b=y.clone().invert();this.camera.hiddenMatrix.multiply(b),this.camera.matrix.premultiply(y),this.camera.matrixWorld.decompose(this.camera.position,this.camera.quaternion,this.camera.scale)}this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let m=new T(0,0,-1).applyQuaternion(this.camera.quaternion),p=new T().subVectors(this.object.position,this.camera.position);this.objectToCamXZ.copy(p),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g;if(Math.abs(m.y)<1e-6){p.y=0,m.y=0;let y=p.projectOnVector(m);this.targetToCamera0.copy(y).negate(),g=this.camera.position.clone().add(y)}else{let y=m.multiplyScalar(p.y/m.y);this.targetToCamera0.copy(y).negate(),g=y.clone().add(this.camera.position)}this.objectToTarget0.subVectors(g,this.object.position);let v=new tr().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-v.x,v.x=0,v.z=0,v.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(v)}if(this.isObjectCamera=this.object.objectType==="CombinedCamera",this.euler.setFromQuaternion(this.object.quaternion,"YXZ"),this.connect(),this.rotByTouch=s.rotByTouch??"joystick",this.rotBy=s.rotBy??"keys",this.rotationMode=s.rotationMode??"normal",this.moveMode=s.moveMode??"walk",this.collisionEnabled=s.collisionEnabled,this.speedTranslate=(s.speedTranslate??250)*p7,this.speedOrbit=(s.speedRotate??100)*m7,this.mouseOrbitSensitivity=(s.speedRotate??100)*g7,this.keyAssignments=s.keyAssignments.map(m=>{let p=[m[0],m[1]];return p[1]==="\u25B2"?p[1]="ArrowUp":p[1]==="\u25C0"?p[1]="ArrowLeft":p[1]==="\u25BC"?p[1]="ArrowDown":p[1]==="\u25B6"?p[1]="ArrowRight":p[1]==="\u21E7"?p[1]="Shift":p[1]==="\u21B5"?p[1]="Enter":p[1]==="Space"?p[1]=" ":p[1]==="\u2318"?p[1]="Meta":p[1]==="Ctrl"?p[1]="Control":p[1]==="Esc"&&(p[1]="Escape"),p}),s.rotBy==="mouse"){let m;m=this.keyAssignments.findIndex(p=>p[0]==="rotNegX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotPosX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotPosY"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotNegY"),m!==-1&&(this.keyAssignments[m][1]="")}this.lerpFactorPosStart=1-.02**(1/((s.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((s.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((s.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((s.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((s.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((s.delayRotCamera??.3)*60)),this.gravity=(o.gravity??li.defaultData.gravity)*v7,this.pixelsPerMeter=o.pixelsPerMeter??li.defaultData.pixelsPerMeter,this.usePhysics=o.usePhysics??li.defaultData.usePhysics,this.jumpPower=s.jumpPower*y7,this.resetYPosition=s.resetYPosition,this.orientMode=s.autoOrientMove?s.orientMode:"none",s.collider.type==="capsule"?(this.collider.radius=s.collider.radius,this.collider.segment.start.y=s.collider.height/2-s.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y):s.collider.type==="sphere"&&(this.collider.radius=s.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0);let f=new T().fromArray(s.collider.position),d=new ut().setFromEuler(new tr().fromArray([...s.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.object.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(f,d,SS),s.cameraXAxis!==void 0&&(this.cameraXAxis=s.cameraXAxis,this.cameraYAxis=s.cameraYAxis,this.minPolarAngle=s.cameraRotXLimits[0],this.maxPolarAngle=s.cameraRotXLimits[1],this.minAzimuthAngleRel=s.cameraRotYLimits[0],this.maxAzimuthAngleRel=s.cameraRotYLimits[1]),s.gameActions!==void 0&&Object.entries(s.gameActions).forEach(([m,p],g)=>{p.forEach(({id:v,data:y})=>{try{this.actions[m]===void 0&&(this.actions[m]=[]),y.type==="Transition"?this.actions[m].push(new Ps(v,y,c,h)):y.type==="Audio"&&this.actions[m].push(new Ms(v,y,t,h))}catch{}})}),this.dispatchStopEvent("move"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle")}reset(t=!1){if(this.object.rotation.copy(this.rotation0),this.object.position.copy(this.position0),this.object.scale.copy(this.scale0),this.object.hiddenMatrix.copy(this.hiddenMatrix0),t===!0){if(this.object.rotation.reorder("YXZ"),this.isFirstPerson===!1){let n=this.object.rotation.y;this.object.rotation.y=0,this.objXZQuat.copy(this.object.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),this.object.rotation.set(0,n,0)}this.euler.setFromQuaternion(this.object.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}this.isObjectCamera?this.object.matrixAutoUpdate=!0:this.object.updateMatrix(),this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.dispatchEvent(bS)}connect(){this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError)}disconnect(){this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError)}dispose(){this.disconnect(),Object.values(this.actions).forEach(t=>{t.forEach(n=>{(n instanceof Ps||n instanceof Ms)&&n.dispose()})})}resetTo(t,n,i){}dispatchStartEvent(t){this.actions[t]!==void 0&&(this.actionState[t]||(this.actionState[t]=!0,this.actions[t].forEach(n=>{n instanceof Ps?n.play():n instanceof Ms&&n.dispatchGameControl("start")})))}dispatchStopEvent(t){this.actions[t]!==void 0&&(!this.actionState[t]||(this.actionState[t]=!1,this.actions[t].forEach(n=>{n instanceof Ps?n.stop():n instanceof Ms&&n.dispatchGameControl("stop")}),this.sceneGraph.traverseFrom(this.object.uuid,this.resetChildrenToBaseState)))}update(t){if(this.gravity<0?this.object.position.y<this.resetYPosition:this.object.position.y>this.resetYPosition)return this.reset(!0),!0;let n=(this.isFirstFrame?16.6:t)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=n*60;if(this.usePhysics){let o=Jr.set(0,-(this.jumpPower+this.gravity*i)*n*.5,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(Rr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,void 0,void 0,void 0,this.object.rigidBody);if(this.slopeAdjust=!1,a){this.slopeAdjust=!1,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),Math.acos(this.groundNormal.y)*180/Math.PI>45?this.onObject=!0:(this.slopeAdjust=!0,this.onObject=!0);let l=a.collider._parent;this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(u.rigidBody===l){u.matrixWorld.decompose(Rr,gd,Jr),this.groundVelocity.subVectors(Rr,u.prevT),this.object.getWorldPosition(Jr).add(this.collider.position).sub(u.position),this.groundYRotation=d7.setFromQuaternion(gd).y-u.prevR.y,$n.copy(Jr).applyAxisAngle(ul,this.groundYRotation),this.groundVelocity.add($n.sub(Jr)).divideScalar(n);break}}else this.onObject=!1}this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.velocityTarget.y+=this.onObject?0:this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.directionXZ.normalize(),this.movementState.moveNegZ||this.movementState.movePosZ?this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce:this.velocityTarget.z=0,this.movementState.moveNegX||this.movementState.movePosX?this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce:this.velocityTarget.x=0,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.hit===null&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("move")));let s=u7.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1&&this.cameraYAxis!=="Locked"){let o=Jr.copy(s);o.y=0,s.set(0,s.y,o.length()*-1)}if(s.applyQuaternion(this.object.quaternion),this.slopeAdjust&&(gd.setFromUnitVectors(ul,this.groundNormal),s.applyQuaternion(gd)),this.usePhysics===!0){let o=Jr;this.pushedVelocity.set(0,0,0);for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){a.parent?.matrixWorld0?(md.multiplyMatrices(a.parent?.matrixWorld0,a.matrix),$n.setFromMatrixPosition(md)):$n.copy(a.position);let l=$n.sub(a.prevT).divideScalar(n);l.divideScalar(this.pixelsPerMeter);let u=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),Rr.copy(s).divideScalar(this.pixelsPerMeter),n);if(l.multiplyScalar(this.pixelsPerMeter),u!==null){this.pushedVelocity.copy(l),o.copy(u.normal1).applyQuaternion(a.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let a=o.dot(s);a<0&&s.addScaledVector(o,-a),s.add(this.pushedVelocity)}else s.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(n),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*n,this.euler.y+=this.rotVelocity.y*n+this.groundYRotation,this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){let o=Rr,a=Jr.copy(this.directionXZ);a.x*=-1,this.camera.getWorldDirection(o);let l=$n.copy(ul).multiplyScalar(o.dot(ul));if(o.sub(l),$n.copy(this.collider.position).applyQuaternion(this.object.quaternion),this.object.rotation.y=o.angleTo(a)*(o.cross(a).y>0?-1:1),cl.copy(this.collider.position).applyQuaternion(this.object.quaternion),cl.sub($n),this.object.position.sub(cl),this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(ul,this.euler.y-this.euler0.y);let u=Jr.copy(this.objectToCamXZ).normalize(),c=$n.copy(s).multiplyScalar(n);c.y=0;let h=c.sub(Rr.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}if(this.cameraFollow===!0&&this.moveMode==="walk"&&this.isFirstPerson===!1?this.cameraXAxis==="Limit"?this.euler.x=ze.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=ze.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):(this.cameraXAxis==="Limit"||this.isFirstPerson||this.cameraFollow===!0)&&(this.euler.x=ze.clamp(this.euler.x,-this.PI_2,this.PI_2)),(this.isFirstPerson||this.moveMode!=="walk")&&(this.object.rotation.x=this.euler.x),(this.isFirstPerson||this.orientMode==="none"||this.cameraYAxis==="Locked")&&($n.copy(this.collider.position).applyQuaternion(this.object.quaternion),this.object.rotation.y=this.euler.y,cl.copy(this.collider.position).applyQuaternion(this.object.quaternion),cl.sub($n),this.object.position.sub(cl)),this.object.rotation.x=ze.clamp(this.object.rotation.x,-this.PI_2,this.PI_2),this.objectRot.x=this.euler.x,this.objectRot.y=this.euler.y,this.objectRealQuat.multiplyQuaternions(this.object.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){if(this.hit=this.sharedGameControlGlobals.rapierWorld.castShape(Rr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,Jr.copy(s).divideScalar(this.pixelsPerMeter),this.object.rigidBody?.collider(0).shape,n,8,void 0,void 0,this.object.rigidBody),this.hit!==null){let o=this.sharedGameControlGlobals.colliderToEntity[this.hit.collider.handle];if(o!==this.lastHitObj){this.lastHitObj=o;let l=this.sharedGameControlGlobals.eventsPerObjects[o?.uuid];if(l)for(let u of l)u.data.target==="character"&&(o.dispatchEvent(xS),u.dispatch())}let a=Rr.set(this.hit.normal2.x,this.hit.normal2.y,this.hit.normal2.z).applyQuaternion(this.colliderWorldQuat);if(this.hit.toi>0){let l=Jr.copy(s).multiplyScalar(this.hit?.toi).dot(a),u=this.hit.toi;l>2&&(u=this.hit.toi*(l-2)/l,this.object.position.addScaledVector(s,u));let c=Jr.copy(s).multiplyScalar(n-u);a.multiplyScalar(c.dot(a));let h=c.sub(a),f=this.sharedGameControlGlobals.rapierWorld.castShape(Rr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,$n.copy(h).divideScalar(this.pixelsPerMeter),this.object.rigidBody?.collider(0).shape,20,8,void 0,void 0,this.object.rigidBody);if(f===null)this.object.position.add(h);else if(f.toi>1){let d=Rr.set(f.normal2.x,f.normal2.y,f.normal2.z).applyQuaternion(this.colliderWorldQuat);Jr.copy(h).dot(d)>2&&this.object.position.add(h)}this.lastDummyPosDelta.subVectors(this.object.position,this.lastDummyPos),this.lastDummyPos.copy(this.object.position)}}else this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),this.object.position.addScaledVector(s,n);this.object.rigidBody?.setTranslation(Rr.copy(this.object.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Uu.copy(this.object.quaternion).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,a=s.multiplyScalar(n/o);for(let l=0;l<o;l++)this.object.position.add(a),this.collisionAdjustment(n/o)}else this.object.position.addScaledVector(s,n);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.isFirstPerson===!1&&this.object.quaternion.multiply(this.objXZQuat),this.isObjectCamera||this.object.updateMatrix(),this.isFirstPerson===!1&&this.object.quaternion.multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.object.position),a=this.targetToCamera.add(o);md.lookAt(a,o,ul).setPosition(a),md.decompose(this.targetPos,this.targetQuat,Rr),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.matrixWorldNeedsUpdate=!0,this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=ze.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=ze.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.lastPosition.distanceToSquared(this.object.position)<this.threshEndTranslate&&8*(1-this.lastQuaternion.dot(this.object.quaternion))<this.threshEndRotate&&(!this.camera||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode!=="walk"||this.onObject===!0||this.collisionEnabled===!1)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t=Uu.setFromAxisAngle(ul,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?ze.clamp(this.objectRot.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.objectRot.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(t);let n;this.cameraXAxis==="Limit"?n=ze.clamp(this.objectRot.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):n=ze.clamp(this.objectRot.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Rr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(t);let s=gd.setFromAxisAngle(i,n);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(t),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}collisionAdjustment(t){let n=cl.set(0,0,0);this.object.updateMatrix();let i=md.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Rr,Uu,Jr).compose(Rr,Uu,SS);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;yi.makeEmpty();let a=f7.copy(o.matrixWorld).decompose(Rr,Uu,Jr).compose(Rr,Uu,SS),l=SD.copy(a).invert(),u=h7.copy(SD).multiply(i);cn.copy(this.collider.segment),cn.start.applyMatrix4(u),cn.end.applyMatrix4(u);let c=c7.copy(this.object.position).applyMatrix4(l);yi.expandByPoint(cn.start),yi.expandByPoint(cn.end),yi.min.addScalar(-this.collider.radius),yi.max.addScalar(this.collider.radius),o.boundsTree.shapecast({intersectsBounds:h=>h.intersectsBox(yi),intersectsTriangle:h=>{let f=Rr,d=Jr,m=h.closestPointToSegment(cn,f,d);if(m<this.collider.radius){let p=this.collider.radius-m,g=d.sub(f).normalize(),v=$n.copy(c);v.addScaledVector(g,p);let y=v.applyMatrix4(a).sub(this.object.position);n.add(y),cn.start.addScaledVector(g,p),cn.end.addScaledVector(g,p)}}})}),yi.makeEmpty(),cn.copy(this.collider.segment),cn.start.applyMatrix4(i),cn.end.applyMatrix4(i),yi.expandByPoint(cn.start),yi.expandByPoint(cn.end),yi.min.addScalar(-this.collider.radius),yi.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({intersectsBounds:o=>o.intersectsBox(yi),intersectsTriangle:o=>{let a=Rr,l=Jr,u=o.closestPointToSegment(cn,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,h=l.sub(a).normalize();n.addScaledVector(h,c),cn.start.addScaledVector(h,c),cn.end.addScaledVector(h,c)}}}),this.onObject=n.y>Math.abs(t*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,n.length()-1e-5);n.normalize().multiplyScalar(s),this.object.position.add(n)}},pd=hv;pd.isLocked=!1;var wS={type:"change"},wD={type:"changeZoom"},x7={type:"changePan"},Gu={type:"start"},vd={type:"end"},AS=new ut,b7=new k,S7=2*Math.PI,w7=1e-8,A7=.01,AD=2,TS=.125,TD=2,_S=1,MS=1,ES=.1;var ku=class extends kt{constructor(t,n,i=!1){super();this.object=t;this.domElement=n;this.isExport=i;this.enabled=!0;this.useKeyEvents=!0;this.enableDamping=!1;this.enableZoom=!0;this.enableRotate=!0;this.enablePan=!0;this.autoRotate=!1;this.rotationLimitsMode=0;this.panLimitsMode=0;this.rotationSoftLimit=2;this.panSoftLimit=2;this.hoverRotatePanMode=0;this.zoomLimitsEnabled=!1;this.mouseButtons=[0,5];this.mouseButtonsPlay=[3,4,5];this.touches=[null,Vn.DOLLY_ROTATE,Vn.PAN];this.offset=new T;this.eye=new T;this.lastPosition=new T;this.lastQuaternion=new ut;this.current=new k;this.overShoot=new k;this.overRatio=new k;this.spherical=new _h;this.sphericalDelta=new _h;this.panOffset=new T;this.panLeftV=new T;this.panUpV=new T;this.panV=new T;this.rotateStart=new k;this.rotateEnd=new k;this.rotateDelta=new k;this.panStart=new k;this.panEnd=new k;this.panDelta=new k;this.dollyStart=new k;this.dollyEnd=new k;this.dollyDelta=new k;this.rotationRangeFactor=new k;this.panRangeFactor=new k;this.state=-1;this.zoomChanged=!1;this.isPointerDown=!1;this.isFirstHover=!0;this.isThetaFlipped=!1;this.prevScale=0;this.scale=1;this.gesture=!1;this.timer=-1;this.timerHover=-1;this.minDistance=0;this.maxDistance=1/0;this.minZoom=0;this.maxZoom=1/0;this.minPhi=0;this.maxPhi=Math.PI;this.minTheta=-1/0;this.maxTheta=1/0;this.minH=0;this.maxH=Math.PI;this.minV=-1/0;this.maxV=1/0;this.autoRotateClockwise=!0;this.isPanOverShoot=!1;this.isRotateOverShoot=!1;this.update=()=>{let t=this.object.position;this.offset.copy(t).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(AS.copy(this.object.quaternion).invert()),this.panOffset.applyQuaternion(AS),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(this.object.quaternion),this.panOffset.applyQuaternion(this.object.quaternion)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-TS),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),t.copy(this.target).add(this.offset);let n=this.spherical.phi%S7;return this.eye.copy(this.offset).normalize(),this.object.up.copy(yt.DefaultUp).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),n>0&&n>Math.PI||n<0&&n>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0?(this.sphericalDelta.theta*=1-TS,this.sphericalDelta.phi*=1-TS):this.sphericalDelta.set(0,0,0),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>A7||8*(1-this.lastQuaternion.dot(this.object.quaternion))>w7?(this.dispatchEvent(wS),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0):(this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),!1)};this.onPointerDown=t=>{this.enabled!==!1&&(this.isPointerDown=!0,st.length===1&&(this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)),t.pointerType==="touch"||t.pointerType==="pen"&&Er?this.onPointerDownTouch(t):this.onPointerDownMouse(t))};this.onPointerMove=t=>{this.enabled!==!1&&(t.pointerType==="touch"||t.pointerType==="pen"&&Er?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t))};this.onPointerUp=t=>{this.isPointerDown=!1,st.length===0&&(this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)),this.dispatchEvent(vd),this.state=-1};this.onPointerDownMouse=t=>{let n;switch(this.useKeyEvents?n=this.mouseButtons[t.button]:n=this.mouseButtonsPlay[t.button],n){case 0:if(t.altKey===!0&&!t.shiftKey&&!Kh(t)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(Kh(t)||t.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(Kh(t)||t.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Gu)};this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(t);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(t);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(t);break}};this.onPointerDownTouch=t=>{switch(this.touches[st.length-1]){case Vn.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case Vn.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case Vn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case Vn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Gu)};this.onPointerMoveTouch=t=>{switch(this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(t),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}};this.dispatchEndDebounced=Nh(()=>this.dispatchEvent(vd),33);this.onMouseWheel=t=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||(this.isExport===!1&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&t.preventDefault(),this.dispatchEvent(Gu),this.handleMouseWheel(t),this.dispatchEndDebounced())};this.onGesture=t=>{if(this.enabled!==!1)if(t.preventDefault(),t.type==="gesturechange"){if(this.enableZoom===!1)return;this.dispatchEvent(Gu),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update()}else this.dispatchEvent(vd)};this.onContextMenu=t=>{this.enabled!==!1&&t.preventDefault()};this.onTouchEnd=t=>{t.preventDefault()};this.onKeyDown=t=>{this.enabled!==!1&&(this.key=t.key)};this.onKeyUp=()=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&this.onPointerUp(st[0]))};this.onPointerHover=t=>{if(!(t.pointerType!=="mouse"||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot)){if(window.clearTimeout(this.timerHover),this.isPointerDown=!0,this.isFirstHover){let n={clientX:window.innerWidth/2,clientY:window.innerHeight/2};this.hoverRotatePanMode===2?this.handleMouseDownPan(n):this.hoverRotatePanMode===1&&this.handleMouseDownRotate(n),this.isFirstHover=!1}this.hoverRotatePanMode===2?this.handleMouseMovePan(t,ES):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(t,ES),this.timerHover=window.setTimeout(()=>{this.isPointerDown=!1},30)}};this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.connect(),this.update()}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.isUpVectorFlipped=this.isUpVectorFlipped0,this.object.updateProjectionMatrix(),this.dispatchEvent(wS),this.isFirstHover=!0,this.update(),this.state=-1}resetTo(t,n,i,s=!1){this.target.copy(t),this.object.position.copy(n),this.object.zoom=i,this.object.isUpVectorFlipped=s,this.object.updateProjectionMatrix(),this.dispatchEvent(wS),this.update(),this.state=-1}fromJSON(t){this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.isFirstHover=!0,this.hoverRotatePanMode!==0&&this.domElement.addEventListener("pointermove",this.onPointerHover),ES=(t.hoverRotatePanStrength/100)**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/t.zoomLimits.max,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,AD=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let i=this.object.getTarget().applyQuaternion(AS.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+i.y,this.maxV=t.panVerticalOffset.max+i.y,this.minH=-t.panHorizontalOffset.min+i.x,this.maxH=t.panHorizontalOffset.max+i.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=aa(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=aa(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=aa(this.spherical.theta-t.rotationHorizontalOffset.min),this.maxTheta=aa(this.spherical.theta+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,t.orbitTouches===1&&(this.touches[0]=Vn.ROTATE),t.panTouches===1&&(this.touches[0]=Vn.PAN),t.orbitTouches===2&&(this.touches[1]=Vn.DOLLY_ROTATE),t.panTouches===2&&(this.touches[1]=Vn.DOLLY_PAN),t.orbitTouches===3&&(this.touches[2]=Vn.ROTATE),t.panTouches===3&&(this.touches[2]=Vn.PAN)}connect(){this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),Zh||(this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture)),this.domElement.addEventListener("touchend",this.onTouchEnd)}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),Zh||(this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture)),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,n,i,s,o,a,l,u){this.overShoot.set(0,0);let c,h,f;t instanceof T?(c=t.x,h=t.y,this.current.set(this.target.x,this.target.y),f=!0):(c=t.theta,h=t.phi,this.current.set(aa(this.spherical.theta),aa(this.spherical.phi)),f=!1),i===0&&(this.current.x+=c,this.current.y+=h),(n===3||n===2)&&(!f&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x),s===o&&(c=0)),(n===3||n===1)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<l&&(this.overShoot.y=l-this.current.y),a===l&&(h=0)),f||(this.overShoot.x=aa(this.overShoot.x),this.overShoot.y=aa(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(u),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=_D(Math.abs(this.overRatio.x)),this.overRatio.y=_D(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9||this.overRatio.y>.9)?this.isPointerDown=!1:(c*this.overShoot.x<0&&(c*=1-this.overRatio.x),h*this.overShoot.y<0&&(h*=1-this.overRatio.y)):i===2&&(!f&&(this.overRatio.x>.002||this.overRatio.y>.002)||f&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(c=this.overShoot.x*.05,h=this.overShoot.y*.05,f?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):f?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(c+=this.overShoot.x,h+=this.overShoot.y),t instanceof T?(t.x=c,t.y=h):(t.theta=c,t.phi=h)}setEnableDampingSpeed(t){this.enableDamping=t,_S=t===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*AD}getZoomScale(){return Math.pow(.95,TD)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,n){this.panLeftV.setFromMatrixColumn(n,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,n){this.panUpV.setFromMatrixColumn(n,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,n){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrix),this.panUp(2*n*o/i.clientHeight,this.object.matrix)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this.panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix));this.dispatchEvent(x7)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(wD)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(wD)}zoomOut(t=this.getZoomScale()){this.dispatchEvent(Gu),this.dollyOut(t),this.dispatchEvent(vd)}zoomIn(t=this.getZoomScale()){this.dispatchEvent(Gu),this.dollyIn(t),this.dispatchEvent(vd)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,n=1){Nc&&Fc<15.5&&!Er?(this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)):this.rotateDelta.set(t.movementX,t.movementY),this.rotateDelta.multiplyScalar(_S*n).rotateAround(b7,-this.object.angleOffsetFromUp);let i=this.domElement;this.rotateLeft(2*Math.PI*this.rotateDelta.x/i.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/i.clientHeight),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,n=1){Nc&&Fc<15.5&&!Er?(this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)):this.panDelta.set(t.movementX,t.movementY),this.panDelta.multiplyScalar(MS*n),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(t){if(q_===!1&&Kh(t)===!1&&T7(t)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(MS),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1)return;t.deltaY===0?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if(st.length===2){let t=.5*(st[0].pageX+st[1].pageX),n=.5*(st[0].pageY+st[1].pageY);this.rotateStart.set(t,n)}else this.rotateStart.set(st[0].pageX,st[0].pageY)}handleTouchStartPan(){if(st.length===2){let t=.5*(st[0].pageX+st[1].pageX),n=.5*(st[0].pageY+st[1].pageY);this.panStart.set(t,n)}else this.panStart.set(st[0].pageX,st[0].pageY)}handleTouchStartDolly(){let t=st[0].pageX-st[1].pageX,n=st[0].pageY-st[1].pageY,i=Math.sqrt(t*t+n*n);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(st.length===2){let i=Dm(t),s=.5*(t.pageX+i.x),o=.5*(t.pageY+i.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==st[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(_S);let n=this.domElement;n&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/n.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/n.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(st.length===2){let n=Dm(t),i=.5*(t.pageX+n.x),s=.5*(t.pageY+n.y);this.panEnd.set(i,s)}else{if(t.pointerId!==st[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(MS),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let n=Dm(t),i=t.pageX-n.x,s=t.pageY-n.y,o=Math.sqrt(i*i+s*s);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,TD)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}};function aa(r){let e=Math.PI*2;for(;r<=-Math.PI;)r+=e;for(;r>Math.PI;)r-=e;return r}function _D(r){return 1-Math.pow(1-r,4)}function T7(r){return r.wheelDeltaY===0||r.deltaY===0?qa&&r.shiftKey&&Math.abs(r.wheelDeltaX)>=120?!1:r.wheelDeltaX?r.wheelDeltaX===-3*r.deltaX:r.deltaMode===0:r.wheelDeltaY?r.wheelDeltaY===-3*r.deltaY:r.deltaMode===0}var CS=new WeakMap,fv=class extends Yl{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){let s=new Ql(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{let a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,a).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){let s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(let l in t.attributeTypes){let u=t.attributeTypes[l];u.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=u.name)}let n=JSON.stringify(t);if(CS.has(e)){let l=CS.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((u,c)=>{i._callbacks[s]={resolve:u,reject:c},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),CS.set(e,{key:n,promise:a}),a}_createGeometry(e){let t=new Le;e.index&&t.setIndex(new We(e.index.array,1));for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n],s=i.name,o=i.array,a=i.itemSize;t.setAttribute(s,new We(o,a))}return t}_loadLibrary(e,t){let n=new Ql(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{let i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);let s=_7.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
4917
4917
|
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){let o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}};function _7(){let r,e;onmessage=function(o){let a=o.data;switch(a.type){case"init":r=a.decoderConfig,e=new Promise(function(c){r.onModuleLoaded=function(h){c({draco:h})},DracoDecoderModule(r)});break;case"decode":let l=a.buffer,u=a.taskConfig;e.then(c=>{let h=c.draco,f=new h.Decoder,d=new h.DecoderBuffer;d.Init(new Int8Array(l),l.byteLength);try{let m=t(h,f,d,u),p=m.attributes.map(g=>g.array.buffer);m.index&&p.push(m.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:m},p)}catch(m){console.error(m),self.postMessage({type:"error",id:a.id,error:m.message})}finally{h.destroy(d),h.destroy(f)}});break}};function t(o,a,l,u){let c=u.attributeIDs,h=u.attributeTypes,f,d,m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)f=new o.Mesh,d=a.DecodeBufferToMesh(l,f);else if(m===o.POINT_CLOUD)f=new o.PointCloud,d=a.DecodeBufferToPointCloud(l,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());let p={index:null,attributes:[]};for(let g in c){let v=self[h[g]],y,b;if(u.useUniqueIDs)b=c[g],y=a.GetAttributeByUniqueId(f,b);else{if(b=a.GetAttributeId(f,o[c[g]]),b===-1)continue;y=a.GetAttribute(f,b)}p.attributes.push(i(o,a,f,g,v,y))}return m===o.TRIANGULAR_MESH&&(p.index=n(o,a,f)),o.destroy(f),p}function n(o,a,l){let c=l.num_faces()*3,h=c*4,f=o._malloc(h);a.GetTrianglesUInt32Array(l,h,f);let d=new Uint32Array(o.HEAPF32.buffer,f,c).slice();return o._free(f),{array:d,itemSize:1}}function i(o,a,l,u,c,h){let f=h.num_components(),m=l.num_points()*f,p=m*c.BYTES_PER_ELEMENT,g=s(o,c),v=o._malloc(p);a.GetAttributeDataArrayForAllPoints(l,h,g,p,v);let y=new c(o.HEAPF32.buffer,v,m).slice();return o._free(v),{name:u,array:y,itemSize:f}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var la;function M7(){return la||(la=new fv,la.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),la.decoderPending}async function E7(r){if(la){let e={attributeIDs:la.defaultAttributeIDs,attributeTypes:la.defaultAttributeTypes,useUniqueIDs:!1},t;try{t=await la.decodeGeometry(new Int8Array(r).buffer,e)}catch(n){console.error(n)}if(t)return{index:t.index?{array:t.index.array}:void 0,attributes:Object.entries(t.attributes).map(([n,i])=>({name:n,itemSize:i.itemSize,array:i.array}))}}return null}async function MD(r,e){let[t,n]=A0(dm.deserialize(new Uint8Array(r)));iM(t);let i=[];t.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&i.push(o)}),i.length&&await M7();for(let s of i){let o=await E7(Mn(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:u,itemSize:c})=>{a[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return e&&e(t),n.result().data}var ED=Object.keys(zb).filter(r=>isNaN(Number(r))),dv=class{constructor(e,t,n,i,s,o,a,l){this.preventScroll=s;this.requestRender=a;this.isEnable=!1;this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0};this.onTouchMovePreventScroll=e=>{(e.touches.length>1||this.preventScroll)&&e.preventDefault()};this.onMouseWheelPreventScroll=e=>{this.preventScroll&&e.preventDefault()};this.eventContext=new jg(e,t,n,o,i,l??!1),this.handlers=[new nv(this.eventContext),new lv(this.eventContext),new rv(this.eventContext),new ov(this.eventContext),new av(this.eventContext),new iv(this.eventContext),new sv(this.eventContext)]}activate(){let{scene:e,domElement:t}=this.eventContext;this.isEnable=!0,e.traverseEntity(n=>{n.addEventListener("requestRender",this.requestRender)}),this.handlers.forEach(n=>n.connect()),this.resize(),ED.forEach(n=>{this.handlers.some(i=>i.domEventsNeeded.has(n))&&t.addEventListener(n,this.onResetRaycaster)}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll)}deactivate(){let{scene:e,domElement:t}=this.eventContext;this.isEnable=!1,this.handlers.forEach(n=>n.disconnect()),e.traverseEntity(n=>{n.removeEventListener("requestRender",this.requestRender)}),ED.forEach(n=>{t.removeEventListener(n,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll)}reset(){this.deactivate(),this.activate()}resize(){this.eventContext.updaterRect()}};var pv=class{constructor(e,t,n,i,s){this._aspect=1;this._renderer=e,this._camera=t,this._frameSize=new k().copy(n),this._editorSize=new k().copy(i),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewportForImageExport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y;this._aspect=e/t,this._camera.zoom*=Math.min(n/e,i/t),this._renderer.setViewport(0,0,e,t)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y,s=0,o=0,a=e,l=t;e<n&&(s=(n-e)*.5,s=-s,a=n),t<i&&(o=(i-t)*.5,o=-o,l=i),this._aspect=a/l,this._renderer.setViewport(s,o,a,l)}updateCamera(){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,t=this._editorSize.y,n=this._fov;if(e>t){let i=C7(e,1080,2160,1,15)/100;n*=e/t,n*=1-i}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}};function C7(r,e,t,n,i){return(r-e)/(t-e)*(i-n)+n}var RD={RED:0,GREEN:1,BLUE:2,ALPHA:3};var yd="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var P7=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
|
4918
4918
|
uniform mediump sampler2D inputBuffer;
|
|
4919
4919
|
#else
|