iflow-engine-base 3.7.2 → 3.7.3
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.
|
@@ -3944,7 +3944,7 @@ void main() {
|
|
|
3944
3944
|
|
|
3945
3945
|
}
|
|
3946
3946
|
|
|
3947
|
-
}`;class C1{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new im(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Wn({vertexShader:w1,fragmentShader:S1,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ys(new jl(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class M1 extends Hr{constructor(e,t){super();const i=this;let s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,d=null,f=null,u=null,g=null;const p=typeof XRWebGLBinding<"u",m=new C1,A={},x=t.getContextAttributes();let b=null,y=null;const _=[],S=[],C=new dt;let D=null;const M=new en;M.viewport=new Lt;const I=new en;I.viewport=new Lt;const P=[M,I],T=new Cw;let L=null,E=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(re){let de=_[re];return de===void 0&&(de=new fu,_[re]=de),de.getTargetRaySpace()},this.getControllerGrip=function(re){let de=_[re];return de===void 0&&(de=new fu,_[re]=de),de.getGripSpace()},this.getHand=function(re){let de=_[re];return de===void 0&&(de=new fu,_[re]=de),de.getHandSpace()};function F(re){const de=S.indexOf(re.inputSource);if(de===-1)return;const Ae=_[de];Ae!==void 0&&(Ae.update(re.inputSource,re.frame,c||o),Ae.dispatchEvent({type:re.type,data:re.inputSource}))}function z(){s.removeEventListener("select",F),s.removeEventListener("selectstart",F),s.removeEventListener("selectend",F),s.removeEventListener("squeeze",F),s.removeEventListener("squeezestart",F),s.removeEventListener("squeezeend",F),s.removeEventListener("end",z),s.removeEventListener("inputsourceschange",X);for(let re=0;re<_.length;re++){const de=S[re];de!==null&&(S[re]=null,_[re].disconnect(de))}L=null,E=null,m.reset();for(const re in A)delete A[re];e.setRenderTarget(b),u=null,f=null,d=null,s=null,y=null,ue.stop(),i.isPresenting=!1,e.setPixelRatio(D),e.setSize(C.width,C.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(re){r=re,i.isPresenting===!0&&$e("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(re){a=re,i.isPresenting===!0&&$e("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(re){c=re},this.getBaseLayer=function(){return f!==null?f:u},this.getBinding=function(){return d===null&&p&&(d=new XRWebGLBinding(s,t)),d},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(re){if(s=re,s!==null){if(b=e.getRenderTarget(),s.addEventListener("select",F),s.addEventListener("selectstart",F),s.addEventListener("selectend",F),s.addEventListener("squeeze",F),s.addEventListener("squeezestart",F),s.addEventListener("squeezeend",F),s.addEventListener("end",z),s.addEventListener("inputsourceschange",X),x.xrCompatible!==!0&&await t.makeXRCompatible(),D=e.getPixelRatio(),e.getSize(C),p&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ae=null,ye=null,Me=null;x.depth&&(Me=x.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Ae=x.stencil?Ho:Wo,ye=x.stencil?jo:Xs);const Oe={colorFormat:t.RGBA8,depthFormat:Me,scaleFactor:r};d=this.getBinding(),f=d.createProjectionLayer(Oe),s.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),y=new qs(f.textureWidth,f.textureHeight,{format:Yi,type:On,depthTexture:new tm(f.textureWidth,f.textureHeight,ye,void 0,void 0,void 0,void 0,void 0,void 0,Ae),stencilBuffer:x.stencil,colorSpace:e.outputColorSpace,samples:x.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{const Ae={antialias:x.antialias,alpha:!0,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(s,t,Ae),s.updateRenderState({baseLayer:u}),e.setPixelRatio(1),e.setSize(u.framebufferWidth,u.framebufferHeight,!1),y=new qs(u.framebufferWidth,u.framebufferHeight,{format:Yi,type:On,colorSpace:e.outputColorSpace,stencilBuffer:x.stencil,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await s.requestReferenceSpace(a),ue.setContext(s),ue.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function X(re){for(let de=0;de<re.removed.length;de++){const Ae=re.removed[de],ye=S.indexOf(Ae);ye>=0&&(S[ye]=null,_[ye].disconnect(Ae))}for(let de=0;de<re.added.length;de++){const Ae=re.added[de];let ye=S.indexOf(Ae);if(ye===-1){for(let Oe=0;Oe<_.length;Oe++)if(Oe>=S.length){S.push(Ae),ye=Oe;break}else if(S[Oe]===null){S[Oe]=Ae,ye=Oe;break}if(ye===-1)break}const Me=_[ye];Me&&Me.connect(Ae)}}const j=new ge,N=new ge;function Y(re,de,Ae){j.setFromMatrixPosition(de.matrixWorld),N.setFromMatrixPosition(Ae.matrixWorld);const ye=j.distanceTo(N),Me=de.projectionMatrix.elements,Oe=Ae.projectionMatrix.elements,nt=Me[14]/(Me[10]-1),Ge=Me[14]/(Me[10]+1),B=(Me[9]+1)/Me[5],ae=(Me[9]-1)/Me[5],ie=(Me[8]-1)/Me[0],W=(Oe[8]+1)/Oe[0],G=nt*ie,K=nt*W,me=ye/(-ie+W),U=me*-ie;if(de.matrixWorld.decompose(re.position,re.quaternion,re.scale),re.translateX(U),re.translateZ(me),re.matrixWorld.compose(re.position,re.quaternion,re.scale),re.matrixWorldInverse.copy(re.matrixWorld).invert(),Me[10]===-1)re.projectionMatrix.copy(de.projectionMatrix),re.projectionMatrixInverse.copy(de.projectionMatrixInverse);else{const te=nt+me,k=Ge+me,R=G-U,Q=K+(ye-U),ee=B*Ge/k*te,se=ae*Ge/k*te;re.projectionMatrix.makePerspective(R,Q,ee,se,te,k),re.projectionMatrixInverse.copy(re.projectionMatrix).invert()}}function V(re,de){de===null?re.matrixWorld.copy(re.matrix):re.matrixWorld.multiplyMatrices(de.matrixWorld,re.matrix),re.matrixWorldInverse.copy(re.matrixWorld).invert()}this.updateCamera=function(re){if(s===null)return;let de=re.near,Ae=re.far;m.texture!==null&&(m.depthNear>0&&(de=m.depthNear),m.depthFar>0&&(Ae=m.depthFar)),T.near=I.near=M.near=de,T.far=I.far=M.far=Ae,(L!==T.near||E!==T.far)&&(s.updateRenderState({depthNear:T.near,depthFar:T.far}),L=T.near,E=T.far),T.layers.mask=re.layers.mask|6,M.layers.mask=T.layers.mask&3,I.layers.mask=T.layers.mask&5;const ye=re.parent,Me=T.cameras;V(T,ye);for(let Oe=0;Oe<Me.length;Oe++)V(Me[Oe],ye);Me.length===2?Y(T,M,I):T.projectionMatrix.copy(M.projectionMatrix),H(re,T,ye)};function H(re,de,Ae){Ae===null?re.matrix.copy(de.matrixWorld):(re.matrix.copy(Ae.matrixWorld),re.matrix.invert(),re.matrix.multiply(de.matrixWorld)),re.matrix.decompose(re.position,re.quaternion,re.scale),re.updateMatrixWorld(!0),re.projectionMatrix.copy(de.projectionMatrix),re.projectionMatrixInverse.copy(de.projectionMatrixInverse),re.isPerspectiveCamera&&(re.fov=Qd*2*Math.atan(1/re.projectionMatrix.elements[5]),re.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(f===null&&u===null))return l},this.setFoveation=function(re){l=re,f!==null&&(f.fixedFoveation=re),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=re)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(T)},this.getCameraTexture=function(re){return A[re]};let oe=null;function pe(re,de){if(h=de.getViewerPose(c||o),g=de,h!==null){const Ae=h.views;u!==null&&(e.setRenderTargetFramebuffer(y,u.framebuffer),e.setRenderTarget(y));let ye=!1;Ae.length!==T.cameras.length&&(T.cameras.length=0,ye=!0);for(let Ge=0;Ge<Ae.length;Ge++){const B=Ae[Ge];let ae=null;if(u!==null)ae=u.getViewport(B);else{const W=d.getViewSubImage(f,B);ae=W.viewport,Ge===0&&(e.setRenderTargetTextures(y,W.colorTexture,W.depthStencilTexture),e.setRenderTarget(y))}let ie=P[Ge];ie===void 0&&(ie=new en,ie.layers.enable(Ge),ie.viewport=new Lt,P[Ge]=ie),ie.matrix.fromArray(B.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray(B.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set(ae.x,ae.y,ae.width,ae.height),Ge===0&&(T.matrix.copy(ie.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),ye===!0&&T.cameras.push(ie)}const Me=s.enabledFeatures;if(Me&&Me.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&p){d=i.getBinding();const Ge=d.getDepthInformation(Ae[0]);Ge&&Ge.isValid&&Ge.texture&&m.init(Ge,s.renderState)}if(Me&&Me.includes("camera-access")&&p){e.state.unbindTexture(),d=i.getBinding();for(let Ge=0;Ge<Ae.length;Ge++){const B=Ae[Ge].camera;if(B){let ae=A[B];ae||(ae=new im,A[B]=ae);const ie=d.getCameraImage(B);ae.sourceTexture=ie}}}}for(let Ae=0;Ae<_.length;Ae++){const ye=S[Ae],Me=_[Ae];ye!==null&&Me!==void 0&&Me.update(ye,de,c||o)}oe&&oe(re,de),de.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:de}),g=null}const ue=new sm;ue.setAnimationLoop(pe),this.setAnimationLoop=function(re){oe=re},this.dispose=function(){}}}const sr=new $s,E1=new zt;function I1(n,e){function t(m,A){m.matrixAutoUpdate===!0&&m.updateMatrix(),A.value.copy(m.matrix)}function i(m,A){A.color.getRGB(m.fogColor.value,Yg(n)),A.isFog?(m.fogNear.value=A.near,m.fogFar.value=A.far):A.isFogExp2&&(m.fogDensity.value=A.density)}function s(m,A,x,b,y){A.isMeshBasicMaterial||A.isMeshLambertMaterial?r(m,A):A.isMeshToonMaterial?(r(m,A),d(m,A)):A.isMeshPhongMaterial?(r(m,A),h(m,A)):A.isMeshStandardMaterial?(r(m,A),f(m,A),A.isMeshPhysicalMaterial&&u(m,A,y)):A.isMeshMatcapMaterial?(r(m,A),g(m,A)):A.isMeshDepthMaterial?r(m,A):A.isMeshDistanceMaterial?(r(m,A),p(m,A)):A.isMeshNormalMaterial?r(m,A):A.isLineBasicMaterial?(o(m,A),A.isLineDashedMaterial&&a(m,A)):A.isPointsMaterial?l(m,A,x,b):A.isSpriteMaterial?c(m,A):A.isShadowMaterial?(m.color.value.copy(A.color),m.opacity.value=A.opacity):A.isShaderMaterial&&(A.uniformsNeedUpdate=!1)}function r(m,A){m.opacity.value=A.opacity,A.color&&m.diffuse.value.copy(A.color),A.emissive&&m.emissive.value.copy(A.emissive).multiplyScalar(A.emissiveIntensity),A.map&&(m.map.value=A.map,t(A.map,m.mapTransform)),A.alphaMap&&(m.alphaMap.value=A.alphaMap,t(A.alphaMap,m.alphaMapTransform)),A.bumpMap&&(m.bumpMap.value=A.bumpMap,t(A.bumpMap,m.bumpMapTransform),m.bumpScale.value=A.bumpScale,A.side===gi&&(m.bumpScale.value*=-1)),A.normalMap&&(m.normalMap.value=A.normalMap,t(A.normalMap,m.normalMapTransform),m.normalScale.value.copy(A.normalScale),A.side===gi&&m.normalScale.value.negate()),A.displacementMap&&(m.displacementMap.value=A.displacementMap,t(A.displacementMap,m.displacementMapTransform),m.displacementScale.value=A.displacementScale,m.displacementBias.value=A.displacementBias),A.emissiveMap&&(m.emissiveMap.value=A.emissiveMap,t(A.emissiveMap,m.emissiveMapTransform)),A.specularMap&&(m.specularMap.value=A.specularMap,t(A.specularMap,m.specularMapTransform)),A.alphaTest>0&&(m.alphaTest.value=A.alphaTest);const x=e.get(A),b=x.envMap,y=x.envMapRotation;b&&(m.envMap.value=b,sr.copy(y),sr.x*=-1,sr.y*=-1,sr.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(sr.y*=-1,sr.z*=-1),m.envMapRotation.value.setFromMatrix4(E1.makeRotationFromEuler(sr)),m.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=A.reflectivity,m.ior.value=A.ior,m.refractionRatio.value=A.refractionRatio),A.lightMap&&(m.lightMap.value=A.lightMap,m.lightMapIntensity.value=A.lightMapIntensity,t(A.lightMap,m.lightMapTransform)),A.aoMap&&(m.aoMap.value=A.aoMap,m.aoMapIntensity.value=A.aoMapIntensity,t(A.aoMap,m.aoMapTransform))}function o(m,A){m.diffuse.value.copy(A.color),m.opacity.value=A.opacity,A.map&&(m.map.value=A.map,t(A.map,m.mapTransform))}function a(m,A){m.dashSize.value=A.dashSize,m.totalSize.value=A.dashSize+A.gapSize,m.scale.value=A.scale}function l(m,A,x,b){m.diffuse.value.copy(A.color),m.opacity.value=A.opacity,m.size.value=A.size*x,m.scale.value=b*.5,A.map&&(m.map.value=A.map,t(A.map,m.uvTransform)),A.alphaMap&&(m.alphaMap.value=A.alphaMap,t(A.alphaMap,m.alphaMapTransform)),A.alphaTest>0&&(m.alphaTest.value=A.alphaTest)}function c(m,A){m.diffuse.value.copy(A.color),m.opacity.value=A.opacity,m.rotation.value=A.rotation,A.map&&(m.map.value=A.map,t(A.map,m.mapTransform)),A.alphaMap&&(m.alphaMap.value=A.alphaMap,t(A.alphaMap,m.alphaMapTransform)),A.alphaTest>0&&(m.alphaTest.value=A.alphaTest)}function h(m,A){m.specular.value.copy(A.specular),m.shininess.value=Math.max(A.shininess,1e-4)}function d(m,A){A.gradientMap&&(m.gradientMap.value=A.gradientMap)}function f(m,A){m.metalness.value=A.metalness,A.metalnessMap&&(m.metalnessMap.value=A.metalnessMap,t(A.metalnessMap,m.metalnessMapTransform)),m.roughness.value=A.roughness,A.roughnessMap&&(m.roughnessMap.value=A.roughnessMap,t(A.roughnessMap,m.roughnessMapTransform)),A.envMap&&(m.envMapIntensity.value=A.envMapIntensity)}function u(m,A,x){m.ior.value=A.ior,A.sheen>0&&(m.sheenColor.value.copy(A.sheenColor).multiplyScalar(A.sheen),m.sheenRoughness.value=A.sheenRoughness,A.sheenColorMap&&(m.sheenColorMap.value=A.sheenColorMap,t(A.sheenColorMap,m.sheenColorMapTransform)),A.sheenRoughnessMap&&(m.sheenRoughnessMap.value=A.sheenRoughnessMap,t(A.sheenRoughnessMap,m.sheenRoughnessMapTransform))),A.clearcoat>0&&(m.clearcoat.value=A.clearcoat,m.clearcoatRoughness.value=A.clearcoatRoughness,A.clearcoatMap&&(m.clearcoatMap.value=A.clearcoatMap,t(A.clearcoatMap,m.clearcoatMapTransform)),A.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=A.clearcoatRoughnessMap,t(A.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),A.clearcoatNormalMap&&(m.clearcoatNormalMap.value=A.clearcoatNormalMap,t(A.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(A.clearcoatNormalScale),A.side===gi&&m.clearcoatNormalScale.value.negate())),A.dispersion>0&&(m.dispersion.value=A.dispersion),A.iridescence>0&&(m.iridescence.value=A.iridescence,m.iridescenceIOR.value=A.iridescenceIOR,m.iridescenceThicknessMinimum.value=A.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=A.iridescenceThicknessRange[1],A.iridescenceMap&&(m.iridescenceMap.value=A.iridescenceMap,t(A.iridescenceMap,m.iridescenceMapTransform)),A.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=A.iridescenceThicknessMap,t(A.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),A.transmission>0&&(m.transmission.value=A.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),A.transmissionMap&&(m.transmissionMap.value=A.transmissionMap,t(A.transmissionMap,m.transmissionMapTransform)),m.thickness.value=A.thickness,A.thicknessMap&&(m.thicknessMap.value=A.thicknessMap,t(A.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=A.attenuationDistance,m.attenuationColor.value.copy(A.attenuationColor)),A.anisotropy>0&&(m.anisotropyVector.value.set(A.anisotropy*Math.cos(A.anisotropyRotation),A.anisotropy*Math.sin(A.anisotropyRotation)),A.anisotropyMap&&(m.anisotropyMap.value=A.anisotropyMap,t(A.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=A.specularIntensity,m.specularColor.value.copy(A.specularColor),A.specularColorMap&&(m.specularColorMap.value=A.specularColorMap,t(A.specularColorMap,m.specularColorMapTransform)),A.specularIntensityMap&&(m.specularIntensityMap.value=A.specularIntensityMap,t(A.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,A){A.matcap&&(m.matcap.value=A.matcap)}function p(m,A){const x=e.get(A).light;m.referencePosition.value.setFromMatrixPosition(x.matrixWorld),m.nearDistance.value=x.shadow.camera.near,m.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function T1(n,e,t,i){let s={},r={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,b){const y=b.program;i.uniformBlockBinding(x,y)}function c(x,b){let y=s[x.id];y===void 0&&(g(x),y=h(x),s[x.id]=y,x.addEventListener("dispose",m));const _=b.program;i.updateUBOMapping(x,_);const S=e.render.frame;r[x.id]!==S&&(f(x),r[x.id]=S)}function h(x){const b=d();x.__bindingPointIndex=b;const y=n.createBuffer(),_=x.__size,S=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,y),n.bufferData(n.UNIFORM_BUFFER,_,S),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,b,y),y}function d(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return Pt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(x){const b=s[x.id],y=x.uniforms,_=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,b);for(let S=0,C=y.length;S<C;S++){const D=Array.isArray(y[S])?y[S]:[y[S]];for(let M=0,I=D.length;M<I;M++){const P=D[M];if(u(P,S,M,_)===!0){const T=P.__offset,L=Array.isArray(P.value)?P.value:[P.value];let E=0;for(let F=0;F<L.length;F++){const z=L[F],X=p(z);typeof z=="number"||typeof z=="boolean"?(P.__data[0]=z,n.bufferSubData(n.UNIFORM_BUFFER,T+E,P.__data)):z.isMatrix3?(P.__data[0]=z.elements[0],P.__data[1]=z.elements[1],P.__data[2]=z.elements[2],P.__data[3]=0,P.__data[4]=z.elements[3],P.__data[5]=z.elements[4],P.__data[6]=z.elements[5],P.__data[7]=0,P.__data[8]=z.elements[6],P.__data[9]=z.elements[7],P.__data[10]=z.elements[8],P.__data[11]=0):(z.toArray(P.__data,E),E+=X.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,T,P.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function u(x,b,y,_){const S=x.value,C=b+"_"+y;if(_[C]===void 0)return typeof S=="number"||typeof S=="boolean"?_[C]=S:_[C]=S.clone(),!0;{const D=_[C];if(typeof S=="number"||typeof S=="boolean"){if(D!==S)return _[C]=S,!0}else if(D.equals(S)===!1)return D.copy(S),!0}return!1}function g(x){const b=x.uniforms;let y=0;const _=16;for(let C=0,D=b.length;C<D;C++){const M=Array.isArray(b[C])?b[C]:[b[C]];for(let I=0,P=M.length;I<P;I++){const T=M[I],L=Array.isArray(T.value)?T.value:[T.value];for(let E=0,F=L.length;E<F;E++){const z=L[E],X=p(z),j=y%_,N=j%X.boundary,Y=j+N;y+=N,Y!==0&&_-Y<X.storage&&(y+=_-Y),T.__data=new Float32Array(X.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=y,y+=X.storage}}}const S=y%_;return S>0&&(y+=_-S),x.__size=y,x.__cache={},this}function p(x){const b={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(b.boundary=4,b.storage=4):x.isVector2?(b.boundary=8,b.storage=8):x.isVector3||x.isColor?(b.boundary=16,b.storage=12):x.isVector4?(b.boundary=16,b.storage=16):x.isMatrix3?(b.boundary=48,b.storage=48):x.isMatrix4?(b.boundary=64,b.storage=64):x.isTexture?$e("WebGLRenderer: Texture samplers can not be part of an uniforms group."):$e("WebGLRenderer: Unsupported uniform value type.",x),b}function m(x){const b=x.target;b.removeEventListener("dispose",m);const y=o.indexOf(b.__bindingPointIndex);o.splice(y,1),n.deleteBuffer(s[b.id]),delete s[b.id],delete r[b.id]}function A(){for(const x in s)n.deleteBuffer(s[x]);o=[],s={},r={}}return{bind:l,update:c,dispose:A}}const D1=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let Hn=null;function B1(){return Hn===null&&(Hn=new xw(D1,32,32,dd,Qr),Hn.minFilter=Fi,Hn.magFilter=Fi,Hn.wrapS=Fn,Hn.wrapT=Fn,Hn.generateMipmaps=!1,Hn.needsUpdate=!0),Hn}class P1{constructor(e={}){const{canvas:t=j_(),context:i=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:f=!1}=e;this.isWebGLRenderer=!0;let u;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");u=i.getContextAttributes().alpha}else u=o;const g=new Set([fd,ud,hd]),p=new Set([On,Xs,Qo,jo,ld,cd]),m=new Uint32Array(4),A=new Int32Array(4);let x=null,b=null;const y=[],_=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=us,this.toneMappingExposure=1,this.transmissionResolutionScale=.25,this.interactionCullingEnabled=!1,this.interactionActive=!1,this.interactionRenderScene=null,this.interactionFrameBudgetMs=10,this.interactionSkipShadows=!1;const S=this;let C=!1;this._outputColorSpace=Ci;let D=0,M=0,I=null,P=-1,T=null;const L=new Lt,E=new Lt;let F=null;const z=new ut(0);let X=0,j=t.width,N=t.height,Y=1,V=null,H=null;const oe=new Lt(0,0,j,N),pe=new Lt(0,0,j,N);let ue=!1;const re=new em;let de=!1,Ae=!1;const ye=new zt,Me=new ge,Oe=new Lt,nt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ge=!1,B=null;const ae=[];function ie(O){ae.push(B);const Z=Number.isFinite(S.interactionFrameBudgetMs)?S.interactionFrameBudgetMs:0,le=S.interactionRenderScene===null||O===S.interactionRenderScene;S.interactionCullingEnabled===!0&&S.interactionActive===!0&&le===!0&&Z>0?B={startTime:performance.now(),budgetMs:Z,aborted:!1}:B=null}function W(O){const Z=Number.isFinite(S.interactionFrameBudgetMs)?S.interactionFrameBudgetMs:0,le=S.interactionRenderScene===null||O===S.interactionRenderScene;return S.interactionCullingEnabled===!0&&S.interactionActive===!0&&le===!0&&Z>0}function G(){B=ae.pop()??null}function K(){return B===null?!1:B.aborted===!0?!0:performance.now()-B.startTime<B.budgetMs?!1:(B.aborted=!0,!0)}function me(){return I===null?Y:1}let U=i;function te(O,Z){return t.getContext(O,Z)}try{const O={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Hh}`),t.addEventListener("webglcontextlost",Bn,!1),t.addEventListener("webglcontextrestored",Pn,!1),t.addEventListener("webglcontextcreationerror",Uv,!1),U===null){const Z="webgl2";if(U=te(Z,O),U===null)throw te(Z)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(O){throw O("WebGLRenderer: "+O.message),O}let k,R,Q,ee,se,J,Te,we,Be,Qe,xe,Ce,je,Ue,Ie,Ve,q,_e,Se,Le,ve,be,ke,Ye;function yt(){k=new zC(U),k.init(),be=new _1(U,k),R=new BC(U,k,e,be),Q=new y1(U,k),R.reversedDepthBuffer&&f&&Q.buffers.depth.setReversed(!0),ee=new QC(U),se=new a1,J=new v1(U,k,Q,se,R,be,ee),Te=new LC(S),we=new NC(S),Be=new Ew(U),ke=new TC(U,Be),Qe=new GC(U,Be,ee,ke),xe=new WC(U,Qe,Be,ee),Se=new jC(U,R,J),Ve=new PC(se),Ce=new o1(S,Te,we,k,R,ke,Ve),je=new I1(S,se),Ue=new c1,Ie=new g1(k),_e=new IC(S,Te,we,Q,xe,u,l),q=new x1(S,xe,R),Ye=new T1(U,ee,R,Q),Le=new DC(U,k,ee),ve=new VC(U,k,ee),ee.programs=Ce.programs,S.capabilities=R,S.extensions=k,S.properties=se,S.renderLists=Ue,S.shadowMap=q,S.state=Q,S.info=ee}yt();const Ke=new M1(S,U);this.xr=Ke,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){const O=k.get("WEBGL_lose_context");O&&O.loseContext()},this.forceContextRestore=function(){const O=k.get("WEBGL_lose_context");O&&O.restoreContext()},this.getPixelRatio=function(){return Y},this.setPixelRatio=function(O){O!==void 0&&(Y=O,this.setSize(j,N,!1))},this.getSize=function(O){return O.set(j,N)},this.setSize=function(O,Z,le=!0){if(Ke.isPresenting){$e("WebGLRenderer: Can't change size while VR device is presenting.");return}j=O,N=Z,t.width=Math.floor(O*Y),t.height=Math.floor(Z*Y),le===!0&&(t.style.width=O+"px",t.style.height=Z+"px"),this.setViewport(0,0,O,Z)},this.getDrawingBufferSize=function(O){return O.set(j*Y,N*Y).floor()},this.setDrawingBufferSize=function(O,Z,le){j=O,N=Z,Y=le,t.width=Math.floor(O*le),t.height=Math.floor(Z*le),this.setViewport(0,0,O,Z)},this.getCurrentViewport=function(O){return O.copy(L)},this.getViewport=function(O){return O.copy(oe)},this.setViewport=function(O,Z,le,fe){O.isVector4?oe.set(O.x,O.y,O.z,O.w):oe.set(O,Z,le,fe),Q.viewport(L.copy(oe).multiplyScalar(Y).round())},this.getScissor=function(O){return O.copy(pe)},this.setScissor=function(O,Z,le,fe){O.isVector4?pe.set(O.x,O.y,O.z,O.w):pe.set(O,Z,le,fe),Q.scissor(E.copy(pe).multiplyScalar(Y).round())},this.getScissorTest=function(){return ue},this.setScissorTest=function(O){Q.setScissorTest(ue=O)},this.setOpaqueSort=function(O){V=O},this.setTransparentSort=function(O){H=O},this.getClearColor=function(O){return O.copy(_e.getClearColor())},this.setClearColor=function(){_e.setClearColor(...arguments)},this.getClearAlpha=function(){return _e.getClearAlpha()},this.setClearAlpha=function(){_e.setClearAlpha(...arguments)},this.clear=function(O=!0,Z=!0,le=!0){let fe=0;if(O){let ne=!1;if(I!==null){const Ee=I.texture.format;ne=g.has(Ee)}if(ne){const Ee=I.texture.type,Pe=p.has(Ee),Ne=_e.getClearColor(),Fe=_e.getClearAlpha(),Xe=Ne.r,qe=Ne.g,We=Ne.b;Pe?(m[0]=Xe,m[1]=qe,m[2]=We,m[3]=Fe,U.clearBufferuiv(U.COLOR,0,m)):(A[0]=Xe,A[1]=qe,A[2]=We,A[3]=Fe,U.clearBufferiv(U.COLOR,0,A))}else fe|=U.COLOR_BUFFER_BIT}Z&&(fe|=U.DEPTH_BUFFER_BIT),le&&(fe|=U.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),U.clear(fe)},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(){t.removeEventListener("webglcontextlost",Bn,!1),t.removeEventListener("webglcontextrestored",Pn,!1),t.removeEventListener("webglcontextcreationerror",Uv,!1),_e.dispose(),Ue.dispose(),Ie.dispose(),se.dispose(),Te.dispose(),we.dispose(),xe.dispose(),ke.dispose(),Ye.dispose(),Ce.dispose(),Ke.dispose(),Ke.removeEventListener("sessionstart",Gv),Ke.removeEventListener("sessionend",Vv),Or.stop()};function Bn(O){O.preventDefault(),Ig("WebGLRenderer: Context Lost."),C=!0}function Pn(){Ig("WebGLRenderer: Context Restored."),C=!1;const O=ee.autoReset,Z=q.enabled,le=q.autoUpdate,fe=q.needsUpdate,ne=q.type;yt(),ee.autoReset=O,q.enabled=Z,q.autoUpdate=le,q.needsUpdate=fe,q.type=ne}function Uv(O){Pt("WebGLRenderer: A WebGL context could not be created. Reason: ",O.statusMessage)}function Nv(O){const Z=O.target;Z.removeEventListener("dispose",Nv),Tk(Z)}function Tk(O){Dk(O),se.remove(O)}function Dk(O){const Z=se.get(O).programs;Z!==void 0&&(Z.forEach(function(le){Ce.releaseProgram(le)}),O.isShaderMaterial&&Ce.releaseShaderCache(O))}this.renderBufferDirect=function(O,Z,le,fe,ne,Ee){Z===null&&(Z=nt);const Pe=ne.isMesh&&ne.matrixWorld.determinant()<0,Ne=Pk(O,Z,le,fe,ne);Q.setMaterial(fe,Pe);let Fe=le.index,Xe=1;if(fe.wireframe===!0){if(Fe=Qe.getWireframeAttribute(le),Fe===void 0)return;Xe=2}const qe=le.drawRange,We=le.attributes.position;let st=qe.start*Xe,gt=(qe.start+qe.count)*Xe;Ee!==null&&(st=Math.max(st,Ee.start*Xe),gt=Math.min(gt,(Ee.start+Ee.count)*Xe)),Fe!==null?(st=Math.max(st,0),gt=Math.min(gt,Fe.count)):We!=null&&(st=Math.max(st,0),gt=Math.min(gt,We.count));const Dt=gt-st;if(Dt<0||Dt===1/0)return;ke.setup(ne,fe,Ne,le,Fe);let Bt,bt=Le;if(Fe!==null&&(Bt=Be.get(Fe),bt=ve,bt.setIndex(Bt)),ne.isMesh)fe.wireframe===!0?(Q.setLineWidth(fe.wireframeLinewidth*me()),bt.setMode(U.LINES)):bt.setMode(U.TRIANGLES);else if(ne.isLine){let He=fe.linewidth;He===void 0&&(He=1),Q.setLineWidth(He*me()),ne.isLineSegments?bt.setMode(U.LINES):ne.isLineLoop?bt.setMode(U.LINE_LOOP):bt.setMode(U.LINE_STRIP)}else ne.isPoints?bt.setMode(U.POINTS):ne.isSprite&&bt.setMode(U.TRIANGLES);if(ne.isBatchedMesh)if(ne._multiDrawInstances!==null)Xo("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),bt.renderMultiDrawInstances(ne._multiDrawStarts,ne._multiDrawCounts,ne._multiDrawCount,ne._multiDrawInstances);else if(k.get("WEBGL_multi_draw"))bt.renderMultiDraw(ne._multiDrawStarts,ne._multiDrawCounts,ne._multiDrawCount);else{const He=ne._multiDrawStarts,wt=ne._multiDrawCounts,at=ne._multiDrawCount,Ri=Fe?Be.get(Fe).bytesPerElement:1,Vo=se.get(fe).currentProgram.getUniforms();for(let ki=0;ki<at;ki++)Vo.setValue(U,"_gl_DrawID",ki),bt.render(He[ki]/Ri,wt[ki])}else if(ne.isInstancedMesh)bt.renderInstances(st,Dt,ne.count);else if(le.isInstancedBufferGeometry){const He=le._maxInstanceCount!==void 0?le._maxInstanceCount:1/0,wt=Math.min(le.instanceCount,He);bt.renderInstances(st,Dt,wt)}else bt.render(st,Dt)};function zv(O,Z,le){O.transparent===!0&&O.side===Rn&&O.forceSinglePass===!1?(O.side=gi,O.needsUpdate=!0,Vh(O,Z,le),O.side=ds,O.needsUpdate=!0,Vh(O,Z,le),O.side=Rn):Vh(O,Z,le)}this.compile=function(O,Z,le=null){le===null&&(le=O),b=Ie.get(le),b.init(Z),_.push(b),le.traverseVisible(function(ne){ne.isLight&&ne.layers.test(Z.layers)&&(b.pushLight(ne),ne.castShadow&&b.pushShadow(ne))}),O!==le&&O.traverseVisible(function(ne){ne.isLight&&ne.layers.test(Z.layers)&&(b.pushLight(ne),ne.castShadow&&b.pushShadow(ne))}),b.setupLights();const fe=new Set;return O.traverse(function(ne){if(!(ne.isMesh||ne.isPoints||ne.isLine||ne.isSprite))return;const Ee=ne.material;if(Ee)if(Array.isArray(Ee))for(let Pe=0;Pe<Ee.length;Pe++){const Ne=Ee[Pe];zv(Ne,le,ne),fe.add(Ne)}else zv(Ee,le,ne),fe.add(Ee)}),b=_.pop(),fe},this.compileAsync=function(O,Z,le=null){const fe=this.compile(O,Z,le);return new Promise(ne=>{function Ee(){if(fe.forEach(function(Pe){se.get(Pe).currentProgram.isReady()&&fe.delete(Pe)}),fe.size===0){ne(O);return}setTimeout(Ee,10)}k.get("KHR_parallel_shader_compile")!==null?Ee():setTimeout(Ee,10)})};let Hp=null;function Bk(O){Hp&&Hp(O)}function Gv(){Or.stop()}function Vv(){Or.start()}const Or=new sm;Or.setAnimationLoop(Bk),typeof self<"u"&&Or.setContext(self),this.setAnimationLoop=function(O){Hp=O,Ke.setAnimationLoop(O),O===null?Or.stop():Or.start()},Ke.addEventListener("sessionstart",Gv),Ke.addEventListener("sessionend",Vv),this.render=function(O,Z){if(Z!==void 0&&Z.isCamera!==!0){Pt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C!==!0){O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),Z.parent===null&&Z.matrixWorldAutoUpdate===!0&&Z.updateMatrixWorld(),Ke.enabled===!0&&Ke.isPresenting===!0&&(Ke.cameraAutoUpdate===!0&&Ke.updateCamera(Z),Z=Ke.getCamera()),O.isScene===!0&&O.onBeforeRender(S,O,Z,I),b=Ie.get(O,_.length),b.init(Z),_.push(b),ye.multiplyMatrices(Z.projectionMatrix,Z.matrixWorldInverse),re.setFromProjectionMatrix(ye,mn,Z.reversedDepth),Ae=this.localClippingEnabled,de=Ve.init(this.clippingPlanes,Ae),x=Ue.get(O,y.length),x.init(),y.push(x),ie(O);try{if(Ke.enabled===!0&&Ke.isPresenting===!0){const Ee=S.xr.getDepthSensingMesh();Ee!==null&&Xp(Ee,Z,-1/0,S.sortObjects)}Xp(O,Z,0,S.sortObjects),x.finish(),S.sortObjects===!0&&x.sort(V,H),Ge=Ke.enabled===!1||Ke.isPresenting===!1||Ke.hasDepthSensing()===!1,Ge&&_e.addToRenderList(x,O),this.info.render.frame++,de===!0&&Ve.beginShadows();const le=b.state.shadowsArray;(S.interactionSkipShadows!==!0||W(O)===!1)&&q.render(le,O,Z),de===!0&&Ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const fe=x.opaque,ne=x.transmissive;if(b.setupLights(),Z.isArrayCamera){const Ee=Z.cameras;if(ne.length>0)for(let Pe=0,Ne=Ee.length;Pe<Ne;Pe++){const Fe=Ee[Pe];jv(fe,ne,O,Fe)}Ge&&_e.render(O);for(let Pe=0,Ne=Ee.length;Pe<Ne;Pe++){const Fe=Ee[Pe];Qv(x,O,Fe,Fe.viewport)}}else ne.length>0&&jv(fe,ne,O,Z),Ge&&_e.render(O),Qv(x,O,Z)}finally{G()}I!==null&&M===0&&(J.updateMultisampleRenderTarget(I),J.updateRenderTargetMipmap(I)),O.isScene===!0&&O.onAfterRender(S,O,Z),ke.resetDefaultState(),P=-1,T=null,_.pop(),_.length>0?(b=_[_.length-1],de===!0&&Ve.setGlobalState(S.clippingPlanes,b.state.camera)):b=null,y.pop(),y.length>0?x=y[y.length-1]:x=null}};function Xp(O,Z,le,fe){if(K()===!0||O.visible===!1)return;if(O.layers.test(Z.layers)){if(O.isGroup)le=O.renderOrder;else if(O.isLOD)O.autoUpdate===!0&&O.update(Z);else if(O.isLight)b.pushLight(O),O.castShadow&&b.pushShadow(O);else if(O.isSprite){if(!O.frustumCulled||re.intersectsSprite(O)){fe&&Oe.setFromMatrixPosition(O.matrixWorld).applyMatrix4(ye);const Pe=xe.update(O),Ne=O.material;Ne.visible&&x.push(O,Pe,Ne,le,Oe.z,null)}}else if((O.isMesh||O.isLine||O.isPoints)&&(!O.frustumCulled||re.intersectsObject(O))){const Pe=xe.update(O),Ne=O.material;if(fe&&(O.boundingSphere!==void 0?(O.boundingSphere===null&&O.computeBoundingSphere(),Oe.copy(O.boundingSphere.center)):(Pe.boundingSphere===null&&Pe.computeBoundingSphere(),Oe.copy(Pe.boundingSphere.center)),Oe.applyMatrix4(O.matrixWorld).applyMatrix4(ye)),Array.isArray(Ne)){const Fe=Pe.groups;for(let Xe=0,qe=Fe.length;Xe<qe;Xe++){const We=Fe[Xe],st=Ne[We.materialIndex];st&&st.visible&&x.push(O,Pe,st,le,Oe.z,We)}}else Ne.visible&&x.push(O,Pe,Ne,le,Oe.z,null)}}const Ee=O.children;for(let Pe=0,Ne=Ee.length;Pe<Ne;Pe++)Xp(Ee[Pe],Z,le,fe)}function Qv(O,Z,le,fe){const{opaque:ne,transmissive:Ee,transparent:Pe}=O;b.setupLightsView(le),de===!0&&Ve.setGlobalState(S.clippingPlanes,le),fe&&Q.viewport(L.copy(fe)),ne.length>0&&Gh(ne,Z,le),Ee.length>0&&Gh(Ee,Z,le),Pe.length>0&&Gh(Pe,Z,le),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function jv(O,Z,le,fe){if((le.isScene===!0?le.overrideMaterial:null)!==null)return;b.state.transmissionRenderTarget[fe.id]===void 0&&(b.state.transmissionRenderTarget[fe.id]=new qs(1,1,{generateMipmaps:!0,type:k.has("EXT_color_buffer_half_float")||k.has("EXT_color_buffer_float")?Qr:On,minFilter:Hs,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ot.workingColorSpace}));const Ee=b.state.transmissionRenderTarget[fe.id],Pe=fe.viewport||L;Ee.setSize(Pe.z*S.transmissionResolutionScale,Pe.w*S.transmissionResolutionScale);const Ne=S.getRenderTarget(),Fe=S.getActiveCubeFace(),Xe=S.getActiveMipmapLevel();S.setRenderTarget(Ee),S.getClearColor(z),X=S.getClearAlpha(),X<1&&S.setClearColor(16777215,.5),S.clear(),Ge&&_e.render(le);const qe=S.toneMapping;S.toneMapping=us;const We=fe.viewport;if(fe.viewport!==void 0&&(fe.viewport=void 0),b.setupLightsView(fe),de===!0&&Ve.setGlobalState(S.clippingPlanes,fe),Gh(O,le,fe),J.updateMultisampleRenderTarget(Ee),J.updateRenderTargetMipmap(Ee),k.has("WEBGL_multisampled_render_to_texture")===!1){let st=!1;for(let gt=0,Dt=Z.length;gt<Dt;gt++){const Bt=Z[gt],{object:bt,geometry:He,material:wt,group:at}=Bt;if(wt.side===Rn&&bt.layers.test(fe.layers)){const Ri=wt.side;wt.side=gi,wt.needsUpdate=!0,Wv(bt,le,fe,He,wt,at),wt.side=Ri,wt.needsUpdate=!0,st=!0}}st===!0&&(J.updateMultisampleRenderTarget(Ee),J.updateRenderTargetMipmap(Ee))}S.setRenderTarget(Ne,Fe,Xe),S.setClearColor(z,X),We!==void 0&&(fe.viewport=We),S.toneMapping=qe}function Gh(O,Z,le){const fe=Z.isScene===!0?Z.overrideMaterial:null;for(let ne=0,Ee=O.length;ne<Ee;ne++){if(K()===!0)return;const Pe=O[ne],{object:Ne,geometry:Fe,group:Xe}=Pe;let qe=Pe.material;qe.allowOverride===!0&&fe!==null&&(qe=fe),Ne.layers.test(le.layers)&&Wv(Ne,Z,le,Fe,qe,Xe)}}function Wv(O,Z,le,fe,ne,Ee){O.onBeforeRender(S,Z,le,fe,ne,Ee),O.modelViewMatrix.multiplyMatrices(le.matrixWorldInverse,O.matrixWorld),O.normalMatrix.getNormalMatrix(O.modelViewMatrix),ne.onBeforeRender(S,Z,le,fe,O,Ee),ne.transparent===!0&&ne.side===Rn&&ne.forceSinglePass===!1?(ne.side=gi,ne.needsUpdate=!0,S.renderBufferDirect(le,Z,fe,ne,O,Ee),ne.side=ds,ne.needsUpdate=!0,S.renderBufferDirect(le,Z,fe,ne,O,Ee),ne.side=Rn):S.renderBufferDirect(le,Z,fe,ne,O,Ee),O.onAfterRender(S,Z,le,fe,ne,Ee)}function Vh(O,Z,le){Z.isScene!==!0&&(Z=nt);const fe=se.get(O),ne=b?.state.lights,Ee=b?.state.shadowsArray,Pe=ne.state.version,Ne=Ce.getParameters(O,ne.state,Ee,Z,le),Fe=Ce.getProgramCacheKey(Ne);let Xe=fe.programs;fe.environment=O.isMeshStandardMaterial?Z.environment:null,fe.fog=Z.fog,fe.envMap=(O.isMeshStandardMaterial?we:Te).get(O.envMap||fe.environment),fe.envMapRotation=fe.environment!==null&&O.envMap===null?Z.environmentRotation:O.envMapRotation,Xe===void 0&&(O.addEventListener("dispose",Nv),Xe=new Map,fe.programs=Xe);let qe=Xe.get(Fe);if(qe!==void 0){if(fe.currentProgram===qe&&fe.lightsStateVersion===Pe)return Xv(O,Ne),qe}else Ne.uniforms=Ce.getUniforms(O),O.onBeforeCompile(Ne,S),qe=Ce.acquireProgram(Ne,Fe),Xe.set(Fe,qe),fe.uniforms=Ne.uniforms;const We=fe.uniforms;return(!O.isShaderMaterial&&!O.isRawShaderMaterial||O.clipping===!0)&&(We.clippingPlanes=Ve.uniform),Xv(O,Ne),fe.needsLights=Rk(O),fe.lightsStateVersion=Pe,fe.needsLights&&(We.ambientLightColor.value=ne.state.ambient,We.lightProbe.value=ne.state.probe,We.directionalLights.value=ne.state.directional,We.directionalLightShadows.value=ne.state.directionalShadow,We.spotLights.value=ne.state.spot,We.spotLightShadows.value=ne.state.spotShadow,We.rectAreaLights.value=ne.state.rectArea,We.ltc_1.value=ne.state.rectAreaLTC1,We.ltc_2.value=ne.state.rectAreaLTC2,We.pointLights.value=ne.state.point,We.pointLightShadows.value=ne.state.pointShadow,We.hemisphereLights.value=ne.state.hemi,We.directionalShadowMap.value=ne.state.directionalShadowMap,We.directionalShadowMatrix.value=ne.state.directionalShadowMatrix,We.spotShadowMap.value=ne.state.spotShadowMap,We.spotLightMatrix.value=ne.state.spotLightMatrix,We.spotLightMap.value=ne.state.spotLightMap,We.pointShadowMap.value=ne.state.pointShadowMap,We.pointShadowMatrix.value=ne.state.pointShadowMatrix),fe.currentProgram=qe,fe.uniformsList=null,qe}function Hv(O){if(O.uniformsList===null){const Z=O.currentProgram.getUniforms();O.uniformsList=ql.seqWithValue(Z.seq,O.uniforms)}return O.uniformsList}function Xv(O,Z){const le=se.get(O);le.outputColorSpace=Z.outputColorSpace,le.batching=Z.batching,le.batchingColor=Z.batchingColor,le.instancing=Z.instancing,le.instancingColor=Z.instancingColor,le.instancingMorph=Z.instancingMorph,le.skinning=Z.skinning,le.morphTargets=Z.morphTargets,le.morphNormals=Z.morphNormals,le.morphColors=Z.morphColors,le.morphTargetsCount=Z.morphTargetsCount,le.numClippingPlanes=Z.numClippingPlanes,le.numIntersection=Z.numClipIntersection,le.vertexAlphas=Z.vertexAlphas,le.vertexTangents=Z.vertexTangents,le.toneMapping=Z.toneMapping}function Pk(O,Z,le,fe,ne){Z.isScene!==!0&&(Z=nt),J.resetTextureUnits();const Ee=Z.fog,Pe=fe.isMeshStandardMaterial?Z.environment:null,Ne=I===null?S.outputColorSpace:I.isXRRenderTarget===!0?I.texture.colorSpace:jr,Fe=(fe.isMeshStandardMaterial?we:Te).get(fe.envMap||Pe),Xe=fe.vertexColors===!0&&!!le.attributes.color&&le.attributes.color.itemSize===4,qe=!!le.attributes.tangent&&(!!fe.normalMap||fe.anisotropy>0),We=!!le.morphAttributes.position,st=!!le.morphAttributes.normal,gt=!!le.morphAttributes.color;let Dt=us;fe.toneMapped&&(I===null||I.isXRRenderTarget===!0)&&(Dt=S.toneMapping);const Bt=le.morphAttributes.position||le.morphAttributes.normal||le.morphAttributes.color,bt=Bt!==void 0?Bt.length:0,He=se.get(fe),wt=b?.state.lights;if(de===!0&&(Ae===!0||O!==T)){const fi=O===T&&fe.id===P;Ve.setState(fe,O,fi)}let at=!1;fe.version===He.__version?(He.needsLights&&He.lightsStateVersion!==wt.state.version||He.outputColorSpace!==Ne||ne.isBatchedMesh&&He.batching===!1||!ne.isBatchedMesh&&He.batching===!0||ne.isBatchedMesh&&He.batchingColor===!0&&ne.colorTexture===null||ne.isBatchedMesh&&He.batchingColor===!1&&ne.colorTexture!==null||ne.isInstancedMesh&&He.instancing===!1||!ne.isInstancedMesh&&He.instancing===!0||ne.isSkinnedMesh&&He.skinning===!1||!ne.isSkinnedMesh&&He.skinning===!0||ne.isInstancedMesh&&He.instancingColor===!0&&ne.instanceColor===null||ne.isInstancedMesh&&He.instancingColor===!1&&ne.instanceColor!==null||ne.isInstancedMesh&&He.instancingMorph===!0&&ne.morphTexture===null||ne.isInstancedMesh&&He.instancingMorph===!1&&ne.morphTexture!==null||He.envMap!==Fe||fe.fog===!0&&He.fog!==Ee||He.numClippingPlanes!==void 0&&(He.numClippingPlanes!==Ve.numPlanes||He.numIntersection!==Ve.numIntersection)||He.vertexAlphas!==Xe||He.vertexTangents!==qe||He.morphTargets!==We||He.morphNormals!==st||He.morphColors!==gt||He.toneMapping!==Dt||He.morphTargetsCount!==bt)&&(at=!0):(at=!0,He.__version=fe.version);let Ri=He.currentProgram;at===!0&&(Ri=Vh(fe,Z,ne));let Vo=!1,ki=!1,fl=!1;const St=Ri.getUniforms(),_i=He.uniforms;if(Q.useProgram(Ri.program)&&(Vo=!0,ki=!0,fl=!0),fe.id!==P&&(P=fe.id,ki=!0),Vo||T!==O){Q.buffers.depth.getReversed()&&O.reversedDepth!==!0&&(O._reversedDepth=!0,O.updateProjectionMatrix()),St.setValue(U,"projectionMatrix",O.projectionMatrix),St.setValue(U,"viewMatrix",O.matrixWorldInverse);const wi=St.map.cameraPosition;wi!==void 0&&wi.setValue(U,Me.setFromMatrixPosition(O.matrixWorld)),R.logarithmicDepthBuffer&&St.setValue(U,"logDepthBufFC",2/(Math.log(O.far+1)/Math.LN2)),(fe.isMeshPhongMaterial||fe.isMeshToonMaterial||fe.isMeshLambertMaterial||fe.isMeshBasicMaterial||fe.isMeshStandardMaterial||fe.isShaderMaterial)&&St.setValue(U,"isOrthographic",O.isOrthographicCamera===!0),T!==O&&(T=O,ki=!0,fl=!0)}if(ne.isSkinnedMesh){St.setOptional(U,ne,"bindMatrix"),St.setOptional(U,ne,"bindMatrixInverse");const fi=ne.skeleton;fi&&(fi.boneTexture===null&&fi.computeBoneTexture(),St.setValue(U,"boneTexture",fi.boneTexture,J))}ne.isBatchedMesh&&(St.setOptional(U,ne,"batchingTexture"),St.setValue(U,"batchingTexture",ne._matricesTexture,J),St.setOptional(U,ne,"batchingIdTexture"),St.setValue(U,"batchingIdTexture",ne._indirectTexture,J),St.setOptional(U,ne,"batchingColorTexture"),ne._colorsTexture!==null&&St.setValue(U,"batchingColorTexture",ne._colorsTexture,J));const qi=le.morphAttributes;if((qi.position!==void 0||qi.normal!==void 0||qi.color!==void 0)&&Se.update(ne,le,Ri),(ki||He.receiveShadow!==ne.receiveShadow)&&(He.receiveShadow=ne.receiveShadow,St.setValue(U,"receiveShadow",ne.receiveShadow)),fe.isMeshGouraudMaterial&&fe.envMap!==null&&(_i.envMap.value=Fe,_i.flipEnvMap.value=Fe.isCubeTexture&&Fe.isRenderTargetTexture===!1?-1:1),fe.isMeshStandardMaterial&&fe.envMap===null&&Z.environment!==null&&(_i.envMapIntensity.value=Z.environmentIntensity),_i.dfgLUT!==void 0&&(_i.dfgLUT.value=B1()),ki&&(St.setValue(U,"toneMappingExposure",S.toneMappingExposure),He.needsLights&&Lk(_i,fl),Ee&&fe.fog===!0&&je.refreshFogUniforms(_i,Ee),je.refreshMaterialUniforms(_i,fe,Y,N,b.state.transmissionRenderTarget[O.id]),ql.upload(U,Hv(He),_i,J)),fe.isShaderMaterial&&fe.uniformsNeedUpdate===!0&&(ql.upload(U,Hv(He),_i,J),fe.uniformsNeedUpdate=!1),fe.isSpriteMaterial&&St.setValue(U,"center",ne.center),St.setValue(U,"modelViewMatrix",ne.modelViewMatrix),St.setValue(U,"normalMatrix",ne.normalMatrix),St.setValue(U,"modelMatrix",ne.matrixWorld),fe.isShaderMaterial||fe.isRawShaderMaterial){const fi=fe.uniformsGroups;for(let wi=0,qp=fi.length;wi<qp;wi++){const Ur=fi[wi];Ye.update(Ur,Ri),Ye.bind(Ur,Ri)}}return Ri}function Lk(O,Z){O.ambientLightColor.needsUpdate=Z,O.lightProbe.needsUpdate=Z,O.directionalLights.needsUpdate=Z,O.directionalLightShadows.needsUpdate=Z,O.pointLights.needsUpdate=Z,O.pointLightShadows.needsUpdate=Z,O.spotLights.needsUpdate=Z,O.spotLightShadows.needsUpdate=Z,O.rectAreaLights.needsUpdate=Z,O.hemisphereLights.needsUpdate=Z}function Rk(O){return O.isMeshLambertMaterial||O.isMeshToonMaterial||O.isMeshPhongMaterial||O.isMeshStandardMaterial||O.isShadowMaterial||O.isShaderMaterial&&O.lights===!0}this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(O,Z,le){const fe=se.get(O);fe.__autoAllocateDepthBuffer=O.resolveDepthBuffer===!1,fe.__autoAllocateDepthBuffer===!1&&(fe.__useRenderToTexture=!1),se.get(O.texture).__webglTexture=Z,se.get(O.depthTexture).__webglTexture=fe.__autoAllocateDepthBuffer?void 0:le,fe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(O,Z){const le=se.get(O);le.__webglFramebuffer=Z,le.__useDefaultFramebuffer=Z===void 0};const kk=U.createFramebuffer();this.setRenderTarget=function(O,Z=0,le=0){I=O,D=Z,M=le;let fe=!0,ne=null,Ee=!1,Pe=!1;if(O){const Fe=se.get(O);if(Fe.__useDefaultFramebuffer!==void 0)Q.bindFramebuffer(U.FRAMEBUFFER,null),fe=!1;else if(Fe.__webglFramebuffer===void 0)J.setupRenderTarget(O);else if(Fe.__hasExternalTextures)J.rebindTextures(O,se.get(O.texture).__webglTexture,se.get(O.depthTexture).__webglTexture);else if(O.depthBuffer){const We=O.depthTexture;if(Fe.__boundDepthTexture!==We){if(We!==null&&se.has(We)&&(O.width!==We.image.width||O.height!==We.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");J.setupDepthRenderbuffer(O)}}const Xe=O.texture;(Xe.isData3DTexture||Xe.isDataArrayTexture||Xe.isCompressedArrayTexture)&&(Pe=!0);const qe=se.get(O).__webglFramebuffer;O.isWebGLCubeRenderTarget?(Array.isArray(qe[Z])?ne=qe[Z][le]:ne=qe[Z],Ee=!0):O.samples>0&&J.useMultisampledRTT(O)===!1?ne=se.get(O).__webglMultisampledFramebuffer:Array.isArray(qe)?ne=qe[le]:ne=qe,L.copy(O.viewport),E.copy(O.scissor),F=O.scissorTest}else L.copy(oe).multiplyScalar(Y).floor(),E.copy(pe).multiplyScalar(Y).floor(),F=ue;if(le!==0&&(ne=kk),Q.bindFramebuffer(U.FRAMEBUFFER,ne)&&fe&&Q.drawBuffers(O,ne),Q.viewport(L),Q.scissor(E),Q.setScissorTest(F),Ee){const Fe=se.get(O.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Fe.__webglTexture,le)}else if(Pe){const Fe=Z;for(let Xe=0;Xe<O.textures.length;Xe++){const qe=se.get(O.textures[Xe]);U.framebufferTextureLayer(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0+Xe,qe.__webglTexture,le,Fe)}}else if(O!==null&&le!==0){const Fe=se.get(O.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Fe.__webglTexture,le)}P=-1},this.readRenderTargetPixels=function(O,Z,le,fe,ne,Ee,Pe,Ne=0){if(!(O&&O.isWebGLRenderTarget)){Pt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Fe=se.get(O).__webglFramebuffer;if(O.isWebGLCubeRenderTarget&&Pe!==void 0&&(Fe=Fe[Pe]),Fe){Q.bindFramebuffer(U.FRAMEBUFFER,Fe);try{const Xe=O.textures[Ne],qe=Xe.format,We=Xe.type;if(!R.textureFormatReadable(qe)){Pt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(We)){Pt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Z>=0&&Z<=O.width-fe&&le>=0&&le<=O.height-ne&&(O.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+Ne),U.readPixels(Z,le,fe,ne,be.convert(qe),be.convert(We),Ee))}finally{const Xe=I!==null?se.get(I).__webglFramebuffer:null;Q.bindFramebuffer(U.FRAMEBUFFER,Xe)}}},this.readRenderTargetPixelsAsync=async function(O,Z,le,fe,ne,Ee,Pe,Ne=0){if(!(O&&O.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Fe=se.get(O).__webglFramebuffer;if(O.isWebGLCubeRenderTarget&&Pe!==void 0&&(Fe=Fe[Pe]),Fe)if(Z>=0&&Z<=O.width-fe&&le>=0&&le<=O.height-ne){Q.bindFramebuffer(U.FRAMEBUFFER,Fe);const Xe=O.textures[Ne],qe=Xe.format,We=Xe.type;if(!R.textureFormatReadable(qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(We))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const st=U.createBuffer();U.bindBuffer(U.PIXEL_PACK_BUFFER,st),U.bufferData(U.PIXEL_PACK_BUFFER,Ee.byteLength,U.STREAM_READ),O.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+Ne),U.readPixels(Z,le,fe,ne,be.convert(qe),be.convert(We),0);const gt=I!==null?se.get(I).__webglFramebuffer:null;Q.bindFramebuffer(U.FRAMEBUFFER,gt);const Dt=U.fenceSync(U.SYNC_GPU_COMMANDS_COMPLETE,0);return U.flush(),await W_(U,Dt,4),U.bindBuffer(U.PIXEL_PACK_BUFFER,st),U.getBufferSubData(U.PIXEL_PACK_BUFFER,0,Ee),U.deleteBuffer(st),U.deleteSync(Dt),Ee}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(O,Z=null,le=0){const fe=Math.pow(2,-le),ne=Math.floor(O.image.width*fe),Ee=Math.floor(O.image.height*fe),Pe=Z!==null?Z.x:0,Ne=Z!==null?Z.y:0;J.setTexture2D(O,0),U.copyTexSubImage2D(U.TEXTURE_2D,le,0,0,Pe,Ne,ne,Ee),Q.unbindTexture()};const Fk=U.createFramebuffer(),Ok=U.createFramebuffer();this.copyTextureToTexture=function(O,Z,le=null,fe=null,ne=0,Ee=null){Ee===null&&(ne!==0?(Xo("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Ee=ne,ne=0):Ee=0);let Pe,Ne,Fe,Xe,qe,We,st,gt,Dt;const Bt=O.isCompressedTexture?O.mipmaps[Ee]:O.image;if(le!==null)Pe=le.max.x-le.min.x,Ne=le.max.y-le.min.y,Fe=le.isBox3?le.max.z-le.min.z:1,Xe=le.min.x,qe=le.min.y,We=le.isBox3?le.min.z:0;else{const qi=Math.pow(2,-ne);Pe=Math.floor(Bt.width*qi),Ne=Math.floor(Bt.height*qi),O.isDataArrayTexture?Fe=Bt.depth:O.isData3DTexture?Fe=Math.floor(Bt.depth*qi):Fe=1,Xe=0,qe=0,We=0}fe!==null?(st=fe.x,gt=fe.y,Dt=fe.z):(st=0,gt=0,Dt=0);const bt=be.convert(Z.format),He=be.convert(Z.type);let wt;Z.isData3DTexture?(J.setTexture3D(Z,0),wt=U.TEXTURE_3D):Z.isDataArrayTexture||Z.isCompressedArrayTexture?(J.setTexture2DArray(Z,0),wt=U.TEXTURE_2D_ARRAY):(J.setTexture2D(Z,0),wt=U.TEXTURE_2D),U.pixelStorei(U.UNPACK_FLIP_Y_WEBGL,Z.flipY),U.pixelStorei(U.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Z.premultiplyAlpha),U.pixelStorei(U.UNPACK_ALIGNMENT,Z.unpackAlignment);const at=U.getParameter(U.UNPACK_ROW_LENGTH),Ri=U.getParameter(U.UNPACK_IMAGE_HEIGHT),Vo=U.getParameter(U.UNPACK_SKIP_PIXELS),ki=U.getParameter(U.UNPACK_SKIP_ROWS),fl=U.getParameter(U.UNPACK_SKIP_IMAGES);U.pixelStorei(U.UNPACK_ROW_LENGTH,Bt.width),U.pixelStorei(U.UNPACK_IMAGE_HEIGHT,Bt.height),U.pixelStorei(U.UNPACK_SKIP_PIXELS,Xe),U.pixelStorei(U.UNPACK_SKIP_ROWS,qe),U.pixelStorei(U.UNPACK_SKIP_IMAGES,We);const St=O.isDataArrayTexture||O.isData3DTexture,_i=Z.isDataArrayTexture||Z.isData3DTexture;if(O.isDepthTexture){const qi=se.get(O),fi=se.get(Z),wi=se.get(qi.__renderTarget),qp=se.get(fi.__renderTarget);Q.bindFramebuffer(U.READ_FRAMEBUFFER,wi.__webglFramebuffer),Q.bindFramebuffer(U.DRAW_FRAMEBUFFER,qp.__webglFramebuffer);for(let Ur=0;Ur<Fe;Ur++)St&&(U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,se.get(O).__webglTexture,ne,We+Ur),U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,se.get(Z).__webglTexture,Ee,Dt+Ur)),U.blitFramebuffer(Xe,qe,Pe,Ne,st,gt,Pe,Ne,U.DEPTH_BUFFER_BIT,U.NEAREST);Q.bindFramebuffer(U.READ_FRAMEBUFFER,null),Q.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else if(ne!==0||O.isRenderTargetTexture||se.has(O)){const qi=se.get(O),fi=se.get(Z);Q.bindFramebuffer(U.READ_FRAMEBUFFER,Fk),Q.bindFramebuffer(U.DRAW_FRAMEBUFFER,Ok);for(let wi=0;wi<Fe;wi++)St?U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,qi.__webglTexture,ne,We+wi):U.framebufferTexture2D(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,qi.__webglTexture,ne),_i?U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,fi.__webglTexture,Ee,Dt+wi):U.framebufferTexture2D(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,fi.__webglTexture,Ee),ne!==0?U.blitFramebuffer(Xe,qe,Pe,Ne,st,gt,Pe,Ne,U.COLOR_BUFFER_BIT,U.NEAREST):_i?U.copyTexSubImage3D(wt,Ee,st,gt,Dt+wi,Xe,qe,Pe,Ne):U.copyTexSubImage2D(wt,Ee,st,gt,Xe,qe,Pe,Ne);Q.bindFramebuffer(U.READ_FRAMEBUFFER,null),Q.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else _i?O.isDataTexture||O.isData3DTexture?U.texSubImage3D(wt,Ee,st,gt,Dt,Pe,Ne,Fe,bt,He,Bt.data):Z.isCompressedArrayTexture?U.compressedTexSubImage3D(wt,Ee,st,gt,Dt,Pe,Ne,Fe,bt,Bt.data):U.texSubImage3D(wt,Ee,st,gt,Dt,Pe,Ne,Fe,bt,He,Bt):O.isDataTexture?U.texSubImage2D(U.TEXTURE_2D,Ee,st,gt,Pe,Ne,bt,He,Bt.data):O.isCompressedTexture?U.compressedTexSubImage2D(U.TEXTURE_2D,Ee,st,gt,Bt.width,Bt.height,bt,Bt.data):U.texSubImage2D(U.TEXTURE_2D,Ee,st,gt,Pe,Ne,bt,He,Bt);U.pixelStorei(U.UNPACK_ROW_LENGTH,at),U.pixelStorei(U.UNPACK_IMAGE_HEIGHT,Ri),U.pixelStorei(U.UNPACK_SKIP_PIXELS,Vo),U.pixelStorei(U.UNPACK_SKIP_ROWS,ki),U.pixelStorei(U.UNPACK_SKIP_IMAGES,fl),Ee===0&&Z.generateMipmaps&&U.generateMipmap(wt),Q.unbindTexture()},this.initRenderTarget=function(O){se.get(O).__webglFramebuffer===void 0&&J.setupRenderTarget(O)},this.initTexture=function(O){O.isCubeTexture?J.setTextureCube(O,0):O.isData3DTexture?J.setTexture3D(O,0):O.isDataArrayTexture||O.isCompressedArrayTexture?J.setTexture2DArray(O,0):J.setTexture2D(O,0),Q.unbindTexture()},this.resetState=function(){D=0,M=0,I=null,Q.reset(),ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return mn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=ot._getDrawingBufferColorSpace(e),t.unpackColorSpace=ot._getUnpackColorSpace()}}const Pm=.9;class L1{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new P1({alpha:!0,premultipliedAlpha:!1,stencil:!0}),this.renderer.setClearColor(0,0),this.renderer.setSize(e,t),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=cg,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=Ci,this.renderer.toneMappingExposure=Pm,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const Lm={type:"change"},vu={type:"start"},Rm={type:"end"},Kl=new v.Ray,km=new v.Plane,R1=Math.cos(70*v.MathUtils.DEG2RAD),Ot=new v.Vector3,k1=new v.Vector3,F1=new v.Vector3,O1=new v.Vector3(0,1,0),U1=new v.Vector3(1,0,0),N1=new v.Vector3(0,0,1),Ai=.25*Math.PI,ft={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},$l=1e-6;let z1=class extends v.Controls{constructor(e,t,i=null){super(t,i),this.engine=e,this.state=ft.NONE,this.target=new v.Vector3,this.cursor=new v.Vector3,this.origin=new v.Vector3(0,0,0),this.showOriginIcon=!0,this.originPosition={x:0,y:0},this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.polarSafetyAngle=v.MathUtils.degToRad(5),this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.perspectiveWheelZoomBoost=5,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:v.MOUSE.ROTATE,MIDDLE:v.MOUSE.DOLLY,RIGHT:v.MOUSE.PAN},this.touches={ONE:v.TOUCH.ROTATE,TWO:v.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new v.Vector3,this._lastQuaternion=new v.Quaternion,this._lastTargetPosition=new v.Vector3,this._quat=new v.Quaternion().setFromUnitVectors(t.up,new v.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new v.Spherical,this._sphericalDelta=new v.Spherical,this._scale=1,this._panOffset=new v.Vector3,this._rotateStart=new v.Vector2,this._rotateEnd=new v.Vector2,this._rotateDelta=new v.Vector2,this._panStart=new v.Vector2,this._panEnd=new v.Vector2,this._panDelta=new v.Vector2,this._dollyStart=new v.Vector2,this._dollyEnd=new v.Vector2,this._dollyDelta=new v.Vector2,this._dollyDirection=new v.Vector3,this._mouse=new v.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=V1.bind(this),this._onPointerDown=G1.bind(this),this._onPointerUp=Q1.bind(this),this._onContextMenu=K1.bind(this),this._onMouseWheel=H1.bind(this),this._onKeyDown=X1.bind(this),this._onTouchStart=q1.bind(this),this._onTouchMove=Y1.bind(this),this._onMouseDown=j1.bind(this),this._onMouseMove=W1.bind(this),this._interceptControlDown=$1.bind(this),this._interceptControlUp=J1.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Lm),this.update(),this.state=ft.NONE}update(e=null){this.engine&&this.engine.interactionManager&&this.engine.interactionManager.origin&&this.origin.copy(this.engine.interactionManager.origin);const t=this.object.position;Ot.copy(t).sub(this.target),Ot.applyQuaternion(this._quat),this._spherical.setFromVector3(Ot),this.autoRotate&&this.state===ft.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=Ai:i>Math.PI&&(i-=Ai),s<-Math.PI?s+=Ai:s>Math.PI&&(s-=Ai),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),this.engine&&this.engine.deviceType==="PC"){const o=new v.Vector3;if(o.copy(this.origin).sub(this.target),o.lengthSq()>1e-4&&(this._sphericalDelta.theta!==0||this._sphericalDelta.phi!==0)){const l=this.enableDamping?this.dampingFactor*3:1,c=O1,h=k1;this.object.getWorldDirection(h);const d=Math.abs(h.y)>.999?U1:c,f=F1;f.crossVectors(h,d),f.lengthSq()<$l&&f.crossVectors(h,N1),f.normalize();const u=new v.Vector3().copy(this.object.position).sub(this.origin);u.applyAxisAngle(c,Math.PI*this._sphericalDelta.theta*l),u.applyAxisAngle(f,Math.PI*this._sphericalDelta.phi*l),t.copy(this.origin).add(u);const g=new v.Vector3().copy(this.target).sub(this.origin);g.applyAxisAngle(c,Math.PI*this._sphericalDelta.theta*l),g.applyAxisAngle(f,Math.PI*this._sphericalDelta.phi*l),this.target.copy(this.origin).add(g)}else t.copy(this.target).add(Ot);this.object.lookAt(this.target)}else t.copy(this.target).add(Ot),this.object.lookAt(this.target);if(this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Ot.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new v.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new v.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Ot.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Kl.origin.copy(this.object.position),Kl.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Kl.direction))<R1?this.object.lookAt(this.target):(km.setFromNormalAndCoplanarPoint(this.object.up,this.target),Kl.intersectPlane(km,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>$l||8*(1-this._lastQuaternion.dot(this.object.quaternion))>$l||this._lastTargetPosition.distanceToSquared(this.target)>$l?(this.dispatchEvent(Lm),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ai/60*this.autoRotateSpeed*e:Ai/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){this.screenSpacePanning===!0?Ot.setFromMatrixColumn(t,1):(Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot)),Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ot.copy(s).sub(this.target);let r=Ot.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,o=i.width,a=i.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ai*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ai*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ai*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ai*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new v.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}};function G1(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n)))}function V1(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function Q1(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Rm),this.state=ft.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function j1(n){if(this.showOriginIcon&&this.engine&&this.engine.ToolUntils){const t=this.engine.scene?.camera||this.object;this.originPosition=this.engine.ToolUntils.WorldPointToScreenPoint(this.origin.clone(),t),console.log("Origin position:",this.originPosition,"Origin:",this.origin)}let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case v.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=ft.DOLLY;break;case v.MOUSE.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=ft.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=ft.ROTATE}break;case v.MOUSE.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=ft.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=ft.PAN}break;default:this.state=ft.NONE}this.state!==ft.NONE&&this.dispatchEvent(vu)}function W1(n){switch(this.state){case ft.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case ft.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case ft.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function H1(n){this.enabled===!1||this.enableZoom===!1||this.state!==ft.NONE||(n.preventDefault(),this.dispatchEvent(vu),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(Rm))}function X1(n){this.enabled!==!1&&this._handleKeyDown(n)}function q1(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case v.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=ft.TOUCH_ROTATE;break;case v.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=ft.TOUCH_PAN;break;default:this.state=ft.NONE}break;case 2:switch(this.touches.TWO){case v.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=ft.TOUCH_DOLLY_PAN;break;case v.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=ft.TOUCH_DOLLY_ROTATE;break;default:this.state=ft.NONE}break;default:this.state=ft.NONE}this.state!==ft.NONE&&this.dispatchEvent(vu)}function Y1(n){switch(this._trackPointer(n),this.state){case ft.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case ft.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case ft.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case ft.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=ft.NONE}}function K1(n){this.enabled!==!1&&n.preventDefault()}function $1(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function J1(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Fm{constructor(e,t,i,s){this._Engine=e,this.camera=t,this.domElement=i,this._isEnabled=!1,this._rayOriginOffset=new w.Vector3(0,-1,0),this._camerLocalDirection=new w.Vector3,this._tmpVector=new w.Vector3,this._rayCaster=new w.Raycaster,this._fallingTime=0,this._isMouseInElement=!1,this._euler=new w.Euler(0,0,0,"YZX"),this._prevMouseX=0,this._prevMouseY=0,this.applyGravity=!1,this.gravityMinHeight=!0,this.applyCollision=!0,this.positionEasing=!0,this.lookflag=1,this.lookSpeed=.003,this.moveSpeed=.02,this.playerHeight=1.4,this.maxRotateX=3,this.g=9.8,this.bindmousedown=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchStart.bind(this):this.onMouseDown.bind(this),this.bindmouseup=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchEnd.bind(this):this.onMouseUp.bind(this),this.bindmousemove=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchMove.bind(this):this.onMouseMove.bind(this),this.bindonKeyDown=this.onKeyDown.bind(this),this.bindonKeyUp=this.onKeyUp.bind(this),this.bindMousewheel=this.onMousewheel.bind(this),this.bindMouseEnter=this.onMouseEnter.bind(this),this.bindMouseLeave=this.onMouseLeave.bind(this),this.needMousewheel=!1,this.moveWheelRun=!0,this.moveWheelStop=!1,this.wheelClock,this.keydown=!1,this.shiftDown=!1,this.gravityTestCount=5,this.catchTestCount=10,this.GetEngine=()=>e}set colliders(e){this._rayCastObjects=e}set enabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._euler.setFromQuaternion(this.camera.quaternion),e?this.addEvents():this.removeEvents())}get enabled(){return this._isEnabled}addEvents(){const e=this._Engine?.DeviceType,t=e==="PC"||!e;console.log("[FirstPersonCameraControl] addEvents - DeviceType:",e,"isPC:",t),t?(console.log("[FirstPersonCameraControl] 添加鼠标事件监听器 - mousedown, mouseup"),this.domElement.addEventListener("mousedown",this.bindmousedown,!1),this.domElement.addEventListener("mouseup",this.bindmouseup,!1)):(console.log("[FirstPersonCameraControl] 添加触摸事件监听器"),this.domElement.addEventListener("touchstart",this.bindmousedown,!1),this.domElement.addEventListener("touchend",this.bindmouseup,!1)),this.domElement.addEventListener("mouseenter",this.bindMouseEnter,!1),this.domElement.addEventListener("mouseleave",this.bindMouseLeave,!1),window.addEventListener("keydown",this.bindonKeyDown,!1),window.addEventListener("keyup",this.bindonKeyUp,!1),this.needMousewheel&&(document.addEventListener&&document.addEventListener("DOMMouseScroll",this.bindMousewheel,!1),window.addEventListener("mousewheel",this.bindMousewheel,!1))}removeEvents(){this._Engine&&this._Engine.deviceType!=="PC"?(this.domElement.removeEventListener("touchstart",this.bindmousedown),this.domElement.removeEventListener("touchend",this.bindmouseup),this.domElement.removeEventListener("touchmove",this.bindmousemove)):(this.domElement.removeEventListener("mousedown",this.bindmousedown),this.domElement.removeEventListener("mouseup",this.bindmouseup),this.domElement.removeEventListener("mousemove",this.bindmousemove)),this.domElement.removeEventListener("mouseenter",this.bindMouseEnter),this.domElement.removeEventListener("mouseleave",this.bindMouseLeave),window.removeEventListener("keydown",this.bindonKeyDown),window.removeEventListener("keyup",this.bindonKeyUp),this.needMousewheel&&(document.addEventListener&&document.removeEventListener("DOMMouseScroll",this.bindMousewheel),window.removeEventListener("mousewheel",this.bindMousewheel))}onMouseEnter(e){this._isMouseInElement=!0}onMouseLeave(e){this._isMouseInElement=!1}onMousewheel(e){let t;switch(e.wheelDelta?(e.wheelDelta>0&&(t="up"),e.wheelDelta<0&&(t="down")):e.detail&&(e.detail<0&&(t="up"),e.detail>0&&(t="down")),t){case"up":this._camerLocalDirection.z=1;break;case"down":this._camerLocalDirection.z=-1;break}this.moveWheelRun==!0?(this.moveWheelRun=!1,this.moveWheelStop=!0,this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},200)):(clearTimeout(this.wheelClock),this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},150))}onMouseDown(e){console.log("[FirstPersonCameraControl] onMouseDown 被调用",e),this.domElement.addEventListener("mousemove",this.bindmousemove,!1),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY}onMouseMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.screenX-this._prevMouseX:0,i=this._prevMouseY?e.screenY-this._prevMouseY:0,s=this._euler.x-i*this.lookflag*this.lookSpeed;s>=0?s<this.maxRotateX?this._euler.x=s:this._euler.x=this.maxRotateX:s>-this.maxRotateX?this._euler.x=s:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY;let r=this.GetEngine();r.movefirst=!0;var o=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(o)}onMouseUp(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("mousemove",this.bindmousemove)}onTouchStart(e){this.domElement.addEventListener("touchmove",this.bindmousemove,!1),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY}onTouchMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.targetTouches[0].clientX-this._prevMouseX:0,i=this._prevMouseY?e.targetTouches[0].clientY-this._prevMouseY:0,s=this._euler.x-i*this.lookflag*this.lookSpeed;s>=0?s<this.maxRotateX?this._euler.x=s:this._euler.x=this.maxRotateX:s>-this.maxRotateX?this._euler.x=s:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY;let r=this.GetEngine();r.movefirst=!0;var o=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(o)}onTouchEnd(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("touchmove",this.bindmousemove)}onKeyDown(e){if(!this._isMouseInElement)return;var t=new CustomEvent("bimengine:camerachange",{detail:""});let i=this.GetEngine();switch(i.movefirst=!0,window.dispatchEvent(t),e.keyCode){case 38:this.rotateY(-1);break;case 81:this.keydown=!0,this._camerLocalDirection.y=1;break;case 69:this._camerLocalDirection.y=-1;break;case 87:this._camerLocalDirection.z=1;break;case 37:this.rotateX(-1);break;case 65:this._camerLocalDirection.x=-1;break;case 40:this.rotateY(1);break;case 83:this._camerLocalDirection.z=-1;break;case 39:this.rotateX(1);break;case 68:this._camerLocalDirection.x=1;break;case 16:this.shiftDown=!0;break}}onKeyUp(e){if(!this._isMouseInElement)return;let t=this.GetEngine();switch(t.movefirst=!1,e.keyCode){case 38:case 87:this._camerLocalDirection.z=0;break;case 37:case 65:this._camerLocalDirection.x=0;break;case 40:case 83:this._camerLocalDirection.z=0;break;case 39:case 68:this._camerLocalDirection.x=0;break;case 81:case 69:this.keydown=!1,this._camerLocalDirection.y=0;break;case 16:this.shiftDown=!1;break}}rotateX(e){this._euler.y-=e*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler)}rotateY(e){let t=this._euler.x-e*this.lookflag*.5*this.lookSpeed;t>=0?t<this.maxRotateX?this._euler.x=t:this._euler.x=this.maxRotateX:t>-this.maxRotateX?this._euler.x=t:this._euler.x=-this.maxRotateX,this.camera.quaternion.setFromEuler(this._euler)}update(){this.keydown||this.gravityTest(),this.collisionTest()}gravityTest(){if(!(this._camerLocalDirection.y==0&&this._camerLocalDirection.z==0&&this._camerLocalDirection.x==0))if(this.applyGravity){let e=!0;this._fallingTime+=.01,this._tmpVector.set(0,-1,0);const t=this.hitTest();if(t==null)return;if(t){const i=t.point.add(new w.Vector3(0,this.playerHeight,0));if(this.positionEasing){if(i.y>=this.camera.position.y||i.y-this.camera.position.y<.2){this.setCameraHeight(this.camera.position.y+(i.y-this.camera.position.y)*.08),this._fallingTime=0,e=!1;return}}else t.distance<this.playerHeight&&(this.setCameraHeight(i.y),this._fallingTime=0,e=!1)}e&&this.setCameraHeight(this.camera.position.y-this.g*Math.pow(this._fallingTime,2))}else this.setCameraHeight(this.camera.position.y)}collisionTest(){this._camerLocalDirection.x!==0&&this.collisionTestX(),this._camerLocalDirection.z!==0&&this.collisionTestZ(),this._camerLocalDirection.y!==0&&this.collisionTestY()}collisionTestX(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.x),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed*(this.shiftDown?2:1))}collisionTestZ(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.crossVectors(this.camera.up,this._tmpVector),this._tmpVector.multiplyScalar(this._camerLocalDirection.z),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed*(this.shiftDown?2:1))}collisionTestY(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector=new w.Vector3(0,1,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.y),this.applyCollision){const i=this.hitTest();if(i&&i.distance<.3)return}let t=this.camera.position.clone().addScaledVector(this._tmpVector,this.moveSpeed*(this.shiftDown?2:1));this.setCameraHeight(t.y)}setCameraHeight(e){let t=this.getMinHeight();this.gravityMinHeight&&t!==void 0&&e<t?this.camera.position.y=t:this.camera.position.y=e}getMinHeight(){let e,t=this.GetEngine(),i=t.ToolUntils?t.ToolUntils.GetBoundingBox(t):null;return t&&i&&(e=i.min.y),e}hitTest(){const e=this.camera.position.clone().add(this._rayOriginOffset);this._rayCaster.ray.origin=e,this._rayCaster.ray.direction=this._tmpVector;let t=this.GetEngine();var i=t.scene.ground;i&&i.material.type;let s={},r=t.handelBehaved.handle_catch(this._rayCaster,s);if(r==null)return null;let o=r.object.name,a=r.object.url,l=t.models.find(c=>c.url==a);if(l!=null){let c=l.nodesMap.get(o);if(c.infos!=null&&c.infos.length!=0&&c.infos[0].name&&(c.infos[0].name.includes("门")||c.infos[0].name.includes("門")||c.infos[0].name.includes("door")))return null}return r}}function _u(n){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.handle_catch=function(p,m){return g(p,m,!0)},e.init=function(p,m){e.self!=null&&e.self.disActive!=null&&e.self.type!=p.type&&e.self.disActive(),e.self=p,m==null&&(m={showCatch:!1}),e.options=m,e.isClickSimpleModel=!0},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){n.renderer.domElement.addEventListener("mousedown",a),n.renderer.domElement.addEventListener("mouseup",c),n.renderer.domElement.addEventListener("mousemove",l),n.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),n.renderer.domElement.addEventListener("touchend",u,{passive:!1}),n.renderer.domElement.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",i)},e.disActive=function(){n.renderer.domElement.removeEventListener("mousedown",a),n.renderer.domElement.removeEventListener("mouseup",c),n.renderer.domElement.removeEventListener("mousemove",l),n.renderer.domElement.removeEventListener("touchstart",d),n.renderer.domElement.removeEventListener("touchend",u),n.renderer.domElement.removeEventListener("touchmove",f),window.removeEventListener("keydown",t),window.removeEventListener("keyup",i)};function t(p){(p.keyCode===8||p.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),p.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),p.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),p.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),p.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),p.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),p.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),p.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function i(p){p.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),p.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),p.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),p.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),p.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),p.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),p.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function s(p){const m=new w.Vector2,A=n.renderer.domElement.clientWidth,x=n.renderer.domElement.clientHeight;return m.x=p.offsetX/A*2-1,m.y=-(p.offsetY/x)*2+1,m}function r(p){const m=new w.Raycaster,A=s(p);return m.setFromCamera(A,n.camera),m}function o(p,m=!1,A=!1,x=!0){const b=r(p);if(p.raycaster=b,m){const y=g(b,p,A,x);p.catch=y}}function a(p){e.mouseDownTime=Date.now(),e.mouseDownPosition=new w.Vector3(p.offsetX,p.offsetY,0),e.self&&e.self.handleMouseDown!=null&&p.button==0&&(o(p,!0,!0),p.catch!=null&&(n.engineStatus.highlightModels==null||n.engineStatus.highlightModels.length==0)&&n.controlModule.orbitControls.origin.set(p.catch.point.x,p.catch.point.y,p.catch.point.z),e.self.handleMouseDown(p))}function l(p){e.self&&e.self.handleMouseMove!=null&&(n.engineStatus.isFree&&o(p,!0,!0,e.isClickSimpleModel),e.self.handleMouseMove(p))}function c(p){const m=Date.now(),A=m-e.mouseDownTime,x=new w.Vector3(p.offsetX,p.offsetY,0);e.self&&e.self.handleMouseUp!=null&&p.button==0&&(o(p,!1,!1,!1),e.self.handleMouseUp(p));const b=x.distanceTo(e.mouseDownPosition);if((A<100||b==0)&&e.self&&e.self.handleMouseClick!=null){o(p,!0,!0,!1);const y=m-e.lastClickTime;console.log(y),y<200?e.self.handleMouseDoubleClick!=null&&p.button==0&&e.self.handleMouseDoubleClick(p):e.self.handleMouseClick!=null&&p.button==0?e.self.handleMouseClick(p):e.self.handleRightMouseClick!=null&&p.button==2&&e.self.handleRightMouseClick(p),e.lastClickTime=Date.now()}}function h(p){const m=p.touches[0]||p.changedTouches[0];if(!m)return null;const x=n.renderer.domElement.getBoundingClientRect(),b=m.clientX-x.left,y=m.clientY-x.top;return{offsetX:b,offsetY:y,button:0,clientX:m.clientX,clientY:m.clientY,preventDefault:()=>p.preventDefault(),stopPropagation:()=>p.stopPropagation(),originalEvent:p}}function d(p){if(p.preventDefault(),p.touches.length!==1)return;const m=h(p);m&&a(m)}function f(p){if(p.preventDefault(),p.touches.length!==1)return;const m=h(p);m&&l(m)}function u(p){p.preventDefault();const m=h(p);m&&c(m)}function g(p,m,A=!1,x=!0){if(!n.engineStatus.isFree&&A==!1){n.hoverHighLight.clearHighlight();return}console.log("catch"),n.catchSvg.innerHTML="";let b=n.octreeBox.rayInterationModel(p,A,x);b=n.clipping?.filterIntersectionsByClipping(b)??b;let y=n.scene.children.filter(j=>j instanceof w.InstancedMesh);x&&(y=y.filter(j=>j.count<500));let _=p.intersectObjects(y,!1);if(_=n.clipping?.filterIntersectionsByClipping(_)??_,_.length>0&&(b.length==0||_[0].distance<b[0].distance)){let j=_[0].object;if(j.ids!=null&&j.ids.length!=0){let N=j.ids[_[0].instanceId],Y={object:{url:j.url,id:N,name:N,isInstance:!0},face:_[0].face,distance:_[0].distance,point:_[0].point,instanceId:_[0].instanceId,matrix:j.matrixs[_[0].instanceId]};b.splice(0,0,Y)}}if(b.length===0)return;let S=b[0].object.url,C=b[0].object.name,D=n.modelEdge.getModelEdge(S,C);D||(D=[0,0,[]]);let M=[];D[2].forEach(j=>{j[0]!=null&&j[1]!=null&&M.push({X:j[0].X*.5+j[1].X*.5,Y:j[0].Y*.5+j[1].Y*.5,Z:j[0].Z*.5+j[1].Z*.5})});let I=[...D[2].map(j=>j[0]),...M],P="face",T=[],L=[],E=10;if(I.forEach(j=>{if(j!=null){let N=new w.Vector3(j.X,j.Z,-j.Y);if(n.clipping&&!n.clipping.isPointInClippingRange(N))return;let Y=new lt(n.camera,n.renderer,n.scene).worldToScreen(N),V=Math.sqrt(Math.pow(Y.x-m.offsetX,2)+Math.pow(Y.y-m.offsetY,2));V<E&&(E=V,T.push({point:N,distance:V,pointxy:Y}))}}),T.length>0?(T.sort((j,N)=>j.distance-N.distance),P="point"):(D[2].forEach(j=>{if(j[0]!=null&&j[1]!=null){let N=new w.Vector3(j[0].X,j[0].Z,-j[0].Y),Y=new w.Vector3(j[1].X,j[1].Z,-j[1].Y),V=new lt(n.camera,n.renderer,n.scene).worldToScreen(N),H=new lt(n.camera,n.renderer,n.scene).worldToScreen(Y),oe=F(new w.Vector2(m.offsetX,m.offsetY),V,H);if(oe<E){let pe=z(new w.Vector2(m.offsetX,m.offsetY),V,H),ue=X(pe,N,Y);if(n.clipping&&!n.clipping.isPointInClippingRange(ue))return;L.push({distance:oe,point:ue,pointxy:new lt(n.camera,n.renderer,n.scene).worldToScreen(ue),start:V,end:H})}}}),L.length>0&&(L.sort((j,N)=>j.distance-N.distance),P="line")),P=="point"&&e.options.showCatch){const j=new lt(n.camera,n.renderer,n.scene).worldToScreen(T[0].point);n.catchSvg.innerHTML="";const N=j.x+n.reactBoundingClientRect.left,Y=j.y+n.reactBoundingClientRect.top;console.log(N,Y);const V=document.createElementNS("http://www.w3.org/2000/svg","polygon");V.setAttribute("class","catchPoint"),V.setAttribute("points",`${N},${Y-8} ${N-7},${Y+4} ${N+7},${Y+4}`),V.setAttribute("stroke","rgb(8, 223, 215)"),V.setAttribute("fill","transparent"),n.catchSvg.appendChild(V),b[0].point=T[0].point}else if(P=="line"&&e.options.showCatch){const j=new lt(n.camera,n.renderer,n.scene).worldToScreen(L[0].point),N=L[0].start,Y=L[0].end;n.catchSvg.innerHTML="";const V=document.createElementNS("http://www.w3.org/2000/svg","line");V.setAttribute("class","catchLine"),V.setAttribute("x1",(N.x+n.reactBoundingClientRect.left).toString()),V.setAttribute("y1",(N.y+n.reactBoundingClientRect.top).toString()),V.setAttribute("x2",(Y.x+n.reactBoundingClientRect.left).toString()),V.setAttribute("y2",(Y.y+n.reactBoundingClientRect.top).toString()),V.setAttribute("stroke","rgb(8, 223, 215)"),V.setAttribute("stroke-width","2"),n.catchSvg.appendChild(V);const H=j.x+n.reactBoundingClientRect.left,oe=j.y+n.reactBoundingClientRect.top,pe=document.createElementNS("http://www.w3.org/2000/svg","polygon");pe.setAttribute("class","catchPoint"),pe.setAttribute("points",`${H},${oe-8} ${H-7},${oe+4} ${H+7},${oe+4}`),pe.setAttribute("stroke","rgb(8, 223, 215)"),pe.setAttribute("fill","transparent"),n.catchSvg.appendChild(pe),b[0].point=L[0].point}else if(P=="face"&&e.options.showCatch){let j=b[0].point.clone(),N=b[0].normal||(b[0].face?b[0].face.normal:null);const Y=(N?N.clone():new w.Vector3(0,0,1)).normalize(),V=Math.abs(Y.y)<.9?new w.Vector3(0,1,0):new w.Vector3(1,0,0),H=new w.Vector3().crossVectors(Y,V).normalize(),oe=new w.Vector3().crossVectors(Y,H).normalize(),pe=20,ue=new lt(n.camera,n.renderer,n.scene),re=ue.worldToScreen(j),de=ue.worldToScreen(new w.Vector3().copy(j).add(H)),Ae=Math.sqrt((de.x-re.x)**2+(de.y-re.y)**2),ye=Ae>0?pe/Ae:.2,nt=[new w.Vector3().copy(H).add(oe).multiplyScalar(ye),new w.Vector3().copy(H).sub(oe).multiplyScalar(ye),new w.Vector3().copy(H).multiplyScalar(-1).sub(oe).multiplyScalar(ye),new w.Vector3().copy(H).multiplyScalar(-1).add(oe).multiplyScalar(ye)].map(B=>new w.Vector3().copy(j).add(B)).map(B=>new lt(n.camera,n.renderer,n.scene).worldToScreen(B));n.catchSvg.innerHTML="";const Ge=document.createElementNS("http://www.w3.org/2000/svg","polygon");Ge.setAttribute("class","catchFace"),Ge.setAttribute("points",nt.map(B=>`${B.x+n.reactBoundingClientRect.left},${B.y+n.reactBoundingClientRect.top}`).join(" ")),Ge.setAttribute("fill","rgba(1, 238, 255, 0.2)"),Ge.setAttribute("stroke","rgb(0, 255, 247)"),Ge.setAttribute("stroke-width","1"),n.catchSvg.appendChild(Ge)}return b[0];function F(j,N,Y){const V=new w.Vector2().subVectors(Y,N),H=V.lengthSq();if(H<1e-10)return j.distanceTo(N);const oe=new w.Vector2().subVectors(j,N),pe=w.MathUtils.clamp(oe.dot(V)/H,0,1),ue=new w.Vector2().copy(V).multiplyScalar(pe).add(N);return j.distanceTo(ue)}function z(j,N,Y){const V=new w.Vector2().subVectors(Y,N),H=V.lengthSq();if(H<1e-10)return 0;const oe=new w.Vector2().subVectors(j,N);return w.MathUtils.clamp(oe.dot(V)/H,0,1)}function X(j,N,Y){const V=w.MathUtils.clamp(j,0,1);return new w.Vector3().lerpVectors(N,Y,V)}}return e}class Z1{engine;orbitControls;firstPersonControls;isActive=!0;originDiv=null;handelBehaved;isDragging=!1;isDown=!1;containerOffset={left:0,top:0};constructor(e){this.engine=e,this.init(),this.handelBehaved=_u(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new z1(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new Fm(this.engine,this.engine.camera,this.engine.renderer.domElement);const e=document.createElement("div");this.originDiv=e,e.className="originDiv",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.width="30px",e.style.height="30px",e.style.borderRadius="50%",e.style.pointerEvents="none",e.style.backgroundImage="url(/assets/svg/rotate-orbit.svg)",this.engine.container.appendChild(this.originDiv)}active(){this.isActive=!0,this.orbitControls.enabled=!0}disActive(){this.isActive=!1,this.orbitControls.enabled=!1}setMoveSpeed(e){this.firstPersonControls.moveSpeed=e*.1}getMoveSpeed(){return this.firstPersonControls.moveSpeed*10}setApplyCollision(e){this.firstPersonControls.applyCollision=e}getApplyCollision(){return this.firstPersonControls.applyCollision}setApplyGravity(e){this.firstPersonControls.applyGravity=e}getApplyGravity(){return this.firstPersonControls.applyGravity}toggleMinMap(){this.engine.minMap.toggle()}switchFirstPersonMode(){this.engine.cameraModule.switchToPerspectiveCamera(),this.firstPersonControls=new Fm(this.engine,this.engine.camera,this.engine.renderer.domElement,[]),this.orbitControls.enabled=!1,this.firstPersonControls.enabled=!0,this.firstPersonControls.isActive=!0,this.engine.worldToScreen=new lt(this.engine.camera,this.engine.renderer,this.engine.scene)}switchDefaultMode(){if(this.firstPersonControls){this.firstPersonControls.enabled=!1;const e=this.engine.camera,t=new w.Vector3;e.getWorldDirection(t),this.orbitControls.target.copy(e.position).add(t.multiplyScalar(10)),this.orbitControls.update()}this.orbitControls.enabled=!0,this.engine.worldToScreen=new lt(this.engine.camera,this.engine.renderer,this.engine.scene)}handleMouseUp(e){this.isDragging=!1,this.isDown=!1}handleMouseMove(e){this.isDown?this.isDragging=!0:this.isDragging=!1}handleMouseDown(e){this.isDown=!0}handleMouseClick(e){this.isDragging=!1,this.isDown=!1}update(){if(this.firstPersonControls.enabled&&this.firstPersonControls.update(),this.orbitControls.enabled){const e=this.engine.controlModule.orbitControls.origin,i=this.engine.worldToScreen.worldToScreen(e);this.originDiv&&this.isDragging?(this.originDiv.style.left=i.x-15+this.engine.reactBoundingClientRect.left+"px",this.originDiv.style.top=i.y-15+this.engine.reactBoundingClientRect.top+"px",this.originDiv.style.display="block"):this.originDiv&&(this.originDiv.style.display="none")}}}const rr={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
3947
|
+
}`;class C1{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new im(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Wn({vertexShader:w1,fragmentShader:S1,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ys(new jl(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class M1 extends Hr{constructor(e,t){super();const i=this;let s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,d=null,f=null,u=null,g=null;const p=typeof XRWebGLBinding<"u",m=new C1,A={},x=t.getContextAttributes();let b=null,y=null;const _=[],S=[],C=new dt;let D=null;const M=new en;M.viewport=new Lt;const I=new en;I.viewport=new Lt;const P=[M,I],T=new Cw;let L=null,E=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(re){let de=_[re];return de===void 0&&(de=new fu,_[re]=de),de.getTargetRaySpace()},this.getControllerGrip=function(re){let de=_[re];return de===void 0&&(de=new fu,_[re]=de),de.getGripSpace()},this.getHand=function(re){let de=_[re];return de===void 0&&(de=new fu,_[re]=de),de.getHandSpace()};function F(re){const de=S.indexOf(re.inputSource);if(de===-1)return;const Ae=_[de];Ae!==void 0&&(Ae.update(re.inputSource,re.frame,c||o),Ae.dispatchEvent({type:re.type,data:re.inputSource}))}function z(){s.removeEventListener("select",F),s.removeEventListener("selectstart",F),s.removeEventListener("selectend",F),s.removeEventListener("squeeze",F),s.removeEventListener("squeezestart",F),s.removeEventListener("squeezeend",F),s.removeEventListener("end",z),s.removeEventListener("inputsourceschange",X);for(let re=0;re<_.length;re++){const de=S[re];de!==null&&(S[re]=null,_[re].disconnect(de))}L=null,E=null,m.reset();for(const re in A)delete A[re];e.setRenderTarget(b),u=null,f=null,d=null,s=null,y=null,ue.stop(),i.isPresenting=!1,e.setPixelRatio(D),e.setSize(C.width,C.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(re){r=re,i.isPresenting===!0&&$e("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(re){a=re,i.isPresenting===!0&&$e("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(re){c=re},this.getBaseLayer=function(){return f!==null?f:u},this.getBinding=function(){return d===null&&p&&(d=new XRWebGLBinding(s,t)),d},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(re){if(s=re,s!==null){if(b=e.getRenderTarget(),s.addEventListener("select",F),s.addEventListener("selectstart",F),s.addEventListener("selectend",F),s.addEventListener("squeeze",F),s.addEventListener("squeezestart",F),s.addEventListener("squeezeend",F),s.addEventListener("end",z),s.addEventListener("inputsourceschange",X),x.xrCompatible!==!0&&await t.makeXRCompatible(),D=e.getPixelRatio(),e.getSize(C),p&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ae=null,ye=null,Me=null;x.depth&&(Me=x.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Ae=x.stencil?Ho:Wo,ye=x.stencil?jo:Xs);const Oe={colorFormat:t.RGBA8,depthFormat:Me,scaleFactor:r};d=this.getBinding(),f=d.createProjectionLayer(Oe),s.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),y=new qs(f.textureWidth,f.textureHeight,{format:Yi,type:On,depthTexture:new tm(f.textureWidth,f.textureHeight,ye,void 0,void 0,void 0,void 0,void 0,void 0,Ae),stencilBuffer:x.stencil,colorSpace:e.outputColorSpace,samples:x.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{const Ae={antialias:x.antialias,alpha:!0,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(s,t,Ae),s.updateRenderState({baseLayer:u}),e.setPixelRatio(1),e.setSize(u.framebufferWidth,u.framebufferHeight,!1),y=new qs(u.framebufferWidth,u.framebufferHeight,{format:Yi,type:On,colorSpace:e.outputColorSpace,stencilBuffer:x.stencil,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await s.requestReferenceSpace(a),ue.setContext(s),ue.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function X(re){for(let de=0;de<re.removed.length;de++){const Ae=re.removed[de],ye=S.indexOf(Ae);ye>=0&&(S[ye]=null,_[ye].disconnect(Ae))}for(let de=0;de<re.added.length;de++){const Ae=re.added[de];let ye=S.indexOf(Ae);if(ye===-1){for(let Oe=0;Oe<_.length;Oe++)if(Oe>=S.length){S.push(Ae),ye=Oe;break}else if(S[Oe]===null){S[Oe]=Ae,ye=Oe;break}if(ye===-1)break}const Me=_[ye];Me&&Me.connect(Ae)}}const j=new ge,N=new ge;function Y(re,de,Ae){j.setFromMatrixPosition(de.matrixWorld),N.setFromMatrixPosition(Ae.matrixWorld);const ye=j.distanceTo(N),Me=de.projectionMatrix.elements,Oe=Ae.projectionMatrix.elements,nt=Me[14]/(Me[10]-1),Ge=Me[14]/(Me[10]+1),B=(Me[9]+1)/Me[5],ae=(Me[9]-1)/Me[5],ie=(Me[8]-1)/Me[0],W=(Oe[8]+1)/Oe[0],G=nt*ie,K=nt*W,me=ye/(-ie+W),U=me*-ie;if(de.matrixWorld.decompose(re.position,re.quaternion,re.scale),re.translateX(U),re.translateZ(me),re.matrixWorld.compose(re.position,re.quaternion,re.scale),re.matrixWorldInverse.copy(re.matrixWorld).invert(),Me[10]===-1)re.projectionMatrix.copy(de.projectionMatrix),re.projectionMatrixInverse.copy(de.projectionMatrixInverse);else{const te=nt+me,k=Ge+me,R=G-U,Q=K+(ye-U),ee=B*Ge/k*te,se=ae*Ge/k*te;re.projectionMatrix.makePerspective(R,Q,ee,se,te,k),re.projectionMatrixInverse.copy(re.projectionMatrix).invert()}}function V(re,de){de===null?re.matrixWorld.copy(re.matrix):re.matrixWorld.multiplyMatrices(de.matrixWorld,re.matrix),re.matrixWorldInverse.copy(re.matrixWorld).invert()}this.updateCamera=function(re){if(s===null)return;let de=re.near,Ae=re.far;m.texture!==null&&(m.depthNear>0&&(de=m.depthNear),m.depthFar>0&&(Ae=m.depthFar)),T.near=I.near=M.near=de,T.far=I.far=M.far=Ae,(L!==T.near||E!==T.far)&&(s.updateRenderState({depthNear:T.near,depthFar:T.far}),L=T.near,E=T.far),T.layers.mask=re.layers.mask|6,M.layers.mask=T.layers.mask&3,I.layers.mask=T.layers.mask&5;const ye=re.parent,Me=T.cameras;V(T,ye);for(let Oe=0;Oe<Me.length;Oe++)V(Me[Oe],ye);Me.length===2?Y(T,M,I):T.projectionMatrix.copy(M.projectionMatrix),H(re,T,ye)};function H(re,de,Ae){Ae===null?re.matrix.copy(de.matrixWorld):(re.matrix.copy(Ae.matrixWorld),re.matrix.invert(),re.matrix.multiply(de.matrixWorld)),re.matrix.decompose(re.position,re.quaternion,re.scale),re.updateMatrixWorld(!0),re.projectionMatrix.copy(de.projectionMatrix),re.projectionMatrixInverse.copy(de.projectionMatrixInverse),re.isPerspectiveCamera&&(re.fov=Qd*2*Math.atan(1/re.projectionMatrix.elements[5]),re.zoom=1)}this.getCamera=function(){return T},this.getFoveation=function(){if(!(f===null&&u===null))return l},this.setFoveation=function(re){l=re,f!==null&&(f.fixedFoveation=re),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=re)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(T)},this.getCameraTexture=function(re){return A[re]};let oe=null;function pe(re,de){if(h=de.getViewerPose(c||o),g=de,h!==null){const Ae=h.views;u!==null&&(e.setRenderTargetFramebuffer(y,u.framebuffer),e.setRenderTarget(y));let ye=!1;Ae.length!==T.cameras.length&&(T.cameras.length=0,ye=!0);for(let Ge=0;Ge<Ae.length;Ge++){const B=Ae[Ge];let ae=null;if(u!==null)ae=u.getViewport(B);else{const W=d.getViewSubImage(f,B);ae=W.viewport,Ge===0&&(e.setRenderTargetTextures(y,W.colorTexture,W.depthStencilTexture),e.setRenderTarget(y))}let ie=P[Ge];ie===void 0&&(ie=new en,ie.layers.enable(Ge),ie.viewport=new Lt,P[Ge]=ie),ie.matrix.fromArray(B.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray(B.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set(ae.x,ae.y,ae.width,ae.height),Ge===0&&(T.matrix.copy(ie.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale)),ye===!0&&T.cameras.push(ie)}const Me=s.enabledFeatures;if(Me&&Me.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&p){d=i.getBinding();const Ge=d.getDepthInformation(Ae[0]);Ge&&Ge.isValid&&Ge.texture&&m.init(Ge,s.renderState)}if(Me&&Me.includes("camera-access")&&p){e.state.unbindTexture(),d=i.getBinding();for(let Ge=0;Ge<Ae.length;Ge++){const B=Ae[Ge].camera;if(B){let ae=A[B];ae||(ae=new im,A[B]=ae);const ie=d.getCameraImage(B);ae.sourceTexture=ie}}}}for(let Ae=0;Ae<_.length;Ae++){const ye=S[Ae],Me=_[Ae];ye!==null&&Me!==void 0&&Me.update(ye,de,c||o)}oe&&oe(re,de),de.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:de}),g=null}const ue=new sm;ue.setAnimationLoop(pe),this.setAnimationLoop=function(re){oe=re},this.dispose=function(){}}}const sr=new $s,E1=new zt;function I1(n,e){function t(m,A){m.matrixAutoUpdate===!0&&m.updateMatrix(),A.value.copy(m.matrix)}function i(m,A){A.color.getRGB(m.fogColor.value,Yg(n)),A.isFog?(m.fogNear.value=A.near,m.fogFar.value=A.far):A.isFogExp2&&(m.fogDensity.value=A.density)}function s(m,A,x,b,y){A.isMeshBasicMaterial||A.isMeshLambertMaterial?r(m,A):A.isMeshToonMaterial?(r(m,A),d(m,A)):A.isMeshPhongMaterial?(r(m,A),h(m,A)):A.isMeshStandardMaterial?(r(m,A),f(m,A),A.isMeshPhysicalMaterial&&u(m,A,y)):A.isMeshMatcapMaterial?(r(m,A),g(m,A)):A.isMeshDepthMaterial?r(m,A):A.isMeshDistanceMaterial?(r(m,A),p(m,A)):A.isMeshNormalMaterial?r(m,A):A.isLineBasicMaterial?(o(m,A),A.isLineDashedMaterial&&a(m,A)):A.isPointsMaterial?l(m,A,x,b):A.isSpriteMaterial?c(m,A):A.isShadowMaterial?(m.color.value.copy(A.color),m.opacity.value=A.opacity):A.isShaderMaterial&&(A.uniformsNeedUpdate=!1)}function r(m,A){m.opacity.value=A.opacity,A.color&&m.diffuse.value.copy(A.color),A.emissive&&m.emissive.value.copy(A.emissive).multiplyScalar(A.emissiveIntensity),A.map&&(m.map.value=A.map,t(A.map,m.mapTransform)),A.alphaMap&&(m.alphaMap.value=A.alphaMap,t(A.alphaMap,m.alphaMapTransform)),A.bumpMap&&(m.bumpMap.value=A.bumpMap,t(A.bumpMap,m.bumpMapTransform),m.bumpScale.value=A.bumpScale,A.side===gi&&(m.bumpScale.value*=-1)),A.normalMap&&(m.normalMap.value=A.normalMap,t(A.normalMap,m.normalMapTransform),m.normalScale.value.copy(A.normalScale),A.side===gi&&m.normalScale.value.negate()),A.displacementMap&&(m.displacementMap.value=A.displacementMap,t(A.displacementMap,m.displacementMapTransform),m.displacementScale.value=A.displacementScale,m.displacementBias.value=A.displacementBias),A.emissiveMap&&(m.emissiveMap.value=A.emissiveMap,t(A.emissiveMap,m.emissiveMapTransform)),A.specularMap&&(m.specularMap.value=A.specularMap,t(A.specularMap,m.specularMapTransform)),A.alphaTest>0&&(m.alphaTest.value=A.alphaTest);const x=e.get(A),b=x.envMap,y=x.envMapRotation;b&&(m.envMap.value=b,sr.copy(y),sr.x*=-1,sr.y*=-1,sr.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(sr.y*=-1,sr.z*=-1),m.envMapRotation.value.setFromMatrix4(E1.makeRotationFromEuler(sr)),m.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=A.reflectivity,m.ior.value=A.ior,m.refractionRatio.value=A.refractionRatio),A.lightMap&&(m.lightMap.value=A.lightMap,m.lightMapIntensity.value=A.lightMapIntensity,t(A.lightMap,m.lightMapTransform)),A.aoMap&&(m.aoMap.value=A.aoMap,m.aoMapIntensity.value=A.aoMapIntensity,t(A.aoMap,m.aoMapTransform))}function o(m,A){m.diffuse.value.copy(A.color),m.opacity.value=A.opacity,A.map&&(m.map.value=A.map,t(A.map,m.mapTransform))}function a(m,A){m.dashSize.value=A.dashSize,m.totalSize.value=A.dashSize+A.gapSize,m.scale.value=A.scale}function l(m,A,x,b){m.diffuse.value.copy(A.color),m.opacity.value=A.opacity,m.size.value=A.size*x,m.scale.value=b*.5,A.map&&(m.map.value=A.map,t(A.map,m.uvTransform)),A.alphaMap&&(m.alphaMap.value=A.alphaMap,t(A.alphaMap,m.alphaMapTransform)),A.alphaTest>0&&(m.alphaTest.value=A.alphaTest)}function c(m,A){m.diffuse.value.copy(A.color),m.opacity.value=A.opacity,m.rotation.value=A.rotation,A.map&&(m.map.value=A.map,t(A.map,m.mapTransform)),A.alphaMap&&(m.alphaMap.value=A.alphaMap,t(A.alphaMap,m.alphaMapTransform)),A.alphaTest>0&&(m.alphaTest.value=A.alphaTest)}function h(m,A){m.specular.value.copy(A.specular),m.shininess.value=Math.max(A.shininess,1e-4)}function d(m,A){A.gradientMap&&(m.gradientMap.value=A.gradientMap)}function f(m,A){m.metalness.value=A.metalness,A.metalnessMap&&(m.metalnessMap.value=A.metalnessMap,t(A.metalnessMap,m.metalnessMapTransform)),m.roughness.value=A.roughness,A.roughnessMap&&(m.roughnessMap.value=A.roughnessMap,t(A.roughnessMap,m.roughnessMapTransform)),A.envMap&&(m.envMapIntensity.value=A.envMapIntensity)}function u(m,A,x){m.ior.value=A.ior,A.sheen>0&&(m.sheenColor.value.copy(A.sheenColor).multiplyScalar(A.sheen),m.sheenRoughness.value=A.sheenRoughness,A.sheenColorMap&&(m.sheenColorMap.value=A.sheenColorMap,t(A.sheenColorMap,m.sheenColorMapTransform)),A.sheenRoughnessMap&&(m.sheenRoughnessMap.value=A.sheenRoughnessMap,t(A.sheenRoughnessMap,m.sheenRoughnessMapTransform))),A.clearcoat>0&&(m.clearcoat.value=A.clearcoat,m.clearcoatRoughness.value=A.clearcoatRoughness,A.clearcoatMap&&(m.clearcoatMap.value=A.clearcoatMap,t(A.clearcoatMap,m.clearcoatMapTransform)),A.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=A.clearcoatRoughnessMap,t(A.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),A.clearcoatNormalMap&&(m.clearcoatNormalMap.value=A.clearcoatNormalMap,t(A.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(A.clearcoatNormalScale),A.side===gi&&m.clearcoatNormalScale.value.negate())),A.dispersion>0&&(m.dispersion.value=A.dispersion),A.iridescence>0&&(m.iridescence.value=A.iridescence,m.iridescenceIOR.value=A.iridescenceIOR,m.iridescenceThicknessMinimum.value=A.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=A.iridescenceThicknessRange[1],A.iridescenceMap&&(m.iridescenceMap.value=A.iridescenceMap,t(A.iridescenceMap,m.iridescenceMapTransform)),A.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=A.iridescenceThicknessMap,t(A.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),A.transmission>0&&(m.transmission.value=A.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),A.transmissionMap&&(m.transmissionMap.value=A.transmissionMap,t(A.transmissionMap,m.transmissionMapTransform)),m.thickness.value=A.thickness,A.thicknessMap&&(m.thicknessMap.value=A.thicknessMap,t(A.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=A.attenuationDistance,m.attenuationColor.value.copy(A.attenuationColor)),A.anisotropy>0&&(m.anisotropyVector.value.set(A.anisotropy*Math.cos(A.anisotropyRotation),A.anisotropy*Math.sin(A.anisotropyRotation)),A.anisotropyMap&&(m.anisotropyMap.value=A.anisotropyMap,t(A.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=A.specularIntensity,m.specularColor.value.copy(A.specularColor),A.specularColorMap&&(m.specularColorMap.value=A.specularColorMap,t(A.specularColorMap,m.specularColorMapTransform)),A.specularIntensityMap&&(m.specularIntensityMap.value=A.specularIntensityMap,t(A.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,A){A.matcap&&(m.matcap.value=A.matcap)}function p(m,A){const x=e.get(A).light;m.referencePosition.value.setFromMatrixPosition(x.matrixWorld),m.nearDistance.value=x.shadow.camera.near,m.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function T1(n,e,t,i){let s={},r={},o=[];const a=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,b){const y=b.program;i.uniformBlockBinding(x,y)}function c(x,b){let y=s[x.id];y===void 0&&(g(x),y=h(x),s[x.id]=y,x.addEventListener("dispose",m));const _=b.program;i.updateUBOMapping(x,_);const S=e.render.frame;r[x.id]!==S&&(f(x),r[x.id]=S)}function h(x){const b=d();x.__bindingPointIndex=b;const y=n.createBuffer(),_=x.__size,S=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,y),n.bufferData(n.UNIFORM_BUFFER,_,S),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,b,y),y}function d(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return Pt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(x){const b=s[x.id],y=x.uniforms,_=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,b);for(let S=0,C=y.length;S<C;S++){const D=Array.isArray(y[S])?y[S]:[y[S]];for(let M=0,I=D.length;M<I;M++){const P=D[M];if(u(P,S,M,_)===!0){const T=P.__offset,L=Array.isArray(P.value)?P.value:[P.value];let E=0;for(let F=0;F<L.length;F++){const z=L[F],X=p(z);typeof z=="number"||typeof z=="boolean"?(P.__data[0]=z,n.bufferSubData(n.UNIFORM_BUFFER,T+E,P.__data)):z.isMatrix3?(P.__data[0]=z.elements[0],P.__data[1]=z.elements[1],P.__data[2]=z.elements[2],P.__data[3]=0,P.__data[4]=z.elements[3],P.__data[5]=z.elements[4],P.__data[6]=z.elements[5],P.__data[7]=0,P.__data[8]=z.elements[6],P.__data[9]=z.elements[7],P.__data[10]=z.elements[8],P.__data[11]=0):(z.toArray(P.__data,E),E+=X.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,T,P.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function u(x,b,y,_){const S=x.value,C=b+"_"+y;if(_[C]===void 0)return typeof S=="number"||typeof S=="boolean"?_[C]=S:_[C]=S.clone(),!0;{const D=_[C];if(typeof S=="number"||typeof S=="boolean"){if(D!==S)return _[C]=S,!0}else if(D.equals(S)===!1)return D.copy(S),!0}return!1}function g(x){const b=x.uniforms;let y=0;const _=16;for(let C=0,D=b.length;C<D;C++){const M=Array.isArray(b[C])?b[C]:[b[C]];for(let I=0,P=M.length;I<P;I++){const T=M[I],L=Array.isArray(T.value)?T.value:[T.value];for(let E=0,F=L.length;E<F;E++){const z=L[E],X=p(z),j=y%_,N=j%X.boundary,Y=j+N;y+=N,Y!==0&&_-Y<X.storage&&(y+=_-Y),T.__data=new Float32Array(X.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=y,y+=X.storage}}}const S=y%_;return S>0&&(y+=_-S),x.__size=y,x.__cache={},this}function p(x){const b={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(b.boundary=4,b.storage=4):x.isVector2?(b.boundary=8,b.storage=8):x.isVector3||x.isColor?(b.boundary=16,b.storage=12):x.isVector4?(b.boundary=16,b.storage=16):x.isMatrix3?(b.boundary=48,b.storage=48):x.isMatrix4?(b.boundary=64,b.storage=64):x.isTexture?$e("WebGLRenderer: Texture samplers can not be part of an uniforms group."):$e("WebGLRenderer: Unsupported uniform value type.",x),b}function m(x){const b=x.target;b.removeEventListener("dispose",m);const y=o.indexOf(b.__bindingPointIndex);o.splice(y,1),n.deleteBuffer(s[b.id]),delete s[b.id],delete r[b.id]}function A(){for(const x in s)n.deleteBuffer(s[x]);o=[],s={},r={}}return{bind:l,update:c,dispose:A}}const D1=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let Hn=null;function B1(){return Hn===null&&(Hn=new xw(D1,32,32,dd,Qr),Hn.minFilter=Fi,Hn.magFilter=Fi,Hn.wrapS=Fn,Hn.wrapT=Fn,Hn.generateMipmaps=!1,Hn.needsUpdate=!0),Hn}class P1{constructor(e={}){const{canvas:t=j_(),context:i=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:f=!1}=e;this.isWebGLRenderer=!0;let u;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");u=i.getContextAttributes().alpha}else u=o;const g=new Set([fd,ud,hd]),p=new Set([On,Xs,Qo,jo,ld,cd]),m=new Uint32Array(4),A=new Int32Array(4);let x=null,b=null;const y=[],_=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=us,this.toneMappingExposure=1,this.transmissionResolutionScale=.25,this.interactionCullingEnabled=!1,this.interactionActive=!1,this.interactionRenderScene=null,this.interactionFrameBudgetMs=10,this.interactionSkipShadows=!1;const S=this;let C=!1;this._outputColorSpace=Ci;let D=0,M=0,I=null,P=-1,T=null;const L=new Lt,E=new Lt;let F=null;const z=new ut(0);let X=0,j=t.width,N=t.height,Y=1,V=null,H=null;const oe=new Lt(0,0,j,N),pe=new Lt(0,0,j,N);let ue=!1;const re=new em;let de=!1,Ae=!1;const ye=new zt,Me=new ge,Oe=new Lt,nt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ge=!1,B=null;const ae=[];function ie(O){ae.push(B);const Z=Number.isFinite(S.interactionFrameBudgetMs)?S.interactionFrameBudgetMs:0,le=S.interactionRenderScene===null||O===S.interactionRenderScene;S.interactionCullingEnabled===!0&&S.interactionActive===!0&&le===!0&&Z>0?B={startTime:performance.now(),budgetMs:Z,aborted:!1}:B=null}function W(O){const Z=Number.isFinite(S.interactionFrameBudgetMs)?S.interactionFrameBudgetMs:0,le=S.interactionRenderScene===null||O===S.interactionRenderScene;return S.interactionCullingEnabled===!0&&S.interactionActive===!0&&le===!0&&Z>0}function G(){B=ae.pop()??null}function K(){return B===null?!1:B.aborted===!0?!0:performance.now()-B.startTime<B.budgetMs?!1:(B.aborted=!0,!0)}function me(){return I===null?Y:1}let U=i;function te(O,Z){return t.getContext(O,Z)}try{const O={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Hh}`),t.addEventListener("webglcontextlost",Bn,!1),t.addEventListener("webglcontextrestored",Pn,!1),t.addEventListener("webglcontextcreationerror",Uv,!1),U===null){const Z="webgl2";if(U=te(Z,O),U===null)throw te(Z)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(O){throw O("WebGLRenderer: "+O.message),O}let k,R,Q,ee,se,J,Te,we,Be,Qe,xe,Ce,je,Ue,Ie,Ve,q,_e,Se,Le,ve,be,ke,Ye;function yt(){k=new zC(U),k.init(),be=new _1(U,k),R=new BC(U,k,e,be),Q=new y1(U,k),R.reversedDepthBuffer&&f&&Q.buffers.depth.setReversed(!0),ee=new QC(U),se=new a1,J=new v1(U,k,Q,se,R,be,ee),Te=new LC(S),we=new NC(S),Be=new Ew(U),ke=new TC(U,Be),Qe=new GC(U,Be,ee,ke),xe=new WC(U,Qe,Be,ee),Se=new jC(U,R,J),Ve=new PC(se),Ce=new o1(S,Te,we,k,R,ke,Ve),je=new I1(S,se),Ue=new c1,Ie=new g1(k),_e=new IC(S,Te,we,Q,xe,u,l),q=new x1(S,xe,R),Ye=new T1(U,ee,R,Q),Le=new DC(U,k,ee),ve=new VC(U,k,ee),ee.programs=Ce.programs,S.capabilities=R,S.extensions=k,S.properties=se,S.renderLists=Ue,S.shadowMap=q,S.state=Q,S.info=ee}yt();const Ke=new M1(S,U);this.xr=Ke,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){const O=k.get("WEBGL_lose_context");O&&O.loseContext()},this.forceContextRestore=function(){const O=k.get("WEBGL_lose_context");O&&O.restoreContext()},this.getPixelRatio=function(){return Y},this.setPixelRatio=function(O){O!==void 0&&(Y=O,this.setSize(j,N,!1))},this.getSize=function(O){return O.set(j,N)},this.setSize=function(O,Z,le=!0){if(Ke.isPresenting){$e("WebGLRenderer: Can't change size while VR device is presenting.");return}j=O,N=Z,t.width=Math.floor(O*Y),t.height=Math.floor(Z*Y),le===!0&&(t.style.width=O+"px",t.style.height=Z+"px"),this.setViewport(0,0,O,Z)},this.getDrawingBufferSize=function(O){return O.set(j*Y,N*Y).floor()},this.setDrawingBufferSize=function(O,Z,le){j=O,N=Z,Y=le,t.width=Math.floor(O*le),t.height=Math.floor(Z*le),this.setViewport(0,0,O,Z)},this.getCurrentViewport=function(O){return O.copy(L)},this.getViewport=function(O){return O.copy(oe)},this.setViewport=function(O,Z,le,fe){O.isVector4?oe.set(O.x,O.y,O.z,O.w):oe.set(O,Z,le,fe),Q.viewport(L.copy(oe).multiplyScalar(Y).round())},this.getScissor=function(O){return O.copy(pe)},this.setScissor=function(O,Z,le,fe){O.isVector4?pe.set(O.x,O.y,O.z,O.w):pe.set(O,Z,le,fe),Q.scissor(E.copy(pe).multiplyScalar(Y).round())},this.getScissorTest=function(){return ue},this.setScissorTest=function(O){Q.setScissorTest(ue=O)},this.setOpaqueSort=function(O){V=O},this.setTransparentSort=function(O){H=O},this.getClearColor=function(O){return O.copy(_e.getClearColor())},this.setClearColor=function(){_e.setClearColor(...arguments)},this.getClearAlpha=function(){return _e.getClearAlpha()},this.setClearAlpha=function(){_e.setClearAlpha(...arguments)},this.clear=function(O=!0,Z=!0,le=!0){let fe=0;if(O){let ne=!1;if(I!==null){const Ee=I.texture.format;ne=g.has(Ee)}if(ne){const Ee=I.texture.type,Pe=p.has(Ee),Ne=_e.getClearColor(),Fe=_e.getClearAlpha(),Xe=Ne.r,qe=Ne.g,We=Ne.b;Pe?(m[0]=Xe,m[1]=qe,m[2]=We,m[3]=Fe,U.clearBufferuiv(U.COLOR,0,m)):(A[0]=Xe,A[1]=qe,A[2]=We,A[3]=Fe,U.clearBufferiv(U.COLOR,0,A))}else fe|=U.COLOR_BUFFER_BIT}Z&&(fe|=U.DEPTH_BUFFER_BIT),le&&(fe|=U.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),U.clear(fe)},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(){t.removeEventListener("webglcontextlost",Bn,!1),t.removeEventListener("webglcontextrestored",Pn,!1),t.removeEventListener("webglcontextcreationerror",Uv,!1),_e.dispose(),Ue.dispose(),Ie.dispose(),se.dispose(),Te.dispose(),we.dispose(),xe.dispose(),ke.dispose(),Ye.dispose(),Ce.dispose(),Ke.dispose(),Ke.removeEventListener("sessionstart",Gv),Ke.removeEventListener("sessionend",Vv),Or.stop()};function Bn(O){O.preventDefault(),Ig("WebGLRenderer: Context Lost."),C=!0}function Pn(){Ig("WebGLRenderer: Context Restored."),C=!1;const O=ee.autoReset,Z=q.enabled,le=q.autoUpdate,fe=q.needsUpdate,ne=q.type;yt(),ee.autoReset=O,q.enabled=Z,q.autoUpdate=le,q.needsUpdate=fe,q.type=ne}function Uv(O){Pt("WebGLRenderer: A WebGL context could not be created. Reason: ",O.statusMessage)}function Nv(O){const Z=O.target;Z.removeEventListener("dispose",Nv),Tk(Z)}function Tk(O){Dk(O),se.remove(O)}function Dk(O){const Z=se.get(O).programs;Z!==void 0&&(Z.forEach(function(le){Ce.releaseProgram(le)}),O.isShaderMaterial&&Ce.releaseShaderCache(O))}this.renderBufferDirect=function(O,Z,le,fe,ne,Ee){Z===null&&(Z=nt);const Pe=ne.isMesh&&ne.matrixWorld.determinant()<0,Ne=Pk(O,Z,le,fe,ne);Q.setMaterial(fe,Pe);let Fe=le.index,Xe=1;if(fe.wireframe===!0){if(Fe=Qe.getWireframeAttribute(le),Fe===void 0)return;Xe=2}const qe=le.drawRange,We=le.attributes.position;let st=qe.start*Xe,gt=(qe.start+qe.count)*Xe;Ee!==null&&(st=Math.max(st,Ee.start*Xe),gt=Math.min(gt,(Ee.start+Ee.count)*Xe)),Fe!==null?(st=Math.max(st,0),gt=Math.min(gt,Fe.count)):We!=null&&(st=Math.max(st,0),gt=Math.min(gt,We.count));const Dt=gt-st;if(Dt<0||Dt===1/0)return;ke.setup(ne,fe,Ne,le,Fe);let Bt,bt=Le;if(Fe!==null&&(Bt=Be.get(Fe),bt=ve,bt.setIndex(Bt)),ne.isMesh)fe.wireframe===!0?(Q.setLineWidth(fe.wireframeLinewidth*me()),bt.setMode(U.LINES)):bt.setMode(U.TRIANGLES);else if(ne.isLine){let He=fe.linewidth;He===void 0&&(He=1),Q.setLineWidth(He*me()),ne.isLineSegments?bt.setMode(U.LINES):ne.isLineLoop?bt.setMode(U.LINE_LOOP):bt.setMode(U.LINE_STRIP)}else ne.isPoints?bt.setMode(U.POINTS):ne.isSprite&&bt.setMode(U.TRIANGLES);if(ne.isBatchedMesh)if(ne._multiDrawInstances!==null)Xo("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),bt.renderMultiDrawInstances(ne._multiDrawStarts,ne._multiDrawCounts,ne._multiDrawCount,ne._multiDrawInstances);else if(k.get("WEBGL_multi_draw"))bt.renderMultiDraw(ne._multiDrawStarts,ne._multiDrawCounts,ne._multiDrawCount);else{const He=ne._multiDrawStarts,wt=ne._multiDrawCounts,at=ne._multiDrawCount,Ri=Fe?Be.get(Fe).bytesPerElement:1,Vo=se.get(fe).currentProgram.getUniforms();for(let ki=0;ki<at;ki++)Vo.setValue(U,"_gl_DrawID",ki),bt.render(He[ki]/Ri,wt[ki])}else if(ne.isInstancedMesh)bt.renderInstances(st,Dt,ne.count);else if(le.isInstancedBufferGeometry){const He=le._maxInstanceCount!==void 0?le._maxInstanceCount:1/0,wt=Math.min(le.instanceCount,He);bt.renderInstances(st,Dt,wt)}else bt.render(st,Dt)};function zv(O,Z,le){O.transparent===!0&&O.side===Rn&&O.forceSinglePass===!1?(O.side=gi,O.needsUpdate=!0,Vh(O,Z,le),O.side=ds,O.needsUpdate=!0,Vh(O,Z,le),O.side=Rn):Vh(O,Z,le)}this.compile=function(O,Z,le=null){le===null&&(le=O),b=Ie.get(le),b.init(Z),_.push(b),le.traverseVisible(function(ne){ne.isLight&&ne.layers.test(Z.layers)&&(b.pushLight(ne),ne.castShadow&&b.pushShadow(ne))}),O!==le&&O.traverseVisible(function(ne){ne.isLight&&ne.layers.test(Z.layers)&&(b.pushLight(ne),ne.castShadow&&b.pushShadow(ne))}),b.setupLights();const fe=new Set;return O.traverse(function(ne){if(!(ne.isMesh||ne.isPoints||ne.isLine||ne.isSprite))return;const Ee=ne.material;if(Ee)if(Array.isArray(Ee))for(let Pe=0;Pe<Ee.length;Pe++){const Ne=Ee[Pe];zv(Ne,le,ne),fe.add(Ne)}else zv(Ee,le,ne),fe.add(Ee)}),b=_.pop(),fe},this.compileAsync=function(O,Z,le=null){const fe=this.compile(O,Z,le);return new Promise(ne=>{function Ee(){if(fe.forEach(function(Pe){se.get(Pe).currentProgram.isReady()&&fe.delete(Pe)}),fe.size===0){ne(O);return}setTimeout(Ee,10)}k.get("KHR_parallel_shader_compile")!==null?Ee():setTimeout(Ee,10)})};let Hp=null;function Bk(O){Hp&&Hp(O)}function Gv(){Or.stop()}function Vv(){Or.start()}const Or=new sm;Or.setAnimationLoop(Bk),typeof self<"u"&&Or.setContext(self),this.setAnimationLoop=function(O){Hp=O,Ke.setAnimationLoop(O),O===null?Or.stop():Or.start()},Ke.addEventListener("sessionstart",Gv),Ke.addEventListener("sessionend",Vv),this.render=function(O,Z){if(Z!==void 0&&Z.isCamera!==!0){Pt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C!==!0){O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),Z.parent===null&&Z.matrixWorldAutoUpdate===!0&&Z.updateMatrixWorld(),Ke.enabled===!0&&Ke.isPresenting===!0&&(Ke.cameraAutoUpdate===!0&&Ke.updateCamera(Z),Z=Ke.getCamera()),O.isScene===!0&&O.onBeforeRender(S,O,Z,I),b=Ie.get(O,_.length),b.init(Z),_.push(b),ye.multiplyMatrices(Z.projectionMatrix,Z.matrixWorldInverse),re.setFromProjectionMatrix(ye,mn,Z.reversedDepth),Ae=this.localClippingEnabled,de=Ve.init(this.clippingPlanes,Ae),x=Ue.get(O,y.length),x.init(),y.push(x),ie(O);try{if(Ke.enabled===!0&&Ke.isPresenting===!0){const Ee=S.xr.getDepthSensingMesh();Ee!==null&&Xp(Ee,Z,-1/0,S.sortObjects)}Xp(O,Z,0,S.sortObjects),x.finish(),S.sortObjects===!0&&x.sort(V,H),Ge=Ke.enabled===!1||Ke.isPresenting===!1||Ke.hasDepthSensing()===!1,Ge&&_e.addToRenderList(x,O),this.info.render.frame++,de===!0&&Ve.beginShadows();const le=b.state.shadowsArray;(S.interactionSkipShadows!==!0||W(O)===!1)&&q.render(le,O,Z),de===!0&&Ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const fe=x.opaque,ne=x.transmissive;if(b.setupLights(),Z.isArrayCamera){const Ee=Z.cameras;if(ne.length>0)for(let Pe=0,Ne=Ee.length;Pe<Ne;Pe++){const Fe=Ee[Pe];jv(fe,ne,O,Fe)}Ge&&_e.render(O);for(let Pe=0,Ne=Ee.length;Pe<Ne;Pe++){const Fe=Ee[Pe];Qv(x,O,Fe,Fe.viewport)}}else ne.length>0&&jv(fe,ne,O,Z),Ge&&_e.render(O),Qv(x,O,Z)}finally{G()}I!==null&&M===0&&(J.updateMultisampleRenderTarget(I),J.updateRenderTargetMipmap(I)),O.isScene===!0&&O.onAfterRender(S,O,Z),ke.resetDefaultState(),P=-1,T=null,_.pop(),_.length>0?(b=_[_.length-1],de===!0&&Ve.setGlobalState(S.clippingPlanes,b.state.camera)):b=null,y.pop(),y.length>0?x=y[y.length-1]:x=null}};function Xp(O,Z,le,fe){if(K()===!0||O.visible===!1)return;if(O.layers.test(Z.layers)){if(O.isGroup)le=O.renderOrder;else if(O.isLOD)O.autoUpdate===!0&&O.update(Z);else if(O.isLight)b.pushLight(O),O.castShadow&&b.pushShadow(O);else if(O.isSprite){if(!O.frustumCulled||re.intersectsSprite(O)){fe&&Oe.setFromMatrixPosition(O.matrixWorld).applyMatrix4(ye);const Pe=xe.update(O),Ne=O.material;Ne.visible&&x.push(O,Pe,Ne,le,Oe.z,null)}}else if((O.isMesh||O.isLine||O.isPoints)&&(!O.frustumCulled||re.intersectsObject(O))){const Pe=xe.update(O),Ne=O.material;if(fe&&(O.boundingSphere!==void 0?(O.boundingSphere===null&&O.computeBoundingSphere(),Oe.copy(O.boundingSphere.center)):(Pe.boundingSphere===null&&Pe.computeBoundingSphere(),Oe.copy(Pe.boundingSphere.center)),Oe.applyMatrix4(O.matrixWorld).applyMatrix4(ye)),Array.isArray(Ne)){const Fe=Pe.groups;for(let Xe=0,qe=Fe.length;Xe<qe;Xe++){const We=Fe[Xe],st=Ne[We.materialIndex];st&&st.visible&&x.push(O,Pe,st,le,Oe.z,We)}}else Ne.visible&&x.push(O,Pe,Ne,le,Oe.z,null)}}const Ee=O.children;for(let Pe=0,Ne=Ee.length;Pe<Ne;Pe++)Xp(Ee[Pe],Z,le,fe)}function Qv(O,Z,le,fe){const{opaque:ne,transmissive:Ee,transparent:Pe}=O;b.setupLightsView(le),de===!0&&Ve.setGlobalState(S.clippingPlanes,le),fe&&Q.viewport(L.copy(fe)),ne.length>0&&Gh(ne,Z,le),Ee.length>0&&Gh(Ee,Z,le),Pe.length>0&&Gh(Pe,Z,le),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function jv(O,Z,le,fe){if((le.isScene===!0?le.overrideMaterial:null)!==null)return;b.state.transmissionRenderTarget[fe.id]===void 0&&(b.state.transmissionRenderTarget[fe.id]=new qs(1,1,{generateMipmaps:!0,type:k.has("EXT_color_buffer_half_float")||k.has("EXT_color_buffer_float")?Qr:On,minFilter:Hs,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ot.workingColorSpace}));const Ee=b.state.transmissionRenderTarget[fe.id],Pe=fe.viewport||L;Ee.setSize(Pe.z*S.transmissionResolutionScale,Pe.w*S.transmissionResolutionScale);const Ne=S.getRenderTarget(),Fe=S.getActiveCubeFace(),Xe=S.getActiveMipmapLevel();S.setRenderTarget(Ee),S.getClearColor(z),X=S.getClearAlpha(),X<1&&S.setClearColor(16777215,.5),S.clear(),Ge&&_e.render(le);const qe=S.toneMapping;S.toneMapping=us;const We=fe.viewport;if(fe.viewport!==void 0&&(fe.viewport=void 0),b.setupLightsView(fe),de===!0&&Ve.setGlobalState(S.clippingPlanes,fe),Gh(O,le,fe),J.updateMultisampleRenderTarget(Ee),J.updateRenderTargetMipmap(Ee),k.has("WEBGL_multisampled_render_to_texture")===!1){let st=!1;for(let gt=0,Dt=Z.length;gt<Dt;gt++){const Bt=Z[gt],{object:bt,geometry:He,material:wt,group:at}=Bt;if(wt.side===Rn&&bt.layers.test(fe.layers)){const Ri=wt.side;wt.side=gi,wt.needsUpdate=!0,Wv(bt,le,fe,He,wt,at),wt.side=Ri,wt.needsUpdate=!0,st=!0}}st===!0&&(J.updateMultisampleRenderTarget(Ee),J.updateRenderTargetMipmap(Ee))}S.setRenderTarget(Ne,Fe,Xe),S.setClearColor(z,X),We!==void 0&&(fe.viewport=We),S.toneMapping=qe}function Gh(O,Z,le){const fe=Z.isScene===!0?Z.overrideMaterial:null;for(let ne=0,Ee=O.length;ne<Ee;ne++){if(K()===!0)return;const Pe=O[ne],{object:Ne,geometry:Fe,group:Xe}=Pe;let qe=Pe.material;qe.allowOverride===!0&&fe!==null&&(qe=fe),Ne.layers.test(le.layers)&&Wv(Ne,Z,le,Fe,qe,Xe)}}function Wv(O,Z,le,fe,ne,Ee){O.onBeforeRender(S,Z,le,fe,ne,Ee),O.modelViewMatrix.multiplyMatrices(le.matrixWorldInverse,O.matrixWorld),O.normalMatrix.getNormalMatrix(O.modelViewMatrix),ne.onBeforeRender(S,Z,le,fe,O,Ee),ne.transparent===!0&&ne.side===Rn&&ne.forceSinglePass===!1?(ne.side=gi,ne.needsUpdate=!0,S.renderBufferDirect(le,Z,fe,ne,O,Ee),ne.side=ds,ne.needsUpdate=!0,S.renderBufferDirect(le,Z,fe,ne,O,Ee),ne.side=Rn):S.renderBufferDirect(le,Z,fe,ne,O,Ee),O.onAfterRender(S,Z,le,fe,ne,Ee)}function Vh(O,Z,le){Z.isScene!==!0&&(Z=nt);const fe=se.get(O),ne=b?.state.lights,Ee=b?.state.shadowsArray,Pe=ne.state.version,Ne=Ce.getParameters(O,ne.state,Ee,Z,le),Fe=Ce.getProgramCacheKey(Ne);let Xe=fe.programs;fe.environment=O.isMeshStandardMaterial?Z.environment:null,fe.fog=Z.fog,fe.envMap=(O.isMeshStandardMaterial?we:Te).get(O.envMap||fe.environment),fe.envMapRotation=fe.environment!==null&&O.envMap===null?Z.environmentRotation:O.envMapRotation,Xe===void 0&&(O.addEventListener("dispose",Nv),Xe=new Map,fe.programs=Xe);let qe=Xe.get(Fe);if(qe!==void 0){if(fe.currentProgram===qe&&fe.lightsStateVersion===Pe)return Xv(O,Ne),qe}else Ne.uniforms=Ce.getUniforms(O),O.onBeforeCompile(Ne,S),qe=Ce.acquireProgram(Ne,Fe),Xe.set(Fe,qe),fe.uniforms=Ne.uniforms;const We=fe.uniforms;return(!O.isShaderMaterial&&!O.isRawShaderMaterial||O.clipping===!0)&&(We.clippingPlanes=Ve.uniform),Xv(O,Ne),fe.needsLights=Rk(O),fe.lightsStateVersion=Pe,fe.needsLights&&(We.ambientLightColor.value=ne.state.ambient,We.lightProbe.value=ne.state.probe,We.directionalLights.value=ne.state.directional,We.directionalLightShadows.value=ne.state.directionalShadow,We.spotLights.value=ne.state.spot,We.spotLightShadows.value=ne.state.spotShadow,We.rectAreaLights.value=ne.state.rectArea,We.ltc_1.value=ne.state.rectAreaLTC1,We.ltc_2.value=ne.state.rectAreaLTC2,We.pointLights.value=ne.state.point,We.pointLightShadows.value=ne.state.pointShadow,We.hemisphereLights.value=ne.state.hemi,We.directionalShadowMap.value=ne.state.directionalShadowMap,We.directionalShadowMatrix.value=ne.state.directionalShadowMatrix,We.spotShadowMap.value=ne.state.spotShadowMap,We.spotLightMatrix.value=ne.state.spotLightMatrix,We.spotLightMap.value=ne.state.spotLightMap,We.pointShadowMap.value=ne.state.pointShadowMap,We.pointShadowMatrix.value=ne.state.pointShadowMatrix),fe.currentProgram=qe,fe.uniformsList=null,qe}function Hv(O){if(O.uniformsList===null){const Z=O.currentProgram.getUniforms();O.uniformsList=ql.seqWithValue(Z.seq,O.uniforms)}return O.uniformsList}function Xv(O,Z){const le=se.get(O);le.outputColorSpace=Z.outputColorSpace,le.batching=Z.batching,le.batchingColor=Z.batchingColor,le.instancing=Z.instancing,le.instancingColor=Z.instancingColor,le.instancingMorph=Z.instancingMorph,le.skinning=Z.skinning,le.morphTargets=Z.morphTargets,le.morphNormals=Z.morphNormals,le.morphColors=Z.morphColors,le.morphTargetsCount=Z.morphTargetsCount,le.numClippingPlanes=Z.numClippingPlanes,le.numIntersection=Z.numClipIntersection,le.vertexAlphas=Z.vertexAlphas,le.vertexTangents=Z.vertexTangents,le.toneMapping=Z.toneMapping}function Pk(O,Z,le,fe,ne){Z.isScene!==!0&&(Z=nt),J.resetTextureUnits();const Ee=Z.fog,Pe=fe.isMeshStandardMaterial?Z.environment:null,Ne=I===null?S.outputColorSpace:I.isXRRenderTarget===!0?I.texture.colorSpace:jr,Fe=(fe.isMeshStandardMaterial?we:Te).get(fe.envMap||Pe),Xe=fe.vertexColors===!0&&!!le.attributes.color&&le.attributes.color.itemSize===4,qe=!!le.attributes.tangent&&(!!fe.normalMap||fe.anisotropy>0),We=!!le.morphAttributes.position,st=!!le.morphAttributes.normal,gt=!!le.morphAttributes.color;let Dt=us;fe.toneMapped&&(I===null||I.isXRRenderTarget===!0)&&(Dt=S.toneMapping);const Bt=le.morphAttributes.position||le.morphAttributes.normal||le.morphAttributes.color,bt=Bt!==void 0?Bt.length:0,He=se.get(fe),wt=b?.state.lights;if(de===!0&&(Ae===!0||O!==T)){const fi=O===T&&fe.id===P;Ve.setState(fe,O,fi)}let at=!1;fe.version===He.__version?(He.needsLights&&He.lightsStateVersion!==wt.state.version||He.outputColorSpace!==Ne||ne.isBatchedMesh&&He.batching===!1||!ne.isBatchedMesh&&He.batching===!0||ne.isBatchedMesh&&He.batchingColor===!0&&ne.colorTexture===null||ne.isBatchedMesh&&He.batchingColor===!1&&ne.colorTexture!==null||ne.isInstancedMesh&&He.instancing===!1||!ne.isInstancedMesh&&He.instancing===!0||ne.isSkinnedMesh&&He.skinning===!1||!ne.isSkinnedMesh&&He.skinning===!0||ne.isInstancedMesh&&He.instancingColor===!0&&ne.instanceColor===null||ne.isInstancedMesh&&He.instancingColor===!1&&ne.instanceColor!==null||ne.isInstancedMesh&&He.instancingMorph===!0&&ne.morphTexture===null||ne.isInstancedMesh&&He.instancingMorph===!1&&ne.morphTexture!==null||He.envMap!==Fe||fe.fog===!0&&He.fog!==Ee||He.numClippingPlanes!==void 0&&(He.numClippingPlanes!==Ve.numPlanes||He.numIntersection!==Ve.numIntersection)||He.vertexAlphas!==Xe||He.vertexTangents!==qe||He.morphTargets!==We||He.morphNormals!==st||He.morphColors!==gt||He.toneMapping!==Dt||He.morphTargetsCount!==bt)&&(at=!0):(at=!0,He.__version=fe.version);let Ri=He.currentProgram;at===!0&&(Ri=Vh(fe,Z,ne));let Vo=!1,ki=!1,fl=!1;const St=Ri.getUniforms(),_i=He.uniforms;if(Q.useProgram(Ri.program)&&(Vo=!0,ki=!0,fl=!0),fe.id!==P&&(P=fe.id,ki=!0),Vo||T!==O){Q.buffers.depth.getReversed()&&O.reversedDepth!==!0&&(O._reversedDepth=!0,O.updateProjectionMatrix()),St.setValue(U,"projectionMatrix",O.projectionMatrix),St.setValue(U,"viewMatrix",O.matrixWorldInverse);const wi=St.map.cameraPosition;wi!==void 0&&wi.setValue(U,Me.setFromMatrixPosition(O.matrixWorld)),R.logarithmicDepthBuffer&&St.setValue(U,"logDepthBufFC",2/(Math.log(O.far+1)/Math.LN2)),(fe.isMeshPhongMaterial||fe.isMeshToonMaterial||fe.isMeshLambertMaterial||fe.isMeshBasicMaterial||fe.isMeshStandardMaterial||fe.isShaderMaterial)&&St.setValue(U,"isOrthographic",O.isOrthographicCamera===!0),T!==O&&(T=O,ki=!0,fl=!0)}if(ne.isSkinnedMesh){St.setOptional(U,ne,"bindMatrix"),St.setOptional(U,ne,"bindMatrixInverse");const fi=ne.skeleton;fi&&(fi.boneTexture===null&&fi.computeBoneTexture(),St.setValue(U,"boneTexture",fi.boneTexture,J))}ne.isBatchedMesh&&(St.setOptional(U,ne,"batchingTexture"),St.setValue(U,"batchingTexture",ne._matricesTexture,J),St.setOptional(U,ne,"batchingIdTexture"),St.setValue(U,"batchingIdTexture",ne._indirectTexture,J),St.setOptional(U,ne,"batchingColorTexture"),ne._colorsTexture!==null&&St.setValue(U,"batchingColorTexture",ne._colorsTexture,J));const qi=le.morphAttributes;if((qi.position!==void 0||qi.normal!==void 0||qi.color!==void 0)&&Se.update(ne,le,Ri),(ki||He.receiveShadow!==ne.receiveShadow)&&(He.receiveShadow=ne.receiveShadow,St.setValue(U,"receiveShadow",ne.receiveShadow)),fe.isMeshGouraudMaterial&&fe.envMap!==null&&(_i.envMap.value=Fe,_i.flipEnvMap.value=Fe.isCubeTexture&&Fe.isRenderTargetTexture===!1?-1:1),fe.isMeshStandardMaterial&&fe.envMap===null&&Z.environment!==null&&(_i.envMapIntensity.value=Z.environmentIntensity),_i.dfgLUT!==void 0&&(_i.dfgLUT.value=B1()),ki&&(St.setValue(U,"toneMappingExposure",S.toneMappingExposure),He.needsLights&&Lk(_i,fl),Ee&&fe.fog===!0&&je.refreshFogUniforms(_i,Ee),je.refreshMaterialUniforms(_i,fe,Y,N,b.state.transmissionRenderTarget[O.id]),ql.upload(U,Hv(He),_i,J)),fe.isShaderMaterial&&fe.uniformsNeedUpdate===!0&&(ql.upload(U,Hv(He),_i,J),fe.uniformsNeedUpdate=!1),fe.isSpriteMaterial&&St.setValue(U,"center",ne.center),St.setValue(U,"modelViewMatrix",ne.modelViewMatrix),St.setValue(U,"normalMatrix",ne.normalMatrix),St.setValue(U,"modelMatrix",ne.matrixWorld),fe.isShaderMaterial||fe.isRawShaderMaterial){const fi=fe.uniformsGroups;for(let wi=0,qp=fi.length;wi<qp;wi++){const Ur=fi[wi];Ye.update(Ur,Ri),Ye.bind(Ur,Ri)}}return Ri}function Lk(O,Z){O.ambientLightColor.needsUpdate=Z,O.lightProbe.needsUpdate=Z,O.directionalLights.needsUpdate=Z,O.directionalLightShadows.needsUpdate=Z,O.pointLights.needsUpdate=Z,O.pointLightShadows.needsUpdate=Z,O.spotLights.needsUpdate=Z,O.spotLightShadows.needsUpdate=Z,O.rectAreaLights.needsUpdate=Z,O.hemisphereLights.needsUpdate=Z}function Rk(O){return O.isMeshLambertMaterial||O.isMeshToonMaterial||O.isMeshPhongMaterial||O.isMeshStandardMaterial||O.isShadowMaterial||O.isShaderMaterial&&O.lights===!0}this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(O,Z,le){const fe=se.get(O);fe.__autoAllocateDepthBuffer=O.resolveDepthBuffer===!1,fe.__autoAllocateDepthBuffer===!1&&(fe.__useRenderToTexture=!1),se.get(O.texture).__webglTexture=Z,se.get(O.depthTexture).__webglTexture=fe.__autoAllocateDepthBuffer?void 0:le,fe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(O,Z){const le=se.get(O);le.__webglFramebuffer=Z,le.__useDefaultFramebuffer=Z===void 0};const kk=U.createFramebuffer();this.setRenderTarget=function(O,Z=0,le=0){I=O,D=Z,M=le;let fe=!0,ne=null,Ee=!1,Pe=!1;if(O){const Fe=se.get(O);if(Fe.__useDefaultFramebuffer!==void 0)Q.bindFramebuffer(U.FRAMEBUFFER,null),fe=!1;else if(Fe.__webglFramebuffer===void 0)J.setupRenderTarget(O);else if(Fe.__hasExternalTextures)J.rebindTextures(O,se.get(O.texture).__webglTexture,se.get(O.depthTexture).__webglTexture);else if(O.depthBuffer){const We=O.depthTexture;if(Fe.__boundDepthTexture!==We){if(We!==null&&se.has(We)&&(O.width!==We.image.width||O.height!==We.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");J.setupDepthRenderbuffer(O)}}const Xe=O.texture;(Xe.isData3DTexture||Xe.isDataArrayTexture||Xe.isCompressedArrayTexture)&&(Pe=!0);const qe=se.get(O).__webglFramebuffer;O.isWebGLCubeRenderTarget?(Array.isArray(qe[Z])?ne=qe[Z][le]:ne=qe[Z],Ee=!0):O.samples>0&&J.useMultisampledRTT(O)===!1?ne=se.get(O).__webglMultisampledFramebuffer:Array.isArray(qe)?ne=qe[le]:ne=qe,L.copy(O.viewport),E.copy(O.scissor),F=O.scissorTest}else L.copy(oe).multiplyScalar(Y).floor(),E.copy(pe).multiplyScalar(Y).floor(),F=ue;if(le!==0&&(ne=kk),Q.bindFramebuffer(U.FRAMEBUFFER,ne)&&fe&&Q.drawBuffers(O,ne),Q.viewport(L),Q.scissor(E),Q.setScissorTest(F),Ee){const Fe=se.get(O.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Fe.__webglTexture,le)}else if(Pe){const Fe=Z;for(let Xe=0;Xe<O.textures.length;Xe++){const qe=se.get(O.textures[Xe]);U.framebufferTextureLayer(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0+Xe,qe.__webglTexture,le,Fe)}}else if(O!==null&&le!==0){const Fe=se.get(O.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Fe.__webglTexture,le)}P=-1},this.readRenderTargetPixels=function(O,Z,le,fe,ne,Ee,Pe,Ne=0){if(!(O&&O.isWebGLRenderTarget)){Pt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Fe=se.get(O).__webglFramebuffer;if(O.isWebGLCubeRenderTarget&&Pe!==void 0&&(Fe=Fe[Pe]),Fe){Q.bindFramebuffer(U.FRAMEBUFFER,Fe);try{const Xe=O.textures[Ne],qe=Xe.format,We=Xe.type;if(!R.textureFormatReadable(qe)){Pt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(We)){Pt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Z>=0&&Z<=O.width-fe&&le>=0&&le<=O.height-ne&&(O.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+Ne),U.readPixels(Z,le,fe,ne,be.convert(qe),be.convert(We),Ee))}finally{const Xe=I!==null?se.get(I).__webglFramebuffer:null;Q.bindFramebuffer(U.FRAMEBUFFER,Xe)}}},this.readRenderTargetPixelsAsync=async function(O,Z,le,fe,ne,Ee,Pe,Ne=0){if(!(O&&O.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Fe=se.get(O).__webglFramebuffer;if(O.isWebGLCubeRenderTarget&&Pe!==void 0&&(Fe=Fe[Pe]),Fe)if(Z>=0&&Z<=O.width-fe&&le>=0&&le<=O.height-ne){Q.bindFramebuffer(U.FRAMEBUFFER,Fe);const Xe=O.textures[Ne],qe=Xe.format,We=Xe.type;if(!R.textureFormatReadable(qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(We))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const st=U.createBuffer();U.bindBuffer(U.PIXEL_PACK_BUFFER,st),U.bufferData(U.PIXEL_PACK_BUFFER,Ee.byteLength,U.STREAM_READ),O.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+Ne),U.readPixels(Z,le,fe,ne,be.convert(qe),be.convert(We),0);const gt=I!==null?se.get(I).__webglFramebuffer:null;Q.bindFramebuffer(U.FRAMEBUFFER,gt);const Dt=U.fenceSync(U.SYNC_GPU_COMMANDS_COMPLETE,0);return U.flush(),await W_(U,Dt,4),U.bindBuffer(U.PIXEL_PACK_BUFFER,st),U.getBufferSubData(U.PIXEL_PACK_BUFFER,0,Ee),U.deleteBuffer(st),U.deleteSync(Dt),Ee}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(O,Z=null,le=0){const fe=Math.pow(2,-le),ne=Math.floor(O.image.width*fe),Ee=Math.floor(O.image.height*fe),Pe=Z!==null?Z.x:0,Ne=Z!==null?Z.y:0;J.setTexture2D(O,0),U.copyTexSubImage2D(U.TEXTURE_2D,le,0,0,Pe,Ne,ne,Ee),Q.unbindTexture()};const Fk=U.createFramebuffer(),Ok=U.createFramebuffer();this.copyTextureToTexture=function(O,Z,le=null,fe=null,ne=0,Ee=null){Ee===null&&(ne!==0?(Xo("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Ee=ne,ne=0):Ee=0);let Pe,Ne,Fe,Xe,qe,We,st,gt,Dt;const Bt=O.isCompressedTexture?O.mipmaps[Ee]:O.image;if(le!==null)Pe=le.max.x-le.min.x,Ne=le.max.y-le.min.y,Fe=le.isBox3?le.max.z-le.min.z:1,Xe=le.min.x,qe=le.min.y,We=le.isBox3?le.min.z:0;else{const qi=Math.pow(2,-ne);Pe=Math.floor(Bt.width*qi),Ne=Math.floor(Bt.height*qi),O.isDataArrayTexture?Fe=Bt.depth:O.isData3DTexture?Fe=Math.floor(Bt.depth*qi):Fe=1,Xe=0,qe=0,We=0}fe!==null?(st=fe.x,gt=fe.y,Dt=fe.z):(st=0,gt=0,Dt=0);const bt=be.convert(Z.format),He=be.convert(Z.type);let wt;Z.isData3DTexture?(J.setTexture3D(Z,0),wt=U.TEXTURE_3D):Z.isDataArrayTexture||Z.isCompressedArrayTexture?(J.setTexture2DArray(Z,0),wt=U.TEXTURE_2D_ARRAY):(J.setTexture2D(Z,0),wt=U.TEXTURE_2D),U.pixelStorei(U.UNPACK_FLIP_Y_WEBGL,Z.flipY),U.pixelStorei(U.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Z.premultiplyAlpha),U.pixelStorei(U.UNPACK_ALIGNMENT,Z.unpackAlignment);const at=U.getParameter(U.UNPACK_ROW_LENGTH),Ri=U.getParameter(U.UNPACK_IMAGE_HEIGHT),Vo=U.getParameter(U.UNPACK_SKIP_PIXELS),ki=U.getParameter(U.UNPACK_SKIP_ROWS),fl=U.getParameter(U.UNPACK_SKIP_IMAGES);U.pixelStorei(U.UNPACK_ROW_LENGTH,Bt.width),U.pixelStorei(U.UNPACK_IMAGE_HEIGHT,Bt.height),U.pixelStorei(U.UNPACK_SKIP_PIXELS,Xe),U.pixelStorei(U.UNPACK_SKIP_ROWS,qe),U.pixelStorei(U.UNPACK_SKIP_IMAGES,We);const St=O.isDataArrayTexture||O.isData3DTexture,_i=Z.isDataArrayTexture||Z.isData3DTexture;if(O.isDepthTexture){const qi=se.get(O),fi=se.get(Z),wi=se.get(qi.__renderTarget),qp=se.get(fi.__renderTarget);Q.bindFramebuffer(U.READ_FRAMEBUFFER,wi.__webglFramebuffer),Q.bindFramebuffer(U.DRAW_FRAMEBUFFER,qp.__webglFramebuffer);for(let Ur=0;Ur<Fe;Ur++)St&&(U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,se.get(O).__webglTexture,ne,We+Ur),U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,se.get(Z).__webglTexture,Ee,Dt+Ur)),U.blitFramebuffer(Xe,qe,Pe,Ne,st,gt,Pe,Ne,U.DEPTH_BUFFER_BIT,U.NEAREST);Q.bindFramebuffer(U.READ_FRAMEBUFFER,null),Q.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else if(ne!==0||O.isRenderTargetTexture||se.has(O)){const qi=se.get(O),fi=se.get(Z);Q.bindFramebuffer(U.READ_FRAMEBUFFER,Fk),Q.bindFramebuffer(U.DRAW_FRAMEBUFFER,Ok);for(let wi=0;wi<Fe;wi++)St?U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,qi.__webglTexture,ne,We+wi):U.framebufferTexture2D(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,qi.__webglTexture,ne),_i?U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,fi.__webglTexture,Ee,Dt+wi):U.framebufferTexture2D(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,fi.__webglTexture,Ee),ne!==0?U.blitFramebuffer(Xe,qe,Pe,Ne,st,gt,Pe,Ne,U.COLOR_BUFFER_BIT,U.NEAREST):_i?U.copyTexSubImage3D(wt,Ee,st,gt,Dt+wi,Xe,qe,Pe,Ne):U.copyTexSubImage2D(wt,Ee,st,gt,Xe,qe,Pe,Ne);Q.bindFramebuffer(U.READ_FRAMEBUFFER,null),Q.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else _i?O.isDataTexture||O.isData3DTexture?U.texSubImage3D(wt,Ee,st,gt,Dt,Pe,Ne,Fe,bt,He,Bt.data):Z.isCompressedArrayTexture?U.compressedTexSubImage3D(wt,Ee,st,gt,Dt,Pe,Ne,Fe,bt,Bt.data):U.texSubImage3D(wt,Ee,st,gt,Dt,Pe,Ne,Fe,bt,He,Bt):O.isDataTexture?U.texSubImage2D(U.TEXTURE_2D,Ee,st,gt,Pe,Ne,bt,He,Bt.data):O.isCompressedTexture?U.compressedTexSubImage2D(U.TEXTURE_2D,Ee,st,gt,Bt.width,Bt.height,bt,Bt.data):U.texSubImage2D(U.TEXTURE_2D,Ee,st,gt,Pe,Ne,bt,He,Bt);U.pixelStorei(U.UNPACK_ROW_LENGTH,at),U.pixelStorei(U.UNPACK_IMAGE_HEIGHT,Ri),U.pixelStorei(U.UNPACK_SKIP_PIXELS,Vo),U.pixelStorei(U.UNPACK_SKIP_ROWS,ki),U.pixelStorei(U.UNPACK_SKIP_IMAGES,fl),Ee===0&&Z.generateMipmaps&&U.generateMipmap(wt),Q.unbindTexture()},this.initRenderTarget=function(O){se.get(O).__webglFramebuffer===void 0&&J.setupRenderTarget(O)},this.initTexture=function(O){O.isCubeTexture?J.setTextureCube(O,0):O.isData3DTexture?J.setTexture3D(O,0):O.isDataArrayTexture||O.isCompressedArrayTexture?J.setTexture2DArray(O,0):J.setTexture2D(O,0),Q.unbindTexture()},this.resetState=function(){D=0,M=0,I=null,Q.reset(),ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return mn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=ot._getDrawingBufferColorSpace(e),t.unpackColorSpace=ot._getUnpackColorSpace()}}const Pm=.9;class L1{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new P1({alpha:!0,premultipliedAlpha:!1,stencil:!0}),this.renderer.setClearColor(0,0),this.renderer.setSize(e,t),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=cg,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=Ci,this.renderer.toneMappingExposure=Pm,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const Lm={type:"change"},vu={type:"start"},Rm={type:"end"},Kl=new v.Ray,km=new v.Plane,R1=Math.cos(70*v.MathUtils.DEG2RAD),Ot=new v.Vector3,k1=new v.Vector3,F1=new v.Vector3,O1=new v.Vector3(0,1,0),U1=new v.Vector3(1,0,0),N1=new v.Vector3(0,0,1),Ai=.25*Math.PI,ft={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},$l=1e-6;let z1=class extends v.Controls{constructor(e,t,i=null){super(t,i),this.engine=e,this.state=ft.NONE,this.target=new v.Vector3,this.cursor=new v.Vector3,this.origin=new v.Vector3(0,0,0),this.showOriginIcon=!0,this.originPosition={x:0,y:0},this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.polarSafetyAngle=v.MathUtils.degToRad(5),this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.perspectiveWheelZoomBoost=5,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:v.MOUSE.ROTATE,MIDDLE:v.MOUSE.DOLLY,RIGHT:v.MOUSE.PAN},this.touches={ONE:v.TOUCH.ROTATE,TWO:v.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new v.Vector3,this._lastQuaternion=new v.Quaternion,this._lastTargetPosition=new v.Vector3,this._quat=new v.Quaternion().setFromUnitVectors(t.up,new v.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new v.Spherical,this._sphericalDelta=new v.Spherical,this._scale=1,this._panOffset=new v.Vector3,this._rotateStart=new v.Vector2,this._rotateEnd=new v.Vector2,this._rotateDelta=new v.Vector2,this._panStart=new v.Vector2,this._panEnd=new v.Vector2,this._panDelta=new v.Vector2,this._dollyStart=new v.Vector2,this._dollyEnd=new v.Vector2,this._dollyDelta=new v.Vector2,this._dollyDirection=new v.Vector3,this._mouse=new v.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=V1.bind(this),this._onPointerDown=G1.bind(this),this._onPointerUp=Q1.bind(this),this._onContextMenu=K1.bind(this),this._onMouseWheel=H1.bind(this),this._onKeyDown=X1.bind(this),this._onTouchStart=q1.bind(this),this._onTouchMove=Y1.bind(this),this._onMouseDown=j1.bind(this),this._onMouseMove=W1.bind(this),this._interceptControlDown=$1.bind(this),this._interceptControlUp=J1.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Lm),this.update(),this.state=ft.NONE}update(e=null){this.engine&&this.engine.interactionManager&&this.engine.interactionManager.origin&&this.origin.copy(this.engine.interactionManager.origin);const t=this.object.position;Ot.copy(t).sub(this.target),Ot.applyQuaternion(this._quat),this._spherical.setFromVector3(Ot),this.autoRotate&&this.state===ft.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=Ai:i>Math.PI&&(i-=Ai),s<-Math.PI?s+=Ai:s>Math.PI&&(s-=Ai),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),this.engine&&this.engine.deviceType==="PC"){const o=new v.Vector3;if(o.copy(this.origin).sub(this.target),o.lengthSq()>1e-4&&(this._sphericalDelta.theta!==0||this._sphericalDelta.phi!==0)){const l=this.enableDamping?this.dampingFactor*3:1,c=O1,h=k1;this.object.getWorldDirection(h);const d=Math.abs(h.y)>.999?U1:c,f=F1;f.crossVectors(h,d),f.lengthSq()<$l&&f.crossVectors(h,N1),f.normalize();const u=new v.Vector3().copy(this.object.position).sub(this.origin);u.applyAxisAngle(c,Math.PI*this._sphericalDelta.theta*l),u.applyAxisAngle(f,Math.PI*this._sphericalDelta.phi*l),t.copy(this.origin).add(u);const g=new v.Vector3().copy(this.target).sub(this.origin);g.applyAxisAngle(c,Math.PI*this._sphericalDelta.theta*l),g.applyAxisAngle(f,Math.PI*this._sphericalDelta.phi*l),this.target.copy(this.origin).add(g)}else t.copy(this.target).add(Ot);this.object.lookAt(this.target)}else t.copy(this.target).add(Ot),this.object.lookAt(this.target);if(this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Ot.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new v.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new v.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Ot.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Kl.origin.copy(this.object.position),Kl.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Kl.direction))<R1?this.object.lookAt(this.target):(km.setFromNormalAndCoplanarPoint(this.object.up,this.target),Kl.intersectPlane(km,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>$l||8*(1-this._lastQuaternion.dot(this.object.quaternion))>$l||this._lastTargetPosition.distanceToSquared(this.target)>$l?(this.dispatchEvent(Lm),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ai/60*this.autoRotateSpeed*e:Ai/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){this.screenSpacePanning===!0?Ot.setFromMatrixColumn(t,1):(Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot)),Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ot.copy(s).sub(this.target);let r=Ot.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,o=i.width,a=i.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ai*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ai*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ai*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ai*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new v.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}};function G1(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n)))}function V1(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function Q1(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Rm),this.state=ft.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function j1(n){if(this.showOriginIcon&&this.engine&&this.engine.ToolUntils){const t=this.engine.scene?.camera||this.object;this.originPosition=this.engine.ToolUntils.WorldPointToScreenPoint(this.origin.clone(),t),console.log("Origin position:",this.originPosition,"Origin:",this.origin)}let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case v.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=ft.DOLLY;break;case v.MOUSE.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=ft.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=ft.ROTATE}break;case v.MOUSE.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=ft.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=ft.PAN}break;default:this.state=ft.NONE}this.state!==ft.NONE&&this.dispatchEvent(vu)}function W1(n){switch(this.state){case ft.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case ft.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case ft.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function H1(n){this.enabled===!1||this.enableZoom===!1||this.state!==ft.NONE||(n.preventDefault(),this.dispatchEvent(vu),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(Rm))}function X1(n){this.enabled!==!1&&this._handleKeyDown(n)}function q1(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case v.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=ft.TOUCH_ROTATE;break;case v.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=ft.TOUCH_PAN;break;default:this.state=ft.NONE}break;case 2:switch(this.touches.TWO){case v.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=ft.TOUCH_DOLLY_PAN;break;case v.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=ft.TOUCH_DOLLY_ROTATE;break;default:this.state=ft.NONE}break;default:this.state=ft.NONE}this.state!==ft.NONE&&this.dispatchEvent(vu)}function Y1(n){switch(this._trackPointer(n),this.state){case ft.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case ft.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case ft.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case ft.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=ft.NONE}}function K1(n){this.enabled!==!1&&n.preventDefault()}function $1(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function J1(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Fm{constructor(e,t,i,s){this._Engine=e,this.camera=t,this.domElement=i,this._isEnabled=!1,this._rayOriginOffset=new w.Vector3(0,-1,0),this._camerLocalDirection=new w.Vector3,this._tmpVector=new w.Vector3,this._rayCaster=new w.Raycaster,this._fallingTime=0,this._isMouseInElement=!1,this._euler=new w.Euler(0,0,0,"YZX"),this._prevMouseX=0,this._prevMouseY=0,this.applyGravity=!1,this.gravityMinHeight=!0,this.applyCollision=!0,this.positionEasing=!0,this.lookflag=1,this.lookSpeed=.003,this.moveSpeed=.02,this.playerHeight=1.4,this.maxRotateX=3,this.g=9.8,this.bindmousedown=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchStart.bind(this):this.onMouseDown.bind(this),this.bindmouseup=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchEnd.bind(this):this.onMouseUp.bind(this),this.bindmousemove=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchMove.bind(this):this.onMouseMove.bind(this),this.bindonKeyDown=this.onKeyDown.bind(this),this.bindonKeyUp=this.onKeyUp.bind(this),this.bindMousewheel=this.onMousewheel.bind(this),this.bindMouseEnter=this.onMouseEnter.bind(this),this.bindMouseLeave=this.onMouseLeave.bind(this),this.needMousewheel=!1,this.moveWheelRun=!0,this.moveWheelStop=!1,this.wheelClock,this.keydown=!1,this.shiftDown=!1,this.gravityTestCount=5,this.catchTestCount=10,this.GetEngine=()=>e}set colliders(e){this._rayCastObjects=e}set enabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._euler.setFromQuaternion(this.camera.quaternion),e?this.addEvents():this.removeEvents())}get enabled(){return this._isEnabled}addEvents(){const e=this._Engine?.DeviceType,t=e==="PC"||!e;console.log("[FirstPersonCameraControl] addEvents - DeviceType:",e,"isPC:",t),t?(console.log("[FirstPersonCameraControl] 添加鼠标事件监听器 - mousedown, mouseup"),this.domElement.addEventListener("mousedown",this.bindmousedown,!1),this.domElement.addEventListener("mouseup",this.bindmouseup,!1)):(console.log("[FirstPersonCameraControl] 添加触摸事件监听器"),this.domElement.addEventListener("touchstart",this.bindmousedown,!1),this.domElement.addEventListener("touchend",this.bindmouseup,!1)),this.domElement.addEventListener("mouseenter",this.bindMouseEnter,!1),this.domElement.addEventListener("mouseleave",this.bindMouseLeave,!1),window.addEventListener("keydown",this.bindonKeyDown,!1),window.addEventListener("keyup",this.bindonKeyUp,!1),this.needMousewheel&&(document.addEventListener&&document.addEventListener("DOMMouseScroll",this.bindMousewheel,!1),window.addEventListener("mousewheel",this.bindMousewheel,!1))}removeEvents(){this._Engine&&this._Engine.deviceType!=="PC"?(this.domElement.removeEventListener("touchstart",this.bindmousedown),this.domElement.removeEventListener("touchend",this.bindmouseup),this.domElement.removeEventListener("touchmove",this.bindmousemove)):(this.domElement.removeEventListener("mousedown",this.bindmousedown),this.domElement.removeEventListener("mouseup",this.bindmouseup),this.domElement.removeEventListener("mousemove",this.bindmousemove)),this.domElement.removeEventListener("mouseenter",this.bindMouseEnter),this.domElement.removeEventListener("mouseleave",this.bindMouseLeave),window.removeEventListener("keydown",this.bindonKeyDown),window.removeEventListener("keyup",this.bindonKeyUp),this.needMousewheel&&(document.addEventListener&&document.removeEventListener("DOMMouseScroll",this.bindMousewheel),window.removeEventListener("mousewheel",this.bindMousewheel))}onMouseEnter(e){this._isMouseInElement=!0}onMouseLeave(e){this._isMouseInElement=!1}onMousewheel(e){let t;switch(e.wheelDelta?(e.wheelDelta>0&&(t="up"),e.wheelDelta<0&&(t="down")):e.detail&&(e.detail<0&&(t="up"),e.detail>0&&(t="down")),t){case"up":this._camerLocalDirection.z=1;break;case"down":this._camerLocalDirection.z=-1;break}this.moveWheelRun==!0?(this.moveWheelRun=!1,this.moveWheelStop=!0,this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},200)):(clearTimeout(this.wheelClock),this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},150))}onMouseDown(e){console.log("[FirstPersonCameraControl] onMouseDown 被调用",e),this.domElement.addEventListener("mousemove",this.bindmousemove,!1),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY}onMouseMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.screenX-this._prevMouseX:0,i=this._prevMouseY?e.screenY-this._prevMouseY:0,s=this._euler.x-i*this.lookflag*this.lookSpeed;s>=0?s<this.maxRotateX?this._euler.x=s:this._euler.x=this.maxRotateX:s>-this.maxRotateX?this._euler.x=s:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY;let r=this.GetEngine();r.movefirst=!0;var o=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(o)}onMouseUp(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("mousemove",this.bindmousemove)}onTouchStart(e){this.domElement.addEventListener("touchmove",this.bindmousemove,!1),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY}onTouchMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.targetTouches[0].clientX-this._prevMouseX:0,i=this._prevMouseY?e.targetTouches[0].clientY-this._prevMouseY:0,s=this._euler.x-i*this.lookflag*this.lookSpeed;s>=0?s<this.maxRotateX?this._euler.x=s:this._euler.x=this.maxRotateX:s>-this.maxRotateX?this._euler.x=s:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY;let r=this.GetEngine();r.movefirst=!0;var o=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(o)}onTouchEnd(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("touchmove",this.bindmousemove)}onKeyDown(e){if(!this._isMouseInElement)return;var t=new CustomEvent("bimengine:camerachange",{detail:""});let i=this.GetEngine();switch(i.movefirst=!0,window.dispatchEvent(t),e.keyCode){case 38:this.rotateY(-1);break;case 81:this.keydown=!0,this._camerLocalDirection.y=1;break;case 69:this._camerLocalDirection.y=-1;break;case 87:this._camerLocalDirection.z=1;break;case 37:this.rotateX(-1);break;case 65:this._camerLocalDirection.x=-1;break;case 40:this.rotateY(1);break;case 83:this._camerLocalDirection.z=-1;break;case 39:this.rotateX(1);break;case 68:this._camerLocalDirection.x=1;break;case 16:this.shiftDown=!0;break}}onKeyUp(e){if(!this._isMouseInElement)return;let t=this.GetEngine();switch(t.movefirst=!1,e.keyCode){case 38:case 87:this._camerLocalDirection.z=0;break;case 37:case 65:this._camerLocalDirection.x=0;break;case 40:case 83:this._camerLocalDirection.z=0;break;case 39:case 68:this._camerLocalDirection.x=0;break;case 81:case 69:this.keydown=!1,this._camerLocalDirection.y=0;break;case 16:this.shiftDown=!1;break}}rotateX(e){this._euler.y-=e*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler)}rotateY(e){let t=this._euler.x-e*this.lookflag*.5*this.lookSpeed;t>=0?t<this.maxRotateX?this._euler.x=t:this._euler.x=this.maxRotateX:t>-this.maxRotateX?this._euler.x=t:this._euler.x=-this.maxRotateX,this.camera.quaternion.setFromEuler(this._euler)}update(){this.keydown||this.gravityTest(),this.collisionTest()}gravityTest(){if(!(this._camerLocalDirection.y==0&&this._camerLocalDirection.z==0&&this._camerLocalDirection.x==0))if(this.applyGravity){let e=!0;this._fallingTime+=.01,this._tmpVector.set(0,-1,0);const t=this.hitTest();if(t==null)return;if(t){const i=t.point.add(new w.Vector3(0,this.playerHeight,0));if(this.positionEasing){if(i.y>=this.camera.position.y||i.y-this.camera.position.y<.2){this.setCameraHeight(this.camera.position.y+(i.y-this.camera.position.y)*.08),this._fallingTime=0,e=!1;return}}else t.distance<this.playerHeight&&(this.setCameraHeight(i.y),this._fallingTime=0,e=!1)}e&&this.setCameraHeight(this.camera.position.y-this.g*Math.pow(this._fallingTime,2))}else this.setCameraHeight(this.camera.position.y)}collisionTest(){this._camerLocalDirection.x!==0&&this.collisionTestX(),this._camerLocalDirection.z!==0&&this.collisionTestZ(),this._camerLocalDirection.y!==0&&this.collisionTestY()}collisionTestX(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.x),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed*(this.shiftDown?2:1))}collisionTestZ(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.crossVectors(this.camera.up,this._tmpVector),this._tmpVector.multiplyScalar(this._camerLocalDirection.z),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed*(this.shiftDown?2:1))}collisionTestY(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector=new w.Vector3(0,1,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.y),this.applyCollision){const i=this.hitTest();if(i&&i.distance<.3)return}let t=this.camera.position.clone().addScaledVector(this._tmpVector,this.moveSpeed*(this.shiftDown?2:1));this.setCameraHeight(t.y)}setCameraHeight(e){let t=this.getMinHeight();this.gravityMinHeight&&t!==void 0&&e<t?this.camera.position.y=t:this.camera.position.y=e}getMinHeight(){let e,t=this.GetEngine(),i=t.ToolUntils?t.ToolUntils.GetBoundingBox(t):null;return t&&i&&(e=i.min.y),e}hitTest(){const e=this.camera.position.clone().add(this._rayOriginOffset);this._rayCaster.ray.origin=e,this._rayCaster.ray.direction=this._tmpVector;let t=this.GetEngine();var i=t.scene.ground;i&&i.material.type;let s={},r=t.handelBehaved.handle_catch(this._rayCaster,s);if(r==null)return null;let o=r.object.name,a=r.object.url,l=t.models.find(c=>c.url==a);if(l!=null){let c=l.nodesMap.get(o);if(c.infos!=null&&c.infos.length!=0&&c.infos[0].name&&(c.infos[0].name.includes("门")||c.infos[0].name.includes("門")||c.infos[0].name.includes("door")))return null}return r}}function _u(n){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.handle_catch=function(p,m){return g(p,m,!0)},e.init=function(p,m){e.self!=null&&e.self.disActive!=null&&e.self.type!=p.type&&e.self.disActive(),e.self=p,m==null&&(m={showCatch:!1}),e.options=m,e.isClickSimpleModel=!0},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){n.renderer.domElement.addEventListener("mousedown",a),n.renderer.domElement.addEventListener("mouseup",c),n.renderer.domElement.addEventListener("mousemove",l),n.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),n.renderer.domElement.addEventListener("touchend",u,{passive:!1}),n.renderer.domElement.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",i)},e.disActive=function(){n.renderer.domElement.removeEventListener("mousedown",a),n.renderer.domElement.removeEventListener("mouseup",c),n.renderer.domElement.removeEventListener("mousemove",l),n.renderer.domElement.removeEventListener("touchstart",d),n.renderer.domElement.removeEventListener("touchend",u),n.renderer.domElement.removeEventListener("touchmove",f),window.removeEventListener("keydown",t),window.removeEventListener("keyup",i)};function t(p){(p.keyCode===8||p.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),p.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),p.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),p.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),p.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),p.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),p.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),p.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function i(p){p.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),p.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),p.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),p.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),p.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),p.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),p.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function s(p){const m=new w.Vector2,A=n.renderer.domElement.clientWidth,x=n.renderer.domElement.clientHeight;return m.x=p.offsetX/A*2-1,m.y=-(p.offsetY/x)*2+1,m}function r(p){const m=new w.Raycaster,A=s(p);return m.setFromCamera(A,n.camera),m}function o(p,m=!1,A=!1,x=!0){const b=r(p);if(p.raycaster=b,m){const y=g(b,p,A,x);p.catch=y}}function a(p){e.mouseDownTime=Date.now(),e.mouseDownPosition=new w.Vector3(p.offsetX,p.offsetY,0),e.self&&e.self.handleMouseDown!=null&&p.button==0&&(o(p,!0,!0),p.catch!=null&&(n.engineStatus.highlightModels==null||n.engineStatus.highlightModels.length==0)&&n.controlModule.orbitControls.origin.set(p.catch.point.x,p.catch.point.y,p.catch.point.z),e.self.handleMouseDown(p))}function l(p){e.self&&e.self.handleMouseMove!=null&&(n.engineStatus.isFree&&o(p,!0,!0,e.isClickSimpleModel),e.self.handleMouseMove(p))}function c(p){const m=Date.now(),A=m-e.mouseDownTime,x=new w.Vector3(p.offsetX,p.offsetY,0);e.self&&e.self.handleMouseUp!=null&&p.button==0&&(o(p,!1,!1,!1),e.self.handleMouseUp(p));const b=x.distanceTo(e.mouseDownPosition);(A<100||b==0)&&e.self&&e.self.handleMouseClick!=null&&(o(p,!0,!0,!1),m-e.lastClickTime<200?e.self.handleMouseDoubleClick!=null&&p.button==0&&e.self.handleMouseDoubleClick(p):e.self.handleMouseClick!=null&&p.button==0?e.self.handleMouseClick(p):e.self.handleRightMouseClick!=null&&p.button==2&&e.self.handleRightMouseClick(p),e.lastClickTime=Date.now())}function h(p){const m=p.touches[0]||p.changedTouches[0];if(!m)return null;const x=n.renderer.domElement.getBoundingClientRect(),b=m.clientX-x.left,y=m.clientY-x.top;return{offsetX:b,offsetY:y,button:0,clientX:m.clientX,clientY:m.clientY,preventDefault:()=>p.preventDefault(),stopPropagation:()=>p.stopPropagation(),originalEvent:p}}function d(p){if(p.preventDefault(),p.touches.length!==1)return;const m=h(p);m&&a(m)}function f(p){if(p.preventDefault(),p.touches.length!==1)return;const m=h(p);m&&l(m)}function u(p){p.preventDefault();const m=h(p);m&&c(m)}function g(p,m,A=!1,x=!0){if(!n.engineStatus.isFree&&A==!1){n.hoverHighLight.clearHighlight();return}n.catchSvg.innerHTML="";let b=n.octreeBox.rayInterationModel(p,A,x);b=n.clipping?.filterIntersectionsByClipping(b)??b;let y=n.scene.children.filter(j=>j instanceof w.InstancedMesh);x&&(y=y.filter(j=>j.count<500));let _=p.intersectObjects(y,!1);if(_=n.clipping?.filterIntersectionsByClipping(_)??_,_.length>0&&(b.length==0||_[0].distance<b[0].distance)){let j=_[0].object;if(j.ids!=null&&j.ids.length!=0){let N=j.ids[_[0].instanceId],Y={object:{url:j.url,id:N,name:N,isInstance:!0},face:_[0].face,distance:_[0].distance,point:_[0].point,instanceId:_[0].instanceId,matrix:j.matrixs[_[0].instanceId]};b.splice(0,0,Y)}}if(b.length===0)return;let S=b[0].object.url,C=b[0].object.name,D=n.modelEdge.getModelEdge(S,C);D||(D=[0,0,[]]);let M=[];D[2].forEach(j=>{j[0]!=null&&j[1]!=null&&M.push({X:j[0].X*.5+j[1].X*.5,Y:j[0].Y*.5+j[1].Y*.5,Z:j[0].Z*.5+j[1].Z*.5})});let I=[...D[2].map(j=>j[0]),...M],P="face",T=[],L=[],E=10;if(I.forEach(j=>{if(j!=null){let N=new w.Vector3(j.X,j.Z,-j.Y);if(n.clipping&&!n.clipping.isPointInClippingRange(N))return;let Y=new lt(n.camera,n.renderer,n.scene).worldToScreen(N),V=Math.sqrt(Math.pow(Y.x-m.offsetX,2)+Math.pow(Y.y-m.offsetY,2));V<E&&(E=V,T.push({point:N,distance:V,pointxy:Y}))}}),T.length>0?(T.sort((j,N)=>j.distance-N.distance),P="point"):(D[2].forEach(j=>{if(j[0]!=null&&j[1]!=null){let N=new w.Vector3(j[0].X,j[0].Z,-j[0].Y),Y=new w.Vector3(j[1].X,j[1].Z,-j[1].Y),V=new lt(n.camera,n.renderer,n.scene).worldToScreen(N),H=new lt(n.camera,n.renderer,n.scene).worldToScreen(Y),oe=F(new w.Vector2(m.offsetX,m.offsetY),V,H);if(oe<E){let pe=z(new w.Vector2(m.offsetX,m.offsetY),V,H),ue=X(pe,N,Y);if(n.clipping&&!n.clipping.isPointInClippingRange(ue))return;L.push({distance:oe,point:ue,pointxy:new lt(n.camera,n.renderer,n.scene).worldToScreen(ue),start:V,end:H})}}}),L.length>0&&(L.sort((j,N)=>j.distance-N.distance),P="line")),P=="point"&&e.options.showCatch){const j=new lt(n.camera,n.renderer,n.scene).worldToScreen(T[0].point);n.catchSvg.innerHTML="";const N=j.x+n.reactBoundingClientRect.left,Y=j.y+n.reactBoundingClientRect.top;console.log(N,Y);const V=document.createElementNS("http://www.w3.org/2000/svg","polygon");V.setAttribute("class","catchPoint"),V.setAttribute("points",`${N},${Y-8} ${N-7},${Y+4} ${N+7},${Y+4}`),V.setAttribute("stroke","rgb(8, 223, 215)"),V.setAttribute("fill","transparent"),n.catchSvg.appendChild(V),b[0].point=T[0].point}else if(P=="line"&&e.options.showCatch){const j=new lt(n.camera,n.renderer,n.scene).worldToScreen(L[0].point),N=L[0].start,Y=L[0].end;n.catchSvg.innerHTML="";const V=document.createElementNS("http://www.w3.org/2000/svg","line");V.setAttribute("class","catchLine"),V.setAttribute("x1",(N.x+n.reactBoundingClientRect.left).toString()),V.setAttribute("y1",(N.y+n.reactBoundingClientRect.top).toString()),V.setAttribute("x2",(Y.x+n.reactBoundingClientRect.left).toString()),V.setAttribute("y2",(Y.y+n.reactBoundingClientRect.top).toString()),V.setAttribute("stroke","rgb(8, 223, 215)"),V.setAttribute("stroke-width","2"),n.catchSvg.appendChild(V);const H=j.x+n.reactBoundingClientRect.left,oe=j.y+n.reactBoundingClientRect.top,pe=document.createElementNS("http://www.w3.org/2000/svg","polygon");pe.setAttribute("class","catchPoint"),pe.setAttribute("points",`${H},${oe-8} ${H-7},${oe+4} ${H+7},${oe+4}`),pe.setAttribute("stroke","rgb(8, 223, 215)"),pe.setAttribute("fill","transparent"),n.catchSvg.appendChild(pe),b[0].point=L[0].point}else if(P=="face"&&e.options.showCatch){let j=b[0].point.clone(),N=b[0].normal||(b[0].face?b[0].face.normal:null);const Y=(N?N.clone():new w.Vector3(0,0,1)).normalize(),V=Math.abs(Y.y)<.9?new w.Vector3(0,1,0):new w.Vector3(1,0,0),H=new w.Vector3().crossVectors(Y,V).normalize(),oe=new w.Vector3().crossVectors(Y,H).normalize(),pe=20,ue=new lt(n.camera,n.renderer,n.scene),re=ue.worldToScreen(j),de=ue.worldToScreen(new w.Vector3().copy(j).add(H)),Ae=Math.sqrt((de.x-re.x)**2+(de.y-re.y)**2),ye=Ae>0?pe/Ae:.2,nt=[new w.Vector3().copy(H).add(oe).multiplyScalar(ye),new w.Vector3().copy(H).sub(oe).multiplyScalar(ye),new w.Vector3().copy(H).multiplyScalar(-1).sub(oe).multiplyScalar(ye),new w.Vector3().copy(H).multiplyScalar(-1).add(oe).multiplyScalar(ye)].map(B=>new w.Vector3().copy(j).add(B)).map(B=>new lt(n.camera,n.renderer,n.scene).worldToScreen(B));n.catchSvg.innerHTML="";const Ge=document.createElementNS("http://www.w3.org/2000/svg","polygon");Ge.setAttribute("class","catchFace"),Ge.setAttribute("points",nt.map(B=>`${B.x+n.reactBoundingClientRect.left},${B.y+n.reactBoundingClientRect.top}`).join(" ")),Ge.setAttribute("fill","rgba(1, 238, 255, 0.2)"),Ge.setAttribute("stroke","rgb(0, 255, 247)"),Ge.setAttribute("stroke-width","1"),n.catchSvg.appendChild(Ge)}return b[0];function F(j,N,Y){const V=new w.Vector2().subVectors(Y,N),H=V.lengthSq();if(H<1e-10)return j.distanceTo(N);const oe=new w.Vector2().subVectors(j,N),pe=w.MathUtils.clamp(oe.dot(V)/H,0,1),ue=new w.Vector2().copy(V).multiplyScalar(pe).add(N);return j.distanceTo(ue)}function z(j,N,Y){const V=new w.Vector2().subVectors(Y,N),H=V.lengthSq();if(H<1e-10)return 0;const oe=new w.Vector2().subVectors(j,N);return w.MathUtils.clamp(oe.dot(V)/H,0,1)}function X(j,N,Y){const V=w.MathUtils.clamp(j,0,1);return new w.Vector3().lerpVectors(N,Y,V)}}return e}class Z1{engine;orbitControls;firstPersonControls;isActive=!0;originDiv=null;handelBehaved;isDragging=!1;isDown=!1;containerOffset={left:0,top:0};constructor(e){this.engine=e,this.init(),this.handelBehaved=_u(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new z1(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new Fm(this.engine,this.engine.camera,this.engine.renderer.domElement);const e=document.createElement("div");this.originDiv=e,e.className="originDiv",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.width="30px",e.style.height="30px",e.style.borderRadius="50%",e.style.pointerEvents="none",e.style.backgroundImage="url(/assets/svg/rotate-orbit.svg)",this.engine.container.appendChild(this.originDiv)}active(){this.isActive=!0,this.orbitControls.enabled=!0}disActive(){this.isActive=!1,this.orbitControls.enabled=!1}setMoveSpeed(e){this.firstPersonControls.moveSpeed=e*.1}getMoveSpeed(){return this.firstPersonControls.moveSpeed*10}setApplyCollision(e){this.firstPersonControls.applyCollision=e}getApplyCollision(){return this.firstPersonControls.applyCollision}setApplyGravity(e){this.firstPersonControls.applyGravity=e}getApplyGravity(){return this.firstPersonControls.applyGravity}toggleMinMap(){this.engine.minMap.toggle()}switchFirstPersonMode(){this.engine.cameraModule.switchToPerspectiveCamera(),this.firstPersonControls=new Fm(this.engine,this.engine.camera,this.engine.renderer.domElement,[]),this.orbitControls.enabled=!1,this.firstPersonControls.enabled=!0,this.firstPersonControls.isActive=!0,this.engine.worldToScreen=new lt(this.engine.camera,this.engine.renderer,this.engine.scene)}switchDefaultMode(){if(this.firstPersonControls){this.firstPersonControls.enabled=!1;const e=this.engine.camera,t=new w.Vector3;e.getWorldDirection(t),this.orbitControls.target.copy(e.position).add(t.multiplyScalar(10)),this.orbitControls.update()}this.orbitControls.enabled=!0,this.engine.worldToScreen=new lt(this.engine.camera,this.engine.renderer,this.engine.scene)}handleMouseUp(e){this.isDragging=!1,this.isDown=!1}handleMouseMove(e){this.isDown?this.isDragging=!0:this.isDragging=!1}handleMouseDown(e){this.isDown=!0}handleMouseClick(e){this.isDragging=!1,this.isDown=!1}update(){if(this.firstPersonControls.enabled&&this.firstPersonControls.update(),this.orbitControls.enabled){const e=this.engine.controlModule.orbitControls.origin,i=this.engine.worldToScreen.worldToScreen(e);this.originDiv&&this.isDragging?(this.originDiv.style.left=i.x-15+this.engine.reactBoundingClientRect.left+"px",this.originDiv.style.top=i.y-15+this.engine.reactBoundingClientRect.top+"px",this.originDiv.style.display="block"):this.originDiv&&(this.originDiv.style.display="none")}}}const rr={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
3948
3948
|
|
|
3949
3949
|
varying vec2 vUv;
|
|
3950
3950
|
|
|
@@ -4938,11 +4938,11 @@ void main() {
|
|
|
4938
4938
|
`):" "+CA(o[0]):"as no adapter specified";throw new Je("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return s}const MA={getAdapter:LI,adapters:Lu};function Ru(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new uo(null,n)}function EA(n){return Ru(n),n.headers=bi.from(n.headers),n.data=Pu.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),MA.getAdapter(n.adapter||la.adapter,n)(n).then(function(i){return Ru(n),i.data=Pu.call(n,n.transformResponse,i),i.headers=bi.from(i.headers),i},function(i){return uA(i)||(Ru(n),i&&i.response&&(i.response.data=Pu.call(n,n.transformResponse,i.response),i.response.headers=bi.from(i.response.headers))),Promise.reject(i)})}const IA="1.13.2",Ac={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{Ac[n]=function(i){return typeof i===n||"a"+(e<1?"n ":" ")+n}});const TA={};Ac.transitional=function(e,t,i){function s(r,o){return"[Axios v"+IA+"] Transitional option '"+r+"'"+o+(i?". "+i:"")}return(r,o,a)=>{if(e===!1)throw new Je(s(o," has been removed"+(t?" in "+t:"")),Je.ERR_DEPRECATED);return t&&!TA[o]&&(TA[o]=!0,console.warn(s(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(r,o,a):!0}},Ac.spelling=function(e){return(t,i)=>(console.warn(`${i} is likely a misspelling of ${e}`),!0)};function RI(n,e,t){if(typeof n!="object")throw new Je("options must be an object",Je.ERR_BAD_OPTION_VALUE);const i=Object.keys(n);let s=i.length;for(;s-- >0;){const r=i[s],o=e[r];if(o){const a=n[r],l=a===void 0||o(a,r,n);if(l!==!0)throw new Je("option "+r+" must be "+l,Je.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Je("Unknown option "+r,Je.ERR_BAD_OPTION)}}const xc={assertOptions:RI,validators:Ac},bn=xc.validators;let cr=class{constructor(e){this.defaults=e||{},this.interceptors={request:new lA,response:new lA}}async request(e,t){try{return await this._request(e,t)}catch(i){if(i instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const r=s.stack?s.stack.replace(/^.+\n/,""):"";try{i.stack?r&&!String(i.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(i.stack+=`
|
|
4939
4939
|
`+r):i.stack=r}catch{}}throw i}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=lr(this.defaults,t);const{transitional:i,paramsSerializer:s,headers:r}=t;i!==void 0&&xc.assertOptions(i,{silentJSONParsing:bn.transitional(bn.boolean),forcedJSONParsing:bn.transitional(bn.boolean),clarifyTimeoutError:bn.transitional(bn.boolean)},!1),s!=null&&(ce.isFunction(s)?t.paramsSerializer={serialize:s}:xc.assertOptions(s,{encode:bn.function,serialize:bn.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),xc.assertOptions(t,{baseUrl:bn.spelling("baseURL"),withXsrfToken:bn.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=r&&ce.merge(r.common,r[t.method]);r&&ce.forEach(["delete","get","head","post","put","patch","common"],g=>{delete r[g]}),t.headers=bi.concat(o,r);const a=[];let l=!0;this.interceptors.request.forEach(function(p){typeof p.runWhen=="function"&&p.runWhen(t)===!1||(l=l&&p.synchronous,a.unshift(p.fulfilled,p.rejected))});const c=[];this.interceptors.response.forEach(function(p){c.push(p.fulfilled,p.rejected)});let h,d=0,f;if(!l){const g=[EA.bind(this),void 0];for(g.unshift(...a),g.push(...c),f=g.length,h=Promise.resolve(t);d<f;)h=h.then(g[d++],g[d++]);return h}f=a.length;let u=t;for(;d<f;){const g=a[d++],p=a[d++];try{u=g(u)}catch(m){p.call(this,m);break}}try{h=EA.call(this,u)}catch(g){return Promise.reject(g)}for(d=0,f=c.length;d<f;)h=h.then(c[d++],c[d++]);return h}getUri(e){e=lr(this.defaults,e);const t=mA(e.baseURL,e.url,e.allowAbsoluteUrls);return aA(t,e.params,e.paramsSerializer)}};ce.forEach(["delete","get","head","options"],function(e){cr.prototype[e]=function(t,i){return this.request(lr(i||{},{method:e,url:t,data:(i||{}).data}))}}),ce.forEach(["post","put","patch"],function(e){function t(i){return function(r,o,a){return this.request(lr(a||{},{method:e,headers:i?{"Content-Type":"multipart/form-data"}:{},url:r,data:o}))}}cr.prototype[e]=t(),cr.prototype[e+"Form"]=t(!0)});let kI=class qv{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const i=this;this.promise.then(s=>{if(!i._listeners)return;let r=i._listeners.length;for(;r-- >0;)i._listeners[r](s);i._listeners=null}),this.promise.then=s=>{let r;const o=new Promise(a=>{i.subscribe(a),r=a}).then(s);return o.cancel=function(){i.unsubscribe(r)},o},e(function(r,o,a){i.reason||(i.reason=new uo(r,o,a),t(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=i=>{e.abort(i)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new qv(function(s){e=s}),cancel:e}}};function FI(n){return function(t){return n.apply(null,t)}}function OI(n){return ce.isObject(n)&&n.isAxiosError===!0}const ku={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(ku).forEach(([n,e])=>{ku[e]=n});function DA(n){const e=new cr(n),t=Hm(cr.prototype.request,e);return ce.extend(t,cr.prototype,e,{allOwnKeys:!0}),ce.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return DA(lr(n,s))},t}const Ct=DA(la);Ct.Axios=cr,Ct.CanceledError=uo,Ct.CancelToken=kI,Ct.isCancel=uA,Ct.VERSION=IA,Ct.toFormData=fc,Ct.AxiosError=Je,Ct.Cancel=Ct.CanceledError,Ct.all=function(e){return Promise.all(e)},Ct.spread=FI,Ct.isAxiosError=OI,Ct.mergeConfig=lr,Ct.AxiosHeaders=bi,Ct.formToJSON=n=>hA(ce.isHTMLForm(n)?new FormData(n):n),Ct.getAdapter=MA.getAdapter,Ct.HttpStatusCode=ku,Ct.default=Ct;const{Axios:SF,AxiosError:CF,CanceledError:MF,isCancel:EF,CancelToken:IF,VERSION:TF,all:DF,Cancel:BF,isAxiosError:PF,spread:LF,toFormData:RF,AxiosHeaders:kF,HttpStatusCode:FF,formToJSON:OF,getAdapter:UF,mergeConfig:NF}=Ct;class fo{static MAGIC=new TextEncoder().encode("BIMGCM01");static isEncrypted(e){if(e.byteLength<8)return!1;const t=new Uint8Array(e);for(let i=0;i<8;i++)if(t[i]!==fo.MAGIC[i])return!1;return!0}static async decryptPzEnc(e,t){const i=new Uint8Array(e),s=new TextEncoder().encode("BIMGCM01");for(let m=0;m<s.length;m++)if(i[m]!==s[m])throw new Error("magic 不匹配: 不是有效的 pzenc 文件");const r=i[8];if(r!==1)throw new Error(`不支持的 pzenc 版本: ${r}`);const o=i[9],a=i[10],l=11,c=i.slice(l,l+o),h=i.slice(l+o,l+o+a),d=i.slice(l+o+a),f=NI(d,h),u=UI(t);if(u.length!==32)throw new Error("AES-256 密钥必须是 32 字节");const g=await crypto.subtle.importKey("raw",u.buffer,{name:"AES-GCM"},!1,["decrypt"]),p=await crypto.subtle.decrypt({name:"AES-GCM",iv:c.buffer,additionalData:i.slice(0,l).buffer,tagLength:a*8},g,f.buffer);return new Uint8Array(p)}}function UI(n){const e=atob(n),t=new Uint8Array(e.length);for(let i=0;i<e.length;i++)t[i]=e.codePointAt(i);return t}function NI(n,e){const t=new Uint8Array(n.length+e.length);return t.set(n,0),t.set(e,n.length),t}function ha(n,e,t,i){Ct({method:"get",responseType:"arraybuffer",url:n}).then(async r=>{let o=r.data;i&&fo.isEncrypted(r.data)&&(o=await fo.decryptPzEnc(r.data,i)),Wm.loadAsync(o).then(a=>{for(let l in a.files){const c=a.file(a.files[l].name);c&&c.async("blob").then(h=>{s(h,"utf-8",function(d,f){e(f)})}).catch(()=>{t()})}}).catch(()=>{t()})}).catch(()=>{t()});function s(r,o,a){var l=new FileReader,c=new Blob([r]);l.onload=function(h){a(null,h.target.result)},l.onerror=function(){a(null,null)},l.readAsText(c,o)}}const Fu=new WeakMap;class zI extends v.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,s){const r=new v.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,o=>{this.parse(o,t,s)},i,s)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,v.SRGBColorSpace,i).catch(i)}decodeDracoFile(e,t,i,s,r=v.LinearSRGBColorSpace,o=()=>{}){const a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const i=JSON.stringify(t);if(Fu.has(e)){const l=Fu.get(e);if(l.key===i)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const r=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(r,o).then(l=>(s=l,new Promise((c,h)=>{s._callbacks[r]={resolve:c,reject:h},s.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{s&&r&&this._releaseTask(s,r)}),Fu.set(e,{key:i,promise:a}),a}_createGeometry(e){const t=new v.BufferGeometry;e.index&&t.setIndex(new v.BufferAttribute(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const{name:s,array:r,itemSize:o,stride:a,vertexColorSpace:l}=e.attributes[i];let c;if(o===a)c=new v.BufferAttribute(r,o);else{const h=new v.InterleavedBuffer(r,a);c=new v.InterleavedBufferAttribute(h,o,0)}s==="color"&&(this._assignVertexColorSpace(c,l),c.normalized=!(r instanceof Float32Array)),t.setAttribute(s,c)}return t}_assignVertexColorSpace(e,t){if(t!==v.SRGBColorSpace)return;const i=new v.Color;for(let s=0,r=e.count;s<r;s++)i.fromBufferAttribute(e,s),v.ColorManagement.colorSpaceToWorking(i,v.SRGBColorSpace),e.setXYZ(s,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new v.FileLoader(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((s,r)=>{i.load(e,s,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{const s=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const r=GI.toString(),o=["/* draco decoder */",s,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
|
|
4940
4940
|
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(r){const o=r.data;switch(o.type){case"decode":s._callbacks[o.id].resolve(o);break;case"error":s._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,r){return s._taskLoad>r._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function GI(){let n,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":n=a.decoderConfig,e=new Promise(function(h){n.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(n)});break;case"decode":const l=a.buffer,c=a.taskConfig;e.then(h=>{const d=h.draco,f=new d.Decoder;try{const u=t(d,f,new Int8Array(l),c),g=u.attributes.map(p=>p.array.buffer);u.index&&g.push(u.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:u},g)}catch(u){console.error(u),self.postMessage({type:"error",id:a.id,error:u.message})}finally{d.destroy(f)}});break}};function t(o,a,l,c){const h=c.attributeIDs,d=c.attributeTypes;let f,u;const g=a.GetEncodedGeometryType(l);if(g===o.TRIANGULAR_MESH)f=new o.Mesh,u=a.DecodeArrayToMesh(l,l.byteLength,f);else if(g===o.POINT_CLOUD)f=new o.PointCloud,u=a.DecodeArrayToPointCloud(l,l.byteLength,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const p={index:null,attributes:[]};for(const m in h){const A=self[d[m]];let x,b;if(c.useUniqueIDs)b=h[m],x=a.GetAttributeByUniqueId(f,b);else{if(b=a.GetAttributeId(f,o[h[m]]),b===-1)continue;x=a.GetAttribute(f,b)}const y=s(o,a,f,m,A,x);m==="color"&&(y.vertexColorSpace=c.vertexColorSpace),p.attributes.push(y)}return g===o.TRIANGULAR_MESH&&(p.index=i(o,a,f)),o.destroy(f),p}function i(o,a,l){const h=l.num_faces()*3,d=h*4,f=o._malloc(d);a.GetTrianglesUInt32Array(l,d,f);const u=new Uint32Array(o.HEAPF32.buffer,f,h).slice();return o._free(f),{array:u,itemSize:1}}function s(o,a,l,c,h,d){const f=l.num_points(),u=d.num_components(),g=r(o,h),p=u*h.BYTES_PER_ELEMENT,m=Math.ceil(p/4)*4,A=m/h.BYTES_PER_ELEMENT,x=f*p,b=f*m,y=o._malloc(x);a.GetAttributeDataArrayForAllPoints(l,d,g,x,y);const _=new h(o.HEAPF32.buffer,y,x/h.BYTES_PER_ELEMENT);let S;if(p===m)S=_.slice();else{S=new h(b/h.BYTES_PER_ELEMENT);let C=0;for(let D=0,M=_.length;D<M;D++){for(let I=0;I<u;I++)S[C+I]=_[D*u+I];C+=A}}return o._free(y),{name:c,count:f,itemSize:u,array:S,stride:A}}function r(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var VI=(function(){var n="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuec:W:Odkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq;lZkdbk;jYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbhodnawTmbaxa8Acd4fRbbhokaocFeGh5cbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q1jjbfcj1jjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bbarcwf9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfag9c8F1:NghcKtc8F91aicdfa8J9c8N1:Nfg8KRbbG86bbarcVfcba8KahcjeGcr4fghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fag9c8F1:NgicKtc8F91aha8J9c8N1:NfghRbbG86bbarc96fcbahaicjeGcr4fgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbb83bbarcwfaicwf8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbcbaocl49Rh8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E93aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:XseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk::ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxabaiarcefciGfcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGfgkcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkabaiarcufciGfcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkabakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K1jjbgeabcifc98GfgbBd:K1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;teeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiaeydlBdlaiaeydwBdwaiaeydxBdxaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk:3eedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdxaialBdwaialBdlaialBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk81dbcjwk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:Kwkl8WNbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuec:q:6dkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:Ctklbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk:183lYud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxavaialfgmar9Rgoad;8qbbcj;abad9Uc;WFbGcjdadca0EhPdndndnadTmbaoadfhscbhzinaeaz9nmdamax9RaD6miabazad2fhHaxaDfhOaPaeaz9RazaPfae6EgAcsfgocl4cifcd4hCavcj;cbfaoc9WGgXcetfhQavcj;cbfaXci2fhLavcj;cbfaXfhKcbhYaoc;ab6h8AincbhodnawTmbaxaYcd4fRbbhokaocFeGhEcbh3avcj;cbfh5indndndndnaEa3cet4ciGgoc9:fPdebdkamaO9RaX6mwavcj;cbfa3aX2faOaX;8qbbaOaAfhOxdkavcj;cbfa3aX2fcbaX;8kbxekamaO9RaC6moaoclVcbawEhraOaCfhocbhidna8Ambamao9Rc;Gb6mbcbhlina5alfhidndndndndndnaOalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiczfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaicafaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaoclffaqc:q:yjjbfRbbfhoxikaic8Wfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaocwffaqc:q:yjjbfRbbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitc:q1jjbfpbibaic:q:yjjbfRbbgipsaoRbegqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqc:q:yjjbfRbbfhokalc;abfhialcjefaX0meaihlamao9Rc;Fb0mbkkdnaiaX9pmbaici4hlinamao9RcK6mwa5aifhqdndndndndndnaOaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaoclffahc:q:yjjbfRbbfhoxikaqaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaocwffahc:q:yjjbfRbbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpkbbaaaocdffahc:q:yjjbfRbbfhokalcdfhlaiczfgiaX6mbkkaohOaoTmoka5aXfh5a3cefg3cl9hmbkdndndndnawTmbasaYcd4fRbbglciGPlbedwbkaXTmdavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep9Ta8Epxeeeeeeeeeeeeeeeeg8Fp9op9Hp9rg8Eagp9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Ug8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9AbbbaladfhlaoczfgoaX6mbxikkaXTmeavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep:nea8Epxebebebebebebebebg8Fp9op:bep9rg8Eagp:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeg8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9AbbbaladfhlaoczfgoaX6mbxdkkaXTmbcbhocbalcl4gl9Rc8FGhiavcjdfaYfhravaYfpbdbh8Finaravcj;cbfaofpblbggaKaofpblbg8JpmbzeHdOiAlCvXoQrLg8KaQaofpblbg8LaLaofpblbg8MpmbzeHdOiAlCvXoQrLg8NpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ea8Fp9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Fa8Ka8NpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwKDYq8AkEx3m5P8Es8Fgga8La8MpmwKDYq8AkEx3m5P8Es8Fg8JpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9AbbbaradfhraoczfgoaX6mbkkaYclfgYad6mbkaHavcjdfaAad2;8qbbavavcjdfaAcufad2fad;8qbbaAazfhzc9:hoaOhxaOmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdaPaeao9RaoaPfae6Eaofgoae6mbkaial9Rhxkcbc99amax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbk:TseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:2Pliur97eue978Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbdnalTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalaeSmeaipxbbbbbbbbbbbbbbbbgqpklbaiabalcdtfgdaeciGglcdtgv;8qbbdnalTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDaqp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkadaiav;8qbbskaipxFubbFubbFubbFubbgxpklbdnalTmbcbhvabhdinadczfgmampbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblbaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oaoarpmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgval6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgopklbaiaopklbaiabalcitfgdaeciGglcitgv;8qbbaiaxpkladnalTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblaaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oaoarpmbezHdiOAlvCXorQLp9qpklbkadaiav;8qbbkk:Iwllue97euo978Jjjjjbca9Rhidnaec98GglTmbcbhvabhoinaocKfpx:ji:1S:ji:1S:ji:1S:ji:1SaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83ibawarp5bampEd:T:j83ibaocwfaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83ibaoaxp5bampEb:T:j83ibaocafhoavclfgval6mbkkdnalaeSmbaiczfpxbbbbbbbbbbbbbbbbgmpklbaiampklbaiabalcitfgoaeciGgvcitgw;8qbbdnavTmbaipx:ji:1S:ji:1S:ji:1S:ji:1SaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83iKaiarp5bampEd:T:j83izaiaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83iwaiaxp5bampEb:T:j83ibkaoaiaw;8qbbkk;uddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbheabhdinadadpbbbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbadczfhdaeclfgeav6mbkkdnavalSmbaic8WfpxbbbbbbbbbbbbbbbbgopklbaicafaopklbaiczfaopklbaiaopklbaiabavcdtfgdalciGgecdtgv;8qbbdnaeTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepklbkadaiav;8qbbkk:CPvdue97euw97eu8Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadpbbbhradpxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpkbbadczfhdaoclfgoal6mbkkalaeSmeaiavpklaaicafabalcdtfgdaeciGglcdtgo;8qbbaiavpklbdnalTmbaipblahraipxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpklakadaicafao;8qbbskaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadczfgspxbFu9hbFu9hbFu9hbFu9hadpbbbgDaspbbbgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblbp9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpkbbadaxarpmbezHdiOAlvCXorQLpkbbadcafhdaoclfgoal6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgrpklbaiarpklbaiabalcitfgdaeciGglcitgo;8qbbaiavpkladnalTmbaipxbFu9hbFu9hbFu9hbFu9haipblbgDaipblzgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblap9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpklzaiaxarpmbezHdiOAlvCXorQLpklbkadaiao;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz:Dbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),i=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var s=WebAssembly.validate(t)?a(e):a(n),r,o=WebAssembly.instantiate(s,{}).then(function(A){r=A.instance,r.exports.__wasm_call_ctors()});function a(A){for(var x=new Uint8Array(A.length),b=0;b<A.length;++b){var y=A.charCodeAt(b);x[b]=y>96?y-97:y>64?y-39:y+4}for(var _=0,b=0;b<A.length;++b)x[_++]=x[b]<60?i[x[b]]:(x[b]-60)*64+x[++b];return x.buffer.slice(0,_)}function l(A,x,b,y,_,S,C){var D=A.exports.sbrk,M=y+3&-4,I=D(M*_),P=D(S.length),T=new Uint8Array(A.exports.memory.buffer);T.set(S,P);var L=x(I,y,_,P,S.length);if(L==0&&C&&C(I,M,_),b.set(T.subarray(I,I+y*_)),D(I-D(0)),L!=0)throw new Error("Malformed buffer data: "+L)}var c={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],f=0;function u(A){var x={object:new Worker(A),pending:0,requests:{}};return x.object.onmessage=function(b){var y=b.data;x.pending-=y.count,x.requests[y.id][y.action](y.value),delete x.requests[y.id]},x}function g(A){for(var x="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(s)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+m.name+";"+l.toString()+m.toString(),b=new Blob([x],{type:"text/javascript"}),y=URL.createObjectURL(b),_=d.length;_<A;++_)d[_]=u(y);for(var _=A;_<d.length;++_)d[_].object.postMessage({});d.length=A,URL.revokeObjectURL(y)}function p(A,x,b,y,_){for(var S=d[0],C=1;C<d.length;++C)d[C].pending<S.pending&&(S=d[C]);return new Promise(function(D,M){var I=new Uint8Array(b),P=++f;S.pending+=A,S.requests[P]={resolve:D,reject:M},S.object.postMessage({id:P,count:A,size:x,source:I,mode:y,filter:_},[I.buffer])})}function m(A){var x=A.data;if(!x.id)return self.close();self.ready.then(function(b){try{var y=new Uint8Array(x.count*x.size);l(b,b.exports[x.mode],y,x.count,x.size,x.source,b.exports[x.filter]),self.postMessage({id:x.id,count:x.count,action:"resolve",value:y},[y.buffer])}catch(_){self.postMessage({id:x.id,count:x.count,action:"reject",value:_})}})}return{ready:o,supported:!0,useWorkers:function(A){g(A)},decodeVertexBuffer:function(A,x,b,y,_){l(r,r.exports.meshopt_decodeVertexBuffer,A,x,b,y,r.exports[c[_]])},decodeIndexBuffer:function(A,x,b,y){l(r,r.exports.meshopt_decodeIndexBuffer,A,x,b,y)},decodeIndexSequence:function(A,x,b,y){l(r,r.exports.meshopt_decodeIndexSequence,A,x,b,y)},decodeGltfBuffer:function(A,x,b,y,_,S){l(r,r.exports[h[_]],A,x,b,y,r.exports[c[S]])},decodeGltfBufferAsync:function(A,x,b,y,_){return d.length>0?p(A,x,b,h[y],c[_]):o.then(function(){var S=new Uint8Array(A*x);return l(r,r.exports[h[y]],S,A,x,b,r.exports[c[_]]),S})}}})();class QI{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0,this.workerCreator=null}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const i=this.workersResolve[e];if(i&&i(t),this.queue.length){const{resolve:s,msg:r,transfer:o}=this.queue.shift();this.workersResolve[e]=s,this.workers[e].postMessage(r,o)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(i=>{const s=this._getIdleWorker();s!==-1?(this._initWorker(s),this.workerStatus|=1<<s,this.workersResolve[s]=i,this.workers[s].postMessage(e,t)):this.queue.push({resolve:i,msg:e,transfer:t})})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const jI=0,BA=2,WI=1,PA=2,HI=0,XI=1,qI=10,YI=0,LA=9,RA=15,kA=16,FA=22,OA=37,UA=43,NA=76,zA=83,GA=97,VA=100,QA=103,jA=109,WA=122,HA=123,XA=131,qA=132,YA=133,KA=134,$A=137,JA=138,ZA=139,e0=140,t0=141,i0=142,n0=145,s0=146,r0=148,o0=152,a0=153,l0=154,c0=155,h0=156,d0=157,u0=158,f0=165,p0=166,g0=1000054e3,m0=1000054001,A0=1000054004,x0=1000054005,Ou=1000066e3,b0=1000066004;let da=class{constructor(e,t,i,s){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,i),this._littleEndian=s,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){const i=this._offset;let s=0;for(;this._dataView.getUint8(this._offset)!==t&&s<e;)s++,this._offset++;return s<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+i,s)}};const oi=[171,75,84,88,32,50,48,187,13,10,26,10];function y0(n){return new TextDecoder().decode(n)}function KI(n){const e=new Uint8Array(n.buffer,n.byteOffset,oi.length);if(e[0]!==oi[0]||e[1]!==oi[1]||e[2]!==oi[2]||e[3]!==oi[3]||e[4]!==oi[4]||e[5]!==oi[5]||e[6]!==oi[6]||e[7]!==oi[7]||e[8]!==oi[8]||e[9]!==oi[9]||e[10]!==oi[10]||e[11]!==oi[11])throw new Error("Missing KTX 2.0 identifier.");const t={vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null},i=17*Uint32Array.BYTES_PER_ELEMENT,s=new da(n,oi.length,i,!0);t.vkFormat=s._nextUint32(),t.typeSize=s._nextUint32(),t.pixelWidth=s._nextUint32(),t.pixelHeight=s._nextUint32(),t.pixelDepth=s._nextUint32(),t.layerCount=s._nextUint32(),t.faceCount=s._nextUint32(),t.levelCount=s._nextUint32(),t.supercompressionScheme=s._nextUint32();const r=s._nextUint32(),o=s._nextUint32(),a=s._nextUint32(),l=s._nextUint32(),c=s._nextUint64(),h=s._nextUint64(),d=3*Math.max(t.levelCount,1)*8,f=new da(n,oi.length+i,d,!0);for(let V=0,H=Math.max(t.levelCount,1);V<H;V++)t.levels.push({levelData:new Uint8Array(n.buffer,n.byteOffset+f._nextUint64(),f._nextUint64()),uncompressedByteLength:f._nextUint64()});const u=new da(n,r,o,!0);u._skip(4);const g=u._nextUint16(),p=u._nextUint16(),m=u._nextUint16(),A=u._nextUint16(),x={vendorId:g,descriptorType:p,versionNumber:m,colorModel:u._nextUint8(),colorPrimaries:u._nextUint8(),transferFunction:u._nextUint8(),flags:u._nextUint8(),texelBlockDimension:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],bytesPlane:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],samples:[]},b=(A/4-6)/4;for(let V=0;V<b;V++){const H={bitOffset:u._nextUint16(),bitLength:u._nextUint8(),channelType:u._nextUint8(),samplePosition:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};64&H.channelType?(H.sampleLower=u._nextInt32(),H.sampleUpper=u._nextInt32()):(H.sampleLower=u._nextUint32(),H.sampleUpper=u._nextUint32()),x.samples[V]=H}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(x);const y=new da(n,a,l,!0);for(;y._offset<l;){const V=y._nextUint32(),H=y._scan(V),oe=y0(H);if(t.keyValue[oe]=y._nextUint8Array(V-H.byteLength-1),oe.match(/^ktx/i)){const pe=y0(t.keyValue[oe]);t.keyValue[oe]=pe.substring(0,pe.lastIndexOf("\0"))}y._skip(V%4?4-V%4:0)}if(h<=0)return t;const _=new da(n,c,h,!0),S=_._nextUint16(),C=_._nextUint16(),D=_._nextUint32(),M=_._nextUint32(),I=_._nextUint32(),P=_._nextUint32(),T=[];for(let V=0,H=Math.max(t.levelCount,1);V<H;V++)T.push({imageFlags:_._nextUint32(),rgbSliceByteOffset:_._nextUint32(),rgbSliceByteLength:_._nextUint32(),alphaSliceByteOffset:_._nextUint32(),alphaSliceByteLength:_._nextUint32()});const L=c+_._offset,E=L+D,F=E+M,z=F+I,X=new Uint8Array(n.buffer,n.byteOffset+L,D),j=new Uint8Array(n.buffer,n.byteOffset+E,M),N=new Uint8Array(n.buffer,n.byteOffset+F,I),Y=new Uint8Array(n.buffer,n.byteOffset+z,P);return t.globalData={endpointCount:S,selectorCount:C,imageDescs:T,endpointsData:X,selectorsData:j,tablesData:N,extendedData:Y},t}let Uu,qn,Nu;const zu={env:{emscripten_notify_memory_growth:function(n){Nu=new Uint8Array(qn.exports.memory.buffer)}}};let $I=class{init(){return Uu||(Uu=typeof fetch<"u"?fetch("data:application/wasm;base64,"+v0).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,zu)).then(this._init):WebAssembly.instantiate(Buffer.from(v0,"base64"),zu).then(this._init),Uu)}_init(e){qn=e.instance,zu.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!qn)throw new Error("ZSTDDecoder: Await .init() before decoding.");const i=e.byteLength,s=qn.exports.malloc(i);Nu.set(e,s),t=t||Number(qn.exports.ZSTD_findDecompressedSize(s,i));const r=qn.exports.malloc(t),o=qn.exports.ZSTD_decompress(r,t,s,i),a=Nu.slice(r,r+o);return qn.exports.free(s),qn.exports.free(r),a}};const v0="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",JI="display-p3",ZI="display-p3-linear";({...v.ColorManagement.spaces[v.SRGBColorSpace]});const Gu=new WeakMap;let Vu=0,Qu;class Ni extends v.Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new QI,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return console.warn('KTX2Loader: "detectSupportAsync()" has been deprecated. Use "detectSupport()" and "await renderer.init();" when creating the renderer.'),await e.init(),this.detectSupport(e)}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-s3tc"),bptcSupported:e.hasFeature("texture-compression-bc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:e.extensions.has("WEBGL_compressed_texture_astc")&&e.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},typeof navigator<"u"&&typeof navigator.platform<"u"&&typeof navigator.userAgent<"u"&&navigator.platform.indexOf("Linux")>=0&&navigator.userAgent.indexOf("Firefox")>=0&&this.workerConfig.astcSupported&&this.workerConfig.etc2Supported&&this.workerConfig.bptcSupported&&this.workerConfig.dxtSupported&&(this.workerConfig.astcSupported=!1,this.workerConfig.etc2Supported=!1)),this}init(){if(!this.transcoderPending){const e=new v.FileLoader(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),i=new v.FileLoader(this.manager);i.setPath(this.transcoderPath),i.setResponseType("arraybuffer"),i.setWithCredentials(this.withCredentials);const s=i.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,s]).then(([r,o])=>{const a=Ni.BasisWorker.toString(),l=["/* constants */","let _EngineFormat = "+JSON.stringify(Ni.EngineFormat),"let _EngineType = "+JSON.stringify(Ni.EngineType),"let _TranscoderFormat = "+JSON.stringify(Ni.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(Ni.BasisFormat),"/* basis_transcoder.js */",r,"/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
|
|
4941
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([l])),this.transcoderBinary=o,this.workerPool.setWorkerCreator(()=>{const c=new Worker(this.workerSourceURL),h=this.transcoderBinary.slice(0);return c.postMessage({type:"init",config:this.workerConfig,transcoderBinary:h},[h]),c})}),Vu>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),Vu++}return this.transcoderPending}load(e,t,i,s){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new v.FileLoader(this.manager);r.setPath(this.path),r.setCrossOrigin(this.crossOrigin),r.setWithCredentials(this.withCredentials),r.setRequestHeader(this.requestHeader),r.setResponseType("arraybuffer"),r.load(e,o=>{this.parse(o,t,s)},i,s)}parse(e,t,i){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(Gu.has(e))return Gu.get(e).promise.then(t).catch(i);this._createTexture(e).then(s=>t?t(s):null).catch(i)}_createTextureFrom(e,t){const{type:i,error:s,data:{faces:r,width:o,height:a,format:l,type:c,dfdFlags:h}}=e;if(i==="error")return Promise.reject(s);let d;if(t.faceCount===6)d=new v.CompressedCubeTexture(r,l,c);else{const f=r[0].mipmaps;d=t.layerCount>1?new v.CompressedArrayTexture(f,o,a,t.layerCount,l,c):new v.CompressedTexture(f,o,a,l,c)}return d.minFilter=r[0].mipmaps.length===1?v.LinearFilter:v.LinearMipmapLinearFilter,d.magFilter=v.LinearFilter,d.generateMipmaps=!1,d.needsUpdate=!0,d.colorSpace=_0(t),d.premultiplyAlpha=!!(h&WI),d}async _createTexture(e,t={}){const i=KI(new Uint8Array(e)),s=i.vkFormat===Ou&&i.dataFormatDescriptor[0].colorModel===167;if(!(i.vkFormat===YI||s&&!this.workerConfig.astcHDRSupported))return tT(i);const o=t,a=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:o},[e])).then(l=>this._createTextureFrom(l.data,i));return Gu.set(e,{promise:a}),a}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),Vu--}}Ni.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},Ni.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},Ni.EngineFormat={RGBAFormat:v.RGBAFormat,RGBA_ASTC_4x4_Format:v.RGBA_ASTC_4x4_Format,RGB_BPTC_UNSIGNED_Format:v.RGB_BPTC_UNSIGNED_Format,RGBA_BPTC_Format:v.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:v.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:v.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:v.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:v.RGB_ETC1_Format,RGB_ETC2_Format:v.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:v.RGB_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format:v.RGBA_S3TC_DXT1_Format},Ni.EngineType={UnsignedByteType:v.UnsignedByteType,HalfFloatType:v.HalfFloatType,FloatType:v.FloatType},Ni.BasisWorker=function(){let n,e,t;const i=_EngineFormat,s=_EngineType,r=_TranscoderFormat,o=_BasisFormat;self.addEventListener("message",function(g){const p=g.data;switch(p.type){case"init":n=p.config,a(p.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:m,buffers:A,width:x,height:b,hasAlpha:y,format:_,type:S,dfdFlags:C}=l(p.buffer);self.postMessage({type:"transcode",id:p.id,data:{faces:m,width:x,height:b,hasAlpha:y,format:_,type:S,dfdFlags:C}},A)}catch(m){console.error(m),self.postMessage({type:"error",id:p.id,error:m.message})}});break}});function a(g){e=new Promise(p=>{t={wasmBinary:g,onRuntimeInitialized:p},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function l(g){const p=new t.KTX2File(new Uint8Array(g));function m(){p.close(),p.delete()}if(!p.isValid())throw m(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let A;if(p.isUASTC())A=o.UASTC;else if(p.isETC1S())A=o.ETC1S;else if(p.isHDR())A=o.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const x=p.getWidth(),b=p.getHeight(),y=p.getLayers()||1,_=p.getLevels(),S=p.getFaces(),C=p.getHasAlpha(),D=p.getDFDFlags(),{transcoderFormat:M,engineFormat:I,engineType:P}=d(A,x,b,C);if(!x||!b||!_)throw m(),new Error("THREE.KTX2Loader: Invalid texture");if(!p.startTranscoding())throw m(),new Error("THREE.KTX2Loader: .startTranscoding failed");const T=[],L=[];for(let E=0;E<S;E++){const F=[];for(let z=0;z<_;z++){const X=[];let j,N;for(let V=0;V<y;V++){const H=p.getImageLevelInfo(z,V,E);E===0&&z===0&&V===0&&(H.origWidth%4!==0||H.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),_>1?(j=H.origWidth,N=H.origHeight):(j=H.width,N=H.height);let oe=new Uint8Array(p.getImageTranscodedSizeInBytes(z,V,0,M));const pe=p.transcodeImage(oe,z,V,E,M,0,-1,-1);if(P===s.HalfFloatType&&(oe=new Uint16Array(oe.buffer,oe.byteOffset,oe.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!pe)throw m(),new Error("THREE.KTX2Loader: .transcodeImage failed.");X.push(oe)}const Y=u(X);F.push({data:Y,width:j,height:N}),L.push(Y.buffer)}T.push({mipmaps:F,width:x,height:b,format:I,type:P})}return m(),{faces:T,buffers:L,width:x,height:b,hasAlpha:C,dfdFlags:D,format:I,type:P}}const c=[{if:"astcSupported",basisFormat:[o.UASTC],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],engineType:[s.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],engineType:[s.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.BC1,r.BC3],engineFormat:[i.RGBA_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],engineType:[s.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],engineType:[s.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.ETC1],engineFormat:[i.RGB_ETC1_Format],engineType:[s.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],engineType:[s.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[o.UASTC_HDR],transcoderFormat:[r.BC6H],engineFormat:[i.RGB_BPTC_UNSIGNED_Format],engineType:[s.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.RGBA32,r.RGBA32],engineFormat:[i.RGBAFormat,i.RGBAFormat],engineType:[s.UnsignedByteType,s.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[o.UASTC_HDR],transcoderFormat:[r.RGBA_HALF],engineFormat:[i.RGBAFormat],engineType:[s.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],h={[o.ETC1S]:c.filter(g=>g.basisFormat.includes(o.ETC1S)).sort((g,p)=>g.priorityETC1S-p.priorityETC1S),[o.UASTC]:c.filter(g=>g.basisFormat.includes(o.UASTC)).sort((g,p)=>g.priorityUASTC-p.priorityUASTC),[o.UASTC_HDR]:c.filter(g=>g.basisFormat.includes(o.UASTC_HDR)).sort((g,p)=>g.priorityHDR-p.priorityHDR)};function d(g,p,m,A){const x=h[g];for(let b=0;b<x.length;b++){const y=x[b];if(y.if&&!n[y.if]||!y.basisFormat.includes(g)||A&&y.transcoderFormat.length<2||y.needsPowerOfTwo&&!(f(p)&&f(m)))continue;const _=y.transcoderFormat[A?1:0],S=y.engineFormat[A?1:0],C=y.engineType[0];return{transcoderFormat:_,engineFormat:S,engineType:C}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}function f(g){return g<=2?!0:(g&g-1)===0&&g!==0}function u(g){if(g.length===1)return g[0];let p=0;for(let x=0;x<g.length;x++){const b=g[x];p+=b.byteLength}const m=new Uint8Array(p);let A=0;for(let x=0;x<g.length;x++){const b=g[x];m.set(b,A),A+=b.byteLength}return m}};const eT=new Set([v.RGBAFormat,v.RGBFormat,v.RGFormat,v.RedFormat]),ju={[jA]:v.RGBAFormat,[QA]:v.RGFormat,[VA]:v.RedFormat,[GA]:v.RGBAFormat,[zA]:v.RGFormat,[NA]:v.RedFormat,[UA]:v.RGBAFormat,[OA]:v.RGBAFormat,[FA]:v.RGFormat,[kA]:v.RGFormat,[RA]:v.RedFormat,[LA]:v.RedFormat,[HA]:v.RGBFormat,[WA]:v.RGBFormat,[o0]:v.RGBA_ETC2_EAC_Format,[r0]:v.RGB_ETC2_Format,[a0]:v.R11_EAC_Format,[l0]:v.SIGNED_R11_EAC_Format,[c0]:v.RG11_EAC_Format,[h0]:v.SIGNED_RG11_EAC_Format,[Ou]:v.RGBA_ASTC_4x4_Format,[u0]:v.RGBA_ASTC_4x4_Format,[d0]:v.RGBA_ASTC_4x4_Format,[b0]:v.RGBA_ASTC_6x6_Format,[p0]:v.RGBA_ASTC_6x6_Format,[f0]:v.RGBA_ASTC_6x6_Format,[KA]:v.RGBA_S3TC_DXT1_Format,[YA]:v.RGBA_S3TC_DXT1_Format,[qA]:v.RGB_S3TC_DXT1_Format,[XA]:v.RGB_S3TC_DXT1_Format,[JA]:v.RGBA_S3TC_DXT5_Format,[$A]:v.RGBA_S3TC_DXT5_Format,[e0]:v.SIGNED_RED_RGTC1_Format,[ZA]:v.RED_RGTC1_Format,[i0]:v.SIGNED_RED_GREEN_RGTC2_Format,[t0]:v.RED_GREEN_RGTC2_Format,[s0]:v.RGBA_BPTC_Format,[n0]:v.RGBA_BPTC_Format,[x0]:v.RGBA_PVRTC_4BPPV1_Format,[m0]:v.RGBA_PVRTC_4BPPV1_Format,[A0]:v.RGBA_PVRTC_2BPPV1_Format,[g0]:v.RGBA_PVRTC_2BPPV1_Format},po={[jA]:v.FloatType,[QA]:v.FloatType,[VA]:v.FloatType,[GA]:v.HalfFloatType,[zA]:v.HalfFloatType,[NA]:v.HalfFloatType,[UA]:v.UnsignedByteType,[OA]:v.UnsignedByteType,[FA]:v.UnsignedByteType,[kA]:v.UnsignedByteType,[RA]:v.UnsignedByteType,[LA]:v.UnsignedByteType,[HA]:v.UnsignedInt5999Type,[WA]:v.UnsignedInt101111Type,[o0]:v.UnsignedByteType,[r0]:v.UnsignedByteType,[a0]:v.UnsignedByteType,[l0]:v.UnsignedByteType,[c0]:v.UnsignedByteType,[h0]:v.UnsignedByteType,[Ou]:v.HalfFloatType,[u0]:v.UnsignedByteType,[d0]:v.UnsignedByteType,[b0]:v.HalfFloatType,[p0]:v.UnsignedByteType,[f0]:v.UnsignedByteType,[KA]:v.UnsignedByteType,[YA]:v.UnsignedByteType,[qA]:v.UnsignedByteType,[XA]:v.UnsignedByteType,[JA]:v.UnsignedByteType,[$A]:v.UnsignedByteType,[e0]:v.UnsignedByteType,[ZA]:v.UnsignedByteType,[i0]:v.UnsignedByteType,[t0]:v.UnsignedByteType,[s0]:v.UnsignedByteType,[n0]:v.UnsignedByteType,[x0]:v.UnsignedByteType,[m0]:v.UnsignedByteType,[A0]:v.UnsignedByteType,[g0]:v.UnsignedByteType};async function tT(n){const{vkFormat:e}=n;if(ju[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+e);po[e]===void 0&&console.warn('THREE.KTX2Loader: Missing ".type" for vkFormat: '+e);let t;n.supercompressionScheme===BA&&(Qu||(Qu=new Promise(async o=>{const a=new $I;await a.init(),o(a)})),t=await Qu);const i=[];for(let o=0;o<n.levels.length;o++){const a=Math.max(1,n.pixelWidth>>o),l=Math.max(1,n.pixelHeight>>o),c=n.pixelDepth?Math.max(1,n.pixelDepth>>o):0,h=n.levels[o];let d;if(n.supercompressionScheme===jI)d=h.levelData;else if(n.supercompressionScheme===BA)d=t.decode(h.levelData,h.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let f;po[e]===v.FloatType?f=new Float32Array(d.buffer,d.byteOffset,d.byteLength/Float32Array.BYTES_PER_ELEMENT):po[e]===v.HalfFloatType?f=new Uint16Array(d.buffer,d.byteOffset,d.byteLength/Uint16Array.BYTES_PER_ELEMENT):po[e]===v.UnsignedInt5999Type||po[e]===v.UnsignedInt101111Type?f=new Uint32Array(d.buffer,d.byteOffset,d.byteLength/Uint32Array.BYTES_PER_ELEMENT):f=d,i.push({data:f,width:a,height:l,depth:c})}const s=n.levelCount===0||i.length>1;let r;if(eT.has(ju[e]))r=n.pixelDepth===0?new v.DataTexture(i[0].data,n.pixelWidth,n.pixelHeight):new v.Data3DTexture(i[0].data,n.pixelWidth,n.pixelHeight,n.pixelDepth),r.minFilter=s?v.NearestMipmapNearestFilter:v.NearestFilter,r.magFilter=v.NearestFilter,r.generateMipmaps=n.levelCount===0;else{if(n.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new v.CompressedTexture(i,n.pixelWidth,n.pixelHeight),r.minFilter=s?v.LinearMipmapLinearFilter:v.LinearFilter,r.magFilter=v.LinearFilter}return r.mipmaps=i,r.type=po[e],r.format=ju[e],r.colorSpace=_0(n),r.needsUpdate=!0,Promise.resolve(r)}function _0(n){const e=n.dataFormatDescriptor[0];return e.colorPrimaries===XI?e.transferFunction===PA?v.SRGBColorSpace:v.LinearSRGBColorSpace:e.colorPrimaries===qI?e.transferFunction===PA?JI:ZI:(e.colorPrimaries===HI||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),v.NoColorSpace)}function iT(n,e,t,i){let s=0,r=0,o=0,a=n.models.find(u=>u.url==t),l=e.circularMeps,c=e.rectMeps?.filter(u=>u.type==="风管"),h=e.rectMeps?.filter(u=>u.type==="桥架"),d=e.ellipseMeps,f=n.scene;if(new w.MeshBasicMaterial,new w.BufferGeometry,l&&l.length){let u=[],g=0;for(let p of l)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new w.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+s,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[n.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),u.push(p);bc("Circle",f,u,t)}if(c&&c.length){let u=[],g=0;for(let p of c)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new w.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+s,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[n.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),u.push(p);bc("Rect",f,u,t)}if(d&&d.length){let u=[],g=0;for(let p of d)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new w.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+s,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[n.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),u.push(p);bc("Ellipse",f,u,t)}if(h&&h.length){let u=[],g=0;for(let p of h)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new w.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+s,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[n.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),u.push(p);bc("Bridge",f,u,t)}}function bc(n,e,t,i,s){let r,o,a={width:1,height:1,length:1,diameter:1,color:new w.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(n){case"Rect":o=yc("Rect",a);break;case"Bridge":o=yc("Bridge",a);break;case"Circle":o=yc("Circle",a);break;case"Ellipse":o=yc("Ellipse",a);break}o&&(r=new w.InstancedMesh(o.geometry,o.material,t.length),r.url=i,e.add(r),r.index=e.children.length-1);let l=[],c=[];for(var h=0;h<t.length;h++){let u=t[h],g=new w.Vector3(u.startPoint.X,0,-u.startPoint.Y),p=new w.Vector3(u.endPoint.X,0,-u.endPoint.Y),m=new w.Vector3(u.startPoint.X,u.startPoint.Z,-u.startPoint.Y),A=new w.Vector3(u.endPoint.X,u.endPoint.Z,-u.endPoint.Y),x=0,b=0,y=0;if(Math.abs(p.clone().sub(g.clone()).z)<.01&&Math.abs(p.clone().sub(g.clone()).x)<.01){if(x=(u.startPoint.Z>u.endPoint.Z?1:-1)*Math.PI*.5,u.base_x!=null){var d=new w.Vector3(u.base_x.X,0,-u.base_x.Y);b=(d.clone().cross(new w.Vector3(0,0,1)).y<=0?1:-1)*d.angleTo(new w.Vector3(0,0,1))+Math.PI*.5}}else b=(p.clone().sub(g.clone()).cross(new w.Vector3(0,0,1)).y>0?-1:1)*p.clone().sub(g.clone()).angleTo(new w.Vector3(0,0,1)),x=(u.startPoint.Z>u.endPoint.Z?1:-1)*p.clone().sub(g.clone()).angleTo(A.clone().sub(m.clone()));let _=new w.Matrix4;const S=new w.Euler(x,b,y,"YXZ");let C=_.clone().makeRotationFromEuler(S),D,M;n==="Circle"?(D=u.diameter,M=u.diameter):(D=u.width,M=u.height);let I=_.clone().makeScale(D,M,u.length);_.multiplyMatrices(C,I),_.setPosition(u.position.x,u.position.y,u.position.z),r.setMatrixAt(h,_.clone()),r.setColorAt(h,u.color),r.geometry.computeBoundingBox();let P=r.geometry.boundingBox.min.clone().applyMatrix4(_.clone()),T=r.geometry.boundingBox.max.clone().applyMatrix4(_.clone()),L=new w.Vector3(Math.min(P.x,T.x),Math.min(P.y,T.y),Math.min(P.z,T.z)),E=new w.Vector3(Math.max(P.x,T.x),Math.max(P.y,T.y),Math.max(P.z,T.z)),F=L.clone().add(E.clone()).multiplyScalar(.5),z={name:u.name,min:L,max:E,center:F,dbid:h,materialName:o.material.name},X=null,j=null;n==="Circle"&&(X={x:u.startPoint.X*.3048,y:u.startPoint.Z*.3048,z:-u.startPoint.Y*.3048},j={x:u.endPoint.X*.3048,y:u.endPoint.Z*.3048,z:-u.endPoint.Y*.3048},z.minC=X,z.maxC=j),r.ids||(r.ids=[]),r.matrixs||(r.matrixs=[]),r.matrixs.push(_.clone()),c.push(_.clone()),r.ids.push(Number(u.id)),l.push(z)}r.castShadow=!0,r.ElementInfos=l,r.name="rootModel",r.TypeName="InstancedMesh-Pipe",r.PipeType=n,r.MeshId=null,r.realMaterial=r.material.clone(),r.originalMaterial=r.material.clone(),r.matrixsClone=c;let f=[];f={geometry:r.geometry,matrix:r.matrix,position:r.position,rotation:r.rotation},r.meshs=f,r.instanceMatrix&&r.instanceMatrix.array&&(r.cloneInstanceMatrix=Array.from(r.instanceMatrix.array))}function yc(n,e,t){let i=new w.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,n){case"Rect":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Bridge":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(-e.width/2+.01,e.height/2),i.lineTo(-e.width/2+.01,-e.height/2+.01),i.lineTo(e.width/2-.01,-e.height/2+.01),i.lineTo(e.width/2-.01,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Circle":i.moveTo(0,0),i.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const s={depth:e.length*.3048,bevelEnabled:!1};return r(i,s,e.color,e.position,e.rotation);function r(o,a,l,c,h){let d=new w.ExtrudeGeometry(o,a),f=new w.MeshStandardMaterial({color:l,side:w.DoubleSide}),u=new w.Mesh(d,f);return u.position.set(c.x,c.y,c.z),u.rotation._order="YXZ",u.rotation.set(h.x,h.y,h.z),u}}function ws(n,e=!1){const t=n[0].index!==null,i=new Set(Object.keys(n[0].attributes)),s=new Set(Object.keys(n[0].morphAttributes)),r={},o={},a=n[0].morphTargetsRelative,l=new v.BufferGeometry;let c=0;for(let h=0;h<n.length;++h){const d=n[h];let f=0;if(t!==(d.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(const u in d.attributes){if(!i.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+u+'" attribute exists among all geometries, or in none of them.'),null;r[u]===void 0&&(r[u]=[]),r[u].push(d.attributes[u]),f++}if(f!==i.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(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const u in d.morphAttributes){if(!s.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[u]===void 0&&(o[u]=[]),o[u].push(d.morphAttributes[u])}if(e){let u;if(t)u=d.index.count;else if(d.attributes.position!==void 0)u=d.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,u,h),c+=u}}if(t){let h=0;const d=[];for(let f=0;f<n.length;++f){const u=n[f].index;for(let g=0;g<u.count;++g)d.push(u.getX(g)+h);h+=n[f].attributes.position.count}l.setIndex(d)}for(const h in r){const d=w0(r[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,d)}for(const h in o){const d=o[h][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let f=0;f<d;++f){const u=[];for(let p=0;p<o[h].length;++p)u.push(o[h][p][f]);const g=w0(u);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 w0(n){let e,t,i,s=-1,r=0;for(let c=0;c<n.length;++c){const h=n[c];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=h.normalized),i!==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*t}const o=new e(r),a=new v.BufferAttribute(o,t,i);let l=0;for(let c=0;c<n.length;++c){const h=n[c];if(h.isInterleavedBufferAttribute){const d=l/t;for(let f=0,u=h.count;f<u;f++)for(let g=0;g<t;g++){const p=h.getComponent(f,g);a.setComponent(f+d,g,p)}}else o.set(h.array,l);l+=h.count*t}return s!==void 0&&(a.gpuType=s),a}function S0(n,e){if(e===v.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===v.TriangleFanDrawMode||e===v.TriangleStripDrawMode){let t=n.getIndex();if(t===null){const o=[],a=n.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);n.setIndex(o),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const i=t.count-2,s=[];if(e===v.TriangleFanDrawMode)for(let o=1;o<=i;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<i;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=n.clone();return r.setIndex(s),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}function nT(n){const e=new Map,t=new Map,i=n.clone();return C0(n,i,function(s,r){e.set(r,s),t.set(s,r)}),i.traverse(function(s){if(!s.isSkinnedMesh)return;const r=s,o=e.get(s),a=o.skeleton.bones;r.skeleton=o.skeleton.clone(),r.bindMatrix.copy(o.bindMatrix),r.skeleton.bones=a.map(function(l){return t.get(l)}),r.bind(r.skeleton,r.bindMatrix)}),i}function C0(n,e,t){t(n,e);for(let i=0;i<n.children.length;i++)C0(n.children[i],e.children[i],t)}class sT extends v.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new cT(t)}),this.register(function(t){return new hT(t)}),this.register(function(t){return new bT(t)}),this.register(function(t){return new yT(t)}),this.register(function(t){return new vT(t)}),this.register(function(t){return new uT(t)}),this.register(function(t){return new fT(t)}),this.register(function(t){return new pT(t)}),this.register(function(t){return new gT(t)}),this.register(function(t){return new lT(t)}),this.register(function(t){return new mT(t)}),this.register(function(t){return new dT(t)}),this.register(function(t){return new xT(t)}),this.register(function(t){return new AT(t)}),this.register(function(t){return new oT(t)}),this.register(function(t){return new M0(t,tt.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new M0(t,tt.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new _T(t)})}load(e,t,i,s){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=v.LoaderUtils.extractUrlBase(e);o=v.LoaderUtils.resolveURL(c,this.path)}else o=v.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){s?s(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new v.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},i,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,s){let r;const o={},a={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===E0){try{o[tt.KHR_BINARY_GLTF]=new wT(e)}catch(d){s&&s(d);return}r=JSON.parse(o[tt.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new FT(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,o[d.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const d=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(d){case tt.KHR_MATERIALS_UNLIT:o[d]=new aT;break;case tt.KHR_DRACO_MESH_COMPRESSION:o[d]=new ST(r,this.dracoLoader);break;case tt.KHR_TEXTURE_TRANSFORM:o[d]=new CT;break;case tt.KHR_MESH_QUANTIZATION:o[d]=new MT;break;default:f.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(i,s)}parseAsync(e,t){const i=this;return new Promise(function(s,r){i.parse(e,t,s,r)})}}function rT(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}function Rt(n,e,t){const i=n.json.materials[e];return i.extensions&&i.extensions[t]?i.extensions[t]:null}const tt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class oT{constructor(e){this.parser=e,this.name=tt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,s=t.length;i<s;i++){const r=t[i];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let s=t.cache.get(i);if(s)return s;const r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const h=new v.Color(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],v.LinearSRGBColorSpace);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new v.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new v.PointLight(h),c.distance=d;break;case"spot":c=new v.SpotLight(h),c.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),yn(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),s=Promise.resolve(c),t.cache.add(i,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,r=i.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return i._getNodeRef(t.cache,a,l)})}}class aT{constructor(){this.name=tt.KHR_MATERIALS_UNLIT}getMaterialType(){return v.MeshBasicMaterial}extendParams(e,t,i){const s=[];e.color=new v.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],v.LinearSRGBColorSpace),e.opacity=o[3]}r.baseColorTexture!==void 0&&s.push(i.assignTexture(e,"map",r.baseColorTexture,v.SRGBColorSpace))}return Promise.all(s)}}class lT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);return i===null||i.emissiveStrength!==void 0&&(t.emissiveIntensity=i.emissiveStrength),Promise.resolve()}}class cT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(s.push(this.parser.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const r=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new v.Vector2(r,r)}return Promise.all(s)}}class hT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);return i===null||(t.dispersion=i.dispersion!==void 0?i.dispersion:0),Promise.resolve()}}class dT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(s)}}class uT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_SHEEN}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];if(t.sheenColor=new v.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,i.sheenColorFactor!==void 0){const r=i.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],v.LinearSRGBColorSpace)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenColorMap",i.sheenColorTexture,v.SRGBColorSpace)),i.sheenRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}}class fT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&s.push(this.parser.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(s)}}class pT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_VOLUME}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const r=i.attenuationColor||[1,1,1];return t.attenuationColor=new v.Color().setRGB(r[0],r[1],r[2],v.LinearSRGBColorSpace),Promise.all(s)}}class gT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_IOR}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);return i===null||(t.ior=i.ior!==void 0?i.ior:1.5),Promise.resolve()}}class mT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularIntensityMap",i.specularTexture));const r=i.specularColorFactor||[1,1,1];return t.specularColor=new v.Color().setRGB(r[0],r[1],r[2],v.LinearSRGBColorSpace),i.specularColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularColorMap",i.specularColorTexture,v.SRGBColorSpace)),Promise.all(s)}}class AT{constructor(e){this.parser=e,this.name=tt.EXT_MATERIALS_BUMP}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&s.push(this.parser.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(s)}}class xT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&s.push(this.parser.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(s)}}class bT{constructor(e){this.parser=e,this.name=tt.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,s=i.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const r=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}}class yT{constructor(e){this.parser=e,this.name=tt.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=s.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return i.loadTextureImage(e,o.source,l)}}class vT{constructor(e){this.parser=e,this.name=tt.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=s.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return i.loadTextureImage(e,o.source,l)}}class M0{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const s=i.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const l=s.byteOffset||0,c=s.byteLength||0,h=s.count,d=s.byteStride,f=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,d,f,s.mode,s.filter).then(function(u){return u.buffer}):o.ready.then(function(){const u=new ArrayBuffer(h*d);return o.decodeGltfBuffer(new Uint8Array(u),h,d,f,s.mode,s.filter),u})})}else return null}}class _T{constructor(e){this.name=tt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const s=t.meshes[i.mesh];for(const c of s.primitives)if(c.mode!==zi.TRIANGLES&&c.mode!==zi.TRIANGLE_STRIP&&c.mode!==zi.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=i.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),d=h.isGroup?h.children:[h],f=c[0].count,u=[];for(const g of d){const p=new v.Matrix4,m=new v.Vector3,A=new v.Quaternion,x=new v.Vector3(1,1,1),b=new v.InstancedMesh(g.geometry,g.material,f);for(let y=0;y<f;y++)l.TRANSLATION&&m.fromBufferAttribute(l.TRANSLATION,y),l.ROTATION&&A.fromBufferAttribute(l.ROTATION,y),l.SCALE&&x.fromBufferAttribute(l.SCALE,y),b.setMatrixAt(y,p.compose(m,A,x));for(const y in l)if(y==="_COLOR_0"){const _=l[y];b.instanceColor=new v.InstancedBufferAttribute(_.array,_.itemSize,_.normalized)}else y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&g.geometry.setAttribute(y,l[y]);v.Object3D.prototype.copy.call(b,g),this.parser.assignFinalMaterial(b),u.push(b)}return h.isGroup?(h.clear(),h.add(...u),h):u[0]}))}}const E0="glTF",ua=12,I0={JSON:1313821514,BIN:5130562};class wT{constructor(e){this.name=tt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ua),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==E0)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-ua,r=new DataView(e,ua);let o=0;for(;o<s;){const a=r.getUint32(o,!0);o+=4;const l=r.getUint32(o,!0);if(o+=4,l===I0.JSON){const c=new Uint8Array(e,ua+o,a);this.content=i.decode(c)}else if(l===I0.BIN){const c=ua+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class ST{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=tt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(const h in o){const d=Hu[h]||h.toLowerCase();a[d]=o[h]}for(const h in e.attributes){const d=Hu[h]||h.toLowerCase();if(o[h]!==void 0){const f=i.accessors[e.attributes[h]],u=go[f.componentType];c[d]=u.name,l[d]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(d,f){s.decodeDracoFile(h,function(u){for(const g in u.attributes){const p=u.attributes[g],m=l[g];m!==void 0&&(p.normalized=m)}d(u)},a,c,v.LinearSRGBColorSpace,f)})})}}class CT{constructor(){this.name=tt.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class MT{constructor(){this.name=tt.KHR_MESH_QUANTIZATION}}class T0 extends v.Interpolant{constructor(e,t,i,s){super(e,t,i,s)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let o=0;o!==s;o++)t[o]=i[r+o];return t}interpolate_(e,t,i,s){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,h=s-t,d=(i-t)/h,f=d*d,u=f*d,g=e*c,p=g-c,m=-2*u+3*f,A=u-f,x=1-m,b=A-f+d;for(let y=0;y!==a;y++){const _=o[p+y+a],S=o[p+y+l]*h,C=o[g+y+a],D=o[g+y]*h;r[y]=x*_+b*S+m*C+A*D}return r}}const ET=new v.Quaternion;class IT extends T0{interpolate_(e,t,i,s){const r=super.interpolate_(e,t,i,s);return ET.fromArray(r).normalize().toArray(r),r}}const zi={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},go={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},D0={9728:v.NearestFilter,9729:v.LinearFilter,9984:v.NearestMipmapNearestFilter,9985:v.LinearMipmapNearestFilter,9986:v.NearestMipmapLinearFilter,9987:v.LinearMipmapLinearFilter},B0={33071:v.ClampToEdgeWrapping,33648:v.MirroredRepeatWrapping,10497:v.RepeatWrapping},Wu={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Hu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ss={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},TT={CUBICSPLINE:void 0,LINEAR:v.InterpolateLinear,STEP:v.InterpolateDiscrete},Xu={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function DT(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new v.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:v.FrontSide})),n.DefaultMaterial}function hr(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function yn(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function BT(n,e,t){let i=!1,s=!1,r=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(i=!0),d.NORMAL!==void 0&&(s=!0),d.COLOR_0!==void 0&&(r=!0),i&&s&&r)break}if(!i&&!s&&!r)return Promise.resolve(n);const o=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(i){const f=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):n.attributes.position;o.push(f)}if(s){const f=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):n.attributes.normal;a.push(f)}if(r){const f=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):n.attributes.color;l.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],f=c[2];return i&&(n.morphAttributes.position=h),s&&(n.morphAttributes.normal=d),r&&(n.morphAttributes.color=f),n.morphTargetsRelative=!0,n})}function PT(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,s=t.length;i<s;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function LT(n){let e;const t=n.extensions&&n.extensions[tt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+qu(t.attributes):e=n.indices+":"+qu(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,s=n.targets.length;i<s;i++)e+=":"+qu(n.targets[i]);return e}function qu(n){let e="";const t=Object.keys(n).sort();for(let i=0,s=t.length;i<s;i++)e+=t[i]+":"+n[t[i]]+";";return e}function Yu(n){switch(n){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function RT(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const kT=new v.Matrix4;class FT{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new rT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,s=-1,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);s=i&&l?parseInt(l[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&s<17||r&&o<98?this.textureLoader=new v.TextureLoader(this.options.manager):this.textureLoader=new v.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new v.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const a={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:i,userData:{}};return hr(r,a,s),yn(a,s),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){const o=t[s].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let s=0,r=e.length;s<r;s++){const o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(i[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const s=i.clone(),r=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,h]of o.children.entries())r(h,a.children[c])};return r(i,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const s=e(t[i]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let s=0;s<t.length;s++){const r=e(t[s]);r&&i.push(r)}return i}getDependency(e,t){const i=e+":"+t;let s=this.cache.get(i);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(i,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(r,o){return i.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[tt.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,o){i.load(v.LoaderUtils.resolveURL(t.uri,s.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){const s=t.byteLength||0,r=t.byteOffset||0;return i.slice(r,r+s)})}loadAccessor(e){const t=this,i=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const o=Wu[s.type],a=go[s.componentType],l=s.normalized===!0,c=new a(s.count*o);return Promise.resolve(new v.BufferAttribute(c,o,l))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],l=Wu[s.type],c=go[s.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,f=s.byteOffset||0,u=s.bufferView!==void 0?i.bufferViews[s.bufferView].byteStride:void 0,g=s.normalized===!0;let p,m;if(u&&u!==d){const A=Math.floor(f/u),x="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+A+":"+s.count;let b=t.cache.get(x);b||(p=new c(a,A*u,s.count*u/h),b=new v.InterleavedBuffer(p,u/h),t.cache.add(x,b)),m=new v.InterleavedBufferAttribute(b,l,f%u/h,g)}else a===null?p=new c(s.count*l):p=new c(a,f,s.count*l),m=new v.BufferAttribute(p,l,g);if(s.sparse!==void 0){const A=Wu.SCALAR,x=go[s.sparse.indices.componentType],b=s.sparse.indices.byteOffset||0,y=s.sparse.values.byteOffset||0,_=new x(o[1],b,s.sparse.count*A),S=new c(o[2],y,s.sparse.count*l);a!==null&&(m=new v.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let C=0,D=_.length;C<D;C++){const M=_[C];if(m.setX(M,S[C*l]),l>=2&&m.setY(M,S[C*l+1]),l>=3&&m.setZ(M,S[C*l+2]),l>=4&&m.setW(M,S[C*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){const t=this.json,i=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const l=i.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,i){const s=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const f=(r.samplers||{})[o.sampler]||{};return h.magFilter=D0[f.magFilter]||v.LinearFilter,h.minFilter=D0[f.minFilter]||v.LinearMipmapLinearFilter,h.wrapS=B0[f.wrapS]||v.RepeatWrapping,h.wrapT=B0[f.wrapT]||v.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==v.NearestFilter&&h.minFilter!==v.LinearFilter,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=s.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=i.getDependency("bufferView",o.bufferView).then(function(d){c=!0;const f=new Blob([d],{type:o.mimeType});return l=a.createObjectURL(f),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(d){return new Promise(function(f,u){let g=f;t.isImageBitmapLoader===!0&&(g=function(p){const m=new v.Texture(p);m.needsUpdate=!0,f(m)}),t.load(v.LoaderUtils.resolveURL(d,r.path),g,void 0,u)})}).then(function(d){return c===!0&&a.revokeObjectURL(l),yn(d,o),d.userData.mimeType=o.mimeType||RT(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,i,s){const r=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),r.extensions[tt.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[tt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(o);o=r.extensions[tt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new v.PointsMaterial,v.Material.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(a,l)),i=l}else if(e.isLine){const a="LineBasicMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new v.LineBasicMaterial,v.Material.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(a,l)),i=l}if(s||r||o){let a="ClonedMaterial:"+i.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=i.clone(),r&&(l.vertexColors=!0),o&&(l.flatShading=!0),s&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return v.MeshStandardMaterial}loadMaterial(e){const t=this,i=this.json,s=this.extensions,r=i.materials[e];let o;const a={},l=r.extensions||{},c=[];if(l[tt.KHR_MATERIALS_UNLIT]){const d=s[tt.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(a,r,t))}else{const d=r.pbrMetallicRoughness||{};if(a.color=new v.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const f=d.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],v.LinearSRGBColorSpace),a.opacity=f[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,v.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=v.DoubleSide);const h=r.alphaMode||Xu.OPAQUE;if(h===Xu.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Xu.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==v.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new v.Vector2(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;a.normalScale.set(d,d)}if(r.occlusionTexture!==void 0&&o!==v.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==v.MeshBasicMaterial){const d=r.emissiveFactor;a.emissive=new v.Color().setRGB(d[0],d[1],d[2],v.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==v.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,v.SRGBColorSpace)),Promise.all(c).then(function(){const d=new o(a);return r.name&&(d.name=r.name),yn(d,r),t.associations.set(d,{materials:e}),r.extensions&&hr(s,d,r),d})}createUniqueName(e){const t=v.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,s=this.primitiveCache;function r(a){return i[tt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return P0(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=LT(c),d=s[h];if(d)o.push(d.promise);else{let f;c.extensions&&c.extensions[tt.KHR_DRACO_MESH_COMPRESSION]?f=r(c):f=P0(new v.BufferGeometry,c,t),s[h]={primitive:c,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){const t=this,i=this.json,s=this.extensions,r=i.meshes[e],o=r.primitives,a=[];for(let l=0,c=o.length;l<c;l++){const h=o[l].material===void 0?DT(this.cache):this.getDependency("material",o[l].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let u=0,g=h.length;u<g;u++){const p=h[u],m=o[u];let A;const x=c[u];if(m.mode===zi.TRIANGLES||m.mode===zi.TRIANGLE_STRIP||m.mode===zi.TRIANGLE_FAN||m.mode===void 0)A=r.isSkinnedMesh===!0?new v.SkinnedMesh(p,x):new v.Mesh(p,x),A.isSkinnedMesh===!0&&A.normalizeSkinWeights(),m.mode===zi.TRIANGLE_STRIP?A.geometry=S0(A.geometry,v.TriangleStripDrawMode):m.mode===zi.TRIANGLE_FAN&&(A.geometry=S0(A.geometry,v.TriangleFanDrawMode));else if(m.mode===zi.LINES)A=new v.LineSegments(p,x);else if(m.mode===zi.LINE_STRIP)A=new v.Line(p,x);else if(m.mode===zi.LINE_LOOP)A=new v.LineLoop(p,x);else if(m.mode===zi.POINTS)A=new v.Points(p,x);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(A.geometry.morphAttributes).length>0&&PT(A,r),A.name=t.createUniqueName(r.name||"mesh_"+e),yn(A,r),m.extensions&&hr(s,A,m),t.assignFinalMaterial(A),d.push(A)}for(let u=0,g=d.length;u<g;u++)t.associations.set(d[u],{meshes:e,primitives:u});if(d.length===1)return r.extensions&&hr(s,d[0],r),d[0];const f=new v.Group;r.extensions&&hr(s,f,r),t.associations.set(f,{meshes:e});for(let u=0,g=d.length;u<g;u++)f.add(d[u]);return f})}loadCamera(e){let t;const i=this.json.cameras[e],s=i[i.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new v.PerspectiveCamera(v.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):i.type==="orthographic"&&(t=new v.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),yn(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let s=0,r=t.joints.length;s<r;s++)i.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(s){const r=s.pop(),o=s,a=[],l=[];for(let c=0,h=o.length;c<h;c++){const d=o[c];if(d){a.push(d);const f=new v.Matrix4;r!==null&&f.fromArray(r.array,c*16),l.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new v.Skeleton(a,l)})}loadAnimation(e){const t=this.json,i=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,o=[],a=[],l=[],c=[],h=[];for(let d=0,f=s.channels.length;d<f;d++){const u=s.channels[d],g=s.samplers[u.sampler],p=u.target,m=p.node,A=s.parameters!==void 0?s.parameters[g.input]:g.input,x=s.parameters!==void 0?s.parameters[g.output]:g.output;p.node!==void 0&&(o.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",A)),l.push(this.getDependency("accessor",x)),c.push(g),h.push(p))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){const f=d[0],u=d[1],g=d[2],p=d[3],m=d[4],A=[];for(let b=0,y=f.length;b<y;b++){const _=f[b],S=u[b],C=g[b],D=p[b],M=m[b];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const I=i._createAnimationTracks(_,S,C,D,M);if(I)for(let P=0;P<I.length;P++)A.push(I[P])}const x=new v.AnimationClip(r,void 0,A);return yn(x,s),x})}createNodeMesh(e){const t=this.json,i=this,s=t.nodes[e];return s.mesh===void 0?null:i.getDependency("mesh",s.mesh).then(function(r){const o=i._getNodeRef(i.meshCache,s.mesh,r);return s.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,c=s.weights.length;l<c;l++)a.morphTargetInfluences[l]=s.weights[l]}),o})}loadNode(e){const t=this.json,i=this,s=t.nodes[e],r=i._loadNodeShallow(e),o=[],a=s.children||[];for(let c=0,h=a.length;c<h;c++)o.push(i.getDependency("node",a[c]));const l=s.skin===void 0?Promise.resolve(null):i.getDependency("skin",s.skin);return Promise.all([r,Promise.all(o),l]).then(function(c){const h=c[0],d=c[1],f=c[2];f!==null&&h.traverse(function(u){u.isSkinnedMesh&&u.bind(f,kT)});for(let u=0,g=d.length;u<g;u++)h.add(d[u]);if(h.userData.pivot!==void 0&&d.length>0){const u=h.userData.pivot,g=d[0];h.pivot=new v.Vector3().fromArray(u),h.position.x-=u[0],h.position.y-=u[1],h.position.z-=u[2],g.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){const t=this.json,i=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?s.createUniqueName(r.name):"",a=[],l=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(c){return s._getNodeRef(s.cameraCache,r.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(r.isBone===!0?h=new v.Bone:c.length>1?h=new v.Group:c.length===1?h=c[0]:h=new v.Object3D,h!==c[0])for(let d=0,f=c.length;d<f;d++)h.add(c[d]);if(r.name&&(h.userData.name=r.name,h.name=o),yn(h,r),r.extensions&&hr(i,h,r),r.matrix!==void 0){const d=new v.Matrix4;d.fromArray(r.matrix),h.applyMatrix4(d)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);if(!s.associations.has(h))s.associations.set(h,{});else if(r.mesh!==void 0&&s.meshCache.refs[r.mesh]>1){const d=s.associations.get(h);s.associations.set(h,{...d})}return s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],s=this,r=new v.Group;i.name&&(r.name=s.createUniqueName(i.name)),yn(r,i),i.extensions&&hr(t,r,i);const o=i.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(s.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let h=0,d=l.length;h<d;h++){const f=l[h];f.parent!==null?r.add(nT(f)):r.add(f)}const c=h=>{const d=new Map;for(const[f,u]of s.associations)(f instanceof v.Material||f instanceof v.Texture)&&d.set(f,u);return h.traverse(f=>{const u=s.associations.get(f);u!=null&&d.set(f,u)}),d};return s.associations=c(r),r})}_createAnimationTracks(e,t,i,s,r){const o=[],a=e.name?e.name:e.uuid,l=[];Ss[r.path]===Ss.weights?e.traverse(function(f){f.morphTargetInfluences&&l.push(f.name?f.name:f.uuid)}):l.push(a);let c;switch(Ss[r.path]){case Ss.weights:c=v.NumberKeyframeTrack;break;case Ss.rotation:c=v.QuaternionKeyframeTrack;break;case Ss.translation:case Ss.scale:c=v.VectorKeyframeTrack;break;default:switch(i.itemSize){case 1:c=v.NumberKeyframeTrack;break;case 2:case 3:default:c=v.VectorKeyframeTrack;break}break}const h=s.interpolation!==void 0?TT[s.interpolation]:v.InterpolateLinear,d=this._getArrayFromAccessor(i);for(let f=0,u=l.length;f<u;f++){const g=new c(l[f]+"."+Ss[r.path],t.array,d,h);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=Yu(t.constructor),s=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)s[r]=t[r]*i;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const s=this instanceof v.QuaternionKeyframeTrack?IT:T0;return new s(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function OT(n,e,t){const i=e.attributes,s=new v.Box3;if(i.POSITION!==void 0){const a=t.json.accessors[i.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(s.set(new v.Vector3(l[0],l[1],l[2]),new v.Vector3(c[0],c[1],c[2])),a.normalized){const h=Yu(go[a.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new v.Vector3,l=new v.Vector3;for(let c=0,h=r.length;c<h;c++){const d=r[c];if(d.POSITION!==void 0){const f=t.json.accessors[d.POSITION],u=f.min,g=f.max;if(u!==void 0&&g!==void 0){if(l.setX(Math.max(Math.abs(u[0]),Math.abs(g[0]))),l.setY(Math.max(Math.abs(u[1]),Math.abs(g[1]))),l.setZ(Math.max(Math.abs(u[2]),Math.abs(g[2]))),f.normalized){const p=Yu(go[f.componentType]);l.multiplyScalar(p)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}n.boundingBox=s;const o=new v.Sphere;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,n.boundingSphere=o}function P0(n,e,t){const i=e.attributes,s=[];function r(o,a){return t.getDependency("accessor",o).then(function(l){n.setAttribute(a,l)})}for(const o in i){const a=Hu[o]||o.toLowerCase();a in n.attributes||s.push(r(i[o],a))}if(e.indices!==void 0&&!n.index){const o=t.getDependency("accessor",e.indices).then(function(a){n.setIndex(a)});s.push(o)}return v.ColorManagement.workingColorSpace!==v.LinearSRGBColorSpace&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${v.ColorManagement.workingColorSpace}" not supported.`),yn(n,e),OT(n,e,t),Promise.all(s).then(function(){return e.targets!==void 0?BT(n,e.targets,t):n})}var Mt=(n=>(n.ModelLoadStart="model-load-start",n.ModelLoadProgress="model-load-progress",n.ModelLoaded="model-loaded",n.ModelError="model-error",n.SelectionChanged="selection-changed",n.HoverChanged="hover-changed",n.Click="click",n.MouseMove="mouse-move",n.CameraChanged="camera-changed",n.CameraIdle="camera-idle",n.EngineFree="engine-free",n.EngineBusy="engine-busy",n.MeasureChanged="measure-changed",n.MeasureClick="measure-click",n.SectionMove="section-move",n.LoadingCompleted="loading_completed",n))(Mt||{});let fa=null,pa=null,L0=null;const UT=8,R0=24,NT=24,zT=64,GT=200,VT=10;function k0(){return new URL("draco/",document.baseURI).toString()}function F0(){return new URL("basis/",document.baseURI).toString()}function QT(){return fa==null&&(fa=new zI,fa.setDecoderPath(k0()),fa.preload()),fa}function jT(n){return pa==null&&(pa=new Ni,pa.setTranscoderPath(F0())),L0!==n&&(pa.detectSupport(n),L0=n),pa}function WT(n){const e=new sT;return e.setDRACOLoader(QT()),e.setMeshoptDecoder(VI),n?.renderer?.capabilities!=null&&typeof n.renderer.getContext=="function"&&e.setKTX2Loader(jT(n.renderer)),e}function O0(){return new Promise(n=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>n());return}setTimeout(n,16)})}function HT(){const n=navigator?.scheduling;return typeof n?.isInputPending=="function"?n.isInputPending():!1}function XT(n){return n?.engineStatus?.isFree===!1||HT()}async function Yn(n,e,t){if(e)return t;const i=performance.now();return XT(n)||i-t>=UT?(await O0(),performance.now()):t}function qT(n,e){return new Promise((t,i)=>{ha(n,s=>{if(s==null){i(new Error(`[loadLightModel] empty zip json: ${n}`));return}t(s)},()=>{i(new Error(`[loadLightModel] failed to load zip json: ${n}`))},e)})}function YT(n,e){return Ct({method:"get",responseType:"arraybuffer",url:n}).then(async t=>{let i=t.data;return fo.isEncrypted(t.data)&&(i=await fo.decryptPzEnc(t.data,e)),Wm.loadAsync(i)})}function U0(n){return n.replace(/\\/g,"/").replace(/^\/+/,"")}function N0(n,e){const t=new Set(e.map(i=>U0(i)));for(const i of Object.keys(n.files))if(t.has(U0(i)))return n.files[i];return null}function z0(n,e){const t=N0(n,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function KT(n){return n.charCodeAt(0)===65279?n.slice(1):n}function Ku(n){return JSON.parse(KT(n))}function $T(n,e){const t=N0(n,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function JT(n,e){return new Promise((t,i)=>{WT(n).parse(e,document.baseURI,t,i)})}function vc(n,e){return n.models.find(t=>t.url==e)}function G0(n){n.loadStatus==null&&(n.loadStatus={}),n.loadStatus.modelMep==null&&(n.loadStatus.modelMep=!1),n.loadStatus.normal==null&&(n.loadStatus.normal=!1)}function ZT(n){return G0(n),n.status==="loaded"&&n.loadStatus.normal===!0&&n.loadStatus.modelMep===!0}function V0(n){const e=n?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(i=>ZT(i))||n.__loadingCompletedTriggered===!0||(n.__loadingCompletedTriggered=!0,n.events?.trigger?.(Mt.LoadingCompleted,{}))}function Q0(n){return n===!0||n==="loading"}function j0(n){return n.index!=null?n.index.count:n.attributes.position?.count??0}async function e2(n,e,t){let i=performance.now();for(let s=0;s<e.length;s++){const r=e[s];r?.geometry!=null&&r.geometry.computeVertexNormals,(s+1)%NT===0&&(i=await Yn(n,t,i))}}async function t2(n,e,t){const i=[],s=[{node:e.octreeBox,visited:!1}];let r=performance.now();for(;s.length>0;){const o=s.pop();if(o==null||o.node==null||o.node.status===!0)continue;const a=o.node;if(o.visited){const c=Array.isArray(a.children)?a.children:[];(c.length===0||c.findIndex(h=>h.status!=!0)===-1)&&(a.status=!0),r=await Yn(n,t,r);continue}s.push({node:a,visited:!0}),Array.isArray(a.elements)&&i.push(...a.elements);const l=Array.isArray(a.children)?a.children:[];for(let c=l.length-1;c>=0;c--)s.push({node:l[c],visited:!1});r=await Yn(n,t,r)}return i}async function i2(n,e,t,i){const s=vc(n,e.url);if(s?.nodesMap==null)return[];const r=await t2(n,t,i);console.log("[loadLightModel] pending mesh ids",t.path,r.length);const o=[];let a=performance.now(),l=0;for(const c of r){if(!s.nodesMap.has(c))continue;const h=s.nodesMap.get(c),d=Array.isArray(h?.infos)?h.infos:[];for(const f of d){const u=t.glbs?.[f.glb]?.[f.mesh];if(u?.geometry==null||u.material==null)continue;const g=new w.Matrix4;g.elements=f.matrix;const p=u.geometry.clone();p.applyMatrix4(g),p.computeBoundingBox();const m=new w.Mesh(p,u.material);f.box=p.boundingBox?.clone(),f.mesh=m,m.name=Number(c),m.glb=f.glb,m.url=e.url,p.attributes.position!=null&&o.push(m),l++,l%R0===0&&(a=await Yn(n,i,a))}}return o}function n2(n,e,t,i,s){const r=ws(i.map(a=>a.geometry),!1),o=new w.Mesh(r,s);return o.castShadow=!0,o.receiveShadow=!0,e.scene.add(o),o.index=e.scene.children.length-1,o.url=n,o.glb=t,o.materialClone=s,o.geometrys=i.map(a=>a.geometry),o.geometry.computeVertexNormals(),o}function s2(n,e,t,i){return n.scene.children.find(s=>{const r=s;return s instanceof w.Mesh&&r.url==e&&r.glb==t&&r.materialClone===i})}function r2(n,e){const t=Array.isArray(n.geometrys)?n.geometrys:[],i=e.map(o=>o.geometry),s=[...t,...i],r=ws(s,!1);n.geometry!=null&&n.geometry.dispose(),n.geometry=r,n.geometrys=s,n.castShadow=!0,n.receiveShadow=!0}async function o2(n,e,t,i){const s=new Map;for(const a of t){const l=s.get(a.glb)??[];l.push(a),s.set(a.glb,l)}const r=vc(e,n);let o=performance.now();for(const[a,l]of s.entries()){const c=i?l.length:GT;for(let h=0;h<l.length;h+=c){const d=l.slice(h,h+c);if(d.length===0)continue;const f=m2(d[0].material,e);let u=s2(e,n,a,f),g=0,p=0;u=null,u!=null?(g=Array.isArray(u.geometrys)?u.geometrys.length:0,p=j0(u.geometry),r2(u,d)):u=n2(n,e,a,d,f);const m=new Map;let A=p;d.forEach((x,b)=>{const y=Number(x.name),_=j0(x.geometry),S=m.get(y)??[];if(S.push([A,A+_]),m.set(y,S),r?.nodesMap?.has(y)){const C=r.nodesMap.get(y);C.indexes==null&&(C.indexes=[]),C.indexes.push([u.index,g+b,A,A+_])}A+=_}),u.indexes==null&&(u.indexes=new Map),m.forEach((x,b)=>{const y=u.indexes.get(b)??[];y.push(...x),u.indexes.set(b,y)}),o=await Yn(e,i,o)}}}async function a2(n,e,t,i,s,r){if(i==null||s==null||s.length===0)return;const o=vc(t,n);if(o==null)return;const a=new w.InstancedMesh(i.geometry,i.material,s.length);t.scene.add(a);const l=new Float32Array(s.length*3);for(let d=0;d<s.length;d++)l[d*3]=1,l[d*3+1]=1,l[d*3+2]=1;a.instanceColor=new w.InstancedBufferAttribute(l,3);let c=performance.now();const h=[];for(let d=0;d<s.length;d++){const f=s[d],u=new w.Matrix4;if(u.elements=f.matrix,a.setMatrixAt(d,u),a.matrixs||(a.matrixs=[]),a.matrixs.push(u.clone()),h.push(u.clone()),o.nodesMap.has(f.id)){const g=o.nodesMap.get(f.id);g.indexes==null&&(g.indexes=[]),g.indexes.push([t.scene.children.length-1,d,0,0])}else o.nodesMap.set(f.id,{instance:!0,info:f,indexes:[[t.scene.children.length-1,d,0,0]]});(d+1)%zT===0&&(c=await Yn(t,r,c))}a.instanceMatrix.needsUpdate=!0,a.instanceColor!=null&&(a.instanceColor.needsUpdate=!0),a.index=t.scene.children.length-1,a.materialClone=i.material,a.url=n,a.glb=i.glb,a.ids=s.map(d=>d.id),a.matrixsClone=h,a.meshIndex=e}async function l2(n,e,t,i){const s=e.instanceNodes;if(s==null)return;let r=performance.now();for(const o in s)if(s[o].isLoaded!==!0){s[o].isLoaded=!0;for(const a of s[o]){const l=e.glbs?.[o]?.[a.mesh];l!=null&&await a2(n.url,a.mesh,t,l,a.children,i)}r=await Yn(t,i,r)}}async function c2(n,e,t,i){if(t.status===!0||t.meshPromise!=null){await t.meshPromise;return}t.meshPromise=(async()=>{console.log(`[loadLightModel] start build lod meshes ${Date.now()-window.startTime}ms`);const s=await i2(n,e,t,i);await o2(e.url,n,s,i),await l2(e,t,n,i),t.status=!0,console.log(`[loadLightModel] *****************************************************finish build lod meshes ${Date.now()-window.startTime}ms`)})().finally(()=>{t.meshPromise=null}),await t.meshPromise}async function h2(n,e,t,i){if(t.loadSuccess!==!0){if(t.preparePromise!=null){await t.preparePromise;return}t.preparePromise=(async()=>{console.log("[loadLightModel] loading GLB bundle",t.path),t.glbs=t.glbs??{};const s=await YT(e.url+t.path,e.key),r=await z0(s,["/nodes.json","nodes.json"]);if(r==null)return;const o=Ku(r),a=vc(n,e.url);if(a==null)return;a.nodesMap==null&&(a.nodesMap=new Map);let l=performance.now();for(const h of Object.keys(o)){const d=o[h];for(let u=0;u<d.length;u++){const g=d[u];if(g.glb=h,a.nodesMap.has(g.id)===!1)a.nodesMap.set(g.id,{infos:[g]});else{if(!a.nodesMap.get(g.id).infos)continue;a.nodesMap.get(g.id).infos.push(g)}(u+1)%R0===0&&(l=await Yn(n,i,l))}const f=await $T(s,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(f==null){console.error("[loadLightModel] glb not found in zip",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,availableFiles:Object.keys(s.files)});continue}try{const u=await JT(n,f);t.glbs[h]=u.scene.children,t.glbs[h].forEach(g=>{g.matrixWorld}),await e2(n,t.glbs[h],i)}catch(u){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:k0(),basisTranscoderPath:F0(),error:u})}l=await Yn(n,i,l)}const c=await z0(s,["/instances.json","instances.json"]);t.instanceNodes=c!=null?Ku(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function d2(n,e,t){if(t.boundingBox||(t.boundingBox=new w.Box3,t.boundingBox.min=new w.Vector3(t.octreeBox.min.X,t.octreeBox.min.Z,-t.octreeBox.min.Y),t.boundingBox.max=new w.Vector3(t.octreeBox.max.X,t.octreeBox.max.Z,-t.octreeBox.max.Y)),!t.maxSize)return 1e3;const i=t.boundingBox,s=i.min,r=i.max,o=s.clone().add(r.clone()).multiplyScalar(.5),a=s.distanceTo(r),l=new w.Vector3,c=new w.Vector3,h=new w.Vector3,d=new w.Vector3;if(e.getWorldDirection(h),e.getWorldPosition(d),e.matrixWorld.extractBasis(l,c,new w.Vector3),e instanceof w.OrthographicCamera){const A=Math.max((e.top-e.bottom)/e.zoom,1e-6),x=n?.cameraModule?.perspectiveCamera?.getEffectiveFOV?.()??20,b=w.MathUtils.degToRad(x*.5),y=b>0?A/(2*Math.tan(b)):A;d.copy(o).add(h.clone().multiplyScalar(-y))}if(d.distanceTo(o)<=a*.5)return 1e3;const f=o.clone().sub(d).dot(h);if(f<=0)return 0;const u=d.clone().add(h.multiplyScalar(Math.max(f,a))),g=u.clone().add(l.setLength(t.maxSize)),p=new lt(e,n.renderer,n.scene).worldToScreen(u),m=new lt(e,n.renderer,n.scene).worldToScreen(g);return p.distanceTo(m)}async function u2(n,e,t,i){t.maxSize<1e6&&t.path!="/lod0"&&(!(d2(n,n.camera,t)>=VT)||t.status===!0)||(await h2(n,e,t,i),t.loadSuccess===!0&&await c2(n,e,t,i))}function f2(n,e,t){if(Q0(e.loadStatus.modelMep))return;e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await O0(),iT(n,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,V0(n)})().catch(s=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",s)})}function p2(n,e,t,i){const s=new w.Group;s.name=e,n.scene.add(s),n.models||(n.models=[]),window.startTime=Date.now();let r="WDDsBNtzVz6aSh/bCFh3CmjjANEDRryoXF1XCJvJjeE=";qT(e+"/info",r).then(o=>{const a=Ku(o);n.__loadingCompletedTriggered=!1,n.engineStatus.models.push({type:"light",info:a,name:a.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1},key:r}),n.models.push({url:e,nodesMap:new Map,grids:a.modelGrid,levels:a.modelLevel,rooms:a.modelRoom,views:a.modelView,name:a.baseInfo.name,boundingBox:{min:new w.Vector3(a.baseInfo.min.X*.3048,a.baseInfo.min.Z*.3048,-a.baseInfo.min.Y*.3048),max:new w.Vector3(a.baseInfo.max.X*.3048,a.baseInfo.max.Z*.3048,-a.baseInfo.max.Y*.3048)}}),n.models.length==i&&(n.viewCube.CameraGoHome(1),setTimeout(()=>{W0(n,null,!1)},100))}).catch(o=>{console.error("[loadLightModel] failed to load model info",{url:e,error:o})})}async function W0(n,e,t=!1){const i=n.engineStatus.models.filter(s=>e==null||s.url==e);for(const s of i)if(G0(s),!(s.status!=="loading"||s.type!=="light")&&(f2(n,s,t),!Q0(s.loadStatus.normal))){s.loadStatus.normal="loading";try{await g2(n,s,t)}finally{const r=Array.isArray(s.info?.lods)&&s.info.lods.every(o=>o.status===!0);s.loadStatus.normal=r,r&&(s.status="loaded"),V0(n)}}}async function g2(n,e,t=!1){if(console.log(`[loadLightModel] start loadNode ${Date.now()-window.startTime}ms`),!(e.info==null||e.info.lods==null))for(const i of e.info.lods)await u2(n,e,i,t)}function m2(n,e){return n.map!=null&&(n.map.colorSpace=w.SRGBColorSpace,n.map.needsUpdate=!0),n.clipShadows=!0,e?.sectionPlane&&(n.clippingPlanes=e.sectionPlane),n}class A2{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const s of e)i(s)==="light"&&p2(this.engine,s,t,e.length);function i(s){const r=s.split(".").pop();return r==="glb"||r==="gltf"?"gltf":"light"}}}var dr=(n=>(n.ModelLoadStart="model-load-start",n.ModelLoadProgress="model-load-progress",n.ModelLoaded="model-loaded",n.ModelError="model-error",n.SelectionChanged="selection-changed",n.HoverChanged="hover-changed",n.Click="click",n.MouseMove="mouse-move",n.CameraChanged="camera-changed",n.CameraIdle="camera-idle",n.ViewportResize="viewport-resize",n.EngineFree="engine-free",n.EngineBusy="engine-busy",n.MeasureChanged="measure-changed",n.SectionMove="section-move",n.LoadingCompleted="loading_completed",n))(dr||{});class x2{engine;isFree;isForceFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.isForceFree=!1,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(dr.EngineFree,e=>{this.updateFree(!0),W0(this.engine,e,!1),this.engine?.octreeBox?.requestBvhBuild?.()}),this.engine.events.on(dr.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let b2=class{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const i=String(e);this.listeners.has(i)||this.listeners.set(i,[]),this.listeners.get(i).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${i}, 当前监听器数量: ${this.listeners.get(i).length}`)}off(e,t){const i=String(e);if(!this.listeners.has(i)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${i}`);return}const s=this.listeners.get(i),r=s.indexOf(t);r!==-1?(s.splice(r,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${i}, 剩余监听器数量: ${s.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${i}`)}trigger(e,t){const i=String(e);if(!this.listeners.has(i)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${i}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const s=this.listeners.get(i);this.debugMode&&console.debug(`[EventModule] 触发事件: ${i}, 监听器数量: ${s.length}`,t),s.forEach((r,o)=>{try{r(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${i}] #${o}:`,a)}})}};const _c=1;class y2{engine;constructor(e){this.engine=e}init(){const e=new w.DirectionalLight(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2,e.shadow.intensity=_c;const i=new w.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(i),this.engine.scene.dirLight=i;const s=new w.AmbientLight(16777215,2);this.engine.scene.add(s)}}class v2{engine;behavior;isCtrlDown=!1;isShiftDown=!1;hoverOldId=null;timeOutEvent;selectionBox=null;isBoxSelecting=!1;selectionStart=new w.Vector2;selectionEnd=new w.Vector2;suppressClickOnce=!1;selectionThreshold=5;tempInstanceMatrix=new w.Matrix4;tempScale=new w.Vector3;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.ensureSelectionBox(),this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.cancelBoxSelection(),this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1,this.isBoxSelecting&&this.cancelBoxSelection()}handelKeyCtrlDown(){this.isCtrlDown=!0}handelKeyShiftUp(){this.isShiftDown=!1}handelKeyShiftDown(){this.isShiftDown=!0}handleMouseDown(e){e.button!==0||!this.isBoxSelectionModifierDown()||(this.isBoxSelecting=!0,this.selectionStart.set(e.offsetX,e.offsetY),this.selectionEnd.copy(this.selectionStart),this.suppressClickOnce=!1,this.clearHoverFeedback(),this.updateSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!1))}handelKeyEscDown(){this.engine.modelToolModule.unhighlightAllModels()}handleMouseMove(e){if(this.clearHoverTimeout(),this.isBoxSelecting){this.selectionEnd.set(e.offsetX,e.offsetY),this.clearHoverFeedback(),this.updateSelectionBox();return}if(e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;const i=this.getCatchMeshs(e,!0);i!=null&&i.length>0&&this.engine.hoverHighLight.showModelNameTag({url:i[0].url,ids:[i[0].name]},e.catch.point)},1e3)),!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}const t=this.getCatchMeshs(e);if(t!=null&&t.length>0){this.engine.hoverHighLight.hightMesh(t);return}e.catch==null&&this.engine.hoverHighLight.clearHighlight()}handleMouseUp(e){if(!this.isBoxSelecting)return;this.selectionEnd.set(e.offsetX,e.offsetY);const t=this.hasSelectionBox(),i=t?this.collectModelsInSelection():[];this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0),t&&(this.isBoxDeselectMode()?this.applyBoxDeselection(i):this.applyBoxSelection(i),this.suppressClickOnce=!0)}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){const c=e.catch.object,h=e.catch.object.id,f=this.engine.models.find(p=>p.url==c.url)?.nodesMap?.get(h),u=new Map;f?.indexes.forEach(p=>{this.getSceneModel(p[0])instanceof w.InstancedMesh&&(u.has(p[0])||u.set(p[0],[]),u.get(p[0])?.push(p[1]))});const g=[];return u.forEach((p,m)=>{const A=this.getSceneModel(m);p.forEach(x=>{const b=A.geometry.clone();b.applyMatrix4(A.matrixs[x]),g.push(new w.Mesh(b,A.material))})}),this.hoverOldId==h?[]:(this.hoverOldId=h,t||this.engine.hoverHighLight.clearHighlight(),g)}const s=e.catch.object,r=s.name,l=this.engine.models.find(c=>c.url===s.url)?.nodesMap?.get(r)?.infos?.map(c=>c.mesh)??[];return this.hoverOldId==r?[]:(this.hoverOldId=r,t||this.engine.hoverHighLight.clearHighlight(),l)}handleMouseClick(e){if(this.suppressClickOnce){this.suppressClickOnce=!1;return}if(this.isShiftDown){if(e.catch!=null){const s=e.catch.object;this.applyBoxDeselection([{url:s.url,ids:[s.name]}])}return}if(e.catch!=null){const i=e.catch,s=i.object;if(!this.isCtrlDown){this.engine.modelToolModule.unhighlightAllModels();const o=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(o)}this.engine.controlModule.orbitControls.origin.set(i.point.x,i.point.y,i.point.z),this.engine.modelToolModule.highlightModel([{url:s.url,ids:[s.name]}]),this.engine.events.trigger(Mt.Click,[{url:s.url,ids:[s.name]}]);const r=new CustomEvent("D3ElementClick",{detail:{id:s.name}});window.dispatchEvent(r);return}const t=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(t),this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(!e.catch){this.engine.viewCube.CameraGoHome(500);return}const t=e.catch,i=t.object,r=this.engine.models.find(l=>l.url===i.url)?.nodesMap?.get(i.name);if(!r)return;if(t.object.isInstance){const l=t.matrix,c=[];r.indexes.forEach(d=>{const f=this.getSceneModel(d[0]);f?.geometry?.boundingSphere||f?.geometry?.computeBoundingSphere?.();const u=f?.geometry?.boundingSphere;if(!u)return;const g=new w.Box3,p=u.center.clone().applyMatrix4(l),m=u.radius,A=new w.Vector3().setFromMatrixScale(l),x=m*Math.max(A.x,A.y,A.z);g.min.set(p.x-x,p.y-x,p.z-x),g.max.set(p.x+x,p.y+x,p.z+x),c.push(g)});const h=this.getMergedBox(c);h!=null&&this.engine.viewCube.zoomToModel(h);return}const o=r.infos.map(l=>l.box).filter(l=>l instanceof w.Box3),a=this.getMergedBox(o);a!=null&&this.engine.viewCube.zoomToModel(a)}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(t=>t instanceof w.InstancedMesh),!0)}ensureSelectionBox(){if(this.selectionBox!=null)return;const e=document.createElement("div");e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.display="none",e.style.pointerEvents="none",e.style.border="1px dashed #00aaff",e.style.backgroundColor="rgba(0, 170, 255, 0.12)",e.style.boxSizing="border-box",e.style.zIndex="1001",this.engine.container?.appendChild(e),this.selectionBox=e}updateSelectionBox(){if(this.selectionBox==null)return;if(!this.hasSelectionBox()){this.selectionBox.style.display="none";return}const e=this.getSelectionRect();this.selectionBox.style.display="block",this.selectionBox.style.left=`${e.left}px`,this.selectionBox.style.top=`${e.top}px`,this.selectionBox.style.width=`${e.right-e.left}px`,this.selectionBox.style.height=`${e.bottom-e.top}px`}hideSelectionBox(){this.selectionBox!=null&&(this.selectionBox.style.display="none")}cancelBoxSelection(){this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0)}clearHoverTimeout(){this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null)}clearHoverFeedback(){this.hoverOldId=null,this.engine.hoverHighLight.clearHighlight(),this.engine.hoverHighLight.showModelNameTag(null,null)}hasSelectionBox(){return Math.abs(this.selectionEnd.x-this.selectionStart.x)>=this.selectionThreshold&&Math.abs(this.selectionEnd.y-this.selectionStart.y)>=this.selectionThreshold}getSelectionRect(){return{left:Math.min(this.selectionStart.x,this.selectionEnd.x),top:Math.min(this.selectionStart.y,this.selectionEnd.y),right:Math.max(this.selectionStart.x,this.selectionEnd.x),bottom:Math.max(this.selectionStart.y,this.selectionEnd.y)}}isContainMode(){return this.selectionEnd.x>=this.selectionStart.x&&this.selectionEnd.y>=this.selectionStart.y}isBoxSelectionModifierDown(){return this.isCtrlDown}isBoxDeselectMode(){return this.isShiftDown}collectModelsInSelection(){const e=this.getSelectionRect(),t=this.isContainMode(),i=new Map;return this.engine.models?.forEach(s=>{!s?.url||!s?.nodesMap||s.nodesMap.forEach((r,o)=>{const a=this.getNodeWorldBox(r),l=this.projectBoxToScreenRect(a);l==null||!(t?this.containsRect(e,l):this.intersectsRect(e,l))||(i.has(s.url)||i.set(s.url,new Set),i.get(s.url)?.add(o))})}),Array.from(i.entries()).map(([s,r])=>({url:s,ids:Array.from(r)}))}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(Mt.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(Mt.SelectionChanged,t))}excludeHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(s=>t.get(i.url)?.add(s))}),e.map(i=>({url:i.url,ids:i.ids.filter(s=>!t.get(i.url)?.has(s))})).filter(i=>i.ids.length>0)}keepHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(s=>t.get(i.url)?.add(s))}),e.map(i=>({url:i.url,ids:i.ids.filter(s=>t.get(i.url)?.has(s))})).filter(i=>i.ids.length>0)}removeModelsFromHighlightState(e){const t=new Map;e.forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(s=>t.get(i.url)?.add(s))}),this.engine.engineStatus.highlightModels=(this.engine.engineStatus.highlightModels??[]).map(i=>({url:i.url,ids:i.ids.filter(s=>!t.get(i.url)?.has(s))})).filter(i=>i.ids.length>0)}getNodeWorldBox(e){if(Array.isArray(e?.infos)&&e.infos.length>0){const t=e.infos.map(i=>i?.box).filter(i=>i instanceof w.Box3);return this.getMergedBox(t)}if(Array.isArray(e?.indexes)&&e.indexes.length>0){const t=[];return e.indexes.forEach(i=>{const s=this.getSceneModel(i[0]),r=this.getInstanceWorldBox(s,i[1]);r!=null&&t.push(r)}),this.getMergedBox(t)}return null}getInstanceWorldBox(e,t){if(!(e instanceof w.InstancedMesh))return null;e.geometry.boundingBox||e.geometry.computeBoundingBox();const i=e.geometry.boundingBox;if(!i)return null;if(typeof e.getMatrixAt=="function")e.getMatrixAt(t,this.tempInstanceMatrix);else if(e.matrixs?.[t])this.tempInstanceMatrix.copy(e.matrixs[t]);else return null;return this.tempScale.setFromMatrixScale(this.tempInstanceMatrix),Math.abs(this.tempScale.x)+Math.abs(this.tempScale.y)+Math.abs(this.tempScale.z)<1e-6?null:i.clone().applyMatrix4(this.tempInstanceMatrix)}projectBoxToScreenRect(e){if(e==null||e.isEmpty())return null;const t=[new w.Vector3(e.min.x,e.min.y,e.min.z),new w.Vector3(e.min.x,e.min.y,e.max.z),new w.Vector3(e.min.x,e.max.y,e.min.z),new w.Vector3(e.min.x,e.max.y,e.max.z),new w.Vector3(e.max.x,e.min.y,e.min.z),new w.Vector3(e.max.x,e.min.y,e.max.z),new w.Vector3(e.max.x,e.max.y,e.min.z),new w.Vector3(e.max.x,e.max.y,e.max.z)];let i=1/0,s=1/0,r=-1/0,o=-1/0;return t.forEach(a=>{const l=new lt(this.engine.camera,this.engine.renderer,this.engine.scene).worldToScreen(a);!Number.isFinite(l.x)||!Number.isFinite(l.y)||(i=Math.min(i,l.x),s=Math.min(s,l.y),r=Math.max(r,l.x),o=Math.max(o,l.y))}),!Number.isFinite(i)||!Number.isFinite(s)||!Number.isFinite(r)||!Number.isFinite(o)?null:{left:i,top:s,right:r,bottom:o}}containsRect(e,t){return t.left>=e.left&&t.top>=e.top&&t.right<=e.right&&t.bottom<=e.bottom}intersectsRect(e,t){return!(t.right<e.left||t.left>e.right||t.bottom<e.top||t.top>e.bottom)}getMergedBox(e){if(e.length===0)return null;const t=new w.Box3().makeEmpty();return e.forEach(i=>t.union(i)),t.isEmpty()?null:t}getSceneModel(e){return this.engine.scene.children.find(t=>t.index===e)??this.engine.scene.children[e]}}class _2{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new w.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.8,side:w.DoubleSide}),this.hideMaterial=new w.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:w.DoubleSide}),this.translucentMaterial=new w.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:w.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof w.InstancedMesh)return;let t=e.materialClone.clone(),i=ws(e.geometrys,!0);i.computeVertexNormals(),i.groups.forEach(s=>{s.materialIndex=0}),e.geometry=i,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}getSceneModel(e){return this.engine.scene.children.find(t=>t.index==e)}highlightModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{this.getSceneModel(a[0])instanceof w.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):(console.log(this.getSceneModel(a[0]).materialClone.color),this.split_merge_model(this.getSceneModel(a[0])),this.getSceneModel(a[0]).geometry.groups[a[1]].materialIndex=1)})}),w2(i,this.engine);let s=this.engine.engineStatus.highlightModels.find(r=>r.url==t.url);s!=null?s.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{this.getSceneModel(o[0])instanceof w.InstancedMesh?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):this.getSceneModel(o[0]).geometry.groups[o[1]].materialIndex=0})}),H0(i,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.hideModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof w.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),i.size>0&&C2(i,this.engine);let s=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);s!=null?s.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.showModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof w.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),i.size>0&&X0(i,this.engine);let s=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);s&&(t.ids.forEach(r=>{const o=s.ids.indexOf(r);o!==-1&&s.ids.splice(o,1)}),s.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(r=>r!==s)))})}isolateModel(e){let t=[];this.engine.models.forEach(i=>{let s={url:i.url,ids:[]},r=e.find(o=>o.url==i.url);for(let o of i.nodesMap)r==null?s.ids.push(o[0]):r.ids.includes(o[0])||s.ids.push(o[0]);t.push(s)});debugger;this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(i=>{let s={url:i.url,ids:[]},r=e.find(o=>o.url==i.url);for(let o of i.nodesMap)r==null?s.ids.push(o[0]):r.ids.includes(o[0])||s.ids.push(o[0]);t.push(s)}),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let i=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof w.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=2)})}),S2(i,this.engine);let s=this.engine.engineStatus.translucentModels.find(r=>r.url==t.url);s!=null?s.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let i=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{const a=this.getSceneModel(o[0]);a instanceof w.InstancedMesh?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),a.geometry.groups[o[1]].materialIndex=0)})}),i.size>0&&X0(i,this.engine),H0(i,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(i.levelName,i.typeName,s=>{this.engine.modelToolModule.highlightModel(s)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(i.levelName,s=>{this.engine.modelToolModule.highlightModel(s)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(i.typeName,s=>{this.engine.modelToolModule.highlightModel(s)})}}function w2(n,e){n.forEach((t,i)=>{const s=ga(e,i);if(!(s instanceof w.InstancedMesh))return;const r=s.geometry,o=new w.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:w.DoubleSide}),a=new w.InstancedMesh(r,o,t.length);a.name="highlightModel",a.key=i;const l=new Map,c=new w.Matrix4,h=new w.Matrix4;h.makeScale(0,0,0),t.forEach((d,f)=>{s.getMatrixAt(d,c),l.set(d,c.clone()),s.setMatrixAt(d,h),a.setMatrixAt(f,c)}),s.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function H0(n,e,t){n.forEach((i,s)=>{const r=ga(e,s);if(!(r instanceof w.InstancedMesh))return;i.forEach(a=>{const l=r.matrixsClone[a];l&&r.setMatrixAt(a,l)}),r.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==s&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function S2(n,e){n.forEach((t,i)=>{const s=ga(e,i);if(!(s instanceof w.InstancedMesh))return;const r=s.geometry,o=new w.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:w.DoubleSide}),a=new w.InstancedMesh(r,o,t.length);a.name="translucentModel",a.key=i;const l=new Map,c=new w.Matrix4,h=new w.Matrix4;h.makeScale(0,0,0),t.forEach((d,f)=>{s.getMatrixAt(d,c),l.set(d,c.clone()),s.setMatrixAt(d,h),a.setMatrixAt(f,c)}),s.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function C2(n,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),n.forEach((t,i)=>{const s=ga(e,i);if(!(s instanceof w.InstancedMesh))return;const r=new Map,o=new w.Matrix4,a=new w.Matrix4;a.makeScale(0,0,0),t.forEach((l,c)=>{s.getMatrixAt(l,o),r.set(l,o.clone()),s.setMatrixAt(l,a)}),s.instanceMatrix.needsUpdate=!0})}function X0(n,e){n.forEach((t,i)=>{const s=ga(e,i);s instanceof w.InstancedMesh&&(t.forEach(r=>{const o=s.matrixs[r];o&&s.setMatrixAt(r,o)}),s.instanceMatrix.needsUpdate=!0)})}function ga(n,e){return n.scene.children.find(t=>t.index==e)}const q0="advanced";class M2{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch(q0)}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!0);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!0);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(i=>i instanceof w.DirectionalLight);t&&(t.castShadow=e),this.engine.scene?.traverse(i=>{i.material&&(i.castShadow!==void 0&&(i.castShadow=e),i.receiveShadow!==void 0&&(i.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&this.gtaoPass&&(this.gtaoPass.enabled=e)}setSSAO(e){this.engine.composerModule?.composer&&this.ssaoPass&&(this.ssaoPass.enabled=e)}setSaturation(e){this.saturationPass&&(this.saturationPass.enabled=e)}setOutputPass(e){this.outputPass&&(this.outputPass.enabled=e)}setFXAA(e){this.fxaaPass&&(this.fxaaPass.enabled=e)}setPerformanceMode(){this.setMode("simple")}setBalancedMode(){this.setMode("balance")}setQualityMode(){this.setMode("advanced")}setSuperQualityMode(){this.setMode("superAdvanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(r=>r instanceof w.DirectionalLight),s={low:1024,medium:2048,high:2048}[e];t?.shadow&&s&&(t.shadow.mapSize.width=s,t.shadow.mapSize.height=s,t.shadow.map?.dispose(),t.shadow.map=null)}setSaturationValue(e){this.saturationPass&&(this.saturationPass.uniforms.saturation.value=e)}setContrastValue(e){this.saturationPass&&(this.saturationPass.uniforms.contrast.value=e)}setGTAOIntensity(e){this.gtaoPass&&(this.gtaoPass.blendIntensity=e)}}class wc{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;tagDiv;constructor(e){this.engine=e,this.init();const t=document.createElement("div");this.tagDiv=t,t.className="tagDiv",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.borderRadius="10px",t.style.pointerEvents="none",this.engine.container.appendChild(this.tagDiv)}showModelNameTag(e,t){if(e==null){this.tagDiv.style.display="none";return}let i=this.engine.models.find(a=>a.url==e.url);if(i==null){this.tagDiv.style.display="none";return}let s=i.nodesMap.get(e.ids[0]);if(s.infos&&s.infos.length>0){let a=s.infos[0].name.replace(/\s*\[[a-f0-9-]+\]$/,"");this.tagDiv.innerHTML=a}const o=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=o.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=o.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new w.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:w.AdditiveBlending,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}hightMesh(e,t=16777215,i=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const s=(Array.isArray(e)?e:e?[e]:[]).filter(r=>r?.geometry);if(s.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=i;for(const r of s){let o=r.geometry.clone();o.computeVertexNormals();const a=new w.Mesh(o,this.overlayMaterial);r.updateWorldMatrix(!0,!1),a.matrix.copy(r.matrixWorld),a.matrixAutoUpdate=!1,this.engine.scene.add(a),this.overlayMeshes.push(a)}this.animState="fadeIn",this.animStartTime=performance.now()}clearHighlight(){this.overlayMeshes.length===0||this.animState==="fadeOut"||(this.animState="fadeOut",this.animStartTime=performance.now())}update(){if(this.animState==="idle"||this.overlayMeshes.length===0)return;const e=performance.now()-this.animStartTime,t=this.overlayMaterial.userData.targetOpacity??.35;if(this.animState==="fadeIn"){const i=Math.min(e/wc.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(i)*t,i>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const i=Math.min(e/wc.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(i))*t,i>=1&&(this.removeOverlayMeshes(),this.animState="idle")}}removeOverlayMeshes(){for(const e of this.overlayMeshes)this.engine.scene.remove(e);this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.animState="idle"}}var Sc={exports:{}},E2=Sc.exports,Y0;function I2(){return Y0||(Y0=1,(function(n,e){(function(t,i){n.exports=i()})(E2,function(){var t=function(){function i(u){return o.appendChild(u.dom),u}function s(u){for(var g=0;g<o.children.length;g++)o.children[g].style.display=g===u?"block":"none";r=u}var r=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(u){u.preventDefault(),s(++r%o.children.length)},!1);var a=(performance||Date).now(),l=a,c=0,h=i(new t.Panel("FPS","#0ff","#002")),d=i(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var f=i(new t.Panel("MB","#f08","#201"));return s(0),{REVISION:16,dom:o,addPanel:i,showPanel:s,begin:function(){a=(performance||Date).now()},end:function(){c++;var u=(performance||Date).now();if(d.update(u-a,200),u>l+1e3&&(h.update(1e3*c/(u-l),100),l=u,c=0,f)){var g=performance.memory;f.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return u},update:function(){a=this.end()},domElement:o,setMode:s}};return t.Panel=function(i,s,r){var o=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,d=48*c,f=3*c,u=2*c,g=3*c,p=15*c,m=74*c,A=30*c,x=document.createElement("canvas");x.width=h,x.height=d,x.style.cssText="width:80px;height:48px";var b=x.getContext("2d");return b.font="bold "+9*c+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=r,b.fillRect(0,0,h,d),b.fillStyle=s,b.fillText(i,f,u),b.fillRect(g,p,m,A),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g,p,m,A),{dom:x,update:function(y,_){o=Math.min(o,y),a=Math.max(a,y),b.fillStyle=r,b.globalAlpha=1,b.fillRect(0,0,h,p),b.fillStyle=s,b.fillText(l(y)+" "+i+" ("+l(o)+"-"+l(a)+")",f,u),b.drawImage(x,g+c,p,m-c,A,g,p,m-c,A),b.fillRect(g+m-c,p,c,A),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g+m-c,p,c,l((1-y/_)*A))}}},t})})(Sc)),Sc.exports}var T2=I2();const D2=Qm(T2);var mo=Object.freeze({Linear:Object.freeze({None:function(n){return n},In:function(n){return n},Out:function(n){return n},InOut:function(n){return n}}),Quadratic:Object.freeze({In:function(n){return n*n},Out:function(n){return n*(2-n)},InOut:function(n){return(n*=2)<1?.5*n*n:-.5*(--n*(n-2)-1)}}),Cubic:Object.freeze({In:function(n){return n*n*n},Out:function(n){return--n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n:.5*((n-=2)*n*n+2)}}),Quartic:Object.freeze({In:function(n){return n*n*n*n},Out:function(n){return 1- --n*n*n*n},InOut:function(n){return(n*=2)<1?.5*n*n*n*n:-.5*((n-=2)*n*n*n-2)}}),Quintic:Object.freeze({In:function(n){return n*n*n*n*n},Out:function(n){return--n*n*n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n*n*n:.5*((n-=2)*n*n*n*n+2)}}),Sinusoidal:Object.freeze({In:function(n){return 1-Math.sin((1-n)*Math.PI/2)},Out:function(n){return Math.sin(n*Math.PI/2)},InOut:function(n){return .5*(1-Math.sin(Math.PI*(.5-n)))}}),Exponential:Object.freeze({In:function(n){return n===0?0:Math.pow(1024,n-1)},Out:function(n){return n===1?1:1-Math.pow(2,-10*n)},InOut:function(n){return n===0?0:n===1?1:(n*=2)<1?.5*Math.pow(1024,n-1):.5*(-Math.pow(2,-10*(n-1))+2)}}),Circular:Object.freeze({In:function(n){return 1-Math.sqrt(1-n*n)},Out:function(n){return Math.sqrt(1- --n*n)},InOut:function(n){return(n*=2)<1?-.5*(Math.sqrt(1-n*n)-1):.5*(Math.sqrt(1-(n-=2)*n)+1)}}),Elastic:Object.freeze({In:function(n){return n===0?0:n===1?1:-Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI)},Out:function(n){return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n-.1)*5*Math.PI)+1},InOut:function(n){return n===0?0:n===1?1:(n*=2,n<1?-.5*Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI):.5*Math.pow(2,-10*(n-1))*Math.sin((n-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(n){var e=1.70158;return n===1?1:n*n*((e+1)*n-e)},Out:function(n){var e=1.70158;return n===0?0:--n*n*((e+1)*n+e)+1},InOut:function(n){var e=2.5949095;return(n*=2)<1?.5*(n*n*((e+1)*n-e)):.5*((n-=2)*n*((e+1)*n+e)+2)}}),Bounce:Object.freeze({In:function(n){return 1-mo.Bounce.Out(1-n)},Out:function(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375},InOut:function(n){return n<.5?mo.Bounce.In(n*2)*.5:mo.Bounce.Out(n*2-1)*.5+.5}}),generatePow:function(n){return n===void 0&&(n=4),n=n<Number.EPSILON?Number.EPSILON:n,n=n>1e4?1e4:n,{In:function(e){return Math.pow(e,n)},Out:function(e){return 1-Math.pow(1-e,n)},InOut:function(e){return e<.5?Math.pow(e*2,n)/2:(1-Math.pow(2-e*2,n))/2+.5}}}}),ma=function(){return performance.now()},B2=(function(){function n(){this._tweens={},this._tweensAddedDuringUpdate={}}return n.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},n.prototype.removeAll=function(){this._tweens={}},n.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},n.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},n.prototype.update=function(e,t){e===void 0&&(e=ma()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s<i.length;s++){var r=this._tweens[i[s]],o=!t;r&&r.update(e,o)===!1&&!t&&delete this._tweens[i[s]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},n})(),$u={Linear:function(n,e){var t=n.length-1,i=t*e,s=Math.floor(i),r=$u.Utils.Linear;return e<0?r(n[0],n[1],i):e>1?r(n[t],n[t-1],t-i):r(n[s],n[s+1>t?t:s+1],i-s)},Utils:{Linear:function(n,e,t){return(e-n)*t+n}}},K0=(function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n})(),Ju=new B2,P2=(function(){function n(e,t){t===void 0&&(t=Ju),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=mo.Linear.None,this._interpolationFunction=$u.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=K0.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return n.prototype.getId=function(){return this._id},n.prototype.isPlaying=function(){return this._isPlaying},n.prototype.isPaused=function(){return this._isPaused},n.prototype.getDuration=function(){return this._duration},n.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},n.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},n.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},n.prototype.start=function(e,t){if(e===void 0&&(e=ma()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var r in this._valuesEnd)s[r]=this._valuesEnd[r];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},n.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},n.prototype._setupProperties=function(e,t,i,s,r){for(var o in i){var a=e[o],l=Array.isArray(a),c=l?"array":typeof a,h=!l&&Array.isArray(i[o]);if(!(c==="undefined"||c==="function")){if(h){var d=i[o];if(d.length===0)continue;for(var f=[a],u=0,g=d.length;u<g;u+=1){var p=this._handleRelativeValue(a,d[u]);if(isNaN(p)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}f.push(p)}h&&(i[o]=f)}if((c==="object"||l)&&a&&!h){t[o]=l?[]:{};var m=a;for(var A in m)t[o][A]=m[A];s[o]=l?[]:{};var d=i[o];if(!this._isDynamic){var x={};for(var A in d)x[A]=d[A];i[o]=d=x}this._setupProperties(m,t[o],d,s[o],r)}else(typeof t[o]>"u"||r)&&(t[o]=a),l||(t[o]*=1),h?s[o]=i[o].slice().reverse():s[o]=t[o]||0}}},n.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},n.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},n.prototype.pause=function(e){return e===void 0&&(e=ma()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},n.prototype.resume=function(e){return e===void 0&&(e=ma()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},n.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},n.prototype.group=function(e){return e===void 0&&(e=Ju),this._group=e,this},n.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},n.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},n.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},n.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},n.prototype.easing=function(e){return e===void 0&&(e=mo.Linear.None),this._easingFunction=e,this},n.prototype.interpolation=function(e){return e===void 0&&(e=$u.Linear),this._interpolationFunction=e,this},n.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},n.prototype.onStart=function(e){return this._onStartCallback=e,this},n.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},n.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},n.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},n.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},n.prototype.onStop=function(e){return this._onStopCallback=e,this},n.prototype.update=function(e,t){var i=this,s;if(e===void 0&&(e=ma()),t===void 0&&(t=!0),this._isPaused)return!0;var r,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>o)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,l=this._duration+((s=this._repeatDelayTime)!==null&&s!==void 0?s:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(i._duration===0||a>c)return 1;var m=Math.trunc(a/l),A=a-m*l,x=Math.min(A/i._duration,1);return x===0&&a===i._duration?1:x},d=h(),f=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,f),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||a>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=u);for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,p=this._chainedTweens.length;g<p;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},n.prototype._updateProperties=function(e,t,i,s){for(var r in i)if(t[r]!==void 0){var o=t[r]||0,a=i[r],l=Array.isArray(e[r]),c=Array.isArray(a),h=!l&&c;h?e[r]=this._interpolationFunction(a,s):typeof a=="object"&&a?this._updateProperties(e[r],o,a,s):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(e[r]=o+(a-o)*s))}},n.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},n.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],i=this._valuesEnd[e];typeof i=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(i):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},n})();K0.nextId;var vn=Ju;vn.getAll.bind(vn),vn.removeAll.bind(vn),vn.add.bind(vn),vn.remove.bind(vn),vn.update.bind(vn);var Aa={Easing:mo,Tween:P2};const $0={type:"change"},Zu={type:"start"},J0={type:"end"},Cc=new v.Ray,Z0=new v.Plane,L2=Math.cos(70*v.MathUtils.DEG2RAD),Qt=new v.Vector3,yi=2*Math.PI,pt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},ef=1e-6;class R2 extends v.Controls{constructor(e,t=null){super(e,t),this.state=pt.NONE,this.target=new v.Vector3,this.cursor=new v.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:v.MOUSE.ROTATE,MIDDLE:v.MOUSE.DOLLY,RIGHT:v.MOUSE.PAN},this.touches={ONE:v.TOUCH.ROTATE,TWO:v.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new v.Vector3,this._lastQuaternion=new v.Quaternion,this._lastTargetPosition=new v.Vector3,this._quat=new v.Quaternion().setFromUnitVectors(e.up,new v.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new v.Spherical,this._sphericalDelta=new v.Spherical,this._scale=1,this._panOffset=new v.Vector3,this._rotateStart=new v.Vector2,this._rotateEnd=new v.Vector2,this._rotateDelta=new v.Vector2,this._panStart=new v.Vector2,this._panEnd=new v.Vector2,this._panDelta=new v.Vector2,this._dollyStart=new v.Vector2,this._dollyEnd=new v.Vector2,this._dollyDelta=new v.Vector2,this._dollyDirection=new v.Vector3,this._mouse=new v.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=F2.bind(this),this._onPointerDown=k2.bind(this),this._onPointerUp=O2.bind(this),this._onContextMenu=j2.bind(this),this._onMouseWheel=z2.bind(this),this._onKeyDown=G2.bind(this),this._onTouchStart=V2.bind(this),this._onTouchMove=Q2.bind(this),this._onMouseDown=U2.bind(this),this._onMouseMove=N2.bind(this),this._interceptControlDown=W2.bind(this),this._interceptControlUp=H2.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent($0),this.update(),this.state=pt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;Qt.copy(t).sub(this.target),Qt.applyQuaternion(this._quat),this._spherical.setFromVector3(Qt),this.autoRotate&&this.state===pt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=yi:i>Math.PI&&(i-=yi),s<-Math.PI?s+=yi:s>Math.PI&&(s-=yi),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Qt.setFromSpherical(this._spherical),Qt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Qt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Qt.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new v.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new v.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Qt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Cc.origin.copy(this.object.position),Cc.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Cc.direction))<L2?this.object.lookAt(this.target):(Z0.setFromNormalAndCoplanarPoint(this.object.up,this.target),Cc.intersectPlane(Z0,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>ef||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ef||this._lastTargetPosition.distanceToSquared(this.target)>ef?(this.dispatchEvent($0),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?yi/60*this.autoRotateSpeed*e:yi/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Qt.setFromMatrixColumn(t,0),Qt.multiplyScalar(-e),this._panOffset.add(Qt)}_panUp(e,t){this.screenSpacePanning===!0?Qt.setFromMatrixColumn(t,1):(Qt.setFromMatrixColumn(t,0),Qt.crossVectors(this.object.up,Qt)),Qt.multiplyScalar(e),this._panOffset.add(Qt)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Qt.copy(s).sub(this.target);let r=Qt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,o=i.width,a=i.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(yi*this._rotateDelta.x/t.clientHeight),this._rotateUp(yi*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(yi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-yi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(yi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-yi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(yi*this._rotateDelta.x/t.clientHeight),this._rotateUp(yi*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new v.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function k2(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function F2(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function O2(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(J0),this.state=pt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function U2(n){let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case v.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=pt.DOLLY;break;case v.MOUSE.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=pt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=pt.ROTATE}break;case v.MOUSE.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=pt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=pt.PAN}break;default:this.state=pt.NONE}this.state!==pt.NONE&&this.dispatchEvent(Zu)}function N2(n){switch(this.state){case pt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case pt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case pt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function z2(n){this.enabled===!1||this.enableZoom===!1||this.state!==pt.NONE||(n.preventDefault(),this.dispatchEvent(Zu),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(J0))}function G2(n){this.enabled!==!1&&this._handleKeyDown(n)}function V2(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case v.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=pt.TOUCH_ROTATE;break;case v.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=pt.TOUCH_PAN;break;default:this.state=pt.NONE}break;case 2:switch(this.touches.TWO){case v.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=pt.TOUCH_DOLLY_PAN;break;case v.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=pt.TOUCH_DOLLY_ROTATE;break;default:this.state=pt.NONE}break;default:this.state=pt.NONE}this.state!==pt.NONE&&this.dispatchEvent(Zu)}function Q2(n){switch(this._trackPointer(n),this.state){case pt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case pt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case pt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case pt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=pt.NONE}}function j2(n){this.enabled!==!1&&n.preventDefault()}function W2(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function H2(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const ur=new v.Raycaster,ei=new v.Vector3,Cs=new v.Vector3,_t=new v.Quaternion,ex={X:new v.Vector3(1,0,0),Y:new v.Vector3(0,1,0),Z:new v.Vector3(0,0,1)},tf={type:"change"},tx={type:"mouseDown",mode:null},ix={type:"mouseUp",mode:null},nx={type:"objectChange"};class sx extends v.Controls{constructor(e,t=null){super(void 0,t);const i=new J2(this);this._root=i;const s=new Z2;this._gizmo=s,i.add(s);const r=new eD;this._plane=r,i.add(r);const o=this;function a(b,y){let _=y;Object.defineProperty(o,b,{get:function(){return _!==void 0?_:y},set:function(S){_!==S&&(_=S,r[b]=S,s[b]=S,o.dispatchEvent({type:b+"-changed",value:S}),o.dispatchEvent(tf))}}),o[b]=y,r[b]=y,s[b]=y}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new v.Vector3,c=new v.Vector3,h=new v.Quaternion,d=new v.Quaternion,f=new v.Vector3,u=new v.Quaternion,g=new v.Vector3,p=new v.Vector3,m=new v.Vector3,A=0,x=new v.Vector3;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",h),a("worldQuaternionStart",d),a("cameraPosition",f),a("cameraQuaternion",u),a("pointStart",g),a("pointEnd",p),a("rotationAxis",m),a("rotationAngle",A),a("eye",x),this._offset=new v.Vector3,this._startNorm=new v.Vector3,this._endNorm=new v.Vector3,this._cameraScale=new v.Vector3,this._parentPosition=new v.Vector3,this._parentQuaternion=new v.Quaternion,this._parentQuaternionInv=new v.Quaternion,this._parentScale=new v.Vector3,this._worldScaleStart=new v.Vector3,this._worldQuaternionInv=new v.Quaternion,this._worldScale=new v.Vector3,this._positionStart=new v.Vector3,this._quaternionStart=new v.Quaternion,this._scaleStart=new v.Vector3,this._getPointer=X2.bind(this),this._onPointerDown=Y2.bind(this),this._onPointerHover=q2.bind(this),this._onPointerMove=K2.bind(this),this._onPointerUp=$2.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&ur.setFromCamera(e,this.camera);const t=nf(this._gizmo.picker[this.mode],ur);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&ur.setFromCamera(e,this.camera);const t=nf(this._plane,ur,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,tx.mode=this.mode,this.dispatchEvent(tx)}}pointerMove(e){const t=this.axis,i=this.mode,s=this.object;let r=this.space;if(i==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),s===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&ur.setFromCamera(e,this.camera);const o=nf(this._plane,ur,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(s.position.applyQuaternion(_t.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),r==="world"&&(s.parent&&s.position.add(ei.setFromMatrixPosition(s.parent.matrixWorld)),t.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(ei.setFromMatrixPosition(s.parent.matrixWorld)))),s.position.x=Math.max(this.minX,Math.min(this.maxX,s.position.x)),s.position.y=Math.max(this.minY,Math.min(this.maxY,s.position.y)),s.position.z=Math.max(this.minZ,Math.min(this.maxZ,s.position.z));else if(i==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Cs.set(a,a,a)}else ei.copy(this.pointStart),Cs.copy(this.pointEnd),ei.applyQuaternion(this._worldQuaternionInv),Cs.applyQuaternion(this._worldQuaternionInv),Cs.divide(ei),t.search("X")===-1&&(Cs.x=1),t.search("Y")===-1&&(Cs.y=1),t.search("Z")===-1&&(Cs.z=1);s.scale.copy(this._scaleStart).multiply(Cs),this.scaleSnap&&(t.search("X")!==-1&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(ei.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(ei.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(ex[t]),ei.copy(ex[t]),r==="local"&&ei.applyQuaternion(this.worldQuaternion),ei.cross(this.eye),ei.length()===0?l=!0:this.rotationAngle=this._offset.dot(ei.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(_t.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(_t.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(tf),this.dispatchEvent(nx)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(ix.mode=this.mode,this.dispatchEvent(ix)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(tf),this.dispatchEvent(nx),this.pointStart.copy(this.pointEnd))}getRaycaster(){return ur}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,i,s){const r=this._gizmo.materialLib;r.xAxis.color.set(e),r.yAxis.color.set(t),r.zAxis.color.set(i),r.active.color.set(s),r.xAxisTransparent.color.set(e),r.yAxisTransparent.color.set(t),r.zAxisTransparent.color.set(i),r.activeTransparent.color.set(s),r.xAxis._color&&r.xAxis._color.set(e),r.yAxis._color&&r.yAxis._color.set(t),r.zAxis._color&&r.zAxis._color.set(i),r.active._color&&r.active._color.set(s),r.xAxisTransparent._color&&r.xAxisTransparent._color.set(e),r.yAxisTransparent._color&&r.yAxisTransparent._color.set(t),r.zAxisTransparent._color&&r.zAxisTransparent._color.set(i),r.activeTransparent._color&&r.activeTransparent._color.set(s)}}function X2(n){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:n.button};{const e=this.domElement.getBoundingClientRect();return{x:(n.clientX-e.left)/e.width*2-1,y:-(n.clientY-e.top)/e.height*2+1,button:n.button}}}function q2(n){if(this.enabled)switch(n.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(n));break}}function Y2(n){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(n)),this.pointerDown(this._getPointer(n)))}function K2(n){this.enabled&&this.pointerMove(this._getPointer(n))}function $2(n){this.enabled&&(this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(n)))}function nf(n,e,t){const i=e.intersectObject(n,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||t)return i[s];return!1}const Mc=new v.Euler,mt=new v.Vector3(0,1,0),rx=new v.Vector3(0,0,0),ox=new v.Matrix4,Ec=new v.Quaternion,Ic=new v.Quaternion,_n=new v.Vector3,ax=new v.Matrix4,xa=new v.Vector3(1,0,0),fr=new v.Vector3(0,1,0),ba=new v.Vector3(0,0,1),Tc=new v.Vector3,ya=new v.Vector3,va=new v.Vector3;class J2 extends v.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class Z2 extends v.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new v.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new v.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const s=t.clone();s.opacity=.5;const r=e.clone();r.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const d=e.clone();d.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25;const u=e.clone();u.color.setHex(16776960);const g=e.clone();g.color.setHex(7895160),this.materialLib={xAxis:r,yAxis:o,zAxis:a,active:u,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:h,activeTransparent:f};const p=new v.CylinderGeometry(0,.04,.1,12);p.translate(0,.05,0);const m=new v.BoxGeometry(.08,.08,.08);m.translate(0,.04,0);const A=new v.BufferGeometry;A.setAttribute("position",new v.Float32BufferAttribute([0,0,0,1,0,0],3));const x=new v.CylinderGeometry(.0075,.0075,.5,3);x.translate(0,.25,0);function b(F,z){const X=new v.TorusGeometry(F,.0075,3,64,z*Math.PI*2);return X.rotateY(Math.PI/2),X.rotateX(Math.PI/2),X}function y(){const F=new v.BufferGeometry;return F.setAttribute("position",new v.Float32BufferAttribute([0,0,0,1,1,1],3)),F}const _={X:[[new v.Mesh(p,r),[.5,0,0],[0,0,-Math.PI/2]],[new v.Mesh(p,r),[-.5,0,0],[0,0,Math.PI/2]],[new v.Mesh(x,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new v.Mesh(p,o),[0,.5,0]],[new v.Mesh(p,o),[0,-.5,0],[Math.PI,0,0]],[new v.Mesh(x,o)]],Z:[[new v.Mesh(p,a),[0,0,.5],[Math.PI/2,0,0]],[new v.Mesh(p,a),[0,0,-.5],[-Math.PI/2,0,0]],[new v.Mesh(x,a),null,[Math.PI/2,0,0]]],XYZ:[[new v.Mesh(new v.OctahedronGeometry(.1,0),d),[0,0,0]]],XY:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new v.Mesh(new v.OctahedronGeometry(.2,0),i)]],XY:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},C={START:[[new v.Mesh(new v.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new v.Mesh(new v.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new v.Line(y(),s),null,null,null,"helper"]],X:[[new v.Line(A,s),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new v.Line(A,s),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new v.Line(A,s),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},D={XYZE:[[new v.Mesh(b(.5,1),g),null,[0,Math.PI/2,0]]],X:[[new v.Mesh(b(.5,.5),r)]],Y:[[new v.Mesh(b(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new v.Mesh(b(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new v.Mesh(b(.75,1),f),null,[0,Math.PI/2,0]]]},M={AXIS:[[new v.Line(A,s),[-1e3,0,0],null,[1e6,1,1],"helper"]]},I={XYZE:[[new v.Mesh(new v.SphereGeometry(.25,10,8),i)]],X:[[new v.Mesh(new v.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new v.Mesh(new v.TorusGeometry(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new v.Mesh(new v.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new v.Mesh(new v.TorusGeometry(.75,.1,2,24),i)]]},P={X:[[new v.Mesh(m,r),[.5,0,0],[0,0,-Math.PI/2]],[new v.Mesh(x,r),[0,0,0],[0,0,-Math.PI/2]],[new v.Mesh(m,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new v.Mesh(m,o),[0,.5,0]],[new v.Mesh(x,o)],[new v.Mesh(m,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new v.Mesh(m,a),[0,0,.5],[Math.PI/2,0,0]],[new v.Mesh(x,a),[0,0,0],[Math.PI/2,0,0]],[new v.Mesh(m,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new v.Mesh(new v.BoxGeometry(.1,.1,.1),d)]]},T={X:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new v.Mesh(new v.BoxGeometry(.2,.2,.2),i),[0,0,0]]]},L={X:[[new v.Line(A,s),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new v.Line(A,s),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new v.Line(A,s),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function E(F){const z=new v.Object3D;for(const X in F)for(let j=F[X].length;j--;){const N=F[X][j][0].clone(),Y=F[X][j][1],V=F[X][j][2],H=F[X][j][3],oe=F[X][j][4];N.name=X,N.tag=oe,Y&&N.position.set(Y[0],Y[1],Y[2]),V&&N.rotation.set(V[0],V[1],V[2]),H&&N.scale.set(H[0],H[1],H[2]),N.updateMatrix();const pe=N.geometry.clone();pe.applyMatrix4(N.matrix),N.geometry=pe,N.renderOrder=1/0,N.position.set(0,0,0),N.rotation.set(0,0,0),N.scale.set(1,1,1),z.add(N)}return z}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=E(_)),this.add(this.gizmo.rotate=E(D)),this.add(this.gizmo.scale=E(P)),this.add(this.picker.translate=E(S)),this.add(this.picker.rotate=E(I)),this.add(this.picker.scale=E(T)),this.add(this.helper.translate=E(C)),this.add(this.helper.rotate=E(M)),this.add(this.helper.scale=E(L)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Ic;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let r=0;r<s.length;r++){const o=s[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(_t.setFromEuler(Mc.set(0,0,0)),o.quaternion.copy(i).multiply(_t),Math.abs(mt.copy(xa).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(_t.setFromEuler(Mc.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(_t),Math.abs(mt.copy(fr).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(_t.setFromEuler(Mc.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(_t),Math.abs(mt.copy(ba).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(_t.setFromEuler(Mc.set(0,Math.PI/2,0)),mt.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(ox.lookAt(rx,mt,fr)),o.quaternion.multiply(_t),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),ei.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),ei.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(ei),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(mt.copy(xa).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(mt.copy(fr).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(mt.copy(ba).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(mt.copy(ba).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(mt.copy(xa).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(mt.copy(fr).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(Ec.copy(i),mt.copy(this.eye).applyQuaternion(_t.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(ox.lookAt(this.eye,rx,fr)),o.name==="X"&&(_t.setFromAxisAngle(xa,Math.atan2(-mt.y,mt.z)),_t.multiplyQuaternions(Ec,_t),o.quaternion.copy(_t)),o.name==="Y"&&(_t.setFromAxisAngle(fr,Math.atan2(mt.x,mt.z)),_t.multiplyQuaternions(Ec,_t),o.quaternion.copy(_t)),o.name==="Z"&&(_t.setFromAxisAngle(ba,Math.atan2(mt.y,mt.x)),_t.multiplyQuaternions(Ec,_t),o.quaternion.copy(_t))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis?(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1):this.axis.split("").some(function(l){return o.name===l})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class eD extends v.Mesh{constructor(){super(new v.PlaneGeometry(1e5,1e5,2,2),new v.MeshBasicMaterial({visible:!1,wireframe:!0,side:v.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Tc.copy(xa).applyQuaternion(t==="local"?this.worldQuaternion:Ic),ya.copy(fr).applyQuaternion(t==="local"?this.worldQuaternion:Ic),va.copy(ba).applyQuaternion(t==="local"?this.worldQuaternion:Ic),mt.copy(ya),this.mode){case"translate":case"scale":switch(this.axis){case"X":mt.copy(this.eye).cross(Tc),_n.copy(Tc).cross(mt);break;case"Y":mt.copy(this.eye).cross(ya),_n.copy(ya).cross(mt);break;case"Z":mt.copy(this.eye).cross(va),_n.copy(va).cross(mt);break;case"XY":_n.copy(va);break;case"YZ":_n.copy(Tc);break;case"XZ":mt.copy(va),_n.copy(ya);break;case"XYZ":case"E":_n.set(0,0,0);break}break;case"rotate":default:_n.set(0,0,0)}_n.length()===0?this.quaternion.copy(this.cameraQuaternion):(ax.lookAt(ei.set(0,0,0),_n,mt),this.quaternion.setFromRotationMatrix(ax)),super.updateMatrixWorld(e)}}class tD extends v.DataTextureLoader{constructor(e){super(e),this.type=v.HalfFloatType}parse(e){const o=function(D,M){switch(D){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(M||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(M||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(M||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(M||""))}},d=function(D,M,I){M=M||1024;let T=D.pos,L=-1,E=0,F="",z=String.fromCharCode.apply(null,new Uint16Array(D.subarray(T,T+128)));for(;0>(L=z.indexOf(`
|
|
4941
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([l])),this.transcoderBinary=o,this.workerPool.setWorkerCreator(()=>{const c=new Worker(this.workerSourceURL),h=this.transcoderBinary.slice(0);return c.postMessage({type:"init",config:this.workerConfig,transcoderBinary:h},[h]),c})}),Vu>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),Vu++}return this.transcoderPending}load(e,t,i,s){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new v.FileLoader(this.manager);r.setPath(this.path),r.setCrossOrigin(this.crossOrigin),r.setWithCredentials(this.withCredentials),r.setRequestHeader(this.requestHeader),r.setResponseType("arraybuffer"),r.load(e,o=>{this.parse(o,t,s)},i,s)}parse(e,t,i){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(Gu.has(e))return Gu.get(e).promise.then(t).catch(i);this._createTexture(e).then(s=>t?t(s):null).catch(i)}_createTextureFrom(e,t){const{type:i,error:s,data:{faces:r,width:o,height:a,format:l,type:c,dfdFlags:h}}=e;if(i==="error")return Promise.reject(s);let d;if(t.faceCount===6)d=new v.CompressedCubeTexture(r,l,c);else{const f=r[0].mipmaps;d=t.layerCount>1?new v.CompressedArrayTexture(f,o,a,t.layerCount,l,c):new v.CompressedTexture(f,o,a,l,c)}return d.minFilter=r[0].mipmaps.length===1?v.LinearFilter:v.LinearMipmapLinearFilter,d.magFilter=v.LinearFilter,d.generateMipmaps=!1,d.needsUpdate=!0,d.colorSpace=_0(t),d.premultiplyAlpha=!!(h&WI),d}async _createTexture(e,t={}){const i=KI(new Uint8Array(e)),s=i.vkFormat===Ou&&i.dataFormatDescriptor[0].colorModel===167;if(!(i.vkFormat===YI||s&&!this.workerConfig.astcHDRSupported))return tT(i);const o=t,a=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:o},[e])).then(l=>this._createTextureFrom(l.data,i));return Gu.set(e,{promise:a}),a}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),Vu--}}Ni.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},Ni.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},Ni.EngineFormat={RGBAFormat:v.RGBAFormat,RGBA_ASTC_4x4_Format:v.RGBA_ASTC_4x4_Format,RGB_BPTC_UNSIGNED_Format:v.RGB_BPTC_UNSIGNED_Format,RGBA_BPTC_Format:v.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:v.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:v.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:v.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:v.RGB_ETC1_Format,RGB_ETC2_Format:v.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:v.RGB_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format:v.RGBA_S3TC_DXT1_Format},Ni.EngineType={UnsignedByteType:v.UnsignedByteType,HalfFloatType:v.HalfFloatType,FloatType:v.FloatType},Ni.BasisWorker=function(){let n,e,t;const i=_EngineFormat,s=_EngineType,r=_TranscoderFormat,o=_BasisFormat;self.addEventListener("message",function(g){const p=g.data;switch(p.type){case"init":n=p.config,a(p.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:m,buffers:A,width:x,height:b,hasAlpha:y,format:_,type:S,dfdFlags:C}=l(p.buffer);self.postMessage({type:"transcode",id:p.id,data:{faces:m,width:x,height:b,hasAlpha:y,format:_,type:S,dfdFlags:C}},A)}catch(m){console.error(m),self.postMessage({type:"error",id:p.id,error:m.message})}});break}});function a(g){e=new Promise(p=>{t={wasmBinary:g,onRuntimeInitialized:p},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function l(g){const p=new t.KTX2File(new Uint8Array(g));function m(){p.close(),p.delete()}if(!p.isValid())throw m(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let A;if(p.isUASTC())A=o.UASTC;else if(p.isETC1S())A=o.ETC1S;else if(p.isHDR())A=o.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const x=p.getWidth(),b=p.getHeight(),y=p.getLayers()||1,_=p.getLevels(),S=p.getFaces(),C=p.getHasAlpha(),D=p.getDFDFlags(),{transcoderFormat:M,engineFormat:I,engineType:P}=d(A,x,b,C);if(!x||!b||!_)throw m(),new Error("THREE.KTX2Loader: Invalid texture");if(!p.startTranscoding())throw m(),new Error("THREE.KTX2Loader: .startTranscoding failed");const T=[],L=[];for(let E=0;E<S;E++){const F=[];for(let z=0;z<_;z++){const X=[];let j,N;for(let V=0;V<y;V++){const H=p.getImageLevelInfo(z,V,E);E===0&&z===0&&V===0&&(H.origWidth%4!==0||H.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),_>1?(j=H.origWidth,N=H.origHeight):(j=H.width,N=H.height);let oe=new Uint8Array(p.getImageTranscodedSizeInBytes(z,V,0,M));const pe=p.transcodeImage(oe,z,V,E,M,0,-1,-1);if(P===s.HalfFloatType&&(oe=new Uint16Array(oe.buffer,oe.byteOffset,oe.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!pe)throw m(),new Error("THREE.KTX2Loader: .transcodeImage failed.");X.push(oe)}const Y=u(X);F.push({data:Y,width:j,height:N}),L.push(Y.buffer)}T.push({mipmaps:F,width:x,height:b,format:I,type:P})}return m(),{faces:T,buffers:L,width:x,height:b,hasAlpha:C,dfdFlags:D,format:I,type:P}}const c=[{if:"astcSupported",basisFormat:[o.UASTC],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],engineType:[s.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],engineType:[s.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.BC1,r.BC3],engineFormat:[i.RGBA_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],engineType:[s.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],engineType:[s.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.ETC1],engineFormat:[i.RGB_ETC1_Format],engineType:[s.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],engineType:[s.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[o.UASTC_HDR],transcoderFormat:[r.BC6H],engineFormat:[i.RGB_BPTC_UNSIGNED_Format],engineType:[s.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.RGBA32,r.RGBA32],engineFormat:[i.RGBAFormat,i.RGBAFormat],engineType:[s.UnsignedByteType,s.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[o.UASTC_HDR],transcoderFormat:[r.RGBA_HALF],engineFormat:[i.RGBAFormat],engineType:[s.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],h={[o.ETC1S]:c.filter(g=>g.basisFormat.includes(o.ETC1S)).sort((g,p)=>g.priorityETC1S-p.priorityETC1S),[o.UASTC]:c.filter(g=>g.basisFormat.includes(o.UASTC)).sort((g,p)=>g.priorityUASTC-p.priorityUASTC),[o.UASTC_HDR]:c.filter(g=>g.basisFormat.includes(o.UASTC_HDR)).sort((g,p)=>g.priorityHDR-p.priorityHDR)};function d(g,p,m,A){const x=h[g];for(let b=0;b<x.length;b++){const y=x[b];if(y.if&&!n[y.if]||!y.basisFormat.includes(g)||A&&y.transcoderFormat.length<2||y.needsPowerOfTwo&&!(f(p)&&f(m)))continue;const _=y.transcoderFormat[A?1:0],S=y.engineFormat[A?1:0],C=y.engineType[0];return{transcoderFormat:_,engineFormat:S,engineType:C}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}function f(g){return g<=2?!0:(g&g-1)===0&&g!==0}function u(g){if(g.length===1)return g[0];let p=0;for(let x=0;x<g.length;x++){const b=g[x];p+=b.byteLength}const m=new Uint8Array(p);let A=0;for(let x=0;x<g.length;x++){const b=g[x];m.set(b,A),A+=b.byteLength}return m}};const eT=new Set([v.RGBAFormat,v.RGBFormat,v.RGFormat,v.RedFormat]),ju={[jA]:v.RGBAFormat,[QA]:v.RGFormat,[VA]:v.RedFormat,[GA]:v.RGBAFormat,[zA]:v.RGFormat,[NA]:v.RedFormat,[UA]:v.RGBAFormat,[OA]:v.RGBAFormat,[FA]:v.RGFormat,[kA]:v.RGFormat,[RA]:v.RedFormat,[LA]:v.RedFormat,[HA]:v.RGBFormat,[WA]:v.RGBFormat,[o0]:v.RGBA_ETC2_EAC_Format,[r0]:v.RGB_ETC2_Format,[a0]:v.R11_EAC_Format,[l0]:v.SIGNED_R11_EAC_Format,[c0]:v.RG11_EAC_Format,[h0]:v.SIGNED_RG11_EAC_Format,[Ou]:v.RGBA_ASTC_4x4_Format,[u0]:v.RGBA_ASTC_4x4_Format,[d0]:v.RGBA_ASTC_4x4_Format,[b0]:v.RGBA_ASTC_6x6_Format,[p0]:v.RGBA_ASTC_6x6_Format,[f0]:v.RGBA_ASTC_6x6_Format,[KA]:v.RGBA_S3TC_DXT1_Format,[YA]:v.RGBA_S3TC_DXT1_Format,[qA]:v.RGB_S3TC_DXT1_Format,[XA]:v.RGB_S3TC_DXT1_Format,[JA]:v.RGBA_S3TC_DXT5_Format,[$A]:v.RGBA_S3TC_DXT5_Format,[e0]:v.SIGNED_RED_RGTC1_Format,[ZA]:v.RED_RGTC1_Format,[i0]:v.SIGNED_RED_GREEN_RGTC2_Format,[t0]:v.RED_GREEN_RGTC2_Format,[s0]:v.RGBA_BPTC_Format,[n0]:v.RGBA_BPTC_Format,[x0]:v.RGBA_PVRTC_4BPPV1_Format,[m0]:v.RGBA_PVRTC_4BPPV1_Format,[A0]:v.RGBA_PVRTC_2BPPV1_Format,[g0]:v.RGBA_PVRTC_2BPPV1_Format},po={[jA]:v.FloatType,[QA]:v.FloatType,[VA]:v.FloatType,[GA]:v.HalfFloatType,[zA]:v.HalfFloatType,[NA]:v.HalfFloatType,[UA]:v.UnsignedByteType,[OA]:v.UnsignedByteType,[FA]:v.UnsignedByteType,[kA]:v.UnsignedByteType,[RA]:v.UnsignedByteType,[LA]:v.UnsignedByteType,[HA]:v.UnsignedInt5999Type,[WA]:v.UnsignedInt101111Type,[o0]:v.UnsignedByteType,[r0]:v.UnsignedByteType,[a0]:v.UnsignedByteType,[l0]:v.UnsignedByteType,[c0]:v.UnsignedByteType,[h0]:v.UnsignedByteType,[Ou]:v.HalfFloatType,[u0]:v.UnsignedByteType,[d0]:v.UnsignedByteType,[b0]:v.HalfFloatType,[p0]:v.UnsignedByteType,[f0]:v.UnsignedByteType,[KA]:v.UnsignedByteType,[YA]:v.UnsignedByteType,[qA]:v.UnsignedByteType,[XA]:v.UnsignedByteType,[JA]:v.UnsignedByteType,[$A]:v.UnsignedByteType,[e0]:v.UnsignedByteType,[ZA]:v.UnsignedByteType,[i0]:v.UnsignedByteType,[t0]:v.UnsignedByteType,[s0]:v.UnsignedByteType,[n0]:v.UnsignedByteType,[x0]:v.UnsignedByteType,[m0]:v.UnsignedByteType,[A0]:v.UnsignedByteType,[g0]:v.UnsignedByteType};async function tT(n){const{vkFormat:e}=n;if(ju[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+e);po[e]===void 0&&console.warn('THREE.KTX2Loader: Missing ".type" for vkFormat: '+e);let t;n.supercompressionScheme===BA&&(Qu||(Qu=new Promise(async o=>{const a=new $I;await a.init(),o(a)})),t=await Qu);const i=[];for(let o=0;o<n.levels.length;o++){const a=Math.max(1,n.pixelWidth>>o),l=Math.max(1,n.pixelHeight>>o),c=n.pixelDepth?Math.max(1,n.pixelDepth>>o):0,h=n.levels[o];let d;if(n.supercompressionScheme===jI)d=h.levelData;else if(n.supercompressionScheme===BA)d=t.decode(h.levelData,h.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let f;po[e]===v.FloatType?f=new Float32Array(d.buffer,d.byteOffset,d.byteLength/Float32Array.BYTES_PER_ELEMENT):po[e]===v.HalfFloatType?f=new Uint16Array(d.buffer,d.byteOffset,d.byteLength/Uint16Array.BYTES_PER_ELEMENT):po[e]===v.UnsignedInt5999Type||po[e]===v.UnsignedInt101111Type?f=new Uint32Array(d.buffer,d.byteOffset,d.byteLength/Uint32Array.BYTES_PER_ELEMENT):f=d,i.push({data:f,width:a,height:l,depth:c})}const s=n.levelCount===0||i.length>1;let r;if(eT.has(ju[e]))r=n.pixelDepth===0?new v.DataTexture(i[0].data,n.pixelWidth,n.pixelHeight):new v.Data3DTexture(i[0].data,n.pixelWidth,n.pixelHeight,n.pixelDepth),r.minFilter=s?v.NearestMipmapNearestFilter:v.NearestFilter,r.magFilter=v.NearestFilter,r.generateMipmaps=n.levelCount===0;else{if(n.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new v.CompressedTexture(i,n.pixelWidth,n.pixelHeight),r.minFilter=s?v.LinearMipmapLinearFilter:v.LinearFilter,r.magFilter=v.LinearFilter}return r.mipmaps=i,r.type=po[e],r.format=ju[e],r.colorSpace=_0(n),r.needsUpdate=!0,Promise.resolve(r)}function _0(n){const e=n.dataFormatDescriptor[0];return e.colorPrimaries===XI?e.transferFunction===PA?v.SRGBColorSpace:v.LinearSRGBColorSpace:e.colorPrimaries===qI?e.transferFunction===PA?JI:ZI:(e.colorPrimaries===HI||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),v.NoColorSpace)}function iT(n,e,t,i){let s=0,r=0,o=0,a=n.models.find(u=>u.url==t),l=e.circularMeps,c=e.rectMeps?.filter(u=>u.type==="风管"),h=e.rectMeps?.filter(u=>u.type==="桥架"),d=e.ellipseMeps,f=n.scene;if(new w.MeshBasicMaterial,new w.BufferGeometry,l&&l.length){let u=[],g=0;for(let p of l)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new w.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+s,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[n.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),u.push(p);bc("Circle",f,u,t)}if(c&&c.length){let u=[],g=0;for(let p of c)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new w.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+s,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[n.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),u.push(p);bc("Rect",f,u,t)}if(d&&d.length){let u=[],g=0;for(let p of d)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new w.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+s,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[n.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),u.push(p);bc("Ellipse",f,u,t)}if(h&&h.length){let u=[],g=0;for(let p of h)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new w.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+s,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[n.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),u.push(p);bc("Bridge",f,u,t)}}function bc(n,e,t,i,s){let r,o,a={width:1,height:1,length:1,diameter:1,color:new w.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(n){case"Rect":o=yc("Rect",a);break;case"Bridge":o=yc("Bridge",a);break;case"Circle":o=yc("Circle",a);break;case"Ellipse":o=yc("Ellipse",a);break}o&&(r=new w.InstancedMesh(o.geometry,o.material,t.length),r.url=i,e.add(r),r.index=e.children.length-1);let l=[],c=[];for(var h=0;h<t.length;h++){let u=t[h],g=new w.Vector3(u.startPoint.X,0,-u.startPoint.Y),p=new w.Vector3(u.endPoint.X,0,-u.endPoint.Y),m=new w.Vector3(u.startPoint.X,u.startPoint.Z,-u.startPoint.Y),A=new w.Vector3(u.endPoint.X,u.endPoint.Z,-u.endPoint.Y),x=0,b=0,y=0;if(Math.abs(p.clone().sub(g.clone()).z)<.01&&Math.abs(p.clone().sub(g.clone()).x)<.01){if(x=(u.startPoint.Z>u.endPoint.Z?1:-1)*Math.PI*.5,u.base_x!=null){var d=new w.Vector3(u.base_x.X,0,-u.base_x.Y);b=(d.clone().cross(new w.Vector3(0,0,1)).y<=0?1:-1)*d.angleTo(new w.Vector3(0,0,1))+Math.PI*.5}}else b=(p.clone().sub(g.clone()).cross(new w.Vector3(0,0,1)).y>0?-1:1)*p.clone().sub(g.clone()).angleTo(new w.Vector3(0,0,1)),x=(u.startPoint.Z>u.endPoint.Z?1:-1)*p.clone().sub(g.clone()).angleTo(A.clone().sub(m.clone()));let _=new w.Matrix4;const S=new w.Euler(x,b,y,"YXZ");let C=_.clone().makeRotationFromEuler(S),D,M;n==="Circle"?(D=u.diameter,M=u.diameter):(D=u.width,M=u.height);let I=_.clone().makeScale(D,M,u.length);_.multiplyMatrices(C,I),_.setPosition(u.position.x,u.position.y,u.position.z),r.setMatrixAt(h,_.clone()),r.setColorAt(h,u.color),r.geometry.computeBoundingBox();let P=r.geometry.boundingBox.min.clone().applyMatrix4(_.clone()),T=r.geometry.boundingBox.max.clone().applyMatrix4(_.clone()),L=new w.Vector3(Math.min(P.x,T.x),Math.min(P.y,T.y),Math.min(P.z,T.z)),E=new w.Vector3(Math.max(P.x,T.x),Math.max(P.y,T.y),Math.max(P.z,T.z)),F=L.clone().add(E.clone()).multiplyScalar(.5),z={name:u.name,min:L,max:E,center:F,dbid:h,materialName:o.material.name},X=null,j=null;n==="Circle"&&(X={x:u.startPoint.X*.3048,y:u.startPoint.Z*.3048,z:-u.startPoint.Y*.3048},j={x:u.endPoint.X*.3048,y:u.endPoint.Z*.3048,z:-u.endPoint.Y*.3048},z.minC=X,z.maxC=j),r.ids||(r.ids=[]),r.matrixs||(r.matrixs=[]),r.matrixs.push(_.clone()),c.push(_.clone()),r.ids.push(Number(u.id)),l.push(z)}r.castShadow=!0,r.ElementInfos=l,r.name="rootModel",r.TypeName="InstancedMesh-Pipe",r.PipeType=n,r.MeshId=null,r.realMaterial=r.material.clone(),r.originalMaterial=r.material.clone(),r.matrixsClone=c;let f=[];f={geometry:r.geometry,matrix:r.matrix,position:r.position,rotation:r.rotation},r.meshs=f,r.instanceMatrix&&r.instanceMatrix.array&&(r.cloneInstanceMatrix=Array.from(r.instanceMatrix.array))}function yc(n,e,t){let i=new w.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,n){case"Rect":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Bridge":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(-e.width/2+.01,e.height/2),i.lineTo(-e.width/2+.01,-e.height/2+.01),i.lineTo(e.width/2-.01,-e.height/2+.01),i.lineTo(e.width/2-.01,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Circle":i.moveTo(0,0),i.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const s={depth:e.length*.3048,bevelEnabled:!1};return r(i,s,e.color,e.position,e.rotation);function r(o,a,l,c,h){let d=new w.ExtrudeGeometry(o,a),f=new w.MeshStandardMaterial({color:l,side:w.DoubleSide}),u=new w.Mesh(d,f);return u.position.set(c.x,c.y,c.z),u.rotation._order="YXZ",u.rotation.set(h.x,h.y,h.z),u}}function ws(n,e=!1){const t=n[0].index!==null,i=new Set(Object.keys(n[0].attributes)),s=new Set(Object.keys(n[0].morphAttributes)),r={},o={},a=n[0].morphTargetsRelative,l=new v.BufferGeometry;let c=0;for(let h=0;h<n.length;++h){const d=n[h];let f=0;if(t!==(d.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(const u in d.attributes){if(!i.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+u+'" attribute exists among all geometries, or in none of them.'),null;r[u]===void 0&&(r[u]=[]),r[u].push(d.attributes[u]),f++}if(f!==i.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(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const u in d.morphAttributes){if(!s.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[u]===void 0&&(o[u]=[]),o[u].push(d.morphAttributes[u])}if(e){let u;if(t)u=d.index.count;else if(d.attributes.position!==void 0)u=d.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,u,h),c+=u}}if(t){let h=0;const d=[];for(let f=0;f<n.length;++f){const u=n[f].index;for(let g=0;g<u.count;++g)d.push(u.getX(g)+h);h+=n[f].attributes.position.count}l.setIndex(d)}for(const h in r){const d=w0(r[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,d)}for(const h in o){const d=o[h][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let f=0;f<d;++f){const u=[];for(let p=0;p<o[h].length;++p)u.push(o[h][p][f]);const g=w0(u);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 w0(n){let e,t,i,s=-1,r=0;for(let c=0;c<n.length;++c){const h=n[c];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=h.normalized),i!==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*t}const o=new e(r),a=new v.BufferAttribute(o,t,i);let l=0;for(let c=0;c<n.length;++c){const h=n[c];if(h.isInterleavedBufferAttribute){const d=l/t;for(let f=0,u=h.count;f<u;f++)for(let g=0;g<t;g++){const p=h.getComponent(f,g);a.setComponent(f+d,g,p)}}else o.set(h.array,l);l+=h.count*t}return s!==void 0&&(a.gpuType=s),a}function S0(n,e){if(e===v.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===v.TriangleFanDrawMode||e===v.TriangleStripDrawMode){let t=n.getIndex();if(t===null){const o=[],a=n.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);n.setIndex(o),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const i=t.count-2,s=[];if(e===v.TriangleFanDrawMode)for(let o=1;o<=i;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<i;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=n.clone();return r.setIndex(s),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}function nT(n){const e=new Map,t=new Map,i=n.clone();return C0(n,i,function(s,r){e.set(r,s),t.set(s,r)}),i.traverse(function(s){if(!s.isSkinnedMesh)return;const r=s,o=e.get(s),a=o.skeleton.bones;r.skeleton=o.skeleton.clone(),r.bindMatrix.copy(o.bindMatrix),r.skeleton.bones=a.map(function(l){return t.get(l)}),r.bind(r.skeleton,r.bindMatrix)}),i}function C0(n,e,t){t(n,e);for(let i=0;i<n.children.length;i++)C0(n.children[i],e.children[i],t)}class sT extends v.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new cT(t)}),this.register(function(t){return new hT(t)}),this.register(function(t){return new bT(t)}),this.register(function(t){return new yT(t)}),this.register(function(t){return new vT(t)}),this.register(function(t){return new uT(t)}),this.register(function(t){return new fT(t)}),this.register(function(t){return new pT(t)}),this.register(function(t){return new gT(t)}),this.register(function(t){return new lT(t)}),this.register(function(t){return new mT(t)}),this.register(function(t){return new dT(t)}),this.register(function(t){return new xT(t)}),this.register(function(t){return new AT(t)}),this.register(function(t){return new oT(t)}),this.register(function(t){return new M0(t,tt.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new M0(t,tt.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new _T(t)})}load(e,t,i,s){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=v.LoaderUtils.extractUrlBase(e);o=v.LoaderUtils.resolveURL(c,this.path)}else o=v.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){s?s(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new v.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},i,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,s){let r;const o={},a={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===E0){try{o[tt.KHR_BINARY_GLTF]=new wT(e)}catch(d){s&&s(d);return}r=JSON.parse(o[tt.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new FT(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,o[d.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const d=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(d){case tt.KHR_MATERIALS_UNLIT:o[d]=new aT;break;case tt.KHR_DRACO_MESH_COMPRESSION:o[d]=new ST(r,this.dracoLoader);break;case tt.KHR_TEXTURE_TRANSFORM:o[d]=new CT;break;case tt.KHR_MESH_QUANTIZATION:o[d]=new MT;break;default:f.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(i,s)}parseAsync(e,t){const i=this;return new Promise(function(s,r){i.parse(e,t,s,r)})}}function rT(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}function Rt(n,e,t){const i=n.json.materials[e];return i.extensions&&i.extensions[t]?i.extensions[t]:null}const tt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class oT{constructor(e){this.parser=e,this.name=tt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,s=t.length;i<s;i++){const r=t[i];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let s=t.cache.get(i);if(s)return s;const r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const h=new v.Color(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],v.LinearSRGBColorSpace);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new v.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new v.PointLight(h),c.distance=d;break;case"spot":c=new v.SpotLight(h),c.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),yn(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),s=Promise.resolve(c),t.cache.add(i,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,r=i.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return i._getNodeRef(t.cache,a,l)})}}class aT{constructor(){this.name=tt.KHR_MATERIALS_UNLIT}getMaterialType(){return v.MeshBasicMaterial}extendParams(e,t,i){const s=[];e.color=new v.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],v.LinearSRGBColorSpace),e.opacity=o[3]}r.baseColorTexture!==void 0&&s.push(i.assignTexture(e,"map",r.baseColorTexture,v.SRGBColorSpace))}return Promise.all(s)}}class lT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);return i===null||i.emissiveStrength!==void 0&&(t.emissiveIntensity=i.emissiveStrength),Promise.resolve()}}class cT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(s.push(this.parser.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const r=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new v.Vector2(r,r)}return Promise.all(s)}}class hT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);return i===null||(t.dispersion=i.dispersion!==void 0?i.dispersion:0),Promise.resolve()}}class dT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(s)}}class uT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_SHEEN}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];if(t.sheenColor=new v.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,i.sheenColorFactor!==void 0){const r=i.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],v.LinearSRGBColorSpace)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenColorMap",i.sheenColorTexture,v.SRGBColorSpace)),i.sheenRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}}class fT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&s.push(this.parser.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(s)}}class pT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_VOLUME}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const r=i.attenuationColor||[1,1,1];return t.attenuationColor=new v.Color().setRGB(r[0],r[1],r[2],v.LinearSRGBColorSpace),Promise.all(s)}}class gT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_IOR}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);return i===null||(t.ior=i.ior!==void 0?i.ior:1.5),Promise.resolve()}}class mT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularIntensityMap",i.specularTexture));const r=i.specularColorFactor||[1,1,1];return t.specularColor=new v.Color().setRGB(r[0],r[1],r[2],v.LinearSRGBColorSpace),i.specularColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularColorMap",i.specularColorTexture,v.SRGBColorSpace)),Promise.all(s)}}class AT{constructor(e){this.parser=e,this.name=tt.EXT_MATERIALS_BUMP}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&s.push(this.parser.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(s)}}class xT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Rt(this.parser,e,this.name)!==null?v.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=Rt(this.parser,e,this.name);if(i===null)return Promise.resolve();const s=[];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&s.push(this.parser.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(s)}}class bT{constructor(e){this.parser=e,this.name=tt.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,s=i.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const r=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}}class yT{constructor(e){this.parser=e,this.name=tt.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=s.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return i.loadTextureImage(e,o.source,l)}}class vT{constructor(e){this.parser=e,this.name=tt.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=s.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return i.loadTextureImage(e,o.source,l)}}class M0{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const s=i.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const l=s.byteOffset||0,c=s.byteLength||0,h=s.count,d=s.byteStride,f=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,d,f,s.mode,s.filter).then(function(u){return u.buffer}):o.ready.then(function(){const u=new ArrayBuffer(h*d);return o.decodeGltfBuffer(new Uint8Array(u),h,d,f,s.mode,s.filter),u})})}else return null}}class _T{constructor(e){this.name=tt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const s=t.meshes[i.mesh];for(const c of s.primitives)if(c.mode!==zi.TRIANGLES&&c.mode!==zi.TRIANGLE_STRIP&&c.mode!==zi.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=i.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),d=h.isGroup?h.children:[h],f=c[0].count,u=[];for(const g of d){const p=new v.Matrix4,m=new v.Vector3,A=new v.Quaternion,x=new v.Vector3(1,1,1),b=new v.InstancedMesh(g.geometry,g.material,f);for(let y=0;y<f;y++)l.TRANSLATION&&m.fromBufferAttribute(l.TRANSLATION,y),l.ROTATION&&A.fromBufferAttribute(l.ROTATION,y),l.SCALE&&x.fromBufferAttribute(l.SCALE,y),b.setMatrixAt(y,p.compose(m,A,x));for(const y in l)if(y==="_COLOR_0"){const _=l[y];b.instanceColor=new v.InstancedBufferAttribute(_.array,_.itemSize,_.normalized)}else y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&g.geometry.setAttribute(y,l[y]);v.Object3D.prototype.copy.call(b,g),this.parser.assignFinalMaterial(b),u.push(b)}return h.isGroup?(h.clear(),h.add(...u),h):u[0]}))}}const E0="glTF",ua=12,I0={JSON:1313821514,BIN:5130562};class wT{constructor(e){this.name=tt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ua),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==E0)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-ua,r=new DataView(e,ua);let o=0;for(;o<s;){const a=r.getUint32(o,!0);o+=4;const l=r.getUint32(o,!0);if(o+=4,l===I0.JSON){const c=new Uint8Array(e,ua+o,a);this.content=i.decode(c)}else if(l===I0.BIN){const c=ua+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class ST{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=tt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(const h in o){const d=Hu[h]||h.toLowerCase();a[d]=o[h]}for(const h in e.attributes){const d=Hu[h]||h.toLowerCase();if(o[h]!==void 0){const f=i.accessors[e.attributes[h]],u=go[f.componentType];c[d]=u.name,l[d]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(d,f){s.decodeDracoFile(h,function(u){for(const g in u.attributes){const p=u.attributes[g],m=l[g];m!==void 0&&(p.normalized=m)}d(u)},a,c,v.LinearSRGBColorSpace,f)})})}}class CT{constructor(){this.name=tt.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class MT{constructor(){this.name=tt.KHR_MESH_QUANTIZATION}}class T0 extends v.Interpolant{constructor(e,t,i,s){super(e,t,i,s)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let o=0;o!==s;o++)t[o]=i[r+o];return t}interpolate_(e,t,i,s){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,h=s-t,d=(i-t)/h,f=d*d,u=f*d,g=e*c,p=g-c,m=-2*u+3*f,A=u-f,x=1-m,b=A-f+d;for(let y=0;y!==a;y++){const _=o[p+y+a],S=o[p+y+l]*h,C=o[g+y+a],D=o[g+y]*h;r[y]=x*_+b*S+m*C+A*D}return r}}const ET=new v.Quaternion;class IT extends T0{interpolate_(e,t,i,s){const r=super.interpolate_(e,t,i,s);return ET.fromArray(r).normalize().toArray(r),r}}const zi={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},go={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},D0={9728:v.NearestFilter,9729:v.LinearFilter,9984:v.NearestMipmapNearestFilter,9985:v.LinearMipmapNearestFilter,9986:v.NearestMipmapLinearFilter,9987:v.LinearMipmapLinearFilter},B0={33071:v.ClampToEdgeWrapping,33648:v.MirroredRepeatWrapping,10497:v.RepeatWrapping},Wu={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Hu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ss={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},TT={CUBICSPLINE:void 0,LINEAR:v.InterpolateLinear,STEP:v.InterpolateDiscrete},Xu={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function DT(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new v.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:v.FrontSide})),n.DefaultMaterial}function hr(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function yn(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function BT(n,e,t){let i=!1,s=!1,r=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(i=!0),d.NORMAL!==void 0&&(s=!0),d.COLOR_0!==void 0&&(r=!0),i&&s&&r)break}if(!i&&!s&&!r)return Promise.resolve(n);const o=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(i){const f=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):n.attributes.position;o.push(f)}if(s){const f=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):n.attributes.normal;a.push(f)}if(r){const f=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):n.attributes.color;l.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],f=c[2];return i&&(n.morphAttributes.position=h),s&&(n.morphAttributes.normal=d),r&&(n.morphAttributes.color=f),n.morphTargetsRelative=!0,n})}function PT(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,s=t.length;i<s;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function LT(n){let e;const t=n.extensions&&n.extensions[tt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+qu(t.attributes):e=n.indices+":"+qu(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,s=n.targets.length;i<s;i++)e+=":"+qu(n.targets[i]);return e}function qu(n){let e="";const t=Object.keys(n).sort();for(let i=0,s=t.length;i<s;i++)e+=t[i]+":"+n[t[i]]+";";return e}function Yu(n){switch(n){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function RT(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const kT=new v.Matrix4;class FT{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new rT,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,s=-1,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);s=i&&l?parseInt(l[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&s<17||r&&o<98?this.textureLoader=new v.TextureLoader(this.options.manager):this.textureLoader=new v.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new v.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const a={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:i,userData:{}};return hr(r,a,s),yn(a,s),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){const o=t[s].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let s=0,r=e.length;s<r;s++){const o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(i[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const s=i.clone(),r=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,h]of o.children.entries())r(h,a.children[c])};return r(i,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const s=e(t[i]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let s=0;s<t.length;s++){const r=e(t[s]);r&&i.push(r)}return i}getDependency(e,t){const i=e+":"+t;let s=this.cache.get(i);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(i,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(r,o){return i.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[tt.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,o){i.load(v.LoaderUtils.resolveURL(t.uri,s.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){const s=t.byteLength||0,r=t.byteOffset||0;return i.slice(r,r+s)})}loadAccessor(e){const t=this,i=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const o=Wu[s.type],a=go[s.componentType],l=s.normalized===!0,c=new a(s.count*o);return Promise.resolve(new v.BufferAttribute(c,o,l))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],l=Wu[s.type],c=go[s.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,f=s.byteOffset||0,u=s.bufferView!==void 0?i.bufferViews[s.bufferView].byteStride:void 0,g=s.normalized===!0;let p,m;if(u&&u!==d){const A=Math.floor(f/u),x="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+A+":"+s.count;let b=t.cache.get(x);b||(p=new c(a,A*u,s.count*u/h),b=new v.InterleavedBuffer(p,u/h),t.cache.add(x,b)),m=new v.InterleavedBufferAttribute(b,l,f%u/h,g)}else a===null?p=new c(s.count*l):p=new c(a,f,s.count*l),m=new v.BufferAttribute(p,l,g);if(s.sparse!==void 0){const A=Wu.SCALAR,x=go[s.sparse.indices.componentType],b=s.sparse.indices.byteOffset||0,y=s.sparse.values.byteOffset||0,_=new x(o[1],b,s.sparse.count*A),S=new c(o[2],y,s.sparse.count*l);a!==null&&(m=new v.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let C=0,D=_.length;C<D;C++){const M=_[C];if(m.setX(M,S[C*l]),l>=2&&m.setY(M,S[C*l+1]),l>=3&&m.setZ(M,S[C*l+2]),l>=4&&m.setW(M,S[C*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){const t=this.json,i=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const l=i.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,i){const s=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const f=(r.samplers||{})[o.sampler]||{};return h.magFilter=D0[f.magFilter]||v.LinearFilter,h.minFilter=D0[f.minFilter]||v.LinearMipmapLinearFilter,h.wrapS=B0[f.wrapS]||v.RepeatWrapping,h.wrapT=B0[f.wrapT]||v.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==v.NearestFilter&&h.minFilter!==v.LinearFilter,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=s.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=i.getDependency("bufferView",o.bufferView).then(function(d){c=!0;const f=new Blob([d],{type:o.mimeType});return l=a.createObjectURL(f),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(d){return new Promise(function(f,u){let g=f;t.isImageBitmapLoader===!0&&(g=function(p){const m=new v.Texture(p);m.needsUpdate=!0,f(m)}),t.load(v.LoaderUtils.resolveURL(d,r.path),g,void 0,u)})}).then(function(d){return c===!0&&a.revokeObjectURL(l),yn(d,o),d.userData.mimeType=o.mimeType||RT(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,i,s){const r=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),r.extensions[tt.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[tt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(o);o=r.extensions[tt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new v.PointsMaterial,v.Material.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(a,l)),i=l}else if(e.isLine){const a="LineBasicMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new v.LineBasicMaterial,v.Material.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(a,l)),i=l}if(s||r||o){let a="ClonedMaterial:"+i.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=i.clone(),r&&(l.vertexColors=!0),o&&(l.flatShading=!0),s&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return v.MeshStandardMaterial}loadMaterial(e){const t=this,i=this.json,s=this.extensions,r=i.materials[e];let o;const a={},l=r.extensions||{},c=[];if(l[tt.KHR_MATERIALS_UNLIT]){const d=s[tt.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(a,r,t))}else{const d=r.pbrMetallicRoughness||{};if(a.color=new v.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const f=d.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],v.LinearSRGBColorSpace),a.opacity=f[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,v.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=v.DoubleSide);const h=r.alphaMode||Xu.OPAQUE;if(h===Xu.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Xu.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==v.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new v.Vector2(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;a.normalScale.set(d,d)}if(r.occlusionTexture!==void 0&&o!==v.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==v.MeshBasicMaterial){const d=r.emissiveFactor;a.emissive=new v.Color().setRGB(d[0],d[1],d[2],v.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==v.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,v.SRGBColorSpace)),Promise.all(c).then(function(){const d=new o(a);return r.name&&(d.name=r.name),yn(d,r),t.associations.set(d,{materials:e}),r.extensions&&hr(s,d,r),d})}createUniqueName(e){const t=v.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,s=this.primitiveCache;function r(a){return i[tt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return P0(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=LT(c),d=s[h];if(d)o.push(d.promise);else{let f;c.extensions&&c.extensions[tt.KHR_DRACO_MESH_COMPRESSION]?f=r(c):f=P0(new v.BufferGeometry,c,t),s[h]={primitive:c,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){const t=this,i=this.json,s=this.extensions,r=i.meshes[e],o=r.primitives,a=[];for(let l=0,c=o.length;l<c;l++){const h=o[l].material===void 0?DT(this.cache):this.getDependency("material",o[l].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let u=0,g=h.length;u<g;u++){const p=h[u],m=o[u];let A;const x=c[u];if(m.mode===zi.TRIANGLES||m.mode===zi.TRIANGLE_STRIP||m.mode===zi.TRIANGLE_FAN||m.mode===void 0)A=r.isSkinnedMesh===!0?new v.SkinnedMesh(p,x):new v.Mesh(p,x),A.isSkinnedMesh===!0&&A.normalizeSkinWeights(),m.mode===zi.TRIANGLE_STRIP?A.geometry=S0(A.geometry,v.TriangleStripDrawMode):m.mode===zi.TRIANGLE_FAN&&(A.geometry=S0(A.geometry,v.TriangleFanDrawMode));else if(m.mode===zi.LINES)A=new v.LineSegments(p,x);else if(m.mode===zi.LINE_STRIP)A=new v.Line(p,x);else if(m.mode===zi.LINE_LOOP)A=new v.LineLoop(p,x);else if(m.mode===zi.POINTS)A=new v.Points(p,x);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(A.geometry.morphAttributes).length>0&&PT(A,r),A.name=t.createUniqueName(r.name||"mesh_"+e),yn(A,r),m.extensions&&hr(s,A,m),t.assignFinalMaterial(A),d.push(A)}for(let u=0,g=d.length;u<g;u++)t.associations.set(d[u],{meshes:e,primitives:u});if(d.length===1)return r.extensions&&hr(s,d[0],r),d[0];const f=new v.Group;r.extensions&&hr(s,f,r),t.associations.set(f,{meshes:e});for(let u=0,g=d.length;u<g;u++)f.add(d[u]);return f})}loadCamera(e){let t;const i=this.json.cameras[e],s=i[i.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new v.PerspectiveCamera(v.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):i.type==="orthographic"&&(t=new v.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),yn(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let s=0,r=t.joints.length;s<r;s++)i.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(s){const r=s.pop(),o=s,a=[],l=[];for(let c=0,h=o.length;c<h;c++){const d=o[c];if(d){a.push(d);const f=new v.Matrix4;r!==null&&f.fromArray(r.array,c*16),l.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new v.Skeleton(a,l)})}loadAnimation(e){const t=this.json,i=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,o=[],a=[],l=[],c=[],h=[];for(let d=0,f=s.channels.length;d<f;d++){const u=s.channels[d],g=s.samplers[u.sampler],p=u.target,m=p.node,A=s.parameters!==void 0?s.parameters[g.input]:g.input,x=s.parameters!==void 0?s.parameters[g.output]:g.output;p.node!==void 0&&(o.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",A)),l.push(this.getDependency("accessor",x)),c.push(g),h.push(p))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){const f=d[0],u=d[1],g=d[2],p=d[3],m=d[4],A=[];for(let b=0,y=f.length;b<y;b++){const _=f[b],S=u[b],C=g[b],D=p[b],M=m[b];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const I=i._createAnimationTracks(_,S,C,D,M);if(I)for(let P=0;P<I.length;P++)A.push(I[P])}const x=new v.AnimationClip(r,void 0,A);return yn(x,s),x})}createNodeMesh(e){const t=this.json,i=this,s=t.nodes[e];return s.mesh===void 0?null:i.getDependency("mesh",s.mesh).then(function(r){const o=i._getNodeRef(i.meshCache,s.mesh,r);return s.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,c=s.weights.length;l<c;l++)a.morphTargetInfluences[l]=s.weights[l]}),o})}loadNode(e){const t=this.json,i=this,s=t.nodes[e],r=i._loadNodeShallow(e),o=[],a=s.children||[];for(let c=0,h=a.length;c<h;c++)o.push(i.getDependency("node",a[c]));const l=s.skin===void 0?Promise.resolve(null):i.getDependency("skin",s.skin);return Promise.all([r,Promise.all(o),l]).then(function(c){const h=c[0],d=c[1],f=c[2];f!==null&&h.traverse(function(u){u.isSkinnedMesh&&u.bind(f,kT)});for(let u=0,g=d.length;u<g;u++)h.add(d[u]);if(h.userData.pivot!==void 0&&d.length>0){const u=h.userData.pivot,g=d[0];h.pivot=new v.Vector3().fromArray(u),h.position.x-=u[0],h.position.y-=u[1],h.position.z-=u[2],g.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){const t=this.json,i=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?s.createUniqueName(r.name):"",a=[],l=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(c){return s._getNodeRef(s.cameraCache,r.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(r.isBone===!0?h=new v.Bone:c.length>1?h=new v.Group:c.length===1?h=c[0]:h=new v.Object3D,h!==c[0])for(let d=0,f=c.length;d<f;d++)h.add(c[d]);if(r.name&&(h.userData.name=r.name,h.name=o),yn(h,r),r.extensions&&hr(i,h,r),r.matrix!==void 0){const d=new v.Matrix4;d.fromArray(r.matrix),h.applyMatrix4(d)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);if(!s.associations.has(h))s.associations.set(h,{});else if(r.mesh!==void 0&&s.meshCache.refs[r.mesh]>1){const d=s.associations.get(h);s.associations.set(h,{...d})}return s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],s=this,r=new v.Group;i.name&&(r.name=s.createUniqueName(i.name)),yn(r,i),i.extensions&&hr(t,r,i);const o=i.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(s.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let h=0,d=l.length;h<d;h++){const f=l[h];f.parent!==null?r.add(nT(f)):r.add(f)}const c=h=>{const d=new Map;for(const[f,u]of s.associations)(f instanceof v.Material||f instanceof v.Texture)&&d.set(f,u);return h.traverse(f=>{const u=s.associations.get(f);u!=null&&d.set(f,u)}),d};return s.associations=c(r),r})}_createAnimationTracks(e,t,i,s,r){const o=[],a=e.name?e.name:e.uuid,l=[];Ss[r.path]===Ss.weights?e.traverse(function(f){f.morphTargetInfluences&&l.push(f.name?f.name:f.uuid)}):l.push(a);let c;switch(Ss[r.path]){case Ss.weights:c=v.NumberKeyframeTrack;break;case Ss.rotation:c=v.QuaternionKeyframeTrack;break;case Ss.translation:case Ss.scale:c=v.VectorKeyframeTrack;break;default:switch(i.itemSize){case 1:c=v.NumberKeyframeTrack;break;case 2:case 3:default:c=v.VectorKeyframeTrack;break}break}const h=s.interpolation!==void 0?TT[s.interpolation]:v.InterpolateLinear,d=this._getArrayFromAccessor(i);for(let f=0,u=l.length;f<u;f++){const g=new c(l[f]+"."+Ss[r.path],t.array,d,h);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=Yu(t.constructor),s=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)s[r]=t[r]*i;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const s=this instanceof v.QuaternionKeyframeTrack?IT:T0;return new s(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function OT(n,e,t){const i=e.attributes,s=new v.Box3;if(i.POSITION!==void 0){const a=t.json.accessors[i.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(s.set(new v.Vector3(l[0],l[1],l[2]),new v.Vector3(c[0],c[1],c[2])),a.normalized){const h=Yu(go[a.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new v.Vector3,l=new v.Vector3;for(let c=0,h=r.length;c<h;c++){const d=r[c];if(d.POSITION!==void 0){const f=t.json.accessors[d.POSITION],u=f.min,g=f.max;if(u!==void 0&&g!==void 0){if(l.setX(Math.max(Math.abs(u[0]),Math.abs(g[0]))),l.setY(Math.max(Math.abs(u[1]),Math.abs(g[1]))),l.setZ(Math.max(Math.abs(u[2]),Math.abs(g[2]))),f.normalized){const p=Yu(go[f.componentType]);l.multiplyScalar(p)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}n.boundingBox=s;const o=new v.Sphere;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,n.boundingSphere=o}function P0(n,e,t){const i=e.attributes,s=[];function r(o,a){return t.getDependency("accessor",o).then(function(l){n.setAttribute(a,l)})}for(const o in i){const a=Hu[o]||o.toLowerCase();a in n.attributes||s.push(r(i[o],a))}if(e.indices!==void 0&&!n.index){const o=t.getDependency("accessor",e.indices).then(function(a){n.setIndex(a)});s.push(o)}return v.ColorManagement.workingColorSpace!==v.LinearSRGBColorSpace&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${v.ColorManagement.workingColorSpace}" not supported.`),yn(n,e),OT(n,e,t),Promise.all(s).then(function(){return e.targets!==void 0?BT(n,e.targets,t):n})}var Mt=(n=>(n.ModelLoadStart="model-load-start",n.ModelLoadProgress="model-load-progress",n.ModelLoaded="model-loaded",n.ModelError="model-error",n.SelectionChanged="selection-changed",n.HoverChanged="hover-changed",n.Click="click",n.MouseMove="mouse-move",n.CameraChanged="camera-changed",n.CameraIdle="camera-idle",n.EngineFree="engine-free",n.EngineBusy="engine-busy",n.MeasureChanged="measure-changed",n.MeasureClick="measure-click",n.SectionMove="section-move",n.LoadingCompleted="loading_completed",n))(Mt||{});let fa=null,pa=null,L0=null;const UT=8,R0=24,NT=24,zT=64,GT=200,VT=10;function k0(){return new URL("draco/",document.baseURI).toString()}function F0(){return new URL("basis/",document.baseURI).toString()}function QT(){return fa==null&&(fa=new zI,fa.setDecoderPath(k0()),fa.preload()),fa}function jT(n){return pa==null&&(pa=new Ni,pa.setTranscoderPath(F0())),L0!==n&&(pa.detectSupport(n),L0=n),pa}function WT(n){const e=new sT;return e.setDRACOLoader(QT()),e.setMeshoptDecoder(VI),n?.renderer?.capabilities!=null&&typeof n.renderer.getContext=="function"&&e.setKTX2Loader(jT(n.renderer)),e}function O0(){return new Promise(n=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>n());return}setTimeout(n,16)})}function HT(){const n=navigator?.scheduling;return typeof n?.isInputPending=="function"?n.isInputPending():!1}function XT(n){return n?.engineStatus?.isFree===!1||HT()}async function Yn(n,e,t){if(e)return t;const i=performance.now();return XT(n)||i-t>=UT?(await O0(),performance.now()):t}function qT(n,e){return new Promise((t,i)=>{ha(n,s=>{if(s==null){i(new Error(`[loadLightModel] empty zip json: ${n}`));return}t(s)},()=>{i(new Error(`[loadLightModel] failed to load zip json: ${n}`))},e)})}function YT(n,e){return Ct({method:"get",responseType:"arraybuffer",url:n}).then(async t=>{let i=t.data;return fo.isEncrypted(t.data)&&(i=await fo.decryptPzEnc(t.data,e)),Wm.loadAsync(i)})}function U0(n){return n.replace(/\\/g,"/").replace(/^\/+/,"")}function N0(n,e){const t=new Set(e.map(i=>U0(i)));for(const i of Object.keys(n.files))if(t.has(U0(i)))return n.files[i];return null}function z0(n,e){const t=N0(n,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function KT(n){return n.charCodeAt(0)===65279?n.slice(1):n}function Ku(n){return JSON.parse(KT(n))}function $T(n,e){const t=N0(n,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function JT(n,e){return new Promise((t,i)=>{WT(n).parse(e,document.baseURI,t,i)})}function vc(n,e){return n.models.find(t=>t.url==e)}function G0(n){n.loadStatus==null&&(n.loadStatus={}),n.loadStatus.modelMep==null&&(n.loadStatus.modelMep=!1),n.loadStatus.normal==null&&(n.loadStatus.normal=!1)}function ZT(n){return G0(n),n.status==="loaded"&&n.loadStatus.normal===!0&&n.loadStatus.modelMep===!0}function V0(n){const e=n?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(i=>ZT(i))||n.__loadingCompletedTriggered===!0||(n.__loadingCompletedTriggered=!0,n.events?.trigger?.(Mt.LoadingCompleted,{}))}function Q0(n){return n===!0||n==="loading"}function j0(n){return n.index!=null?n.index.count:n.attributes.position?.count??0}async function e2(n,e,t){let i=performance.now();for(let s=0;s<e.length;s++){const r=e[s];r?.geometry!=null&&r.geometry.computeVertexNormals,(s+1)%NT===0&&(i=await Yn(n,t,i))}}async function t2(n,e,t){const i=[],s=[{node:e.octreeBox,visited:!1}];let r=performance.now();for(;s.length>0;){const o=s.pop();if(o==null||o.node==null||o.node.status===!0)continue;const a=o.node;if(o.visited){const c=Array.isArray(a.children)?a.children:[];(c.length===0||c.findIndex(h=>h.status!=!0)===-1)&&(a.status=!0),r=await Yn(n,t,r);continue}s.push({node:a,visited:!0}),Array.isArray(a.elements)&&i.push(...a.elements);const l=Array.isArray(a.children)?a.children:[];for(let c=l.length-1;c>=0;c--)s.push({node:l[c],visited:!1});r=await Yn(n,t,r)}return i}async function i2(n,e,t,i){const s=vc(n,e.url);if(s?.nodesMap==null)return[];const r=await t2(n,t,i);console.log("[loadLightModel] pending mesh ids",t.path,r.length);const o=[];let a=performance.now(),l=0;for(const c of r){if(!s.nodesMap.has(c))continue;const h=s.nodesMap.get(c),d=Array.isArray(h?.infos)?h.infos:[];for(const f of d){const u=t.glbs?.[f.glb]?.[f.mesh];if(u?.geometry==null||u.material==null)continue;const g=new w.Matrix4;g.elements=f.matrix;const p=u.geometry.clone();p.applyMatrix4(g),p.computeBoundingBox();const m=new w.Mesh(p,u.material);f.box=p.boundingBox?.clone(),f.mesh=m,m.name=Number(c),m.glb=f.glb,m.url=e.url,p.attributes.position!=null&&o.push(m),l++,l%R0===0&&(a=await Yn(n,i,a))}}return o}function n2(n,e,t,i,s){const r=ws(i.map(a=>a.geometry),!1),o=new w.Mesh(r,s);return o.castShadow=!0,o.receiveShadow=!0,e.scene.add(o),o.index=e.scene.children.length-1,o.url=n,o.glb=t,o.materialClone=s,o.geometrys=i.map(a=>a.geometry),o.geometry.computeVertexNormals(),o}function s2(n,e,t,i){return n.scene.children.find(s=>{const r=s;return s instanceof w.Mesh&&r.url==e&&r.glb==t&&r.materialClone===i})}function r2(n,e){const t=Array.isArray(n.geometrys)?n.geometrys:[],i=e.map(o=>o.geometry),s=[...t,...i],r=ws(s,!1);n.geometry!=null&&n.geometry.dispose(),n.geometry=r,n.geometrys=s,n.castShadow=!0,n.receiveShadow=!0}async function o2(n,e,t,i){const s=new Map;for(const a of t){const l=s.get(a.glb)??[];l.push(a),s.set(a.glb,l)}const r=vc(e,n);let o=performance.now();for(const[a,l]of s.entries()){const c=i?l.length:GT;for(let h=0;h<l.length;h+=c){const d=l.slice(h,h+c);if(d.length===0)continue;const f=m2(d[0].material,e);let u=s2(e,n,a,f),g=0,p=0;u=null,u!=null?(g=Array.isArray(u.geometrys)?u.geometrys.length:0,p=j0(u.geometry),r2(u,d)):u=n2(n,e,a,d,f);const m=new Map;let A=p;d.forEach((x,b)=>{const y=Number(x.name),_=j0(x.geometry),S=m.get(y)??[];if(S.push([A,A+_]),m.set(y,S),r?.nodesMap?.has(y)){const C=r.nodesMap.get(y);C.indexes==null&&(C.indexes=[]),C.indexes.push([u.index,g+b,A,A+_])}A+=_}),u.indexes==null&&(u.indexes=new Map),m.forEach((x,b)=>{const y=u.indexes.get(b)??[];y.push(...x),u.indexes.set(b,y)}),o=await Yn(e,i,o)}}}async function a2(n,e,t,i,s,r){if(i==null||s==null||s.length===0)return;const o=vc(t,n);if(o==null)return;const a=new w.InstancedMesh(i.geometry,i.material,s.length);t.scene.add(a);const l=new Float32Array(s.length*3);for(let d=0;d<s.length;d++)l[d*3]=1,l[d*3+1]=1,l[d*3+2]=1;a.instanceColor=new w.InstancedBufferAttribute(l,3);let c=performance.now();const h=[];for(let d=0;d<s.length;d++){const f=s[d],u=new w.Matrix4;if(u.elements=f.matrix,a.setMatrixAt(d,u),a.matrixs||(a.matrixs=[]),a.matrixs.push(u.clone()),h.push(u.clone()),o.nodesMap.has(f.id)){const g=o.nodesMap.get(f.id);g.indexes==null&&(g.indexes=[]),g.indexes.push([t.scene.children.length-1,d,0,0])}else o.nodesMap.set(f.id,{instance:!0,info:f,indexes:[[t.scene.children.length-1,d,0,0]]});(d+1)%zT===0&&(c=await Yn(t,r,c))}a.instanceMatrix.needsUpdate=!0,a.instanceColor!=null&&(a.instanceColor.needsUpdate=!0),a.index=t.scene.children.length-1,a.materialClone=i.material,a.url=n,a.glb=i.glb,a.ids=s.map(d=>d.id),a.matrixsClone=h,a.meshIndex=e}async function l2(n,e,t,i){const s=e.instanceNodes;if(s==null)return;let r=performance.now();for(const o in s)if(s[o].isLoaded!==!0){s[o].isLoaded=!0;for(const a of s[o]){const l=e.glbs?.[o]?.[a.mesh];l!=null&&await a2(n.url,a.mesh,t,l,a.children,i)}r=await Yn(t,i,r)}}async function c2(n,e,t,i){if(t.status===!0||t.meshPromise!=null){await t.meshPromise;return}t.meshPromise=(async()=>{console.log(`[loadLightModel] start build lod meshes ${Date.now()-window.startTime}ms`);const s=await i2(n,e,t,i);await o2(e.url,n,s,i),await l2(e,t,n,i),t.status=!0,console.log(`[loadLightModel] *****************************************************finish build lod meshes ${Date.now()-window.startTime}ms`)})().finally(()=>{t.meshPromise=null}),await t.meshPromise}async function h2(n,e,t,i){if(t.loadSuccess!==!0){if(t.preparePromise!=null){await t.preparePromise;return}t.preparePromise=(async()=>{console.log("[loadLightModel] loading GLB bundle",t.path),t.glbs=t.glbs??{};const s=await YT(e.url+t.path,e.key),r=await z0(s,["/nodes.json","nodes.json"]);if(r==null)return;const o=Ku(r),a=vc(n,e.url);if(a==null)return;a.nodesMap==null&&(a.nodesMap=new Map);let l=performance.now();for(const h of Object.keys(o)){const d=o[h];for(let u=0;u<d.length;u++){const g=d[u];if(g.glb=h,a.nodesMap.has(g.id)===!1)a.nodesMap.set(g.id,{infos:[g]});else{if(!a.nodesMap.get(g.id).infos)continue;a.nodesMap.get(g.id).infos.push(g)}(u+1)%R0===0&&(l=await Yn(n,i,l))}const f=await $T(s,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(f==null){console.error("[loadLightModel] glb not found in zip",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,availableFiles:Object.keys(s.files)});continue}try{const u=await JT(n,f);t.glbs[h]=u.scene.children,t.glbs[h].forEach(g=>{g.matrixWorld}),await e2(n,t.glbs[h],i)}catch(u){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:k0(),basisTranscoderPath:F0(),error:u})}l=await Yn(n,i,l)}const c=await z0(s,["/instances.json","instances.json"]);t.instanceNodes=c!=null?Ku(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function d2(n,e,t){if(t.boundingBox||(t.boundingBox=new w.Box3,t.boundingBox.min=new w.Vector3(t.octreeBox.min.X,t.octreeBox.min.Z,-t.octreeBox.min.Y),t.boundingBox.max=new w.Vector3(t.octreeBox.max.X,t.octreeBox.max.Z,-t.octreeBox.max.Y)),!t.maxSize)return 1e3;const i=t.boundingBox,s=i.min,r=i.max,o=s.clone().add(r.clone()).multiplyScalar(.5),a=s.distanceTo(r),l=new w.Vector3,c=new w.Vector3,h=new w.Vector3,d=new w.Vector3;if(e.getWorldDirection(h),e.getWorldPosition(d),e.matrixWorld.extractBasis(l,c,new w.Vector3),e instanceof w.OrthographicCamera){const A=Math.max((e.top-e.bottom)/e.zoom,1e-6),x=n?.cameraModule?.perspectiveCamera?.getEffectiveFOV?.()??20,b=w.MathUtils.degToRad(x*.5),y=b>0?A/(2*Math.tan(b)):A;d.copy(o).add(h.clone().multiplyScalar(-y))}if(d.distanceTo(o)<=a*.5)return 1e3;const f=o.clone().sub(d).dot(h);if(f<=0)return 0;const u=d.clone().add(h.multiplyScalar(Math.max(f,a))),g=u.clone().add(l.setLength(t.maxSize)),p=new lt(e,n.renderer,n.scene).worldToScreen(u),m=new lt(e,n.renderer,n.scene).worldToScreen(g);return p.distanceTo(m)}async function u2(n,e,t,i){t.maxSize<1e6&&t.path!="/lod0"&&(!(d2(n,n.camera,t)>=VT)||t.status===!0)||(await h2(n,e,t,i),t.loadSuccess===!0&&await c2(n,e,t,i))}function f2(n,e,t){if(Q0(e.loadStatus.modelMep))return;e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await O0(),iT(n,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,V0(n)})().catch(s=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",s)})}function p2(n,e,t,i){const s=new w.Group;s.name=e,n.scene.add(s),n.models||(n.models=[]),window.startTime=Date.now();let r="WDDsBNtzVz6aSh/bCFh3CmjjANEDRryoXF1XCJvJjeE=";qT(e+"/info",r).then(o=>{const a=Ku(o);n.__loadingCompletedTriggered=!1,n.engineStatus.models.push({type:"light",info:a,name:a.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1},key:r}),n.models.push({url:e,nodesMap:new Map,grids:a.modelGrid,levels:a.modelLevel,rooms:a.modelRoom,views:a.modelView,name:a.baseInfo.name,boundingBox:{min:new w.Vector3(a.baseInfo.min.X*.3048,a.baseInfo.min.Z*.3048,-a.baseInfo.min.Y*.3048),max:new w.Vector3(a.baseInfo.max.X*.3048,a.baseInfo.max.Z*.3048,-a.baseInfo.max.Y*.3048)}}),n.models.length==i&&(n.viewCube.CameraGoHome(1),setTimeout(()=>{W0(n,null,!1)},100))}).catch(o=>{console.error("[loadLightModel] failed to load model info",{url:e,error:o})})}async function W0(n,e,t=!1){const i=n.engineStatus.models.filter(s=>e==null||s.url==e);for(const s of i)if(G0(s),!(s.status!=="loading"||s.type!=="light")&&(f2(n,s,t),!Q0(s.loadStatus.normal))){s.loadStatus.normal="loading";try{await g2(n,s,t)}finally{const r=Array.isArray(s.info?.lods)&&s.info.lods.every(o=>o.status===!0);s.loadStatus.normal=r,r&&(s.status="loaded"),V0(n)}}}async function g2(n,e,t=!1){if(console.log(`[loadLightModel] start loadNode ${Date.now()-window.startTime}ms`),!(e.info==null||e.info.lods==null))for(const i of e.info.lods)await u2(n,e,i,t)}function m2(n,e){return n.map!=null&&(n.map.colorSpace=w.SRGBColorSpace,n.map.needsUpdate=!0),n.clipShadows=!0,e?.sectionPlane&&(n.clippingPlanes=e.sectionPlane),n}class A2{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const s of e)i(s)==="light"&&p2(this.engine,s,t,e.length);function i(s){const r=s.split(".").pop();return r==="glb"||r==="gltf"?"gltf":"light"}}}var dr=(n=>(n.ModelLoadStart="model-load-start",n.ModelLoadProgress="model-load-progress",n.ModelLoaded="model-loaded",n.ModelError="model-error",n.SelectionChanged="selection-changed",n.HoverChanged="hover-changed",n.Click="click",n.MouseMove="mouse-move",n.CameraChanged="camera-changed",n.CameraIdle="camera-idle",n.ViewportResize="viewport-resize",n.EngineFree="engine-free",n.EngineBusy="engine-busy",n.MeasureChanged="measure-changed",n.SectionMove="section-move",n.LoadingCompleted="loading_completed",n))(dr||{});class x2{engine;isFree;isForceFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.isForceFree=!1,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(dr.EngineFree,e=>{this.updateFree(!0),W0(this.engine,e,!1),this.engine?.octreeBox?.requestBvhBuild?.()}),this.engine.events.on(dr.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let b2=class{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const i=String(e);this.listeners.has(i)||this.listeners.set(i,[]),this.listeners.get(i).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${i}, 当前监听器数量: ${this.listeners.get(i).length}`)}off(e,t){const i=String(e);if(!this.listeners.has(i)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${i}`);return}const s=this.listeners.get(i),r=s.indexOf(t);r!==-1?(s.splice(r,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${i}, 剩余监听器数量: ${s.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${i}`)}trigger(e,t){const i=String(e);if(!this.listeners.has(i)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${i}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const s=this.listeners.get(i);this.debugMode&&console.debug(`[EventModule] 触发事件: ${i}, 监听器数量: ${s.length}`,t),s.forEach((r,o)=>{try{r(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${i}] #${o}:`,a)}})}};const _c=1;class y2{engine;constructor(e){this.engine=e}init(){const e=new w.DirectionalLight(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2,e.shadow.intensity=_c;const i=new w.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(i),this.engine.scene.dirLight=i;const s=new w.AmbientLight(16777215,2);this.engine.scene.add(s)}}class v2{engine;behavior;isCtrlDown=!1;isShiftDown=!1;hoverOldId=null;timeOutEvent;selectionBox=null;isBoxSelecting=!1;selectionStart=new w.Vector2;selectionEnd=new w.Vector2;suppressClickOnce=!1;selectionThreshold=5;tempInstanceMatrix=new w.Matrix4;tempScale=new w.Vector3;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.ensureSelectionBox(),this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.cancelBoxSelection(),this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1,this.isBoxSelecting&&this.cancelBoxSelection()}handelKeyCtrlDown(){this.isCtrlDown=!0}handelKeyShiftUp(){this.isShiftDown=!1}handelKeyShiftDown(){this.isShiftDown=!0}handleMouseDown(e){e.button!==0||!this.isBoxSelectionModifierDown()||(this.isBoxSelecting=!0,this.selectionStart.set(e.offsetX,e.offsetY),this.selectionEnd.copy(this.selectionStart),this.suppressClickOnce=!1,this.clearHoverFeedback(),this.updateSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!1))}handelKeyEscDown(){this.engine.modelToolModule.unhighlightAllModels()}handleMouseMove(e){if(this.clearHoverTimeout(),this.isBoxSelecting){this.selectionEnd.set(e.offsetX,e.offsetY),this.clearHoverFeedback(),this.updateSelectionBox();return}if(e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;const i=this.getCatchMeshs(e,!0);i!=null&&i.length>0&&this.engine.hoverHighLight.showModelNameTag({url:i[0].url,ids:[i[0].name]},e.catch.point)},1e3)),!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}const t=this.getCatchMeshs(e);if(t!=null&&t.length>0){this.engine.hoverHighLight.hightMesh(t);return}e.catch==null&&this.engine.hoverHighLight.clearHighlight()}handleMouseUp(e){if(!this.isBoxSelecting)return;this.selectionEnd.set(e.offsetX,e.offsetY);const t=this.hasSelectionBox(),i=t?this.collectModelsInSelection():[];this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0),t&&(this.isBoxDeselectMode()?this.applyBoxDeselection(i):this.applyBoxSelection(i),this.suppressClickOnce=!0)}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){const c=e.catch.object,h=e.catch.object.id,f=this.engine.models.find(p=>p.url==c.url)?.nodesMap?.get(h),u=new Map;f?.indexes.forEach(p=>{this.getSceneModel(p[0])instanceof w.InstancedMesh&&(u.has(p[0])||u.set(p[0],[]),u.get(p[0])?.push(p[1]))});const g=[];return u.forEach((p,m)=>{const A=this.getSceneModel(m);p.forEach(x=>{const b=A.geometry.clone();b.applyMatrix4(A.matrixs[x]),g.push(new w.Mesh(b,A.material))})}),this.hoverOldId==h?[]:(this.hoverOldId=h,t||this.engine.hoverHighLight.clearHighlight(),g)}const s=e.catch.object,r=s.name,l=this.engine.models.find(c=>c.url===s.url)?.nodesMap?.get(r)?.infos?.map(c=>c.mesh)??[];return this.hoverOldId==r?[]:(this.hoverOldId=r,t||this.engine.hoverHighLight.clearHighlight(),l)}handleMouseClick(e){if(this.suppressClickOnce){this.suppressClickOnce=!1;return}if(this.isShiftDown){if(e.catch!=null){const s=e.catch.object;this.applyBoxDeselection([{url:s.url,ids:[s.name]}])}return}if(e.catch!=null){const i=e.catch,s=i.object;if(!this.isCtrlDown){this.engine.modelToolModule.unhighlightAllModels();const o=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(o)}this.engine.controlModule.orbitControls.origin.set(i.point.x,i.point.y,i.point.z),this.engine.modelToolModule.highlightModel([{url:s.url,ids:[s.name]}]),this.engine.events.trigger(Mt.Click,[{url:s.url,ids:[s.name]}]);const r=new CustomEvent("D3ElementClick",{detail:{id:s.name}});window.dispatchEvent(r);return}const t=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(t),this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(!e.catch){this.engine.viewCube.CameraGoHome(500);return}const t=e.catch,i=t.object,r=this.engine.models.find(l=>l.url===i.url)?.nodesMap?.get(i.name);if(!r)return;if(t.object.isInstance){const l=t.matrix,c=[];r.indexes.forEach(d=>{const f=this.getSceneModel(d[0]);f?.geometry?.boundingSphere||f?.geometry?.computeBoundingSphere?.();const u=f?.geometry?.boundingSphere;if(!u)return;const g=new w.Box3,p=u.center.clone().applyMatrix4(l),m=u.radius,A=new w.Vector3().setFromMatrixScale(l),x=m*Math.max(A.x,A.y,A.z);g.min.set(p.x-x,p.y-x,p.z-x),g.max.set(p.x+x,p.y+x,p.z+x),c.push(g)});const h=this.getMergedBox(c);h!=null&&this.engine.viewCube.zoomToModel(h);return}const o=r.infos.map(l=>l.box).filter(l=>l instanceof w.Box3),a=this.getMergedBox(o);a!=null&&this.engine.viewCube.zoomToModel(a)}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(t=>t instanceof w.InstancedMesh),!0)}ensureSelectionBox(){if(this.selectionBox!=null)return;const e=document.createElement("div");e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.display="none",e.style.pointerEvents="none",e.style.border="1px dashed #00aaff",e.style.backgroundColor="rgba(0, 170, 255, 0.12)",e.style.boxSizing="border-box",e.style.zIndex="1001",this.engine.container?.appendChild(e),this.selectionBox=e}updateSelectionBox(){if(this.selectionBox==null)return;if(!this.hasSelectionBox()){this.selectionBox.style.display="none";return}const e=this.getSelectionRect();this.selectionBox.style.display="block",this.selectionBox.style.left=`${e.left}px`,this.selectionBox.style.top=`${e.top}px`,this.selectionBox.style.width=`${e.right-e.left}px`,this.selectionBox.style.height=`${e.bottom-e.top}px`}hideSelectionBox(){this.selectionBox!=null&&(this.selectionBox.style.display="none")}cancelBoxSelection(){this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0)}clearHoverTimeout(){this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null)}clearHoverFeedback(){this.hoverOldId=null,this.engine.hoverHighLight.clearHighlight(),this.engine.hoverHighLight.showModelNameTag(null,null)}hasSelectionBox(){return Math.abs(this.selectionEnd.x-this.selectionStart.x)>=this.selectionThreshold&&Math.abs(this.selectionEnd.y-this.selectionStart.y)>=this.selectionThreshold}getSelectionRect(){return{left:Math.min(this.selectionStart.x,this.selectionEnd.x),top:Math.min(this.selectionStart.y,this.selectionEnd.y),right:Math.max(this.selectionStart.x,this.selectionEnd.x),bottom:Math.max(this.selectionStart.y,this.selectionEnd.y)}}isContainMode(){return this.selectionEnd.x>=this.selectionStart.x&&this.selectionEnd.y>=this.selectionStart.y}isBoxSelectionModifierDown(){return this.isCtrlDown}isBoxDeselectMode(){return this.isShiftDown}collectModelsInSelection(){const e=this.getSelectionRect(),t=this.isContainMode(),i=new Map;return this.engine.models?.forEach(s=>{!s?.url||!s?.nodesMap||s.nodesMap.forEach((r,o)=>{const a=this.getNodeWorldBox(r),l=this.projectBoxToScreenRect(a);l==null||!(t?this.containsRect(e,l):this.intersectsRect(e,l))||(i.has(s.url)||i.set(s.url,new Set),i.get(s.url)?.add(o))})}),Array.from(i.entries()).map(([s,r])=>({url:s,ids:Array.from(r)}))}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(Mt.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(Mt.SelectionChanged,t))}excludeHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(s=>t.get(i.url)?.add(s))}),e.map(i=>({url:i.url,ids:i.ids.filter(s=>!t.get(i.url)?.has(s))})).filter(i=>i.ids.length>0)}keepHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(s=>t.get(i.url)?.add(s))}),e.map(i=>({url:i.url,ids:i.ids.filter(s=>t.get(i.url)?.has(s))})).filter(i=>i.ids.length>0)}removeModelsFromHighlightState(e){const t=new Map;e.forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(s=>t.get(i.url)?.add(s))}),this.engine.engineStatus.highlightModels=(this.engine.engineStatus.highlightModels??[]).map(i=>({url:i.url,ids:i.ids.filter(s=>!t.get(i.url)?.has(s))})).filter(i=>i.ids.length>0)}getNodeWorldBox(e){if(Array.isArray(e?.infos)&&e.infos.length>0){const t=e.infos.map(i=>i?.box).filter(i=>i instanceof w.Box3);return this.getMergedBox(t)}if(Array.isArray(e?.indexes)&&e.indexes.length>0){const t=[];return e.indexes.forEach(i=>{const s=this.getSceneModel(i[0]),r=this.getInstanceWorldBox(s,i[1]);r!=null&&t.push(r)}),this.getMergedBox(t)}return null}getInstanceWorldBox(e,t){if(!(e instanceof w.InstancedMesh))return null;e.geometry.boundingBox||e.geometry.computeBoundingBox();const i=e.geometry.boundingBox;if(!i)return null;if(typeof e.getMatrixAt=="function")e.getMatrixAt(t,this.tempInstanceMatrix);else if(e.matrixs?.[t])this.tempInstanceMatrix.copy(e.matrixs[t]);else return null;return this.tempScale.setFromMatrixScale(this.tempInstanceMatrix),Math.abs(this.tempScale.x)+Math.abs(this.tempScale.y)+Math.abs(this.tempScale.z)<1e-6?null:i.clone().applyMatrix4(this.tempInstanceMatrix)}projectBoxToScreenRect(e){if(e==null||e.isEmpty())return null;const t=[new w.Vector3(e.min.x,e.min.y,e.min.z),new w.Vector3(e.min.x,e.min.y,e.max.z),new w.Vector3(e.min.x,e.max.y,e.min.z),new w.Vector3(e.min.x,e.max.y,e.max.z),new w.Vector3(e.max.x,e.min.y,e.min.z),new w.Vector3(e.max.x,e.min.y,e.max.z),new w.Vector3(e.max.x,e.max.y,e.min.z),new w.Vector3(e.max.x,e.max.y,e.max.z)];let i=1/0,s=1/0,r=-1/0,o=-1/0;return t.forEach(a=>{const l=new lt(this.engine.camera,this.engine.renderer,this.engine.scene).worldToScreen(a);!Number.isFinite(l.x)||!Number.isFinite(l.y)||(i=Math.min(i,l.x),s=Math.min(s,l.y),r=Math.max(r,l.x),o=Math.max(o,l.y))}),!Number.isFinite(i)||!Number.isFinite(s)||!Number.isFinite(r)||!Number.isFinite(o)?null:{left:i,top:s,right:r,bottom:o}}containsRect(e,t){return t.left>=e.left&&t.top>=e.top&&t.right<=e.right&&t.bottom<=e.bottom}intersectsRect(e,t){return!(t.right<e.left||t.left>e.right||t.bottom<e.top||t.top>e.bottom)}getMergedBox(e){if(e.length===0)return null;const t=new w.Box3().makeEmpty();return e.forEach(i=>t.union(i)),t.isEmpty()?null:t}getSceneModel(e){return this.engine.scene.children.find(t=>t.index===e)??this.engine.scene.children[e]}}class _2{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new w.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.8,side:w.DoubleSide}),this.hideMaterial=new w.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:w.DoubleSide}),this.translucentMaterial=new w.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:w.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof w.InstancedMesh)return;let t=e.materialClone.clone(),i=ws(e.geometrys,!0);i.computeVertexNormals(),i.groups.forEach(s=>{s.materialIndex=0}),e.geometry=i,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}getSceneModel(e){return this.engine.scene.children.find(t=>t.index==e)}highlightModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{this.getSceneModel(a[0])instanceof w.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),this.getSceneModel(a[0]).geometry.groups[a[1]].materialIndex=1)})}),w2(i,this.engine);let s=this.engine.engineStatus.highlightModels.find(r=>r.url==t.url);s!=null?s.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{this.getSceneModel(o[0])instanceof w.InstancedMesh?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):this.getSceneModel(o[0]).geometry.groups[o[1]].materialIndex=0})}),H0(i,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.hideModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof w.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),i.size>0&&C2(i,this.engine);let s=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);s!=null?s.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.showModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof w.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),i.size>0&&X0(i,this.engine);let s=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);s&&(t.ids.forEach(r=>{const o=s.ids.indexOf(r);o!==-1&&s.ids.splice(o,1)}),s.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(r=>r!==s)))})}isolateModel(e){let t=[];this.engine.models.forEach(i=>{let s={url:i.url,ids:[]},r=e.find(o=>o.url==i.url);for(let o of i.nodesMap)r==null?s.ids.push(o[0]):r.ids.includes(o[0])||s.ids.push(o[0]);t.push(s)});debugger;this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(i=>{let s={url:i.url,ids:[]},r=e.find(o=>o.url==i.url);for(let o of i.nodesMap)r==null?s.ids.push(o[0]):r.ids.includes(o[0])||s.ids.push(o[0]);t.push(s)}),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let i=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof w.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=2)})}),S2(i,this.engine);let s=this.engine.engineStatus.translucentModels.find(r=>r.url==t.url);s!=null?s.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let i=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{const a=this.getSceneModel(o[0]);a instanceof w.InstancedMesh?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),a.geometry.groups[o[1]].materialIndex=0)})}),i.size>0&&X0(i,this.engine),H0(i,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(i.levelName,i.typeName,s=>{this.engine.modelToolModule.highlightModel(s)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(i.levelName,s=>{this.engine.modelToolModule.highlightModel(s)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(i.typeName,s=>{this.engine.modelToolModule.highlightModel(s)})}}function w2(n,e){n.forEach((t,i)=>{const s=ga(e,i);if(!(s instanceof w.InstancedMesh))return;const r=s.geometry,o=new w.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:w.DoubleSide}),a=new w.InstancedMesh(r,o,t.length);a.name="highlightModel",a.key=i;const l=new Map,c=new w.Matrix4,h=new w.Matrix4;h.makeScale(0,0,0),t.forEach((d,f)=>{s.getMatrixAt(d,c),l.set(d,c.clone()),s.setMatrixAt(d,h),a.setMatrixAt(f,c)}),s.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function H0(n,e,t){n.forEach((i,s)=>{const r=ga(e,s);if(!(r instanceof w.InstancedMesh))return;i.forEach(a=>{const l=r.matrixsClone[a];l&&r.setMatrixAt(a,l)}),r.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==s&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function S2(n,e){n.forEach((t,i)=>{const s=ga(e,i);if(!(s instanceof w.InstancedMesh))return;const r=s.geometry,o=new w.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:w.DoubleSide}),a=new w.InstancedMesh(r,o,t.length);a.name="translucentModel",a.key=i;const l=new Map,c=new w.Matrix4,h=new w.Matrix4;h.makeScale(0,0,0),t.forEach((d,f)=>{s.getMatrixAt(d,c),l.set(d,c.clone()),s.setMatrixAt(d,h),a.setMatrixAt(f,c)}),s.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function C2(n,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),n.forEach((t,i)=>{const s=ga(e,i);if(!(s instanceof w.InstancedMesh))return;const r=new Map,o=new w.Matrix4,a=new w.Matrix4;a.makeScale(0,0,0),t.forEach((l,c)=>{s.getMatrixAt(l,o),r.set(l,o.clone()),s.setMatrixAt(l,a)}),s.instanceMatrix.needsUpdate=!0})}function X0(n,e){n.forEach((t,i)=>{const s=ga(e,i);s instanceof w.InstancedMesh&&(t.forEach(r=>{const o=s.matrixs[r];o&&s.setMatrixAt(r,o)}),s.instanceMatrix.needsUpdate=!0)})}function ga(n,e){return n.scene.children.find(t=>t.index==e)}const q0="advanced";class M2{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch(q0)}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!0);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!0);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(i=>i instanceof w.DirectionalLight);t&&(t.castShadow=e),this.engine.scene?.traverse(i=>{i.material&&(i.castShadow!==void 0&&(i.castShadow=e),i.receiveShadow!==void 0&&(i.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&this.gtaoPass&&(this.gtaoPass.enabled=e)}setSSAO(e){this.engine.composerModule?.composer&&this.ssaoPass&&(this.ssaoPass.enabled=e)}setSaturation(e){this.saturationPass&&(this.saturationPass.enabled=e)}setOutputPass(e){this.outputPass&&(this.outputPass.enabled=e)}setFXAA(e){this.fxaaPass&&(this.fxaaPass.enabled=e)}setPerformanceMode(){this.setMode("simple")}setBalancedMode(){this.setMode("balance")}setQualityMode(){this.setMode("advanced")}setSuperQualityMode(){this.setMode("superAdvanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(r=>r instanceof w.DirectionalLight),s={low:1024,medium:2048,high:2048}[e];t?.shadow&&s&&(t.shadow.mapSize.width=s,t.shadow.mapSize.height=s,t.shadow.map?.dispose(),t.shadow.map=null)}setSaturationValue(e){this.saturationPass&&(this.saturationPass.uniforms.saturation.value=e)}setContrastValue(e){this.saturationPass&&(this.saturationPass.uniforms.contrast.value=e)}setGTAOIntensity(e){this.gtaoPass&&(this.gtaoPass.blendIntensity=e)}}class wc{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;tagDiv;constructor(e){this.engine=e,this.init();const t=document.createElement("div");this.tagDiv=t,t.className="tagDiv",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.borderRadius="10px",t.style.pointerEvents="none",this.engine.container.appendChild(this.tagDiv)}showModelNameTag(e,t){if(e==null){this.tagDiv.style.display="none";return}let i=this.engine.models.find(a=>a.url==e.url);if(i==null){this.tagDiv.style.display="none";return}let s=i.nodesMap.get(e.ids[0]);if(s.infos&&s.infos.length>0){let a=s.infos[0].name.replace(/\s*\[[a-f0-9-]+\]$/,"");this.tagDiv.innerHTML=a}const o=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=o.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=o.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new w.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:w.AdditiveBlending,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}hightMesh(e,t=16777215,i=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const s=(Array.isArray(e)?e:e?[e]:[]).filter(r=>r?.geometry);if(s.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=i;for(const r of s){let o=r.geometry.clone();o.computeVertexNormals();const a=new w.Mesh(o,this.overlayMaterial);r.updateWorldMatrix(!0,!1),a.matrix.copy(r.matrixWorld),a.matrixAutoUpdate=!1,this.engine.scene.add(a),this.overlayMeshes.push(a)}this.animState="fadeIn",this.animStartTime=performance.now()}clearHighlight(){this.overlayMeshes.length===0||this.animState==="fadeOut"||(this.animState="fadeOut",this.animStartTime=performance.now())}update(){if(this.animState==="idle"||this.overlayMeshes.length===0)return;const e=performance.now()-this.animStartTime,t=this.overlayMaterial.userData.targetOpacity??.35;if(this.animState==="fadeIn"){const i=Math.min(e/wc.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(i)*t,i>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const i=Math.min(e/wc.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(i))*t,i>=1&&(this.removeOverlayMeshes(),this.animState="idle")}}removeOverlayMeshes(){for(const e of this.overlayMeshes)this.engine.scene.remove(e);this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.animState="idle"}}var Sc={exports:{}},E2=Sc.exports,Y0;function I2(){return Y0||(Y0=1,(function(n,e){(function(t,i){n.exports=i()})(E2,function(){var t=function(){function i(u){return o.appendChild(u.dom),u}function s(u){for(var g=0;g<o.children.length;g++)o.children[g].style.display=g===u?"block":"none";r=u}var r=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(u){u.preventDefault(),s(++r%o.children.length)},!1);var a=(performance||Date).now(),l=a,c=0,h=i(new t.Panel("FPS","#0ff","#002")),d=i(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var f=i(new t.Panel("MB","#f08","#201"));return s(0),{REVISION:16,dom:o,addPanel:i,showPanel:s,begin:function(){a=(performance||Date).now()},end:function(){c++;var u=(performance||Date).now();if(d.update(u-a,200),u>l+1e3&&(h.update(1e3*c/(u-l),100),l=u,c=0,f)){var g=performance.memory;f.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return u},update:function(){a=this.end()},domElement:o,setMode:s}};return t.Panel=function(i,s,r){var o=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,d=48*c,f=3*c,u=2*c,g=3*c,p=15*c,m=74*c,A=30*c,x=document.createElement("canvas");x.width=h,x.height=d,x.style.cssText="width:80px;height:48px";var b=x.getContext("2d");return b.font="bold "+9*c+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=r,b.fillRect(0,0,h,d),b.fillStyle=s,b.fillText(i,f,u),b.fillRect(g,p,m,A),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g,p,m,A),{dom:x,update:function(y,_){o=Math.min(o,y),a=Math.max(a,y),b.fillStyle=r,b.globalAlpha=1,b.fillRect(0,0,h,p),b.fillStyle=s,b.fillText(l(y)+" "+i+" ("+l(o)+"-"+l(a)+")",f,u),b.drawImage(x,g+c,p,m-c,A,g,p,m-c,A),b.fillRect(g+m-c,p,c,A),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g+m-c,p,c,l((1-y/_)*A))}}},t})})(Sc)),Sc.exports}var T2=I2();const D2=Qm(T2);var mo=Object.freeze({Linear:Object.freeze({None:function(n){return n},In:function(n){return n},Out:function(n){return n},InOut:function(n){return n}}),Quadratic:Object.freeze({In:function(n){return n*n},Out:function(n){return n*(2-n)},InOut:function(n){return(n*=2)<1?.5*n*n:-.5*(--n*(n-2)-1)}}),Cubic:Object.freeze({In:function(n){return n*n*n},Out:function(n){return--n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n:.5*((n-=2)*n*n+2)}}),Quartic:Object.freeze({In:function(n){return n*n*n*n},Out:function(n){return 1- --n*n*n*n},InOut:function(n){return(n*=2)<1?.5*n*n*n*n:-.5*((n-=2)*n*n*n-2)}}),Quintic:Object.freeze({In:function(n){return n*n*n*n*n},Out:function(n){return--n*n*n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n*n*n:.5*((n-=2)*n*n*n*n+2)}}),Sinusoidal:Object.freeze({In:function(n){return 1-Math.sin((1-n)*Math.PI/2)},Out:function(n){return Math.sin(n*Math.PI/2)},InOut:function(n){return .5*(1-Math.sin(Math.PI*(.5-n)))}}),Exponential:Object.freeze({In:function(n){return n===0?0:Math.pow(1024,n-1)},Out:function(n){return n===1?1:1-Math.pow(2,-10*n)},InOut:function(n){return n===0?0:n===1?1:(n*=2)<1?.5*Math.pow(1024,n-1):.5*(-Math.pow(2,-10*(n-1))+2)}}),Circular:Object.freeze({In:function(n){return 1-Math.sqrt(1-n*n)},Out:function(n){return Math.sqrt(1- --n*n)},InOut:function(n){return(n*=2)<1?-.5*(Math.sqrt(1-n*n)-1):.5*(Math.sqrt(1-(n-=2)*n)+1)}}),Elastic:Object.freeze({In:function(n){return n===0?0:n===1?1:-Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI)},Out:function(n){return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n-.1)*5*Math.PI)+1},InOut:function(n){return n===0?0:n===1?1:(n*=2,n<1?-.5*Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI):.5*Math.pow(2,-10*(n-1))*Math.sin((n-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(n){var e=1.70158;return n===1?1:n*n*((e+1)*n-e)},Out:function(n){var e=1.70158;return n===0?0:--n*n*((e+1)*n+e)+1},InOut:function(n){var e=2.5949095;return(n*=2)<1?.5*(n*n*((e+1)*n-e)):.5*((n-=2)*n*((e+1)*n+e)+2)}}),Bounce:Object.freeze({In:function(n){return 1-mo.Bounce.Out(1-n)},Out:function(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375},InOut:function(n){return n<.5?mo.Bounce.In(n*2)*.5:mo.Bounce.Out(n*2-1)*.5+.5}}),generatePow:function(n){return n===void 0&&(n=4),n=n<Number.EPSILON?Number.EPSILON:n,n=n>1e4?1e4:n,{In:function(e){return Math.pow(e,n)},Out:function(e){return 1-Math.pow(1-e,n)},InOut:function(e){return e<.5?Math.pow(e*2,n)/2:(1-Math.pow(2-e*2,n))/2+.5}}}}),ma=function(){return performance.now()},B2=(function(){function n(){this._tweens={},this._tweensAddedDuringUpdate={}}return n.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},n.prototype.removeAll=function(){this._tweens={}},n.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},n.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},n.prototype.update=function(e,t){e===void 0&&(e=ma()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s<i.length;s++){var r=this._tweens[i[s]],o=!t;r&&r.update(e,o)===!1&&!t&&delete this._tweens[i[s]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},n})(),$u={Linear:function(n,e){var t=n.length-1,i=t*e,s=Math.floor(i),r=$u.Utils.Linear;return e<0?r(n[0],n[1],i):e>1?r(n[t],n[t-1],t-i):r(n[s],n[s+1>t?t:s+1],i-s)},Utils:{Linear:function(n,e,t){return(e-n)*t+n}}},K0=(function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n})(),Ju=new B2,P2=(function(){function n(e,t){t===void 0&&(t=Ju),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=mo.Linear.None,this._interpolationFunction=$u.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=K0.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return n.prototype.getId=function(){return this._id},n.prototype.isPlaying=function(){return this._isPlaying},n.prototype.isPaused=function(){return this._isPaused},n.prototype.getDuration=function(){return this._duration},n.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},n.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},n.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},n.prototype.start=function(e,t){if(e===void 0&&(e=ma()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var r in this._valuesEnd)s[r]=this._valuesEnd[r];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},n.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},n.prototype._setupProperties=function(e,t,i,s,r){for(var o in i){var a=e[o],l=Array.isArray(a),c=l?"array":typeof a,h=!l&&Array.isArray(i[o]);if(!(c==="undefined"||c==="function")){if(h){var d=i[o];if(d.length===0)continue;for(var f=[a],u=0,g=d.length;u<g;u+=1){var p=this._handleRelativeValue(a,d[u]);if(isNaN(p)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}f.push(p)}h&&(i[o]=f)}if((c==="object"||l)&&a&&!h){t[o]=l?[]:{};var m=a;for(var A in m)t[o][A]=m[A];s[o]=l?[]:{};var d=i[o];if(!this._isDynamic){var x={};for(var A in d)x[A]=d[A];i[o]=d=x}this._setupProperties(m,t[o],d,s[o],r)}else(typeof t[o]>"u"||r)&&(t[o]=a),l||(t[o]*=1),h?s[o]=i[o].slice().reverse():s[o]=t[o]||0}}},n.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},n.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},n.prototype.pause=function(e){return e===void 0&&(e=ma()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},n.prototype.resume=function(e){return e===void 0&&(e=ma()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},n.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},n.prototype.group=function(e){return e===void 0&&(e=Ju),this._group=e,this},n.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},n.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},n.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},n.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},n.prototype.easing=function(e){return e===void 0&&(e=mo.Linear.None),this._easingFunction=e,this},n.prototype.interpolation=function(e){return e===void 0&&(e=$u.Linear),this._interpolationFunction=e,this},n.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},n.prototype.onStart=function(e){return this._onStartCallback=e,this},n.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},n.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},n.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},n.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},n.prototype.onStop=function(e){return this._onStopCallback=e,this},n.prototype.update=function(e,t){var i=this,s;if(e===void 0&&(e=ma()),t===void 0&&(t=!0),this._isPaused)return!0;var r,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>o)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,l=this._duration+((s=this._repeatDelayTime)!==null&&s!==void 0?s:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(i._duration===0||a>c)return 1;var m=Math.trunc(a/l),A=a-m*l,x=Math.min(A/i._duration,1);return x===0&&a===i._duration?1:x},d=h(),f=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,f),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||a>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=u);for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,p=this._chainedTweens.length;g<p;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},n.prototype._updateProperties=function(e,t,i,s){for(var r in i)if(t[r]!==void 0){var o=t[r]||0,a=i[r],l=Array.isArray(e[r]),c=Array.isArray(a),h=!l&&c;h?e[r]=this._interpolationFunction(a,s):typeof a=="object"&&a?this._updateProperties(e[r],o,a,s):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(e[r]=o+(a-o)*s))}},n.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},n.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],i=this._valuesEnd[e];typeof i=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(i):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},n})();K0.nextId;var vn=Ju;vn.getAll.bind(vn),vn.removeAll.bind(vn),vn.add.bind(vn),vn.remove.bind(vn),vn.update.bind(vn);var Aa={Easing:mo,Tween:P2};const $0={type:"change"},Zu={type:"start"},J0={type:"end"},Cc=new v.Ray,Z0=new v.Plane,L2=Math.cos(70*v.MathUtils.DEG2RAD),Qt=new v.Vector3,yi=2*Math.PI,pt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},ef=1e-6;class R2 extends v.Controls{constructor(e,t=null){super(e,t),this.state=pt.NONE,this.target=new v.Vector3,this.cursor=new v.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:v.MOUSE.ROTATE,MIDDLE:v.MOUSE.DOLLY,RIGHT:v.MOUSE.PAN},this.touches={ONE:v.TOUCH.ROTATE,TWO:v.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new v.Vector3,this._lastQuaternion=new v.Quaternion,this._lastTargetPosition=new v.Vector3,this._quat=new v.Quaternion().setFromUnitVectors(e.up,new v.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new v.Spherical,this._sphericalDelta=new v.Spherical,this._scale=1,this._panOffset=new v.Vector3,this._rotateStart=new v.Vector2,this._rotateEnd=new v.Vector2,this._rotateDelta=new v.Vector2,this._panStart=new v.Vector2,this._panEnd=new v.Vector2,this._panDelta=new v.Vector2,this._dollyStart=new v.Vector2,this._dollyEnd=new v.Vector2,this._dollyDelta=new v.Vector2,this._dollyDirection=new v.Vector3,this._mouse=new v.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=F2.bind(this),this._onPointerDown=k2.bind(this),this._onPointerUp=O2.bind(this),this._onContextMenu=j2.bind(this),this._onMouseWheel=z2.bind(this),this._onKeyDown=G2.bind(this),this._onTouchStart=V2.bind(this),this._onTouchMove=Q2.bind(this),this._onMouseDown=U2.bind(this),this._onMouseMove=N2.bind(this),this._interceptControlDown=W2.bind(this),this._interceptControlUp=H2.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent($0),this.update(),this.state=pt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;Qt.copy(t).sub(this.target),Qt.applyQuaternion(this._quat),this._spherical.setFromVector3(Qt),this.autoRotate&&this.state===pt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=yi:i>Math.PI&&(i-=yi),s<-Math.PI?s+=yi:s>Math.PI&&(s-=yi),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Qt.setFromSpherical(this._spherical),Qt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Qt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Qt.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new v.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new v.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Qt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Cc.origin.copy(this.object.position),Cc.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Cc.direction))<L2?this.object.lookAt(this.target):(Z0.setFromNormalAndCoplanarPoint(this.object.up,this.target),Cc.intersectPlane(Z0,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>ef||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ef||this._lastTargetPosition.distanceToSquared(this.target)>ef?(this.dispatchEvent($0),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?yi/60*this.autoRotateSpeed*e:yi/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Qt.setFromMatrixColumn(t,0),Qt.multiplyScalar(-e),this._panOffset.add(Qt)}_panUp(e,t){this.screenSpacePanning===!0?Qt.setFromMatrixColumn(t,1):(Qt.setFromMatrixColumn(t,0),Qt.crossVectors(this.object.up,Qt)),Qt.multiplyScalar(e),this._panOffset.add(Qt)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Qt.copy(s).sub(this.target);let r=Qt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,o=i.width,a=i.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(yi*this._rotateDelta.x/t.clientHeight),this._rotateUp(yi*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(yi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-yi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(yi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-yi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(yi*this._rotateDelta.x/t.clientHeight),this._rotateUp(yi*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new v.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function k2(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function F2(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function O2(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(J0),this.state=pt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function U2(n){let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case v.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=pt.DOLLY;break;case v.MOUSE.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=pt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=pt.ROTATE}break;case v.MOUSE.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=pt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=pt.PAN}break;default:this.state=pt.NONE}this.state!==pt.NONE&&this.dispatchEvent(Zu)}function N2(n){switch(this.state){case pt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case pt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case pt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function z2(n){this.enabled===!1||this.enableZoom===!1||this.state!==pt.NONE||(n.preventDefault(),this.dispatchEvent(Zu),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(J0))}function G2(n){this.enabled!==!1&&this._handleKeyDown(n)}function V2(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case v.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=pt.TOUCH_ROTATE;break;case v.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=pt.TOUCH_PAN;break;default:this.state=pt.NONE}break;case 2:switch(this.touches.TWO){case v.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=pt.TOUCH_DOLLY_PAN;break;case v.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=pt.TOUCH_DOLLY_ROTATE;break;default:this.state=pt.NONE}break;default:this.state=pt.NONE}this.state!==pt.NONE&&this.dispatchEvent(Zu)}function Q2(n){switch(this._trackPointer(n),this.state){case pt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case pt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case pt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case pt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=pt.NONE}}function j2(n){this.enabled!==!1&&n.preventDefault()}function W2(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function H2(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const ur=new v.Raycaster,ei=new v.Vector3,Cs=new v.Vector3,_t=new v.Quaternion,ex={X:new v.Vector3(1,0,0),Y:new v.Vector3(0,1,0),Z:new v.Vector3(0,0,1)},tf={type:"change"},tx={type:"mouseDown",mode:null},ix={type:"mouseUp",mode:null},nx={type:"objectChange"};class sx extends v.Controls{constructor(e,t=null){super(void 0,t);const i=new J2(this);this._root=i;const s=new Z2;this._gizmo=s,i.add(s);const r=new eD;this._plane=r,i.add(r);const o=this;function a(b,y){let _=y;Object.defineProperty(o,b,{get:function(){return _!==void 0?_:y},set:function(S){_!==S&&(_=S,r[b]=S,s[b]=S,o.dispatchEvent({type:b+"-changed",value:S}),o.dispatchEvent(tf))}}),o[b]=y,r[b]=y,s[b]=y}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new v.Vector3,c=new v.Vector3,h=new v.Quaternion,d=new v.Quaternion,f=new v.Vector3,u=new v.Quaternion,g=new v.Vector3,p=new v.Vector3,m=new v.Vector3,A=0,x=new v.Vector3;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",h),a("worldQuaternionStart",d),a("cameraPosition",f),a("cameraQuaternion",u),a("pointStart",g),a("pointEnd",p),a("rotationAxis",m),a("rotationAngle",A),a("eye",x),this._offset=new v.Vector3,this._startNorm=new v.Vector3,this._endNorm=new v.Vector3,this._cameraScale=new v.Vector3,this._parentPosition=new v.Vector3,this._parentQuaternion=new v.Quaternion,this._parentQuaternionInv=new v.Quaternion,this._parentScale=new v.Vector3,this._worldScaleStart=new v.Vector3,this._worldQuaternionInv=new v.Quaternion,this._worldScale=new v.Vector3,this._positionStart=new v.Vector3,this._quaternionStart=new v.Quaternion,this._scaleStart=new v.Vector3,this._getPointer=X2.bind(this),this._onPointerDown=Y2.bind(this),this._onPointerHover=q2.bind(this),this._onPointerMove=K2.bind(this),this._onPointerUp=$2.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&ur.setFromCamera(e,this.camera);const t=nf(this._gizmo.picker[this.mode],ur);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&ur.setFromCamera(e,this.camera);const t=nf(this._plane,ur,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,tx.mode=this.mode,this.dispatchEvent(tx)}}pointerMove(e){const t=this.axis,i=this.mode,s=this.object;let r=this.space;if(i==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),s===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&ur.setFromCamera(e,this.camera);const o=nf(this._plane,ur,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(s.position.applyQuaternion(_t.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),r==="world"&&(s.parent&&s.position.add(ei.setFromMatrixPosition(s.parent.matrixWorld)),t.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(ei.setFromMatrixPosition(s.parent.matrixWorld)))),s.position.x=Math.max(this.minX,Math.min(this.maxX,s.position.x)),s.position.y=Math.max(this.minY,Math.min(this.maxY,s.position.y)),s.position.z=Math.max(this.minZ,Math.min(this.maxZ,s.position.z));else if(i==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Cs.set(a,a,a)}else ei.copy(this.pointStart),Cs.copy(this.pointEnd),ei.applyQuaternion(this._worldQuaternionInv),Cs.applyQuaternion(this._worldQuaternionInv),Cs.divide(ei),t.search("X")===-1&&(Cs.x=1),t.search("Y")===-1&&(Cs.y=1),t.search("Z")===-1&&(Cs.z=1);s.scale.copy(this._scaleStart).multiply(Cs),this.scaleSnap&&(t.search("X")!==-1&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(ei.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(ei.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(ex[t]),ei.copy(ex[t]),r==="local"&&ei.applyQuaternion(this.worldQuaternion),ei.cross(this.eye),ei.length()===0?l=!0:this.rotationAngle=this._offset.dot(ei.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(_t.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(_t.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(tf),this.dispatchEvent(nx)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(ix.mode=this.mode,this.dispatchEvent(ix)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(tf),this.dispatchEvent(nx),this.pointStart.copy(this.pointEnd))}getRaycaster(){return ur}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,i,s){const r=this._gizmo.materialLib;r.xAxis.color.set(e),r.yAxis.color.set(t),r.zAxis.color.set(i),r.active.color.set(s),r.xAxisTransparent.color.set(e),r.yAxisTransparent.color.set(t),r.zAxisTransparent.color.set(i),r.activeTransparent.color.set(s),r.xAxis._color&&r.xAxis._color.set(e),r.yAxis._color&&r.yAxis._color.set(t),r.zAxis._color&&r.zAxis._color.set(i),r.active._color&&r.active._color.set(s),r.xAxisTransparent._color&&r.xAxisTransparent._color.set(e),r.yAxisTransparent._color&&r.yAxisTransparent._color.set(t),r.zAxisTransparent._color&&r.zAxisTransparent._color.set(i),r.activeTransparent._color&&r.activeTransparent._color.set(s)}}function X2(n){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:n.button};{const e=this.domElement.getBoundingClientRect();return{x:(n.clientX-e.left)/e.width*2-1,y:-(n.clientY-e.top)/e.height*2+1,button:n.button}}}function q2(n){if(this.enabled)switch(n.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(n));break}}function Y2(n){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(n)),this.pointerDown(this._getPointer(n)))}function K2(n){this.enabled&&this.pointerMove(this._getPointer(n))}function $2(n){this.enabled&&(this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(n)))}function nf(n,e,t){const i=e.intersectObject(n,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||t)return i[s];return!1}const Mc=new v.Euler,mt=new v.Vector3(0,1,0),rx=new v.Vector3(0,0,0),ox=new v.Matrix4,Ec=new v.Quaternion,Ic=new v.Quaternion,_n=new v.Vector3,ax=new v.Matrix4,xa=new v.Vector3(1,0,0),fr=new v.Vector3(0,1,0),ba=new v.Vector3(0,0,1),Tc=new v.Vector3,ya=new v.Vector3,va=new v.Vector3;class J2 extends v.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class Z2 extends v.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new v.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new v.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const s=t.clone();s.opacity=.5;const r=e.clone();r.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const d=e.clone();d.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25;const u=e.clone();u.color.setHex(16776960);const g=e.clone();g.color.setHex(7895160),this.materialLib={xAxis:r,yAxis:o,zAxis:a,active:u,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:h,activeTransparent:f};const p=new v.CylinderGeometry(0,.04,.1,12);p.translate(0,.05,0);const m=new v.BoxGeometry(.08,.08,.08);m.translate(0,.04,0);const A=new v.BufferGeometry;A.setAttribute("position",new v.Float32BufferAttribute([0,0,0,1,0,0],3));const x=new v.CylinderGeometry(.0075,.0075,.5,3);x.translate(0,.25,0);function b(F,z){const X=new v.TorusGeometry(F,.0075,3,64,z*Math.PI*2);return X.rotateY(Math.PI/2),X.rotateX(Math.PI/2),X}function y(){const F=new v.BufferGeometry;return F.setAttribute("position",new v.Float32BufferAttribute([0,0,0,1,1,1],3)),F}const _={X:[[new v.Mesh(p,r),[.5,0,0],[0,0,-Math.PI/2]],[new v.Mesh(p,r),[-.5,0,0],[0,0,Math.PI/2]],[new v.Mesh(x,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new v.Mesh(p,o),[0,.5,0]],[new v.Mesh(p,o),[0,-.5,0],[Math.PI,0,0]],[new v.Mesh(x,o)]],Z:[[new v.Mesh(p,a),[0,0,.5],[Math.PI/2,0,0]],[new v.Mesh(p,a),[0,0,-.5],[-Math.PI/2,0,0]],[new v.Mesh(x,a),null,[Math.PI/2,0,0]]],XYZ:[[new v.Mesh(new v.OctahedronGeometry(.1,0),d),[0,0,0]]],XY:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new v.Mesh(new v.OctahedronGeometry(.2,0),i)]],XY:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},C={START:[[new v.Mesh(new v.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new v.Mesh(new v.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new v.Line(y(),s),null,null,null,"helper"]],X:[[new v.Line(A,s),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new v.Line(A,s),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new v.Line(A,s),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},D={XYZE:[[new v.Mesh(b(.5,1),g),null,[0,Math.PI/2,0]]],X:[[new v.Mesh(b(.5,.5),r)]],Y:[[new v.Mesh(b(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new v.Mesh(b(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new v.Mesh(b(.75,1),f),null,[0,Math.PI/2,0]]]},M={AXIS:[[new v.Line(A,s),[-1e3,0,0],null,[1e6,1,1],"helper"]]},I={XYZE:[[new v.Mesh(new v.SphereGeometry(.25,10,8),i)]],X:[[new v.Mesh(new v.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new v.Mesh(new v.TorusGeometry(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new v.Mesh(new v.TorusGeometry(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new v.Mesh(new v.TorusGeometry(.75,.1,2,24),i)]]},P={X:[[new v.Mesh(m,r),[.5,0,0],[0,0,-Math.PI/2]],[new v.Mesh(x,r),[0,0,0],[0,0,-Math.PI/2]],[new v.Mesh(m,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new v.Mesh(m,o),[0,.5,0]],[new v.Mesh(x,o)],[new v.Mesh(m,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new v.Mesh(m,a),[0,0,.5],[Math.PI/2,0,0]],[new v.Mesh(x,a),[0,0,0],[Math.PI/2,0,0]],[new v.Mesh(m,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new v.Mesh(new v.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new v.Mesh(new v.BoxGeometry(.1,.1,.1),d)]]},T={X:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,.3,0]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new v.Mesh(new v.CylinderGeometry(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new v.Mesh(new v.BoxGeometry(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new v.Mesh(new v.BoxGeometry(.2,.2,.2),i),[0,0,0]]]},L={X:[[new v.Line(A,s),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new v.Line(A,s),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new v.Line(A,s),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function E(F){const z=new v.Object3D;for(const X in F)for(let j=F[X].length;j--;){const N=F[X][j][0].clone(),Y=F[X][j][1],V=F[X][j][2],H=F[X][j][3],oe=F[X][j][4];N.name=X,N.tag=oe,Y&&N.position.set(Y[0],Y[1],Y[2]),V&&N.rotation.set(V[0],V[1],V[2]),H&&N.scale.set(H[0],H[1],H[2]),N.updateMatrix();const pe=N.geometry.clone();pe.applyMatrix4(N.matrix),N.geometry=pe,N.renderOrder=1/0,N.position.set(0,0,0),N.rotation.set(0,0,0),N.scale.set(1,1,1),z.add(N)}return z}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=E(_)),this.add(this.gizmo.rotate=E(D)),this.add(this.gizmo.scale=E(P)),this.add(this.picker.translate=E(S)),this.add(this.picker.rotate=E(I)),this.add(this.picker.scale=E(T)),this.add(this.helper.translate=E(C)),this.add(this.helper.rotate=E(M)),this.add(this.helper.scale=E(L)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Ic;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let r=0;r<s.length;r++){const o=s[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(_t.setFromEuler(Mc.set(0,0,0)),o.quaternion.copy(i).multiply(_t),Math.abs(mt.copy(xa).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(_t.setFromEuler(Mc.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(_t),Math.abs(mt.copy(fr).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(_t.setFromEuler(Mc.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(_t),Math.abs(mt.copy(ba).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(_t.setFromEuler(Mc.set(0,Math.PI/2,0)),mt.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(ox.lookAt(rx,mt,fr)),o.quaternion.multiply(_t),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),ei.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),ei.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(ei),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(mt.copy(xa).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(mt.copy(fr).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(mt.copy(ba).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(mt.copy(ba).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(mt.copy(xa).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(mt.copy(fr).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(Ec.copy(i),mt.copy(this.eye).applyQuaternion(_t.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(ox.lookAt(this.eye,rx,fr)),o.name==="X"&&(_t.setFromAxisAngle(xa,Math.atan2(-mt.y,mt.z)),_t.multiplyQuaternions(Ec,_t),o.quaternion.copy(_t)),o.name==="Y"&&(_t.setFromAxisAngle(fr,Math.atan2(mt.x,mt.z)),_t.multiplyQuaternions(Ec,_t),o.quaternion.copy(_t)),o.name==="Z"&&(_t.setFromAxisAngle(ba,Math.atan2(mt.y,mt.x)),_t.multiplyQuaternions(Ec,_t),o.quaternion.copy(_t))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis?(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1):this.axis.split("").some(function(l){return o.name===l})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class eD extends v.Mesh{constructor(){super(new v.PlaneGeometry(1e5,1e5,2,2),new v.MeshBasicMaterial({visible:!1,wireframe:!0,side:v.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Tc.copy(xa).applyQuaternion(t==="local"?this.worldQuaternion:Ic),ya.copy(fr).applyQuaternion(t==="local"?this.worldQuaternion:Ic),va.copy(ba).applyQuaternion(t==="local"?this.worldQuaternion:Ic),mt.copy(ya),this.mode){case"translate":case"scale":switch(this.axis){case"X":mt.copy(this.eye).cross(Tc),_n.copy(Tc).cross(mt);break;case"Y":mt.copy(this.eye).cross(ya),_n.copy(ya).cross(mt);break;case"Z":mt.copy(this.eye).cross(va),_n.copy(va).cross(mt);break;case"XY":_n.copy(va);break;case"YZ":_n.copy(Tc);break;case"XZ":mt.copy(va),_n.copy(ya);break;case"XYZ":case"E":_n.set(0,0,0);break}break;case"rotate":default:_n.set(0,0,0)}_n.length()===0?this.quaternion.copy(this.cameraQuaternion):(ax.lookAt(ei.set(0,0,0),_n,mt),this.quaternion.setFromRotationMatrix(ax)),super.updateMatrixWorld(e)}}class tD extends v.DataTextureLoader{constructor(e){super(e),this.type=v.HalfFloatType}parse(e){const o=function(D,M){switch(D){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(M||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(M||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(M||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(M||""))}},d=function(D,M,I){M=M||1024;let T=D.pos,L=-1,E=0,F="",z=String.fromCharCode.apply(null,new Uint16Array(D.subarray(T,T+128)));for(;0>(L=z.indexOf(`
|
|
4942
4942
|
`))&&E<M&&T<D.byteLength;)F+=z,E+=z.length,T+=128,z+=String.fromCharCode.apply(null,new Uint16Array(D.subarray(T,T+128)));return-1<L?(D.pos+=E+L+1,F+z.slice(0,L)):!1},f=function(D){const M=/^#\?(\S+)/,I=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,P=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,T=/^\s*FORMAT=(\S+)\s*$/,L=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,E={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let F,z;for((D.pos>=D.byteLength||!(F=d(D)))&&o(1,"no header found"),(z=F.match(M))||o(3,"bad initial token"),E.valid|=1,E.programtype=z[1],E.string+=F+`
|
|
4943
4943
|
`;F=d(D),F!==!1;){if(E.string+=F+`
|
|
4944
4944
|
`,F.charAt(0)==="#"){E.comments+=F+`
|
|
4945
|
-
`;continue}if((z=F.match(I))&&(E.gamma=parseFloat(z[1])),(z=F.match(P))&&(E.exposure=parseFloat(z[1])),(z=F.match(T))&&(E.valid|=2,E.format=z[1]),(z=F.match(L))&&(E.valid|=4,E.height=parseInt(z[1],10),E.width=parseInt(z[2],10)),E.valid&2&&E.valid&4)break}return E.valid&2||o(3,"missing format specifier"),E.valid&4||o(3,"missing image size specifier"),E},u=function(D,M,I){const P=M;if(P<8||P>32767||D[0]!==2||D[1]!==2||D[2]&128)return new Uint8Array(D);P!==(D[2]<<8|D[3])&&o(3,"wrong scanline width");const T=new Uint8Array(4*M*I);T.length||o(4,"unable to allocate buffer space");let L=0,E=0;const F=4*P,z=new Uint8Array(4),X=new Uint8Array(F);let j=I;for(;j>0&&E<D.byteLength;){E+4>D.byteLength&&o(1),z[0]=D[E++],z[1]=D[E++],z[2]=D[E++],z[3]=D[E++],(z[0]!=2||z[1]!=2||(z[2]<<8|z[3])!=P)&&o(3,"bad rgbe scanline format");let N=0,Y;for(;N<F&&E<D.byteLength;){Y=D[E++];const H=Y>128;if(H&&(Y-=128),(Y===0||N+Y>F)&&o(3,"bad scanline data"),H){const oe=D[E++];for(let pe=0;pe<Y;pe++)X[N++]=oe}else X.set(D.subarray(E,E+Y),N),N+=Y,E+=Y}const V=P;for(let H=0;H<V;H++){let oe=0;T[L]=X[H+oe],oe+=P,T[L+1]=X[H+oe],oe+=P,T[L+2]=X[H+oe],oe+=P,T[L+3]=X[H+oe],L+=4}j--}return T},g=function(D,M,I,P){const T=D[M+3],L=Math.pow(2,T-128)/255;I[P+0]=D[M+0]*L,I[P+1]=D[M+1]*L,I[P+2]=D[M+2]*L,I[P+3]=1},p=function(D,M,I,P){const T=D[M+3],L=Math.pow(2,T-128)/255;I[P+0]=v.DataUtils.toHalfFloat(Math.min(D[M+0]*L,65504)),I[P+1]=v.DataUtils.toHalfFloat(Math.min(D[M+1]*L,65504)),I[P+2]=v.DataUtils.toHalfFloat(Math.min(D[M+2]*L,65504)),I[P+3]=v.DataUtils.toHalfFloat(1)},m=new Uint8Array(e);m.pos=0;const A=f(m),x=A.width,b=A.height,y=u(m.subarray(m.pos),x,b);let _,S,C;switch(this.type){case v.FloatType:C=y.length/4;const D=new Float32Array(C*4);for(let I=0;I<C;I++)g(y,I*4,D,I*4);_=D,S=v.FloatType;break;case v.HalfFloatType:C=y.length/4;const M=new Uint16Array(C*4);for(let I=0;I<C;I++)p(y,I*4,M,I*4);_=M,S=v.HalfFloatType;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:x,height:b,data:_,header:A.string,gamma:A.gamma,exposure:A.exposure,type:S}}setDataType(e){return this.type=e,this}load(e,t,i,s){function r(o,a){switch(o.type){case v.FloatType:case v.HalfFloatType:o.colorSpace=v.LinearSRGBColorSpace,o.minFilter=v.LinearFilter,o.magFilter=v.LinearFilter,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,a)}return super.load(e,r,i,s)}}function iD(){return new w.Scene}function nD(n,e){n.appendChild(e.domElement)}function sD(n,e,t){var i=new Object;i.visible=!0;let s=null,r,o,a=[];i.init=function(){r||(c(),h(),p())},i.Hide=function(){r.style.display="none",i.visible=!1},i.Show=function(){r.style.display="block",i.visible=!0},i.RenderScene=function(){if(!d){i.camera.quaternion.copy(e.camera.quaternion);const x=new w.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);i.camera.position.copy(x.multiplyScalar(100))}i.orbitControls&&i.orbitControls.update(),i.sceneOrtho.renderer.render(i.sceneOrtho,i.camera)},i.ToggleDirectionView=function(x){var b=new w.Vector3(0,0,0);x=="top"?b=new w.Vector3(0,1,1e-5):x=="down"?b=new w.Vector3(0,-1,1e-5):x=="front"?b=new w.Vector3(0,0,1):x=="left"?b=new w.Vector3(-1,0,0):x=="back"?b=new w.Vector3(0,0,-1):x=="right"?b=new w.Vector3(1,0,0):x=="top_front"?b=new w.Vector3(1,1,0):x=="top_left"?b=new w.Vector3(0,1,-1):x=="top_back"?b=new w.Vector3(-1,1,0):x=="top_right"?b=new w.Vector3(0,1,1):x=="down_front"?b=new w.Vector3(1,-1,0):x=="down_left"?b=new w.Vector3(0,-1,-1):x=="down_back"?b=new w.Vector3(-1,-1,0):x=="down_right"?b=new w.Vector3(0,-1,1):x=="front_right"?b=new w.Vector3(1,0,1):x=="right_back"?b=new w.Vector3(-1,0,1):x=="back_left"?b=new w.Vector3(-1,0,-1):x=="left_front"?b=new w.Vector3(1,0,-1):x=="top_left_front"?b=new w.Vector3(1,1,-1):x=="top_front_right"?b=new w.Vector3(1,1,1):x=="top_right_back"?b=new w.Vector3(-1,1,1):x=="top_back_left"?b=new w.Vector3(-1,1,-1):x=="button_left_front"?b=new w.Vector3(1,-1,-1):x=="button_front_right"?b=new w.Vector3(1,-1,1):x=="button_right_back"?b=new w.Vector3(-1,1,1):x=="button_back_left"&&(b=new w.Vector3(-1,-1,-1));var y=n.octreeBox.getBoundingBox(),_=y.min,S=y.max,C=_.clone().add(S.clone()).multiplyScalar(.5),D=C.clone().add(b.multiplyScalar(1*S.distanceTo(_)));l(e.camera.position,D,n.controls.target.clone(),C)},i.GetCameraPose=function(){var x=e.camera.quaternion,b=e.camera.position,y=n.controls.target,_={quaternion:x,position:b,target:y};return _},i.ReductionCameraPose=function(x,b=1e3,y){var _=new w.Quaternion(x.quaternion._x,x.quaternion._y,x.quaternion._z,x.quaternion._w),S=new w.Vector3(x.position.x,x.position.y,x.position.z),C=new w.Vector3(x.target.x,x.target.y,x.target.z);let D=!1;l(e.camera.position,S,n.controls.target.clone(),C,e.camera.quaternion,_,b,M=>{y&&(D||(y(M),D=!0))}),y&&setTimeout(()=>{D||(y(!0),D=!0)},b+10)},i.CameraGoHome=function(x=1e3){var b=n.octreeBox.getBoundingBox(),y=b.min.clone().add(b.max.clone()).multiplyScalar(.5);let _=new w.Vector3(1,1,1);var S=b.max.distanceTo(b.min),C=y.clone().add(_.multiplyScalar(S*.8));if(e.camera.isOrthographicCamera){var D=n.container.clientWidth/n.container.clientHeight,M=S*.5;e.camera.left=-M*D,e.camera.right=M*D,e.camera.top=M,e.camera.bottom=-M,e.camera.zoom=1,e.camera.updateProjectionMatrix(),e.camera.far=S*3}else e.camera.far=S*3;n.controlModule.orbitControls.origin=y.clone(),l(e.camera.position,C,n.controls.target.clone(),y,null,null,x)},i.zoomToBox=function(x){if(e.camera.isOrthographicCamera){let re=function(){s=requestAnimationFrame(re),ue.update()};var b=x.min.clone().add(x.max.clone()).multiplyScalar(.5),y=e.camera.position.clone().sub(n.controls.target.clone()).normalize(),_=e.camera.position.distanceTo(n.controls.target),S=b.clone().add(y.multiplyScalar(_)),C=e.camera.zoom,D=new w.Vector3(1,0,0).applyQuaternion(e.camera.quaternion),M=new w.Vector3(0,1,0).applyQuaternion(e.camera.quaternion),I=[new w.Vector3(x.min.x,x.min.y,x.min.z),new w.Vector3(x.max.x,x.min.y,x.min.z),new w.Vector3(x.min.x,x.max.y,x.min.z),new w.Vector3(x.max.x,x.max.y,x.min.z),new w.Vector3(x.min.x,x.min.y,x.max.z),new w.Vector3(x.max.x,x.min.y,x.max.z),new w.Vector3(x.min.x,x.max.y,x.max.z),new w.Vector3(x.max.x,x.max.y,x.max.z)],P=1/0,T=-1/0,L=1/0,E=-1/0;for(var F of I){var z=F.dot(D),X=F.dot(M);P=Math.min(P,z),T=Math.max(T,z),L=Math.min(L,X),E=Math.max(E,X)}var j=(T-P)/2,N=(E-L)/2,Y=(e.camera.right-e.camera.left)/2,V=(e.camera.top-e.camera.bottom)/2;C=Math.min(Y/j,V/N)*.75;var H=e.camera.position.clone(),oe=n.controls.target.clone(),pe=e.camera.zoom,ue=new Aa.Tween({x1:H.x,y1:H.y,z1:H.z,x2:oe.x,y2:oe.y,z2:oe.z,zoom:pe}).to({x1:S.x,y1:S.y,z1:S.z,x2:b.x,y2:b.y,z2:b.z,zoom:C},1e3);ue.onUpdate(function(de){n.controls&&(e.camera.position.set(de.x1,de.y1,de.z1),n.controls.target.set(de.x2,de.y2,de.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=de.zoom,e.camera.updateProjectionMatrix()),n.controls.auto=!0,n.controls.update(),i.RenderScene())}),ue.onComplete(function(){n.controls&&(n.controls.auto=!1,i.RenderScene(),cancelAnimationFrame(s),s=null)}),ue.easing(Aa.Easing.Cubic.InOut),ue.start(),re()}else{var b=x.min.clone().add(x.max.clone()).multiplyScalar(.5);let Ae=e.camera.position.clone().sub(n.controls.target.clone()).normalize();var S=b.clone().add(Ae.multiplyScalar(2*x.max.distanceTo(x.min)));l(e.camera.position,S,n.controls.target.clone(),b)}};function l(x,b,y,_,S,C,D=1e3,M){var I;S&&C?(I=new Aa.Tween({x1:x.x,y1:x.y,z1:x.z,x2:y.x,y2:y.y,z2:y.z,_x:S._x,_y:S._y,_z:S._z,_w:S._w}),I.to({x1:b.x,y1:b.y,z1:b.z,x2:_.x,y2:_.y,z2:_.z,_x:C._x,_y:C._y,_z:C._z,_w:C._w},D)):(I=new Aa.Tween({x1:x.x,y1:x.y,z1:x.z,x2:y.x,y2:y.y,z2:y.z}),I.to({x1:b.x,y1:b.y,z1:b.z,x2:_.x,y2:_.y,z2:_.z},D)),I.onUpdate(function(T){n.controls&&(S&&C?(e.camera.quaternion._x=T._x,e.camera.quaternion._y=T._y,e.camera.quaternion._z=T._z,e.camera.quaternion._w=T._w):n.controls.auto=!0,e.camera.position.x=T.x1,e.camera.position.y=T.y1,e.camera.position.z=T.z1,n.controls.target.x=T.x2,n.controls.target.y=T.y2,n.controls.target.z=T.z2,n.controls.update(),i.RenderScene())}),I.onComplete(function(T){n.controls&&(n.controls.auto=!1,i.RenderScene(),M&&M(!0),cancelAnimationFrame(s),s=null)}),I.easing(Aa.Easing.Cubic.InOut);function P(T){s=requestAnimationFrame(P),I.update()}I.start(),P()}function c(){r=document.createElement("div"),r.className="ViewCube",t.appendChild(r),o=document.createElement("div"),o.className="viewSettingWrapper",o.innerHTML="...";var x=document.createElement("div");x.className="homeViewWrapper",x.addEventListener("mousedown",function(){i.CameraGoHome()}),r.appendChild(x),o.addEventListener("mousedown",function(_){_.stopPropagation(),cameraToggle.classList.contains("show")?(b(),console.log("隐藏功能按钮")):(y(),console.log("显示功能按钮"))});function b(){cameraToggle.classList.remove("show"),screenshot.classList.remove("show"),fullscreen.classList.remove("show")}function y(){cameraToggle.classList.add("show"),screenshot.classList.add("show"),fullscreen.classList.add("show")}}function h(){i.sceneOrtho=iD();var y=t.clientWidth,_=t.clientWidth,x=y>_?y/_:_/y,b=300;i.camera=new w.OrthographicCamera(b*x/-2,b*x/2,b/2,b/-2,.01,1e4);var y=r.clientWidth,_=r.clientHeight,S=new w.WebGLRenderer({alpha:!0});S.setSize(y,_),S.setClearAlpha(0),i.sceneOrtho.renderer=S;let C=new w.AmbientLight(16777215,.8);i.sceneOrtho.add(C),nD(r,S),i.orbitControls=new R2(i.camera,r),i.orbitControls.enableZoom=!1,i.orbitControls.enablePan=!1,i.orbitControls.enableDamping=!0,i.orbitControls.dampingFactor=.1,i.orbitControls.rotateSpeed=.5,i.orbitControls.addEventListener("start",f),i.orbitControls.addEventListener("change",u),i.orbitControls.addEventListener("end",g)}let d=!1;function f(){d=!0,n.controls&&(i._mainTarget=n.controls.target.clone(),i._mainDistance=e.camera.position.distanceTo(n.controls.target))}function u(){if(d){if(e.camera.quaternion.copy(i.camera.quaternion),n.controls&&i._mainTarget&&i._mainDistance){const x=new w.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);e.camera.position.copy(i._mainTarget.clone().add(x.multiplyScalar(i._mainDistance))),n.controls.update()}n.renderer&&e.camera&&n.renderer.render(e,e.camera)}}function g(){d=!1,i._mainTarget=null,i._mainDistance=null}function p(){const x="/assets/viewcube/";let b=[{label:"右",icon:x+"cn_right.png"},{label:"左",icon:x+"cn_left.png"},{label:"顶",icon:x+"cn_top.png"},{label:"底",icon:x+"cn_bottom.png"},{label:"前",icon:x+"cn_front.png"},{label:"后",icon:x+"cn_back.png"}];var y=[];for(const C of b)y.push(new w.MeshBasicMaterial({color:16777215,map:new w.TextureLoader().load(C.icon)}));new w.MeshLambertMaterial({color:255});var _=new w.Mesh(new w.BoxGeometry(110,110,110),y);i.sceneOrtho.add(_),m(122);let S={x:0,y:0};r.addEventListener("mousedown",C=>{S.x=C.clientX,S.y=C.clientY}),r.addEventListener("mouseup",C=>{if(d)return;const D=C.clientX-S.x,M=C.clientY-S.y;if(Math.sqrt(D*D+M*M)>5)return;var P={};P.x=C.offsetX/r.clientWidth*2-1,P.y=-(C.offsetY/r.clientHeight)*2+1;var T=new w.Raycaster;T.setFromCamera(P,i.camera);const L=T.intersectObjects(a,!1);L.length>0&&i.ToggleDirectionView(L[0].object.name)}),r.addEventListener("mousemove",C=>{var D={};D.x=C.offsetX/r.clientWidth*2-1,D.y=-(C.offsetY/r.clientHeight)*2+1;var M=new w.Raycaster;M.setFromCamera(D,i.camera);const I=M.intersectObjects(a,!1);for(var P of a)P.material.opacity=.01;I.length>0&&(I[0].object.material.opacity=.2)})}function m(x){for(var b=x*.5-20,y=[{name:"right",a:30,b:75,c:75,point:new w.Vector3(b,0,0)},{name:"back",a:75,b:75,c:30,point:new w.Vector3(0,0,-b)},{name:"left",a:30,b:75,c:75,point:new w.Vector3(-b,0,0)},{name:"front",a:75,b:75,c:30,point:new w.Vector3(0,0,b)},{name:"top",a:75,b:30,c:75,point:new w.Vector3(0,b,0)},{name:"button",a:75,b:30,c:75,point:new w.Vector3(0,-b,0)}],_=[{name:"top_right_back",a:30,b:30,c:30,point:new w.Vector3(-b,b,b)},{name:"button_front_right",a:30,b:30,c:30,point:new w.Vector3(-b,-b,b)},{name:"top_front_right",a:30,b:30,c:30,point:new w.Vector3(b,b,b)},{name:"button_right_back",a:30,b:30,c:30,point:new w.Vector3(b,-b,b)},{name:"top_back_left",a:30,b:30,c:30,point:new w.Vector3(-b,b,-b)},{name:"button_back_left",a:30,b:30,c:30,point:new w.Vector3(-b,-b,-b)},{name:"top_left_front",a:30,b:30,c:30,point:new w.Vector3(b,b,-b)},{name:"button_left_front",a:30,b:30,c:30,point:new w.Vector3(b,-b,-b)}],S=[{name:"top_front",a:30,b:30,c:75,point:new w.Vector3(b,b,0)},{name:"top_right",a:75,b:30,c:30,point:new w.Vector3(0,b,b)},{name:"top_back",a:30,b:30,c:75,point:new w.Vector3(-b,b,0)},{name:"top_left",a:75,b:30,c:30,point:new w.Vector3(0,b,-b)},{name:"button_front",a:30,b:30,c:75,point:new w.Vector3(b,-b,0)},{name:"button_right",a:75,b:30,c:30,point:new w.Vector3(0,-b,b)},{name:"button_back",a:30,b:30,c:75,point:new w.Vector3(-b,-b,0)},{name:"button_left",a:75,b:30,c:30,point:new w.Vector3(0,-b,-b)},{name:"front_right",a:30,b:75,c:30,point:new w.Vector3(b,0,b)},{name:"right_back",a:30,b:75,c:30,point:new w.Vector3(-b,0,b)},{name:"back_left",a:30,b:75,c:30,point:new w.Vector3(-b,0,-b)},{name:"left_front",a:30,b:75,c:30,point:new w.Vector3(b,0,-b)}],C=0;C<y.length;C++)a.push(A(y[C]));for(var C=0;C<_.length;C++)a.push(A(_[C]));for(var C=0;C<S.length;C++)a.push(A(S[C]))}function A(x){const b=new w.BoxGeometry(x.a,x.b,x.c),y=new w.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),_=new w.Matrix4().makeTranslation(x.point.x,x.point.y,x.point.z);let S=b.applyMatrix4(_),C=new w.Mesh(S,y);return C.name=x.name,i.sceneOrtho.add(C),C}return i.ToggleCameraType=function(){n.cameraModule.switchCurrentCamera()},i.TakeScreenshot=function(){try{if(!n.renderer){console.error("渲染器未初始化");return}n.renderer.render(e,e.camera);const b=n.renderer.domElement.toDataURL("image/png"),y=document.createElement("a"),_=new Date().toISOString().replaceAll(/[:.]/g,"-");y.download=`screenshot_${_}.png`,y.href=b,y.click(),console.log("截图已保存")}catch(x){console.error("截图失败:",x)}},i.ToggleFullscreen=function(){const x=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(x.requestFullscreen?x.requestFullscreen():x.webkitRequestFullscreen?x.webkitRequestFullscreen():x.mozRequestFullScreen?x.mozRequestFullScreen():x.msRequestFullscreen&&x.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},i}class rD{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=sD(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(e){this.cubeTool.CameraGoHome(e)}zoomToModel(e){this.cubeTool.zoomToBox(e)}zoomToModels(e){try{let t=this.engine.models.find(i=>i.url==e.url);this.cubeTool.zoomToBox(t.nodesMap.get(e.id).infos[0].box)}catch{}}hide(){}}function oD(n){let e=new Object;return e.getBoundingBox=function(){let t=n.models,i=new w.Vector3(1e8,1e9,1e10),s=new w.Vector3(-1e8,-1e9,-1e10);t.forEach(d=>{let f=new w.Vector3(Math.min(d.boundingBox.min.x,d.boundingBox.max.x),Math.min(d.boundingBox.min.y,d.boundingBox.max.y),Math.min(d.boundingBox.min.z,d.boundingBox.max.z)),u=new w.Vector3(Math.max(d.boundingBox.min.x,d.boundingBox.max.x),Math.max(d.boundingBox.min.y,d.boundingBox.max.y),Math.max(d.boundingBox.min.z,d.boundingBox.max.z));f.x<i.x&&(i.x=f.x),f.y<i.y&&(i.y=f.y),f.z<i.z&&(i.z=f.z),u.x>s.x&&(s.x=u.x),u.y>s.y&&(s.y=u.y),u.z>s.z&&(s.z=u.z)});let r=Math.min(i.x,s.x),o=Math.min(i.y,s.y),a=Math.min(i.z,s.z),l=Math.max(i.x,s.x),c=Math.max(i.y,s.y),h=Math.max(i.z,s.z);return{min:new w.Vector3(r,o,a),max:new w.Vector3(l,c,h)}},e.rayInterationModel=function(t,i,s=!0){let r=[];return n.engineStatus.models.forEach(l=>{l.info.lods.forEach(c=>{let h=c.octreeBox;a(t,h,l)})}),r=r.filter(l=>l instanceof w.Mesh),s&&(r=r.filter(l=>l.geometry.attributes.position.count<1e3)),r.forEach(l=>{l.box||(l.box=new w.Box3().setFromObject(l))}),r=r.filter(l=>t.ray.intersectsBox(l.box,!1)==!0),t.intersectObjects(r,!1);function a(l,c,h){if(c==null)return;let d=new w.Vector3(c.min.X*.3048,c.min.Z*.3048,-c.min.Y*.3048),f=new w.Vector3(c.max.X*.3048,c.max.Z*.3048,-c.max.Y*.3048),u=new w.Vector3(Math.min(d.x,f.x),Math.min(d.y,f.y),Math.min(d.z,f.z)),g=new w.Vector3(Math.max(f.x,d.x),Math.max(f.y,d.y),Math.max(f.z,d.z)),p=new w.Box3(u,g),m=l.ray.intersectsBox(p);if(!(m==null||m==!1))if(c.children==null||c.children.length==0){if(c.elements!=null)for(var A of c.elements){if(!n.engineStatus.isFree&&i==!1)continue;let x=n.engineStatus.hideModels.find(S=>S.url==h.url)?.ids;if(x!=null&&x.includes(A))continue;let b=n.engineStatus.translucentModels.find(S=>S.url==h.url)?.ids;if(b!=null&&b.includes(A))continue;let _=n.models.find(S=>S.url==h.url).nodesMap.get(A);_!=null&&!_.instance&&_.infos!=null&&_.infos.map(C=>C.mesh).forEach(C=>{r.push(C)})}}else{if(c.elements!=null)for(var A of c.elements){let b=n.engineStatus.hideModels.find(C=>C.url==h.url)?.ids;if(b!=null&&b.includes(A))continue;let y=n.engineStatus.translucentModels.find(C=>C.url==h.url)?.ids;if(y!=null&&y.includes(A))continue;let S=n.models.find(C=>C.url==h.url).nodesMap.get(A);S!=null&&!S.instance&&S.infos!=null&&S.infos.map(D=>D.mesh).forEach(D=>{r.push(D)})}for(let x of c.children)a(l,x,h)}}},e}class aD{engine;isDrawing=!1;startPoint=new w.Vector2;endPoint=new w.Vector2;selectionBox=null;worldToScreen=null;boundMouseDown;boundMouseMove;boundMouseUp;boundKeyDown;constructor(e){this.engine=e,this.boundMouseDown=this.onMouseDown.bind(this),this.boundMouseMove=this.onMouseMove.bind(this),this.boundMouseUp=this.onMouseUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this)}init(){this.createSelectionBoxElement(),this.engine.scene&&this.engine.camera&&this.engine.renderer&&(this.worldToScreen=new lt(this.engine.camera,this.engine.renderer,this.engine.scene))}active(){this.engine.controlModule.disActive();const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.boundMouseDown),e.addEventListener("mousemove",this.boundMouseMove),e.addEventListener("mouseup",this.boundMouseUp),e.style.cursor="crosshair"),window.addEventListener("keydown",this.boundKeyDown)}disActive(){this.engine.controlModule.active();const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.boundMouseDown),e.removeEventListener("mousemove",this.boundMouseMove),e.removeEventListener("mouseup",this.boundMouseUp),e.style.cursor="default"),window.removeEventListener("keydown",this.boundKeyDown),this.isDrawing&&this.endDrawing()}createSelectionBoxElement(){this.selectionBox=document.createElement("div"),this.selectionBox.style.position="absolute",this.selectionBox.style.border="2px dashed #00aaff",this.selectionBox.style.backgroundColor="rgba(0, 170, 255, 0.1)",this.selectionBox.style.pointerEvents="none",this.selectionBox.style.display="none",this.selectionBox.style.zIndex="1000",this.selectionBox.style.boxSizing="border-box";const e=this.engine.renderer?.domElement;e&&e.parentElement&&e.parentElement.appendChild(this.selectionBox)}onMouseDown(e){e.button!==0||!this.engine.renderer?.domElement||(this.startPoint.set(e.offsetX,e.offsetY),this.endPoint.copy(this.startPoint),this.isDrawing=!0,this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation())}onMouseMove(e){!this.isDrawing||!this.engine.renderer?.domElement||(this.endPoint.set(e.offsetX,e.offsetY),this.updateSelectionBoxUI(),e.preventDefault(),e.stopPropagation())}onMouseUp(e){this.isDrawing&&(this.endDrawing(),this.performZoom(),e.preventDefault(),e.stopPropagation(),this.disActive())}onKeyDown(e){e.key==="Escape"&&(this.disActive(),e.preventDefault(),e.stopPropagation())}endDrawing(){this.isDrawing&&(this.isDrawing=!1,this.selectionBox&&(this.selectionBox.style.display="none"))}updateSelectionBoxUI(){if(!this.selectionBox||!this.engine.renderer?.domElement)return;const t=Math.min(this.startPoint.x,this.endPoint.x),i=Math.min(this.startPoint.y,this.endPoint.y),s=Math.abs(this.endPoint.x-this.startPoint.x),r=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${t}px`,this.selectionBox.style.top=`${i}px`,this.selectionBox.style.width=`${s}px`,this.selectionBox.style.height=`${r}px`}performZoom(){const e=Math.abs(this.endPoint.x-this.startPoint.x),t=Math.abs(this.endPoint.y-this.startPoint.y);if(e<5||t<5)return;if(!this.worldToScreen){console.warn("RangeScale: 坐标转换工具未初始化");return}const i=Math.min(this.startPoint.x,this.endPoint.x),s=Math.max(this.startPoint.x,this.endPoint.x),r=Math.min(this.startPoint.y,this.endPoint.y),o=Math.max(this.startPoint.y,this.endPoint.y),a=[],l=[{x:i,y:r},{x:s,y:r},{x:s,y:o},{x:i,y:o}];for(const h of l){const d=this.worldToScreen.screenToWorld(h.x,h.y);d&&a.push(d)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const c=new w.Box3;for(const h of a)c.expandByPoint(h);if(c.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(c)}fitCameraToBoundingBox(e){const t=this.engine.camera,i=this.engine.controls;if(!t||!i){console.warn("RangeScale: 相机或控制器未初始化");return}const s=new w.Vector3;e.getCenter(s);const r=new w.Vector3;e.getSize(r);const o=Math.max(r.x,r.y,r.z);if(t instanceof w.PerspectiveCamera){const a=t.fov*(Math.PI/180),c=o/(2*Math.tan(a/2))*1.2,h=new w.Vector3;t.getWorldDirection(h);const d=s.clone().sub(t.position);h.dot(d.normalize())<0&&h.negate();const u=s.clone().sub(h.multiplyScalar(c));t.position.copy(u),i.target&&i.target.copy(s),t.lookAt(s),i.update()}else if(t instanceof w.OrthographicCamera){const l=o*1.2,c=this.engine.renderer?.domElement,h=c?c.width/c.height:1;t.left=-l*h/2,t.right=l*h/2,t.top=l/2,t.bottom=-l/2,t.updateProjectionMatrix();const d=new w.Vector3;t.getWorldDirection(d);const f=o*1.5,u=s.clone().sub(d.multiplyScalar(f));t.position.copy(u),i.target&&i.target.copy(s),t.lookAt(s),i.update()}}}const lD=w.MathUtils.degToRad(10),lx=.001,sf=!1,cD=[];class hD{engine;rootGroup=null;isVisible=sf;axes=[];coordinateMapper=e=>new w.Vector3(e.X,e.Z,-e.Y);constructor(e){this.engine=e,this._initRoot()}setData(e=[]){this._clearAxes(),this.axes=e.map(t=>({data:t,group:null})),this.axes.forEach(t=>this._buildAxis(t))}setMockData(){const e=this.engine.models?.[0]?.grids;this.setData(Array.isArray(e)&&e.length>0?e:cD)}show(){this.isVisible=!0,this.rootGroup&&(this.rootGroup.visible=!0)}hide(){this.isVisible=!1,this.rootGroup&&(this.rootGroup.visible=!1)}toggle(){if(this.isVisible){this.hide();return}this.show()}getVisible(){return this.isVisible}update(){if(!this.isVisible||!this.rootGroup)return;const e=this.engine.camera,t=this.engine.renderer;if(!e||!t)return;let i=.5;if(e instanceof w.OrthographicCamera){const s=(e.top-e.bottom)/e.zoom,r=t.domElement.clientHeight||1;i=30*s/r}this.rootGroup.traverse(s=>{s instanceof w.Sprite&&s.scale.set(i,i,1)})}getLocationByPoint(e,t){const{url:i,targetPoint:s}=this.resolvePointLookupArgs(e,t),r=this.getGridData(i);debugger;if(r.length===0)return null;const o=this.toVector3(s),a=new w.Vector2(o.x,o.z),l=this.buildAxisFamilies(r).sort((f,u)=>u.axes.length-f.axes.length).slice(0,2).map((f,u)=>({...f,familyIndex:u}));if(l.length===0)return null;const c=l.map(f=>this.resolveFamilyLocation(f,a)),h=this.sortFamiliesForDisplay(c),d=h.length===2&&h.every(f=>f.isInside);return{point:{x:o.x,y:o.y,z:o.z},description:this.formatGridDescription(h),families:h,isInside:d}}dispose(){this._clearAxes(),this.rootGroup&&(this.engine.scene&&this.engine.scene.remove(this.rootGroup),this.rootGroup=null)}_initRoot(){this.rootGroup=new w.Group,this.rootGroup.name="GridRoot",this.rootGroup.visible=sf,this.engine.scene&&this.engine.scene.add(this.rootGroup)}_clearAxes(){this.axes.forEach(e=>{e.group&&(this.rootGroup?.remove(e.group),e.group.traverse(t=>{const i=t;if("geometry"in i&&i.geometry&&i.geometry.dispose(),"material"in i&&i.material){const s=i.material;"map"in s&&s.map&&s.map.dispose(),s.dispose()}}),e.group=null)}),this.axes=[]}_buildAxis(e){if(!this.rootGroup)return;const t=this.coordinateMapper(e.data.Points[0]),i=this.coordinateMapper(e.data.Points[1]),s=new w.Group;s.name=`GridAxis_${e.data.Id}`;const r=new w.BufferGeometry().setFromPoints([t,i]),o=new w.LineBasicMaterial({color:1609983,depthTest:!1}),a=new w.Line(r,o);a.renderOrder=998,s.add(a),s.add(this._makeCircleSprite(e.data.Name,t)),s.add(this._makeCircleSprite(e.data.Name,i)),this.rootGroup.add(s),e.group=s}_makeCircleSprite(e,t){const s=document.createElement("canvas");s.width=128,s.height=128;const r=s.getContext("2d");if(!r)throw new Error("Grid sprite canvas context is not available");const o=128/2,a=128/2,l=128/2-4;r.beginPath(),r.arc(o,a,l,0,Math.PI*2),r.fillStyle="white",r.fill(),r.strokeStyle="#1890ff",r.lineWidth=6,r.stroke(),r.fillStyle="#1890ff",r.font=`bold ${Math.round(128*.38)}px Arial`,r.textAlign="center",r.textBaseline="middle",r.fillText(e,o,a);const c=new w.CanvasTexture(s),h=new w.SpriteMaterial({map:c,depthTest:!1,transparent:!0}),d=new w.Sprite(h);return d.position.copy(t),d.scale.set(.5,.5,1),d.renderOrder=999,d}getGridData(e){if(e){const i=this.findModelByUrl(e);return Array.isArray(i?.grids)?i.grids:[]}if(this.axes.length>0)return this.axes.map(i=>i.data);if(!Array.isArray(this.engine.models))return[];const t=[];return this.engine.models.forEach(i=>{Array.isArray(i.grids)&&t.push(...i.grids)}),t}resolvePointLookupArgs(e,t){if(typeof e=="string"){if(!t)throw new Error("Grid.getLocationByPoint(url, point) requires a point argument.");return{url:e,targetPoint:t}}return{targetPoint:e}}findModelByUrl(e){return this.engine.models?.find(t=>t.url===e)}buildAxisFamilies(e){const t=[];return e.forEach(i=>{const s=this.createProjection(i);if(!s)return;const r=t.find(o=>o.direction.angleTo(s.direction)<=lD);if(r){r.axes.push(s);return}t.push({familyIndex:t.length,direction:s.direction.clone(),normal:new w.Vector2(-s.direction.y,s.direction.x),axes:[s]})}),t.forEach(i=>{i.axes.sort((s,r)=>s.offset-r.offset)}),t}createProjection(e){const t=this.coordinateMapper(e.Points[0]),i=this.coordinateMapper(e.Points[1]),s=new w.Vector2(t.x,t.z),r=new w.Vector2(i.x,i.z),o=r.clone().sub(s);if(o.lengthSq()<=Number.EPSILON)return null;const a=this.normalizeDirection(o),l=new w.Vector2(-a.y,a.x);return{data:e,start:s,end:r,direction:a,offset:s.dot(l)}}normalizeDirection(e){const t=e.clone().normalize();return(t.x<0||Math.abs(t.x)<=lx&&t.y<0)&&t.multiplyScalar(-1),t}resolveFamilyLocation(e,t){const i=t.dot(e.normal),s=e.axes.find(c=>Math.abs(c.offset-i)<=lx)??null;if(s){const c=e.axes.findIndex(d=>d.data.Id===s.data.Id),h=this.pickAxisPairAroundIndex(e.axes,c);return{familyIndex:e.familyIndex,description:h?this.formatAxisPair(h[0].data.Name,h[1].data.Name):s.data.Name,startAxisName:h?.[0].data.Name??s.data.Name,endAxisName:h?.[1].data.Name??s.data.Name,axisName:s.data.Name,pointOffset:i,isOnAxis:!0,isInside:h!==null}}let r=null,o=null;e.axes.forEach(c=>{if(c.offset<i){r=c;return}o||(o=c)});let a="",l=!1;if(r&&o)a=this.formatAxisPair(r.data.Name,o.data.Name),l=!0;else{const c=this.pickNearestBoundaryPair(e.axes,i);c&&(a=this.formatAxisPair(c[0].data.Name,c[1].data.Name))}return{familyIndex:e.familyIndex,description:a,startAxisName:r?.data.Name??null,endAxisName:o?.data.Name??null,axisName:null,pointOffset:i,isOnAxis:!1,isInside:l}}pickAxisPairAroundIndex(e,t){const i=e[t],s=t>0?e[t-1]:null,r=t<e.length-1?e[t+1]:null;if(!i)return null;if(s&&r){const o=Math.abs(i.offset-s.offset),a=Math.abs(r.offset-i.offset);return o<=a?[s,i]:[i,r]}return s?[s,i]:r?[i,r]:null}pickNearestBoundaryPair(e,t){if(e.length<2)return null;const i=[e[0],e[1]],s=[e[e.length-2],e[e.length-1]],r=Math.min(Math.abs(t-i[0].offset),Math.abs(t-i[1].offset)),o=Math.min(Math.abs(t-s[0].offset),Math.abs(t-s[1].offset));return r<=o?i:s}sortFamiliesForDisplay(e){return[...e].sort((t,i)=>{const s=this.getFamilySampleLabel(t),r=this.getFamilySampleLabel(i),o=this.isNumericLabel(s),a=this.isNumericLabel(r);return o!==a?o?1:-1:this.compareLabels(s,r)})}getFamilySampleLabel(e){return e.axisName??e.startAxisName??e.endAxisName??""}formatAxisPair(e,t){return this.compareLabels(e,t)<=0?`${e}-${t}`:`${t}-${e}`}formatGridDescription(e){if(e.length!==2)return"";const t=e.map(i=>i.description).filter(i=>i.length>0);return t.length!==2?"":`${t[0]}交${t[1]}`}compareLabels(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}isNumericLabel(e){return/^\d/.test(e.trim())}toVector3(e){return e instanceof w.Vector3?e.clone():new w.Vector3(e.x,e.y,e.z)}}class dD extends v.Mesh{constructor(e,t={}){super(e),this.isWater=!0;const i=this,s=t.textureWidth!==void 0?t.textureWidth:512,r=t.textureHeight!==void 0?t.textureHeight:512,o=t.clipBias!==void 0?t.clipBias:0,a=t.alpha!==void 0?t.alpha:1,l=t.time!==void 0?t.time:0,c=t.waterNormals!==void 0?t.waterNormals:null,h=t.sunDirection!==void 0?t.sunDirection:new v.Vector3(.70707,.70707,0),d=new v.Color(t.sunColor!==void 0?t.sunColor:16777215),f=new v.Color(t.waterColor!==void 0?t.waterColor:8355711),u=t.eye!==void 0?t.eye:new v.Vector3(0,0,0),g=t.distortionScale!==void 0?t.distortionScale:20,p=t.side!==void 0?t.side:v.FrontSide,m=t.fog!==void 0?t.fog:!1,A=new v.Plane,x=new v.Vector3,b=new v.Vector3,y=new v.Vector3,_=new v.Matrix4,S=new v.Vector3(0,0,-1),C=new v.Vector4,D=new v.Vector3,M=new v.Vector3,I=new v.Vector4,P=new v.Matrix4,T=new v.PerspectiveCamera,L=new v.WebGLRenderTarget(s,r,{type:v.HalfFloatType}),E={name:"MirrorShader",uniforms:v.UniformsUtils.merge([v.UniformsLib.fog,v.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new v.Matrix4},sunColor:{value:new v.Color(8355711)},sunDirection:{value:new v.Vector3(.70707,.70707,0)},eye:{value:new v.Vector3},waterColor:{value:new v.Color(5592405)}}]),vertexShader:`
|
|
4945
|
+
`;continue}if((z=F.match(I))&&(E.gamma=parseFloat(z[1])),(z=F.match(P))&&(E.exposure=parseFloat(z[1])),(z=F.match(T))&&(E.valid|=2,E.format=z[1]),(z=F.match(L))&&(E.valid|=4,E.height=parseInt(z[1],10),E.width=parseInt(z[2],10)),E.valid&2&&E.valid&4)break}return E.valid&2||o(3,"missing format specifier"),E.valid&4||o(3,"missing image size specifier"),E},u=function(D,M,I){const P=M;if(P<8||P>32767||D[0]!==2||D[1]!==2||D[2]&128)return new Uint8Array(D);P!==(D[2]<<8|D[3])&&o(3,"wrong scanline width");const T=new Uint8Array(4*M*I);T.length||o(4,"unable to allocate buffer space");let L=0,E=0;const F=4*P,z=new Uint8Array(4),X=new Uint8Array(F);let j=I;for(;j>0&&E<D.byteLength;){E+4>D.byteLength&&o(1),z[0]=D[E++],z[1]=D[E++],z[2]=D[E++],z[3]=D[E++],(z[0]!=2||z[1]!=2||(z[2]<<8|z[3])!=P)&&o(3,"bad rgbe scanline format");let N=0,Y;for(;N<F&&E<D.byteLength;){Y=D[E++];const H=Y>128;if(H&&(Y-=128),(Y===0||N+Y>F)&&o(3,"bad scanline data"),H){const oe=D[E++];for(let pe=0;pe<Y;pe++)X[N++]=oe}else X.set(D.subarray(E,E+Y),N),N+=Y,E+=Y}const V=P;for(let H=0;H<V;H++){let oe=0;T[L]=X[H+oe],oe+=P,T[L+1]=X[H+oe],oe+=P,T[L+2]=X[H+oe],oe+=P,T[L+3]=X[H+oe],L+=4}j--}return T},g=function(D,M,I,P){const T=D[M+3],L=Math.pow(2,T-128)/255;I[P+0]=D[M+0]*L,I[P+1]=D[M+1]*L,I[P+2]=D[M+2]*L,I[P+3]=1},p=function(D,M,I,P){const T=D[M+3],L=Math.pow(2,T-128)/255;I[P+0]=v.DataUtils.toHalfFloat(Math.min(D[M+0]*L,65504)),I[P+1]=v.DataUtils.toHalfFloat(Math.min(D[M+1]*L,65504)),I[P+2]=v.DataUtils.toHalfFloat(Math.min(D[M+2]*L,65504)),I[P+3]=v.DataUtils.toHalfFloat(1)},m=new Uint8Array(e);m.pos=0;const A=f(m),x=A.width,b=A.height,y=u(m.subarray(m.pos),x,b);let _,S,C;switch(this.type){case v.FloatType:C=y.length/4;const D=new Float32Array(C*4);for(let I=0;I<C;I++)g(y,I*4,D,I*4);_=D,S=v.FloatType;break;case v.HalfFloatType:C=y.length/4;const M=new Uint16Array(C*4);for(let I=0;I<C;I++)p(y,I*4,M,I*4);_=M,S=v.HalfFloatType;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:x,height:b,data:_,header:A.string,gamma:A.gamma,exposure:A.exposure,type:S}}setDataType(e){return this.type=e,this}load(e,t,i,s){function r(o,a){switch(o.type){case v.FloatType:case v.HalfFloatType:o.colorSpace=v.LinearSRGBColorSpace,o.minFilter=v.LinearFilter,o.magFilter=v.LinearFilter,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,a)}return super.load(e,r,i,s)}}function iD(){return new w.Scene}function nD(n,e){n.appendChild(e.domElement)}function sD(n,e,t){var i=new Object;i.visible=!0;let s=null,r,o,a=[];i.init=function(){r||(c(),h(),p())},i.Hide=function(){r.style.display="none",i.visible=!1},i.Show=function(){r.style.display="block",i.visible=!0},i.RenderScene=function(){if(!d){i.camera.quaternion.copy(e.camera.quaternion);const x=new w.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);i.camera.position.copy(x.multiplyScalar(100))}i.orbitControls&&i.orbitControls.update(),i.sceneOrtho.renderer.render(i.sceneOrtho,i.camera)},i.ToggleDirectionView=function(x){var b=new w.Vector3(0,0,0);x=="top"?b=new w.Vector3(0,1,1e-5):x=="down"?b=new w.Vector3(0,-1,1e-5):x=="front"?b=new w.Vector3(0,0,1):x=="left"?b=new w.Vector3(-1,0,0):x=="back"?b=new w.Vector3(0,0,-1):x=="right"?b=new w.Vector3(1,0,0):x=="top_front"?b=new w.Vector3(1,1,0):x=="top_left"?b=new w.Vector3(0,1,-1):x=="top_back"?b=new w.Vector3(-1,1,0):x=="top_right"?b=new w.Vector3(0,1,1):x=="down_front"?b=new w.Vector3(1,-1,0):x=="down_left"?b=new w.Vector3(0,-1,-1):x=="down_back"?b=new w.Vector3(-1,-1,0):x=="down_right"?b=new w.Vector3(0,-1,1):x=="front_right"?b=new w.Vector3(1,0,1):x=="right_back"?b=new w.Vector3(-1,0,1):x=="back_left"?b=new w.Vector3(-1,0,-1):x=="left_front"?b=new w.Vector3(1,0,-1):x=="top_left_front"?b=new w.Vector3(1,1,-1):x=="top_front_right"?b=new w.Vector3(1,1,1):x=="top_right_back"?b=new w.Vector3(-1,1,1):x=="top_back_left"?b=new w.Vector3(-1,1,-1):x=="button_left_front"?b=new w.Vector3(1,-1,-1):x=="button_front_right"?b=new w.Vector3(1,-1,1):x=="button_right_back"?b=new w.Vector3(-1,1,1):x=="button_back_left"&&(b=new w.Vector3(-1,-1,-1));var y=n.octreeBox.getBoundingBox(),_=y.min,S=y.max,C=_.clone().add(S.clone()).multiplyScalar(.5),D=C.clone().add(b.multiplyScalar(1*S.distanceTo(_)));l(e.camera.position,D,n.controls.target.clone(),C)},i.GetCameraPose=function(){var x=e.camera.quaternion,b=e.camera.position,y=n.controls.target,_={quaternion:x,position:b,target:y};return _},i.ReductionCameraPose=function(x,b=1e3,y){var _=new w.Quaternion(x.quaternion._x,x.quaternion._y,x.quaternion._z,x.quaternion._w),S=new w.Vector3(x.position.x,x.position.y,x.position.z),C=new w.Vector3(x.target.x,x.target.y,x.target.z);let D=!1;l(e.camera.position,S,n.controls.target.clone(),C,e.camera.quaternion,_,b,M=>{y&&(D||(y(M),D=!0))}),y&&setTimeout(()=>{D||(y(!0),D=!0)},b+10)},i.CameraGoHome=function(x=1e3){var b=n.octreeBox.getBoundingBox(),y=b.min.clone().add(b.max.clone()).multiplyScalar(.5);let _=new w.Vector3(1,1,1);var S=b.max.distanceTo(b.min),C=y.clone().add(_.multiplyScalar(S*.8));if(e.camera.isOrthographicCamera){var D=n.container.clientWidth/n.container.clientHeight,M=S*.5;e.camera.left=-M*D,e.camera.right=M*D,e.camera.top=M,e.camera.bottom=-M,e.camera.zoom=1,e.camera.updateProjectionMatrix(),e.camera.far=S*3}else e.camera.far=S*3;n.controlModule.orbitControls.origin=y.clone(),l(e.camera.position,C,n.controls.target.clone(),y,null,null,x)},i.zoomToBox=function(x){if(e.camera.isOrthographicCamera){let re=function(){s=requestAnimationFrame(re),ue.update()};var b=x.min.clone().add(x.max.clone()).multiplyScalar(.5),y=e.camera.position.clone().sub(n.controls.target.clone()).normalize(),_=e.camera.position.distanceTo(n.controls.target),S=b.clone().add(y.multiplyScalar(_)),C=e.camera.zoom,D=new w.Vector3(1,0,0).applyQuaternion(e.camera.quaternion),M=new w.Vector3(0,1,0).applyQuaternion(e.camera.quaternion),I=[new w.Vector3(x.min.x,x.min.y,x.min.z),new w.Vector3(x.max.x,x.min.y,x.min.z),new w.Vector3(x.min.x,x.max.y,x.min.z),new w.Vector3(x.max.x,x.max.y,x.min.z),new w.Vector3(x.min.x,x.min.y,x.max.z),new w.Vector3(x.max.x,x.min.y,x.max.z),new w.Vector3(x.min.x,x.max.y,x.max.z),new w.Vector3(x.max.x,x.max.y,x.max.z)],P=1/0,T=-1/0,L=1/0,E=-1/0;for(var F of I){var z=F.dot(D),X=F.dot(M);P=Math.min(P,z),T=Math.max(T,z),L=Math.min(L,X),E=Math.max(E,X)}var j=(T-P)/2,N=(E-L)/2,Y=(e.camera.right-e.camera.left)/2,V=(e.camera.top-e.camera.bottom)/2;C=Math.min(Y/j,V/N)*.75;var H=e.camera.position.clone(),oe=n.controls.target.clone(),pe=e.camera.zoom,ue=new Aa.Tween({x1:H.x,y1:H.y,z1:H.z,x2:oe.x,y2:oe.y,z2:oe.z,zoom:pe}).to({x1:S.x,y1:S.y,z1:S.z,x2:b.x,y2:b.y,z2:b.z,zoom:C},1e3);ue.onUpdate(function(de){n.controls&&(e.camera.position.set(de.x1,de.y1,de.z1),n.controls.target.set(de.x2,de.y2,de.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=de.zoom,e.camera.updateProjectionMatrix()),n.controls.auto=!0,n.controls.update(),i.RenderScene())}),ue.onComplete(function(){n.controls&&(n.controls.auto=!1,i.RenderScene(),cancelAnimationFrame(s),s=null)}),ue.easing(Aa.Easing.Cubic.InOut),ue.start(),re()}else{var b=x.min.clone().add(x.max.clone()).multiplyScalar(.5);let Ae=e.camera.position.clone().sub(n.controls.target.clone()).normalize();var S=b.clone().add(Ae.multiplyScalar(2*x.max.distanceTo(x.min)));l(e.camera.position,S,n.controls.target.clone(),b)}};function l(x,b,y,_,S,C,D=1e3,M){var I;S&&C?(I=new Aa.Tween({x1:x.x,y1:x.y,z1:x.z,x2:y.x,y2:y.y,z2:y.z,_x:S._x,_y:S._y,_z:S._z,_w:S._w}),I.to({x1:b.x,y1:b.y,z1:b.z,x2:_.x,y2:_.y,z2:_.z,_x:C._x,_y:C._y,_z:C._z,_w:C._w},D)):(I=new Aa.Tween({x1:x.x,y1:x.y,z1:x.z,x2:y.x,y2:y.y,z2:y.z}),I.to({x1:b.x,y1:b.y,z1:b.z,x2:_.x,y2:_.y,z2:_.z},D)),I.onUpdate(function(T){n.controls&&(S&&C?(e.camera.quaternion._x=T._x,e.camera.quaternion._y=T._y,e.camera.quaternion._z=T._z,e.camera.quaternion._w=T._w):n.controls.auto=!0,e.camera.position.x=T.x1,e.camera.position.y=T.y1,e.camera.position.z=T.z1,n.controls.target.x=T.x2,n.controls.target.y=T.y2,n.controls.target.z=T.z2,n.controls.update(),i.RenderScene())}),I.onComplete(function(T){n.controls&&(n.controls.auto=!1,i.RenderScene(),M&&M(!0),cancelAnimationFrame(s),s=null)}),I.easing(Aa.Easing.Cubic.InOut);function P(T){s=requestAnimationFrame(P),I.update()}I.start(),P()}function c(){r=document.createElement("div"),r.className="ViewCube",t.appendChild(r),o=document.createElement("div"),o.className="viewSettingWrapper",o.innerHTML="...";var x=document.createElement("div");x.className="homeViewWrapper",x.addEventListener("mousedown",function(){n.viewCube.cameraGoHome(500)}),r.appendChild(x),o.addEventListener("mousedown",function(_){_.stopPropagation(),cameraToggle.classList.contains("show")?(b(),console.log("隐藏功能按钮")):(y(),console.log("显示功能按钮"))});function b(){cameraToggle.classList.remove("show"),screenshot.classList.remove("show"),fullscreen.classList.remove("show")}function y(){cameraToggle.classList.add("show"),screenshot.classList.add("show"),fullscreen.classList.add("show")}}function h(){i.sceneOrtho=iD();var y=t.clientWidth,_=t.clientWidth,x=y>_?y/_:_/y,b=300;i.camera=new w.OrthographicCamera(b*x/-2,b*x/2,b/2,b/-2,.01,1e4);var y=r.clientWidth,_=r.clientHeight,S=new w.WebGLRenderer({alpha:!0});S.setSize(y,_),S.setClearAlpha(0),i.sceneOrtho.renderer=S;let C=new w.AmbientLight(16777215,.8);i.sceneOrtho.add(C),nD(r,S),i.orbitControls=new R2(i.camera,r),i.orbitControls.enableZoom=!1,i.orbitControls.enablePan=!1,i.orbitControls.enableDamping=!0,i.orbitControls.dampingFactor=.1,i.orbitControls.rotateSpeed=.5,i.orbitControls.addEventListener("start",f),i.orbitControls.addEventListener("change",u),i.orbitControls.addEventListener("end",g)}let d=!1;function f(){d=!0,n.controls&&(i._mainTarget=n.controls.target.clone(),i._mainDistance=e.camera.position.distanceTo(n.controls.target))}function u(){if(d){if(e.camera.quaternion.copy(i.camera.quaternion),n.controls&&i._mainTarget&&i._mainDistance){const x=new w.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);e.camera.position.copy(i._mainTarget.clone().add(x.multiplyScalar(i._mainDistance))),n.controls.update()}n.renderer&&e.camera&&n.renderer.render(e,e.camera)}}function g(){d=!1,i._mainTarget=null,i._mainDistance=null}function p(){const x="/assets/viewcube/";let b=[{label:"右",icon:x+"cn_right.png"},{label:"左",icon:x+"cn_left.png"},{label:"顶",icon:x+"cn_top.png"},{label:"底",icon:x+"cn_bottom.png"},{label:"前",icon:x+"cn_front.png"},{label:"后",icon:x+"cn_back.png"}];var y=[];for(const C of b)y.push(new w.MeshBasicMaterial({color:16777215,map:new w.TextureLoader().load(C.icon)}));new w.MeshLambertMaterial({color:255});var _=new w.Mesh(new w.BoxGeometry(110,110,110),y);i.sceneOrtho.add(_),m(122);let S={x:0,y:0};r.addEventListener("mousedown",C=>{S.x=C.clientX,S.y=C.clientY}),r.addEventListener("mouseup",C=>{if(d)return;const D=C.clientX-S.x,M=C.clientY-S.y;if(Math.sqrt(D*D+M*M)>5)return;var P={};P.x=C.offsetX/r.clientWidth*2-1,P.y=-(C.offsetY/r.clientHeight)*2+1;var T=new w.Raycaster;T.setFromCamera(P,i.camera);const L=T.intersectObjects(a,!1);L.length>0&&i.ToggleDirectionView(L[0].object.name)}),r.addEventListener("mousemove",C=>{var D={};D.x=C.offsetX/r.clientWidth*2-1,D.y=-(C.offsetY/r.clientHeight)*2+1;var M=new w.Raycaster;M.setFromCamera(D,i.camera);const I=M.intersectObjects(a,!1);for(var P of a)P.material.opacity=.01;I.length>0&&(I[0].object.material.opacity=.2)})}function m(x){for(var b=x*.5-20,y=[{name:"right",a:30,b:75,c:75,point:new w.Vector3(b,0,0)},{name:"back",a:75,b:75,c:30,point:new w.Vector3(0,0,-b)},{name:"left",a:30,b:75,c:75,point:new w.Vector3(-b,0,0)},{name:"front",a:75,b:75,c:30,point:new w.Vector3(0,0,b)},{name:"top",a:75,b:30,c:75,point:new w.Vector3(0,b,0)},{name:"button",a:75,b:30,c:75,point:new w.Vector3(0,-b,0)}],_=[{name:"top_right_back",a:30,b:30,c:30,point:new w.Vector3(-b,b,b)},{name:"button_front_right",a:30,b:30,c:30,point:new w.Vector3(-b,-b,b)},{name:"top_front_right",a:30,b:30,c:30,point:new w.Vector3(b,b,b)},{name:"button_right_back",a:30,b:30,c:30,point:new w.Vector3(b,-b,b)},{name:"top_back_left",a:30,b:30,c:30,point:new w.Vector3(-b,b,-b)},{name:"button_back_left",a:30,b:30,c:30,point:new w.Vector3(-b,-b,-b)},{name:"top_left_front",a:30,b:30,c:30,point:new w.Vector3(b,b,-b)},{name:"button_left_front",a:30,b:30,c:30,point:new w.Vector3(b,-b,-b)}],S=[{name:"top_front",a:30,b:30,c:75,point:new w.Vector3(b,b,0)},{name:"top_right",a:75,b:30,c:30,point:new w.Vector3(0,b,b)},{name:"top_back",a:30,b:30,c:75,point:new w.Vector3(-b,b,0)},{name:"top_left",a:75,b:30,c:30,point:new w.Vector3(0,b,-b)},{name:"button_front",a:30,b:30,c:75,point:new w.Vector3(b,-b,0)},{name:"button_right",a:75,b:30,c:30,point:new w.Vector3(0,-b,b)},{name:"button_back",a:30,b:30,c:75,point:new w.Vector3(-b,-b,0)},{name:"button_left",a:75,b:30,c:30,point:new w.Vector3(0,-b,-b)},{name:"front_right",a:30,b:75,c:30,point:new w.Vector3(b,0,b)},{name:"right_back",a:30,b:75,c:30,point:new w.Vector3(-b,0,b)},{name:"back_left",a:30,b:75,c:30,point:new w.Vector3(-b,0,-b)},{name:"left_front",a:30,b:75,c:30,point:new w.Vector3(b,0,-b)}],C=0;C<y.length;C++)a.push(A(y[C]));for(var C=0;C<_.length;C++)a.push(A(_[C]));for(var C=0;C<S.length;C++)a.push(A(S[C]))}function A(x){const b=new w.BoxGeometry(x.a,x.b,x.c),y=new w.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),_=new w.Matrix4().makeTranslation(x.point.x,x.point.y,x.point.z);let S=b.applyMatrix4(_),C=new w.Mesh(S,y);return C.name=x.name,i.sceneOrtho.add(C),C}return i.ToggleCameraType=function(){n.cameraModule.switchCurrentCamera()},i.TakeScreenshot=function(){try{if(!n.renderer){console.error("渲染器未初始化");return}n.renderer.render(e,e.camera);const b=n.renderer.domElement.toDataURL("image/png"),y=document.createElement("a"),_=new Date().toISOString().replaceAll(/[:.]/g,"-");y.download=`screenshot_${_}.png`,y.href=b,y.click(),console.log("截图已保存")}catch(x){console.error("截图失败:",x)}},i.ToggleFullscreen=function(){const x=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(x.requestFullscreen?x.requestFullscreen():x.webkitRequestFullscreen?x.webkitRequestFullscreen():x.mozRequestFullScreen?x.mozRequestFullScreen():x.msRequestFullscreen&&x.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},i}class rD{engine;cubeTool;mainViewPort;constructor(e){this.engine=e}init(){this.cubeTool=sD(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(e){if(this.mainViewPort){this.goToMainPort();return}this.cubeTool.CameraGoHome(e)}cameraGoHome(e){if(this.mainViewPort){this.goToMainPort();return}this.cubeTool.CameraGoHome(e)}zoomToModel(e){this.cubeTool.zoomToBox(e)}zoomToModels(e){try{let t=this.engine.models.find(i=>i.url==e.url);this.cubeTool.zoomToBox(t.nodesMap.get(e.id).infos[0].box)}catch{}}saveMainViewPort(){const e=this.engine.cameraModule.perspectiveCamera,t=this.engine.cameraModule.orthographicCamera,i=this.engine.controls;return this.mainViewPort={activeCamera:this.engine.cameraModule.getCameraType(),perspectiveCamera:{position:e.position.clone(),quaternion:e.quaternion.clone(),target:i.target.clone(),fov:e.fov,near:e.near,far:e.far,up:e.up.clone()},orthographicCamera:{position:t.position.clone(),quaternion:t.quaternion.clone(),target:i.target.clone(),zoom:t.zoom,left:t.left,right:t.right,top:t.top,bottom:t.bottom,near:t.near,far:t.far,up:t.up.clone()}},this.mainViewPort}setMainViewPort(e){this.mainViewPort=e,this.goToMainPort()}goToMainPort(){const e=this.mainViewPort;if(!e)return;this.engine.cameraModule.getCameraType()!==e.activeCamera&&(e.activeCamera==="orthographic"?this.engine.cameraModule.switchToOrthographicCamera():this.engine.cameraModule.switchToPerspectiveCamera());const i=e.activeCamera==="orthographic"?e.orthographicCamera:e.perspectiveCamera;if(e.activeCamera==="orthographic"){const s=this.engine.cameraModule.orthographicCamera;s.left=i.left,s.right=i.right,s.top=i.top,s.bottom=i.bottom,s.zoom=i.zoom,s.updateProjectionMatrix()}else{const s=this.engine.cameraModule.perspectiveCamera;s.fov=i.fov,s.updateProjectionMatrix()}this.engine.camera.up.copy(i.up),this.cubeTool.ReductionCameraPose(i,500)}resetMainViewPort(){this.mainViewPort=null,this.cubeTool.CameraGoHome()}screenshot(){this.cubeTool.TakeScreenshot()}}function oD(n){let e=new Object;return e.getBoundingBox=function(){let t=n.models,i=new w.Vector3(1e8,1e9,1e10),s=new w.Vector3(-1e8,-1e9,-1e10);t.forEach(d=>{let f=new w.Vector3(Math.min(d.boundingBox.min.x,d.boundingBox.max.x),Math.min(d.boundingBox.min.y,d.boundingBox.max.y),Math.min(d.boundingBox.min.z,d.boundingBox.max.z)),u=new w.Vector3(Math.max(d.boundingBox.min.x,d.boundingBox.max.x),Math.max(d.boundingBox.min.y,d.boundingBox.max.y),Math.max(d.boundingBox.min.z,d.boundingBox.max.z));f.x<i.x&&(i.x=f.x),f.y<i.y&&(i.y=f.y),f.z<i.z&&(i.z=f.z),u.x>s.x&&(s.x=u.x),u.y>s.y&&(s.y=u.y),u.z>s.z&&(s.z=u.z)});let r=Math.min(i.x,s.x),o=Math.min(i.y,s.y),a=Math.min(i.z,s.z),l=Math.max(i.x,s.x),c=Math.max(i.y,s.y),h=Math.max(i.z,s.z);return{min:new w.Vector3(r,o,a),max:new w.Vector3(l,c,h)}},e.rayInterationModel=function(t,i,s=!0){let r=[];return n.engineStatus.models.forEach(l=>{l.info.lods.forEach(c=>{let h=c.octreeBox;a(t,h,l)})}),r=r.filter(l=>l instanceof w.Mesh),s&&(r=r.filter(l=>l.geometry.attributes.position.count<1e3)),r.forEach(l=>{l.box||(l.box=new w.Box3().setFromObject(l))}),r=r.filter(l=>t.ray.intersectsBox(l.box,!1)==!0),t.intersectObjects(r,!1);function a(l,c,h){if(c==null)return;let d=new w.Vector3(c.min.X*.3048,c.min.Z*.3048,-c.min.Y*.3048),f=new w.Vector3(c.max.X*.3048,c.max.Z*.3048,-c.max.Y*.3048),u=new w.Vector3(Math.min(d.x,f.x),Math.min(d.y,f.y),Math.min(d.z,f.z)),g=new w.Vector3(Math.max(f.x,d.x),Math.max(f.y,d.y),Math.max(f.z,d.z)),p=new w.Box3(u,g),m=l.ray.intersectsBox(p);if(!(m==null||m==!1))if(c.children==null||c.children.length==0){if(c.elements!=null)for(var A of c.elements){if(!n.engineStatus.isFree&&i==!1)continue;let x=n.engineStatus.hideModels.find(S=>S.url==h.url)?.ids;if(x!=null&&x.includes(A))continue;let b=n.engineStatus.translucentModels.find(S=>S.url==h.url)?.ids;if(b!=null&&b.includes(A))continue;let _=n.models.find(S=>S.url==h.url).nodesMap.get(A);_!=null&&!_.instance&&_.infos!=null&&_.infos.map(C=>C.mesh).forEach(C=>{r.push(C)})}}else{if(c.elements!=null)for(var A of c.elements){let b=n.engineStatus.hideModels.find(C=>C.url==h.url)?.ids;if(b!=null&&b.includes(A))continue;let y=n.engineStatus.translucentModels.find(C=>C.url==h.url)?.ids;if(y!=null&&y.includes(A))continue;let S=n.models.find(C=>C.url==h.url).nodesMap.get(A);S!=null&&!S.instance&&S.infos!=null&&S.infos.map(D=>D.mesh).forEach(D=>{r.push(D)})}for(let x of c.children)a(l,x,h)}}},e}class aD{engine;isDrawing=!1;startPoint=new w.Vector2;endPoint=new w.Vector2;selectionBox=null;worldToScreen=null;boundMouseDown;boundMouseMove;boundMouseUp;boundKeyDown;constructor(e){this.engine=e,this.boundMouseDown=this.onMouseDown.bind(this),this.boundMouseMove=this.onMouseMove.bind(this),this.boundMouseUp=this.onMouseUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this)}init(){this.createSelectionBoxElement(),this.engine.scene&&this.engine.camera&&this.engine.renderer&&(this.worldToScreen=new lt(this.engine.camera,this.engine.renderer,this.engine.scene))}active(){this.engine.controlModule.disActive();const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.boundMouseDown),e.addEventListener("mousemove",this.boundMouseMove),e.addEventListener("mouseup",this.boundMouseUp),e.style.cursor="crosshair"),window.addEventListener("keydown",this.boundKeyDown)}disActive(){this.engine.controlModule.active();const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.boundMouseDown),e.removeEventListener("mousemove",this.boundMouseMove),e.removeEventListener("mouseup",this.boundMouseUp),e.style.cursor="default"),window.removeEventListener("keydown",this.boundKeyDown),this.isDrawing&&this.endDrawing()}createSelectionBoxElement(){this.selectionBox=document.createElement("div"),this.selectionBox.style.position="absolute",this.selectionBox.style.border="2px dashed #00aaff",this.selectionBox.style.backgroundColor="rgba(0, 170, 255, 0.1)",this.selectionBox.style.pointerEvents="none",this.selectionBox.style.display="none",this.selectionBox.style.zIndex="1000",this.selectionBox.style.boxSizing="border-box";const e=this.engine.renderer?.domElement;e&&e.parentElement&&e.parentElement.appendChild(this.selectionBox)}onMouseDown(e){e.button!==0||!this.engine.renderer?.domElement||(this.startPoint.set(e.offsetX,e.offsetY),this.endPoint.copy(this.startPoint),this.isDrawing=!0,this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation())}onMouseMove(e){!this.isDrawing||!this.engine.renderer?.domElement||(this.endPoint.set(e.offsetX,e.offsetY),this.updateSelectionBoxUI(),e.preventDefault(),e.stopPropagation())}onMouseUp(e){this.isDrawing&&(this.endDrawing(),this.performZoom(),e.preventDefault(),e.stopPropagation(),this.disActive())}onKeyDown(e){e.key==="Escape"&&(this.disActive(),e.preventDefault(),e.stopPropagation())}endDrawing(){this.isDrawing&&(this.isDrawing=!1,this.selectionBox&&(this.selectionBox.style.display="none"))}updateSelectionBoxUI(){if(!this.selectionBox||!this.engine.renderer?.domElement)return;const t=Math.min(this.startPoint.x,this.endPoint.x),i=Math.min(this.startPoint.y,this.endPoint.y),s=Math.abs(this.endPoint.x-this.startPoint.x),r=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${t}px`,this.selectionBox.style.top=`${i}px`,this.selectionBox.style.width=`${s}px`,this.selectionBox.style.height=`${r}px`}performZoom(){const e=Math.abs(this.endPoint.x-this.startPoint.x),t=Math.abs(this.endPoint.y-this.startPoint.y);if(e<5||t<5)return;if(!this.worldToScreen){console.warn("RangeScale: 坐标转换工具未初始化");return}const i=Math.min(this.startPoint.x,this.endPoint.x),s=Math.max(this.startPoint.x,this.endPoint.x),r=Math.min(this.startPoint.y,this.endPoint.y),o=Math.max(this.startPoint.y,this.endPoint.y),a=[],l=[{x:i,y:r},{x:s,y:r},{x:s,y:o},{x:i,y:o}];for(const h of l){const d=this.worldToScreen.screenToWorld(h.x,h.y);d&&a.push(d)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const c=new w.Box3;for(const h of a)c.expandByPoint(h);if(c.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(c)}fitCameraToBoundingBox(e){const t=this.engine.camera,i=this.engine.controls;if(!t||!i){console.warn("RangeScale: 相机或控制器未初始化");return}const s=new w.Vector3;e.getCenter(s);const r=new w.Vector3;e.getSize(r);const o=Math.max(r.x,r.y,r.z);if(t instanceof w.PerspectiveCamera){const a=t.fov*(Math.PI/180),c=o/(2*Math.tan(a/2))*1.2,h=new w.Vector3;t.getWorldDirection(h);const d=s.clone().sub(t.position);h.dot(d.normalize())<0&&h.negate();const u=s.clone().sub(h.multiplyScalar(c));t.position.copy(u),i.target&&i.target.copy(s),t.lookAt(s),i.update()}else if(t instanceof w.OrthographicCamera){const l=o*1.2,c=this.engine.renderer?.domElement,h=c?c.width/c.height:1;t.left=-l*h/2,t.right=l*h/2,t.top=l/2,t.bottom=-l/2,t.updateProjectionMatrix();const d=new w.Vector3;t.getWorldDirection(d);const f=o*1.5,u=s.clone().sub(d.multiplyScalar(f));t.position.copy(u),i.target&&i.target.copy(s),t.lookAt(s),i.update()}}}const lD=w.MathUtils.degToRad(10),lx=.001,sf=!1,cD=[];class hD{engine;rootGroup=null;isVisible=sf;axes=[];coordinateMapper=e=>new w.Vector3(e.X,e.Z,-e.Y);constructor(e){this.engine=e,this._initRoot()}setData(e=[]){this._clearAxes(),this.axes=e.map(t=>({data:t,group:null})),this.axes.forEach(t=>this._buildAxis(t))}setMockData(){const e=this.engine.models?.[0]?.grids;this.setData(Array.isArray(e)&&e.length>0?e:cD)}show(){this.isVisible=!0,this.rootGroup&&(this.rootGroup.visible=!0)}hide(){this.isVisible=!1,this.rootGroup&&(this.rootGroup.visible=!1)}toggle(){if(this.isVisible){this.hide();return}this.show()}getVisible(){return this.isVisible}update(){if(!this.isVisible||!this.rootGroup)return;const e=this.engine.camera,t=this.engine.renderer;if(!e||!t)return;let i=.5;if(e instanceof w.OrthographicCamera){const s=(e.top-e.bottom)/e.zoom,r=t.domElement.clientHeight||1;i=30*s/r}this.rootGroup.traverse(s=>{s instanceof w.Sprite&&s.scale.set(i,i,1)})}getLocationByPoint(e,t){const{url:i,targetPoint:s}=this.resolvePointLookupArgs(e,t),r=this.getGridData(i);debugger;if(r.length===0)return null;const o=this.toVector3(s),a=new w.Vector2(o.x,o.z),l=this.buildAxisFamilies(r).sort((f,u)=>u.axes.length-f.axes.length).slice(0,2).map((f,u)=>({...f,familyIndex:u}));if(l.length===0)return null;const c=l.map(f=>this.resolveFamilyLocation(f,a)),h=this.sortFamiliesForDisplay(c),d=h.length===2&&h.every(f=>f.isInside);return{point:{x:o.x,y:o.y,z:o.z},description:this.formatGridDescription(h),families:h,isInside:d}}dispose(){this._clearAxes(),this.rootGroup&&(this.engine.scene&&this.engine.scene.remove(this.rootGroup),this.rootGroup=null)}_initRoot(){this.rootGroup=new w.Group,this.rootGroup.name="GridRoot",this.rootGroup.visible=sf,this.engine.scene&&this.engine.scene.add(this.rootGroup)}_clearAxes(){this.axes.forEach(e=>{e.group&&(this.rootGroup?.remove(e.group),e.group.traverse(t=>{const i=t;if("geometry"in i&&i.geometry&&i.geometry.dispose(),"material"in i&&i.material){const s=i.material;"map"in s&&s.map&&s.map.dispose(),s.dispose()}}),e.group=null)}),this.axes=[]}_buildAxis(e){if(!this.rootGroup)return;const t=this.coordinateMapper(e.data.Points[0]),i=this.coordinateMapper(e.data.Points[1]),s=new w.Group;s.name=`GridAxis_${e.data.Id}`;const r=new w.BufferGeometry().setFromPoints([t,i]),o=new w.LineBasicMaterial({color:1609983,depthTest:!1}),a=new w.Line(r,o);a.renderOrder=998,s.add(a),s.add(this._makeCircleSprite(e.data.Name,t)),s.add(this._makeCircleSprite(e.data.Name,i)),this.rootGroup.add(s),e.group=s}_makeCircleSprite(e,t){const s=document.createElement("canvas");s.width=128,s.height=128;const r=s.getContext("2d");if(!r)throw new Error("Grid sprite canvas context is not available");const o=128/2,a=128/2,l=128/2-4;r.beginPath(),r.arc(o,a,l,0,Math.PI*2),r.fillStyle="white",r.fill(),r.strokeStyle="#1890ff",r.lineWidth=6,r.stroke(),r.fillStyle="#1890ff",r.font=`bold ${Math.round(128*.38)}px Arial`,r.textAlign="center",r.textBaseline="middle",r.fillText(e,o,a);const c=new w.CanvasTexture(s),h=new w.SpriteMaterial({map:c,depthTest:!1,transparent:!0}),d=new w.Sprite(h);return d.position.copy(t),d.scale.set(.5,.5,1),d.renderOrder=999,d}getGridData(e){if(e){const i=this.findModelByUrl(e);return Array.isArray(i?.grids)?i.grids:[]}if(this.axes.length>0)return this.axes.map(i=>i.data);if(!Array.isArray(this.engine.models))return[];const t=[];return this.engine.models.forEach(i=>{Array.isArray(i.grids)&&t.push(...i.grids)}),t}resolvePointLookupArgs(e,t){if(typeof e=="string"){if(!t)throw new Error("Grid.getLocationByPoint(url, point) requires a point argument.");return{url:e,targetPoint:t}}return{targetPoint:e}}findModelByUrl(e){return this.engine.models?.find(t=>t.url===e)}buildAxisFamilies(e){const t=[];return e.forEach(i=>{const s=this.createProjection(i);if(!s)return;const r=t.find(o=>o.direction.angleTo(s.direction)<=lD);if(r){r.axes.push(s);return}t.push({familyIndex:t.length,direction:s.direction.clone(),normal:new w.Vector2(-s.direction.y,s.direction.x),axes:[s]})}),t.forEach(i=>{i.axes.sort((s,r)=>s.offset-r.offset)}),t}createProjection(e){const t=this.coordinateMapper(e.Points[0]),i=this.coordinateMapper(e.Points[1]),s=new w.Vector2(t.x,t.z),r=new w.Vector2(i.x,i.z),o=r.clone().sub(s);if(o.lengthSq()<=Number.EPSILON)return null;const a=this.normalizeDirection(o),l=new w.Vector2(-a.y,a.x);return{data:e,start:s,end:r,direction:a,offset:s.dot(l)}}normalizeDirection(e){const t=e.clone().normalize();return(t.x<0||Math.abs(t.x)<=lx&&t.y<0)&&t.multiplyScalar(-1),t}resolveFamilyLocation(e,t){const i=t.dot(e.normal),s=e.axes.find(c=>Math.abs(c.offset-i)<=lx)??null;if(s){const c=e.axes.findIndex(d=>d.data.Id===s.data.Id),h=this.pickAxisPairAroundIndex(e.axes,c);return{familyIndex:e.familyIndex,description:h?this.formatAxisPair(h[0].data.Name,h[1].data.Name):s.data.Name,startAxisName:h?.[0].data.Name??s.data.Name,endAxisName:h?.[1].data.Name??s.data.Name,axisName:s.data.Name,pointOffset:i,isOnAxis:!0,isInside:h!==null}}let r=null,o=null;e.axes.forEach(c=>{if(c.offset<i){r=c;return}o||(o=c)});let a="",l=!1;if(r&&o)a=this.formatAxisPair(r.data.Name,o.data.Name),l=!0;else{const c=this.pickNearestBoundaryPair(e.axes,i);c&&(a=this.formatAxisPair(c[0].data.Name,c[1].data.Name))}return{familyIndex:e.familyIndex,description:a,startAxisName:r?.data.Name??null,endAxisName:o?.data.Name??null,axisName:null,pointOffset:i,isOnAxis:!1,isInside:l}}pickAxisPairAroundIndex(e,t){const i=e[t],s=t>0?e[t-1]:null,r=t<e.length-1?e[t+1]:null;if(!i)return null;if(s&&r){const o=Math.abs(i.offset-s.offset),a=Math.abs(r.offset-i.offset);return o<=a?[s,i]:[i,r]}return s?[s,i]:r?[i,r]:null}pickNearestBoundaryPair(e,t){if(e.length<2)return null;const i=[e[0],e[1]],s=[e[e.length-2],e[e.length-1]],r=Math.min(Math.abs(t-i[0].offset),Math.abs(t-i[1].offset)),o=Math.min(Math.abs(t-s[0].offset),Math.abs(t-s[1].offset));return r<=o?i:s}sortFamiliesForDisplay(e){return[...e].sort((t,i)=>{const s=this.getFamilySampleLabel(t),r=this.getFamilySampleLabel(i),o=this.isNumericLabel(s),a=this.isNumericLabel(r);return o!==a?o?1:-1:this.compareLabels(s,r)})}getFamilySampleLabel(e){return e.axisName??e.startAxisName??e.endAxisName??""}formatAxisPair(e,t){return this.compareLabels(e,t)<=0?`${e}-${t}`:`${t}-${e}`}formatGridDescription(e){if(e.length!==2)return"";const t=e.map(i=>i.description).filter(i=>i.length>0);return t.length!==2?"":`${t[0]}交${t[1]}`}compareLabels(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}isNumericLabel(e){return/^\d/.test(e.trim())}toVector3(e){return e instanceof w.Vector3?e.clone():new w.Vector3(e.x,e.y,e.z)}}class dD extends v.Mesh{constructor(e,t={}){super(e),this.isWater=!0;const i=this,s=t.textureWidth!==void 0?t.textureWidth:512,r=t.textureHeight!==void 0?t.textureHeight:512,o=t.clipBias!==void 0?t.clipBias:0,a=t.alpha!==void 0?t.alpha:1,l=t.time!==void 0?t.time:0,c=t.waterNormals!==void 0?t.waterNormals:null,h=t.sunDirection!==void 0?t.sunDirection:new v.Vector3(.70707,.70707,0),d=new v.Color(t.sunColor!==void 0?t.sunColor:16777215),f=new v.Color(t.waterColor!==void 0?t.waterColor:8355711),u=t.eye!==void 0?t.eye:new v.Vector3(0,0,0),g=t.distortionScale!==void 0?t.distortionScale:20,p=t.side!==void 0?t.side:v.FrontSide,m=t.fog!==void 0?t.fog:!1,A=new v.Plane,x=new v.Vector3,b=new v.Vector3,y=new v.Vector3,_=new v.Matrix4,S=new v.Vector3(0,0,-1),C=new v.Vector4,D=new v.Vector3,M=new v.Vector3,I=new v.Vector4,P=new v.Matrix4,T=new v.PerspectiveCamera,L=new v.WebGLRenderTarget(s,r,{type:v.HalfFloatType}),E={name:"MirrorShader",uniforms:v.UniformsUtils.merge([v.UniformsLib.fog,v.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new v.Matrix4},sunColor:{value:new v.Color(8355711)},sunDirection:{value:new v.Vector3(.70707,.70707,0)},eye:{value:new v.Vector3},waterColor:{value:new v.Color(5592405)}}]),vertexShader:`
|
|
4946
4946
|
uniform mat4 textureMatrix;
|
|
4947
4947
|
uniform float time;
|
|
4948
4948
|
|
|
@@ -6053,7 +6053,7 @@ void main() {
|
|
|
6053
6053
|
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
|
6054
6054
|
gl_FragColor = color;
|
|
6055
6055
|
}
|
|
6056
|
-
`}applyTo2d({imageData:{data:n}}){let e=-this.vibrance;for(let t=0;t<n.length;t+=4){let i=n[t],s=n[t+1],r=n[t+2],o=Math.max(i,s,r),a=(i+s+r)/3,l=2*Math.abs(o-a)/255*e;n[t]+=o===i?0:(o-i)*l,n[t+1]+=o===s?0:(o-s)*l,n[t+2]+=o===r?0:(o-r)*l}}sendUniformData(n,e){n.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}};$(dl,"type","Vibrance"),$(dl,"defaults",{vibrance:0}),$(dl,"uniformLocations",["uVibrance"]),Re.setClass(dl),La({BaseFilter:()=>Nt,BlackWhite:()=>bR,BlendColor:()=>$a,BlendImage:()=>Ja,Blur:()=>Za,Brightness:()=>el,Brownie:()=>fR,ColorMatrix:()=>kr,Composed:()=>Wp,Contrast:()=>tl,Convolute:()=>il,Gamma:()=>nl,Grayscale:()=>sl,HueRotation:()=>zh,Invert:()=>rl,Kodachrome:()=>gR,Noise:()=>ol,Pixelate:()=>al,Polaroid:()=>AR,RemoveColor:()=>ll,Resize:()=>cl,Saturation:()=>hl,Sepia:()=>xR,Technicolor:()=>mR,Vibrance:()=>dl,Vintage:()=>pR});function wR(n,e,t="bim-snapshot.png"){const i=n?.renderer,s=i?.domElement;if(!i||!s||!e)return null;const r=s.width||s.clientWidth,o=s.height||s.clientHeight;if(r<=0||o<=0)return null;let a=SR(s,r,o);if(!CR(a)){const f=MR(n,r,o);f&&(a=f)}const l=document.createElement("canvas");l.width=r,l.height=o;const c=l.getContext("2d");if(!c)return null;c.drawImage(a,0,0,r,o),c.drawImage(e,0,0,r,o);const h=l.toDataURL("image/png"),d=document.createElement("a");return d.href=h,d.download=t.toLowerCase().endsWith(".png")?t:`${t}.png`,d.click(),h}function SR(n,e,t){const i=document.createElement("canvas");i.width=e,i.height=t;const s=i.getContext("2d");return s&&s.drawImage(n,0,0,e,t),i}function CR(n){const e=n.getContext("2d");if(!e||n.width<=0||n.height<=0)return!1;const t=Math.min(32,n.width),i=Math.min(32,n.height),s=Math.max(1,Math.floor(n.width/t)),r=Math.max(1,Math.floor(n.height/i));for(let o=0;o<n.height;o+=r)for(let a=0;a<n.width;a+=s){const l=e.getImageData(a,o,1,1).data;if(l[0]!==0||l[1]!==0||l[2]!==0||l[3]!==0)return!0}return!1}function MR(n,e,t){const i=n?.renderer,s=n?.scene,r=n?.camera;if(!i||!s||!r)return null;const o=new w.WebGLRenderTarget(e,t,{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat,depthBuffer:!0,stencilBuffer:!0}),a=i.getRenderTarget(),l=i.autoClear,c=i.xr?.enabled??!1;try{i.xr&&(i.xr.enabled=!1),i.autoClear=!0,i.setRenderTarget(o),i.clear(!0,!0,!0),i.render(s,r);const h=new Uint8Array(e*t*4);return i.readRenderTargetPixels(o,0,0,e,t,h),ER(h,e,t)}catch{return null}finally{i.setRenderTarget(a),i.autoClear=l,i.xr&&(i.xr.enabled=c),o.dispose()}}function ER(n,e,t){const i=document.createElement("canvas");i.width=e,i.height=t;const s=i.getContext("2d");if(!s)return i;const r=s.createImageData(e,t),o=e*4;for(let a=0;a<t;a++){const l=(t-1-a)*o,c=a*o;for(let h=0;h<o;h++)r.data[c+h]=n[l+h]}return s.putImageData(r,0,0),i}const IR={none:new URL("/assets/icon/%E9%80%89%E6%8B%A9.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,line:new URL("/assets/icon/%E7%BA%BF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,arrow:new URL("/assets/icon/%E7%AE%AD%E5%A4%B4.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,rect:new URL("/assets/icon/%E7%9F%A9%E5%BD%A2.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,circle:new URL("/assets/icon/%E5%9C%86%E5%BD%A2.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,text:new URL("/assets/icon/%E6%96%87%E5%AD%97.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,cloudline:new URL("/assets/icon/%E4%BA%91%E7%BA%BF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href},TR=new URL("/assets/icon/%E6%B5%8B%E8%B7%9D.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,DR=new URL("/assets/icon/%E6%88%AA%E5%9B%BE.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,BR=new URL("/assets/icon/%E7%BA%BF%E5%AE%BD.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,PR=new URL("/assets/icon/%E5%AD%97%E5%8F%B7.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,LR=[{type:"distance",label:"距离"},{type:"clearDistance",label:"垂距"},{type:"clearHeight",label:"净高"},{type:"elevation",label:"标高"},{type:"point",label:"坐标"},{type:"angle",label:"角度"},{type:"area",label:"面积"},{type:"slope",label:"坡度"}],RR={distance:new URL("/assets/icon/%E8%B7%9D%E7%A6%BB.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,clearDistance:new URL("/assets/icon/%E5%87%80%E8%B7%9D.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,clearHeight:new URL("/assets/icon/%E5%87%80%E9%AB%98.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,elevation:new URL("/assets/icon/%E6%A0%87%E9%AB%98.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,point:new URL("/assets/icon/%E5%9D%90%E6%A0%87.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,angle:new URL("/assets/icon/%E8%A7%92%E5%BA%A6.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,area:new URL("/assets/icon/%E9%9D%A2%E7%A7%AF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,slope:new URL("/assets/icon/%E5%9D%A1%E5%BA%A6.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href};class kR{constructor(e,t){this.handlers=e,this.root=document.createElement("div"),this.root.style.position="absolute",this.root.style.top="8px",this.root.style.left="50%",this.root.style.transform="translateX(-50%)",this.root.style.display="none",this.root.style.padding="6px",this.root.style.background="#ffffff",this.root.style.border="1px solid #d9d9d9",this.root.style.borderRadius="8px",this.root.style.pointerEvents="auto",this.root.style.userSelect="none",this.root.style.boxShadow="0 4px 14px rgba(0, 0, 0, 0.12)",this.root.style.zIndex="1300",this.editPanel=document.createElement("div"),this.editPanel.style.display="flex",this.editPanel.style.flexDirection="column",this.editPanel.style.gap="6px",this.viewPanel=document.createElement("div"),this.viewPanel.style.display="none",this.viewPanel.style.alignItems="center",this.viewPanel.style.gap="6px";const i=document.createElement("div");i.style.display="flex",i.style.alignItems="center",i.style.gap="6px",i.style.flexWrap="wrap",[{type:"none",label:"选择"},{type:"line",label:"线"},{type:"arrow",label:"箭头"},{type:"rect",label:"矩形"},{type:"circle",label:"圆形"},{type:"text",label:"文字"},{type:"cloudline",label:"云线"}].forEach(c=>{const h=this.createIconButton(c.label,IR[c.type]);h.onclick=()=>this.handlers.onDrawTypeChange(c.type),this.drawButtons[c.type]=h,i.appendChild(h)}),this.colorInput=document.createElement("input"),this.colorInput.type="color",this.colorInput.value=t.stroke,this.colorInput.style.width="32px",this.colorInput.style.height="24px",this.colorInput.style.padding="0",this.colorInput.style.border="1px solid #d9d9d9",this.colorInput.style.borderRadius="4px",this.colorInput.style.background="#ffffff",this.colorInput.oninput=()=>this.handlers.onColorChange(this.colorInput.value),i.appendChild(this.createField("",this.colorInput)),this.strokeWidthInput=document.createElement("input"),this.strokeWidthInput.type="number",this.strokeWidthInput.min="1",this.strokeWidthInput.max="20",this.strokeWidthInput.step="1",this.strokeWidthInput.value=String(t.strokeWidth),this.strokeWidthInput.style.width="46px",this.strokeWidthInput.oninput=()=>this.handlers.onStrokeWidthChange(this.strokeWidthInput.value),i.appendChild(this.createField("",this.strokeWidthInput,BR,"线宽")),this.fontSizeInput=document.createElement("input"),this.fontSizeInput.type="number",this.fontSizeInput.min="10",this.fontSizeInput.max="96",this.fontSizeInput.step="1",this.fontSizeInput.value=String(t.fontSize),this.fontSizeInput.style.width="46px",this.fontSizeInput.oninput=()=>this.handlers.onFontSizeChange(this.fontSizeInput.value),i.appendChild(this.createField("",this.fontSizeInput,PR,"字号")),this.distanceButton=this.createIconButton("测量",TR),this.distanceButton.onclick=()=>this.handlers.onMeasureToggle(),i.appendChild(this.distanceButton);const r=this.createIconButton("截图",DR);r.onclick=()=>this.handlers.onScreenshot(),i.appendChild(r);const o=this.createTextButton("×","取消");o.onclick=()=>this.handlers.onCancel(),o.style.background="#ff4d4f",o.style.borderColor="#ff4d4f",o.style.color="#ffffff",i.appendChild(o);const a=this.createTextButton("✔","确定");a.onclick=()=>this.handlers.onConfirm(),a.style.background="#52c41a",a.style.borderColor="#52c41a",a.style.color="#ffffff",i.appendChild(a),this.measureSubPanel=document.createElement("div"),this.measureSubPanel.style.display="none",this.measureSubPanel.style.alignItems="center",this.measureSubPanel.style.gap="6px",this.measureSubPanel.style.flexWrap="wrap",this.measureSubPanel.style.paddingTop="2px",LR.forEach(c=>{const h=this.createSmallIconButton(c.label,RR[c.type]);h.onclick=()=>this.handlers.onMeasureTypeChange(c.type),this.measureTypeButtons[c.type]=h,this.measureSubPanel.appendChild(h)}),this.editPanel.appendChild(i),this.editPanel.appendChild(this.measureSubPanel);const l=this.createTextButton("关闭","关闭");l.onclick=()=>this.handlers.onClose(),this.viewPanel.appendChild(l),this.root.appendChild(this.editPanel),this.root.appendChild(this.viewPanel),this.setMode("edit")}root;drawButtons={};measureTypeButtons={};distanceButton;colorInput;strokeWidthInput;fontSizeInput;editPanel;viewPanel;measureSubPanel;mode="edit";mount(e){e.appendChild(this.root)}show(){this.root.style.display="block"}hide(){this.root.style.display="none"}setMode(e){this.mode=e,this.editPanel.style.display=e==="edit"?"flex":"none",this.viewPanel.style.display=e==="view"?"flex":"none",e==="view"&&this.setMeasurePanelVisible(!1)}setDrawType(e){for(const t in this.drawButtons){const i=this.drawButtons[t];if(!i)continue;const s=t===e;i.style.background=s?"#eaf2ff":"#ffffff",i.style.borderColor=s?"#2f80ed":"#d9d9d9"}}setMeasurePanelVisible(e){if(this.mode!=="edit"){this.measureSubPanel.style.display="none";return}this.measureSubPanel.style.display=e?"flex":"none"}setMeasureState(e,t){this.distanceButton.style.background=e?"#eaf2ff":"#ffffff",this.distanceButton.style.borderColor=e?"#2f80ed":"#d9d9d9";for(const i in this.measureTypeButtons){const s=this.measureTypeButtons[i];if(!s)continue;const r=e&&t===i;s.style.background=r?"#eaf2ff":"#ffffff",s.style.borderColor=r?"#2f80ed":"#d9d9d9"}}setStyleValues(e){e.stroke&&(this.colorInput.value=e.stroke),typeof e.strokeWidth=="number"&&(this.strokeWidthInput.value=String(e.strokeWidth)),typeof e.fontSize=="number"&&(this.fontSizeInput.value=String(e.fontSize))}dispose(){this.colorInput.oninput=null,this.strokeWidthInput.oninput=null,this.fontSizeInput.oninput=null,this.root.remove()}createField(e,t,i,s=""){const r=document.createElement("div");if(r.style.display="flex",r.style.alignItems="center",r.style.gap="4px",r.style.padding="0 2px",r.style.color="#333333",r.style.fontSize="12px",e){const o=document.createElement("span");o.textContent=e,r.appendChild(o)}if(i){const o=document.createElement("img");o.src=i,o.alt=s,o.style.width="14px",o.style.height="14px",o.style.display="block",r.appendChild(o)}return t.style.height="24px",t.style.border="1px solid #d9d9d9",t.style.borderRadius="4px",t.style.background="#ffffff",t.style.color="#333333",t.style.outline="none",t.style.padding="0 4px",r.appendChild(t),r}createIconButton(e,t){const i=document.createElement("button");i.type="button",i.style.width="28px",i.style.height="28px",i.style.padding="0",i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.border="1px solid #d9d9d9",i.style.borderRadius="4px",i.style.background="#ffffff",i.style.cursor="pointer";const s=document.createElement("img");return s.src=t,s.alt=e,s.style.width="16px",s.style.height="16px",s.style.display="block",i.appendChild(s),i}createSmallIconButton(e,t){const i=document.createElement("button");i.type="button",i.style.width="26px",i.style.height="26px",i.style.padding="0",i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.border="1px solid #d9d9d9",i.style.borderRadius="4px",i.style.background="#ffffff",i.style.cursor="pointer";const s=document.createElement("img");return s.src=t,s.alt=e,s.style.width="14px",s.style.height="14px",s.style.display="block",i.appendChild(s),i}createTextButton(e,t){const i=document.createElement("button");return i.type="button",i.textContent=e,i.style.height="28px",i.style.padding="0 10px",i.style.border="1px solid #d9d9d9",i.style.borderRadius="4px",i.style.background="#ffffff",i.style.color="#333333",i.style.fontSize="13px",i.style.lineHeight="1",i.style.cursor="pointer",i}}class FR{engine;wrapper;canvasEl;canvas;toolbar;isActive=!1;isVisible=!0;isDistanceMeasureMode=!1;isMeasurePanelExpanded=!1;drawType="none";mode="edit";currentMeasureType=null;sessionSnapshot=null;actionHandlers={};drawStyle={stroke:"#ff4d4f",strokeWidth:2,fill:"rgba(255, 77, 79, 0.08)",fontSize:16,text:"文本",cloudRadius:10};startPoint=null;tempObject=null;cloudPoints=[];onMouseDown=e=>this.handleMouseDown(e);onMouseMove=e=>this.handleMouseMove(e);onMouseUp=e=>this.handleMouseUp(e);onMouseDblClick=e=>this.handleMouseDblClick(e);onSelectionChanged=()=>this.syncStyleFromSelection();onKeyDown=e=>this.handleKeyDown(e);constructor(e){this.engine=e;const t=this.engine.container;if(!t)throw new Error("FabricDraw: engine container not found.");this.wrapper=document.createElement("div"),this.wrapper.className="fabric-draw-layer",this.wrapper.style.position="absolute",this.wrapper.style.left="0",this.wrapper.style.top="0",this.wrapper.style.right="0",this.wrapper.style.bottom="0",this.wrapper.style.zIndex="1200",this.wrapper.style.pointerEvents="none",this.canvasEl=document.createElement("canvas"),this.canvasEl.style.width="100%",this.canvasEl.style.height="100%",this.wrapper.appendChild(this.canvasEl),this.toolbar=new kR({onDrawTypeChange:i=>this.setDrawType(i),onMeasureToggle:()=>this.toggleMeasurePanel(),onMeasureTypeChange:i=>this.activateDistanceMeasure(i),onScreenshot:()=>{this.saveScreenshot(this.createScreenshotFileName())},onColorChange:i=>this.handleColorInputChange(i),onStrokeWidthChange:i=>this.handleStrokeWidthInputChange(i),onFontSizeChange:i=>this.handleFontSizeInputChange(i),onCancel:()=>{this.handleCancelClick()},onConfirm:()=>this.handleConfirmClick(),onClose:()=>{this.handleCloseClick()}},{stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,fontSize:this.drawStyle.fontSize}),this.toolbar.mount(this.wrapper),t.appendChild(this.wrapper),this.canvas=new Op(this.canvasEl,{selection:!0,preserveObjectStacking:!0}),this.resize(),this.canvas.on("mouse:down",this.onMouseDown),this.canvas.on("mouse:move",this.onMouseMove),this.canvas.on("mouse:up",this.onMouseUp),this.canvas.on("mouse:dblclick",this.onMouseDblClick),this.canvas.on("selection:created",this.onSelectionChanged),this.canvas.on("selection:updated",this.onSelectionChanged),this.canvas.on("selection:cleared",this.onSelectionChanged),window.addEventListener("keydown",this.onKeyDown),this.refreshToolbarState()}active(e="edit"){this.isActive=!0,this.mode=e,this.drawType="none",this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.canvas.defaultCursor="default",this.sessionSnapshot=e==="edit"?this.cloneJson(this.getAllShapes()):null,this.toolbar.setMode(e),this.applyCanvasInteractive(e==="edit"),this.isVisible&&this.toolbar.show(),this.updateOverlayPointerEvents(),this.refreshToolbarState()}disActive(){this.isActive=!1,this.startPoint=null,this.cloudPoints=[],this.tempObject=null,this.drawType="none",this.mode="edit",this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.sessionSnapshot=null,this.stopDistanceMeasureMode(),this.canvas.defaultCursor="default",this.canvas.discardActiveObject(),this.applyCanvasInteractive(!0),this.canvas.requestRenderAll(),this.toolbar.setMode("edit"),this.toolbar.hide(),this.updateOverlayPointerEvents(),this.refreshToolbarState()}close(){this.disActive()}hide(){this.isVisible=!1,this.wrapper.style.display="none",this.toolbar.hide()}show(){this.isVisible=!0,this.wrapper.style.display="block",this.isActive&&this.toolbar.show(),this.resize()}isShown(){return this.isVisible}setDrawType(e,t){this.mode!=="view"&&(this.stopDistanceMeasureMode(),this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.drawType=e,t&&(this.drawStyle={...this.drawStyle,...t}),this.canvas.defaultCursor=e==="none"?"default":"crosshair",this.updateOverlayPointerEvents(),this.refreshToolbarState())}getDrawType(){return this.drawType}setActionHandlers(e){this.actionHandlers={...e}}drawLine(e,t,i){const s=this.mergeStyle(i),r=this.createLineObject(e,t,s,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawArrow(e,t,i){const s=this.mergeStyle(i),r=this.createArrowObject(e,t,s,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawRect(e,t,i){const s=this.mergeStyle(i),r=this.createRectObject(e,t,s,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawCircle(e,t,i){const s=this.mergeStyle(i),r=this.createCircleObject(e,t,s,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawText(e,t,i){const s=this.mergeStyle(i),r=new Lr(t??s.text,{left:e.x,top:e.y,fontSize:s.fontSize,fill:s.stroke,selectable:!0,evented:!0,objectCaching:!1});return r.annotationType="text",this.canvas.add(r),this.canvas.requestRenderAll(),r}drawCloudLine(e,t){if(e.length<2)return null;const i=this.mergeStyle(t),s=this.createCloudObject(e,i,!0);return s?(this.canvas.add(s),this.canvas.requestRenderAll(),s):null}getAllShapes(){return this.canvas.toObject(["annotationType"])}clearAllShapes(){this.canvas.clear(),this.canvas.requestRenderAll()}async restoreAllShapes(e){await this.canvas.loadFromJSON(e),this.canvas.requestRenderAll()}saveScreenshot(e="bim-snapshot.png"){const t=this.canvas.lowerCanvasEl;return t?wR(this.engine,t,e):null}resize(e,t){const i=this.engine.container;if(!i)return;const s=e??i.clientWidth??1,r=t??i.clientHeight??1;this.canvas.setDimensions({width:s,height:r}),this.canvas.requestRenderAll()}dispose(){this.stopDistanceMeasureMode(),window.removeEventListener("keydown",this.onKeyDown),this.canvas.off("mouse:down",this.onMouseDown),this.canvas.off("mouse:move",this.onMouseMove),this.canvas.off("mouse:up",this.onMouseUp),this.canvas.off("mouse:dblclick",this.onMouseDblClick),this.canvas.off("selection:created",this.onSelectionChanged),this.canvas.off("selection:updated",this.onSelectionChanged),this.canvas.off("selection:cleared",this.onSelectionChanged),this.toolbar.dispose(),this.canvas.dispose(),this.wrapper.remove()}handleMouseDown(e){if(!this.isActive||this.mode==="view"||this.drawType==="none"||e?.target)return;const t=this.getPointFromEvent(e);if(this.drawType==="text"){const s=this.drawText(t);this.canvas.setActiveObject(s),this.canvas.requestRenderAll(),setTimeout(()=>{s.enterEditing(),s.hiddenTextarea?.focus(),s.selectAll()},0);return}this.startPoint=t,this.cloudPoints=[t],this.canvas.selection=!1,this.canvas.discardActiveObject();const i=this.createDraftObject(t,t);i&&(this.tempObject=i,this.canvas.add(i),this.canvas.requestRenderAll())}handleMouseMove(e){if(!this.isActive||this.mode==="view"||!this.startPoint||!this.tempObject)return;const t=this.getPointFromEvent(e),i=this.drawStyle;if(this.drawType==="cloudline"){if(this.shouldAppendCloudPoint(t)){this.cloudPoints.push(t),this.canvas.remove(this.tempObject);const s=this.createCloudObject(this.cloudPoints,i,!1);if(!s)return;this.tempObject=s,this.canvas.add(s),this.canvas.requestRenderAll()}return}if(this.drawType==="arrow"){this.canvas.remove(this.tempObject),this.tempObject=this.createArrowObject(this.startPoint,t,i,!1),this.canvas.add(this.tempObject),this.canvas.requestRenderAll();return}this.updateDraftObject(this.startPoint,t),this.canvas.requestRenderAll()}handleMouseUp(e){if(!this.isActive||this.mode==="view"||!this.startPoint)return;const t=this.getPointFromEvent(e);this.drawType==="cloudline"&&this.cloudPoints.length===1&&(this.cloudPoints.push(t),this.canvas.remove(this.tempObject),this.tempObject=this.createCloudObject(this.cloudPoints,this.drawStyle,!0),this.tempObject&&this.canvas.add(this.tempObject)),this.tempObject&&(this.tempObject.set({selectable:!0,evented:!0}),this.tempObject.setCoords?.(),this.canvas.requestRenderAll()),this.startPoint=null,this.tempObject=null,this.cloudPoints=[],this.canvas.selection=!0}handleMouseDblClick(e){const t=e?.target;this.isTextObject(t)&&(t.enterEditing(),t.hiddenTextarea?.focus(),t.selectAll?.())}handleKeyDown(e){if(!this.isActive)return;const t=this.canvas.getActiveObject();if(this.isTextObject(t)&&t?.isEditing||this.isInputElement(e.target))return;if(e.key==="Escape"){e.preventDefault(),this.mode==="view"?this.handleCloseClick():this.handleCancelClick();return}if(e.key==="Enter"){this.mode==="edit"&&(e.preventDefault(),this.handleConfirmClick());return}if(e.key!=="Delete"&&e.key!=="Backspace"||!t)return;e.preventDefault(),this.canvas.getActiveObjects().forEach(r=>this.canvas.remove(r)),this.canvas.discardActiveObject(),this.canvas.requestRenderAll()}getPointFromEvent(e){if(e?.e){const i=this.canvas.getScenePoint(e.e);return{x:i.x,y:i.y}}const t=e?.scenePoint??e?.pointer??e?.absolutePointer;return t?{x:t.x,y:t.y}:{x:0,y:0}}shouldAppendCloudPoint(e){if(this.cloudPoints.length===0)return!0;const t=this.cloudPoints[this.cloudPoints.length-1],i=e.x-t.x,s=e.y-t.y;return Math.sqrt(i*i+s*s)>=6}createDraftObject(e,t){const i=this.drawStyle;switch(this.drawType){case"line":return this.createLineObject(e,t,i,!1);case"arrow":return this.createArrowObject(e,t,i,!1);case"rect":return this.createRectObject(e,t,i,!1);case"circle":return this.createCircleObject(e,t,i,!1);case"cloudline":return this.createCloudObject([e,t],i,!1);default:return null}}updateDraftObject(e,t){if(this.tempObject){if(this.drawType==="line"){this.tempObject.set({x2:t.x,y2:t.y});return}if(this.drawType==="rect"){const i=this.getBoxFromPoints(e,t);this.tempObject.set({left:i.left,top:i.top,width:i.width,height:i.height});return}if(this.drawType==="circle"){const i=this.getCircleFromPoints(e,t);this.tempObject.set({left:i.left,top:i.top,radius:i.radius})}}}mergeStyle(e){return{...this.drawStyle,...e??{}}}createObjectBase(e,t){return{stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,selectable:t,evented:t,objectCaching:!1}}createLineObject(e,t,i,s){const r=new Qs([e.x,e.y,t.x,t.y],{...this.createObjectBase(i,s),fill:"",strokeLineCap:"round"});return r.annotationType="line",r}createRectObject(e,t,i,s){const r=this.getBoxFromPoints(e,t),o=new zs({...this.createObjectBase(i,s),left:r.left,top:r.top,width:r.width,height:r.height,originX:"left",originY:"top"});return o.annotationType="rect",o}createCircleObject(e,t,i,s){const r=this.getCircleFromPoints(e,t),o=new Pr({...this.createObjectBase(i,s),left:r.left,top:r.top,radius:r.radius,originX:"left",originY:"top"});return o.annotationType="circle",o}createArrowObject(e,t,i,s){const r=t.x-e.x,o=t.y-e.y,a=Math.sqrt(r*r+o*o);if(a<1e-6){const D=new Qs([e.x,e.y,t.x,t.y],{stroke:i.stroke,strokeWidth:i.strokeWidth,fill:"",selectable:s,evented:s}),M=new Gs([D],{selectable:s,evented:s,objectCaching:!1});return M.annotationType="arrow",M}const l=r/a,c=o/a,h=-c,d=l,f=Math.max(10,i.strokeWidth*6),u=f*.72,g=t.x-l*f,p=t.y-c*f,m=g+h*(u*.5),A=p+d*(u*.5),x=g-h*(u*.5),b=p-d*(u*.5),y=new Qs([e.x,e.y,t.x,t.y],{stroke:i.stroke,strokeWidth:i.strokeWidth,fill:"",strokeLineCap:"round",selectable:!1,evented:!1}),_=`M ${t.x} ${t.y} L ${m} ${A} L ${x} ${b} Z`,S=new Br(_,{fill:i.stroke,stroke:i.stroke,strokeWidth:1,selectable:!1,evented:!1,objectCaching:!1}),C=new Gs([y,S],{selectable:s,evented:s,objectCaching:!1});return C.annotationType="arrow",C}createCloudObject(e,t,i){const s=this.buildCloudPath(e,t.cloudRadius);if(!s)return null;const r=new Br(s,{stroke:t.stroke,strokeWidth:t.strokeWidth,fill:"",strokeLineCap:"round",strokeLineJoin:"round",selectable:i,evented:i});return r.annotationType="cloudline",r}getBoxFromPoints(e,t){return{left:Math.min(e.x,t.x),top:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}getCircleFromPoints(e,t){const i=t.x-e.x,s=t.y-e.y,r=Math.max(Math.abs(i),Math.abs(s)),o=i>=0?e.x:e.x-r,a=s>=0?e.y:e.y-r;return{left:o,top:a,radius:Math.max(r/2,1)}}buildCloudPath(e,t){if(e.length<2)return"";const i=Math.max(2,t),s=i*1.4;let r=`M ${e[0].x} ${e[0].y}`,o=1;for(let a=1;a<e.length;a++){const l=e[a-1],c=e[a],h=c.x-l.x,d=c.y-l.y,f=Math.sqrt(h*h+d*d);if(f<.1)continue;const u=-d/f,g=h/f,p=Math.max(1,Math.round(f/s));for(let m=1;m<=p;m++){const A=m/p,x=l.x+h*A,b=l.y+d*A,y=o%2===0?-1:1,_=x+u*i*y,S=b+g*i*y;r+=` Q ${_} ${S} ${x} ${b}`,o++}}return r}handleColorInputChange(e){this.drawStyle.stroke=e||this.drawStyle.stroke,this.drawStyle.fill=this.colorToAlpha(this.drawStyle.stroke,.08),this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}handleStrokeWidthInputChange(e){const t=this.parseNumber(e,this.drawStyle.strokeWidth,1,20);this.drawStyle.strokeWidth=t,this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}handleFontSizeInputChange(e){const t=this.parseNumber(e,this.drawStyle.fontSize,10,96);this.drawStyle.fontSize=t,this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}applyCurrentStyleToSelection(){const e=this.canvas.getActiveObjects();e.length!==0&&(e.forEach(t=>this.applyStyleToObject(t)),this.canvas.requestRenderAll())}applyStyleToObject(e){if(!e)return;if(e.annotationType==="arrow"&&Array.isArray(e._objects)){e._objects.forEach(i=>{if(i?.type==="triangle"||i?.type==="path"){i.set({fill:this.drawStyle.stroke,stroke:this.drawStyle.stroke,strokeWidth:1});return}i?.set({stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,strokeLineCap:"round"})}),e.set({dirty:!0}),e.setCoords?.();return}if(this.isTextObject(e)){e.set({fill:this.drawStyle.stroke,fontSize:this.drawStyle.fontSize}),e.setCoords?.();return}const t={stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth};e?.type==="line"||e?.type==="path"?t.fill="":t.fill=this.drawStyle.fill,e.set(t),e.setCoords?.()}syncStyleFromSelection(){const e=this.canvas.getActiveObject();if(!e)return;const t=this.readStyleFromObject(e);t.stroke&&(this.drawStyle.stroke=t.stroke,this.drawStyle.fill=this.colorToAlpha(t.stroke,.08)),typeof t.strokeWidth=="number"&&(this.drawStyle.strokeWidth=t.strokeWidth),typeof t.fontSize=="number"&&(this.drawStyle.fontSize=t.fontSize),this.refreshToolbarStyleValues()}readStyleFromObject(e){if(!e)return{};if(e.annotationType==="arrow"&&Array.isArray(e._objects)){const t=e._objects.find(i=>i?.type==="line")??e._objects[0];return{stroke:t?.stroke,strokeWidth:t?.strokeWidth}}return this.isTextObject(e)?{stroke:e.fill??this.drawStyle.stroke,fontSize:e.fontSize??this.drawStyle.fontSize}:{stroke:e.stroke??this.drawStyle.stroke,strokeWidth:e.strokeWidth??this.drawStyle.strokeWidth}}isTextObject(e){return e?e.type==="i-text"||e.type==="textbox"||e.annotationType==="text":!1}isInputElement(e){const t=e;if(!t||!t.tagName)return!1;const i=t.tagName.toLowerCase();return i==="input"||i==="textarea"||!!t.isContentEditable}applyCanvasInteractive(e){this.canvas.selection=e,this.canvas.getObjects().forEach(t=>{t.set({selectable:e,evented:e}),t.setCoords?.()}),this.canvas.discardActiveObject(),this.canvas.requestRenderAll()}parseNumber(e,t,i,s){const r=Number(e);return Number.isFinite(r)?Math.min(s,Math.max(i,r)):t}colorToAlpha(e,t){const i=e.trim(),s=/^#([0-9a-fA-F]{3})$/.exec(i);if(s){const o=s[1],a=parseInt(o[0]+o[0],16),l=parseInt(o[1]+o[1],16),c=parseInt(o[2]+o[2],16);return`rgba(${a}, ${l}, ${c}, ${t})`}const r=/^#([0-9a-fA-F]{6})$/.exec(i);if(r){const o=r[1],a=parseInt(o.slice(0,2),16),l=parseInt(o.slice(2,4),16),c=parseInt(o.slice(4,6),16);return`rgba(${a}, ${l}, ${c}, ${t})`}return this.drawStyle.fill}toggleMeasurePanel(){!this.isActive||this.mode!=="edit"||(this.isMeasurePanelExpanded=!this.isMeasurePanelExpanded,this.refreshToolbarState())}activateDistanceMeasure(e){if(!this.isActive||this.mode!=="edit")return;this.drawType="none",this.canvas.defaultCursor="default",this.isDistanceMeasureMode=!0,this.isMeasurePanelExpanded=!0,this.currentMeasureType=e,this.canvas.discardActiveObject(),this.canvas.requestRenderAll();const t=this.engine.measure;t?.active?.(),this.disActiveMeasureTools(t),this.activeMeasureTool(t,e),this.updateOverlayPointerEvents(),this.refreshToolbarState()}stopDistanceMeasureMode(){if(!this.isDistanceMeasureMode)return;const e=this.engine.measure;this.disActiveMeasureTools(e),this.isDistanceMeasureMode=!1,this.currentMeasureType=null,this.updateOverlayPointerEvents(),this.refreshToolbarState()}disActiveMeasureTools(e){e?.distanceMeasure?.disActive?.(),e?.clearDistanceMeasure?.disActive?.(),e?.clearHeightMeasure?.disActive?.(),e?.elevationMeasure?.disActive?.(),e?.pointMeasure?.disActive?.(),e?.angleMeasure?.disActive?.(),e?.areaMeasure?.disActive?.(),e?.slopeMeasure?.disActive?.()}activeMeasureTool(e,t){const s={distance:"distanceMeasure",clearDistance:"clearDistanceMeasure",clearHeight:"clearHeightMeasure",elevation:"elevationMeasure",point:"pointMeasure",angle:"angleMeasure",area:"areaMeasure",slope:"slopeMeasure"}[t];s&&e?.[s]?.active?.()}updateOverlayPointerEvents(){if(!this.isActive){this.wrapper.style.pointerEvents="none",this.canvasEl.style.pointerEvents="none";return}if(this.mode==="view"||this.isDistanceMeasureMode){this.wrapper.style.pointerEvents="none",this.canvasEl.style.pointerEvents="none",this.toolbar.root.style.pointerEvents="auto";return}this.wrapper.style.pointerEvents="auto",this.canvasEl.style.pointerEvents="auto",this.toolbar.root.style.pointerEvents="auto"}async handleCancelClick(){this.sessionSnapshot&&await this.restoreAllShapes(this.cloneJson(this.sessionSnapshot)),this.actionHandlers.onCancel?.(),this.disActive()}async handleCloseClick(){this.disActive()}handleConfirmClick(){const e=this.cloneJson(this.getAllShapes());this.actionHandlers.onConfirm?.(e),this.disActive()}refreshToolbarStyleValues(){this.toolbar.setStyleValues({stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,fontSize:this.drawStyle.fontSize})}refreshToolbarState(){this.toolbar.setDrawType(this.drawType),this.toolbar.setMode(this.mode),this.toolbar.setMeasurePanelVisible(this.isMeasurePanelExpanded),this.toolbar.setMeasureState(this.isDistanceMeasureMode,this.currentMeasureType),this.refreshToolbarStyleValues()}createScreenshotFileName(){const e=new Date,t=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0"),r=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0");return`bim-snapshot-${t}${i}${s}-${r}${o}${a}.png`}cloneJson(e){return JSON.parse(JSON.stringify(e))}}class OR{engine;constructor(e){this.engine=e}get(){return{cameraPose:this.engine.cameraModule?.getCameraPose?.()??null,clipping:this.captureClippingState(),measureData:this.captureMeasureData(),annotationData:this.captureAnnotationData()}}async restore(e,t="view"){e&&(e.cameraPose&&this.engine.cameraModule?.restoreCameraPose?.(e.cameraPose),this.restoreClippingState(e.clipping),this.restoreMeasureData(e.measureData),await this.restoreAnnotationData(e.annotationData),this.applyAnnotationMode(t))}create(e){const t=this.engine.fabricDraw;if(!t){e?.(this.get());return}t.setActionHandlers({onConfirm:i=>{const s=this.get();s.annotationData=this.serializeSnapshotValue(i),e?.(s),this.clearAnnotation()},onCancel:()=>{this.clearAnnotation()}}),t.show?.(),t.active?.("edit"),t.setDrawType?.("none")}clearAnnotation(){this.engine.fabricDraw?.clearAllShapes?.()}captureClippingState(){const e=this.engine.clipping,t=e?.sectionFace,i=e?.currentClippingMode??"",s={mode:i,fillCutFace:e?.getFillCutFace?.()??!0};if(i==="box"&&e?.sectionBox?.getboxXyz&&(s.box=e.sectionBox.getboxXyz()),i==="x"||i==="y"||i==="z"||i==="face"){const r=t?.normal;r&&(s.face={normal:{x:Number(r.x)||0,y:Number(r.y)||0,z:Number(r.z)||1},distance:Number(t?.distance)||0,direction:Number(t?.direction)===-1?-1:1})}return s}restoreClippingState(e){const t=this.engine.clipping;if(!t)return;typeof e?.fillCutFace=="boolean"&&t.setFillCutFace?.(e.fillCutFace);const i=e?.mode??"";if(!i){t.disActive?.();return}if(i==="box"){t.active?.("box"),e.box&&t.sectionBox?.setboxXyz?.(e.box);return}if(i==="x"||i==="y"||i==="z"){t.active?.(i),this.applyFaceState(e.face);return}if(i==="face"){this.restoreFaceMode(e.face);return}t.active?.(i)}restoreFaceMode(e){const t=this.engine.clipping,i=t?.sectionFace;!t||!i||(t.sectionBox?.disActive?.(),i.disActive?.(),i.active?.(),t.currentClippingMode="face",this.applyFaceState(e))}applyFaceState(e){if(!e)return;const t=this.engine.clipping?.sectionFace;if(!t)return;const i=new w.Vector3(e.normal.x,e.normal.y,e.normal.z).normalize();t.direction=e.direction===-1?-1:1,t.setFaceNormal?.(i,e.distance??0)}captureMeasureData(){const e=this.engine.measure?.annotationData;return e?this.serializeSnapshotValue(e):null}restoreMeasureData(e){const t=this.engine.measure;if(!t)return;try{t.clearAll?.()}catch{}if(!e)return;const i=this.deserializeSnapshotValue(e);(!t.annotationData||typeof t.annotationData!="object")&&(t.annotationData={}),Object.keys(t.annotationData).forEach(s=>{t.annotationData[s]=[]}),Object.keys(i).forEach(s=>{t.annotationData[s]=Array.isArray(i[s])?i[s]:[]}),t.tools?.drawNormalAnnotation?.()}captureAnnotationData(){const e=this.engine.fabricDraw;return e?.getAllShapes?this.serializeSnapshotValue(e.getAllShapes()):null}async restoreAnnotationData(e){const t=this.engine.fabricDraw;if(!t)return;if(!e){t.clearAllShapes?.();return}const i=this.deserializeSnapshotValue(e);await t.restoreAllShapes?.(i)}applyAnnotationMode(e){const t=this.engine.fabricDraw;t&&(t.setActionHandlers?.({}),t.show?.(),t.active?.(e),t.setDrawType?.("none"))}serializeSnapshotValue(e){if(e==null)return e;if(e instanceof w.Vector3)return{__type:"Vector3",x:e.x,y:e.y,z:e.z};if(Array.isArray(e))return e.map(t=>this.serializeSnapshotValue(t));if(typeof e=="object"){if(e instanceof HTMLElement||e instanceof SVGElement)return;const t={};return Object.keys(e).forEach(i=>{if(i==="container")return;const s=this.serializeSnapshotValue(e[i]);s!==void 0&&(t[i]=s)}),t}if(typeof e!="function")return e}deserializeSnapshotValue(e){if(e==null)return e;if(Array.isArray(e))return e.map(t=>this.deserializeSnapshotValue(t));if(typeof e=="object"){if(e.__type==="Vector3")return new w.Vector3(e.x,e.y,e.z);const t={};return Object.keys(e).forEach(i=>{t[i]=this.deserializeSnapshotValue(e[i])}),t}return e}}class UR{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=5;_highFpsRequired=.1;isMouseDown=!1;isWheeling=!1;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;engineModelModule;viewTree;merge2d;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;issueReport;text;hdr;ground;skyManager;linkElement2d3d;linkView2d3d;oneClickEncoding;fabricDraw;drawingPin;models=[];reactBoundingClientRect={left:0,top:0};version="3.7.1";versionEl=null;container;constructor(e){if(window.THREE=w,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new M2(this),this.engineModelModule.init(),this.ai=new IP(this),this.deviceModule=new i_(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new gn(this),this.sceneModule=new t_(this),this.scene=this.sceneModule.scene,this.renderModule=new L1(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.renderer){const r=this.renderer;r.interactionCullingEnabled=!0,r.interactionActive=!1,r.interactionRenderScene=this.scene,r.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,r.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new Z1(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new _P(this),this.clipping.init(),this.composerModule=new uE(this),this.composerModule.init(),this.events=new b2,this.engineStatus=new x2(this),this.engineStatus.init(),this.loaderModule=new A2(this),this.lightModule=new y2(this),this.lightModule.init(),this.viewCube=new rD(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=oD(this),this.rangeScale=new aD(this),this.rangeScale.init(),this.setting=new bD(this),this.engineModelModule.init(),this.handelBehaved=_u(this),this.modelMapperBatch=new MP(this),this.measure=new ID(this),this.modelToolModule=new _2(this),this.modelProperties=new CP(this),this.interactionModule=new v2(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new wc(this),this.modelEdge=new AD(this),this.modelTree=new wP(this),this.viewTree=new OP(this),this.merge2d=new WP(this),this.engineInfo=new SP(this),this.pathRoaming=new TP(this),this.pathRoaming.init(),this.oneClickEncoding=new FP(this),this.minMap=new DP(this),this.linkElement2d3d=new LP(this),this.linkView2d3d=new RP(this),this.grid=new hD(this),this.level=new mD(this),this.issueReport=new BP(this),this.fabricDraw=new FR(this),this.drawingPin=new OR(this),this.text=new PP(this),this.hdr=new fD(this),this.ground=new rf(this),this.ground.init(),this.skyManager=new xD(this),this.setting.init(),this.worldToScreen=new lt(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new D2,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElement("div");t.className="versionText",this.versionEl=t,this.updateVersionDisplay(),this.container.appendChild(t);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.position="absolute",i.style.zIndex="1000",i.style.left="0px",i.style.top="0px",i.style.pointerEvents="none",this.container.appendChild(i),this.catchSvg=i,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let s=this;this.controls.addEventListener("start",()=>{s.renderer&&(s.renderer.interactionActive=!0),s.events.trigger(dr.EngineBusy),s.container&&(s.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{s.renderer&&(s.renderer.interactionActive=!1),s.events.trigger(dr.EngineFree),s.container&&(s.container.style.cursor="default")}),this.controls.addEventListener("change",()=>{const r=new w.Vector3;s.camera.getWorldDirection(r);const o=Math.atan2(r.x,-r.z);let a=new CustomEvent("D3ViewUpdate",{detail:{position:s.camera.position,rotation:o,type:s.camera.type}});window.dispatchEvent(a)}),this.events.on(dr.LoadingCompleted,r=>{s.modelEdge.active()}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.skyManager.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this._fpsFrameCount++;const r=performance.now();if(r-this._fpsLastCheck>=this._fpsCheckInterval){const o=r-this._fpsLastCheck,a=this._fpsFrameCount/o*1e3;this._fpsFrameCount=0,this._fpsLastCheck=r,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&r-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=r,this._lowFpsCount=0)):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let o=this.scene?.dirLight;o&&this.camera&&this.updateLightPosition(this.camera,o)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",i=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${i}`}updateLightPosition(e,t){const i=new w.Vector3;e.getWorldDirection(i);const s=100,r=new w.Vector3().copy(i).multiplyScalar(-s),o=new w.Vector3(0,1,0),a=new w.Vector3().crossVectors(i,o).normalize();r.addScaledVector(o,s*.5),r.addScaledVector(a,s*.3),t.position.copy(e.position).add(r);const l=new w.Vector3().copy(e.position).add(i.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),i=e.indexOf(t);if(i>0){const s=e[i-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${s}`),this.engineModelModule.autoSwitch(s)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),i=e.indexOf(t);if(i<e.length-1){const s=e[i+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${s}`),this.engineModelModule.autoSwitch(s)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const s=this.deviceModule.getContainerSize();e=e??s.width,t=t??s.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const i=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=i,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const s=this.cameraModule.orthographicCamera,r=this.cameraModule.getOrthographicVisibleHeight(s);this.cameraModule.setOrthographicVisibleHeight(r,s),s.updateProjectionMatrix()}if(this.catchSvg){const s=this.container.clientWidth,r=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${s} ${r}`)}this.fabricDraw&&this.fabricDraw.resize(e,t),this.events&&this.events.trigger(dr.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),this.issueReport&&this.issueReport.dispose(),this.fabricDraw&&this.fabricDraw.dispose(),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(i=>{this.clearScene(i)}),e.parent&&e.parent.remove(e),e instanceof w.Mesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>this.disposeMaterial(i)):this.disposeMaterial(e.material))),e instanceof w.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof w.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof w.InstancedMesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>this.disposeMaterial(i)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof w.Sprite&&e.material&&this.disposeMaterial(e.material)}disposeMaterial(e){if(!e)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(i=>{const s=e[i];s&&s instanceof w.Texture&&s.dispose()}),e.dispose()}}const NR=`
|
|
6056
|
+
`}applyTo2d({imageData:{data:n}}){let e=-this.vibrance;for(let t=0;t<n.length;t+=4){let i=n[t],s=n[t+1],r=n[t+2],o=Math.max(i,s,r),a=(i+s+r)/3,l=2*Math.abs(o-a)/255*e;n[t]+=o===i?0:(o-i)*l,n[t+1]+=o===s?0:(o-s)*l,n[t+2]+=o===r?0:(o-r)*l}}sendUniformData(n,e){n.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}};$(dl,"type","Vibrance"),$(dl,"defaults",{vibrance:0}),$(dl,"uniformLocations",["uVibrance"]),Re.setClass(dl),La({BaseFilter:()=>Nt,BlackWhite:()=>bR,BlendColor:()=>$a,BlendImage:()=>Ja,Blur:()=>Za,Brightness:()=>el,Brownie:()=>fR,ColorMatrix:()=>kr,Composed:()=>Wp,Contrast:()=>tl,Convolute:()=>il,Gamma:()=>nl,Grayscale:()=>sl,HueRotation:()=>zh,Invert:()=>rl,Kodachrome:()=>gR,Noise:()=>ol,Pixelate:()=>al,Polaroid:()=>AR,RemoveColor:()=>ll,Resize:()=>cl,Saturation:()=>hl,Sepia:()=>xR,Technicolor:()=>mR,Vibrance:()=>dl,Vintage:()=>pR});function wR(n,e,t="bim-snapshot.png"){const i=n?.renderer,s=i?.domElement;if(!i||!s||!e)return null;const r=s.width||s.clientWidth,o=s.height||s.clientHeight;if(r<=0||o<=0)return null;let a=SR(s,r,o);if(!CR(a)){const f=MR(n,r,o);f&&(a=f)}const l=document.createElement("canvas");l.width=r,l.height=o;const c=l.getContext("2d");if(!c)return null;c.drawImage(a,0,0,r,o),c.drawImage(e,0,0,r,o);const h=l.toDataURL("image/png"),d=document.createElement("a");return d.href=h,d.download=t.toLowerCase().endsWith(".png")?t:`${t}.png`,d.click(),h}function SR(n,e,t){const i=document.createElement("canvas");i.width=e,i.height=t;const s=i.getContext("2d");return s&&s.drawImage(n,0,0,e,t),i}function CR(n){const e=n.getContext("2d");if(!e||n.width<=0||n.height<=0)return!1;const t=Math.min(32,n.width),i=Math.min(32,n.height),s=Math.max(1,Math.floor(n.width/t)),r=Math.max(1,Math.floor(n.height/i));for(let o=0;o<n.height;o+=r)for(let a=0;a<n.width;a+=s){const l=e.getImageData(a,o,1,1).data;if(l[0]!==0||l[1]!==0||l[2]!==0||l[3]!==0)return!0}return!1}function MR(n,e,t){const i=n?.renderer,s=n?.scene,r=n?.camera;if(!i||!s||!r)return null;const o=new w.WebGLRenderTarget(e,t,{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat,depthBuffer:!0,stencilBuffer:!0}),a=i.getRenderTarget(),l=i.autoClear,c=i.xr?.enabled??!1;try{i.xr&&(i.xr.enabled=!1),i.autoClear=!0,i.setRenderTarget(o),i.clear(!0,!0,!0),i.render(s,r);const h=new Uint8Array(e*t*4);return i.readRenderTargetPixels(o,0,0,e,t,h),ER(h,e,t)}catch{return null}finally{i.setRenderTarget(a),i.autoClear=l,i.xr&&(i.xr.enabled=c),o.dispose()}}function ER(n,e,t){const i=document.createElement("canvas");i.width=e,i.height=t;const s=i.getContext("2d");if(!s)return i;const r=s.createImageData(e,t),o=e*4;for(let a=0;a<t;a++){const l=(t-1-a)*o,c=a*o;for(let h=0;h<o;h++)r.data[c+h]=n[l+h]}return s.putImageData(r,0,0),i}const IR={none:new URL("/assets/icon/%E9%80%89%E6%8B%A9.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,line:new URL("/assets/icon/%E7%BA%BF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,arrow:new URL("/assets/icon/%E7%AE%AD%E5%A4%B4.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,rect:new URL("/assets/icon/%E7%9F%A9%E5%BD%A2.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,circle:new URL("/assets/icon/%E5%9C%86%E5%BD%A2.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,text:new URL("/assets/icon/%E6%96%87%E5%AD%97.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,cloudline:new URL("/assets/icon/%E4%BA%91%E7%BA%BF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href},TR=new URL("/assets/icon/%E6%B5%8B%E8%B7%9D.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,DR=new URL("/assets/icon/%E6%88%AA%E5%9B%BE.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,BR=new URL("/assets/icon/%E7%BA%BF%E5%AE%BD.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,PR=new URL("/assets/icon/%E5%AD%97%E5%8F%B7.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,LR=[{type:"distance",label:"距离"},{type:"clearDistance",label:"垂距"},{type:"clearHeight",label:"净高"},{type:"elevation",label:"标高"},{type:"point",label:"坐标"},{type:"angle",label:"角度"},{type:"area",label:"面积"},{type:"slope",label:"坡度"}],RR={distance:new URL("/assets/icon/%E8%B7%9D%E7%A6%BB.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,clearDistance:new URL("/assets/icon/%E5%87%80%E8%B7%9D.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,clearHeight:new URL("/assets/icon/%E5%87%80%E9%AB%98.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,elevation:new URL("/assets/icon/%E6%A0%87%E9%AB%98.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,point:new URL("/assets/icon/%E5%9D%90%E6%A0%87.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,angle:new URL("/assets/icon/%E8%A7%92%E5%BA%A6.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,area:new URL("/assets/icon/%E9%9D%A2%E7%A7%AF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,slope:new URL("/assets/icon/%E5%9D%A1%E5%BA%A6.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href};class kR{constructor(e,t){this.handlers=e,this.root=document.createElement("div"),this.root.style.position="absolute",this.root.style.top="8px",this.root.style.left="50%",this.root.style.transform="translateX(-50%)",this.root.style.display="none",this.root.style.padding="6px",this.root.style.background="#ffffff",this.root.style.border="1px solid #d9d9d9",this.root.style.borderRadius="8px",this.root.style.pointerEvents="auto",this.root.style.userSelect="none",this.root.style.boxShadow="0 4px 14px rgba(0, 0, 0, 0.12)",this.root.style.zIndex="1300",this.editPanel=document.createElement("div"),this.editPanel.style.display="flex",this.editPanel.style.flexDirection="column",this.editPanel.style.gap="6px",this.viewPanel=document.createElement("div"),this.viewPanel.style.display="none",this.viewPanel.style.alignItems="center",this.viewPanel.style.gap="6px";const i=document.createElement("div");i.style.display="flex",i.style.alignItems="center",i.style.gap="6px",i.style.flexWrap="wrap",[{type:"none",label:"选择"},{type:"line",label:"线"},{type:"arrow",label:"箭头"},{type:"rect",label:"矩形"},{type:"circle",label:"圆形"},{type:"text",label:"文字"},{type:"cloudline",label:"云线"}].forEach(c=>{const h=this.createIconButton(c.label,IR[c.type]);h.onclick=()=>this.handlers.onDrawTypeChange(c.type),this.drawButtons[c.type]=h,i.appendChild(h)}),this.colorInput=document.createElement("input"),this.colorInput.type="color",this.colorInput.value=t.stroke,this.colorInput.style.width="32px",this.colorInput.style.height="24px",this.colorInput.style.padding="0",this.colorInput.style.border="1px solid #d9d9d9",this.colorInput.style.borderRadius="4px",this.colorInput.style.background="#ffffff",this.colorInput.oninput=()=>this.handlers.onColorChange(this.colorInput.value),i.appendChild(this.createField("",this.colorInput)),this.strokeWidthInput=document.createElement("input"),this.strokeWidthInput.type="number",this.strokeWidthInput.min="1",this.strokeWidthInput.max="20",this.strokeWidthInput.step="1",this.strokeWidthInput.value=String(t.strokeWidth),this.strokeWidthInput.style.width="46px",this.strokeWidthInput.oninput=()=>this.handlers.onStrokeWidthChange(this.strokeWidthInput.value),i.appendChild(this.createField("",this.strokeWidthInput,BR,"线宽")),this.fontSizeInput=document.createElement("input"),this.fontSizeInput.type="number",this.fontSizeInput.min="10",this.fontSizeInput.max="96",this.fontSizeInput.step="1",this.fontSizeInput.value=String(t.fontSize),this.fontSizeInput.style.width="46px",this.fontSizeInput.oninput=()=>this.handlers.onFontSizeChange(this.fontSizeInput.value),i.appendChild(this.createField("",this.fontSizeInput,PR,"字号")),this.distanceButton=this.createIconButton("测量",TR),this.distanceButton.onclick=()=>this.handlers.onMeasureToggle(),i.appendChild(this.distanceButton);const r=this.createIconButton("截图",DR);r.onclick=()=>this.handlers.onScreenshot(),i.appendChild(r);const o=this.createTextButton("×","取消");o.onclick=()=>this.handlers.onCancel(),o.style.background="#ff4d4f",o.style.borderColor="#ff4d4f",o.style.color="#ffffff",i.appendChild(o);const a=this.createTextButton("✔","确定");a.onclick=()=>this.handlers.onConfirm(),a.style.background="#52c41a",a.style.borderColor="#52c41a",a.style.color="#ffffff",i.appendChild(a),this.measureSubPanel=document.createElement("div"),this.measureSubPanel.style.display="none",this.measureSubPanel.style.alignItems="center",this.measureSubPanel.style.gap="6px",this.measureSubPanel.style.flexWrap="wrap",this.measureSubPanel.style.paddingTop="2px",LR.forEach(c=>{const h=this.createSmallIconButton(c.label,RR[c.type]);h.onclick=()=>this.handlers.onMeasureTypeChange(c.type),this.measureTypeButtons[c.type]=h,this.measureSubPanel.appendChild(h)}),this.editPanel.appendChild(i),this.editPanel.appendChild(this.measureSubPanel);const l=this.createTextButton("关闭","关闭");l.onclick=()=>this.handlers.onClose(),this.viewPanel.appendChild(l),this.root.appendChild(this.editPanel),this.root.appendChild(this.viewPanel),this.setMode("edit")}root;drawButtons={};measureTypeButtons={};distanceButton;colorInput;strokeWidthInput;fontSizeInput;editPanel;viewPanel;measureSubPanel;mode="edit";mount(e){e.appendChild(this.root)}show(){this.root.style.display="block"}hide(){this.root.style.display="none"}setMode(e){this.mode=e,this.editPanel.style.display=e==="edit"?"flex":"none",this.viewPanel.style.display=e==="view"?"flex":"none",e==="view"&&this.setMeasurePanelVisible(!1)}setDrawType(e){for(const t in this.drawButtons){const i=this.drawButtons[t];if(!i)continue;const s=t===e;i.style.background=s?"#eaf2ff":"#ffffff",i.style.borderColor=s?"#2f80ed":"#d9d9d9"}}setMeasurePanelVisible(e){if(this.mode!=="edit"){this.measureSubPanel.style.display="none";return}this.measureSubPanel.style.display=e?"flex":"none"}setMeasureState(e,t){this.distanceButton.style.background=e?"#eaf2ff":"#ffffff",this.distanceButton.style.borderColor=e?"#2f80ed":"#d9d9d9";for(const i in this.measureTypeButtons){const s=this.measureTypeButtons[i];if(!s)continue;const r=e&&t===i;s.style.background=r?"#eaf2ff":"#ffffff",s.style.borderColor=r?"#2f80ed":"#d9d9d9"}}setStyleValues(e){e.stroke&&(this.colorInput.value=e.stroke),typeof e.strokeWidth=="number"&&(this.strokeWidthInput.value=String(e.strokeWidth)),typeof e.fontSize=="number"&&(this.fontSizeInput.value=String(e.fontSize))}dispose(){this.colorInput.oninput=null,this.strokeWidthInput.oninput=null,this.fontSizeInput.oninput=null,this.root.remove()}createField(e,t,i,s=""){const r=document.createElement("div");if(r.style.display="flex",r.style.alignItems="center",r.style.gap="4px",r.style.padding="0 2px",r.style.color="#333333",r.style.fontSize="12px",e){const o=document.createElement("span");o.textContent=e,r.appendChild(o)}if(i){const o=document.createElement("img");o.src=i,o.alt=s,o.style.width="14px",o.style.height="14px",o.style.display="block",r.appendChild(o)}return t.style.height="24px",t.style.border="1px solid #d9d9d9",t.style.borderRadius="4px",t.style.background="#ffffff",t.style.color="#333333",t.style.outline="none",t.style.padding="0 4px",r.appendChild(t),r}createIconButton(e,t){const i=document.createElement("button");i.type="button",i.style.width="28px",i.style.height="28px",i.style.padding="0",i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.border="1px solid #d9d9d9",i.style.borderRadius="4px",i.style.background="#ffffff",i.style.cursor="pointer";const s=document.createElement("img");return s.src=t,s.alt=e,s.style.width="16px",s.style.height="16px",s.style.display="block",i.appendChild(s),i}createSmallIconButton(e,t){const i=document.createElement("button");i.type="button",i.style.width="26px",i.style.height="26px",i.style.padding="0",i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.border="1px solid #d9d9d9",i.style.borderRadius="4px",i.style.background="#ffffff",i.style.cursor="pointer";const s=document.createElement("img");return s.src=t,s.alt=e,s.style.width="14px",s.style.height="14px",s.style.display="block",i.appendChild(s),i}createTextButton(e,t){const i=document.createElement("button");return i.type="button",i.textContent=e,i.style.width="28px",i.style.height="28px",i.style.padding="0 10px",i.style.border="1px solid #d9d9d9",i.style.borderRadius="4px",i.style.background="#ffffff",i.style.color="#333333",i.style.fontSize="13px",i.style.lineHeight="1",i.style.cursor="pointer",i}}class FR{engine;wrapper;canvasEl;canvas;toolbar;isActive=!1;isVisible=!0;isDistanceMeasureMode=!1;isMeasurePanelExpanded=!1;drawType="none";mode="edit";currentMeasureType=null;sessionSnapshot=null;actionHandlers={};drawStyle={stroke:"#ff4d4f",strokeWidth:2,fill:"rgba(255, 77, 79, 0.08)",fontSize:16,text:"文本",cloudRadius:10};startPoint=null;tempObject=null;cloudPoints=[];onMouseDown=e=>this.handleMouseDown(e);onMouseMove=e=>this.handleMouseMove(e);onMouseUp=e=>this.handleMouseUp(e);onMouseDblClick=e=>this.handleMouseDblClick(e);onSelectionChanged=()=>this.syncStyleFromSelection();onKeyDown=e=>this.handleKeyDown(e);constructor(e){this.engine=e;const t=this.engine.container;if(!t)throw new Error("FabricDraw: engine container not found.");this.wrapper=document.createElement("div"),this.wrapper.className="fabric-draw-layer",this.wrapper.style.position="absolute",this.wrapper.style.left="0",this.wrapper.style.top="0",this.wrapper.style.right="0",this.wrapper.style.bottom="0",this.wrapper.style.zIndex="1200",this.wrapper.style.pointerEvents="none",this.canvasEl=document.createElement("canvas"),this.canvasEl.style.width="100%",this.canvasEl.style.height="100%",this.wrapper.appendChild(this.canvasEl),this.toolbar=new kR({onDrawTypeChange:i=>this.setDrawType(i),onMeasureToggle:()=>this.toggleMeasurePanel(),onMeasureTypeChange:i=>this.activateDistanceMeasure(i),onScreenshot:()=>{this.saveScreenshot(this.createScreenshotFileName())},onColorChange:i=>this.handleColorInputChange(i),onStrokeWidthChange:i=>this.handleStrokeWidthInputChange(i),onFontSizeChange:i=>this.handleFontSizeInputChange(i),onCancel:()=>{this.handleCancelClick()},onConfirm:()=>this.handleConfirmClick(),onClose:()=>{this.handleCloseClick()}},{stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,fontSize:this.drawStyle.fontSize}),this.toolbar.mount(this.wrapper),t.appendChild(this.wrapper),this.canvas=new Op(this.canvasEl,{selection:!0,preserveObjectStacking:!0}),this.resize(),this.canvas.on("mouse:down",this.onMouseDown),this.canvas.on("mouse:move",this.onMouseMove),this.canvas.on("mouse:up",this.onMouseUp),this.canvas.on("mouse:dblclick",this.onMouseDblClick),this.canvas.on("selection:created",this.onSelectionChanged),this.canvas.on("selection:updated",this.onSelectionChanged),this.canvas.on("selection:cleared",this.onSelectionChanged),window.addEventListener("keydown",this.onKeyDown),this.refreshToolbarState()}active(e="edit"){this.isActive=!0,this.mode=e,this.drawType="none",this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.canvas.defaultCursor="default",this.sessionSnapshot=e==="edit"?this.cloneJson(this.getAllShapes()):null,this.toolbar.setMode(e),this.applyCanvasInteractive(e==="edit"),this.isVisible&&this.toolbar.show(),this.updateOverlayPointerEvents(),this.refreshToolbarState()}disActive(){this.isActive=!1,this.startPoint=null,this.cloudPoints=[],this.tempObject=null,this.drawType="none",this.mode="edit",this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.sessionSnapshot=null,this.stopDistanceMeasureMode(),this.canvas.defaultCursor="default",this.canvas.discardActiveObject(),this.applyCanvasInteractive(!0),this.canvas.requestRenderAll(),this.toolbar.setMode("edit"),this.toolbar.hide(),this.updateOverlayPointerEvents(),this.refreshToolbarState()}close(){this.disActive()}hide(){this.isVisible=!1,this.wrapper.style.display="none",this.toolbar.hide()}show(){this.isVisible=!0,this.wrapper.style.display="block",this.isActive&&this.toolbar.show(),this.resize()}isShown(){return this.isVisible}setDrawType(e,t){this.mode!=="view"&&(this.stopDistanceMeasureMode(),this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.drawType=e,t&&(this.drawStyle={...this.drawStyle,...t}),this.canvas.defaultCursor=e==="none"?"default":"crosshair",this.updateOverlayPointerEvents(),this.refreshToolbarState())}getDrawType(){return this.drawType}setActionHandlers(e){this.actionHandlers={...e}}drawLine(e,t,i){const s=this.mergeStyle(i),r=this.createLineObject(e,t,s,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawArrow(e,t,i){const s=this.mergeStyle(i),r=this.createArrowObject(e,t,s,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawRect(e,t,i){const s=this.mergeStyle(i),r=this.createRectObject(e,t,s,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawCircle(e,t,i){const s=this.mergeStyle(i),r=this.createCircleObject(e,t,s,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawText(e,t,i){const s=this.mergeStyle(i),r=new Lr(t??s.text,{left:e.x,top:e.y,fontSize:s.fontSize,fill:s.stroke,selectable:!0,evented:!0,objectCaching:!1});return r.annotationType="text",this.canvas.add(r),this.canvas.requestRenderAll(),r}drawCloudLine(e,t){if(e.length<2)return null;const i=this.mergeStyle(t),s=this.createCloudObject(e,i,!0);return s?(this.canvas.add(s),this.canvas.requestRenderAll(),s):null}getAllShapes(){return this.canvas.toObject(["annotationType"])}clearAllShapes(){this.canvas.clear(),this.canvas.requestRenderAll()}async restoreAllShapes(e){await this.canvas.loadFromJSON(e),this.canvas.requestRenderAll()}saveScreenshot(e="bim-snapshot.png"){const t=this.canvas.lowerCanvasEl;return t?wR(this.engine,t,e):null}resize(e,t){const i=this.engine.container;if(!i)return;const s=e??i.clientWidth??1,r=t??i.clientHeight??1;this.canvas.setDimensions({width:s,height:r}),this.canvas.requestRenderAll()}dispose(){this.stopDistanceMeasureMode(),window.removeEventListener("keydown",this.onKeyDown),this.canvas.off("mouse:down",this.onMouseDown),this.canvas.off("mouse:move",this.onMouseMove),this.canvas.off("mouse:up",this.onMouseUp),this.canvas.off("mouse:dblclick",this.onMouseDblClick),this.canvas.off("selection:created",this.onSelectionChanged),this.canvas.off("selection:updated",this.onSelectionChanged),this.canvas.off("selection:cleared",this.onSelectionChanged),this.toolbar.dispose(),this.canvas.dispose(),this.wrapper.remove()}handleMouseDown(e){if(!this.isActive||this.mode==="view"||this.drawType==="none"||e?.target)return;const t=this.getPointFromEvent(e);if(this.drawType==="text"){const s=this.drawText(t);this.canvas.setActiveObject(s),this.canvas.requestRenderAll(),setTimeout(()=>{s.enterEditing(),s.hiddenTextarea?.focus(),s.selectAll()},0);return}this.startPoint=t,this.cloudPoints=[t],this.canvas.selection=!1,this.canvas.discardActiveObject();const i=this.createDraftObject(t,t);i&&(this.tempObject=i,this.canvas.add(i),this.canvas.requestRenderAll())}handleMouseMove(e){if(!this.isActive||this.mode==="view"||!this.startPoint||!this.tempObject)return;const t=this.getPointFromEvent(e),i=this.drawStyle;if(this.drawType==="cloudline"){if(this.shouldAppendCloudPoint(t)){this.cloudPoints.push(t),this.canvas.remove(this.tempObject);const s=this.createCloudObject(this.cloudPoints,i,!1);if(!s)return;this.tempObject=s,this.canvas.add(s),this.canvas.requestRenderAll()}return}if(this.drawType==="arrow"){this.canvas.remove(this.tempObject),this.tempObject=this.createArrowObject(this.startPoint,t,i,!1),this.canvas.add(this.tempObject),this.canvas.requestRenderAll();return}this.updateDraftObject(this.startPoint,t),this.canvas.requestRenderAll()}handleMouseUp(e){if(!this.isActive||this.mode==="view"||!this.startPoint)return;const t=this.getPointFromEvent(e);this.drawType==="cloudline"&&this.cloudPoints.length===1&&(this.cloudPoints.push(t),this.canvas.remove(this.tempObject),this.tempObject=this.createCloudObject(this.cloudPoints,this.drawStyle,!0),this.tempObject&&this.canvas.add(this.tempObject)),this.tempObject&&(this.tempObject.set({selectable:!0,evented:!0}),this.tempObject.setCoords?.(),this.canvas.requestRenderAll()),this.startPoint=null,this.tempObject=null,this.cloudPoints=[],this.canvas.selection=!0}handleMouseDblClick(e){const t=e?.target;this.isTextObject(t)&&(t.enterEditing(),t.hiddenTextarea?.focus(),t.selectAll?.())}handleKeyDown(e){if(!this.isActive)return;const t=this.canvas.getActiveObject();if(this.isTextObject(t)&&t?.isEditing||this.isInputElement(e.target))return;if(e.key==="Escape"){e.preventDefault(),this.mode==="view"?this.handleCloseClick():this.handleCancelClick();return}if(e.key==="Enter"){this.mode==="edit"&&(e.preventDefault(),this.handleConfirmClick());return}if(e.key!=="Delete"&&e.key!=="Backspace"||!t)return;e.preventDefault(),this.canvas.getActiveObjects().forEach(r=>this.canvas.remove(r)),this.canvas.discardActiveObject(),this.canvas.requestRenderAll()}getPointFromEvent(e){if(e?.e){const i=this.canvas.getScenePoint(e.e);return{x:i.x,y:i.y}}const t=e?.scenePoint??e?.pointer??e?.absolutePointer;return t?{x:t.x,y:t.y}:{x:0,y:0}}shouldAppendCloudPoint(e){if(this.cloudPoints.length===0)return!0;const t=this.cloudPoints[this.cloudPoints.length-1],i=e.x-t.x,s=e.y-t.y;return Math.sqrt(i*i+s*s)>=6}createDraftObject(e,t){const i=this.drawStyle;switch(this.drawType){case"line":return this.createLineObject(e,t,i,!1);case"arrow":return this.createArrowObject(e,t,i,!1);case"rect":return this.createRectObject(e,t,i,!1);case"circle":return this.createCircleObject(e,t,i,!1);case"cloudline":return this.createCloudObject([e,t],i,!1);default:return null}}updateDraftObject(e,t){if(this.tempObject){if(this.drawType==="line"){this.tempObject.set({x2:t.x,y2:t.y});return}if(this.drawType==="rect"){const i=this.getBoxFromPoints(e,t);this.tempObject.set({left:i.left,top:i.top,width:i.width,height:i.height});return}if(this.drawType==="circle"){const i=this.getCircleFromPoints(e,t);this.tempObject.set({left:i.left,top:i.top,radius:i.radius})}}}mergeStyle(e){return{...this.drawStyle,...e??{}}}createObjectBase(e,t){return{stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,selectable:t,evented:t,objectCaching:!1}}createLineObject(e,t,i,s){const r=new Qs([e.x,e.y,t.x,t.y],{...this.createObjectBase(i,s),fill:"",strokeLineCap:"round"});return r.annotationType="line",r}createRectObject(e,t,i,s){const r=this.getBoxFromPoints(e,t),o=new zs({...this.createObjectBase(i,s),left:r.left,top:r.top,width:r.width,height:r.height,originX:"left",originY:"top"});return o.annotationType="rect",o}createCircleObject(e,t,i,s){const r=this.getCircleFromPoints(e,t),o=new Pr({...this.createObjectBase(i,s),left:r.left,top:r.top,radius:r.radius,originX:"left",originY:"top"});return o.annotationType="circle",o}createArrowObject(e,t,i,s){const r=t.x-e.x,o=t.y-e.y,a=Math.sqrt(r*r+o*o);if(a<1e-6){const D=new Qs([e.x,e.y,t.x,t.y],{stroke:i.stroke,strokeWidth:i.strokeWidth,fill:"",selectable:s,evented:s}),M=new Gs([D],{selectable:s,evented:s,objectCaching:!1});return M.annotationType="arrow",M}const l=r/a,c=o/a,h=-c,d=l,f=Math.max(10,i.strokeWidth*6),u=f*.72,g=t.x-l*f,p=t.y-c*f,m=g+h*(u*.5),A=p+d*(u*.5),x=g-h*(u*.5),b=p-d*(u*.5),y=new Qs([e.x,e.y,t.x,t.y],{stroke:i.stroke,strokeWidth:i.strokeWidth,fill:"",strokeLineCap:"round",selectable:!1,evented:!1}),_=`M ${t.x} ${t.y} L ${m} ${A} L ${x} ${b} Z`,S=new Br(_,{fill:i.stroke,stroke:i.stroke,strokeWidth:1,selectable:!1,evented:!1,objectCaching:!1}),C=new Gs([y,S],{selectable:s,evented:s,objectCaching:!1});return C.annotationType="arrow",C}createCloudObject(e,t,i){const s=this.buildCloudPath(e,t.cloudRadius);if(!s)return null;const r=new Br(s,{stroke:t.stroke,strokeWidth:t.strokeWidth,fill:"",strokeLineCap:"round",strokeLineJoin:"round",selectable:i,evented:i});return r.annotationType="cloudline",r}getBoxFromPoints(e,t){return{left:Math.min(e.x,t.x),top:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}getCircleFromPoints(e,t){const i=t.x-e.x,s=t.y-e.y,r=Math.max(Math.abs(i),Math.abs(s)),o=i>=0?e.x:e.x-r,a=s>=0?e.y:e.y-r;return{left:o,top:a,radius:Math.max(r/2,1)}}buildCloudPath(e,t){if(e.length<2)return"";const i=Math.max(2,t),s=i*1.4;let r=`M ${e[0].x} ${e[0].y}`,o=1;for(let a=1;a<e.length;a++){const l=e[a-1],c=e[a],h=c.x-l.x,d=c.y-l.y,f=Math.sqrt(h*h+d*d);if(f<.1)continue;const u=-d/f,g=h/f,p=Math.max(1,Math.round(f/s));for(let m=1;m<=p;m++){const A=m/p,x=l.x+h*A,b=l.y+d*A,y=o%2===0?-1:1,_=x+u*i*y,S=b+g*i*y;r+=` Q ${_} ${S} ${x} ${b}`,o++}}return r}handleColorInputChange(e){this.drawStyle.stroke=e||this.drawStyle.stroke,this.drawStyle.fill=this.colorToAlpha(this.drawStyle.stroke,.08),this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}handleStrokeWidthInputChange(e){const t=this.parseNumber(e,this.drawStyle.strokeWidth,1,20);this.drawStyle.strokeWidth=t,this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}handleFontSizeInputChange(e){const t=this.parseNumber(e,this.drawStyle.fontSize,10,96);this.drawStyle.fontSize=t,this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}applyCurrentStyleToSelection(){const e=this.canvas.getActiveObjects();e.length!==0&&(e.forEach(t=>this.applyStyleToObject(t)),this.canvas.requestRenderAll())}applyStyleToObject(e){if(!e)return;if(e.annotationType==="arrow"&&Array.isArray(e._objects)){e._objects.forEach(i=>{if(i?.type==="triangle"||i?.type==="path"){i.set({fill:this.drawStyle.stroke,stroke:this.drawStyle.stroke,strokeWidth:1});return}i?.set({stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,strokeLineCap:"round"})}),e.set({dirty:!0}),e.setCoords?.();return}if(this.isTextObject(e)){e.set({fill:this.drawStyle.stroke,fontSize:this.drawStyle.fontSize}),e.setCoords?.();return}const t={stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth};e?.type==="line"||e?.type==="path"?t.fill="":t.fill=this.drawStyle.fill,e.set(t),e.setCoords?.()}syncStyleFromSelection(){const e=this.canvas.getActiveObject();if(!e)return;const t=this.readStyleFromObject(e);t.stroke&&(this.drawStyle.stroke=t.stroke,this.drawStyle.fill=this.colorToAlpha(t.stroke,.08)),typeof t.strokeWidth=="number"&&(this.drawStyle.strokeWidth=t.strokeWidth),typeof t.fontSize=="number"&&(this.drawStyle.fontSize=t.fontSize),this.refreshToolbarStyleValues()}readStyleFromObject(e){if(!e)return{};if(e.annotationType==="arrow"&&Array.isArray(e._objects)){const t=e._objects.find(i=>i?.type==="line")??e._objects[0];return{stroke:t?.stroke,strokeWidth:t?.strokeWidth}}return this.isTextObject(e)?{stroke:e.fill??this.drawStyle.stroke,fontSize:e.fontSize??this.drawStyle.fontSize}:{stroke:e.stroke??this.drawStyle.stroke,strokeWidth:e.strokeWidth??this.drawStyle.strokeWidth}}isTextObject(e){return e?e.type==="i-text"||e.type==="textbox"||e.annotationType==="text":!1}isInputElement(e){const t=e;if(!t||!t.tagName)return!1;const i=t.tagName.toLowerCase();return i==="input"||i==="textarea"||!!t.isContentEditable}applyCanvasInteractive(e){this.canvas.selection=e,this.canvas.getObjects().forEach(t=>{t.set({selectable:e,evented:e}),t.setCoords?.()}),this.canvas.discardActiveObject(),this.canvas.requestRenderAll()}parseNumber(e,t,i,s){const r=Number(e);return Number.isFinite(r)?Math.min(s,Math.max(i,r)):t}colorToAlpha(e,t){const i=e.trim(),s=/^#([0-9a-fA-F]{3})$/.exec(i);if(s){const o=s[1],a=parseInt(o[0]+o[0],16),l=parseInt(o[1]+o[1],16),c=parseInt(o[2]+o[2],16);return`rgba(${a}, ${l}, ${c}, ${t})`}const r=/^#([0-9a-fA-F]{6})$/.exec(i);if(r){const o=r[1],a=parseInt(o.slice(0,2),16),l=parseInt(o.slice(2,4),16),c=parseInt(o.slice(4,6),16);return`rgba(${a}, ${l}, ${c}, ${t})`}return this.drawStyle.fill}toggleMeasurePanel(){!this.isActive||this.mode!=="edit"||(this.isMeasurePanelExpanded=!this.isMeasurePanelExpanded,this.refreshToolbarState())}activateDistanceMeasure(e){if(!this.isActive||this.mode!=="edit")return;this.drawType="none",this.canvas.defaultCursor="default",this.isDistanceMeasureMode=!0,this.isMeasurePanelExpanded=!0,this.currentMeasureType=e,this.canvas.discardActiveObject(),this.canvas.requestRenderAll();const t=this.engine.measure;t?.active?.(),this.disActiveMeasureTools(t),this.activeMeasureTool(t,e),this.updateOverlayPointerEvents(),this.refreshToolbarState()}stopDistanceMeasureMode(){if(!this.isDistanceMeasureMode)return;const e=this.engine.measure;this.disActiveMeasureTools(e),this.isDistanceMeasureMode=!1,this.currentMeasureType=null,this.updateOverlayPointerEvents(),this.refreshToolbarState()}disActiveMeasureTools(e){e?.distanceMeasure?.disActive?.(),e?.clearDistanceMeasure?.disActive?.(),e?.clearHeightMeasure?.disActive?.(),e?.elevationMeasure?.disActive?.(),e?.pointMeasure?.disActive?.(),e?.angleMeasure?.disActive?.(),e?.areaMeasure?.disActive?.(),e?.slopeMeasure?.disActive?.()}activeMeasureTool(e,t){const s={distance:"distanceMeasure",clearDistance:"clearDistanceMeasure",clearHeight:"clearHeightMeasure",elevation:"elevationMeasure",point:"pointMeasure",angle:"angleMeasure",area:"areaMeasure",slope:"slopeMeasure"}[t];s&&e?.[s]?.active?.()}updateOverlayPointerEvents(){if(!this.isActive){this.wrapper.style.pointerEvents="none",this.canvasEl.style.pointerEvents="none";return}if(this.mode==="view"||this.isDistanceMeasureMode){this.wrapper.style.pointerEvents="none",this.canvasEl.style.pointerEvents="none",this.toolbar.root.style.pointerEvents="auto";return}this.wrapper.style.pointerEvents="auto",this.canvasEl.style.pointerEvents="auto",this.toolbar.root.style.pointerEvents="auto"}async handleCancelClick(){this.sessionSnapshot&&await this.restoreAllShapes(this.cloneJson(this.sessionSnapshot)),this.actionHandlers.onCancel?.(),this.disActive()}async handleCloseClick(){this.disActive()}handleConfirmClick(){const e=this.cloneJson(this.getAllShapes());this.actionHandlers.onConfirm?.(e),this.disActive()}refreshToolbarStyleValues(){this.toolbar.setStyleValues({stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,fontSize:this.drawStyle.fontSize})}refreshToolbarState(){this.toolbar.setDrawType(this.drawType),this.toolbar.setMode(this.mode),this.toolbar.setMeasurePanelVisible(this.isMeasurePanelExpanded),this.toolbar.setMeasureState(this.isDistanceMeasureMode,this.currentMeasureType),this.refreshToolbarStyleValues()}createScreenshotFileName(){const e=new Date,t=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0"),r=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0");return`bim-snapshot-${t}${i}${s}-${r}${o}${a}.png`}cloneJson(e){return JSON.parse(JSON.stringify(e))}}class OR{engine;constructor(e){this.engine=e}get(){return{cameraPose:this.engine.cameraModule?.getCameraPose?.()??null,clipping:this.captureClippingState(),measureData:this.captureMeasureData(),annotationData:this.captureAnnotationData()}}async restore(e,t="view"){e&&(e.cameraPose&&this.engine.cameraModule?.restoreCameraPose?.(e.cameraPose),this.restoreClippingState(e.clipping),this.restoreMeasureData(e.measureData),await this.restoreAnnotationData(e.annotationData),this.applyAnnotationMode(t))}create(e){const t=this.engine.fabricDraw;if(!t){e?.(this.get());return}t.setActionHandlers({onConfirm:i=>{const s=this.get();s.annotationData=this.serializeSnapshotValue(i),e?.(s),this.clearAnnotation()},onCancel:()=>{this.clearAnnotation()}}),t.show?.(),t.active?.("edit"),t.setDrawType?.("none")}clearAnnotation(){this.engine.fabricDraw?.clearAllShapes?.(),this.engine.measure.disActive?.()}captureClippingState(){const e=this.engine.clipping,t=e?.sectionFace,i=e?.currentClippingMode??"",s={mode:i,fillCutFace:e?.getFillCutFace?.()??!0};if(i==="box"&&e?.sectionBox?.getboxXyz&&(s.box=e.sectionBox.getboxXyz()),i==="x"||i==="y"||i==="z"||i==="face"){const r=t?.normal;r&&(s.face={normal:{x:Number(r.x)||0,y:Number(r.y)||0,z:Number(r.z)||1},distance:Number(t?.distance)||0,direction:Number(t?.direction)===-1?-1:1})}return s}restoreClippingState(e){const t=this.engine.clipping;if(!t)return;typeof e?.fillCutFace=="boolean"&&t.setFillCutFace?.(e.fillCutFace);const i=e?.mode??"";if(!i){t.disActive?.();return}if(i==="box"){t.active?.("box"),e.box&&t.sectionBox?.setboxXyz?.(e.box);return}if(i==="x"||i==="y"||i==="z"){t.active?.(i),this.applyFaceState(e.face);return}if(i==="face"){this.restoreFaceMode(e.face);return}t.active?.(i)}restoreFaceMode(e){const t=this.engine.clipping,i=t?.sectionFace;!t||!i||(t.sectionBox?.disActive?.(),i.disActive?.(),i.active?.(),t.currentClippingMode="face",this.applyFaceState(e))}applyFaceState(e){if(!e)return;const t=this.engine.clipping?.sectionFace;if(!t)return;const i=new w.Vector3(e.normal.x,e.normal.y,e.normal.z).normalize();t.direction=e.direction===-1?-1:1,t.setFaceNormal?.(i,e.distance??0)}captureMeasureData(){const e=this.engine.measure?.annotationData;return e?this.serializeSnapshotValue(e):null}restoreMeasureData(e){const t=this.engine.measure;if(!t)return;try{t.clearAll?.()}catch{}if(!e)return;const i=this.deserializeSnapshotValue(e);(!t.annotationData||typeof t.annotationData!="object")&&(t.annotationData={}),Object.keys(t.annotationData).forEach(s=>{t.annotationData[s]=[]}),Object.keys(i).forEach(s=>{t.annotationData[s]=Array.isArray(i[s])?i[s]:[]}),t.tools?.drawNormalAnnotation?.()}captureAnnotationData(){const e=this.engine.fabricDraw;return e?.getAllShapes?this.serializeSnapshotValue(e.getAllShapes()):null}async restoreAnnotationData(e){const t=this.engine.fabricDraw;if(!t)return;if(!e){t.clearAllShapes?.();return}const i=this.deserializeSnapshotValue(e);await t.restoreAllShapes?.(i)}applyAnnotationMode(e){const t=this.engine.fabricDraw;t&&(t.setActionHandlers?.({}),t.show?.(),t.active?.(e),t.setDrawType?.("none"))}serializeSnapshotValue(e){if(e==null)return e;if(e instanceof w.Vector3)return{__type:"Vector3",x:e.x,y:e.y,z:e.z};if(Array.isArray(e))return e.map(t=>this.serializeSnapshotValue(t));if(typeof e=="object"){if(e instanceof HTMLElement||e instanceof SVGElement)return;const t={};return Object.keys(e).forEach(i=>{if(i==="container")return;const s=this.serializeSnapshotValue(e[i]);s!==void 0&&(t[i]=s)}),t}if(typeof e!="function")return e}deserializeSnapshotValue(e){if(e==null)return e;if(Array.isArray(e))return e.map(t=>this.deserializeSnapshotValue(t));if(typeof e=="object"){if(e.__type==="Vector3")return new w.Vector3(e.x,e.y,e.z);const t={};return Object.keys(e).forEach(i=>{t[i]=this.deserializeSnapshotValue(e[i])}),t}return e}}class UR{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=5;_highFpsRequired=.1;isMouseDown=!1;isWheeling=!1;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;engineModelModule;viewTree;merge2d;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;issueReport;text;hdr;ground;skyManager;linkElement2d3d;linkView2d3d;oneClickEncoding;fabricDraw;drawingPin;models=[];reactBoundingClientRect={left:0,top:0};version="3.7.3";versionEl=null;container;constructor(e){if(window.THREE=w,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new M2(this),this.engineModelModule.init(),this.ai=new IP(this),this.deviceModule=new i_(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new gn(this),this.sceneModule=new t_(this),this.scene=this.sceneModule.scene,this.renderModule=new L1(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.renderer){const r=this.renderer;r.interactionCullingEnabled=!0,r.interactionActive=!1,r.interactionRenderScene=this.scene,r.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,r.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new Z1(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new _P(this),this.clipping.init(),this.composerModule=new uE(this),this.composerModule.init(),this.events=new b2,this.engineStatus=new x2(this),this.engineStatus.init(),this.loaderModule=new A2(this),this.lightModule=new y2(this),this.lightModule.init(),this.viewCube=new rD(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=oD(this),this.rangeScale=new aD(this),this.rangeScale.init(),this.setting=new bD(this),this.engineModelModule.init(),this.handelBehaved=_u(this),this.modelMapperBatch=new MP(this),this.measure=new ID(this),this.modelToolModule=new _2(this),this.modelProperties=new CP(this),this.interactionModule=new v2(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new wc(this),this.modelEdge=new AD(this),this.modelTree=new wP(this),this.viewTree=new OP(this),this.merge2d=new WP(this),this.engineInfo=new SP(this),this.pathRoaming=new TP(this),this.pathRoaming.init(),this.oneClickEncoding=new FP(this),this.minMap=new DP(this),this.linkElement2d3d=new LP(this),this.linkView2d3d=new RP(this),this.grid=new hD(this),this.level=new mD(this),this.issueReport=new BP(this),this.fabricDraw=new FR(this),this.drawingPin=new OR(this),this.text=new PP(this),this.hdr=new fD(this),this.ground=new rf(this),this.ground.init(),this.skyManager=new xD(this),this.setting.init(),this.worldToScreen=new lt(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new D2,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElement("div");t.className="versionText",this.versionEl=t,this.updateVersionDisplay(),this.container.appendChild(t);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.position="absolute",i.style.zIndex="1000",i.style.left="0px",i.style.top="0px",i.style.pointerEvents="none",this.container.appendChild(i),this.catchSvg=i,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let s=this;this.controls.addEventListener("start",()=>{s.renderer&&(s.renderer.interactionActive=!0),s.events.trigger(dr.EngineBusy),s.container&&(s.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{s.renderer&&(s.renderer.interactionActive=!1),s.events.trigger(dr.EngineFree),s.container&&(s.container.style.cursor="default")}),this.controls.addEventListener("change",()=>{const r=new w.Vector3;s.camera.getWorldDirection(r);const o=Math.atan2(r.x,-r.z);let a=new CustomEvent("D3ViewUpdate",{detail:{position:s.camera.position,rotation:o,type:s.camera.type}});window.dispatchEvent(a)}),this.events.on(dr.LoadingCompleted,r=>{s.modelEdge.active()}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.skyManager.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this._fpsFrameCount++;const r=performance.now();if(r-this._fpsLastCheck>=this._fpsCheckInterval){const o=r-this._fpsLastCheck,a=this._fpsFrameCount/o*1e3;this._fpsFrameCount=0,this._fpsLastCheck=r,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&r-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=r,this._lowFpsCount=0)):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let o=this.scene?.dirLight;o&&this.camera&&this.updateLightPosition(this.camera,o)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",i=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${i}`}updateLightPosition(e,t){const i=new w.Vector3;e.getWorldDirection(i);const s=100,r=new w.Vector3().copy(i).multiplyScalar(-s),o=new w.Vector3(0,1,0),a=new w.Vector3().crossVectors(i,o).normalize();r.addScaledVector(o,s*.5),r.addScaledVector(a,s*.3),t.position.copy(e.position).add(r);const l=new w.Vector3().copy(e.position).add(i.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),i=e.indexOf(t);if(i>0){const s=e[i-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${s}`),this.engineModelModule.autoSwitch(s)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),i=e.indexOf(t);if(i<e.length-1){const s=e[i+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${s}`),this.engineModelModule.autoSwitch(s)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const s=this.deviceModule.getContainerSize();e=e??s.width,t=t??s.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const i=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=i,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const s=this.cameraModule.orthographicCamera,r=this.cameraModule.getOrthographicVisibleHeight(s);this.cameraModule.setOrthographicVisibleHeight(r,s),s.updateProjectionMatrix()}if(this.catchSvg){const s=this.container.clientWidth,r=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${s} ${r}`)}this.fabricDraw&&this.fabricDraw.resize(e,t),this.events&&this.events.trigger(dr.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),this.issueReport&&this.issueReport.dispose(),this.fabricDraw&&this.fabricDraw.dispose(),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(i=>{this.clearScene(i)}),e.parent&&e.parent.remove(e),e instanceof w.Mesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>this.disposeMaterial(i)):this.disposeMaterial(e.material))),e instanceof w.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof w.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof w.InstancedMesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>this.disposeMaterial(i)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof w.Sprite&&e.material&&this.disposeMaterial(e.material)}disposeMaterial(e){if(!e)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(i=>{const s=e[i];s&&s instanceof w.Texture&&s.dispose()}),e.dispose()}}const NR=`
|
|
6057
6057
|
varying vec2 vWorldPos;
|
|
6058
6058
|
|
|
6059
6059
|
void main() {
|