@aibee/crc-bmap 0.12.9 → 0.12.10

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.
@@ -7940,7 +7940,7 @@ void main() {
7940
7940
  }
7941
7941
 
7942
7942
  }\`,go=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){let s=new Le,r=t.properties.get(s);r.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}render(t,e){if(this.texture!==null){if(this.mesh===null){let n=e.cameras[0].viewport,s=new qe({extensions:{fragDepth:!0},vertexShader:im,fragmentShader:sm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new ze(new Xs(20,20),s)}t.render(this.mesh,e)}}reset(){this.texture=null,this.mesh=null}},_o=class extends Mn{constructor(t,e){super();let n=this,s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,m=null,g=null,y=new go,f=e.getContextAttributes(),p=null,E=null,x=[],A=[],L=new nt,R=null,T=new Re;T.layers.enable(1),T.viewport=new de;let B=new Re;B.layers.enable(2),B.viewport=new de;let K=[T,B],v=new mo;v.layers.enable(1),v.layers.enable(2);let b=null,it=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let Q=x[z];return Q===void 0&&(Q=new Fi,x[z]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(z){let Q=x[z];return Q===void 0&&(Q=new Fi,x[z]=Q),Q.getGripSpace()},this.getHand=function(z){let Q=x[z];return Q===void 0&&(Q=new Fi,x[z]=Q),Q.getHandSpace()};function $(z){let Q=A.indexOf(z.inputSource);if(Q===-1)return;let pt=x[Q];pt!==void 0&&(pt.update(z.inputSource,z.frame,c||a),pt.dispatchEvent({type:z.type,data:z.inputSource}))}function C(){s.removeEventListener("select",$),s.removeEventListener("selectstart",$),s.removeEventListener("selectend",$),s.removeEventListener("squeeze",$),s.removeEventListener("squeezestart",$),s.removeEventListener("squeezeend",$),s.removeEventListener("end",C),s.removeEventListener("inputsourceschange",H);for(let z=0;z<x.length;z++){let Q=A[z];Q!==null&&(A[z]=null,x[z].disconnect(Q))}b=null,it=null,y.reset(),t.setRenderTarget(p),m=null,d=null,u=null,s=null,E=null,Pt.stop(),n.isPresenting=!1,t.setPixelRatio(R),t.setSize(L.width,L.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(z){r=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(z){o=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(z){c=z},this.getBaseLayer=function(){return d!==null?d:m},this.getBinding=function(){return u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=function(z){return Qi(this,null,function*(){if(s=z,s!==null){if(p=t.getRenderTarget(),s.addEventListener("select",$),s.addEventListener("selectstart",$),s.addEventListener("selectend",$),s.addEventListener("squeeze",$),s.addEventListener("squeezestart",$),s.addEventListener("squeezeend",$),s.addEventListener("end",C),s.addEventListener("inputsourceschange",H),f.xrCompatible!==!0&&(yield e.makeXRCompatible()),R=t.getPixelRatio(),t.getSize(L),s.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let Q={antialias:s.renderState.layers===void 0?f.antialias:!0,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};m=new XRWebGLLayer(s,e,Q),s.updateRenderState({baseLayer:m}),t.setPixelRatio(1),t.setSize(m.framebufferWidth,m.framebufferHeight,!1),E=new on(m.framebufferWidth,m.framebufferHeight,{format:Be,type:xn,colorSpace:t.outputColorSpace,stencilBuffer:f.stencil})}else{let Q=null,pt=null,Et=null;f.depth&&(Et=f.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,Q=f.stencil?vi:zn,pt=f.stencil?Bn:mn);let yt={colorFormat:e.RGBA8,depthFormat:Et,scaleFactor:r};u=new XRWebGLBinding(s,e),d=u.createProjectionLayer(yt),s.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),E=new on(d.textureWidth,d.textureHeight,{format:Be,type:xn,depthTexture:new Ys(d.textureWidth,d.textureHeight,pt,void 0,void 0,void 0,void 0,void 0,void 0,Q),stencilBuffer:f.stencil,colorSpace:t.outputColorSpace,samples:f.antialias?4:0});let xt=t.properties.get(E);xt.__ignoreDepthValues=d.ignoreDepthValues}E.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=yield s.requestReferenceSpace(o),Pt.setContext(s),Pt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode};function H(z){for(let Q=0;Q<z.removed.length;Q++){let pt=z.removed[Q],Et=A.indexOf(pt);Et>=0&&(A[Et]=null,x[Et].disconnect(pt))}for(let Q=0;Q<z.added.length;Q++){let pt=z.added[Q],Et=A.indexOf(pt);if(Et===-1){for(let xt=0;xt<x.length;xt++)if(xt>=A.length){A.push(pt),Et=xt;break}else if(A[xt]===null){A[xt]=pt,Et=xt;break}if(Et===-1)break}let yt=x[Et];yt&&yt.connect(pt)}}let V=new I,Y=new I;function W(z,Q,pt){V.setFromMatrixPosition(Q.matrixWorld),Y.setFromMatrixPosition(pt.matrixWorld);let Et=V.distanceTo(Y),yt=Q.projectionMatrix.elements,xt=pt.projectionMatrix.elements,zt=yt[14]/(yt[10]-1),At=yt[14]/(yt[10]+1),w=(yt[9]+1)/yt[5],ot=(yt[9]-1)/yt[5],q=(yt[8]-1)/yt[0],st=(xt[8]+1)/xt[0],Z=zt*q,_t=zt*st,ft=Et/(-q+st),vt=ft*-q;Q.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(vt),z.translateZ(ft),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert();let Vt=zt+ft,S=At+ft,_=Z-vt,k=_t+(Et-vt),G=w*At/S*Vt,j=ot*At/S*Vt;z.projectionMatrix.makePerspective(_,k,G,j,Vt,S),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}function X(z,Q){Q===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(Q.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;y.texture!==null&&(z.near=y.depthNear,z.far=y.depthFar),v.near=B.near=T.near=z.near,v.far=B.far=T.far=z.far,(b!==v.near||it!==v.far)&&(s.updateRenderState({depthNear:v.near,depthFar:v.far}),b=v.near,it=v.far,T.near=b,T.far=it,B.near=b,B.far=it,T.updateProjectionMatrix(),B.updateProjectionMatrix(),z.updateProjectionMatrix());let Q=z.parent,pt=v.cameras;X(v,Q);for(let Et=0;Et<pt.length;Et++)X(pt[Et],Q);pt.length===2?W(v,T,B):v.projectionMatrix.copy(T.projectionMatrix),et(z,v,Q)};function et(z,Q,pt){pt===null?z.matrix.copy(Q.matrixWorld):(z.matrix.copy(pt.matrixWorld),z.matrix.invert(),z.matrix.multiply(Q.matrixWorld)),z.matrix.decompose(z.position,z.quaternion,z.scale),z.updateMatrixWorld(!0),z.projectionMatrix.copy(Q.projectionMatrix),z.projectionMatrixInverse.copy(Q.projectionMatrixInverse),z.isPerspectiveCamera&&(z.fov=Qr*2*Math.atan(1/z.projectionMatrix.elements[5]),z.zoom=1)}this.getCamera=function(){return v},this.getFoveation=function(){if(!(d===null&&m===null))return l},this.setFoveation=function(z){l=z,d!==null&&(d.fixedFoveation=z),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=z)},this.hasDepthSensing=function(){return y.texture!==null};let tt=null;function gt(z,Q){if(h=Q.getViewerPose(c||a),g=Q,h!==null){let pt=h.views;m!==null&&(t.setRenderTargetFramebuffer(E,m.framebuffer),t.setRenderTarget(E));let Et=!1;pt.length!==v.cameras.length&&(v.cameras.length=0,Et=!0);for(let xt=0;xt<pt.length;xt++){let zt=pt[xt],At=null;if(m!==null)At=m.getViewport(zt);else{let ot=u.getViewSubImage(d,zt);At=ot.viewport,xt===0&&(t.setRenderTargetTextures(E,ot.colorTexture,d.ignoreDepthValues?void 0:ot.depthStencilTexture),t.setRenderTarget(E))}let w=K[xt];w===void 0&&(w=new Re,w.layers.enable(xt),w.viewport=new de,K[xt]=w),w.matrix.fromArray(zt.transform.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale),w.projectionMatrix.fromArray(zt.projectionMatrix),w.projectionMatrixInverse.copy(w.projectionMatrix).invert(),w.viewport.set(At.x,At.y,At.width,At.height),xt===0&&(v.matrix.copy(w.matrix),v.matrix.decompose(v.position,v.quaternion,v.scale)),Et===!0&&v.cameras.push(w)}let yt=s.enabledFeatures;if(yt&&yt.includes("depth-sensing")){let xt=u.getDepthInformation(pt[0]);xt&&xt.isValid&&xt.texture&&y.init(t,xt,s.renderState)}}for(let pt=0;pt<x.length;pt++){let Et=A[pt],yt=x[pt];Et!==null&&yt!==void 0&&yt.update(Et,Q,c||a)}y.render(t,v),tt&&tt(z,Q),Q.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Q}),g=null}let Pt=new Wl;Pt.setAnimationLoop(gt),this.setAnimationLoop=function(z){tt=z},this.dispose=function(){}}},In=new Vn,rm=new oe;function om(i,t){function e(f,p){f.matrixAutoUpdate===!0&&f.updateMatrix(),p.value.copy(f.matrix)}function n(f,p){p.color.getRGB(f.fogColor.value,Hl(i)),p.isFog?(f.fogNear.value=p.near,f.fogFar.value=p.far):p.isFogExp2&&(f.fogDensity.value=p.density)}function s(f,p,E,x,A){p.isMeshBasicMaterial||p.isMeshLambertMaterial?r(f,p):p.isMeshToonMaterial?(r(f,p),u(f,p)):p.isMeshPhongMaterial?(r(f,p),h(f,p)):p.isMeshStandardMaterial?(r(f,p),d(f,p),p.isMeshPhysicalMaterial&&m(f,p,A)):p.isMeshMatcapMaterial?(r(f,p),g(f,p)):p.isMeshDepthMaterial?r(f,p):p.isMeshDistanceMaterial?(r(f,p),y(f,p)):p.isMeshNormalMaterial?r(f,p):p.isLineBasicMaterial?(a(f,p),p.isLineDashedMaterial&&o(f,p)):p.isPointsMaterial?l(f,p,E,x):p.isSpriteMaterial?c(f,p):p.isShadowMaterial?(f.color.value.copy(p.color),f.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(f,p){f.opacity.value=p.opacity,p.color&&f.diffuse.value.copy(p.color),p.emissive&&f.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(f.map.value=p.map,e(p.map,f.mapTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,e(p.alphaMap,f.alphaMapTransform)),p.bumpMap&&(f.bumpMap.value=p.bumpMap,e(p.bumpMap,f.bumpMapTransform),f.bumpScale.value=p.bumpScale,p.side===be&&(f.bumpScale.value*=-1)),p.normalMap&&(f.normalMap.value=p.normalMap,e(p.normalMap,f.normalMapTransform),f.normalScale.value.copy(p.normalScale),p.side===be&&f.normalScale.value.negate()),p.displacementMap&&(f.displacementMap.value=p.displacementMap,e(p.displacementMap,f.displacementMapTransform),f.displacementScale.value=p.displacementScale,f.displacementBias.value=p.displacementBias),p.emissiveMap&&(f.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,f.emissiveMapTransform)),p.specularMap&&(f.specularMap.value=p.specularMap,e(p.specularMap,f.specularMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest);let E=t.get(p),x=E.envMap,A=E.envMapRotation;if(x&&(f.envMap.value=x,In.copy(A),In.x*=-1,In.y*=-1,In.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(In.y*=-1,In.z*=-1),f.envMapRotation.value.setFromMatrix4(rm.makeRotationFromEuler(In)),f.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=p.reflectivity,f.ior.value=p.ior,f.refractionRatio.value=p.refractionRatio),p.lightMap){f.lightMap.value=p.lightMap;let L=i._useLegacyLights===!0?Math.PI:1;f.lightMapIntensity.value=p.lightMapIntensity*L,e(p.lightMap,f.lightMapTransform)}p.aoMap&&(f.aoMap.value=p.aoMap,f.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,f.aoMapTransform))}function a(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,p.map&&(f.map.value=p.map,e(p.map,f.mapTransform))}function o(f,p){f.dashSize.value=p.dashSize,f.totalSize.value=p.dashSize+p.gapSize,f.scale.value=p.scale}function l(f,p,E,x){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.size.value=p.size*E,f.scale.value=x*.5,p.map&&(f.map.value=p.map,e(p.map,f.uvTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,e(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function c(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.rotation.value=p.rotation,p.map&&(f.map.value=p.map,e(p.map,f.mapTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,e(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function h(f,p){f.specular.value.copy(p.specular),f.shininess.value=Math.max(p.shininess,1e-4)}function u(f,p){p.gradientMap&&(f.gradientMap.value=p.gradientMap)}function d(f,p){f.metalness.value=p.metalness,p.metalnessMap&&(f.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,f.metalnessMapTransform)),f.roughness.value=p.roughness,p.roughnessMap&&(f.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,f.roughnessMapTransform)),t.get(p).envMap&&(f.envMapIntensity.value=p.envMapIntensity)}function m(f,p,E){f.ior.value=p.ior,p.sheen>0&&(f.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),f.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(f.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,f.sheenColorMapTransform)),p.sheenRoughnessMap&&(f.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,f.sheenRoughnessMapTransform))),p.clearcoat>0&&(f.clearcoat.value=p.clearcoat,f.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(f.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,f.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(f.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===be&&f.clearcoatNormalScale.value.negate())),p.iridescence>0&&(f.iridescence.value=p.iridescence,f.iridescenceIOR.value=p.iridescenceIOR,f.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(f.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,f.iridescenceMapTransform)),p.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),p.transmission>0&&(f.transmission.value=p.transmission,f.transmissionSamplerMap.value=E.texture,f.transmissionSamplerSize.value.set(E.width,E.height),p.transmissionMap&&(f.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,f.transmissionMapTransform)),f.thickness.value=p.thickness,p.thicknessMap&&(f.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=p.attenuationDistance,f.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(f.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(f.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=p.specularIntensity,f.specularColor.value.copy(p.specularColor),p.specularColorMap&&(f.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,f.specularColorMapTransform)),p.specularIntensityMap&&(f.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,f.specularIntensityMapTransform))}function g(f,p){p.matcap&&(f.matcap.value=p.matcap)}function y(f,p){let E=t.get(p).light;f.referencePosition.value.setFromMatrixPosition(E.matrixWorld),f.nearDistance.value=E.shadow.camera.near,f.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function am(i,t,e,n){let s={},r={},a=[],o=e.isWebGL2?i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(E,x){let A=x.program;n.uniformBlockBinding(E,A)}function c(E,x){let A=s[E.id];A===void 0&&(g(E),A=h(E),s[E.id]=A,E.addEventListener("dispose",f));let L=x.program;n.updateUBOMapping(E,L);let R=t.render.frame;r[E.id]!==R&&(d(E),r[E.id]=R)}function h(E){let x=u();E.__bindingPointIndex=x;let A=i.createBuffer(),L=E.__size,R=E.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,L,R),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,x,A),A}function u(){for(let E=0;E<o;E++)if(a.indexOf(E)===-1)return a.push(E),E;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(E){let x=s[E.id],A=E.uniforms,L=E.__cache;i.bindBuffer(i.UNIFORM_BUFFER,x);for(let R=0,T=A.length;R<T;R++){let B=Array.isArray(A[R])?A[R]:[A[R]];for(let K=0,v=B.length;K<v;K++){let b=B[K];if(m(b,R,K,L)===!0){let it=b.__offset,$=Array.isArray(b.value)?b.value:[b.value],C=0;for(let H=0;H<$.length;H++){let V=$[H],Y=y(V);typeof V=="number"||typeof V=="boolean"?(b.__data[0]=V,i.bufferSubData(i.UNIFORM_BUFFER,it+C,b.__data)):V.isMatrix3?(b.__data[0]=V.elements[0],b.__data[1]=V.elements[1],b.__data[2]=V.elements[2],b.__data[3]=0,b.__data[4]=V.elements[3],b.__data[5]=V.elements[4],b.__data[6]=V.elements[5],b.__data[7]=0,b.__data[8]=V.elements[6],b.__data[9]=V.elements[7],b.__data[10]=V.elements[8],b.__data[11]=0):(V.toArray(b.__data,C),C+=Y.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,it,b.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(E,x,A,L){let R=E.value,T=x+"_"+A;if(L[T]===void 0)return typeof R=="number"||typeof R=="boolean"?L[T]=R:L[T]=R.clone(),!0;{let B=L[T];if(typeof R=="number"||typeof R=="boolean"){if(B!==R)return L[T]=R,!0}else if(B.equals(R)===!1)return B.copy(R),!0}return!1}function g(E){let x=E.uniforms,A=0,L=16;for(let T=0,B=x.length;T<B;T++){let K=Array.isArray(x[T])?x[T]:[x[T]];for(let v=0,b=K.length;v<b;v++){let it=K[v],$=Array.isArray(it.value)?it.value:[it.value];for(let C=0,H=$.length;C<H;C++){let V=$[C],Y=y(V),W=A%L;W!==0&&L-W<Y.boundary&&(A+=L-W),it.__data=new Float32Array(Y.storage/Float32Array.BYTES_PER_ELEMENT),it.__offset=A,A+=Y.storage}}}let R=A%L;return R>0&&(A+=L-R),E.__size=A,E.__cache={},this}function y(E){let x={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(x.boundary=4,x.storage=4):E.isVector2?(x.boundary=8,x.storage=8):E.isVector3||E.isColor?(x.boundary=16,x.storage=12):E.isVector4?(x.boundary=16,x.storage=16):E.isMatrix3?(x.boundary=48,x.storage=48):E.isMatrix4?(x.boundary=64,x.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),x}function f(E){let x=E.target;x.removeEventListener("dispose",f);let A=a.indexOf(x.__bindingPointIndex);a.splice(A,1),i.deleteBuffer(s[x.id]),delete s[x.id],delete r[x.id]}function p(){for(let E in s)i.deleteBuffer(s[E]);a=[],s={},r={}}return{bind:l,update:c,dispose:p}}var xo=class{constructor(t={}){let{canvas:e=hh(),context:n=null,depth:s=!0,stencil:r=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=t;this.isWebGLRenderer=!0;let d;n!==null?d=n.getContextAttributes().alpha:d=a;let m=new Uint32Array(4),g=new Int32Array(4),y=null,f=null,p=[],E=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=He,this._useLegacyLights=!1,this.toneMapping=_n,this.toneMappingExposure=1;let x=this,A=!1,L=0,R=0,T=null,B=-1,K=null,v=new de,b=new de,it=null,$=new Wt(0),C=0,H=e.width,V=e.height,Y=1,W=null,X=null,et=new de(0,0,H,V),tt=new de(0,0,H,V),gt=!1,Pt=new Ws,z=!1,Q=!1,pt=null,Et=new oe,yt=new nt,xt=new I,zt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function At(){return T===null?Y:1}let w=n;function ot(M,U){for(let O=0;O<M.length;O++){let F=M[O],D=e.getContext(F,U);if(D!==null)return D}return null}try{let M={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",\`three.js r\${Vo}\`),e.addEventListener("webglcontextlost",Kt,!1),e.addEventListener("webglcontextrestored",P,!1),e.addEventListener("webglcontextcreationerror",ut,!1),w===null){let U=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&U.shift(),w=ot(U,M),w===null)throw ot(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext!="undefined"&&w instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),w.getShaderPrecisionFormat===void 0&&(w.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(M){throw console.error("THREE.WebGLRenderer: "+M.message),M}let q,st,Z,_t,ft,vt,Vt,S,_,k,G,j,J,It,Tt,lt,ht,Lt,rt,se,Gt,wt,Mt,St;function Xt(){q=new bf(w),st=new _f(w,q,t),q.init(st),wt=new em(w,q,st),Z=new jp(w,q,st),_t=new wf(w),ft=new Vp,vt=new tm(w,q,Z,ft,st,wt,_t),Vt=new vf(x),S=new Sf(x),_=new Ih(w,st),Mt=new mf(w,q,_,st),k=new Ef(w,_,_t,Mt),G=new Pf(w,k,_,_t),rt=new Cf(w,st,vt),lt=new xf(ft),j=new kp(x,Vt,S,q,st,Mt,lt),J=new om(x,ft),It=new Hp,Tt=new Jp(q,st),Lt=new pf(x,Vt,S,Z,G,d,l),ht=new Qp(x,G,st),St=new am(w,_t,st,Z),se=new gf(w,q,_t,st),Gt=new Af(w,q,_t,st),_t.programs=j.programs,x.capabilities=st,x.extensions=q,x.properties=ft,x.renderLists=It,x.shadowMap=ht,x.state=Z,x.info=_t}Xt();let Dt=new _o(x,w);this.xr=Dt,this.getContext=function(){return w},this.getContextAttributes=function(){return w.getContextAttributes()},this.forceContextLoss=function(){let M=q.get("WEBGL_lose_context");M&&M.loseContext()},this.forceContextRestore=function(){let M=q.get("WEBGL_lose_context");M&&M.restoreContext()},this.getPixelRatio=function(){return Y},this.setPixelRatio=function(M){M!==void 0&&(Y=M,this.setSize(H,V,!1))},this.getSize=function(M){return M.set(H,V)},this.setSize=function(M,U,O=!0){if(Dt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}H=M,V=U,e.width=Math.floor(M*Y),e.height=Math.floor(U*Y),O===!0&&(e.style.width=M+"px",e.style.height=U+"px"),this.setViewport(0,0,M,U)},this.getDrawingBufferSize=function(M){return M.set(H*Y,V*Y).floor()},this.setDrawingBufferSize=function(M,U,O){H=M,V=U,Y=O,e.width=Math.floor(M*O),e.height=Math.floor(U*O),this.setViewport(0,0,M,U)},this.getCurrentViewport=function(M){return M.copy(v)},this.getViewport=function(M){return M.copy(et)},this.setViewport=function(M,U,O,F){M.isVector4?et.set(M.x,M.y,M.z,M.w):et.set(M,U,O,F),Z.viewport(v.copy(et).multiplyScalar(Y).round())},this.getScissor=function(M){return M.copy(tt)},this.setScissor=function(M,U,O,F){M.isVector4?tt.set(M.x,M.y,M.z,M.w):tt.set(M,U,O,F),Z.scissor(b.copy(tt).multiplyScalar(Y).round())},this.getScissorTest=function(){return gt},this.setScissorTest=function(M){Z.setScissorTest(gt=M)},this.setOpaqueSort=function(M){W=M},this.setTransparentSort=function(M){X=M},this.getClearColor=function(M){return M.copy(Lt.getClearColor())},this.setClearColor=function(){Lt.setClearColor.apply(Lt,arguments)},this.getClearAlpha=function(){return Lt.getClearAlpha()},this.setClearAlpha=function(){Lt.setClearAlpha.apply(Lt,arguments)},this.clear=function(M=!0,U=!0,O=!0){let F=0;if(M){let D=!1;if(T!==null){let mt=T.texture.format;D=mt===Fl||mt===Ol||mt===Nl}if(D){let mt=T.texture.type,bt=mt===xn||mt===mn||mt===Go||mt===Bn||mt===Ul||mt===Dl,Rt=Lt.getClearColor(),Ct=Lt.getClearAlpha(),kt=Rt.r,Ut=Rt.g,Nt=Rt.b;bt?(m[0]=kt,m[1]=Ut,m[2]=Nt,m[3]=Ct,w.clearBufferuiv(w.COLOR,0,m)):(g[0]=kt,g[1]=Ut,g[2]=Nt,g[3]=Ct,w.clearBufferiv(w.COLOR,0,g))}else F|=w.COLOR_BUFFER_BIT}U&&(F|=w.DEPTH_BUFFER_BIT),O&&(F|=w.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),w.clear(F)},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",Kt,!1),e.removeEventListener("webglcontextrestored",P,!1),e.removeEventListener("webglcontextcreationerror",ut,!1),It.dispose(),Tt.dispose(),ft.dispose(),Vt.dispose(),S.dispose(),G.dispose(),Mt.dispose(),St.dispose(),j.dispose(),ht.dispose(),Dt.dispose(),Dt.removeEventListener("sessionstart",Ce),Dt.removeEventListener("sessionend",Jt),pt&&(pt.dispose(),pt=null),xe.stop()};function Kt(M){M.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function P(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;let M=_t.autoReset,U=ht.enabled,O=ht.autoUpdate,F=ht.needsUpdate,D=ht.type;Xt(),_t.autoReset=M,ht.enabled=U,ht.autoUpdate=O,ht.needsUpdate=F,ht.type=D}function ut(M){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",M.statusMessage)}function N(M){let U=M.target;U.removeEventListener("dispose",N),at(U)}function at(M){dt(M),ft.remove(M)}function dt(M){let U=ft.get(M).programs;U!==void 0&&(U.forEach(function(O){j.releaseProgram(O)}),M.isShaderMaterial&&j.releaseShaderCache(M))}this.renderBufferDirect=function(M,U,O,F,D,mt){U===null&&(U=zt);let bt=D.isMesh&&D.matrixWorld.determinant()<0,Rt=rc(M,U,O,F,D);Z.setMaterial(F,bt);let Ct=O.index,kt=1;if(F.wireframe===!0){if(Ct=k.getWireframeAttribute(O),Ct===void 0)return;kt=2}let Ut=O.drawRange,Nt=O.attributes.position,ie=Ut.start*kt,Ae=(Ut.start+Ut.count)*kt;mt!==null&&(ie=Math.max(ie,mt.start*kt),Ae=Math.min(Ae,(mt.start+mt.count)*kt)),Ct!==null?(ie=Math.max(ie,0),Ae=Math.min(Ae,Ct.count)):Nt!=null&&(ie=Math.max(ie,0),Ae=Math.min(Ae,Nt.count));let ce=Ae-ie;if(ce<0||ce===1/0)return;Mt.setup(D,F,Rt,O,Ct);let Ye,ee=se;if(Ct!==null&&(Ye=_.get(Ct),ee=Gt,ee.setIndex(Ye)),D.isMesh)F.wireframe===!0?(Z.setLineWidth(F.wireframeLinewidth*At()),ee.setMode(w.LINES)):ee.setMode(w.TRIANGLES);else if(D.isLine){let Ot=F.linewidth;Ot===void 0&&(Ot=1),Z.setLineWidth(Ot*At()),D.isLineSegments?ee.setMode(w.LINES):D.isLineLoop?ee.setMode(w.LINE_LOOP):ee.setMode(w.LINE_STRIP)}else D.isPoints?ee.setMode(w.POINTS):D.isSprite&&ee.setMode(w.TRIANGLES);if(D.isBatchedMesh)ee.renderMultiDraw(D._multiDrawStarts,D._multiDrawCounts,D._multiDrawCount);else if(D.isInstancedMesh)ee.renderInstances(ie,ce,D.count);else if(O.isInstancedBufferGeometry){let Ot=O._maxInstanceCount!==void 0?O._maxInstanceCount:1/0,ir=Math.min(O.instanceCount,Ot);ee.renderInstances(ie,ce,ir)}else ee.render(ie,ce)};function Ht(M,U,O){M.transparent===!0&&M.side===en&&M.forceSinglePass===!1?(M.side=be,M.needsUpdate=!0,Ki(M,U,O),M.side=yn,M.needsUpdate=!0,Ki(M,U,O),M.side=en):Ki(M,U,O)}this.compile=function(M,U,O=null){O===null&&(O=M),f=Tt.get(O),f.init(),E.push(f),O.traverseVisible(function(D){D.isLight&&D.layers.test(U.layers)&&(f.pushLight(D),D.castShadow&&f.pushShadow(D))}),M!==O&&M.traverseVisible(function(D){D.isLight&&D.layers.test(U.layers)&&(f.pushLight(D),D.castShadow&&f.pushShadow(D))}),f.setupLights(x._useLegacyLights);let F=new Set;return M.traverse(function(D){let mt=D.material;if(mt)if(Array.isArray(mt))for(let bt=0;bt<mt.length;bt++){let Rt=mt[bt];Ht(Rt,O,D),F.add(Rt)}else Ht(mt,O,D),F.add(mt)}),E.pop(),f=null,F},this.compileAsync=function(M,U,O=null){let F=this.compile(M,U,O);return new Promise(D=>{function mt(){if(F.forEach(function(bt){ft.get(bt).currentProgram.isReady()&&F.delete(bt)}),F.size===0){D(M);return}setTimeout(mt,10)}q.get("KHR_parallel_shader_compile")!==null?mt():setTimeout(mt,10)})};let Zt=null;function ue(M){Zt&&Zt(M)}function Ce(){xe.stop()}function Jt(){xe.start()}let xe=new Wl;xe.setAnimationLoop(ue),typeof self!="undefined"&&xe.setContext(self),this.setAnimationLoop=function(M){Zt=M,Dt.setAnimationLoop(M),M===null?xe.stop():xe.start()},Dt.addEventListener("sessionstart",Ce),Dt.addEventListener("sessionend",Jt),this.render=function(M,U){if(U!==void 0&&U.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;M.matrixWorldAutoUpdate===!0&&M.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),Dt.enabled===!0&&Dt.isPresenting===!0&&(Dt.cameraAutoUpdate===!0&&Dt.updateCamera(U),U=Dt.getCamera()),M.isScene===!0&&M.onBeforeRender(x,M,U,T),f=Tt.get(M,E.length),f.init(),E.push(f),Et.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Pt.setFromProjectionMatrix(Et),Q=this.localClippingEnabled,z=lt.init(this.clippingPlanes,Q),y=It.get(M,p.length),y.init(),p.push(y),Ge(M,U,0,x.sortObjects),y.finish(),x.sortObjects===!0&&y.sort(W,X),this.info.render.frame++,z===!0&&lt.beginShadows();let O=f.state.shadowsArray;if(ht.render(O,M,U),z===!0&&lt.endShadows(),this.info.autoReset===!0&&this.info.reset(),(Dt.enabled===!1||Dt.isPresenting===!1||Dt.hasDepthSensing()===!1)&&Lt.render(y,M),f.setupLights(x._useLegacyLights),U.isArrayCamera){let F=U.cameras;for(let D=0,mt=F.length;D<mt;D++){let bt=F[D];Zo(y,M,bt,bt.viewport)}}else Zo(y,M,U);T!==null&&(vt.updateMultisampleRenderTarget(T),vt.updateRenderTargetMipmap(T)),M.isScene===!0&&M.onAfterRender(x,M,U),Mt.resetDefaultState(),B=-1,K=null,E.pop(),E.length>0?f=E[E.length-1]:f=null,p.pop(),p.length>0?y=p[p.length-1]:y=null};function Ge(M,U,O,F){if(M.visible===!1)return;if(M.layers.test(U.layers)){if(M.isGroup)O=M.renderOrder;else if(M.isLOD)M.autoUpdate===!0&&M.update(U);else if(M.isLight)f.pushLight(M),M.castShadow&&f.pushShadow(M);else if(M.isSprite){if(!M.frustumCulled||Pt.intersectsSprite(M)){F&&xt.setFromMatrixPosition(M.matrixWorld).applyMatrix4(Et);let bt=G.update(M),Rt=M.material;Rt.visible&&y.push(M,bt,Rt,O,xt.z,null)}}else if((M.isMesh||M.isLine||M.isPoints)&&(!M.frustumCulled||Pt.intersectsObject(M))){let bt=G.update(M),Rt=M.material;if(F&&(M.boundingSphere!==void 0?(M.boundingSphere===null&&M.computeBoundingSphere(),xt.copy(M.boundingSphere.center)):(bt.boundingSphere===null&&bt.computeBoundingSphere(),xt.copy(bt.boundingSphere.center)),xt.applyMatrix4(M.matrixWorld).applyMatrix4(Et)),Array.isArray(Rt)){let Ct=bt.groups;for(let kt=0,Ut=Ct.length;kt<Ut;kt++){let Nt=Ct[kt],ie=Rt[Nt.materialIndex];ie&&ie.visible&&y.push(M,bt,ie,O,xt.z,Nt)}}else Rt.visible&&y.push(M,bt,Rt,O,xt.z,null)}}let mt=M.children;for(let bt=0,Rt=mt.length;bt<Rt;bt++)Ge(mt[bt],U,O,F)}function Zo(M,U,O,F){let D=M.opaque,mt=M.transmissive,bt=M.transparent;f.setupLightsView(O),z===!0&&lt.setGlobalState(x.clippingPlanes,O),mt.length>0&&sc(D,mt,U,O),F&&Z.viewport(v.copy(F)),D.length>0&&$i(D,U,O),mt.length>0&&$i(mt,U,O),bt.length>0&&$i(bt,U,O),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function sc(M,U,O,F){if((O.isScene===!0?O.overrideMaterial:null)!==null)return;let mt=st.isWebGL2;pt===null&&(pt=new on(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")?ki:xn,minFilter:Nn,samples:mt?4:0})),x.getDrawingBufferSize(yt),mt?pt.setSize(yt.x,yt.y):pt.setSize(jr(yt.x),jr(yt.y));let bt=x.getRenderTarget();x.setRenderTarget(pt),x.getClearColor($),C=x.getClearAlpha(),C<1&&x.setClearColor(16777215,.5),x.clear();let Rt=x.toneMapping;x.toneMapping=_n,$i(M,O,F),vt.updateMultisampleRenderTarget(pt),vt.updateRenderTargetMipmap(pt);let Ct=!1;for(let kt=0,Ut=U.length;kt<Ut;kt++){let Nt=U[kt],ie=Nt.object,Ae=Nt.geometry,ce=Nt.material,Ye=Nt.group;if(ce.side===en&&ie.layers.test(F.layers)){let ee=ce.side;ce.side=be,ce.needsUpdate=!0,Jo(ie,O,F,Ae,ce,Ye),ce.side=ee,ce.needsUpdate=!0,Ct=!0}}Ct===!0&&(vt.updateMultisampleRenderTarget(pt),vt.updateRenderTargetMipmap(pt)),x.setRenderTarget(bt),x.setClearColor($,C),x.toneMapping=Rt}function $i(M,U,O){let F=U.isScene===!0?U.overrideMaterial:null;for(let D=0,mt=M.length;D<mt;D++){let bt=M[D],Rt=bt.object,Ct=bt.geometry,kt=F===null?bt.material:F,Ut=bt.group;Rt.layers.test(O.layers)&&Jo(Rt,U,O,Ct,kt,Ut)}}function Jo(M,U,O,F,D,mt){M.onBeforeRender(x,U,O,F,D,mt),M.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,M.matrixWorld),M.normalMatrix.getNormalMatrix(M.modelViewMatrix),D.onBeforeRender(x,U,O,F,M,mt),D.transparent===!0&&D.side===en&&D.forceSinglePass===!1?(D.side=be,D.needsUpdate=!0,x.renderBufferDirect(O,U,F,D,M,mt),D.side=yn,D.needsUpdate=!0,x.renderBufferDirect(O,U,F,D,M,mt),D.side=en):x.renderBufferDirect(O,U,F,D,M,mt),M.onAfterRender(x,U,O,F,D,mt)}function Ki(M,U,O){U.isScene!==!0&&(U=zt);let F=ft.get(M),D=f.state.lights,mt=f.state.shadowsArray,bt=D.state.version,Rt=j.getParameters(M,D.state,mt,U,O),Ct=j.getProgramCacheKey(Rt),kt=F.programs;F.environment=M.isMeshStandardMaterial?U.environment:null,F.fog=U.fog,F.envMap=(M.isMeshStandardMaterial?S:Vt).get(M.envMap||F.environment),F.envMapRotation=F.environment!==null&&M.envMap===null?U.environmentRotation:M.envMapRotation,kt===void 0&&(M.addEventListener("dispose",N),kt=new Map,F.programs=kt);let Ut=kt.get(Ct);if(Ut!==void 0){if(F.currentProgram===Ut&&F.lightsStateVersion===bt)return Ko(M,Rt),Ut}else Rt.uniforms=j.getUniforms(M),M.onBuild(O,Rt,x),M.onBeforeCompile(Rt,x),Ut=j.acquireProgram(Rt,Ct),kt.set(Ct,Ut),F.uniforms=Rt.uniforms;let Nt=F.uniforms;return(!M.isShaderMaterial&&!M.isRawShaderMaterial||M.clipping===!0)&&(Nt.clippingPlanes=lt.uniform),Ko(M,Rt),F.needsLights=ac(M),F.lightsStateVersion=bt,F.needsLights&&(Nt.ambientLightColor.value=D.state.ambient,Nt.lightProbe.value=D.state.probe,Nt.directionalLights.value=D.state.directional,Nt.directionalLightShadows.value=D.state.directionalShadow,Nt.spotLights.value=D.state.spot,Nt.spotLightShadows.value=D.state.spotShadow,Nt.rectAreaLights.value=D.state.rectArea,Nt.ltc_1.value=D.state.rectAreaLTC1,Nt.ltc_2.value=D.state.rectAreaLTC2,Nt.pointLights.value=D.state.point,Nt.pointLightShadows.value=D.state.pointShadow,Nt.hemisphereLights.value=D.state.hemi,Nt.directionalShadowMap.value=D.state.directionalShadowMap,Nt.directionalShadowMatrix.value=D.state.directionalShadowMatrix,Nt.spotShadowMap.value=D.state.spotShadowMap,Nt.spotLightMatrix.value=D.state.spotLightMatrix,Nt.spotLightMap.value=D.state.spotLightMap,Nt.pointShadowMap.value=D.state.pointShadowMap,Nt.pointShadowMatrix.value=D.state.pointShadowMatrix),F.currentProgram=Ut,F.uniformsList=null,Ut}function $o(M){if(M.uniformsList===null){let U=M.currentProgram.getUniforms();M.uniformsList=gi.seqWithValue(U.seq,M.uniforms)}return M.uniformsList}function Ko(M,U){let O=ft.get(M);O.outputColorSpace=U.outputColorSpace,O.batching=U.batching,O.instancing=U.instancing,O.instancingColor=U.instancingColor,O.instancingMorph=U.instancingMorph,O.skinning=U.skinning,O.morphTargets=U.morphTargets,O.morphNormals=U.morphNormals,O.morphColors=U.morphColors,O.morphTargetsCount=U.morphTargetsCount,O.numClippingPlanes=U.numClippingPlanes,O.numIntersection=U.numClipIntersection,O.vertexAlphas=U.vertexAlphas,O.vertexTangents=U.vertexTangents,O.toneMapping=U.toneMapping}function rc(M,U,O,F,D){U.isScene!==!0&&(U=zt),vt.resetTextureUnits();let mt=U.fog,bt=F.isMeshStandardMaterial?U.environment:null,Rt=T===null?x.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:bn,Ct=(F.isMeshStandardMaterial?S:Vt).get(F.envMap||bt),kt=F.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,Ut=!!O.attributes.tangent&&(!!F.normalMap||F.anisotropy>0),Nt=!!O.morphAttributes.position,ie=!!O.morphAttributes.normal,Ae=!!O.morphAttributes.color,ce=_n;F.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(ce=x.toneMapping);let Ye=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,ee=Ye!==void 0?Ye.length:0,Ot=ft.get(F),ir=f.state.lights;if(z===!0&&(Q===!0||M!==K)){let Pe=M===K&&F.id===B;lt.setState(F,M,Pe)}let Qt=!1;F.version===Ot.__version?(Ot.needsLights&&Ot.lightsStateVersion!==ir.state.version||Ot.outputColorSpace!==Rt||D.isBatchedMesh&&Ot.batching===!1||!D.isBatchedMesh&&Ot.batching===!0||D.isInstancedMesh&&Ot.instancing===!1||!D.isInstancedMesh&&Ot.instancing===!0||D.isSkinnedMesh&&Ot.skinning===!1||!D.isSkinnedMesh&&Ot.skinning===!0||D.isInstancedMesh&&Ot.instancingColor===!0&&D.instanceColor===null||D.isInstancedMesh&&Ot.instancingColor===!1&&D.instanceColor!==null||D.isInstancedMesh&&Ot.instancingMorph===!0&&D.morphTexture===null||D.isInstancedMesh&&Ot.instancingMorph===!1&&D.morphTexture!==null||Ot.envMap!==Ct||F.fog===!0&&Ot.fog!==mt||Ot.numClippingPlanes!==void 0&&(Ot.numClippingPlanes!==lt.numPlanes||Ot.numIntersection!==lt.numIntersection)||Ot.vertexAlphas!==kt||Ot.vertexTangents!==Ut||Ot.morphTargets!==Nt||Ot.morphNormals!==ie||Ot.morphColors!==Ae||Ot.toneMapping!==ce||st.isWebGL2===!0&&Ot.morphTargetsCount!==ee)&&(Qt=!0):(Qt=!0,Ot.__version=F.version);let En=Ot.currentProgram;Qt===!0&&(En=Ki(F,U,D));let Qo=!1,Ri=!1,sr=!1,pe=En.getUniforms(),An=Ot.uniforms;if(Z.useProgram(En.program)&&(Qo=!0,Ri=!0,sr=!0),F.id!==B&&(B=F.id,Ri=!0),Qo||K!==M){pe.setValue(w,"projectionMatrix",M.projectionMatrix),pe.setValue(w,"viewMatrix",M.matrixWorldInverse);let Pe=pe.map.cameraPosition;Pe!==void 0&&Pe.setValue(w,xt.setFromMatrixPosition(M.matrixWorld)),st.logarithmicDepthBuffer&&pe.setValue(w,"logDepthBufFC",2/(Math.log(M.far+1)/Math.LN2)),(F.isMeshPhongMaterial||F.isMeshToonMaterial||F.isMeshLambertMaterial||F.isMeshBasicMaterial||F.isMeshStandardMaterial||F.isShaderMaterial)&&pe.setValue(w,"isOrthographic",M.isOrthographicCamera===!0),K!==M&&(K=M,Ri=!0,sr=!0)}if(D.isSkinnedMesh){pe.setOptional(w,D,"bindMatrix"),pe.setOptional(w,D,"bindMatrixInverse");let Pe=D.skeleton;Pe&&(st.floatVertexTextures?(Pe.boneTexture===null&&Pe.computeBoneTexture(),pe.setValue(w,"boneTexture",Pe.boneTexture,vt)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}D.isBatchedMesh&&(pe.setOptional(w,D,"batchingTexture"),pe.setValue(w,"batchingTexture",D._matricesTexture,vt));let rr=O.morphAttributes;if((rr.position!==void 0||rr.normal!==void 0||rr.color!==void 0&&st.isWebGL2===!0)&&rt.update(D,O,En),(Ri||Ot.receiveShadow!==D.receiveShadow)&&(Ot.receiveShadow=D.receiveShadow,pe.setValue(w,"receiveShadow",D.receiveShadow)),F.isMeshGouraudMaterial&&F.envMap!==null&&(An.envMap.value=Ct,An.flipEnvMap.value=Ct.isCubeTexture&&Ct.isRenderTargetTexture===!1?-1:1),Ri&&(pe.setValue(w,"toneMappingExposure",x.toneMappingExposure),Ot.needsLights&&oc(An,sr),mt&&F.fog===!0&&J.refreshFogUniforms(An,mt),J.refreshMaterialUniforms(An,F,Y,V,pt),gi.upload(w,$o(Ot),An,vt)),F.isShaderMaterial&&F.uniformsNeedUpdate===!0&&(gi.upload(w,$o(Ot),An,vt),F.uniformsNeedUpdate=!1),F.isSpriteMaterial&&pe.setValue(w,"center",D.center),pe.setValue(w,"modelViewMatrix",D.modelViewMatrix),pe.setValue(w,"normalMatrix",D.normalMatrix),pe.setValue(w,"modelMatrix",D.matrixWorld),F.isShaderMaterial||F.isRawShaderMaterial){let Pe=F.uniformsGroups;for(let or=0,lc=Pe.length;or<lc;or++)if(st.isWebGL2){let jo=Pe[or];St.update(jo,En),St.bind(jo,En)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return En}function oc(M,U){M.ambientLightColor.needsUpdate=U,M.lightProbe.needsUpdate=U,M.directionalLights.needsUpdate=U,M.directionalLightShadows.needsUpdate=U,M.pointLights.needsUpdate=U,M.pointLightShadows.needsUpdate=U,M.spotLights.needsUpdate=U,M.spotLightShadows.needsUpdate=U,M.rectAreaLights.needsUpdate=U,M.hemisphereLights.needsUpdate=U}function ac(M){return M.isMeshLambertMaterial||M.isMeshToonMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isShadowMaterial||M.isShaderMaterial&&M.lights===!0}this.getActiveCubeFace=function(){return L},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(M,U,O){ft.get(M.texture).__webglTexture=U,ft.get(M.depthTexture).__webglTexture=O;let F=ft.get(M);F.__hasExternalTextures=!0,F.__autoAllocateDepthBuffer=O===void 0,F.__autoAllocateDepthBuffer||q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),F.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(M,U){let O=ft.get(M);O.__webglFramebuffer=U,O.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(M,U=0,O=0){T=M,L=U,R=O;let F=!0,D=null,mt=!1,bt=!1;if(M){let Ct=ft.get(M);Ct.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(w.FRAMEBUFFER,null),F=!1):Ct.__webglFramebuffer===void 0?vt.setupRenderTarget(M):Ct.__hasExternalTextures&&vt.rebindTextures(M,ft.get(M.texture).__webglTexture,ft.get(M.depthTexture).__webglTexture);let kt=M.texture;(kt.isData3DTexture||kt.isDataArrayTexture||kt.isCompressedArrayTexture)&&(bt=!0);let Ut=ft.get(M).__webglFramebuffer;M.isWebGLCubeRenderTarget?(Array.isArray(Ut[U])?D=Ut[U][O]:D=Ut[U],mt=!0):st.isWebGL2&&M.samples>0&&vt.useMultisampledRTT(M)===!1?D=ft.get(M).__webglMultisampledFramebuffer:Array.isArray(Ut)?D=Ut[O]:D=Ut,v.copy(M.viewport),b.copy(M.scissor),it=M.scissorTest}else v.copy(et).multiplyScalar(Y).floor(),b.copy(tt).multiplyScalar(Y).floor(),it=gt;if(Z.bindFramebuffer(w.FRAMEBUFFER,D)&&st.drawBuffers&&F&&Z.drawBuffers(M,D),Z.viewport(v),Z.scissor(b),Z.setScissorTest(it),mt){let Ct=ft.get(M.texture);w.framebufferTexture2D(w.FRAMEBUFFER,w.COLOR_ATTACHMENT0,w.TEXTURE_CUBE_MAP_POSITIVE_X+U,Ct.__webglTexture,O)}else if(bt){let Ct=ft.get(M.texture),kt=U||0;w.framebufferTextureLayer(w.FRAMEBUFFER,w.COLOR_ATTACHMENT0,Ct.__webglTexture,O||0,kt)}B=-1},this.readRenderTargetPixels=function(M,U,O,F,D,mt,bt){if(!(M&&M.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Rt=ft.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&bt!==void 0&&(Rt=Rt[bt]),Rt){Z.bindFramebuffer(w.FRAMEBUFFER,Rt);try{let Ct=M.texture,kt=Ct.format,Ut=Ct.type;if(kt!==Be&&wt.convert(kt)!==w.getParameter(w.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Nt=Ut===ki&&(q.has("EXT_color_buffer_half_float")||st.isWebGL2&&q.has("EXT_color_buffer_float"));if(Ut!==xn&&wt.convert(Ut)!==w.getParameter(w.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ut===nn&&(st.isWebGL2||q.has("OES_texture_float")||q.has("WEBGL_color_buffer_float")))&&!Nt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=M.width-F&&O>=0&&O<=M.height-D&&w.readPixels(U,O,F,D,wt.convert(kt),wt.convert(Ut),mt)}finally{let Ct=T!==null?ft.get(T).__webglFramebuffer:null;Z.bindFramebuffer(w.FRAMEBUFFER,Ct)}}},this.copyFramebufferToTexture=function(M,U,O=0){let F=Math.pow(2,-O),D=Math.floor(U.image.width*F),mt=Math.floor(U.image.height*F);vt.setTexture2D(U,0),w.copyTexSubImage2D(w.TEXTURE_2D,O,0,0,M.x,M.y,D,mt),Z.unbindTexture()},this.copyTextureToTexture=function(M,U,O,F=0){let D=U.image.width,mt=U.image.height,bt=wt.convert(O.format),Rt=wt.convert(O.type);vt.setTexture2D(O,0),w.pixelStorei(w.UNPACK_FLIP_Y_WEBGL,O.flipY),w.pixelStorei(w.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),w.pixelStorei(w.UNPACK_ALIGNMENT,O.unpackAlignment),U.isDataTexture?w.texSubImage2D(w.TEXTURE_2D,F,M.x,M.y,D,mt,bt,Rt,U.image.data):U.isCompressedTexture?w.compressedTexSubImage2D(w.TEXTURE_2D,F,M.x,M.y,U.mipmaps[0].width,U.mipmaps[0].height,bt,U.mipmaps[0].data):w.texSubImage2D(w.TEXTURE_2D,F,M.x,M.y,bt,Rt,U.image),F===0&&O.generateMipmaps&&w.generateMipmap(w.TEXTURE_2D),Z.unbindTexture()},this.copyTextureToTexture3D=function(M,U,O,F,D=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let mt=Math.round(M.max.x-M.min.x),bt=Math.round(M.max.y-M.min.y),Rt=M.max.z-M.min.z+1,Ct=wt.convert(F.format),kt=wt.convert(F.type),Ut;if(F.isData3DTexture)vt.setTexture3D(F,0),Ut=w.TEXTURE_3D;else if(F.isDataArrayTexture||F.isCompressedArrayTexture)vt.setTexture2DArray(F,0),Ut=w.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}w.pixelStorei(w.UNPACK_FLIP_Y_WEBGL,F.flipY),w.pixelStorei(w.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),w.pixelStorei(w.UNPACK_ALIGNMENT,F.unpackAlignment);let Nt=w.getParameter(w.UNPACK_ROW_LENGTH),ie=w.getParameter(w.UNPACK_IMAGE_HEIGHT),Ae=w.getParameter(w.UNPACK_SKIP_PIXELS),ce=w.getParameter(w.UNPACK_SKIP_ROWS),Ye=w.getParameter(w.UNPACK_SKIP_IMAGES),ee=O.isCompressedTexture?O.mipmaps[D]:O.image;w.pixelStorei(w.UNPACK_ROW_LENGTH,ee.width),w.pixelStorei(w.UNPACK_IMAGE_HEIGHT,ee.height),w.pixelStorei(w.UNPACK_SKIP_PIXELS,M.min.x),w.pixelStorei(w.UNPACK_SKIP_ROWS,M.min.y),w.pixelStorei(w.UNPACK_SKIP_IMAGES,M.min.z),O.isDataTexture||O.isData3DTexture?w.texSubImage3D(Ut,D,U.x,U.y,U.z,mt,bt,Rt,Ct,kt,ee.data):F.isCompressedArrayTexture?w.compressedTexSubImage3D(Ut,D,U.x,U.y,U.z,mt,bt,Rt,Ct,ee.data):w.texSubImage3D(Ut,D,U.x,U.y,U.z,mt,bt,Rt,Ct,kt,ee),w.pixelStorei(w.UNPACK_ROW_LENGTH,Nt),w.pixelStorei(w.UNPACK_IMAGE_HEIGHT,ie),w.pixelStorei(w.UNPACK_SKIP_PIXELS,Ae),w.pixelStorei(w.UNPACK_SKIP_ROWS,ce),w.pixelStorei(w.UNPACK_SKIP_IMAGES,Ye),D===0&&F.generateMipmaps&&w.generateMipmap(Ut),Z.unbindTexture()},this.initTexture=function(M){M.isCubeTexture?vt.setTextureCube(M,0):M.isData3DTexture?vt.setTexture3D(M,0):M.isDataArrayTexture||M.isCompressedArrayTexture?vt.setTexture2DArray(M,0):vt.setTexture2D(M,0),Z.unbindTexture()},this.resetState=function(){L=0,R=0,T=null,Z.reset(),Mt.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return sn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=t===Ho?"display-p3":"srgb",e.unpackColorSpace=Yt.workingColorSpace===tr?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}},vo=class extends xo{};vo.prototype.isWebGL1Renderer=!0;var Zs=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=$r,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=rn()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Vl("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let s=0,r=this.stride;s<r;s++)this.array[t+s]=e.array[n+s];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=rn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=rn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.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}}},ve=new I,Hi=class i{constructor(t,e,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)ve.fromBufferAttribute(this,e),ve.applyMatrix4(t),this.setXYZ(e,ve.x,ve.y,ve.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)ve.fromBufferAttribute(this,e),ve.applyNormalMatrix(t),this.setXYZ(e,ve.x,ve.y,ve.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)ve.fromBufferAttribute(this,e),ve.transformDirection(t),this.setXYZ(e,ve.x,ve.y,ve.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Xe(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=qt(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=qt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=qt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=qt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=qt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Xe(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Xe(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Xe(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Xe(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=qt(e,this.array),n=qt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=qt(e,this.array),n=qt(n,this.array),s=qt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=qt(e,this.array),n=qt(n,this.array),s=qt(s,this.array),r=qt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=s,this.data.array[t+3]=r,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[s+r])}return new te(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new i(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},yo=class extends Gn{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Wt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},fn,Di=new I,li=new I,ci=new I,hi=new nt,Ni=new nt,$l=new oe,ys=new I,Oi=new I,Ms=new I,bl=new nt,kr=new nt,El=new nt,Mo=class extends ke{constructor(t=new yo){if(super(),this.isSprite=!0,this.type="Sprite",fn===void 0){fn=new Ee;let e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Zs(e,5);fn.setIndex([0,1,2,0,2,3]),fn.setAttribute("position",new Hi(n,3,0,!1)),fn.setAttribute("uv",new Hi(n,2,3,!1))}this.geometry=fn,this.material=t,this.center=new nt(.5,.5)}raycast(t,e){t.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),li.setFromMatrixScale(this.matrixWorld),$l.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),ci.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&li.multiplyScalar(-ci.z);let n=this.material.rotation,s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));let a=this.center;Ss(ys.set(-.5,-.5,0),ci,a,li,s,r),Ss(Oi.set(.5,-.5,0),ci,a,li,s,r),Ss(Ms.set(.5,.5,0),ci,a,li,s,r),bl.set(0,0),kr.set(1,0),El.set(1,1);let o=t.ray.intersectTriangle(ys,Oi,Ms,!1,Di);if(o===null&&(Ss(Oi.set(-.5,.5,0),ci,a,li,s,r),kr.set(0,1),o=t.ray.intersectTriangle(ys,Ms,Oi,!1,Di),o===null))return;let l=t.ray.origin.distanceTo(Di);l<t.near||l>t.far||e.push({distance:l,point:Di.clone(),uv:On.getInterpolation(Di,ys,Oi,Ms,bl,kr,El,new nt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}};Mo.Dispose=function(){fn.dispose(),fn=void 0};function Ss(i,t,e,n,s,r){hi.subVectors(i,e).addScalar(.5).multiply(n),s!==void 0?(Ni.x=r*hi.x-s*hi.y,Ni.y=s*hi.x+r*hi.y):Ni.copy(hi),i.copy(t),i.x+=Ni.x,i.y+=Ni.y,i.applyMatrix4($l)}var Ue=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,s=this.getPoint(0),r=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),r+=n.distanceTo(s),e.push(r),s=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),s=0,r=n.length,a;e?a=e:a=t*n[r-1];let o=0,l=r-1,c;for(;o<=l;)if(s=Math.floor(o+(l-o)/2),c=n[s]-a,c<0)o=s+1;else if(c>0)l=s-1;else{l=s;break}if(s=l,n[s]===a)return s/(r-1);let h=n[s],d=n[s+1]-h,m=(a-h)/d;return(s+m)/(r-1)}getTangent(t,e){let s=t-1e-4,r=t+1e-4;s<0&&(s=0),r>1&&(r=1);let a=this.getPoint(s),o=this.getPoint(r),l=e||(a.isVector2?new nt:new I);return l.copy(o).sub(a).normalize(),l}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new I,s=[],r=[],a=[],o=new I,l=new oe;for(let m=0;m<=t;m++){let g=m/t;s[m]=this.getTangentAt(g,new I)}r[0]=new I,a[0]=new I;let c=Number.MAX_VALUE,h=Math.abs(s[0].x),u=Math.abs(s[0].y),d=Math.abs(s[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(s[0],n).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let m=1;m<=t;m++){if(r[m]=r[m-1].clone(),a[m]=a[m-1].clone(),o.crossVectors(s[m-1],s[m]),o.length()>Number.EPSILON){o.normalize();let g=Math.acos(_e(s[m-1].dot(s[m]),-1,1));r[m].applyMatrix4(l.makeRotationAxis(o,g))}a[m].crossVectors(s[m],r[m])}if(e===!0){let m=Math.acos(_e(r[0].dot(r[t]),-1,1));m/=t,s[0].dot(o.crossVectors(r[0],r[t]))>0&&(m=-m);for(let g=1;g<=t;g++)r[g].applyMatrix4(l.makeRotationAxis(s[g],m*g)),a[g].crossVectors(s[g],r[g])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},Wi=class extends Ue{constructor(t=0,e=0,n=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(t,e=new nt){let n=e,s=Math.PI*2,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=s;for(;r>s;)r-=s;r<Number.EPSILON&&(a?r=0:r=s),this.aClockwise===!0&&!a&&(r===s?r=-s:r=r-s);let o=this.aStartAngle+t*r,l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,m=c-this.aY;l=d*h-m*u+this.aX,c=d*u+m*h+this.aY}return n.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},So=class extends Wi{constructor(t,e,n,s,r,a){super(t,e,n,n,s,r,a),this.isArcCurve=!0,this.type="ArcCurve"}};function Xo(){let i=0,t=0,e=0,n=0;function s(r,a,o,l){i=r,t=o,e=-3*r+3*a-2*o-l,n=2*r-2*a+o+l}return{initCatmullRom:function(r,a,o,l,c){s(a,o,c*(o-r),c*(l-a))},initNonuniformCatmullRom:function(r,a,o,l,c,h,u){let d=(a-r)/c-(o-r)/(c+h)+(o-a)/h,m=(o-a)/h-(l-a)/(h+u)+(l-o)/u;d*=h,m*=h,s(a,o,d,m)},calc:function(r){let a=r*r,o=a*r;return i+t*r+e*a+n*o}}}var bs=new I,Vr=new Xo,Gr=new Xo,Hr=new Xo,bo=class extends Ue{constructor(t=[],e=!1,n="centripetal",s=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=s}getPoint(t,e=new I){let n=e,s=this.points,r=s.length,a=(r-(this.closed?0:1))*t,o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,h;this.closed||o>0?c=s[(o-1)%r]:(bs.subVectors(s[0],s[1]).add(s[0]),c=bs);let u=s[o%r],d=s[(o+1)%r];if(this.closed||o+2<r?h=s[(o+2)%r]:(bs.subVectors(s[r-1],s[r-2]).add(s[r-1]),h=bs),this.curveType==="centripetal"||this.curveType==="chordal"){let m=this.curveType==="chordal"?.5:.25,g=Math.pow(c.distanceToSquared(u),m),y=Math.pow(u.distanceToSquared(d),m),f=Math.pow(d.distanceToSquared(h),m);y<1e-4&&(y=1),g<1e-4&&(g=y),f<1e-4&&(f=y),Vr.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,g,y,f),Gr.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,g,y,f),Hr.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,g,y,f)}else this.curveType==="catmullrom"&&(Vr.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),Gr.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Hr.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(Vr.calc(l),Gr.calc(l),Hr.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let s=t.points[e];this.points.push(s.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let s=this.points[e];t.points.push(s.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let s=t.points[e];this.points.push(new I().fromArray(s))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function Al(i,t,e,n,s){let r=(n-t)*.5,a=(s-e)*.5,o=i*i,l=i*o;return(2*e-2*n+r+a)*l+(-3*e+3*n-2*r-a)*o+r*i+e}function lm(i,t){let e=1-i;return e*e*t}function cm(i,t){return 2*(1-i)*i*t}function hm(i,t){return i*i*t}function Bi(i,t,e,n){return lm(i,t)+cm(i,e)+hm(i,n)}function um(i,t){let e=1-i;return e*e*e*t}function dm(i,t){let e=1-i;return 3*e*e*i*t}function fm(i,t){return 3*(1-i)*i*i*t}function pm(i,t){return i*i*i*t}function zi(i,t,e,n,s){return um(i,t)+dm(i,e)+fm(i,n)+pm(i,s)}var Js=class extends Ue{constructor(t=new nt,e=new nt,n=new nt,s=new nt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=s}getPoint(t,e=new nt){let n=e,s=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(zi(t,s.x,r.x,a.x,o.x),zi(t,s.y,r.y,a.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Eo=class extends Ue{constructor(t=new I,e=new I,n=new I,s=new I){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=s}getPoint(t,e=new I){let n=e,s=this.v0,r=this.v1,a=this.v2,o=this.v3;return n.set(zi(t,s.x,r.x,a.x,o.x),zi(t,s.y,r.y,a.y,o.y),zi(t,s.z,r.z,a.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},$s=class extends Ue{constructor(t=new nt,e=new nt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new nt){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new nt){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Ao=class extends Ue{constructor(t=new I,e=new I){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new I){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new I){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Ks=class extends Ue{constructor(t=new nt,e=new nt,n=new nt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new nt){let n=e,s=this.v0,r=this.v1,a=this.v2;return n.set(Bi(t,s.x,r.x,a.x),Bi(t,s.y,r.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},wo=class extends Ue{constructor(t=new I,e=new I,n=new I){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new I){let n=e,s=this.v0,r=this.v1,a=this.v2;return n.set(Bi(t,s.x,r.x,a.x),Bi(t,s.y,r.y,a.y),Bi(t,s.z,r.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Qs=class extends Ue{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new nt){let n=e,s=this.points,r=(s.length-1)*t,a=Math.floor(r),o=r-a,l=s[a===0?a:a-1],c=s[a],h=s[a>s.length-2?s.length-1:a+1],u=s[a>s.length-3?s.length-1:a+2];return n.set(Al(o,l.x,c.x,h.x,u.x),Al(o,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let s=t.points[e];this.points.push(s.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let s=this.points[e];t.points.push(s.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let s=t.points[e];this.points.push(new nt().fromArray(s))}return this}},To=Object.freeze({__proto__:null,ArcCurve:So,CatmullRomCurve3:bo,CubicBezierCurve:Js,CubicBezierCurve3:Eo,EllipseCurve:Wi,LineCurve:$s,LineCurve3:Ao,QuadraticBezierCurve:Ks,QuadraticBezierCurve3:wo,SplineCurve:Qs}),Ro=class extends Ue{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){let n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new To[n](e,t))}return this}getPoint(t,e){let n=t*this.getLength(),s=this.getCurveLengths(),r=0;for(;r<s.length;){if(s[r]>=n){let a=s[r]-n,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,e)}r++}return null}getLength(){let t=this.getCurveLengths();return t[t.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 t=[],e=0;for(let n=0,s=this.curves.length;n<s;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let s=0,r=this.curves;s<r.length;s++){let a=r[s],o=a.isEllipseCurve?t*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?t*a.points.length:t,l=a.getPoints(o);for(let c=0;c<l.length;c++){let h=l[c];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let s=t.curves[e];this.curves.push(s.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let s=this.curves[e];t.curves.push(s.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let s=t.curves[e];this.curves.push(new To[s.type]().fromJSON(s))}return this}},Mi=class extends Ro{constructor(t){super(),this.type="Path",this.currentPoint=new nt,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new $s(this.currentPoint.clone(),new nt(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,s){let r=new Ks(this.currentPoint.clone(),new nt(t,e),new nt(n,s));return this.curves.push(r),this.currentPoint.set(n,s),this}bezierCurveTo(t,e,n,s,r,a){let o=new Js(this.currentPoint.clone(),new nt(t,e),new nt(n,s),new nt(r,a));return this.curves.push(o),this.currentPoint.set(r,a),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new Qs(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,s,r,a){let o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+o,e+l,n,s,r,a),this}absarc(t,e,n,s,r,a){return this.absellipse(t,e,n,n,s,r,a),this}ellipse(t,e,n,s,r,a,o,l){let c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,n,s,r,a,o,l),this}absellipse(t,e,n,s,r,a,o,l){let c=new Wi(t,e,n,s,r,a,o,l);if(this.curves.length>0){let u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);let h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}};var Si=class extends Mi{constructor(t){super(t),this.uuid=rn(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,s=this.holes.length;n<s;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let s=t.holes[e];this.holes.push(s.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let s=this.holes[e];t.holes.push(s.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let s=t.holes[e];this.holes.push(new Mi().fromJSON(s))}return this}},mm={triangulate:function(i,t,e=2){let n=t&&t.length,s=n?t[0]*e:i.length,r=Kl(i,0,s,e,!0),a=[];if(!r||r.next===r.prev)return a;let o,l,c,h,u,d,m;if(n&&(r=ym(i,t,r,e)),i.length>80*e){o=c=i[0],l=h=i[1];for(let g=e;g<s;g+=e)u=i[g],d=i[g+1],u<o&&(o=u),d<l&&(l=d),u>c&&(c=u),d>h&&(h=d);m=Math.max(c-o,h-l),m=m!==0?32767/m:0}return Xi(r,a,e,o,l,m,0),a}};function Kl(i,t,e,n,s){let r,a;if(s===Im(i,t,e,n)>0)for(r=t;r<e;r+=n)a=wl(r,i[r],i[r+1],a);else for(r=e-n;r>=t;r-=n)a=wl(r,i[r],i[r+1],a);return a&&nr(a,a.next)&&(Yi(a),a=a.next),a}function Hn(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(nr(e,e.next)||ne(e.prev,e,e.next)===0)){if(Yi(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Xi(i,t,e,n,s,r,a){if(!i)return;!a&&r&&Am(i,n,s,r);let o=i,l,c;for(;i.prev!==i.next;){if(l=i.prev,c=i.next,r?_m(i,n,s,r):gm(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(c.i/e|0),Yi(i),i=c.next,o=c.next;continue}if(i=c,i===o){a?a===1?(i=xm(Hn(i),t,e),Xi(i,t,e,n,s,r,2)):a===2&&vm(i,t,e,n,s,r):Xi(Hn(i),t,e,n,s,r,1);break}}}function gm(i){let t=i.prev,e=i,n=i.next;if(ne(t,e,n)>=0)return!1;let s=t.x,r=e.x,a=n.x,o=t.y,l=e.y,c=n.y,h=s<r?s<a?s:a:r<a?r:a,u=o<l?o<c?o:c:l<c?l:c,d=s>r?s>a?s:a:r>a?r:a,m=o>l?o>c?o:c:l>c?l:c,g=n.next;for(;g!==t;){if(g.x>=h&&g.x<=d&&g.y>=u&&g.y<=m&&fi(s,o,r,l,a,c,g.x,g.y)&&ne(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function _m(i,t,e,n){let s=i.prev,r=i,a=i.next;if(ne(s,r,a)>=0)return!1;let o=s.x,l=r.x,c=a.x,h=s.y,u=r.y,d=a.y,m=o<l?o<c?o:c:l<c?l:c,g=h<u?h<d?h:d:u<d?u:d,y=o>l?o>c?o:c:l>c?l:c,f=h>u?h>d?h:d:u>d?u:d,p=Co(m,g,t,e,n),E=Co(y,f,t,e,n),x=i.prevZ,A=i.nextZ;for(;x&&x.z>=p&&A&&A.z<=E;){if(x.x>=m&&x.x<=y&&x.y>=g&&x.y<=f&&x!==s&&x!==a&&fi(o,h,l,u,c,d,x.x,x.y)&&ne(x.prev,x,x.next)>=0||(x=x.prevZ,A.x>=m&&A.x<=y&&A.y>=g&&A.y<=f&&A!==s&&A!==a&&fi(o,h,l,u,c,d,A.x,A.y)&&ne(A.prev,A,A.next)>=0))return!1;A=A.nextZ}for(;x&&x.z>=p;){if(x.x>=m&&x.x<=y&&x.y>=g&&x.y<=f&&x!==s&&x!==a&&fi(o,h,l,u,c,d,x.x,x.y)&&ne(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;A&&A.z<=E;){if(A.x>=m&&A.x<=y&&A.y>=g&&A.y<=f&&A!==s&&A!==a&&fi(o,h,l,u,c,d,A.x,A.y)&&ne(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function xm(i,t,e){let n=i;do{let s=n.prev,r=n.next.next;!nr(s,r)&&Ql(s,n,n.next,r)&&qi(s,r)&&qi(r,s)&&(t.push(s.i/e|0),t.push(n.i/e|0),t.push(r.i/e|0),Yi(n),Yi(n.next),n=i=r),n=n.next}while(n!==i);return Hn(n)}function vm(i,t,e,n,s,r){let a=i;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Rm(a,o)){let l=jl(a,o);a=Hn(a,a.next),l=Hn(l,l.next),Xi(a,t,e,n,s,r,0),Xi(l,t,e,n,s,r,0);return}o=o.next}a=a.next}while(a!==i)}function ym(i,t,e,n){let s=[],r,a,o,l,c;for(r=0,a=t.length;r<a;r++)o=t[r]*n,l=r<a-1?t[r+1]*n:i.length,c=Kl(i,o,l,n,!1),c===c.next&&(c.steiner=!0),s.push(Tm(c));for(s.sort(Mm),r=0;r<s.length;r++)e=Sm(s[r],e);return e}function Mm(i,t){return i.x-t.x}function Sm(i,t){let e=bm(i,t);if(!e)return t;let n=jl(e,i);return Hn(n,n.next),Hn(e,e.next)}function bm(i,t){let e=t,n=-1/0,s,r=i.x,a=i.y;do{if(a<=e.y&&a>=e.next.y&&e.next.y!==e.y){let d=e.x+(a-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=r&&d>n&&(n=d,s=e.x<e.next.x?e:e.next,d===r))return s}e=e.next}while(e!==t);if(!s)return null;let o=s,l=s.x,c=s.y,h=1/0,u;e=s;do r>=e.x&&e.x>=l&&r!==e.x&&fi(a<c?r:n,a,l,c,a<c?n:r,a,e.x,e.y)&&(u=Math.abs(a-e.y)/(r-e.x),qi(e,i)&&(u<h||u===h&&(e.x>s.x||e.x===s.x&&Em(s,e)))&&(s=e,h=u)),e=e.next;while(e!==o);return s}function Em(i,t){return ne(i.prev,i,t.prev)<0&&ne(t.next,i,i.next)<0}function Am(i,t,e,n){let s=i;do s.z===0&&(s.z=Co(s.x,s.y,t,e,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i);s.prevZ.nextZ=null,s.prevZ=null,wm(s)}function wm(i){let t,e,n,s,r,a,o,l,c=1;do{for(e=i,i=null,r=null,a=0;e;){for(a++,n=e,o=0,t=0;t<c&&(o++,n=n.nextZ,!!n);t++);for(l=c;o>0||l>0&&n;)o!==0&&(l===0||!n||e.z<=n.z)?(s=e,e=e.nextZ,o--):(s=n,n=n.nextZ,l--),r?r.nextZ=s:i=s,s.prevZ=r,r=s;e=n}r.nextZ=null,c*=2}while(a>1);return i}function Co(i,t,e,n,s){return i=(i-e)*s|0,t=(t-n)*s|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function Tm(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function fi(i,t,e,n,s,r,a,o){return(s-a)*(t-o)>=(i-a)*(r-o)&&(i-a)*(n-o)>=(e-a)*(t-o)&&(e-a)*(r-o)>=(s-a)*(n-o)}function Rm(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!Cm(i,t)&&(qi(i,t)&&qi(t,i)&&Pm(i,t)&&(ne(i.prev,i,t.prev)||ne(i,t.prev,t))||nr(i,t)&&ne(i.prev,i,i.next)>0&&ne(t.prev,t,t.next)>0)}function ne(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function nr(i,t){return i.x===t.x&&i.y===t.y}function Ql(i,t,e,n){let s=As(ne(i,t,e)),r=As(ne(i,t,n)),a=As(ne(e,n,i)),o=As(ne(e,n,t));return!!(s!==r&&a!==o||s===0&&Es(i,e,t)||r===0&&Es(i,n,t)||a===0&&Es(e,i,n)||o===0&&Es(e,t,n))}function Es(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function As(i){return i>0?1:i<0?-1:0}function Cm(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&Ql(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function qi(i,t){return ne(i.prev,i,i.next)<0?ne(i,t,i.next)>=0&&ne(i,i.prev,t)>=0:ne(i,t,i.prev)<0||ne(i,i.next,t)<0}function Pm(i,t){let e=i,n=!1,s=(i.x+t.x)/2,r=(i.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&s<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function jl(i,t){let e=new Po(i.i,i.x,i.y),n=new Po(t.i,t.x,t.y),s=i.next,r=t.prev;return i.next=t,t.prev=i,e.next=s,s.prev=e,n.next=e,e.prev=n,r.next=n,n.prev=r,n}function wl(i,t,e,n){let s=new Po(i,t,e);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function Yi(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Po(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Im(i,t,e,n){let s=0;for(let r=t,a=e-n;r<e;r+=n)s+=(i[a]-i[r])*(i[r+1]+i[a+1]),a=r;return s}var vn=class i{static area(t){let e=t.length,n=0;for(let s=e-1,r=0;r<e;s=r++)n+=t[s].x*t[r].y-t[r].x*t[s].y;return n*.5}static isClockWise(t){return i.area(t)<0}static triangulateShape(t,e){let n=[],s=[],r=[];Tl(t),Rl(n,t);let a=t.length;e.forEach(Tl);for(let l=0;l<e.length;l++)s.push(a),a+=e[l].length,Rl(n,e[l]);let o=mm.triangulate(n,s);for(let l=0;l<o.length;l+=3)r.push(o.slice(l,l+3));return r}};function Tl(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function Rl(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var bi=class i extends Ee{constructor(t=new Si([new nt(.5,.5),new nt(-.5,.5),new nt(-.5,-.5),new nt(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];let n=this,s=[],r=[];for(let o=0,l=t.length;o<l;o++){let c=t[o];a(c)}this.setAttribute("position",new fe(s,3)),this.setAttribute("uv",new fe(r,2)),this.computeVertexNormals();function a(o){let l=[],c=e.curveSegments!==void 0?e.curveSegments:12,h=e.steps!==void 0?e.steps:1,u=e.depth!==void 0?e.depth:1,d=e.bevelEnabled!==void 0?e.bevelEnabled:!0,m=e.bevelThickness!==void 0?e.bevelThickness:.2,g=e.bevelSize!==void 0?e.bevelSize:m-.1,y=e.bevelOffset!==void 0?e.bevelOffset:0,f=e.bevelSegments!==void 0?e.bevelSegments:3,p=e.extrudePath,E=e.UVGenerator!==void 0?e.UVGenerator:Lm,x,A=!1,L,R,T,B;p&&(x=p.getSpacedPoints(h),A=!0,d=!1,L=p.computeFrenetFrames(h,!1),R=new I,T=new I,B=new I),d||(f=0,m=0,g=0,y=0);let K=o.extractPoints(c),v=K.shape,b=K.holes;if(!vn.isClockWise(v)){v=v.reverse();for(let w=0,ot=b.length;w<ot;w++){let q=b[w];vn.isClockWise(q)&&(b[w]=q.reverse())}}let $=vn.triangulateShape(v,b),C=v;for(let w=0,ot=b.length;w<ot;w++){let q=b[w];v=v.concat(q)}function H(w,ot,q){return ot||console.error("THREE.ExtrudeGeometry: vec does not exist"),w.clone().addScaledVector(ot,q)}let V=v.length,Y=$.length;function W(w,ot,q){let st,Z,_t,ft=w.x-ot.x,vt=w.y-ot.y,Vt=q.x-w.x,S=q.y-w.y,_=ft*ft+vt*vt,k=ft*S-vt*Vt;if(Math.abs(k)>Number.EPSILON){let G=Math.sqrt(_),j=Math.sqrt(Vt*Vt+S*S),J=ot.x-vt/G,It=ot.y+ft/G,Tt=q.x-S/j,lt=q.y+Vt/j,ht=((Tt-J)*S-(lt-It)*Vt)/(ft*S-vt*Vt);st=J+ft*ht-w.x,Z=It+vt*ht-w.y;let Lt=st*st+Z*Z;if(Lt<=2)return new nt(st,Z);_t=Math.sqrt(Lt/2)}else{let G=!1;ft>Number.EPSILON?Vt>Number.EPSILON&&(G=!0):ft<-Number.EPSILON?Vt<-Number.EPSILON&&(G=!0):Math.sign(vt)===Math.sign(S)&&(G=!0),G?(st=-vt,Z=ft,_t=Math.sqrt(_)):(st=ft,Z=vt,_t=Math.sqrt(_/2))}return new nt(st/_t,Z/_t)}let X=[];for(let w=0,ot=C.length,q=ot-1,st=w+1;w<ot;w++,q++,st++)q===ot&&(q=0),st===ot&&(st=0),X[w]=W(C[w],C[q],C[st]);let et=[],tt,gt=X.concat();for(let w=0,ot=b.length;w<ot;w++){let q=b[w];tt=[];for(let st=0,Z=q.length,_t=Z-1,ft=st+1;st<Z;st++,_t++,ft++)_t===Z&&(_t=0),ft===Z&&(ft=0),tt[st]=W(q[st],q[_t],q[ft]);et.push(tt),gt=gt.concat(tt)}for(let w=0;w<f;w++){let ot=w/f,q=m*Math.cos(ot*Math.PI/2),st=g*Math.sin(ot*Math.PI/2)+y;for(let Z=0,_t=C.length;Z<_t;Z++){let ft=H(C[Z],X[Z],st);Et(ft.x,ft.y,-q)}for(let Z=0,_t=b.length;Z<_t;Z++){let ft=b[Z];tt=et[Z];for(let vt=0,Vt=ft.length;vt<Vt;vt++){let S=H(ft[vt],tt[vt],st);Et(S.x,S.y,-q)}}}let Pt=g+y;for(let w=0;w<V;w++){let ot=d?H(v[w],gt[w],Pt):v[w];A?(T.copy(L.normals[0]).multiplyScalar(ot.x),R.copy(L.binormals[0]).multiplyScalar(ot.y),B.copy(x[0]).add(T).add(R),Et(B.x,B.y,B.z)):Et(ot.x,ot.y,0)}for(let w=1;w<=h;w++)for(let ot=0;ot<V;ot++){let q=d?H(v[ot],gt[ot],Pt):v[ot];A?(T.copy(L.normals[w]).multiplyScalar(q.x),R.copy(L.binormals[w]).multiplyScalar(q.y),B.copy(x[w]).add(T).add(R),Et(B.x,B.y,B.z)):Et(q.x,q.y,u/h*w)}for(let w=f-1;w>=0;w--){let ot=w/f,q=m*Math.cos(ot*Math.PI/2),st=g*Math.sin(ot*Math.PI/2)+y;for(let Z=0,_t=C.length;Z<_t;Z++){let ft=H(C[Z],X[Z],st);Et(ft.x,ft.y,u+q)}for(let Z=0,_t=b.length;Z<_t;Z++){let ft=b[Z];tt=et[Z];for(let vt=0,Vt=ft.length;vt<Vt;vt++){let S=H(ft[vt],tt[vt],st);A?Et(S.x,S.y+x[h-1].y,x[h-1].x+q):Et(S.x,S.y,u+q)}}}z(),Q();function z(){let w=s.length/3;if(d){let ot=0,q=V*ot;for(let st=0;st<Y;st++){let Z=$[st];yt(Z[2]+q,Z[1]+q,Z[0]+q)}ot=h+f*2,q=V*ot;for(let st=0;st<Y;st++){let Z=$[st];yt(Z[0]+q,Z[1]+q,Z[2]+q)}}else{for(let ot=0;ot<Y;ot++){let q=$[ot];yt(q[2],q[1],q[0])}for(let ot=0;ot<Y;ot++){let q=$[ot];yt(q[0]+V*h,q[1]+V*h,q[2]+V*h)}}n.addGroup(w,s.length/3-w,0)}function Q(){let w=s.length/3,ot=0;pt(C,ot),ot+=C.length;for(let q=0,st=b.length;q<st;q++){let Z=b[q];pt(Z,ot),ot+=Z.length}n.addGroup(w,s.length/3-w,1)}function pt(w,ot){let q=w.length;for(;--q>=0;){let st=q,Z=q-1;Z<0&&(Z=w.length-1);for(let _t=0,ft=h+f*2;_t<ft;_t++){let vt=V*_t,Vt=V*(_t+1),S=ot+st+vt,_=ot+Z+vt,k=ot+Z+Vt,G=ot+st+Vt;xt(S,_,k,G)}}}function Et(w,ot,q){l.push(w),l.push(ot),l.push(q)}function yt(w,ot,q){zt(w),zt(ot),zt(q);let st=s.length/3,Z=E.generateTopUV(n,s,st-3,st-2,st-1);At(Z[0]),At(Z[1]),At(Z[2])}function xt(w,ot,q,st){zt(w),zt(ot),zt(st),zt(ot),zt(q),zt(st);let Z=s.length/3,_t=E.generateSideWallUV(n,s,Z-6,Z-3,Z-2,Z-1);At(_t[0]),At(_t[1]),At(_t[3]),At(_t[1]),At(_t[2]),At(_t[3])}function zt(w){s.push(l[w*3+0]),s.push(l[w*3+1]),s.push(l[w*3+2])}function At(w){r.push(w.x),r.push(w.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON(),e=this.parameters.shapes,n=this.parameters.options;return Um(e,n,t)}static fromJSON(t,e){let n=[];for(let r=0,a=t.shapes.length;r<a;r++){let o=e[t.shapes[r]];n.push(o)}let s=t.options.extrudePath;return s!==void 0&&(t.options.extrudePath=new To[s.type]().fromJSON(s)),new i(n,t.options)}},Lm={generateTopUV:function(i,t,e,n,s){let r=t[e*3],a=t[e*3+1],o=t[n*3],l=t[n*3+1],c=t[s*3],h=t[s*3+1];return[new nt(r,a),new nt(o,l),new nt(c,h)]},generateSideWallUV:function(i,t,e,n,s,r){let a=t[e*3],o=t[e*3+1],l=t[e*3+2],c=t[n*3],h=t[n*3+1],u=t[n*3+2],d=t[s*3],m=t[s*3+1],g=t[s*3+2],y=t[r*3],f=t[r*3+1],p=t[r*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new nt(a,1-l),new nt(c,1-u),new nt(d,1-g),new nt(y,1-p)]:[new nt(o,1-l),new nt(h,1-u),new nt(m,1-g),new nt(f,1-p)]}};function Um(i,t,e){if(e.shapes=[],Array.isArray(i))for(let n=0,s=i.length;n<s;n++){let r=i[n];e.shapes.push(r.uuid)}else e.shapes.push(i.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}var Zi=class i extends Ee{constructor(t=new Si([new nt(0,.5),new nt(-.5,-.5),new nt(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};let n=[],s=[],r=[],a=[],o=0,l=0;if(Array.isArray(t)===!1)c(t);else for(let h=0;h<t.length;h++)c(t[h]),this.addGroup(o,l,h),o+=l,l=0;this.setIndex(n),this.setAttribute("position",new fe(s,3)),this.setAttribute("normal",new fe(r,3)),this.setAttribute("uv",new fe(a,2));function c(h){let u=s.length/3,d=h.extractPoints(e),m=d.shape,g=d.holes;vn.isClockWise(m)===!1&&(m=m.reverse());for(let f=0,p=g.length;f<p;f++){let E=g[f];vn.isClockWise(E)===!0&&(g[f]=E.reverse())}let y=vn.triangulateShape(m,g);for(let f=0,p=g.length;f<p;f++){let E=g[f];m=m.concat(E)}for(let f=0,p=m.length;f<p;f++){let E=m[f];s.push(E.x,E.y,0),r.push(0,0,1),a.push(E.x,E.y)}for(let f=0,p=y.length;f<p;f++){let E=y[f],x=E[0]+u,A=E[1]+u,L=E[2]+u;n.push(x,A,L),l+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON(),e=this.parameters.shapes;return Dm(e,t)}static fromJSON(t,e){let n=[];for(let s=0,r=t.shapes.length;s<r;s++){let a=e[t.shapes[s]];n.push(a)}return new i(n,t.curveSegments)}};function Dm(i,t){if(t.shapes=[],Array.isArray(i))for(let e=0,n=i.length;e<n;e++){let s=i[e];t.shapes.push(s.uuid)}else t.shapes.push(i.uuid);return t}function ws(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function Nm(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}var Ei=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t<s)){for(let o=n+2;;){if(s===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=e[++n],t<s)break t}a=e.length;break e}if(!(t>=r)){let o=e[1];t<o&&(n=2,r=o);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(s=r,r=e[--n-1],t>=r)break t}a=n,n=0;break e}break n}for(;n<a;){let o=n+a>>>1;t<e[o]?a=o:n=o+1}if(s=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,t,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=t*s;for(let a=0;a!==s;++a)e[a]=n[r+a];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Io=class extends Ei{constructor(t,e,n,s){super(t,e,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:La,endingEnd:La}}intervalChanged_(t,e,n){let s=this.parameterPositions,r=t-2,a=t+1,o=s[r],l=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case Ua:r=t,o=2*e-n;break;case Da:r=s.length-2,o=e+s[r]-s[r+1];break;default:r=t,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Ua:a=t,l=2*n-e;break;case Da:a=1,l=n+s[1]-s[0];break;default:a=t-1,l=e}let c=(n-e)*.5,h=this.valueSize;this._weightPrev=c/(e-o),this._weightNext=c/(l-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=t*o,c=l-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,m=this._weightNext,g=(n-e)/(s-e),y=g*g,f=y*g,p=-d*f+2*d*y-d*g,E=(1+d)*f+(-1.5-2*d)*y+(-.5+d)*g+1,x=(-1-m)*f+(1.5+m)*y+.5*g,A=m*f-m*y;for(let L=0;L!==o;++L)r[L]=p*a[h+L]+E*a[c+L]+x*a[l+L]+A*a[u+L];return r}},Lo=class extends Ei{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=t*o,c=l-o,h=(n-e)/(s-e),u=1-h;for(let d=0;d!==o;++d)r[d]=a[c+d]*u+a[l+d]*h;return r}},Uo=class extends Ei{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t){return this.copySampleValue_(t-1)}},Ve=class{constructor(t,e,n,s){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ws(e,this.TimeBufferType),this.values=ws(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:ws(t.times,Array),values:ws(t.values,Array)};let s=t.getInterpolation();s!==t.DefaultInterpolation&&(n.interpolation=s)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Uo(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Lo(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Io(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Rs:e=this.InterpolantFactoryMethodDiscrete;break;case Cs:e=this.InterpolantFactoryMethodLinear;break;case fr:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Rs;case this.InterpolantFactoryMethodLinear:return Cs;case this.InterpolantFactoryMethodSmooth:return fr}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]*=t}return this}trim(t,e){let n=this.times,s=n.length,r=0,a=s-1;for(;r!==s&&n[r]<t;)++r;for(;a!==-1&&n[a]>e;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){let l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),t=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),t=!1;break}a=l}if(s!==void 0&&Nm(s))for(let o=0,l=s.length;o!==l;++o){let c=s[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===fr,r=t.length-1,a=1;for(let o=1;o<r;++o){let l=!1,c=t[o],h=t[o+1];if(c!==h&&(o!==1||c!==t[0]))if(s)l=!0;else{let u=o*n,d=u-n,m=u+n;for(let g=0;g!==n;++g){let y=e[u+g];if(y!==e[d+g]||y!==e[m+g]){l=!0;break}}}if(l){if(o!==a){t[a]=t[o];let u=o*n,d=a*n;for(let m=0;m!==n;++m)e[d+m]=e[u+m]}++a}}if(r>0){t[a]=t[r];for(let o=r*n,l=a*n,c=0;c!==n;++c)e[l+c]=e[o+c];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}};Ve.prototype.TimeBufferType=Float32Array;Ve.prototype.ValueBufferType=Float32Array;Ve.prototype.DefaultInterpolation=Cs;var Wn=class extends Ve{};Wn.prototype.ValueTypeName="bool";Wn.prototype.ValueBufferType=Array;Wn.prototype.DefaultInterpolation=Rs;Wn.prototype.InterpolantFactoryMethodLinear=void 0;Wn.prototype.InterpolantFactoryMethodSmooth=void 0;var Do=class extends Ve{};Do.prototype.ValueTypeName="color";var No=class extends Ve{};No.prototype.ValueTypeName="number";var Oo=class extends Ei{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-e)/(s-e),c=t*o;for(let h=c+o;c!==h;c+=4)Sn.slerpFlat(r,0,a,c-o,a,c,l);return r}},Ji=class extends Ve{InterpolantFactoryMethodLinear(t){return new Oo(this.times,this.values,this.getValueSize(),t)}};Ji.prototype.ValueTypeName="quaternion";Ji.prototype.DefaultInterpolation=Cs;Ji.prototype.InterpolantFactoryMethodSmooth=void 0;var Xn=class extends Ve{};Xn.prototype.ValueTypeName="string";Xn.prototype.ValueBufferType=Array;Xn.prototype.DefaultInterpolation=Rs;Xn.prototype.InterpolantFactoryMethodLinear=void 0;Xn.prototype.InterpolantFactoryMethodSmooth=void 0;var Fo=class extends Ve{};Fo.prototype.ValueTypeName="vector";var Bo=class{constructor(t,e,n){let s=this,r=!1,a=0,o=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){let u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){let m=c[u],g=c[u+1];if(m.global&&(m.lastIndex=0),m.test(h))return g}return null}}},Om=new Bo,zo=class{constructor(t){this.manager=t!==void 0?t:Om,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(s,r){n.load(t,s,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};zo.DEFAULT_MATERIAL_NAME="__DEFAULT";var qo="\\\\[\\\\]\\\\.:\\\\/",Fm=new RegExp("["+qo+"]","g"),Yo="[^"+qo+"]",Bm="[^"+qo.replace("\\\\.","")+"]",zm=/((?:WC+[\\/:])*)/.source.replace("WC",Yo),km=/(WCOD+)?/.source.replace("WCOD",Bm),Vm=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",Yo),Gm=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",Yo),Hm=new RegExp("^"+zm+km+Vm+Gm+"$"),Wm=["material","materials","bones","map"],ko=class{constructor(t,e,n){let s=n||jt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,s)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},jt=class i{constructor(t,e,n){this.path=e,this.parsedPath=n||i.parseTrackName(e),this.node=i.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new i.Composite(t,e,n):new i(t,e,n)}static sanitizeNodeName(t){return t.replace(/\\s/g,"_").replace(Fm,"")}static parseTrackName(t){let e=Hm.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);Wm.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let a=0;a<r.length;a++){let o=r[a];if(o.name===e||o.uuid===e)return o;let l=n(o.children);if(l)return l}return null},s=n(t.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)t[e++]=n[s]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,s=e.propertyName,r=e.propertyIndex;if(t||(t=i.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===c){c=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(c!==void 0){if(t[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}let a=t[s];if(a===void 0){let c=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+s+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};jt.Composite=ko;jt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};jt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};jt.prototype.GetterByBindingType=[jt.prototype._getValue_direct,jt.prototype._getValue_array,jt.prototype._getValue_arrayElement,jt.prototype._getValue_toArray];jt.prototype.SetterByBindingTypeAndVersioning=[[jt.prototype._setValue_direct,jt.prototype._setValue_direct_setNeedsUpdate,jt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[jt.prototype._setValue_array,jt.prototype._setValue_array_setNeedsUpdate,jt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[jt.prototype._setValue_arrayElement,jt.prototype._setValue_arrayElement_setNeedsUpdate,jt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[jt.prototype._setValue_fromArray,jt.prototype._setValue_fromArray_setNeedsUpdate,jt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var $m=new Float32Array(1);typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Vo}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Vo);function wi(i,t=[]){let e=new Si(i.map(n=>new nt(...n)));return t.length&&t.forEach(n=>{var s=new Mi(n.map(r=>new nt(...r)));e.holes.push(s)}),e}function tc(i){return i.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function ec(i){let t={};for(let n in i)n.startsWith("on")&&(t[tc(n.slice(2))]=i[n]);let e=s=>Qi(this,[s],function*({data:n}){if(t[n.type])try{let r=yield t[n.type](n.data);if(r!=null&&r.$transfer&&Array.isArray(r.$transfer)){let a=r.$transfer;delete r.$transfer,self.postMessage({type:\`\${n.type}_result\`,key:n.key,data:r},a)}else self.postMessage({type:\`\${n.type}_result\`,key:n.key,data:r})}catch(r){self.postMessage({type:\`\${n.type}_result\`,key:n.key,error:r})}else self.postMessage({type:\`\${n.type}_result\`,key:n.key,error:"no_event"})});return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}}function Ti(i,t=!1){let e=i[0].index!==null,n=new Set(Object.keys(i[0].attributes)),s=new Set(Object.keys(i[0].morphAttributes)),r={},a={},o=i[0].morphTargetsRelative,l=new Ee,c=0;for(let h=0;h<i.length;++h){let u=i[h],d=0;if(e!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let m in u.attributes){if(!n.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;r[m]===void 0&&(r[m]=[]),r[m].push(u.attributes[m]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let m in u.morphAttributes){if(!s.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[m]===void 0&&(a[m]=[]),a[m].push(u.morphAttributes[m])}if(t){let m;if(e)m=u.index.count;else if(u.attributes.position!==void 0)m=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,m,h),c+=m}}if(e){let h=0,u=[];for(let d=0;d<i.length;++d){let m=i[d].index;for(let g=0;g<m.count;++g)u.push(m.getX(g)+h);h+=i[d].attributes.position.count}l.setIndex(u)}for(let h in r){let u=nc(r[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(let h in a){let u=a[h][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let d=0;d<u;++d){let m=[];for(let y=0;y<a[h].length;++y)m.push(a[h][y][d]);let g=nc(m);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(g)}}return l}function nc(i){let t,e,n,s=-1,r=0;for(let c=0;c<i.length;++c){let h=i[c];if(t===void 0&&(t=h.array.constructor),t!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=h.itemSize),e!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(s===-1&&(s=h.gpuType),s!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=h.count*e}let a=new t(r),o=new te(a,e,n),l=0;for(let c=0;c<i.length;++c){let h=i[c];if(h.isInterleavedBufferAttribute){let u=l/e;for(let d=0,m=h.count;d<m;d++)for(let g=0;g<e;g++){let y=h.getComponent(d,g);o.setComponent(d+u,g,y)}}else a.set(h.array,l);l+=h.count*e}return s!==void 0&&(o.gpuType=s),o}function ic(i,t=!0,e=!1){let n=i.filter(o=>o.geometry.type==="polygon");if(!n.length)return null;let s=n.map(o=>{let l=o.geometry.coords,c=wi(l[0],l.slice(1)),h=new bi(c,{steps:1,bevelEnabled:!1,depth:o.height,curveSegments:4});o.deltaHeight||(o.deltaHeight=0),h.translate(0,0,o.airHeight+o.deltaHeight);let u=h.attributes.position.count,d=new Float32Array(u).fill(o.height+o.airHeight+o.deltaHeight);if(h.setAttribute("maxZ",new te(d,1)),h.setAttribute("opacity",new te(new Float32Array(u).fill(o.fillOpacity),1)),e){let y=new Float32Array(u).fill(o.airHeight+o.deltaHeight);h.setAttribute("minZ",new te(y,1))}let m=new Wt(o.fillColor).convertLinearToSRGB(),g=new Float32Array(u*3);for(let y=0;y<u;y++)g[y*3]=m.r,g[y*3+1]=m.g,g[y*3+2]=m.b;return h.setAttribute("color",new te(g,3)),h}),r=Ti(s);s.forEach(o=>o.dispose());let a={geometry:r};return r.dispose(),t&&(a.lineGeometry=Xm(n)||void 0),a}function Xm(i){let{points:t,colors:e,opacities:n}=qm(i);if(!t.length)return null;let s=new Ee().setFromPoints(t);return s.setAttribute("color",new te(new Float32Array(e),3)),s.setAttribute("opacity",new te(new Float32Array(n),1)),s}function qm(i){let t=[],e=[],n=[];return i.filter(s=>s.strokeOpacity>0).map(s=>{let r=s.height+(s.deltaHeight||0)+s.airHeight,{coords:a}=s.geometry,{strokeColor:o,strokeOpacity:l}=s,c=new Wt(o).convertLinearToSRGB();for(let h=0;h<a.length;h++){let u=a[h];for(let d=0;d<u.length;d++){let m=u[d],g=d+1===u.length?u[0]:u[d+1];t.push(new I(m[0],m[1],r)),t.push(new I(g[0],g[1],r)),e.push(c.r,c.g,c.b),e.push(c.r,c.g,c.b),n.push(l),n.push(l)}}}),{points:t,colors:e,opacities:n}}ec({onGetMergedGeometryAttributes({data:i}){let t=i.map(s=>{let r=s.geometry.coords,a=wi(r[0],r.slice(1));return new bi(a,{steps:1,bevelEnabled:!1,depth:s.height,curveSegments:4})}),e=Ti(t);t.forEach(s=>s.dispose());let n={attributes:e.attributes,index:e.index,morphAttributes:e.morphAttributes,morphTargetsRelative:e.morphTargetsRelative,groups:e.groups,boundingSphere:e.boundingSphere};return e.dispose(),n},onGetMergedShapeGeometryAttributes({data:i}){let t=i.map(s=>{var h;let r=wi(s.geometry.coords[0].slice(0,-1),s.geometry.coords.slice(1)),a=new Zi(r,4),o=a.getAttribute("position"),l=[],c=new Wt(s.fillColor);for(let u=0;u<o.count;u++)o.setZ(u,s.airHeight+(s.deltaHeight||0)),l.push(c.r,c.g,c.b,(h=s.fillOpacity)!=null?h:1);return a.setAttribute("color",new te(new Float32Array(l),4)),a}),e=Ti(t);t.forEach(s=>s.dispose());let n={attributes:e.attributes,index:e.index,morphAttributes:e.morphAttributes,morphTargetsRelative:e.morphTargetsRelative,groups:e.groups,boundingSphere:e.boundingSphere};return e.dispose(),n},onGetMergedTexture2dShapeGeometryAttributes({data:i}){let t=i.map(s=>{let r=wi(s.geometry.coords[0].slice(0,-1),s.geometry.coords.slice(1)),a=new Zi(r,4),o=a.getAttribute("position"),l=[1,1,1,0,0,0,0,1];a.setAttribute("uv",new fe(l,2));let c=s.height+(s.deltaHeight||0)+s.airHeight;for(let h=0;h<o.count;h++)o.setZ(h,c);return a}),e=Ti(t);t.forEach(s=>s.dispose());let n={attributes:e.attributes,index:e.index,morphAttributes:e.morphAttributes,morphTargetsRelative:e.morphTargetsRelative,groups:e.groups,boundingSphere:e.boundingSphere};return e.dispose(),n},onGetMergedGeometriesJson({data:i}){var e;let t=ic(i);return t?{mergedGeometry:t.geometry.toJSON(),lineGeometry:(e=t.lineGeometry)==null?void 0:e.toJSON()}:null}});
7943
- `],{type:"text/javascript"}),t=URL.createObjectURL(r),e=new Worker(t);return URL.revokeObjectURL(t),e}import{BufferGeometry as H4,BufferAttribute as W1}from"three";var $i=class{static GetMergeGeometry(t){return v(this,null,function*(){let e=yield this.WorkerPool.getWorker(),n=yield qi(e,"get_merged_geometry_attributes",{data:t}),i=this.GetBufferGeometryByData(n);return this.WorkerPool.releaseWorker(e),i})}static GetMergedShapeGeometry(t){return v(this,null,function*(){let e=yield this.WorkerPool.getWorker(),n=yield qi(e,"get_merged_shape_geometry_attributes",{data:t}),i=this.GetBufferGeometryByData(n);return this.WorkerPool.releaseWorker(e),i})}static GetMergedTexture2dGeometry(t){return v(this,null,function*(){let e=yield this.WorkerPool.getWorker(),n=yield qi(e,"get_merged_texture2d_shape_geometry_attributes",{data:t}),i=this.GetBufferGeometryByData(n);return this.WorkerPool.releaseWorker(e),i})}static GetBufferGeometryByData(t){let e=new H4;return Object.keys(t.attributes).forEach(n=>{e.setAttribute(n,new W1(t.attributes[n].array,t.attributes[n].itemSize))}),t.index&&e.setIndex(new W1(t.index.array,t.index.itemSize)),e.morphAttributes=t.morphAttributes,e.morphTargetsRelative=t.morphTargetsRelative,e.groups=t.groups,e.boundingSphere=t.boundingSphere,e}static GetMergedGeometry(t){return v(this,null,function*(){let e=yield this.WorkerPool.getWorker(),n=yield qi(e,"get_merged_geometries_json",{data:t});return this.WorkerPool.releaseWorker(e),n?Su(Su({},t[0]),n):null})}static dispose(){this.WorkerPool.dispose()}};lt($i,"WorkerPool",new Aa(10,dh));var Sa=class extends at{getCenter(){return new Q4().setFromObject(this).getCenter(new $4)}addGraphics(t,e){t.map(n=>{this.graphicDataMap.set(n.id,n)}),e?e.map(n=>{let i=new ar(this.context,n);this.group.add(i)}):this.refresh()}createGraphic(t){return v(this,null,function*(){console.time("createGraphic");let e=yield $i.GetMergedGeometry(t);if(console.timeEnd("createGraphic"),V(this.group),this.group.clear(),e){let n=new ar(this.context,e);this.group.add(n)}})}refresh(){this.createGraphic(Array.from(this.graphicDataMap.values()))}removeGraphicById(t){this.graphicDataMap.delete(t),this.createGraphic(Array.from(this.graphicDataMap.values()))}getGraphicDataByNodeId(t){return this.graphicMap.get(t)||null}setGraphicOptions(t,e){let n,i=this.graphicDataMap.get(t);i&&(typeof e=="function"?n=e(i):n=A({},i,e),this.graphicDataMap.set(t,n),this.createGraphic(Array.from(this.graphicDataMap.values())))}getGraphicPosition(t){let e=this.graphicDataMap.get(t);return e?[e.center_x,e.center_y]:null}constructor(t){super(t),this.graphicMap=new Map,this.group=new q4,this.graphicDataMap=new Map,this.add(this.group)}};var EQ=f(E(),1),IQ=f(us(),1);import{Box2 as mh,Object3D as tF,Sprite as C1,SpriteMaterial as Y1,Vector2 as Ta}from"three";import{isNil as to}from"lodash";var eF={text:"",icon:"",icon_size:[22,22],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},text_font_size:14,icon_rotate:0,depth_test:!1,hide_text:!1,maxWeight:25,minWeight:1,text_opacity:1,icon_opacity:1},et=class extends tF{get hasText(){return!this.options.hide_text&&this.options.text}get durIconAndText(){return this.options.icon&&this.hasText?2:0}get offset(){return this.options.icon&&this.hasText?0:.5}get iconWidth(){return this.options.icon?this.options.icon_size[0]:0}get iconHeight(){return this.options.icon?this.options.icon_size[1]:0}get textWidth(){return this.hasText?this.textHeight*this.textAspect:0}get textHeight(){return this.hasText?this.options.text_font_size*this.textureLines:0}get hasOriginTexture(){let{text_texture:t,text_texture_width:e,text_texture_height:n,text_texture_offset_x:i,text_texture_offset_y:o}=this.options;return!to(t)&&!to(e)&&!to(n)&&!to(i)&&!to(o)}get deltaZ(){return this.options.icon&&this.hasText?.1+this.offset*(this.iconHeight+this.durIconAndText+this.textHeight)/this.context.camera.zoom:this.hasText?.1+.5*this.textHeight/this.context.camera.zoom:.1}get canSelect(){return this.visible&&(this.spriteIcon?this.spriteIcon.visible:!0)&&(this.spriteText?this.spriteText.visible:!0)}registryEvent(){this.context.addEventListener("control-zoom-change",this._initScale),this.addEventListener("change-icon",t=>v(this,null,function*(){let{value:e}=t;this._initIconPromise&&(yield this._initIconPromise),this.spriteIcon&&(this.remove(this.spriteIcon),this.spriteIcon=void 0),yield this.initIcon(),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})),this.addEventListener("change-text",t=>v(this,null,function*(){let{value:e}=t;this.spriteText&&(this.remove(this.spriteText),this.spriteText=void 0),yield this.initText(),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})),this.addEventListener("change-text_font_size",t=>v(this,null,function*(){let{value:e}=t;this.spriteText&&(this.remove(this.spriteText),this.spriteText=void 0),yield this.initText(),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})),this.addEventListener("change-icon_rotate",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.rotation=e/180*Math.PI)}),this.addEventListener("change-icon_size",t=>{let{value:e}=t;this.spriteIcon&&(this.initSize(),this._initScale({zoom:this.context.camera.zoom}))}),this.addEventListener("change-depth_test",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.depthTest=e),this.spriteText&&(this.spriteText.material.depthTest=e)}),this.addEventListener("change-icon_opacity",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.opacity=e)}),this.addEventListener("change-text_opacity",t=>{let{value:e}=t;this.spriteText&&(this.spriteText.material.opacity=e)})}unRegistryEvent(){this.context.removeEventListener("control-zoom-change",this._initScale)}getPosition(){return this.position}initIcon(){return v(this,null,function*(){if(this.options.icon)return this._initIconPromise=new Promise(t=>v(this,null,function*(){let e;if(this.options.icon_border){let{icon:i,icon_size:o,icon_border:s}=this.options;e=yield ct.getUrlTextureBorder(i,o[0]-s.width*2,s)}else e=yield ct.getTextureByUrl(this.options.icon);let n=new C1(new Y1({map:e,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI,opacity:this.options.icon_opacity}));n.visible=!1,n.renderOrder=1e5+this.options.level,e.needsUpdate=!0,this.add(n),this.spriteIcon=n,t(n)})).then(()=>{this._initIconPromise=null})})}initText(){return v(this,null,function*(){if(this.hasText){let t;if(this.hasOriginTexture){let{text_texture:n,text_texture_width:i,text_texture_height:o,text_texture_offset_x:s,text_texture_offset_y:a}=this.options;t=this.options.text_texture.clone(),t.uuid=n.uuid,t.offset.set(s/t.image.width,1-(o+a)/t.image.height),t.repeat.set(i/t.image.width,o/t.image.height),this.textAspect=i/o}else{let n=yield rt.getTextureByText(this.options.text);t=n.texture,this.textureLines=n.lines,this.textAspect=t.image.width/t.image.height}let e=new C1(new Y1({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,opacity:this.options.text_opacity}));e.visible=!1,e.renderOrder=100001+this.options.level,t.needsUpdate=!0,this.spriteText=e,this.add(e)}})}initSize(){var t,e;let n=0,i=0,{icon:o}=this.options;o?this.hasText?(n=0,i=n*(this.iconHeight/this.textHeight)-this.iconHeight/this.textHeight-this.durIconAndText/this.textHeight):(n=.5,i=0):this.hasText?(i=.5,n=0):(n=0,i=0),(t=this.spriteIcon)==null||t.center.set(.5,n),(e=this.spriteText)==null||e.center.set(.5,i)}init(){return v(this,null,function*(){yield Promise.all([this.initIcon(),this.initText()]),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})}resetZ(){let t=this.deltaZ;this.spriteIcon&&(this.spriteIcon.position.z=t),this.spriteText&&(this.spriteText.position.z=t)}getBox(t){let{clientSize:{width:e,height:n}}=this.context,i=e*(t.x+1)/2,o=n*(-t.y+1)/2;o+=this.offset*(this.iconHeight+this.durIconAndText+this.textHeight);let s=this.iconWidth/2,a=new mh(new Ta(i-s,o-this.iconHeight),new Ta(i+s,o)),u=this.textWidth/2,l=new mh(new Ta(i-u,o-this.textHeight-this.durIconAndText-this.iconHeight),new Ta(i+u,o-this.iconHeight-this.durIconAndText));return this.box=l.union(a),this.box}renderBoxHelper(t,e){if(!this.boxHelper){let n=document.createElement("div");n.style.position="absolute",n.style.zIndex="999",n.style.border="1px solid red",n.style.pointerEvents="none",this.boxHelper=n,this.context.container.appendChild(n)}t&&e?(this.boxHelper.style.left=t+"px",this.boxHelper.style.top=e+"px",this.boxHelper.style.width="2px",this.boxHelper.style.height="2px"):(this.boxHelper.style.left=this.box.min.x+"px",this.boxHelper.style.top=this.box.min.y+"px",this.boxHelper.style.width=this.box.max.x-this.box.min.x+"px",this.boxHelper.style.height=this.box.max.y-this.box.min.y+"px")}parentSetVisible(t){this.spriteText&&(this.spriteText.visible=t),this.spriteIcon&&(this.spriteIcon.visible=t),this.boxHelper&&(this.boxHelper.style.display=t?"block":"none")}dispose(){this.clear(),this.unRegistryEvent(),this.spriteText=void 0,this.spriteIcon=void 0,this._listeners={}}constructor(t,e){var n;super(),this.context=t,this.textAspect=1,this.box=new mh,this._initIconPromise=null,this.textureLines=1,this._initScale=o=>{let{zoom:s}=o;if(this.spriteText){let u=this.textHeight/s;this.spriteText.scale.set(this.textAspect*u,u,.1)}if(this.spriteIcon){var a;(a=this.spriteIcon)==null||a.scale.set(this.options.icon_size[0]/s,this.options.icon_size[1]/s,.1)}this.resetZ()};var i;this.options=Pr(A({},eF,e,{text:(i=(n=e.text)==null?void 0:n.trim())!=null?i:""}),this),this.position.set(this.options.position.x,this.options.position.y,this.options.position.z),this.registryEvent(),this.init()}};var qt=class extends gh{getPosition(){return this.box.getCenter(new xa)}onAddToScene(){this.poiLayer2.onAddToScene()}onRemoveFromScene(){this.poiLayer2.onRemoveFromScene()}createGround(t){let e=new ht(this.context,t);e.userData.data=t,this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(this.grounds.add(e),this.groundLayer.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight+e.options.deltaHeight)):0,this.groundUpper.position.z=this.groundMaxHeight+.01}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new ba().setFromObject(this).getCenter(new xa)}addModel(t){let e=new fa(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new ba().setFromObject(this.groundUpper),e=t.getCenter(new xa),n=t.getSize(new xa);this.shadow.setPosition(e),this.shadow.changeLightCamera(n)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addPoi2(t){let e=new et(this.context,t);return this.poiLayer2.pushPoi(e)}removePoi2(t){return this.poiLayer2.removePoi(t)}removePoi2ById(t){return this.poiLayer2.removePoiById(t)}addHeatmap(t){this.heatmap||(this.heatmap=new pa(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new ba().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z),this.heatmap}removeHeatMap(){this.heatmap&&(this.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=void 0)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}setGraphicOptions(t,e){this.graphicLayer.graphicMap.has(t)?this.graphicLayer.setGraphicOptions(t,e):this.mergeGraphicLayer.setGraphicOptions(t,e)}getGraphicPosition(t){return this.graphicLayer.getGraphicPosition(t)||this.mergeGraphicLayer.getGraphicPosition(t)||this.parkingSpaceLayer.getGraphicPosition(t)}changeParkingColor(t){this.parkingSpaceLayer.changeParkingColor(t)}updateBox(){this.box.setFromObject(this.groundLayer)}dispose(){var t;console.log("floor dispose",this.name),this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.parkingSpaceLayer.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.textTextureLayer.dispose(),this.grounds.forEach(e=>e.dispose()),(t=this.heatmap)==null||t.dispose(),this.groundUpper.clear(),this.models.children.forEach(e=>e.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new ha,this.groundUpper=new gh,this.models=new gh,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new ba,this.groundLayer=new at(this.context),this.graphicLayer=new da(this.context),this.poiLayer=new ga(this.context),this.poiLayer2=new Gr(this.context),this.parkingSpaceLayer=new ya(this.context),this.wallLayer=new at(this.context),this.textureLayer=new at(this.context),this.glbModelLayer=new Pa(this.context),this.laneLayer=new at(this.context),this.mergeGraphicLayer=new Sa(this.context),this.textTextureLayer=new at(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.parkingSpaceLayer),this.groundUpper.add(this.wallLayer),this.groundUpper.add(this.textureLayer),this.groundUpper.add(this.glbModelLayer),this.groundUpper.add(this.laneLayer),this.groundUpper.add(this.mergeGraphicLayer),this.groundUpper.add(this.textTextureLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}};var nq=f(X(),1),rq=f(E(),1);import{EventDispatcher as nF,Vector3 as rF}from"three";var $t=class extends nF{_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:n}=this.context,{offsetX:i,offsetY:o}=t,{clientWidth:s,clientHeight:a}=n.domElement,u=i/s*2-1,l=1-o/a*2;return new rF(u,l,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:n}=this.context;return Y(t,e,n.clientWidth,n.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}constructor(t){super(),this.context=t,this.points=[],this.enable=!0,this._onResize=e=>{let{width:n,height:i}=e;this.svg&&(this.svg.setAttribute("width",""+n),this.svg.setAttribute("height",""+i))},this.svg=$g(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var wa=class extends $t{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:n,y:i}]=this.points;return Math.sqrt((n-t)**2+(i-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}constructor(t){super(t),this.context=t,this.onUpdate=()=>{if(this.points[0]){let i=this.getSvgCoordinate(this.points[0]);Bn(this.circles[0],i.x,i.y),fe(this.line,i)}if(this.points[1]){let i=this.getSvgCoordinate(this.points[1]);Bn(this.circles[1],i.x,i.y),fe(this.line,void 0,i)}},this.onPointermove=i=>{this.points.length===1&&(this.line.style.display="block",fe(this.line,void 0,{x:i.offsetX,y:i.offsetY}))},this.onPointerleave=()=>{this.points[1]||(this.line.style.display="none")},this.onPointerdown=i=>{if(this.points[1])return;let o=this.getIntersectByPointerEvent(i);if(o){let{offsetX:s,offsetY:a}=i,u=this.circles[this.points.length];Bn(u,s,a),this.points.length||fe(this.line,{x:s,y:a},{x:s,y:a}),this.addPoint(o)}};let{config:{svg:{circle:e,line:n}}}=t;this.circles=[Si(e.radius,e.fill),Si(e.radius,e.fill)],this.line=os(n.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}};var aq=f(X(),1);var ja=class extends $t{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let n=this.circles[0],i=+n.getAttribute("cx"),o=+n.getAttribute("cy");return Math.sqrt((t-i)**2+(e-o)**2)<=5}addPoint(t){if(this.points.push(t),this.isClose){let e=this.calculatedArea();this.dispatchEvent({type:"area",area:e})}}calculatedArea(){let t=this.points.map(i=>[i.x,i.y]),e=0,n=t.length;for(let i=0;i<n;i++){let o=(i+1)%n;e+=t[i][0]*t[o][1]-t[o][0]*t[i][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}constructor(t){super(t),this.circles=[],this.lines=[],this.isClose=!1,this.onUpdate=()=>{this.points.length&&this.points.forEach((e,n)=>{let i=this.getSvgCoordinate(e);this.circles[n]&&Bn(this.circles[n],i.x,i.y),n!==0&&fe(this.lines[n-1],void 0,i),this.lines[n]&&fe(this.lines[n],i)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",fe(this.lastLine,void 0,{x:e.offsetX,y:e.offsetY}))},this.onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")},this.onPointerdown=e=>{if(this.isClose)return;let n=this.getIntersectByPointerEvent(e);if(n){let{offsetX:i,offsetY:o}=e;this.checkAdsorb(i,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(n);let{circle:{fill:s,radius:a},line:{stroke:u}}=this.context.config.svg;if(!this.isClose){let l=Si(a,s);Bn(l,i,o),this.addCircle(l)}if(this.lines.length&&fe(this.lastLine,void 0,{x:i,y:o}),!this.isClose){let l=os(u);fe(l,{x:i,y:o},{x:i,y:o}),this.addLine(l)}}},this.registryEvent()}};import{Box3 as iF}from"three";var R1=class extends $t{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}constructor(t){super(t),this.context=t,this.cornerRect=[],this.centerRect=[],this.onUpdate=()=>{if(this.graphic){let n=new iF().setFromObject(this.graphic),{camera:i,container:{clientWidth:o,clientHeight:s}}=this.context,{min:a,max:u}=n,l=Y(a,i,o,s),c=Y(u,i,o,s);_t(this.rect,l.x,c.y,Math.abs(c.x-l.x),Math.abs(c.y-l.y));let{x:h,y:p}=l,{x:d,y:m}=c,y=5,M=[{x:h-y,y:m-y},{x:d-y,y:m-y},{x:h-y,y:p-y},{x:d-y,y:p-y}];for(let D=0;D<M.length;D++)_t(this.cornerRect[D],M[D].x,M[D].y,y*2,y*2);let _=4,S=(h+d)/2,b=(p+m)/2,I=[{x:S-_,y:m-_},{x:h-_,y:b-_},{x:d-_,y:b-_},{x:S-_,y:p-_}];for(let D=0;D<I.length;D++)_t(this.centerRect[D],I[D].x,I[D].y,_*2,_*2)}else{_t(this.rect,0,0,0,0);for(let n=0;n<this.cornerRect.length;n++)_t(this.cornerRect[n],0,0,0,0),_t(this.centerRect[n],0,0,0,0)}};let{config:{svg:{line:e}}}=t;this.rect=Sn(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let n=0;n<4;n++)this.cornerRect[n]=Sn(e.stroke,"#ffffff"),this.centerRect[n]=Sn(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[n]),this.svg.appendChild(this.centerRect[n]);this.registryEvent()}};var mq=f(X(),1);import{BufferGeometry as oF,Color as yh,LineSegments as sF,Mesh as aF,Object3D as uF,ShaderMaterial as lF,Vector3 as O1}from"three";import{mergeGeometries as cF}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Ea=class extends uF{initGeometry(){return v(this,null,function*(){let t=yield ve.GetMergeGeometry(this.options);this.geometry=t})}initMaterial(){let t=`
7943
+ `],{type:"text/javascript"}),t=URL.createObjectURL(r),e=new Worker(t);return URL.revokeObjectURL(t),e}import{BufferGeometry as H4,BufferAttribute as W1}from"three";var $i=class{static GetMergeGeometry(t){return v(this,null,function*(){let e=yield this.WorkerPool.getWorker(),n=yield qi(e,"get_merged_geometry_attributes",{data:t}),i=this.GetBufferGeometryByData(n);return this.WorkerPool.releaseWorker(e),i})}static GetMergedShapeGeometry(t){return v(this,null,function*(){let e=yield this.WorkerPool.getWorker(),n=yield qi(e,"get_merged_shape_geometry_attributes",{data:t}),i=this.GetBufferGeometryByData(n);return this.WorkerPool.releaseWorker(e),i})}static GetMergedTexture2dGeometry(t){return v(this,null,function*(){let e=yield this.WorkerPool.getWorker(),n=yield qi(e,"get_merged_texture2d_shape_geometry_attributes",{data:t}),i=this.GetBufferGeometryByData(n);return this.WorkerPool.releaseWorker(e),i})}static GetBufferGeometryByData(t){let e=new H4;return Object.keys(t.attributes).forEach(n=>{e.setAttribute(n,new W1(t.attributes[n].array,t.attributes[n].itemSize))}),t.index&&e.setIndex(new W1(t.index.array,t.index.itemSize)),e.morphAttributes=t.morphAttributes,e.morphTargetsRelative=t.morphTargetsRelative,e.groups=t.groups,e.boundingSphere=t.boundingSphere,e}static GetMergedGeometry(t){return v(this,null,function*(){let e=yield this.WorkerPool.getWorker(),n=yield qi(e,"get_merged_geometries_json",{data:t});return this.WorkerPool.releaseWorker(e),n?Su(Su({},t[0]),n):null})}static dispose(){this.WorkerPool.dispose()}};lt($i,"WorkerPool",new Aa(10,dh));var Sa=class extends at{getCenter(){return new Q4().setFromObject(this).getCenter(new $4)}addGraphics(t,e){t.map(n=>{this.graphicDataMap.set(n.id,n)}),e?e.map(n=>{let i=new ar(this.context,n);this.group.add(i)}):this.refresh()}createGraphic(t){return v(this,null,function*(){let e=yield $i.GetMergedGeometry(t);if(V(this.group),this.group.clear(),e){let n=new ar(this.context,e);this.group.add(n)}})}refresh(){this.createGraphic(Array.from(this.graphicDataMap.values()))}removeGraphicById(t){this.graphicDataMap.delete(t),this.createGraphic(Array.from(this.graphicDataMap.values()))}getGraphicDataByNodeId(t){return this.graphicMap.get(t)||null}setGraphicOptions(t,e){let n,i=this.graphicDataMap.get(t);i&&(typeof e=="function"?n=e(i):n=A({},i,e),this.graphicDataMap.set(t,n),this.createGraphic(Array.from(this.graphicDataMap.values())))}getGraphicPosition(t){let e=this.graphicDataMap.get(t);return e?[e.center_x,e.center_y]:null}constructor(t){super(t),this.graphicMap=new Map,this.group=new q4,this.graphicDataMap=new Map,this.add(this.group)}};var EQ=f(E(),1),IQ=f(us(),1);import{Box2 as mh,Object3D as tF,Sprite as C1,SpriteMaterial as Y1,Vector2 as Ta}from"three";import{isNil as to}from"lodash";var eF={text:"",icon:"",icon_size:[22,22],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},text_font_size:14,icon_rotate:0,depth_test:!1,hide_text:!1,maxWeight:25,minWeight:1,text_opacity:1,icon_opacity:1},et=class extends tF{get hasText(){return!this.options.hide_text&&this.options.text}get durIconAndText(){return this.options.icon&&this.hasText?2:0}get offset(){return this.options.icon&&this.hasText?0:.5}get iconWidth(){return this.options.icon?this.options.icon_size[0]:0}get iconHeight(){return this.options.icon?this.options.icon_size[1]:0}get textWidth(){return this.hasText?this.textHeight*this.textAspect:0}get textHeight(){return this.hasText?this.options.text_font_size*this.textureLines:0}get hasOriginTexture(){let{text_texture:t,text_texture_width:e,text_texture_height:n,text_texture_offset_x:i,text_texture_offset_y:o}=this.options;return!to(t)&&!to(e)&&!to(n)&&!to(i)&&!to(o)}get deltaZ(){return this.options.icon&&this.hasText?.1+this.offset*(this.iconHeight+this.durIconAndText+this.textHeight)/this.context.camera.zoom:this.hasText?.1+.5*this.textHeight/this.context.camera.zoom:.1}get canSelect(){return this.visible&&(this.spriteIcon?this.spriteIcon.visible:!0)&&(this.spriteText?this.spriteText.visible:!0)}registryEvent(){this.context.addEventListener("control-zoom-change",this._initScale),this.addEventListener("change-icon",t=>v(this,null,function*(){let{value:e}=t;this._initIconPromise&&(yield this._initIconPromise),this.spriteIcon&&(this.remove(this.spriteIcon),this.spriteIcon=void 0),yield this.initIcon(),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})),this.addEventListener("change-text",t=>v(this,null,function*(){let{value:e}=t;this.spriteText&&(this.remove(this.spriteText),this.spriteText=void 0),yield this.initText(),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})),this.addEventListener("change-text_font_size",t=>v(this,null,function*(){let{value:e}=t;this.spriteText&&(this.remove(this.spriteText),this.spriteText=void 0),yield this.initText(),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})),this.addEventListener("change-icon_rotate",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.rotation=e/180*Math.PI)}),this.addEventListener("change-icon_size",t=>{let{value:e}=t;this.spriteIcon&&(this.initSize(),this._initScale({zoom:this.context.camera.zoom}))}),this.addEventListener("change-depth_test",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.depthTest=e),this.spriteText&&(this.spriteText.material.depthTest=e)}),this.addEventListener("change-icon_opacity",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.opacity=e)}),this.addEventListener("change-text_opacity",t=>{let{value:e}=t;this.spriteText&&(this.spriteText.material.opacity=e)})}unRegistryEvent(){this.context.removeEventListener("control-zoom-change",this._initScale)}getPosition(){return this.position}initIcon(){return v(this,null,function*(){if(this.options.icon)return this._initIconPromise=new Promise(t=>v(this,null,function*(){let e;if(this.options.icon_border){let{icon:i,icon_size:o,icon_border:s}=this.options;e=yield ct.getUrlTextureBorder(i,o[0]-s.width*2,s)}else e=yield ct.getTextureByUrl(this.options.icon);let n=new C1(new Y1({map:e,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI,opacity:this.options.icon_opacity}));n.visible=!1,n.renderOrder=1e5+this.options.level,e.needsUpdate=!0,this.add(n),this.spriteIcon=n,t(n)})).then(()=>{this._initIconPromise=null})})}initText(){return v(this,null,function*(){if(this.hasText){let t;if(this.hasOriginTexture){let{text_texture:n,text_texture_width:i,text_texture_height:o,text_texture_offset_x:s,text_texture_offset_y:a}=this.options;t=this.options.text_texture.clone(),t.uuid=n.uuid,t.offset.set(s/t.image.width,1-(o+a)/t.image.height),t.repeat.set(i/t.image.width,o/t.image.height),this.textAspect=i/o}else{let n=yield rt.getTextureByText(this.options.text);t=n.texture,this.textureLines=n.lines,this.textAspect=t.image.width/t.image.height}let e=new C1(new Y1({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,opacity:this.options.text_opacity}));e.visible=!1,e.renderOrder=100001+this.options.level,t.needsUpdate=!0,this.spriteText=e,this.add(e)}})}initSize(){var t,e;let n=0,i=0,{icon:o}=this.options;o?this.hasText?(n=0,i=n*(this.iconHeight/this.textHeight)-this.iconHeight/this.textHeight-this.durIconAndText/this.textHeight):(n=.5,i=0):this.hasText?(i=.5,n=0):(n=0,i=0),(t=this.spriteIcon)==null||t.center.set(.5,n),(e=this.spriteText)==null||e.center.set(.5,i)}init(){return v(this,null,function*(){yield Promise.all([this.initIcon(),this.initText()]),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})}resetZ(){let t=this.deltaZ;this.spriteIcon&&(this.spriteIcon.position.z=t),this.spriteText&&(this.spriteText.position.z=t)}getBox(t){let{clientSize:{width:e,height:n}}=this.context,i=e*(t.x+1)/2,o=n*(-t.y+1)/2;o+=this.offset*(this.iconHeight+this.durIconAndText+this.textHeight);let s=this.iconWidth/2,a=new mh(new Ta(i-s,o-this.iconHeight),new Ta(i+s,o)),u=this.textWidth/2,l=new mh(new Ta(i-u,o-this.textHeight-this.durIconAndText-this.iconHeight),new Ta(i+u,o-this.iconHeight-this.durIconAndText));return this.box=l.union(a),this.box}renderBoxHelper(t,e){if(!this.boxHelper){let n=document.createElement("div");n.style.position="absolute",n.style.zIndex="999",n.style.border="1px solid red",n.style.pointerEvents="none",this.boxHelper=n,this.context.container.appendChild(n)}t&&e?(this.boxHelper.style.left=t+"px",this.boxHelper.style.top=e+"px",this.boxHelper.style.width="2px",this.boxHelper.style.height="2px"):(this.boxHelper.style.left=this.box.min.x+"px",this.boxHelper.style.top=this.box.min.y+"px",this.boxHelper.style.width=this.box.max.x-this.box.min.x+"px",this.boxHelper.style.height=this.box.max.y-this.box.min.y+"px")}parentSetVisible(t){this.spriteText&&(this.spriteText.visible=t),this.spriteIcon&&(this.spriteIcon.visible=t),this.boxHelper&&(this.boxHelper.style.display=t?"block":"none")}dispose(){this.clear(),this.unRegistryEvent(),this.spriteText=void 0,this.spriteIcon=void 0,this._listeners={}}constructor(t,e){var n;super(),this.context=t,this.textAspect=1,this.box=new mh,this._initIconPromise=null,this.textureLines=1,this._initScale=o=>{let{zoom:s}=o;if(this.spriteText){let u=this.textHeight/s;this.spriteText.scale.set(this.textAspect*u,u,.1)}if(this.spriteIcon){var a;(a=this.spriteIcon)==null||a.scale.set(this.options.icon_size[0]/s,this.options.icon_size[1]/s,.1)}this.resetZ()};var i;this.options=Pr(A({},eF,e,{text:(i=(n=e.text)==null?void 0:n.trim())!=null?i:""}),this),this.position.set(this.options.position.x,this.options.position.y,this.options.position.z),this.registryEvent(),this.init()}};var qt=class extends gh{getPosition(){return this.box.getCenter(new xa)}onAddToScene(){this.poiLayer2.onAddToScene()}onRemoveFromScene(){this.poiLayer2.onRemoveFromScene()}createGround(t){let e=new ht(this.context,t);e.userData.data=t,this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(this.grounds.add(e),this.groundLayer.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight+e.options.deltaHeight)):0,this.groundUpper.position.z=this.groundMaxHeight+.01}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new ba().setFromObject(this).getCenter(new xa)}addModel(t){let e=new fa(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new ba().setFromObject(this.groundUpper),e=t.getCenter(new xa),n=t.getSize(new xa);this.shadow.setPosition(e),this.shadow.changeLightCamera(n)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addPoi2(t){let e=new et(this.context,t);return this.poiLayer2.pushPoi(e)}removePoi2(t){return this.poiLayer2.removePoi(t)}removePoi2ById(t){return this.poiLayer2.removePoiById(t)}addHeatmap(t){this.heatmap||(this.heatmap=new pa(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new ba().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z),this.heatmap}removeHeatMap(){this.heatmap&&(this.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=void 0)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}setGraphicOptions(t,e){this.graphicLayer.graphicMap.has(t)?this.graphicLayer.setGraphicOptions(t,e):this.mergeGraphicLayer.setGraphicOptions(t,e)}getGraphicPosition(t){return this.graphicLayer.getGraphicPosition(t)||this.mergeGraphicLayer.getGraphicPosition(t)||this.parkingSpaceLayer.getGraphicPosition(t)}changeParkingColor(t){this.parkingSpaceLayer.changeParkingColor(t)}updateBox(){this.box.setFromObject(this.groundLayer)}dispose(){var t;console.log("floor dispose",this.name),this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.parkingSpaceLayer.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.textTextureLayer.dispose(),this.grounds.forEach(e=>e.dispose()),(t=this.heatmap)==null||t.dispose(),this.groundUpper.clear(),this.models.children.forEach(e=>e.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new ha,this.groundUpper=new gh,this.models=new gh,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new ba,this.groundLayer=new at(this.context),this.graphicLayer=new da(this.context),this.poiLayer=new ga(this.context),this.poiLayer2=new Gr(this.context),this.parkingSpaceLayer=new ya(this.context),this.wallLayer=new at(this.context),this.textureLayer=new at(this.context),this.glbModelLayer=new Pa(this.context),this.laneLayer=new at(this.context),this.mergeGraphicLayer=new Sa(this.context),this.textTextureLayer=new at(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.parkingSpaceLayer),this.groundUpper.add(this.wallLayer),this.groundUpper.add(this.textureLayer),this.groundUpper.add(this.glbModelLayer),this.groundUpper.add(this.laneLayer),this.groundUpper.add(this.mergeGraphicLayer),this.groundUpper.add(this.textTextureLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}};var nq=f(X(),1),rq=f(E(),1);import{EventDispatcher as nF,Vector3 as rF}from"three";var $t=class extends nF{_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:n}=this.context,{offsetX:i,offsetY:o}=t,{clientWidth:s,clientHeight:a}=n.domElement,u=i/s*2-1,l=1-o/a*2;return new rF(u,l,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:n}=this.context;return Y(t,e,n.clientWidth,n.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}constructor(t){super(),this.context=t,this.points=[],this.enable=!0,this._onResize=e=>{let{width:n,height:i}=e;this.svg&&(this.svg.setAttribute("width",""+n),this.svg.setAttribute("height",""+i))},this.svg=$g(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var wa=class extends $t{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:n,y:i}]=this.points;return Math.sqrt((n-t)**2+(i-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}constructor(t){super(t),this.context=t,this.onUpdate=()=>{if(this.points[0]){let i=this.getSvgCoordinate(this.points[0]);Bn(this.circles[0],i.x,i.y),fe(this.line,i)}if(this.points[1]){let i=this.getSvgCoordinate(this.points[1]);Bn(this.circles[1],i.x,i.y),fe(this.line,void 0,i)}},this.onPointermove=i=>{this.points.length===1&&(this.line.style.display="block",fe(this.line,void 0,{x:i.offsetX,y:i.offsetY}))},this.onPointerleave=()=>{this.points[1]||(this.line.style.display="none")},this.onPointerdown=i=>{if(this.points[1])return;let o=this.getIntersectByPointerEvent(i);if(o){let{offsetX:s,offsetY:a}=i,u=this.circles[this.points.length];Bn(u,s,a),this.points.length||fe(this.line,{x:s,y:a},{x:s,y:a}),this.addPoint(o)}};let{config:{svg:{circle:e,line:n}}}=t;this.circles=[Si(e.radius,e.fill),Si(e.radius,e.fill)],this.line=os(n.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}};var aq=f(X(),1);var ja=class extends $t{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let n=this.circles[0],i=+n.getAttribute("cx"),o=+n.getAttribute("cy");return Math.sqrt((t-i)**2+(e-o)**2)<=5}addPoint(t){if(this.points.push(t),this.isClose){let e=this.calculatedArea();this.dispatchEvent({type:"area",area:e})}}calculatedArea(){let t=this.points.map(i=>[i.x,i.y]),e=0,n=t.length;for(let i=0;i<n;i++){let o=(i+1)%n;e+=t[i][0]*t[o][1]-t[o][0]*t[i][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}constructor(t){super(t),this.circles=[],this.lines=[],this.isClose=!1,this.onUpdate=()=>{this.points.length&&this.points.forEach((e,n)=>{let i=this.getSvgCoordinate(e);this.circles[n]&&Bn(this.circles[n],i.x,i.y),n!==0&&fe(this.lines[n-1],void 0,i),this.lines[n]&&fe(this.lines[n],i)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",fe(this.lastLine,void 0,{x:e.offsetX,y:e.offsetY}))},this.onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")},this.onPointerdown=e=>{if(this.isClose)return;let n=this.getIntersectByPointerEvent(e);if(n){let{offsetX:i,offsetY:o}=e;this.checkAdsorb(i,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(n);let{circle:{fill:s,radius:a},line:{stroke:u}}=this.context.config.svg;if(!this.isClose){let l=Si(a,s);Bn(l,i,o),this.addCircle(l)}if(this.lines.length&&fe(this.lastLine,void 0,{x:i,y:o}),!this.isClose){let l=os(u);fe(l,{x:i,y:o},{x:i,y:o}),this.addLine(l)}}},this.registryEvent()}};import{Box3 as iF}from"three";var R1=class extends $t{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}constructor(t){super(t),this.context=t,this.cornerRect=[],this.centerRect=[],this.onUpdate=()=>{if(this.graphic){let n=new iF().setFromObject(this.graphic),{camera:i,container:{clientWidth:o,clientHeight:s}}=this.context,{min:a,max:u}=n,l=Y(a,i,o,s),c=Y(u,i,o,s);_t(this.rect,l.x,c.y,Math.abs(c.x-l.x),Math.abs(c.y-l.y));let{x:h,y:p}=l,{x:d,y:m}=c,y=5,M=[{x:h-y,y:m-y},{x:d-y,y:m-y},{x:h-y,y:p-y},{x:d-y,y:p-y}];for(let D=0;D<M.length;D++)_t(this.cornerRect[D],M[D].x,M[D].y,y*2,y*2);let _=4,S=(h+d)/2,b=(p+m)/2,I=[{x:S-_,y:m-_},{x:h-_,y:b-_},{x:d-_,y:b-_},{x:S-_,y:p-_}];for(let D=0;D<I.length;D++)_t(this.centerRect[D],I[D].x,I[D].y,_*2,_*2)}else{_t(this.rect,0,0,0,0);for(let n=0;n<this.cornerRect.length;n++)_t(this.cornerRect[n],0,0,0,0),_t(this.centerRect[n],0,0,0,0)}};let{config:{svg:{line:e}}}=t;this.rect=Sn(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let n=0;n<4;n++)this.cornerRect[n]=Sn(e.stroke,"#ffffff"),this.centerRect[n]=Sn(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[n]),this.svg.appendChild(this.centerRect[n]);this.registryEvent()}};var mq=f(X(),1);import{BufferGeometry as oF,Color as yh,LineSegments as sF,Mesh as aF,Object3D as uF,ShaderMaterial as lF,Vector3 as O1}from"three";import{mergeGeometries as cF}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Ea=class extends uF{initGeometry(){return v(this,null,function*(){let t=yield ve.GetMergeGeometry(this.options);this.geometry=t})}initMaterial(){let t=`
7944
7944
  varying vec3 vPosition; // \u7528\u4E8E\u4F20\u9012\u9876\u70B9\u7684\u4F4D\u7F6E\u7ED9\u7247\u6BB5\u7740\u8272\u5668
7945
7945
  uniform float maxZ; // \u58F0\u660E\u4E00\u4E2Auniform\u53D8\u91CF
7946
7946
  uniform vec3 uColor;