iflow-engine-base 3.5.2 → 3.5.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.
@@ -5257,7 +5257,7 @@ void main() {
5257
5257
  #include <tonemapping_fragment>
5258
5258
  #include <colorspace_fragment>
5259
5259
 
5260
- }`};const gA={turbidity:10,rayleigh:3,mieCoefficient:.005,mieDirectionalG:.7,elevation:2,azimuth:180,exposure:.5,orthoExposureScale:1.5,cloudCoverage:.4,cloudDensity:.4,cloudElevation:.5,showSunDisc:!0},af="sunrise_clear",mA=.2,lf=[{id:"sunrise_clear",names:["晴朗日出","晴朗日出","Clear Sunrise"],params:{turbidity:4,rayleigh:1.8,mieCoefficient:.004,mieDirectionalG:.72,elevation:8,azimuth:105,exposure:.42,cloudCoverage:.12,cloudDensity:.2,cloudElevation:.45,showSunDisc:!0}},{id:"morning_mist",names:["晨雾薄云","晨雾薄云","Misty Morning"],params:{turbidity:14,rayleigh:2.4,mieCoefficient:.018,mieDirectionalG:.68,elevation:12,azimuth:120,exposure:.35,cloudCoverage:.45,cloudDensity:.5,cloudElevation:.35,showSunDisc:!0}},{id:"noon_clear",names:["晴空正午","晴空正午","Clear Noon"],params:{turbidity:2,rayleigh:1,mieCoefficient:.002,mieDirectionalG:.82,elevation:68,azimuth:180,exposure:.58,cloudCoverage:.05,cloudDensity:.12,cloudElevation:.55,showSunDisc:!0}},{id:"afternoon_cloudy",names:["午后多云","午后多云","Cloudy Afternoon"],params:{turbidity:8,rayleigh:1.7,mieCoefficient:.008,mieDirectionalG:.74,elevation:42,azimuth:220,exposure:.5,cloudCoverage:.48,cloudDensity:.42,cloudElevation:.52,showSunDisc:!0}},{id:"sunset_glow",names:["落日晚霞","落日晚霞","Sunset Glow"],params:{turbidity:10,rayleigh:2,mieCoefficient:.006,mieDirectionalG:.7,elevation:6,azimuth:245,exposure:.6,cloudCoverage:.3,cloudDensity:.36,cloudElevation:.5,showSunDisc:!0}},{id:"blue_hour",names:["暮色蓝调","暮色蓝调","Blue Hour"],params:{turbidity:7,rayleigh:1.2,mieCoefficient:.003,mieDirectionalG:.76,elevation:-4,azimuth:255,exposure:.22,cloudCoverage:.2,cloudDensity:.24,cloudElevation:.48,showSunDisc:!1}},{id:"overcast_day",names:["阴天白昼","阴天白昼","Overcast Day"],params:{turbidity:20,rayleigh:2,mieCoefficient:.02,mieDirectionalG:.6,elevation:32,azimuth:180,exposure:.38,cloudCoverage:.86,cloudDensity:.68,cloudElevation:.4,showSunDisc:!1}},{id:"storm_rain",names:["暴雨雷云","暴雨雷云","Storm Rain"],params:{turbidity:19,rayleigh:.9,mieCoefficient:.03,mieDirectionalG:.58,elevation:18,azimuth:210,exposure:.2,cloudCoverage:.95,cloudDensity:.9,cloudElevation:.28,showSunDisc:!1}},{id:"snow_day",names:["雪天漫射","雪天漫射","Snowy Day"],params:{turbidity:15,rayleigh:2.6,mieCoefficient:.012,mieDirectionalG:.65,elevation:24,azimuth:170,exposure:.5,cloudCoverage:.78,cloudDensity:.72,cloudElevation:.43,showSunDisc:!1}},{id:"moonlit_night",names:["月夜星空","月夜星空","Moonlit Night"],params:{turbidity:4,rayleigh:.35,mieCoefficient:.001,mieDirectionalG:.82,elevation:-18,azimuth:160,exposure:.14,cloudCoverage:.1,cloudDensity:.14,cloudElevation:.55,showSunDisc:!1}}],AA=lf.reduce((n,e)=>(n[e.id]=e,n),{}),xA=2e6;class xI{engine;sky=null;sun=new C.Vector3;params={...gA,...AA[af].params};currentPreset=af;currentIntensity=mA;currentEnvironmentTarget=null;skyScale=45e4;skyName="bim_engine_sky";savedCameraFar=null;previousBackground=null;previousEnvironment=null;previousBackgroundIntensity=1;previousEnvironmentIntensity=1;previousToneMapping=C.NoToneMapping;previousToneMappingExposure=1;hasCapturedSceneState=!1;constructor(e){this.engine=e}activate(){if(!this.engine?.scene)return;if(this.sky){this.sky.visible=!0,this._captureSceneState(),this._expandCameraFarForSky(),this._applyParamsToSky();return}const e=new Dc;e.scale.setScalar(this.skyScale),e.name=this.skyName,this.sky=e,this.engine.scene.add(e),this._captureSceneState(),this._expandCameraFarForSky(),this.engine.renderer&&(this.engine.renderer.toneMapping=C.ACESFilmicToneMapping,this.engine.scene.background=null),this._applyParamsToSky()}close(e=!0){this.sky&&(this._restoreCameraFar(),this._restoreSceneState(e),e?(this.engine?.scene?.remove(this.sky),this.sky.material.dispose(),this.sky.geometry.dispose(),this.sky=null):this.sky.visible=!1)}isActive(){return this.sky!=null&&this.engine?.scene?.children?.includes(this.sky)}getParams(){return{...this.params}}setParams(e){Object.assign(this.params,e),this._applyParamsToSky(),this.engine?.renderer&&(e.exposure!==void 0||e.orthoExposureScale!==void 0)&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure())}setPreset(e){const t=AA[e];t&&(this.currentPreset=e,this.params={...gA,...t.params},this._applyParamsToSky(),this.engine?.renderer&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure()))}getCurrentPreset(){return this.currentPreset}getPresetNames(){return lf.map(e=>e.id)}getPresetList(){return lf.map(e=>({id:e.id,names:[...e.names],params:{...e.params}}))}setIntensity(e){if(this.currentIntensity=Math.max(e,0),!(!this.sky?.visible||!this.engine?.scene)){if(!this.currentEnvironmentTarget){this._refreshEnvironmentMap();return}this.engine.scene.environmentIntensity=this.currentIntensity}}getIntensity(){return this.currentIntensity}update(e){if(!this.sky?.visible)return;const t=this.sky.material.uniforms;t&&"time"in t&&(t.time.value=e??performance.now()*.001),this.engine?.renderer&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure())}_isOrthographicCamera(){const e=this.engine?.camera;return e!=null&&e.type==="OrthographicCamera"}_getEffectiveExposure(){const e=this.params.exposure;return this._isOrthographicCamera()?e*this.params.orthoExposureScale:e}_expandCameraFarForSky(){const e=this.engine?.camera;if(!e||typeof e.far!="number")return;const t=e.far;t>=xA||(this.savedCameraFar==null&&(this.savedCameraFar=t),e.far=xA,typeof e.updateProjectionMatrix=="function"&&e.updateProjectionMatrix())}_restoreCameraFar(){if(this.savedCameraFar==null||!this.engine?.camera)return;const e=this.engine.camera;typeof e.far=="number"&&(e.far=this.savedCameraFar,typeof e.updateProjectionMatrix=="function"&&e.updateProjectionMatrix(),this.savedCameraFar=null)}_applyParamsToSky(){if(!this.sky)return;const e=this.sky.material.uniforms;this._setUniformValue(e,"turbidity",this.params.turbidity),this._setUniformValue(e,"rayleigh",this.params.rayleigh),this._setUniformValue(e,"mieCoefficient",this.params.mieCoefficient),this._setUniformValue(e,"mieDirectionalG",this.params.mieDirectionalG),this._setUniformValue(e,"cloudCoverage",this.params.cloudCoverage),this._setUniformValue(e,"cloudDensity",this.params.cloudDensity),this._setUniformValue(e,"cloudElevation",this.params.cloudElevation),this._setUniformValue(e,"showSunDisc",this.params.showSunDisc?1:0);const t=C.MathUtils.degToRad(90-this.params.elevation),i=C.MathUtils.degToRad(this.params.azimuth);this.sun.setFromSphericalCoords(1,t,i),this._setUniformValue(e,"sunPosition",this.sun),this.engine?.renderer&&(this.engine.renderer.toneMapping=C.ACESFilmicToneMapping,this.engine.renderer.toneMappingExposure=this._getEffectiveExposure(),this.sky.visible&&this._refreshEnvironmentMap())}_captureSceneState(){this.hasCapturedSceneState||!this.engine?.scene||(this.previousBackground=this.engine.scene.background,this.previousEnvironment=this.engine.scene.environment,this.previousBackgroundIntensity=this.engine.scene.backgroundIntensity??1,this.previousEnvironmentIntensity=this.engine.scene.environmentIntensity??1,this.previousToneMapping=this.engine.renderer?.toneMapping??C.NoToneMapping,this.previousToneMappingExposure=this.engine.renderer?.toneMappingExposure??1,this.hasCapturedSceneState=!0)}_restoreSceneState(e){!this.hasCapturedSceneState||!this.engine?.scene||(this.engine.scene.background=this.previousBackground,this.engine.scene.environment=this.previousEnvironment,this.engine.scene.backgroundIntensity=this.previousBackgroundIntensity,this.engine.scene.environmentIntensity=this.previousEnvironmentIntensity,this.engine.renderer&&(this.engine.renderer.toneMapping=this.previousToneMapping,this.engine.renderer.toneMappingExposure=this.previousToneMappingExposure),e&&(this._disposeEnvironmentTarget(),this.previousBackground=null,this.previousEnvironment=null,this.previousBackgroundIntensity=1,this.previousEnvironmentIntensity=1,this.previousToneMapping=C.NoToneMapping,this.previousToneMappingExposure=1,this.hasCapturedSceneState=!1))}_refreshEnvironmentMap(){if(!this.sky||!this.engine?.renderer||!this.engine?.scene)return;this._disposeEnvironmentTarget();const e=new C.Scene,t=this.sky.clone();t.material=this.sky.material.clone(),e.add(t);const i=new C.PMREMGenerator(this.engine.renderer);this.currentEnvironmentTarget=i.fromScene(e,0,.1,this.skyScale*2),i.dispose(),this.engine.scene.background=null,this.engine.scene.environment=this.currentEnvironmentTarget.texture,this.engine.scene.environmentIntensity=this.currentIntensity,t.material.dispose()}_disposeEnvironmentTarget(){this.currentEnvironmentTarget?.dispose(),this.currentEnvironmentTarget=null}_setUniformValue(e,t,i){const s=e[t];s&&(i instanceof C.Vector3&&typeof s.value?.copy=="function"?s.value.copy(i):s.value=i)}}class bI{engine;defaultSettings;settings;environmentApplyVersion=0;constructor(e){this.engine=e,this.defaultSettings=this._buildDefaultSettingsFromModules(),this.settings=this._clone(this.defaultSettings)}init(){this.defaultSettings=this._buildDefaultSettingsFromModules(),this.settings=this._clone(this.defaultSettings)}getSettings(){return this._syncSettingsFromModules(),this._clone(this.settings)}getPresetLists(){const e=this.engine.ground?.getGroundList()||[],t=this.engine.hdr?.getHdrList()||[],i=this.engine.skyManager?.getPresetList()||[];return{ground:e.map(s=>this._toPresetItem(s)),hdr:t.map(s=>this._toPresetItem(s)),sky:i.map(s=>this._toPresetItem(s))}}async setSettings(e){e.render&&(Object.assign(this.settings.render,e.render),this._applyRenderSettings(this.settings.render)),e.display&&(Object.assign(this.settings.display,e.display),this._applyDisplaySettings(this.settings.display)),e.environment&&(this._mergeEnvironmentSettings(e.environment),await this._applyEnvironmentSettings(this._clone(this.settings.environment)))}async resetToDefault(){this.settings=this._clone(this.defaultSettings),this._applyRenderSettings(this.settings.render),this._applyDisplaySettings(this.settings.display),await this._applyEnvironmentSettings(this._clone(this.settings.environment))}setRenderMode(e){this.settings.render.mode=e,this.engine.engineModelModule?.switchModel(e)}setContrast(e){this.settings.render.contrast=e,this.engine.engineModelModule?.setContrastValue(.5+e/100)}setSaturation(e){this.settings.render.saturation=e,this.engine.engineModelModule?.setSaturationValue(.5+e/100)}setShadowIntensity(e){this.settings.render.shadowIntensity=e,this._updateDirectionalLight(t=>{t.shadow.intensity=e/100*2})}setLightIntensity(e){this.settings.render.lightIntensity=e,this.setAmbientLightIntensity(e/100)}setGTAOIntensity(e){this.settings.render.gtaoIntensity=e,this.engine.engineModelModule?.setGTAOIntensity(e/100)}setShowEdge(e){this.settings.display.showEdge=e,e?this.engine.modelEdge?.active():this.engine.modelEdge?.disActive()}setEdgeOpacity(e){this.settings.display.edgeOpacity=e,this.engine.modelEdge?.setOpacity(e/100)}setShowGrid(e){this.settings.display.showGrid=e,e?this.engine.grid?.show():this.engine.grid?.hide()}setShowLevel(e){this.settings.display.showLevel=e,e?this.engine.level?.show():this.engine.level?.hide()}setShowGround(e){this.settings.display.showGround=e,e?this.engine.ground?.show():this.engine.ground?.hide()}setGroundId(e){this.settings.display.groundId=e,this.engine.ground?.setGround(e)}setGroundHeight(e){this.settings.display.groundHeight=e,this.engine.ground?.setHeight(e)}async setEnvironmentType(e){this.settings.environment.type=e,await this._applyEnvironmentSettings(this._clone(this.settings.environment))}async setHdrId(e){this.settings.environment.hdrId=e,this.settings.environment.type==="hdr"&&await this._applyEnvironmentSettings(this._clone(this.settings.environment))}setHdrIntensity(e){this.settings.environment.hdrIntensity=e,this.settings.environment.type==="hdr"&&this.engine.hdr?.setIntensity(e/100)}setSkyPreset(e){this.settings.environment.skyPreset=e,this.settings.environment.skyParams={},this.settings.environment.type==="sky"&&this.engine.skyManager?.setPreset(e)}setSkyParams(e){this.settings.environment.skyParams=this._clone(e),this.settings.environment.type==="sky"&&this.engine.skyManager?.setParams(this.settings.environment.skyParams)}setSkyIntensity(e){this.settings.environment.skyIntensity=e,this.settings.environment.type==="sky"&&this.engine.skyManager?.setIntensity(e/100)}setAmbientLightIntensity(e){this.engine.renderer.toneMappingExposure=2*e}_syncSettingsFromModules(){this.settings=this._readCurrentSettingsFromModules()}_buildDefaultSettingsFromModules(){const e=this.engine.composerModule?.saturationPass?.uniforms?.saturation?.value,t=this.engine.composerModule?.saturationPass?.uniforms?.contrast?.value,i=this.engine.composerModule?.gtaoPass?.blendIntensity,s=this.engine.renderer?.toneMappingExposure,r=this.engine.modelEdge?.getOpacity?.(),o=this.engine.hdr?.getCurrentHdrId?.()??Cn,a=this.engine.hdr?.getIntensity?.(),l=this.engine.skyManager?.getIntensity?.(),c=this.engine.skyManager?.getCurrentPreset?.()??af,h=this.engine.skyManager?.isActive?.()===!0;return{render:{mode:this._toRenderMode(this.engine.engineModelModule?.getCurrentMode?.()),contrast:this._uniformToPercent(t,Vg),saturation:this._uniformToPercent(e,Gg),shadowIntensity:this._shadowToPercent(this._getDirectionalLightShadowIntensity(),_c),lightIntensity:this._exposureToPercent(s,Pg),gtaoIntensity:this._unitToPercent(i,zg)},display:{showEdge:this.engine.modelEdge?.isEnabled?.()??of,edgeOpacity:this._unitToPercent(r,pA),showGrid:this.engine.grid?.getVisible?.()??sf,showLevel:this.engine.level?.getVisible?.()??fA,showGround:this.engine.ground?.getVisible?.()??dA,groundId:this.engine.ground?.getCurrentId?.()??cA,groundHeight:this.engine.ground?.getHeight?.()??hA},environment:{type:h?"sky":o!==Cn?"hdr":"none",hdrId:o,hdrIntensity:this._unitToPercent(a,uA),skyPreset:c,skyParams:{},skyIntensity:this._unitToPercent(l,mA)}}}_readCurrentSettingsFromModules(){const e=this.engine.composerModule?.saturationPass?.uniforms?.saturation?.value,t=this.engine.composerModule?.saturationPass?.uniforms?.contrast?.value,i=this.engine.composerModule?.gtaoPass?.blendIntensity,s=this.engine.renderer?.toneMappingExposure,r=this.engine.modelEdge?.getOpacity?.(),o=this.engine.hdr?.getCurrentHdrId?.()??this.settings.environment.hdrId,a=this.engine.hdr?.getIntensity?.(),l=this.engine.skyManager?.getIntensity?.(),c=this.engine.skyManager?.getCurrentPreset?.()??this.settings.environment.skyPreset,h=this.engine.skyManager?.getParams?.(),d=this.engine.skyManager?.isActive?.()===!0;return{render:{mode:this._toRenderMode(this.engine.engineModelModule?.getCurrentMode?.()??this.settings.render.mode),contrast:this._uniformToPercent(t,this.settings.render.contrast/100+.5),saturation:this._uniformToPercent(e,this.settings.render.saturation/100+.5),shadowIntensity:this._shadowToPercent(this._getDirectionalLightShadowIntensity(),this.settings.render.shadowIntensity/50),lightIntensity:this._exposureToPercent(s,this.settings.render.lightIntensity/50),gtaoIntensity:this._unitToPercent(i,this.settings.render.gtaoIntensity/100)},display:{showEdge:this.engine.modelEdge?.isEnabled?.()??this.settings.display.showEdge,edgeOpacity:this._unitToPercent(r,this.settings.display.edgeOpacity/100),showGrid:this.engine.grid?.getVisible?.()??this.settings.display.showGrid,showLevel:this.engine.level?.getVisible?.()??this.settings.display.showLevel,showGround:this.engine.ground?.getVisible?.()??this.settings.display.showGround,groundId:this.engine.ground?.getCurrentId?.()??this.settings.display.groundId,groundHeight:this.engine.ground?.getHeight?.()??this.settings.display.groundHeight},environment:{type:d?"sky":o!==Cn?"hdr":"none",hdrId:o,hdrIntensity:this._unitToPercent(a,this.settings.environment.hdrIntensity/100),skyPreset:c,skyParams:h?this._clone(h):this._clone(this.settings.environment.skyParams),skyIntensity:this._unitToPercent(l,this.settings.environment.skyIntensity/100)}}}_toRenderMode(e){return e==="simple"||e==="balance"||e==="advanced"?e:q2}_uniformToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent((i-.5)*100)}_shadowToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent(i*50)}_exposureToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent(i*50)}_unitToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent(i*100)}_clampPercent(e){return Math.min(100,Math.max(0,Math.round(e)))}_getDirectionalLightShadowIntensity(){const e=this.engine.scene?.children?.filter(i=>i instanceof C.DirectionalLight);return!e||e.length===0?_c:(e.find(i=>i.castShadow)??e[0]).shadow?.intensity??_c}_applyRenderSettings(e){this.setRenderMode(e.mode),this.setContrast(e.contrast),this.setSaturation(e.saturation),this.setShadowIntensity(e.shadowIntensity),this.setLightIntensity(e.lightIntensity),this.setGTAOIntensity(e.gtaoIntensity)}_applyDisplaySettings(e){this.setShowEdge(e.showEdge),this.setEdgeOpacity(e.edgeOpacity),this.setShowGrid(e.showGrid),this.setShowLevel(e.showLevel),this.setShowGround(e.showGround),this.setGroundId(e.groundId),this.setGroundHeight(e.groundHeight)}async _applyEnvironmentSettings(e){const t=++this.environmentApplyVersion;if(await this.engine.hdr?.setHdr(Cn),t===this.environmentApplyVersion&&(this.engine.skyManager?.close(!0),t===this.environmentApplyVersion))switch(e.type){case"none":break;case"hdr":if(e.hdrId!==Cn){if(await this.engine.hdr?.setHdr(e.hdrId),t!==this.environmentApplyVersion){this._applyEnvironmentSettings(this._clone(this.settings.environment));return}this.engine.hdr?.setIntensity(e.hdrIntensity/100)}break;case"sky":this.engine.skyManager?.activate(),this.engine.skyManager?.setPreset(e.skyPreset),Object.keys(e.skyParams).length>0&&this.engine.skyManager?.setParams(this._clone(e.skyParams)),this.engine.skyManager?.setIntensity(e.skyIntensity/100);break}}_updateDirectionalLight(e){const t=this.engine.scene?.children.find(i=>i instanceof C.DirectionalLight);t&&e(t)}_mergeEnvironmentSettings(e){Object.assign(this.settings.environment,e),e.skyPreset!==void 0&&e.skyParams===void 0&&(this.settings.environment.skyParams={}),e.skyParams!==void 0&&(this.settings.environment.skyParams=this._clone(e.skyParams))}_toPresetItem(e){const t=Array.isArray(e.names)?[...e.names]:[];return{id:e.id,name:t[0]??e.id,names:t}}_clone(e){return JSON.parse(JSON.stringify(e))}}function Kn(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var e=Math.random()*16|0,t=n=="x"?e:e&3|8;return t.toString(16)})}class $n{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=_u(e),this.handelBehaved.init(this,null),this.setting={unit:"m",precision:3}}getSetting(){return this.setting}saveSetting(e){this.setting=e}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}getMeasureText(e,t){if(e==null)return null;let i=this.setting.unit,s=i;return t==1?i=="mm"?e=e*1e3:i=="cm"?e=e*100:i=="dm"?e=e*10:i=="m"?e=e*1:i=="km"&&(e=e*.001):t==2&&(i=="mm"?e=e*1e3*1e3:i=="cm"?e=e*100*100:i=="dm"?e=e*10*10:i=="m"?e=e*1*1:i=="km"&&(e=e*.001*.001),s=s+"²"),e.toFixed(this.setting.precision)+" "+s}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(i=>{i.highlight==!0&&(i.highlight=!1,i.container.classList.remove("Hight"),i.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let i=e[t].length-1;i>=0;i--){let s=e[t][i];s.isSelect==!0&&(s.container.remove(),e[t].splice(i,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let i=e[t].length-1;i>=0;i--){let s=e[t][i];s.highlight==!0&&(s.container.remove(),e[t].splice(i,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(i=>{i.highlight=!1,i.container.classList.remove("Hight"),i.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(g=>{u(g)}),this.engine.measure.annotationData.elevationAnnotation.forEach(g=>{f(g)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(g=>{d(g)}),this.engine.measure.annotationData.angleAnnotation.forEach(g=>{l(g)}),this.engine.measure.annotationData.areaAnnotation.forEach(g=>{c(g)}),this.engine.measure.annotationData.slopeAnnotation.forEach(g=>{h(g)});function l(g){if(g.container==null){let S=['<svg class="measureSvg">','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel">'+g.text+"</text>","</svg>"].join("");g.container=document.createElement("div"),g.container.className="angle-annotation",g.container.id=g.id,g.container.style.pointerEvents="none",g.container.innerHTML=S,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}let p=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point1),m=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point2),A=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point3),x=e.engine.reactBoundingClientRect.left,b=e.engine.reactBoundingClientRect.top;p.x+=x,p.y+=b,m.x+=x,m.y+=b,A.x+=x,A.y+=b;let y=g.container;y.getElementsByTagName("circle")[0].setAttribute("cx",p.x),y.getElementsByTagName("circle")[0].setAttribute("cy",p.y),y.getElementsByTagName("circle")[1].setAttribute("cx",m.x),y.getElementsByTagName("circle")[1].setAttribute("cy",m.y),y.getElementsByTagName("circle")[2].setAttribute("cx",A.x),y.getElementsByTagName("circle")[2].setAttribute("cy",A.y),y.getElementsByTagName("polyline")[0].setAttribute("points",p.x+","+p.y+" "+m.x+","+m.y),y.getElementsByTagName("polyline")[1].setAttribute("points",m.x+","+m.y+" "+A.x+","+A.y);let _=m.x,w=m.y-30;y.getElementsByTagName("rect")[0].setAttribute("x",_-40),y.getElementsByTagName("rect")[0].setAttribute("y",w-12.5),y.getElementsByTagName("text")[0].setAttribute("x",_),y.getElementsByTagName("text")[0].setAttribute("y",w+4),y.getElementsByTagName("text")[0].innerHTML=g.text,y.style.top="0px",y.style.left="0px"}function c(g){if(g.container==null){let D=['<svg class="measureSvg">','<polygon fill="rgba(0, 0, 255, 0.1)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>','<polyline class="measureLine" stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel"> '+e.getMeasureText(g.text,2)+"</text>","</svg>"].join("");g.container=document.createElement("div"),g.container.className="area-annotation",g.container.id=g.id,g.container.innerHTML=D,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}if(!g.points||g.points.length<3)return;let p=e.engine.reactBoundingClientRect.left,m=e.engine.reactBoundingClientRect.top,A=[],x=0,b=0;for(let D=0;D<g.points.length;D++){let M=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.points[D]);M.x+=p,M.y+=m,A.push(M),x+=M.x,b+=M.y}x=x/A.length,b=b/A.length;let y=A.map(D=>D.x+","+D.y).join(" "),_=g.container;_.getElementsByTagName("polygon")[0].setAttribute("points",y),_.getElementsByTagName("polyline")[0].setAttribute("points",y);let w=x,S=b;_.getElementsByTagName("rect")[0].setAttribute("x",w-40),_.getElementsByTagName("rect")[0].setAttribute("y",S-12.5),_.getElementsByTagName("text")[0].setAttribute("x",w+10),_.getElementsByTagName("text")[0].setAttribute("y",S+4),_.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(g.text,2),_.style.top="0px",_.style.left="0px"}function h(g){if(g.container==null){let w=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+g.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path class="measureLine" d="M0,0 L0,6 L9,3 z"/>',"</marker>","</defs>",'<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-'+g.id+')" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel"> '+g.text+"</text>","</svg>"].join("");g.container=document.createElement("div"),g.container.className="slope-annotation",g.container.id=g.id,g.container.innerHTML=w,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}let p=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point1),m=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point2),A=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;p.x+=A,p.y+=x,m.x+=A,m.y+=x;let b=g.container;b.getElementsByTagName("polyline")[0].setAttribute("points",p.x+","+p.y+" "+m.x+","+m.y);let y=(p.x+m.x)/2,_=(p.y+m.y)/2-30;b.getElementsByTagName("rect")[0].setAttribute("x",y-50),b.getElementsByTagName("rect")[0].setAttribute("y",_-12.5),b.getElementsByTagName("text")[0].setAttribute("x",y),b.getElementsByTagName("text")[0].setAttribute("y",_+4),b.getElementsByTagName("text")[0].innerHTML=g.text,b.style.top="0px",b.style.left="0px"}function d(g){if(g.container==null){let S=['<svg class="measureSvg">','<circle class="measurePointer" cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="50" y="-11" text-anchor="middle" class="measureLabel"> X: '+e.getMeasureText(g.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="50" y="25" text-anchor="middle" class="measureLabel"> Y: '+e.getMeasureText(-g.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="50" y="51" text-anchor="middle" class="measureLabel"> Z: '+e.getMeasureText(g.textY,1)+"</text>","</svg>"].join("");g.container=document.createElement("div"),g.container.className="coordinate-annotation",g.container.id=g.id,g.container.style.position="absolute",g.container.style.pointerEvents="none",g.container.innerHTML=S,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}let p=g.container,m=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point),A=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;m.x+=A,m.y+=x,p.style.top="0px",p.style.left="0px";let b=p.getElementsByTagName("circle")[0];b&&(b.setAttribute("cx",m.x),b.setAttribute("cy",m.y));let y=p.getElementsByTagName("rect"),_=p.getElementsByTagName("text"),w=-55;y[0]&&(y[0].setAttribute("x",m.x+10),y[0].setAttribute("y",m.y+10+w)),_[0]&&(_[0].setAttribute("x",m.x+10+50),_[0].setAttribute("y",m.y+10+16+w)),y[1]&&(y[1].setAttribute("x",m.x+10),y[1].setAttribute("y",m.y+10+30+w)),_[1]&&(_[1].setAttribute("x",m.x+10+50),_[1].setAttribute("y",m.y+10+46+w)),y[2]&&(y[2].setAttribute("x",m.x+10),y[2].setAttribute("y",m.y+10+60+w)),_[2]&&(_[2].setAttribute("x",m.x+10+50),_[2].setAttribute("y",m.y+10+76+w)),_[0]&&(_[0].innerHTML="X: "+e.getMeasureText(g.textX,1)),_[1]&&(_[1].innerHTML="Y: "+e.getMeasureText(-g.textZ,1)),_[2]&&(_[2].innerHTML="Z: "+e.getMeasureText(g.textY,1))}function f(g){if(g.container==null){let b=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel"> '+e.getMeasureText(g.text,1)+"</text>",'<polyline class="measureLine" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");g.container=document.createElement("div"),g.container.className="elevation-annotation",g.container.id=g.id,g.container.style.position="absolute",g.container.style.pointerEvents="none",g.container.innerHTML=b,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}let p=g.container,m=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point),A=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;p.style.top=m.y+x-48+"px",p.style.left=m.x+A-16+"px",p.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(g.text,1)}function u(g){if(g.container==null){let y=['<svg class="measureSvg">','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline class="measureLine" stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel"> '+e.getMeasureText(g.text,1)+"</text>","</svg>"].join("");g.container=document.createElement("div"),g.container.className="normal-annotation",g.container.id=g.id,g.container.innerHTML=y,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}let p=g.container;if(g.point1==null||g.point2==null){p.style.display="none";return}else p.style.display="block";let m=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point1),A=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point2),x=e.engine.reactBoundingClientRect.left,b=e.engine.reactBoundingClientRect.top;m.x+=x,m.y+=b,A.x+=x,A.y+=b,p.getElementsByTagName("polyline")[0].setAttribute("points",m.x+","+m.y+" "+A.x+","+A.y),p.getElementsByTagName("circle")[0].setAttribute("cx",m.x),p.getElementsByTagName("circle")[0].setAttribute("cy",m.y),p.getElementsByTagName("circle")[1].setAttribute("cx",A.x),p.getElementsByTagName("circle")[1].setAttribute("cy",A.y),p.getElementsByTagName("rect")[0].setAttribute("x",m.x*.5+A.x*.5-40),p.getElementsByTagName("rect")[0].setAttribute("y",m.y*.5+A.y*.5-12.5),p.getElementsByTagName("text")[0].setAttribute("x",m.x*.5+A.x*.5+50-40),p.getElementsByTagName("text")[0].setAttribute("y",m.y*.5+A.y*.5+16-12.5),p.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(g.text,1),p.style.top="0px",p.style.left="0px"}}}class yI{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}setDirection(e){this.catchDir=e}setSelectType(e){this.type=e}getMeshesMinMaxY(e){if(!Array.isArray(e)||e.length===0)return null;let t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(let s=0;s<e.length;s++){const r=e[s];if(!r)continue;typeof r.updateMatrixWorld=="function"&&r.updateMatrixWorld(!0);const o=new C.Box3().setFromObject(r);!Number.isFinite(o.min.y)||!Number.isFinite(o.max.y)||(o.min.y<t&&(t=o.min.y),o.max.y>i&&(i=o.max.y))}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minY:t,maxY:i}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let r=this.engine.interactionModule.getCatchMeshs(e);var i=this.getMeshesMinMaxY(r);this.catchDir==0?t.set(t.x,i?.minY,t.z):t.set(t.x,i?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(t);return}let s=this.engine.measure.annotationData.normalAnnotation.find(r=>r.isSelect==!0);s!=null&&(s.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);t==null&&(t={text:null,id:Kn(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let i=e.catch;if(this.type=="element"){let s=e.catch.point.clone();s.set(s.x,this.points[0].y,s.z);let r=new C.Raycaster(s.add(new C.Vector3(0,.01,0)),new C.Vector3(0,this.catchDir==0?-1:1,0));i.point=this.points[0];const o=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(r))??this.engine.octreeBox.rayInterationModel(r);if(o.length===0){t.point2=null;return}t.point1=s,t.point2=o[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Mt.MeasureChanged,t)}else{let s=new C.Raycaster(e.catch.point.clone().add(new C.Vector3(0,.01,0)),new C.Vector3(0,this.catchDir==0?-1:1,0));const r=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(s))??this.engine.octreeBox.rayInterationModel(s);if(r.length===0){t.point2=null;return}t.point1=i.point,t.point2=r[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Mt.MeasureChanged,t)}}}class vI{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.isActive=!1,this.engine.handelBehaved.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1){let i=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);if(i==null)return;i.point2=t.point,i.isSelect=!1,this.points=[],this.engine.events.trigger(Mt.MeasureChanged,i)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let i=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);i==null&&(i={id:Kn(),point1:this.points[0].clone(),point2:t.point.clone(),text:this.points[0].clone().distanceTo(t.point.clone()),type:"distance",isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(i)),i.point2=t.point,i.text=i.point1.clone().distanceTo(i.point2.clone())}}}class _I{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(o=>o.isSelect==!0);t==null&&(t={text:null,id:Kn(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let i=new C.Raycaster(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.normal);const s=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(i))??this.engine.octreeBox.rayInterationModel(i);if(s.length==0){t.point2=null;return}let r=e.catch;t.point1=r.point,t.point2=s[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Mt.MeasureChanged,t)}}class CI{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(i=>i.isSelect==!0);t==null&&(t={id:Kn(),point:e.catch.point.clone(),text:e.catch.point.y,isSelect:!0,type:"elevation"},this.engine.measure.annotationData.elevationAnnotation.push(t)),t.point=e.catch.point.clone(),t.text=e.catch.point.y}handleMouseClick(e){if(e.catch==null)return;this.engine.measure.tools.clearHighlight();let t=this.engine.measure.annotationData.elevationAnnotation.find(i=>i.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(Mt.MeasureChanged,t))}}class wI{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseUp(e){this.engine.deviceType!="PC"&&this.createMeasure()}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(i=>i.isSelect==!0);t!=null&&(t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z)}handleMouseClick(e){if(e.catch==null)return;this.engine.measure.tools.clearHighlight();let t=this.engine.measure.annotationData.coordinateAnnotation.find(i=>i.isSelect==!0);if(t==null){t={id:Kn(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t);return}t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,t.isSelect=!1,this.engine.events.trigger(Mt.MeasureChanged,t)}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(Mt.MeasureChanged,e))}}class SI{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,i){const s=new C.Vector3().subVectors(e,t),r=new C.Vector3().subVectors(i,t),o=s.length(),a=r.length();if(o===0||a===0)return 0;const c=s.dot(r)/(o*a),h=Math.max(-1,Math.min(1,c));return Math.acos(h)*(180/Math.PI)}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1)this.points.push(t.point);else if(this.points.length==2){let i=this.engine.measure.annotationData.angleAnnotation.find(s=>s.isSelect==!0);if(i==null)return;i.point3=t.point.clone(),i.angle=this.calculateAngle(i.point1,i.point2,i.point3),i.text=i.angle.toFixed(2)+"°",i.isSelect=!1,i.type="angle",this.points=[],this.engine.events.trigger(Mt.MeasureChanged,i)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);t==null&&(t={id:Kn(),point1:this.points[0].clone(),point2:this.points[1].clone(),point3:e.catch.point.clone(),angle:0,text:"0.00°",isSelect:!0,type:"angle"},this.engine.measure.annotationData.angleAnnotation.push(t)),t.point3=e.catch.point.clone(),t.angle=this.calculateAngle(t.point1,t.point2,t.point3),t.text=t.angle.toFixed(2)+"°",console.log("角度",t.text)}}}class MI{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateArea(e){if(e.length<3)return 0;const t=e.length,i=new C.Vector3(0,0,0);for(let s=0;s<t;s++){const r=(s+1)%t;i.x+=(e[s].y-e[r].y)*(e[s].z+e[r].z),i.y+=(e[s].z-e[r].z)*(e[s].x+e[r].x),i.z+=(e[s].x-e[r].x)*(e[s].y+e[r].y)}return i.length()/2}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.push(t.point.clone()),this.points.length>=3){let i=this.engine.measure.annotationData.areaAnnotation.find(s=>s.isSelect==!0);i==null?(i={id:Kn(),points:this.points.map(s=>s.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(i)):(this.points.push(t.point.clone()),i.points=this.points.map(s=>s.clone())),i.area=this.calculateArea(i.points),i.text=i.area,console.log("面积",i.text)}else this.engine.measure.tools.clearHighlight()}handleMouseMove(e){if(e.catch!=null&&this.points.length>=2){let t=this.engine.measure.annotationData.areaAnnotation.find(i=>i.isSelect==!0);if(t==null){if(this.points.length>=2){let i=this.points.map(s=>s.clone());i.push(e.catch.point.clone()),i.length>=3&&(t={id:Kn(),points:i,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const i=t.points.length-1;t.points[i]=e.catch.point.clone()}else t.points=this.points.map(i=>i.clone()),t.points.push(e.catch.point.clone());t&&t.points.length>=3&&(t.area=this.calculateArea(t.points),t.text=t.area)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){this.points=this.points.slice(0,this.points.length-1);let e=this.engine.measure.annotationData.areaAnnotation.find(t=>t.isSelect==!0);e!=null&&e.points.length>=3&&(e.points.length>this.points.length&&(e.points=this.points.map(t=>t.clone())),e.area=this.calculateArea(e.points),e.text=e.area,e.isSelect=!1,this.points=[],this.engine.events.trigger(Mt.MeasureChanged,e))}}class EI{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateSlope(e,t){const i=t.y-e.y,s=t.x-e.x,r=t.z-e.z,o=Math.sqrt(s*s+r*r);if(o===0)return{percentage:0,angle:0,heightDiff:i,horizontalDist:0,type:"slope"};const a=i/o*100,c=Math.atan(i/o)*(180/Math.PI);return{percentage:a,angle:c,heightDiff:i,horizontalDist:o,type:"slope"}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1){let i=this.engine.measure.annotationData.slopeAnnotation.find(r=>r.isSelect==!0);if(i==null)return;console.log("进来了"),i.point2=t.point.clone();const s=this.calculateSlope(i.point1,i.point2);i.slopePercentage=s.percentage,i.slopeAngle=s.angle,i.heightDiff=s.heightDiff,i.horizontalDist=s.horizontalDist,i.text=s.percentage.toFixed(2)+"% ("+s.angle.toFixed(2)+"°)",i.isSelect=!1,this.points=[],this.engine.events.trigger(Mt.MeasureChanged,i)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let i=this.engine.measure.annotationData.slopeAnnotation.find(r=>r.isSelect==!0);i==null&&(i={id:Kn(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0,type:"slope"},this.engine.measure.annotationData.slopeAnnotation.push(i)),i.point2=t.point.clone();const s=this.calculateSlope(i.point1,i.point2);i.slopePercentage=s.percentage,i.slopeAngle=s.angle,i.heightDiff=s.heightDiff,i.horizontalDist=s.horizontalDist,i.text=s.percentage.toFixed(2)+"% ("+s.angle.toFixed(2)+"°)"}}}class II{isActive=!1;engine;clearHeightMeasure;distanceMeasure;clearDistanceMeasure;elevationMeasure;pointMeasure;angleMeasure;areaMeasure;slopeMeasure;tools;annotationContainer;annotationData={normalAnnotation:[],textAnnotation:[],coordinateAnnotation:[],angleAnnotation:[],distanceAnnotation:[],areaAnnotation:[],slopeAnnotation:[],elevationAnnotation:[],volumeAnnotation:[]};constructor(e){this.engine=e,this.clearHeightMeasure=new yI(e),this.distanceMeasure=new vI(e),this.clearDistanceMeasure=new _I(e),this.elevationMeasure=new CI(e),this.pointMeasure=new wI(e),this.angleMeasure=new SI(e),this.areaMeasure=new MI(e),this.slopeMeasure=new EI(e),this.tools=new $n(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.engine.modelEdge.loadModelEdge(),this.tools.active()}disActive(){this.tools.disActive(),this.clearAll(),this.isActive=!1,this.clearHeightMeasure.disActive(),this.distanceMeasure.disActive(),this.clearDistanceMeasure.disActive(),this.elevationMeasure.disActive(),this.pointMeasure.disActive(),this.angleMeasure.disActive(),this.areaMeasure.disActive(),this.slopeMeasure.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active()}clearAllPoints(){this.clearHeightMeasure.clearAllPoints(),this.distanceMeasure.clearAllPoints(),this.clearDistanceMeasure.clearAllPoints(),this.elevationMeasure.clearAllPoints(),this.pointMeasure.clearAllPoints(),this.angleMeasure.clearAllPoints(),this.areaMeasure.clearAllPoints(),this.slopeMeasure.clearAllPoints()}clearAll(){e(this.annotationData.normalAnnotation),e(this.annotationData.textAnnotation),e(this.annotationData.coordinateAnnotation),e(this.annotationData.angleAnnotation),e(this.annotationData.distanceAnnotation),e(this.annotationData.areaAnnotation),e(this.annotationData.slopeAnnotation),e(this.annotationData.elevationAnnotation),e(this.annotationData.volumeAnnotation);function e(t){for(let i=0;i<t.length;i++)t[i].container.remove();t=[]}}saveSetting(e){this.tools.saveSetting(e)}getSetting(){return this.tools.getSetting()}update(){this.isActive&&this.tools.drawNormalAnnotation()}}class TI{engine;isActive=!1;isCtrlDown=!1;listenersAttached=!1;box;pickPoint;pickNormal;pickMesh;box_;plane;meshs;isDrag=!1;maxBox;faceIdleOpacity=0;faceHoverOpacity=.05;transformControls=new Map;transformAnchors=new Map;transformHelpers=new Map;faceMetaMap=new Map;isSyncingTransform=!1;transformHandleSize=1.05;transformHandleColor=16777215;transformHandleHoverColor=16776960;handleNativeMouseDown=e=>{if(e.button!==0||!(this.isCtrlDown||e.ctrlKey))return;const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);i.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:i}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:i})};handleNativeMouseUp=e=>{e.button!==0||!this.isDrag||(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseUp({button:e.button}))};handleNativeKeyDown=e=>{e.key==="Control"&&(this.isCtrlDown=!0)};handleNativeKeyUp=e=>{e.key==="Control"&&(this.isCtrlDown=!1,this.isDrag&&this.handleMouseUp({button:0}),this.resetMeshOpacity())};constructor(e,t){this.engine=e,this.meshs=[]}active(){this.isActive||(this.attachListeners(),this.init(),this.setTransformControlsVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}disActive(){this.init(!1),this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0},!1),this.setTransformControlsVisible(!1),this.clearClippingBoxFill(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}disabled(){this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0},!1),this.setTransformControlsVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}recover(){this.isActive||(this.attachListeners(),this.setTransformControlsVisible(!0),this.updateClippingBoxFill(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}init(e=!0){const t=this.engine.octreeBox.getBoundingBox();t.min.x-=.1,t.min.y-=.1,t.min.z-=.1,t.max.x+=.1,t.max.y+=.1,t.max.z+=.1,this.maxBox=JSON.parse(JSON.stringify(t)),this.box=t,this.updata_face(t),e&&this.updateClippingBoxFill()}getboxXyz(){return{minX:this.box.min.x,minY:this.box.min.y,minZ:this.box.min.z,maxX:this.box.max.x,maxY:this.box.max.y,maxZ:this.box.max.z}}setboxXyz(e){this.box.min.x=e.minX,this.box.min.y=e.minY,this.box.min.z=e.minZ,this.box.max.x=e.maxX,this.box.max.y=e.maxY,this.box.max.z=e.maxZ,this.updata_face(this.box),this.updateClippingBoxFill()}setBox(e){this.box=e,this.updata_face(e),this.updateClippingBoxFill()}reverseBox(){}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){this.clearClippingBoxFill();const i=t[0];this.isDrag=!0,this.pickPoint=i.point.clone(),this.pickMesh=i.object;const s=this.pickMesh?.userData?.dragNormal?.clone?.(),r=i.face?.normal?.clone?.();if(this.pickNormal=(s??r??new C.Vector3(0,0,1)).clone().normalize(),this.engine.controls.enabled=!1,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.pickNormal.y==0){const o=new C.Plane;o.setFromNormalAndCoplanarPoint(new C.Vector3(0,1,0),this.pickPoint),this.plane=o}else{const o=new C.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z),a=new C.Plane;a.setFromNormalAndCoplanarPoint(o.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=a}}else this.isDrag=!1}handleMouseUp(e,t=!0){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.plane=null,this.engine.controls.enabled=!0,t&&this.updateClippingBoxFill()}clampVector3(e,t,i){return new C.Vector3(Math.max(t.x,Math.min(i.x,e.x)),Math.max(t.y,Math.min(i.y,e.y)),Math.max(t.z,Math.min(i.z,e.z)))}handleMouseMove(e){this.resetMeshOpacity();const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=this.faceHoverOpacity),this.pickPoint!=null){const i=new C.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,i)){const s=i.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());if(!!this.pickMesh?.userData?.isMinFace){const o=this.box_.min.clone().add(this.pickNormal.clone().setLength(s));this.box.min=this.clampVector3(o,this.maxBox.min,this.box.max)}else{const o=this.box_.max.clone().add(this.pickNormal.clone().setLength(s));this.box.max=this.clampVector3(o,this.box.min,this.maxBox.max)}this.updata_face(this.box),this.calculate_ratio()}}}calculate_ratio(){const e=this.maxBox.max.x-this.maxBox.min.x,t=this.maxBox.max.y-this.maxBox.min.y,i=this.maxBox.max.z-this.maxBox.min.z,s=this.toPercent((this.box.min.x-this.maxBox.min.x)/e*100),r=this.toPercent((this.box.max.x-this.maxBox.min.x)/e*100),o=this.toPercent((this.box.min.y-this.maxBox.min.y)/t*100),a=this.toPercent((this.box.max.y-this.maxBox.min.y)/t*100),l=this.toPercent((this.box.min.z-this.maxBox.min.z)/i*100),c=this.toPercent((this.box.max.z-this.maxBox.min.z)/i*100),h={x:{min:s,max:r},y:{min:o,max:a},z:{min:l,max:c}};this.engine.events.trigger(Mt.SectionMove,h)}toPercent(e){return e<0?0:e>100?100:e}getInteractiveMeshes(){return this.meshs.filter(e=>e.type==="Mesh")}createRaycasterFromMouseEvent(e){const t=new C.Raycaster,i=new C.Vector2,s=this.engine.renderer.domElement.clientWidth,r=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/s*2-1,i.y=-(e.offsetY/r)*2+1,t.setFromCamera(i,this.engine.camera),t}attachListeners(){if(this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.handleNativeMouseDown,!0),e.addEventListener("mousemove",this.handleNativeMouseMove,!0),e.addEventListener("mouseup",this.handleNativeMouseUp,!0),window.addEventListener("keydown",this.handleNativeKeyDown),window.addEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!0)}detachListeners(){if(!this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.handleNativeMouseDown,!0),e.removeEventListener("mousemove",this.handleNativeMouseMove,!0),e.removeEventListener("mouseup",this.handleNativeMouseUp,!0)),window.removeEventListener("keydown",this.handleNativeKeyDown),window.removeEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!1,this.isCtrlDown=!1}resetMeshOpacity(){this.getInteractiveMeshes().forEach(e=>{e.material&&(e.material.opacity=this.faceIdleOpacity)})}updateClippingBoxFill(){const e=(Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:[]).slice(0,6).filter(t=>t instanceof C.Plane);if(e.length===0){this.clearClippingBoxFill();return}this.engine.clipping?.clippingCSGSimple?.updataFaces?.(e)}clearClippingBoxFill(){this.engine.clipping?.clippingCSGSimple?.clear?.()}getFaceTransformOffset(){if(!this.box)return .06;const e=this.box.min.distanceTo(this.box.max);return Math.max(e*.015,.06)}keepSingleDirectionArrow(e,t="X"){const i=e.getHelper(),s=[];i.traverse(r=>{if(r?.name!==t||!r.geometry)return;const o=r.geometry;o.boundingBox||o.computeBoundingBox();const a=o.boundingBox;if(!a)return;const l=a.getCenter(new C.Vector3);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const h=o.parameters,d=h&&h.radiusTop===0&&h.radiusBottom===.04&&h.height===.1,f=h&&h.radiusTop===.2&&h.radiusBottom===0&&h.height===.6;(d||f)&&s.push(r)}),s.forEach(r=>{r.parent?.remove(r)})}setTransformControlsVisible(e){this.transformControls.forEach(t=>{t.enabled=e}),this.transformHelpers.forEach(t=>{t.visible=e}),this.transformAnchors.forEach(t=>{t.visible=e}),e||(this.engine.controls.enabled=!0)}ensureFaceTransformControl(e){if(this.transformControls.has(e)&&this.transformAnchors.has(e))return;const t=this.engine.renderer?.domElement,i=this.engine.camera;if(!t||!i)return;const s=new C.Object3D;s.name=`SectionBoxTransformAnchor_${e}`,s.visible=this.isActive,this.engine.scene.add(s);const r=new sA(i,t);r.name=`SectionBoxTransformControl_${e}`,r.setMode("translate"),r.setSpace("local"),r.showX=!0,r.showY=!1,r.showZ=!1,r.size=this.transformHandleSize,r.setColors(this.transformHandleColor,this.transformHandleColor,this.transformHandleColor,this.transformHandleHoverColor),r.enabled=this.isActive,r.attach(s),this.keepSingleDirectionArrow(r,"X"),r.addEventListener("dragging-changed",a=>{this.engine.controls.enabled=!a.value,a.value===!0?this.clearClippingBoxFill():this.updateClippingBoxFill()}),r.addEventListener("objectChange",()=>{this.handleTransformObjectChange(e)});const o=r.getHelper();o.visible=this.isActive,this.engine.scene.add(o),this.transformAnchors.set(e,s),this.transformControls.set(e,r),this.transformHelpers.set(e,o)}updateFaceTransformControl(e,t,i,s){this.ensureFaceTransformControl(e);const r=this.transformAnchors.get(e),o=this.transformControls.get(e);if(!r||!o)return;const a=this.getFaceTransformOffset(),l=new C.Quaternion().setFromUnitVectors(new C.Vector3(1,0,0),t.clone().normalize()),c=i.clone().add(t.clone().setLength(a));this.faceMetaMap.set(e,{normal:t.clone().normalize(),isMinFace:s,center:i.clone()}),this.isSyncingTransform=!0,r.position.copy(c),r.quaternion.copy(l),r.visible=this.isActive,o.object!==r&&o.attach(r),o.enabled=this.isActive;const h=this.transformHelpers.get(e);h&&(h.visible=this.isActive),this.isSyncingTransform=!1}getDominantAxis(e){const t=Math.abs(e.x),i=Math.abs(e.y),s=Math.abs(e.z);return t>=i&&t>=s?"x":i>=t&&i>=s?"y":"z"}handleTransformObjectChange(e){if(this.isSyncingTransform)return;const t=this.transformAnchors.get(e),i=this.faceMetaMap.get(e);if(!t||!i||!this.box||!this.maxBox)return;const s=i.normal,r=this.getDominantAxis(s),o=this.getFaceTransformOffset(),a=s[r],l=t.position[r]-a*o;if(i.isMinFace){const c=this.maxBox.min[r],h=this.box.max[r];this.box.min[r]=Math.max(c,Math.min(h,l))}else{const c=this.box.min[r],h=this.maxBox.max[r];this.box.max[r]=Math.max(c,Math.min(h,l))}this.updata_face(this.box),this.calculate_ratio()}updata_face(e){let t=this.engine.scene.children.find(s=>s.type=="Group"&&s.name=="ClippingBox");t==null&&(t=new C.Group,t.name="ClippingBox",this.engine.scene.add(t)),[{name:"前",normal:new C.Vector3(0,0,-1),isMinFace:!0,planePoint:e.min,vertices:[new C.Vector3(e.min.x,e.max.y,e.min.z),new C.Vector3(e.max.x,e.max.y,e.min.z),new C.Vector3(e.max.x,e.min.y,e.min.z),new C.Vector3(e.min.x,e.min.y,e.min.z)]},{name:"后",normal:new C.Vector3(0,0,1),isMinFace:!1,planePoint:e.max,vertices:[new C.Vector3(e.min.x,e.min.y,e.max.z),new C.Vector3(e.max.x,e.min.y,e.max.z),new C.Vector3(e.max.x,e.max.y,e.max.z),new C.Vector3(e.min.x,e.max.y,e.max.z)]},{name:"右",normal:new C.Vector3(1,0,0),isMinFace:!1,planePoint:e.max,vertices:[new C.Vector3(e.max.x,e.min.y,e.max.z),new C.Vector3(e.max.x,e.min.y,e.min.z),new C.Vector3(e.max.x,e.max.y,e.min.z),new C.Vector3(e.max.x,e.max.y,e.max.z)]},{name:"左",normal:new C.Vector3(-1,0,0),isMinFace:!0,planePoint:e.min,vertices:[new C.Vector3(e.min.x,e.min.y,e.min.z),new C.Vector3(e.min.x,e.min.y,e.max.z),new C.Vector3(e.min.x,e.max.y,e.max.z),new C.Vector3(e.min.x,e.max.y,e.min.z)]},{name:"顶",normal:new C.Vector3(0,1,0),isMinFace:!1,planePoint:e.max,vertices:[new C.Vector3(e.min.x,e.max.y,e.max.z),new C.Vector3(e.max.x,e.max.y,e.max.z),new C.Vector3(e.max.x,e.max.y,e.min.z),new C.Vector3(e.min.x,e.max.y,e.min.z)]},{name:"底",normal:new C.Vector3(0,-1,0),isMinFace:!0,planePoint:e.min,vertices:[new C.Vector3(e.min.x,e.min.y,e.min.z),new C.Vector3(e.max.x,e.min.y,e.min.z),new C.Vector3(e.max.x,e.min.y,e.max.z),new C.Vector3(e.min.x,e.min.y,e.max.z)]}].forEach(s=>{this.createFace(t,s.vertices,s.normal,s.name,s.isMinFace,s.planePoint)}),this.engine.scene.children.filter(s=>s.type=="Mesh"&&s.url).forEach(s=>{s.material&&Array.isArray(s.material)?s.material.forEach(r=>{r.clippingPlanes=this.engine.sectionPlane}):s.material.clippingPlanes=this.engine.sectionPlane})}createFace(e,t,i,s,r,o){const a=new C.BufferGeometry,l=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z]),c=[0,2,1,0,3,2];a.setAttribute("position",new C.BufferAttribute(l,3)),a.setIndex(c);let h=this.meshs.find(A=>A.name===s);if(h==null){const A=new C.MeshBasicMaterial({color:65280,transparent:!0,opacity:this.faceIdleOpacity,side:C.DoubleSide});A.polygonOffset=!0,A.polygonOffsetFactor=1,A.polygonOffsetUnits=4,h=new C.Mesh(a,A),h.name=s,e.add(h),this.meshs.push(h)}else h.geometry=a;h.userData={dragNormal:i.clone(),isMinFace:r,faceName:s};const d=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z,t[0].x,t[0].y,t[0].z]),f=new C.LineBasicMaterial({color:255}),u=new C.BufferGeometry;u.setAttribute("position",new C.BufferAttribute(d,3));let g=this.meshs.find(A=>A.name===s+"Line");g==null?(g=new C.Line(u,f),g.name=s+"Line",e.add(g),this.meshs.push(g)):(g.geometry=u,g.material=f);const p=new C.Vector3;t.forEach(A=>p.add(A)),p.multiplyScalar(1/t.length),this.updateFaceTransformControl(s,i,p,r);const m=this.engine.sectionPlane.find(A=>A.name==s);m&&m.setFromNormalAndCoplanarPoint(i.clone().setLength(-1),o)}}class DI{engine;isActive=!1;isDrag=!1;isCtrlDown=!1;listenersAttached=!1;meshs=[];box=null;pickPoint=null;pickNormal=null;plane=null;angleX=0;angleY=0;angleZ=0;direction=1;normal=new C.Vector3(0,0,1);distance=0;center=null;current_center=null;dragStartDistance=0;idleOpacity=.02;hoverOpacity=.05;transformControl=null;transformAnchor=null;transformHelper=null;isSyncingTransformControl=!1;moveEpsilon=1e-5;transformHandleSize=1.15;transformHandleColor=16777215;transformHandleHoverColor=16776960;handleNativeMouseDown=e=>{if(e.button!==0||!(this.isCtrlDown||e.ctrlKey))return;const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);i.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:i}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:i})};handleNativeMouseUp=e=>{e.button!==0||!this.isDrag||(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseUp({button:e.button}))};handleNativeKeyDown=e=>{e.key==="Control"&&(this.isCtrlDown=!0)};handleNativeKeyUp=e=>{e.key==="Control"&&(this.isCtrlDown=!1,this.isDrag&&this.handleMouseUp({button:0}),this.resetMeshOpacity())};handleTransformObjectChange=()=>{if(this.isSyncingTransformControl||!this.transformAnchor||!this.center)return;const e=this.normal.clone().normalize(),t=this.getDistanceRange(e),i=this.getTransformHandleOffset(),s=this.transformAnchor.position.clone().sub(this.center).dot(e)-i,r=Math.min(t.max,Math.max(t.min,s));Math.abs(r-Number(this.distance))>this.moveEpsilon?this.updata_face(r):Math.abs(s-r)>this.moveEpsilon&&this.updateTransformControl(e)};constructor(e){this.engine=e,this.meshs=[],this.box=null}active(){if(this.isActive==!0)return;this.isActive=!0,this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(i=>{i.name.includes("face")&&(i.visible=!0)})}),this.attachListeners(),this.ensureTransformControl(),this.setTransformControlVisible(!0);const e=this;e.engine.scene.children.filter(t=>t.type=="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(i=>{i.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(i=>i.name=="face"),t)}),this.init()}disActive(){this.init(),this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0},!1),this.setTransformControlVisible(!1),this.clearClippingFaceFill();const e=this.engine.sectionPlane.find(t=>t.name=="face");e&&(e.constant=1e5),this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(i=>{i.name.includes("face")&&(i.visible=!1)})})}init(e){const t=this.engine.octreeBox.getBoundingBox();this.box=t,this.distance=0,this.center=new C.Vector3((t.min.x+t.max.x)/2,(t.min.y+t.max.y)/2,(t.min.z+t.max.z)/2),this.current_center=this.center.clone(),!e&&this.updata_face(0)}disabled(){this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0},!1),this.setTransformControlVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!1)})})}recover(){this.isActive||(this.attachListeners(),this.setTransformControlVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!0)})}),this.isActive=!0)}setFaceAngle(e,t,i){this.angleX=e,this.angleY=t,this.angleZ=i,this.distance=0,this.normal=new C.Vector3(0,1,0).applyAxisAngle(new C.Vector3(1,0,0),e).applyAxisAngle(new C.Vector3(0,0,1),t).applyAxisAngle(new C.Vector3(0,1,0),i).normalize(),this.updata_face(0),this.updateClippingFaceFill()}setFaceNormal(e,t=0){this.normal=e.clone().normalize(),this.distance=t,this.updata_face(t),this.updateClippingFaceFill()}setFaceNormalPlaneOnly(e,t){if(this.normal=e.clone().normalize(),this.distance=t,!this.center||!this.box)return;const i=this.engine.sectionPlane?.find(s=>s.name==="face");if(i){const s=this.center.clone().add(this.normal.clone().multiplyScalar(t));i.setFromNormalAndCoplanarPoint(this.normal.clone().multiplyScalar(this.direction),s)}this.updateClippingFaceFill()}activateClippingOnly(){if(this.isActive)return;this.isActive=!0;const e=this;e.engine.scene.children.filter(t=>t.type==="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(i=>{i.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(i=>i.name==="face"),t)})}reverse(){this.direction=this.direction*-1,this.updata_face(this.distance),this.updateClippingFaceFill()}getFaceAngle(){return{angleX:this.angleX,angleY:this.angleY,angleZ:this.angleZ,direction:this.direction}}updata_face(e){if(!this.box)return;this.distance=e;let t=this.engine.scene.children.find(b=>b.type=="Group"&&b.name=="ClippingBox");t==null&&(t=new C.Group,t.name="ClippingBox",this.engine.scene.add(t));const i=this.normal.clone().normalize(),s=this.center??new C.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2);this.center=s.clone();const{tangent:r,bitangent:o}=this.getPlaneBasis(i),a=this.getBoxCorners(this.box),l=this.box.min.distanceTo(this.box.max),c=Math.max(l*.02,.01);let h=1/0,d=-1/0,f=1/0,u=-1/0;a.forEach(b=>{const y=b.clone().sub(s),_=y.dot(r),w=y.dot(o);h=Math.min(h,_),d=Math.max(d,_),f=Math.min(f,w),u=Math.max(u,w)}),h-=c,d+=c,f-=c,u+=c;const g=i.clone().multiplyScalar(e),p=s.clone().add(r.clone().multiplyScalar(h)).add(o.clone().multiplyScalar(f)).add(g),m=s.clone().add(r.clone().multiplyScalar(d)).add(o.clone().multiplyScalar(f)).add(g),A=s.clone().add(r.clone().multiplyScalar(d)).add(o.clone().multiplyScalar(u)).add(g),x=s.clone().add(r.clone().multiplyScalar(h)).add(o.clone().multiplyScalar(u)).add(g);this.current_center=s.clone().add(g),this.createFace(t,[p,m,A,x],i,"face"),this.updateTransformControl(i)}createFace(e,t,i,s){const r=new C.BufferGeometry,o=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z]),a=[0,1,2,0,2,3];r.setAttribute("position",new C.BufferAttribute(o,3)),r.setIndex(a);let l=this.meshs.find(g=>g.name==s);if(l==null){const g=new C.MeshBasicMaterial({color:65280,transparent:!0,opacity:this.idleOpacity,side:C.DoubleSide});g.polygonOffset=!0,g.polygonOffsetFactor=1,g.polygonOffsetUnits=4,l=new C.Mesh(r,g),l.name=s,e.add(l),this.meshs.push(l)}else l.geometry=r;l.normal=i.clone();const c=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z,t[0].x,t[0].y,t[0].z]),h=new C.LineBasicMaterial({color:255}),d=new C.BufferGeometry;d.setAttribute("position",new C.BufferAttribute(c,3));let f=this.meshs.find(g=>g.name==s+"Line");f==null?(f=new C.Line(d,h),f.name=s+"Line",e.add(f),this.meshs.push(f)):(f.geometry=d,f.material=h);const u=this.engine.sectionPlane.find(g=>g.name==s);u&&this.current_center&&u.setFromNormalAndCoplanarPoint(i.clone().setLength(this.direction),this.current_center)}getPlaneBasis(e){const t=new C.Vector3(1,0,0),i=new C.Vector3(0,1,0),s=new C.Vector3(0,0,1),r=Math.abs(e.dot(t)),o=Math.abs(e.dot(i)),a=Math.abs(e.dot(s));let l=t;o<=r&&o<=a?l=i:a<=r&&a<=o&&(l=s),l=l.clone().sub(e.clone().multiplyScalar(l.dot(e))).normalize();const c=new C.Vector3().crossVectors(e,l).normalize();return{tangent:l,bitangent:c}}getBoxCorners(e){return[new C.Vector3(e.min.x,e.min.y,e.min.z),new C.Vector3(e.min.x,e.min.y,e.max.z),new C.Vector3(e.min.x,e.max.y,e.min.z),new C.Vector3(e.min.x,e.max.y,e.max.z),new C.Vector3(e.max.x,e.min.y,e.min.z),new C.Vector3(e.max.x,e.min.y,e.max.z),new C.Vector3(e.max.x,e.max.y,e.min.z),new C.Vector3(e.max.x,e.max.y,e.max.z)]}getDistanceRange(e){if(!this.box)return{min:0,max:0};const t=this.center??new C.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2),i=this.getBoxCorners(this.box);let s=1/0,r=-1/0;return i.forEach(o=>{const a=o.clone().sub(t).dot(e);s=Math.min(s,a),r=Math.max(r,a)}),{min:s,max:r}}getInteractiveMeshes(){return this.meshs.filter(e=>e.type==="Mesh")}getTransformHandleOffset(){if(!this.box)return .06;const e=this.box.min.distanceTo(this.box.max);return Math.max(e*.015,.06)}keepSingleDirectionArrow(e,t="X"){const i=e.getHelper(),s=[];i.traverse(r=>{if(r?.name!==t||!r.geometry)return;const o=r.geometry;o.boundingBox||o.computeBoundingBox();const a=o.boundingBox;if(!a)return;const l=a.getCenter(new C.Vector3);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const h=o.parameters,d=h&&h.radiusTop===0&&h.radiusBottom===.04&&h.height===.1,f=h&&h.radiusTop===.2&&h.radiusBottom===0&&h.height===.6;(d||f)&&s.push(r)}),s.forEach(r=>{r.parent?.remove(r)})}ensureTransformControl(){if(this.transformControl&&this.transformAnchor)return;const e=this.engine.renderer?.domElement,t=this.engine.camera;if(!e||!t)return;const i=new C.Object3D;i.name="SectionFaceTransformAnchor",i.visible=this.isActive,this.engine.scene.add(i);const s=new sA(t,e);s.name="SectionFaceTransformControl",s.setMode("translate"),s.setSpace("local"),s.showX=!0,s.showY=!1,s.showZ=!1,s.size=this.transformHandleSize,s.setColors(this.transformHandleColor,this.transformHandleColor,this.transformHandleColor,this.transformHandleHoverColor),s.enabled=this.isActive,s.attach(i),this.keepSingleDirectionArrow(s,"X"),s.addEventListener("dragging-changed",o=>{this.engine.controls.enabled=!o.value,o.value===!0?this.clearClippingFaceFill():this.updateClippingFaceFill()}),s.addEventListener("objectChange",this.handleTransformObjectChange);const r=s.getHelper();r.visible=this.isActive,this.engine.scene.add(r),this.transformAnchor=i,this.transformControl=s,this.transformHelper=r}setTransformControlVisible(e){this.ensureTransformControl(),this.transformControl&&(this.transformControl.enabled=e),this.transformHelper&&(this.transformHelper.visible=e),this.transformAnchor&&(this.transformAnchor.visible=e),e||(this.engine.controls.enabled=!0)}updateTransformControl(e){if(this.ensureTransformControl(),!this.transformControl||!this.transformAnchor||!this.current_center)return;const t=this.getTransformHandleOffset(),i=this.current_center.clone().add(e.clone().setLength(t)),s=new C.Quaternion().setFromUnitVectors(new C.Vector3(1,0,0),e.clone().normalize().multiplyScalar(-1));this.isSyncingTransformControl=!0,this.transformAnchor.position.copy(i),this.transformAnchor.quaternion.copy(s),this.transformAnchor.visible=this.isActive,this.transformControl.object!==this.transformAnchor&&this.transformControl.attach(this.transformAnchor),this.transformControl.enabled=this.isActive,this.transformHelper&&(this.transformHelper.visible=this.isActive),this.isSyncingTransformControl=!1}createRaycasterFromMouseEvent(e){const t=new C.Raycaster,i=new C.Vector2,s=this.engine.renderer.domElement.clientWidth,r=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/s*2-1,i.y=-(e.offsetY/r)*2+1,t.setFromCamera(i,this.engine.camera),t}attachListeners(){if(this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.handleNativeMouseDown,!0),e.addEventListener("mousemove",this.handleNativeMouseMove,!0),e.addEventListener("mouseup",this.handleNativeMouseUp,!0),window.addEventListener("keydown",this.handleNativeKeyDown),window.addEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!0)}detachListeners(){if(!this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.handleNativeMouseDown,!0),e.removeEventListener("mousemove",this.handleNativeMouseMove,!0),e.removeEventListener("mouseup",this.handleNativeMouseUp,!0)),window.removeEventListener("keydown",this.handleNativeKeyDown),window.removeEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!1,this.isCtrlDown=!1}resetMeshOpacity(){this.getInteractiveMeshes().forEach(e=>{e.material&&(e.material.opacity=this.idleOpacity)})}updateClippingFaceFill(){const e=this.engine.sectionPlane?.find?.(t=>t.name==="face");if(e){this.engine.clipping?.clippingCSGSimple?.updataFace?.(e);return}this.clearClippingFaceFill()}clearClippingFaceFill(){this.engine.clipping?.clippingCSGSimple?.clear?.()}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){this.clearClippingFaceFill();const i=t[0],s=i.point.clone();this.isDrag=!0,this.pickPoint=s;const o=(i.face?.normal?.clone()??this.normal.clone()).clone();if(o.dot(this.normal)<0&&o.multiplyScalar(-1),o.normalize(),this.pickNormal=o,this.engine.controls.enabled=!1,this.dragStartDistance=Number(this.distance)||0,o.y==0){const a=new C.Plane;a.setFromNormalAndCoplanarPoint(new C.Vector3(0,1,0),s),this.plane=a}else{const a=new C.Vector3(this.engine.camera.position.x,s.y,this.engine.camera.position.z),l=new C.Plane;l.setFromNormalAndCoplanarPoint(a.clone().sub(s.clone()).setLength(1),s),this.plane=l}}else this.isDrag=!1}handleMouseUp(e,t=!0){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.plane=null,this.engine.controls.enabled=!0,t&&this.updateClippingFaceFill()}handleMouseMove(e){this.resetMeshOpacity();const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);t!=null&&t.length>0&&(t[0].object.material.opacity=this.hoverOpacity);const i=this.pickPoint,s=this.pickNormal,r=this.plane;if(i!=null&&s!=null&&r!=null){const o=new C.Vector3;if(e.raycaster.ray.intersectPlane(r,o)){const a=o.clone().sub(i.clone()).dot(s.clone()),l=this.getDistanceRange(this.normal.clone().normalize()),c=this.dragStartDistance+a;this.distance=Math.min(l.max,Math.max(l.min,c)),this.updata_face(this.distance)}}}}class BI{engine;callback_;constructor(e){this.engine=e}init(){this.engine.handelBehaved.init(this,{showCatch:!0}),this.engine.handelBehaved.active()}catch_face(e){this.callback_=e}handleMouseMove(e){}handleMouseClick(e){if(e.catch?.normal==null&&(e.catch.normal=e.catch.face?.normal),!e.catch?.normal||!e.catch?.point)return;let t=e.catch.normal.setLength(-1);this.engine.handelBehaved.disActive(),this.callback_({dir:t,position:e.catch.point})}}const bA=0,PI=1,LI=2,yA=2,cf=1.25,vA=1,ai=32,Wt=ai/4,_A=65535,RI=Math.pow(2,-24),hf=Symbol("SKIP_GENERATION");function kI(n){return n.index?n.index.count:n.attributes.position.count}function pr(n){return kI(n)/3}function FI(n,e=ArrayBuffer){return n>65535?new Uint32Array(new e(4*n)):new Uint16Array(new e(2*n))}function OI(n,e){if(!n.index){const t=n.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=FI(t,i);n.setIndex(new v.BufferAttribute(s,1));for(let r=0;r<t;r++)s[r]=r}}function CA(n,e){const t=pr(n),i=e||n.drawRange,s=i.start/3,r=(i.start+i.count)/3,o=Math.max(0,s),a=Math.min(t,r)-o;return[{offset:Math.floor(o),count:Math.floor(a)}]}function wA(n,e){if(!n.groups||!n.groups.length)return CA(n,e);const t=[],i=e||n.drawRange,s=i.start/3,r=(i.start+i.count)/3,o=pr(n),a=[];for(const h of n.groups){const{start:d,count:f}=h,u=d/3,g=isFinite(f)?f:o*3-d,p=(d+g)/3;u<r&&p>s&&(a.push({pos:Math.max(s,u),isStart:!0}),a.push({pos:Math.min(r,p),isStart:!1}))}a.sort((h,d)=>h.pos!==d.pos?h.pos-d.pos:h.type==="end"?-1:1);let l=0,c=null;for(const h of a){const d=h.pos;l!==0&&d!==c&&t.push({offset:c,count:d-c}),l+=h.isStart?1:-1,c=d}return t}function df(n,e,t,i,s){let r=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0,d=1/0,f=1/0,u=1/0,g=-1/0,p=-1/0,m=-1/0;const A=n.offset||0;for(let x=(e-A)*6,b=(e+t-A)*6;x<b;x+=6){const y=n[x+0],_=n[x+1],w=y-_,S=y+_;w<r&&(r=w),S>l&&(l=S),y<d&&(d=y),y>g&&(g=y);const D=n[x+2],M=n[x+3],I=D-M,P=D+M;I<o&&(o=I),P>c&&(c=P),D<f&&(f=D),D>p&&(p=D);const T=n[x+4],L=n[x+5],E=T-L,F=T+L;E<a&&(a=E),F>h&&(h=F),T<u&&(u=T),T>m&&(m=T)}i[0]=r,i[1]=o,i[2]=a,i[3]=l,i[4]=c,i[5]=h,s[0]=d,s[1]=f,s[2]=u,s[3]=g,s[4]=p,s[5]=m}function SA(n,e,t=null,i=null,s=null){const r=n.attributes.position,o=n.index?n.index.array:null,a=r.normalized;if(s===null)s=new Float32Array(t*6),s.offset=e;else if(e<0||t+e>s.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=r.array,c=r.offset||0;let h=3;r.isInterleavedBufferAttribute&&(h=r.data.stride);const d=["getX","getY","getZ"],f=s.offset;for(let u=e,g=e+t;u<g;u++){const m=(i?i[u]:u)*3,A=(u-f)*6;let x=m+0,b=m+1,y=m+2;o&&(x=o[x],b=o[b],y=o[y]),a||(x=x*h+c,b=b*h+c,y=y*h+c);for(let _=0;_<3;_++){let w,S,D;a?(w=r[d[_]](x),S=r[d[_]](b),D=r[d[_]](y)):(w=l[x+_],S=l[b+_],D=l[y+_]);let M=w;S<M&&(M=S),D<M&&(M=D);let I=w;S>I&&(I=S),D>I&&(I=D);const P=(I-M)/2,T=_*2;s[A+T+0]=M+P,s[A+T+1]=P+(Math.abs(M)+P)*RI}}return s}function Et(n,e,t){return t.min.x=e[n],t.min.y=e[n+1],t.min.z=e[n+2],t.max.x=e[n+3],t.max.y=e[n+4],t.max.z=e[n+5],t}function MA(n){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=n[i+3]-n[i];s>t&&(t=s,e=i)}return e}function EA(n,e){e.set(n)}function IA(n,e,t){let i,s;for(let r=0;r<3;r++){const o=r+3;i=n[r],s=e[r],t[r]=i<s?i:s,i=n[o],s=e[o],t[o]=i>s?i:s}}function Bc(n,e,t){for(let i=0;i<3;i++){const s=e[n+2*i],r=e[n+2*i+1],o=s-r,a=s+r;o<t[i]&&(t[i]=o),a>t[i+3]&&(t[i+3]=a)}}function _a(n){const e=n[3]-n[0],t=n[4]-n[1],i=n[5]-n[2];return 2*(e*t+t*i+i*e)}const Zn=32,UI=(n,e)=>n.candidate-e.candidate,Ms=new Array(Zn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Pc=new Float32Array(6);function NI(n,e,t,i,s,r){let o=-1,a=0;if(r===bA)o=MA(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(r===PI)o=MA(n),o!==-1&&(a=zI(t,i,s,o));else if(r===LI){const l=_a(n);let c=cf*s;const h=t.offset||0,d=(i-h)*6,f=(i+s-h)*6;for(let u=0;u<3;u++){const g=e[u],A=(e[u+3]-g)/Zn;if(s<Zn/4){const x=[...Ms];x.length=s;let b=0;for(let _=d;_<f;_+=6,b++){const w=x[b];w.candidate=t[_+2*u],w.count=0;const{bounds:S,leftCacheBounds:D,rightCacheBounds:M}=w;for(let I=0;I<3;I++)M[I]=1/0,M[I+3]=-1/0,D[I]=1/0,D[I+3]=-1/0,S[I]=1/0,S[I+3]=-1/0;Bc(_,t,S)}x.sort(UI);let y=s;for(let _=0;_<y;_++){const w=x[_];for(;_+1<y&&x[_+1].candidate===w.candidate;)x.splice(_+1,1),y--}for(let _=d;_<f;_+=6){const w=t[_+2*u];for(let S=0;S<y;S++){const D=x[S];w>=D.candidate?Bc(_,t,D.rightCacheBounds):(Bc(_,t,D.leftCacheBounds),D.count++)}}for(let _=0;_<y;_++){const w=x[_],S=w.count,D=s-w.count,M=w.leftCacheBounds,I=w.rightCacheBounds;let P=0;S!==0&&(P=_a(M)/l);let T=0;D!==0&&(T=_a(I)/l);const L=vA+cf*(P*S+T*D);L<c&&(o=u,c=L,a=w.candidate)}}else{for(let y=0;y<Zn;y++){const _=Ms[y];_.count=0,_.candidate=g+A+y*A;const w=_.bounds;for(let S=0;S<3;S++)w[S]=1/0,w[S+3]=-1/0}for(let y=d;y<f;y+=6){let S=~~((t[y+2*u]-g)/A);S>=Zn&&(S=Zn-1);const D=Ms[S];D.count++,Bc(y,t,D.bounds)}const x=Ms[Zn-1];EA(x.bounds,x.rightCacheBounds);for(let y=Zn-2;y>=0;y--){const _=Ms[y],w=Ms[y+1];IA(_.bounds,w.rightCacheBounds,_.rightCacheBounds)}let b=0;for(let y=0;y<Zn-1;y++){const _=Ms[y],w=_.count,S=_.bounds,M=Ms[y+1].rightCacheBounds;w!==0&&(b===0?EA(S,Pc):IA(S,Pc,Pc)),b+=w;let I=0,P=0;b!==0&&(I=_a(Pc)/l);const T=s-b;T!==0&&(P=_a(M)/l);const L=vA+cf*(I*b+P*T);L<c&&(o=u,c=L,a=_.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:a}}function zI(n,e,t,i){let s=0;const r=n.offset;for(let o=e,a=e+t;o<a;o++)s+=n[(o-r)*6+i*2];return s/t}class uf{constructor(){this.boundingData=new Float32Array(6)}}function GI(n,e,t,i,s,r){let o=i,a=i+s-1;const l=r.pos,c=r.axis*2,h=t.offset||0;for(;;){for(;o<=a&&t[(o-h)*6+c]<l;)o++;for(;o<=a&&t[(a-h)*6+c]>=l;)a--;if(o<a){for(let d=0;d<3;d++){let f=e[o*3+d];e[o*3+d]=e[a*3+d],e[a*3+d]=f}for(let d=0;d<6;d++){const f=o-h,u=a-h,g=t[f*6+d];t[f*6+d]=t[u*6+d],t[u*6+d]=g}o++,a--}else return o}}function VI(n,e,t,i,s,r){let o=i,a=i+s-1;const l=r.pos,c=r.axis*2,h=t.offset||0;for(;;){for(;o<=a&&t[(o-h)*6+c]<l;)o++;for(;o<=a&&t[(a-h)*6+c]>=l;)a--;if(o<a){let d=n[o];n[o]=n[a],n[a]=d;for(let f=0;f<6;f++){const u=o-h,g=a-h,p=t[u*6+f];t[u*6+f]=t[g*6+f],t[g*6+f]=p}o++,a--}else return o}}let TA,Lc,ff,DA;const QI=Math.pow(2,32);function pf(n){return"count"in n?1:1+pf(n.left)+pf(n.right)}function jI(n,e,t){return TA=new Float32Array(t),Lc=new Uint32Array(t),ff=new Uint16Array(t),DA=new Uint8Array(t),gf(n,e)}function gf(n,e){const t=n/4,i=n/2,s="count"in e,r=e.boundingData;for(let o=0;o<6;o++)TA[t+o]=r[o];if(s)return e.buffer?(DA.set(new Uint8Array(e.buffer),n),n+e.buffer.byteLength):(Lc[t+6]=e.offset,ff[i+14]=e.count,ff[i+15]=_A,n+ai);{const{left:o,right:a,splitAxis:l}=e,c=n+ai;let h=gf(c,o);const d=n/ai,u=h/ai-d;if(u>QI)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Lc[t+6]=u,Lc[t+7]=l,gf(h,a)}}function WI(n,e,t){const s=(n.index?n.index.count:n.attributes.position.count)/3>2**16,r=t.reduce((h,d)=>h+d.count,0),o=s?4:2,a=e?new SharedArrayBuffer(r*o):new ArrayBuffer(r*o),l=s?new Uint32Array(a):new Uint16Array(a);let c=0;for(let h=0;h<t.length;h++){const{offset:d,count:f}=t[h];for(let u=0;u<f;u++)l[c+u]=d+u;c+=f}return l}function HI(n,e,t,i,s){const{maxDepth:r,verbose:o,maxLeafTris:a,strategy:l,onProgress:c,indirect:h}=s,d=n._indirectBuffer,f=n.geometry,u=f.index?f.index.array:null,g=h?VI:GI,p=pr(f),m=new Float32Array(6);let A=!1;const x=new uf;return df(e,t,i,x.boundingData,m),y(x,t,i,m),x;function b(_){c&&c(_/p)}function y(_,w,S,D=null,M=0){if(!A&&M>=r&&(A=!0,o&&(console.warn(`MeshBVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`),console.warn(f))),S<=a||M>=r)return b(w+S),_.offset=w,_.count=S,_;const I=NI(_.boundingData,D,e,w,S,l);if(I.axis===-1)return b(w+S),_.offset=w,_.count=S,_;const P=g(d,u,e,w,S,I);if(P===w||P===w+S)b(w+S),_.offset=w,_.count=S;else{_.splitAxis=I.axis;const T=new uf,L=w,E=P-w;_.left=T,df(e,L,E,T.boundingData,m),y(T,L,E,m,M+1);const F=new uf,z=P,X=S-E;_.right=F,df(e,z,X,F.boundingData,m),y(F,z,X,m,M+1)}return _}}function XI(n,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=n.geometry;let s,r;if(e.indirect){const o=wA(i,e.range),a=WI(i,e.useSharedArrayBuffer,o);n._indirectBuffer=a,s=SA(i,0,a.length,a),r=[{offset:0,count:a.length}]}else{OI(i,e);const o=CA(i,e.range)[0];s=SA(i,o.offset,o.count),r=wA(i,e.range)}n._roots=r.map(o=>{const a=HI(n,s,o.offset,o.count,e),l=pf(a),c=new t(ai*l);return jI(0,a,c),c})}class Jn{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let r=0,o=e.length;r<o;r++){const l=e[r][t];i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let r=0,o=t.length;r<o;r++){const a=t[r],l=e.dot(a);i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}Jn.prototype.setFromBox=(function(){const n=new v.Vector3;return function(t,i){const s=i.min,r=i.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){n.x=s.x*l+r.x*(1-l),n.y=s.y*c+r.y*(1-c),n.z=s.z*h+r.z*(1-h);const d=t.dot(n);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}})();const qI=(function(){const n=new v.Vector3,e=new v.Vector3,t=new v.Vector3;return function(s,r,o){const a=s.start,l=n,c=r.start,h=e;t.subVectors(a,c),n.subVectors(s.end,s.start),e.subVectors(r.end,r.start);const d=t.dot(h),f=h.dot(l),u=h.dot(h),g=t.dot(l),m=l.dot(l)*u-f*f;let A,x;m!==0?A=(d*f-g*u)/m:A=0,x=(d+A*f)/u,o.x=A,o.y=x}})(),mf=(function(){const n=new v.Vector2,e=new v.Vector3,t=new v.Vector3;return function(s,r,o,a){qI(s,r,n);let l=n.x,c=n.y;if(l>=0&&l<=1&&c>=0&&c<=1){s.at(l,o),r.at(c,a);return}else if(l>=0&&l<=1){c<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?s.at(0,o):s.at(1,o),r.closestPointToPoint(o,!0,a);return}else{let h;l<0?h=s.start:h=s.end;let d;c<0?d=r.start:d=r.end;const f=e,u=t;if(s.closestPointToPoint(d,!0,e),r.closestPointToPoint(h,!0,t),f.distanceToSquared(d)<=u.distanceToSquared(h)){o.copy(f),a.copy(d);return}else{o.copy(h),a.copy(u);return}}}})(),YI=(function(){const n=new v.Vector3,e=new v.Vector3,t=new v.Plane,i=new v.Line3;return function(r,o){const{radius:a,center:l}=r,{a:c,b:h,c:d}=o;if(i.start=c,i.end=h,i.closestPointToPoint(l,!0,n).distanceTo(l)<=a||(i.start=c,i.end=d,i.closestPointToPoint(l,!0,n).distanceTo(l)<=a)||(i.start=h,i.end=d,i.closestPointToPoint(l,!0,n).distanceTo(l)<=a))return!0;const p=o.getPlane(t);if(Math.abs(p.distanceToPoint(l))<=a){const A=p.projectPoint(l,e);if(o.containsPoint(A))return!0}return!1}})(),KI=["x","y","z"],es=1e-15,BA=es*es;function Gi(n){return Math.abs(n)<es}class Vi extends v.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new v.Vector3),this.satBounds=new Array(4).fill().map(()=>new Jn),this.points=[this.a,this.b,this.c],this.plane=new v.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new v.Line3,this.needsUpdate=!0}intersectsSphere(e){return YI(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,r=this.satAxes,o=this.satBounds,a=r[0],l=o[0];this.getNormal(a),l.setFromPoints(a,s);const c=r[1],h=o[1];c.subVectors(e,t),h.setFromPoints(c,s);const d=r[2],f=o[2];d.subVectors(t,i),f.setFromPoints(d,s);const u=r[3],g=o[3];u.subVectors(i,e),g.setFromPoints(u,s);const p=c.length(),m=d.length(),A=u.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,p<es?m<es||A<es?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(i)):m<es?A<es?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):A<es&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(i),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}Vi.prototype.closestPointToSegment=(function(){const n=new v.Vector3,e=new v.Vector3,t=new v.Line3;return function(s,r=null,o=null){const{start:a,end:l}=s,c=this.points;let h,d=1/0;for(let f=0;f<3;f++){const u=(f+1)%3;t.start.copy(c[f]),t.end.copy(c[u]),mf(t,s,n,e),h=n.distanceToSquared(e),h<d&&(d=h,r&&r.copy(n),o&&o.copy(e))}return this.closestPointToPoint(a,n),h=a.distanceToSquared(n),h<d&&(d=h,r&&r.copy(n),o&&o.copy(a)),this.closestPointToPoint(l,n),h=l.distanceToSquared(n),h<d&&(d=h,r&&r.copy(n),o&&o.copy(l)),Math.sqrt(d)}})(),Vi.prototype.intersectsTriangle=(function(){const n=new Vi,e=new Jn,t=new Jn,i=new v.Vector3,s=new v.Vector3,r=new v.Vector3,o=new v.Vector3,a=new v.Line3,l=new v.Line3,c=new v.Vector3,h=new v.Vector2,d=new v.Vector2;function f(b,y,_,w){const S=i;!b.isDegenerateIntoPoint&&!b.isDegenerateIntoSegment?S.copy(b.plane.normal):S.copy(y.plane.normal);const D=b.satBounds,M=b.satAxes;for(let T=1;T<4;T++){const L=D[T],E=M[T];if(e.setFromPoints(E,y.points),L.isSeparated(e)||(o.copy(S).cross(E),e.setFromPoints(o,b.points),t.setFromPoints(o,y.points),e.isSeparated(t)))return!1}const I=y.satBounds,P=y.satAxes;for(let T=1;T<4;T++){const L=I[T],E=P[T];if(e.setFromPoints(E,b.points),L.isSeparated(e)||(o.crossVectors(S,E),e.setFromPoints(o,b.points),t.setFromPoints(o,y.points),e.isSeparated(t)))return!1}return _&&(w||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),_.start.set(0,0,0),_.end.set(0,0,0)),!0}function u(b,y,_,w,S,D,M,I,P,T,L){let E=M/(M-I);T.x=w+(S-w)*E,L.start.subVectors(y,b).multiplyScalar(E).add(b),E=M/(M-P),T.y=w+(D-w)*E,L.end.subVectors(_,b).multiplyScalar(E).add(b)}function g(b,y,_,w,S,D,M,I,P,T,L){if(S>0)u(b.c,b.a,b.b,w,y,_,P,M,I,T,L);else if(D>0)u(b.b,b.a,b.c,_,y,w,I,M,P,T,L);else if(I*P>0||M!=0)u(b.a,b.b,b.c,y,_,w,M,I,P,T,L);else if(I!=0)u(b.b,b.a,b.c,_,y,w,I,M,P,T,L);else if(P!=0)u(b.c,b.a,b.b,w,y,_,P,M,I,T,L);else return!0;return!1}function p(b,y,_,w){const S=y.degenerateSegment,D=b.plane.distanceToPoint(S.start),M=b.plane.distanceToPoint(S.end);return Gi(D)?Gi(M)?f(b,y,_,w):(_&&(_.start.copy(S.start),_.end.copy(S.start)),b.containsPoint(S.start)):Gi(M)?(_&&(_.start.copy(S.end),_.end.copy(S.end)),b.containsPoint(S.end)):b.plane.intersectLine(S,i)!=null?(_&&(_.start.copy(i),_.end.copy(i)),b.containsPoint(i)):!1}function m(b,y,_){const w=y.a;return Gi(b.plane.distanceToPoint(w))&&b.containsPoint(w)?(_&&(_.start.copy(w),_.end.copy(w)),!0):!1}function A(b,y,_){const w=b.degenerateSegment,S=y.a;return w.closestPointToPoint(S,!0,i),S.distanceToSquared(i)<BA?(_&&(_.start.copy(S),_.end.copy(S)),!0):!1}function x(b,y,_,w){if(b.isDegenerateIntoSegment)if(y.isDegenerateIntoSegment){const S=b.degenerateSegment,D=y.degenerateSegment,M=s,I=r;S.delta(M),D.delta(I);const P=i.subVectors(D.start,S.start),T=M.x*I.y-M.y*I.x;if(Gi(T))return!1;const L=(P.x*I.y-P.y*I.x)/T,E=-(M.x*P.y-M.y*P.x)/T;if(L<0||L>1||E<0||E>1)return!1;const F=S.start.z+M.z*L,z=D.start.z+I.z*E;return Gi(F-z)?(_&&(_.start.copy(S.start).addScaledVector(M,L),_.end.copy(S.start).addScaledVector(M,L)),!0):!1}else return y.isDegenerateIntoPoint?A(b,y,_):p(y,b,_,w);else{if(b.isDegenerateIntoPoint)return y.isDegenerateIntoPoint?y.a.distanceToSquared(b.a)<BA?(_&&(_.start.copy(b.a),_.end.copy(b.a)),!0):!1:y.isDegenerateIntoSegment?A(y,b,_):m(y,b,_);if(y.isDegenerateIntoPoint)return m(b,y,_);if(y.isDegenerateIntoSegment)return p(b,y,_,w)}}return function(y,_=null,w=!1){this.needsUpdate&&this.update(),y.isExtendedTriangle?y.needsUpdate&&y.update():(n.copy(y),n.update(),y=n);const S=x(this,y,_,w);if(S!==void 0)return S;const D=this.plane,M=y.plane;let I=M.distanceToPoint(this.a),P=M.distanceToPoint(this.b),T=M.distanceToPoint(this.c);Gi(I)&&(I=0),Gi(P)&&(P=0),Gi(T)&&(T=0);const L=I*P,E=I*T;if(L>0&&E>0)return!1;let F=D.distanceToPoint(y.a),z=D.distanceToPoint(y.b),X=D.distanceToPoint(y.c);Gi(F)&&(F=0),Gi(z)&&(z=0),Gi(X)&&(X=0);const j=F*z,N=F*X;if(j>0&&N>0)return!1;s.copy(D.normal),r.copy(M.normal);const Y=s.cross(r);let V=0,H=Math.abs(Y.x);const oe=Math.abs(Y.y);oe>H&&(H=oe,V=1),Math.abs(Y.z)>H&&(V=2);const ue=KI[V],re=this.a[ue],de=this.b[ue],Ae=this.c[ue],ye=y.a[ue],Me=y.b[ue],Oe=y.c[ue];if(g(this,re,de,Ae,L,E,I,P,T,h,a))return f(this,y,_,w);if(g(y,ye,Me,Oe,j,N,F,z,X,d,l))return f(this,y,_,w);if(h.y<h.x){const nt=h.y;h.y=h.x,h.x=nt,c.copy(a.start),a.start.copy(a.end),a.end.copy(c)}if(d.y<d.x){const nt=d.y;d.y=d.x,d.x=nt,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return h.y<d.x||d.y<h.x?!1:(_&&(d.x>h.x?_.start.copy(l.start):_.start.copy(a.start),d.y<h.y?_.end.copy(l.end):_.end.copy(a.end)),!0)}})(),Vi.prototype.distanceToPoint=(function(){const n=new v.Vector3;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}})(),Vi.prototype.distanceToTriangle=(function(){const n=new v.Vector3,e=new v.Vector3,t=["a","b","c"],i=new v.Line3,s=new v.Line3;return function(o,a=null,l=null){const c=a||l?i:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let h=1/0;for(let d=0;d<3;d++){let f;const u=t[d],g=o[u];this.closestPointToPoint(g,n),f=g.distanceToSquared(n),f<h&&(h=f,a&&a.copy(n),l&&l.copy(g));const p=this[u];o.closestPointToPoint(p,n),f=p.distanceToSquared(n),f<h&&(h=f,a&&a.copy(p),l&&l.copy(n))}for(let d=0;d<3;d++){const f=t[d],u=t[(d+1)%3];i.set(this[f],this[u]);for(let g=0;g<3;g++){const p=t[g],m=t[(g+1)%3];s.set(o[p],o[m]),mf(i,s,n,e);const A=n.distanceToSquared(e);A<h&&(h=A,a&&a.copy(n),l&&l.copy(e))}}return Math.sqrt(h)}})();class li{constructor(e,t,i){this.isOrientedBox=!0,this.min=new v.Vector3,this.max=new v.Vector3,this.matrix=new v.Matrix4,this.invMatrix=new v.Matrix4,this.points=new Array(8).fill().map(()=>new v.Vector3),this.satAxes=new Array(3).fill().map(()=>new v.Vector3),this.satBounds=new Array(3).fill().map(()=>new Jn),this.alignedSatBounds=new Array(3).fill().map(()=>new Jn),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}li.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let c=0;c<=1;c++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){const f=1*c|2*h|4*d,u=s[f];u.x=c?i.x:t.x,u.y=h?i.y:t.y,u.z=d?i.z:t.z,u.applyMatrix4(e)}const r=this.satBounds,o=this.satAxes,a=s[0];for(let c=0;c<3;c++){const h=o[c],d=r[c],f=1<<c,u=s[f];h.subVectors(a,u),d.setFromPoints(h,s)}const l=this.alignedSatBounds;l[0].setFromPointsField(s,"x"),l[1].setFromPointsField(s,"y"),l[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),li.prototype.intersectsBox=(function(){const n=new Jn;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,r=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(n.min=i.x,n.max=s.x,a[0].isSeparated(n)||(n.min=i.y,n.max=s.y,a[1].isSeparated(n))||(n.min=i.z,n.max=s.z,a[2].isSeparated(n)))return!1;for(let l=0;l<3;l++){const c=o[l],h=r[l];if(n.setFromBox(c,t),h.isSeparated(n))return!1}return!0}})(),li.prototype.intersectsTriangle=(function(){const n=new Vi,e=new Array(3),t=new Jn,i=new Jn,s=new v.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(n.copy(o),n.update(),o=n);const a=this.satBounds,l=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let f=0;f<3;f++){const u=a[f],g=l[f];if(t.setFromPoints(g,e),u.isSeparated(t))return!1}const c=o.satBounds,h=o.satAxes,d=this.points;for(let f=0;f<3;f++){const u=c[f],g=h[f];if(t.setFromPoints(g,d),u.isSeparated(t))return!1}for(let f=0;f<3;f++){const u=l[f];for(let g=0;g<4;g++){const p=h[g];if(s.crossVectors(u,p),t.setFromPoints(s,e),i.setFromPoints(s,d),t.isSeparated(i))return!1}}return!0}})(),li.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})(),li.prototype.distanceToPoint=(function(){const n=new v.Vector3;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}})(),li.prototype.distanceToBox=(function(){const n=["x","y","z"],e=new Array(12).fill().map(()=>new v.Line3),t=new Array(12).fill().map(()=>new v.Line3),i=new v.Vector3,s=new v.Vector3;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),l&&l.copy(i),c&&c.copy(s)),0;const h=a*a,d=o.min,f=o.max,u=this.points;let g=1/0;for(let m=0;m<8;m++){const A=u[m];s.copy(A).clamp(d,f);const x=A.distanceToSquared(s);if(x<g&&(g=x,l&&l.copy(A),c&&c.copy(s),x<h))return Math.sqrt(x)}let p=0;for(let m=0;m<3;m++)for(let A=0;A<=1;A++)for(let x=0;x<=1;x++){const b=(m+1)%3,y=(m+2)%3,_=A<<b|x<<y,w=1<<m|A<<b|x<<y,S=u[_],D=u[w];e[p].set(S,D);const I=n[m],P=n[b],T=n[y],L=t[p],E=L.start,F=L.end;E[I]=d[I],E[P]=A?d[P]:f[P],E[T]=x?d[T]:f[P],F[I]=f[I],F[P]=A?d[P]:f[P],F[T]=x?d[T]:f[P],p++}for(let m=0;m<=1;m++)for(let A=0;A<=1;A++)for(let x=0;x<=1;x++){s.x=m?f.x:d.x,s.y=A?f.y:d.y,s.z=x?f.z:d.z,this.closestPointToPoint(s,i);const b=s.distanceToSquared(i);if(b<g&&(g=b,l&&l.copy(i),c&&c.copy(s),b<h))return Math.sqrt(b)}for(let m=0;m<12;m++){const A=e[m];for(let x=0;x<12;x++){const b=t[x];mf(A,b,i,s);const y=i.distanceToSquared(s);if(y<g&&(g=y,l&&l.copy(i),c&&c.copy(s),y<h))return Math.sqrt(y)}}return Math.sqrt(g)}})();class Af{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class $I extends Af{constructor(){super(()=>new Vi)}}const Qi=new $I;function Ht(n,e){return e[n+15]===_A}function Ii(n,e){return e[n+6]}function ji(n,e){return e[n+14]}function qt(n){return n+Wt}function Yt(n,e){const t=e[n+6];return n+t*Wt}function xf(n,e){return e[n+7]}function z6(n){return n}class ZI{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const vt=new ZI;let Es,Ao;const xo=[],Rc=new Af(()=>new v.Box3);function JI(n,e,t,i,s,r){Es=Rc.getPrimitive(),Ao=Rc.getPrimitive(),xo.push(Es,Ao),vt.setBuffer(n._roots[e]);const o=bf(0,n.geometry,t,i,s,r);vt.clearBuffer(),Rc.releasePrimitive(Es),Rc.releasePrimitive(Ao),xo.pop(),xo.pop();const a=xo.length;return a>0&&(Ao=xo[a-1],Es=xo[a-2]),o}function bf(n,e,t,i,s=null,r=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:c}=vt;let h=n*2;if(Ht(h,l)){const f=Ii(n,c),u=ji(h,l);return Et(n,a,Es),i(f,u,!1,o,r+n/Wt,Es)}else{let I=function(T){const{uint16Array:L,uint32Array:E}=vt;let F=T*2;for(;!Ht(F,L);)T=qt(T),F=T*2;return Ii(T,E)},P=function(T){const{uint16Array:L,uint32Array:E}=vt;let F=T*2;for(;!Ht(F,L);)T=Yt(T,E),F=T*2;return Ii(T,E)+ji(F,L)};const f=qt(n),u=Yt(n,c);let g=f,p=u,m,A,x,b;if(s&&(x=Es,b=Ao,Et(g,a,x),Et(p,a,b),m=s(x),A=s(b),A<m)){g=u,p=f;const T=m;m=A,A=T,x=b}x||(x=Es,Et(g,a,x));const y=Ht(g*2,l),_=t(x,y,m,o+1,r+g/Wt);let w;if(_===yA){const T=I(g),E=P(g)-T;w=i(T,E,!0,o+1,r+g/Wt,x)}else w=_&&bf(g,e,t,i,s,r,o+1);if(w)return!0;b=Ao,Et(p,a,b);const S=Ht(p*2,l),D=t(b,S,A,o+1,r+p/Wt);let M;if(D===yA){const T=I(p),E=P(p)-T;M=i(T,E,!0,o+1,r+p/Wt,b)}else M=D&&bf(p,e,t,i,s,r,o+1);return!!M}}const Ca=new v.Vector3,yf=new v.Vector3;function eT(n,e,t={},i=0,s=1/0){const r=i*i,o=s*s;let a=1/0,l=null;if(n.shapecast({boundsTraverseOrder:h=>(Ca.copy(e).clamp(h.min,h.max),Ca.distanceToSquared(e)),intersectsBounds:(h,d,f)=>f<a&&f<o,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,Ca);const f=e.distanceToSquared(Ca);return f<a&&(yf.copy(Ca),a=f,l=d),f<r}}),a===1/0)return null;const c=Math.sqrt(a);return t.point?t.point.copy(yf):t.point=yf.clone(),t.distance=c,t.faceIndex=l,t}const kc=parseInt(v.REVISION)>=169,tT=parseInt(v.REVISION)<=161,gr=new v.Vector3,mr=new v.Vector3,Ar=new v.Vector3,Fc=new v.Vector2,Oc=new v.Vector2,Uc=new v.Vector2,PA=new v.Vector3,LA=new v.Vector3,RA=new v.Vector3,wa=new v.Vector3;function iT(n,e,t,i,s,r,o,a){let l;if(r===v.BackSide?l=n.intersectTriangle(i,t,e,!0,s):l=n.intersectTriangle(e,t,i,r!==v.DoubleSide,s),l===null)return null;const c=n.origin.distanceTo(s);return c<o||c>a?null:{distance:c,point:s.clone()}}function kA(n,e,t,i,s,r,o,a,l,c,h){gr.fromBufferAttribute(e,r),mr.fromBufferAttribute(e,o),Ar.fromBufferAttribute(e,a);const d=iT(n,gr,mr,Ar,wa,l,c,h);if(d){if(i){Fc.fromBufferAttribute(i,r),Oc.fromBufferAttribute(i,o),Uc.fromBufferAttribute(i,a),d.uv=new v.Vector2;const u=v.Triangle.getInterpolation(wa,gr,mr,Ar,Fc,Oc,Uc,d.uv);kc||(d.uv=u)}if(s){Fc.fromBufferAttribute(s,r),Oc.fromBufferAttribute(s,o),Uc.fromBufferAttribute(s,a),d.uv1=new v.Vector2;const u=v.Triangle.getInterpolation(wa,gr,mr,Ar,Fc,Oc,Uc,d.uv1);kc||(d.uv1=u),tT&&(d.uv2=d.uv1)}if(t){PA.fromBufferAttribute(t,r),LA.fromBufferAttribute(t,o),RA.fromBufferAttribute(t,a),d.normal=new v.Vector3;const u=v.Triangle.getInterpolation(wa,gr,mr,Ar,PA,LA,RA,d.normal);d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1),kc||(d.normal=u)}const f={a:r,b:o,c:a,normal:new v.Vector3,materialIndex:0};if(v.Triangle.getNormal(gr,mr,Ar,f.normal),d.face=f,d.faceIndex=r,kc){const u=new v.Vector3;v.Triangle.getBarycoord(wa,gr,mr,Ar,u),d.barycoord=u}}return d}function FA(n){return n&&n.isMaterial?n.side:n}function Nc(n,e,t,i,s,r,o){const a=i*3;let l=a+0,c=a+1,h=a+2;const{index:d,groups:f}=n;n.index&&(l=d.getX(l),c=d.getX(c),h=d.getX(h));const{position:u,normal:g,uv:p,uv1:m}=n.attributes;if(Array.isArray(e)){const A=i*3;for(let x=0,b=f.length;x<b;x++){const{start:y,count:_,materialIndex:w}=f[x];if(A>=y&&A<y+_){const S=FA(e[w]),D=kA(t,u,g,p,m,l,c,h,S,r,o);if(D)if(D.faceIndex=i,D.face.materialIndex=w,s)s.push(D);else return D}}}else{const A=FA(e),x=kA(t,u,g,p,m,l,c,h,A,r,o);if(x)if(x.faceIndex=i,x.face.materialIndex=0,s)s.push(x);else return x}return null}function Ut(n,e,t,i){const s=n.a,r=n.b,o=n.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),s.x=i.getX(a),s.y=i.getY(a),s.z=i.getZ(a),r.x=i.getX(l),r.y=i.getY(l),r.z=i.getZ(l),o.x=i.getX(c),o.y=i.getY(c),o.z=i.getZ(c)}function nT(n,e,t,i,s,r,o,a){const{geometry:l,_indirectBuffer:c}=n;for(let h=i,d=i+s;h<d;h++)Nc(l,e,t,h,r,o,a)}function sT(n,e,t,i,s,r,o){const{geometry:a,_indirectBuffer:l}=n;let c=1/0,h=null;for(let d=i,f=i+s;d<f;d++){let u;u=Nc(a,e,t,d,null,r,o),u&&u.distance<c&&(h=u,c=u.distance)}return h}function rT(n,e,t,i,s,r,o){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=n,d=e+n;h<d;h++){let f;if(f=h,Ut(o,f*3,l,c),o.needsUpdate=!0,i(o,f,s,r))return!0}return!1}function oT(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,a,l,c=0;const h=n._roots;for(let f=0,u=h.length;f<u;f++)r=h[f],o=new Uint32Array(r),a=new Uint16Array(r),l=new Float32Array(r),d(0,c),c+=r.byteLength;function d(f,u,g=!1){const p=f*2;if(Ht(p,a)){const m=o[f+6],A=a[p+14];let x=1/0,b=1/0,y=1/0,_=-1/0,w=-1/0,S=-1/0;for(let D=3*m,M=3*(m+A);D<M;D++){let I=i[D];const P=s.getX(I),T=s.getY(I),L=s.getZ(I);P<x&&(x=P),P>_&&(_=P),T<b&&(b=T),T>w&&(w=T),L<y&&(y=L),L>S&&(S=L)}return l[f+0]!==x||l[f+1]!==b||l[f+2]!==y||l[f+3]!==_||l[f+4]!==w||l[f+5]!==S?(l[f+0]=x,l[f+1]=b,l[f+2]=y,l[f+3]=_,l[f+4]=w,l[f+5]=S,!0):!1}else{const m=qt(f),A=Yt(f,o);let x=g,b=!1,y=!1;if(e){if(!x){const I=m/Wt+u/ai,P=A/Wt+u/ai;b=e.has(I),y=e.has(P),x=!b&&!y}}else b=!0,y=!0;const _=x||b,w=x||y;let S=!1;_&&(S=d(m,u,x));let D=!1;w&&(D=d(A,u,x));const M=S||D;if(M)for(let I=0;I<3;I++){const P=m+I,T=A+I,L=l[P],E=l[P+3],F=l[T],z=l[T+3];l[f+I]=L<F?L:F,l[f+I+3]=E>z?E:z}return M}}}function Is(n,e,t,i,s){let r,o,a,l,c,h;const d=1/t.direction.x,f=1/t.direction.y,u=1/t.direction.z,g=t.origin.x,p=t.origin.y,m=t.origin.z;let A=e[n],x=e[n+3],b=e[n+1],y=e[n+3+1],_=e[n+2],w=e[n+3+2];return d>=0?(r=(A-g)*d,o=(x-g)*d):(r=(x-g)*d,o=(A-g)*d),f>=0?(a=(b-p)*f,l=(y-p)*f):(a=(y-p)*f,l=(b-p)*f),r>l||a>o||((a>r||isNaN(r))&&(r=a),(l<o||isNaN(o))&&(o=l),u>=0?(c=(_-m)*u,h=(w-m)*u):(c=(w-m)*u,h=(_-m)*u),r>h||c>o)?!1:((c>r||r!==r)&&(r=c),(h<o||o!==o)&&(o=h),r<=s&&o>=i)}function aT(n,e,t,i,s,r,o,a){const{geometry:l,_indirectBuffer:c}=n;for(let h=i,d=i+s;h<d;h++){let f=c?c[h]:h;Nc(l,e,t,f,r,o,a)}}function lT(n,e,t,i,s,r,o){const{geometry:a,_indirectBuffer:l}=n;let c=1/0,h=null;for(let d=i,f=i+s;d<f;d++){let u;u=Nc(a,e,t,l?l[d]:d,null,r,o),u&&u.distance<c&&(h=u,c=u.distance)}return h}function cT(n,e,t,i,s,r,o){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=n,d=e+n;h<d;h++){let f;if(f=t.resolveTriangleIndex(h),Ut(o,f*3,l,c),o.needsUpdate=!0,i(o,f,s,r))return!0}return!1}function hT(n,e,t,i,s,r,o){vt.setBuffer(n._roots[e]),vf(0,n,t,i,s,r,o),vt.clearBuffer()}function vf(n,e,t,i,s,r,o){const{float32Array:a,uint16Array:l,uint32Array:c}=vt,h=n*2;if(Ht(h,l)){const f=Ii(n,c),u=ji(h,l);nT(e,t,i,f,u,s,r,o)}else{const f=qt(n);Is(f,a,i,r,o)&&vf(f,e,t,i,s,r,o);const u=Yt(n,c);Is(u,a,i,r,o)&&vf(u,e,t,i,s,r,o)}}const dT=["x","y","z"];function uT(n,e,t,i,s,r){vt.setBuffer(n._roots[e]);const o=_f(0,n,t,i,s,r);return vt.clearBuffer(),o}function _f(n,e,t,i,s,r){const{float32Array:o,uint16Array:a,uint32Array:l}=vt;let c=n*2;if(Ht(c,a)){const d=Ii(n,l),f=ji(c,a);return sT(e,t,i,d,f,s,r)}else{const d=xf(n,l),f=dT[d],g=i.direction[f]>=0;let p,m;g?(p=qt(n),m=Yt(n,l)):(p=Yt(n,l),m=qt(n));const x=Is(p,o,i,s,r)?_f(p,e,t,i,s,r):null;if(x){const _=x.point[f];if(g?_<=o[m+d]:_>=o[m+d+3])return x}const y=Is(m,o,i,s,r)?_f(m,e,t,i,s,r):null;return x&&y?x.distance<=y.distance?x:y:x||y||null}}const zc=new v.Box3,bo=new Vi,yo=new Vi,Sa=new v.Matrix4,OA=new li,Gc=new li;function fT(n,e,t,i){vt.setBuffer(n._roots[e]);const s=Cf(0,n,t,i);return vt.clearBuffer(),s}function Cf(n,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:a}=vt;let l=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),OA.set(t.boundingBox.min,t.boundingBox.max,i),s=OA),Ht(l,o)){const h=e.geometry,d=h.index,f=h.attributes.position,u=t.index,g=t.attributes.position,p=Ii(n,a),m=ji(l,o);if(Sa.copy(i).invert(),t.boundsTree)return Et(n,r,Gc),Gc.matrix.copy(Sa),Gc.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Gc.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(i),x.b.applyMatrix4(i),x.c.applyMatrix4(i),x.needsUpdate=!0;for(let b=p*3,y=(m+p)*3;b<y;b+=3)if(Ut(yo,b,d,f),yo.needsUpdate=!0,x.intersectsTriangle(yo))return!0;return!1}});{const A=pr(t);for(let x=p*3,b=(m+p)*3;x<b;x+=3){Ut(bo,x,d,f),bo.a.applyMatrix4(Sa),bo.b.applyMatrix4(Sa),bo.c.applyMatrix4(Sa),bo.needsUpdate=!0;for(let y=0,_=A*3;y<_;y+=3)if(Ut(yo,y,u,g),yo.needsUpdate=!0,bo.intersectsTriangle(yo))return!0}}}else{const h=qt(n),d=Yt(n,a);return Et(h,r,zc),!!(s.intersectsBox(zc)&&Cf(h,e,t,i,s)||(Et(d,r,zc),s.intersectsBox(zc)&&Cf(d,e,t,i,s)))}}const Vc=new v.Matrix4,wf=new li,Ma=new li,pT=new v.Vector3,gT=new v.Vector3,mT=new v.Vector3,AT=new v.Vector3;function xT(n,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),wf.set(e.boundingBox.min,e.boundingBox.max,t),wf.needsUpdate=!0;const a=n.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,d=e.index,f=Qi.getPrimitive(),u=Qi.getPrimitive();let g=pT,p=gT,m=null,A=null;s&&(m=mT,A=AT);let x=1/0,b=null,y=null;return Vc.copy(t).invert(),Ma.matrix.copy(Vc),n.shapecast({boundsTraverseOrder:_=>wf.distanceToBox(_),intersectsBounds:(_,w,S)=>S<x&&S<o?(w&&(Ma.min.copy(_.min),Ma.max.copy(_.max),Ma.needsUpdate=!0),!0):!1,intersectsRange:(_,w)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:D=>Ma.distanceToBox(D),intersectsBounds:(D,M,I)=>I<x&&I<o,intersectsRange:(D,M)=>{for(let I=D,P=D+M;I<P;I++){Ut(u,3*I,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let T=_,L=_+w;T<L;T++){Ut(f,3*T,c,l),f.needsUpdate=!0;const E=f.distanceToTriangle(u,g,m);if(E<x&&(p.copy(g),A&&A.copy(m),x=E,b=T,y=I),E<r)return!0}}}});{const S=pr(e);for(let D=0,M=S;D<M;D++){Ut(u,3*D,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let I=_,P=_+w;I<P;I++){Ut(f,3*I,c,l),f.needsUpdate=!0;const T=f.distanceToTriangle(u,g,m);if(T<x&&(p.copy(g),A&&A.copy(m),x=T,b=I,y=D),T<r)return!0}}}}}),Qi.releasePrimitive(f),Qi.releasePrimitive(u),x===1/0?null:(i.point?i.point.copy(p):i.point=p.clone(),i.distance=x,i.faceIndex=b,s&&(s.point?s.point.copy(A):s.point=A.clone(),s.point.applyMatrix4(Vc),p.applyMatrix4(Vc),s.distance=p.sub(s.point).length(),s.faceIndex=y),i)}function bT(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,a,l,c=0;const h=n._roots;for(let f=0,u=h.length;f<u;f++)r=h[f],o=new Uint32Array(r),a=new Uint16Array(r),l=new Float32Array(r),d(0,c),c+=r.byteLength;function d(f,u,g=!1){const p=f*2;if(Ht(p,a)){const m=o[f+6],A=a[p+14];let x=1/0,b=1/0,y=1/0,_=-1/0,w=-1/0,S=-1/0;for(let D=m,M=m+A;D<M;D++){const I=3*n.resolveTriangleIndex(D);for(let P=0;P<3;P++){let T=I+P;T=i?i[T]:T;const L=s.getX(T),E=s.getY(T),F=s.getZ(T);L<x&&(x=L),L>_&&(_=L),E<b&&(b=E),E>w&&(w=E),F<y&&(y=F),F>S&&(S=F)}}return l[f+0]!==x||l[f+1]!==b||l[f+2]!==y||l[f+3]!==_||l[f+4]!==w||l[f+5]!==S?(l[f+0]=x,l[f+1]=b,l[f+2]=y,l[f+3]=_,l[f+4]=w,l[f+5]=S,!0):!1}else{const m=qt(f),A=Yt(f,o);let x=g,b=!1,y=!1;if(e){if(!x){const I=m/Wt+u/ai,P=A/Wt+u/ai;b=e.has(I),y=e.has(P),x=!b&&!y}}else b=!0,y=!0;const _=x||b,w=x||y;let S=!1;_&&(S=d(m,u,x));let D=!1;w&&(D=d(A,u,x));const M=S||D;if(M)for(let I=0;I<3;I++){const P=m+I,T=A+I,L=l[P],E=l[P+3],F=l[T],z=l[T+3];l[f+I]=L<F?L:F,l[f+I+3]=E>z?E:z}return M}}}function yT(n,e,t,i,s,r,o){vt.setBuffer(n._roots[e]),Sf(0,n,t,i,s,r,o),vt.clearBuffer()}function Sf(n,e,t,i,s,r,o){const{float32Array:a,uint16Array:l,uint32Array:c}=vt,h=n*2;if(Ht(h,l)){const f=Ii(n,c),u=ji(h,l);aT(e,t,i,f,u,s,r,o)}else{const f=qt(n);Is(f,a,i,r,o)&&Sf(f,e,t,i,s,r,o);const u=Yt(n,c);Is(u,a,i,r,o)&&Sf(u,e,t,i,s,r,o)}}const vT=["x","y","z"];function _T(n,e,t,i,s,r){vt.setBuffer(n._roots[e]);const o=Mf(0,n,t,i,s,r);return vt.clearBuffer(),o}function Mf(n,e,t,i,s,r){const{float32Array:o,uint16Array:a,uint32Array:l}=vt;let c=n*2;if(Ht(c,a)){const d=Ii(n,l),f=ji(c,a);return lT(e,t,i,d,f,s,r)}else{const d=xf(n,l),f=vT[d],g=i.direction[f]>=0;let p,m;g?(p=qt(n),m=Yt(n,l)):(p=Yt(n,l),m=qt(n));const x=Is(p,o,i,s,r)?Mf(p,e,t,i,s,r):null;if(x){const _=x.point[f];if(g?_<=o[m+d]:_>=o[m+d+3])return x}const y=Is(m,o,i,s,r)?Mf(m,e,t,i,s,r):null;return x&&y?x.distance<=y.distance?x:y:x||y||null}}const Qc=new v.Box3,vo=new Vi,_o=new Vi,Ea=new v.Matrix4,UA=new li,jc=new li;function CT(n,e,t,i){vt.setBuffer(n._roots[e]);const s=Ef(0,n,t,i);return vt.clearBuffer(),s}function Ef(n,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:a}=vt;let l=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),UA.set(t.boundingBox.min,t.boundingBox.max,i),s=UA),Ht(l,o)){const h=e.geometry,d=h.index,f=h.attributes.position,u=t.index,g=t.attributes.position,p=Ii(n,a),m=ji(l,o);if(Ea.copy(i).invert(),t.boundsTree)return Et(n,r,jc),jc.matrix.copy(Ea),jc.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>jc.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(i),x.b.applyMatrix4(i),x.c.applyMatrix4(i),x.needsUpdate=!0;for(let b=p,y=m+p;b<y;b++)if(Ut(_o,3*e.resolveTriangleIndex(b),d,f),_o.needsUpdate=!0,x.intersectsTriangle(_o))return!0;return!1}});{const A=pr(t);for(let x=p,b=m+p;x<b;x++){const y=e.resolveTriangleIndex(x);Ut(vo,3*y,d,f),vo.a.applyMatrix4(Ea),vo.b.applyMatrix4(Ea),vo.c.applyMatrix4(Ea),vo.needsUpdate=!0;for(let _=0,w=A*3;_<w;_+=3)if(Ut(_o,_,u,g),_o.needsUpdate=!0,vo.intersectsTriangle(_o))return!0}}}else{const h=qt(n),d=Yt(n,a);return Et(h,r,Qc),!!(s.intersectsBox(Qc)&&Ef(h,e,t,i,s)||(Et(d,r,Qc),s.intersectsBox(Qc)&&Ef(d,e,t,i,s)))}}const Wc=new v.Matrix4,If=new li,Ia=new li,wT=new v.Vector3,ST=new v.Vector3,MT=new v.Vector3,ET=new v.Vector3;function IT(n,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),If.set(e.boundingBox.min,e.boundingBox.max,t),If.needsUpdate=!0;const a=n.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,d=e.index,f=Qi.getPrimitive(),u=Qi.getPrimitive();let g=wT,p=ST,m=null,A=null;s&&(m=MT,A=ET);let x=1/0,b=null,y=null;return Wc.copy(t).invert(),Ia.matrix.copy(Wc),n.shapecast({boundsTraverseOrder:_=>If.distanceToBox(_),intersectsBounds:(_,w,S)=>S<x&&S<o?(w&&(Ia.min.copy(_.min),Ia.max.copy(_.max),Ia.needsUpdate=!0),!0):!1,intersectsRange:(_,w)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:D=>Ia.distanceToBox(D),intersectsBounds:(D,M,I)=>I<x&&I<o,intersectsRange:(D,M)=>{for(let I=D,P=D+M;I<P;I++){const T=S.resolveTriangleIndex(I);Ut(u,3*T,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let L=_,E=_+w;L<E;L++){const F=n.resolveTriangleIndex(L);Ut(f,3*F,c,l),f.needsUpdate=!0;const z=f.distanceToTriangle(u,g,m);if(z<x&&(p.copy(g),A&&A.copy(m),x=z,b=L,y=I),z<r)return!0}}}})}else{const S=pr(e);for(let D=0,M=S;D<M;D++){Ut(u,3*D,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let I=_,P=_+w;I<P;I++){const T=n.resolveTriangleIndex(I);Ut(f,3*T,c,l),f.needsUpdate=!0;const L=f.distanceToTriangle(u,g,m);if(L<x&&(p.copy(g),A&&A.copy(m),x=L,b=I,y=D),L<r)return!0}}}}}),Qi.releasePrimitive(f),Qi.releasePrimitive(u),x===1/0?null:(i.point?i.point.copy(p):i.point=p.clone(),i.distance=x,i.faceIndex=b,s&&(s.point?s.point.copy(A):s.point=A.clone(),s.point.applyMatrix4(Wc),p.applyMatrix4(Wc),s.distance=p.sub(s.point).length(),s.faceIndex=y),i)}function TT(){return typeof SharedArrayBuffer<"u"}const Ta=new vt.constructor,Hc=new vt.constructor,Ts=new Af(()=>new v.Box3),Co=new v.Box3,wo=new v.Box3,Tf=new v.Box3,Df=new v.Box3;let Bf=!1;function DT(n,e,t,i){if(Bf)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Bf=!0;const s=n._roots,r=e._roots;let o,a=0,l=0;const c=new v.Matrix4().copy(t).invert();for(let h=0,d=s.length;h<d;h++){Ta.setBuffer(s[h]),l=0;const f=Ts.getPrimitive();Et(0,Ta.float32Array,f),f.applyMatrix4(c);for(let u=0,g=r.length;u<g&&(Hc.setBuffer(r[u]),o=sn(0,0,t,c,i,a,l,0,0,f),Hc.clearBuffer(),l+=r[u].byteLength/ai,!o);u++);if(Ts.releasePrimitive(f),Ta.clearBuffer(),a+=s[h].byteLength/ai,o)break}return Bf=!1,o}function sn(n,e,t,i,s,r=0,o=0,a=0,l=0,c=null,h=!1){let d,f;h?(d=Hc,f=Ta):(d=Ta,f=Hc);const u=d.float32Array,g=d.uint32Array,p=d.uint16Array,m=f.float32Array,A=f.uint32Array,x=f.uint16Array,b=n*2,y=e*2,_=Ht(b,p),w=Ht(y,x);let S=!1;if(w&&_)h?S=s(Ii(e,A),ji(e*2,x),Ii(n,g),ji(n*2,p),l,o+e/Wt,a,r+n/Wt):S=s(Ii(n,g),ji(n*2,p),Ii(e,A),ji(e*2,x),a,r+n/Wt,l,o+e/Wt);else if(w){const D=Ts.getPrimitive();Et(e,m,D),D.applyMatrix4(t);const M=qt(n),I=Yt(n,g);Et(M,u,Co),Et(I,u,wo);const P=D.intersectsBox(Co),T=D.intersectsBox(wo);S=P&&sn(e,M,i,t,s,o,r,l,a+1,D,!h)||T&&sn(e,I,i,t,s,o,r,l,a+1,D,!h),Ts.releasePrimitive(D)}else{const D=qt(e),M=Yt(e,A);Et(D,m,Tf),Et(M,m,Df);const I=c.intersectsBox(Tf),P=c.intersectsBox(Df);if(I&&P)S=sn(n,D,t,i,s,r,o,a,l+1,c,h)||sn(n,M,t,i,s,r,o,a,l+1,c,h);else if(I)if(_)S=sn(n,D,t,i,s,r,o,a,l+1,c,h);else{const T=Ts.getPrimitive();T.copy(Tf).applyMatrix4(t);const L=qt(n),E=Yt(n,g);Et(L,u,Co),Et(E,u,wo);const F=T.intersectsBox(Co),z=T.intersectsBox(wo);S=F&&sn(D,L,i,t,s,o,r,l,a+1,T,!h)||z&&sn(D,E,i,t,s,o,r,l,a+1,T,!h),Ts.releasePrimitive(T)}else if(P)if(_)S=sn(n,M,t,i,s,r,o,a,l+1,c,h);else{const T=Ts.getPrimitive();T.copy(Df).applyMatrix4(t);const L=qt(n),E=Yt(n,g);Et(L,u,Co),Et(E,u,wo);const F=T.intersectsBox(Co),z=T.intersectsBox(wo);S=F&&sn(M,L,i,t,s,o,r,l,a+1,T,!h)||z&&sn(M,E,i,t,s,o,r,l,a+1,T,!h),Ts.releasePrimitive(T)}}return S}const Xc=new li,NA=new v.Box3,BT={strategy:bA,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Pf{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,r=e._indirectBuffer,o=i.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(a.roots=s.map(l=>l.slice()),a.index=o?o.array.slice():null,a.indirectBuffer=r?r.slice():null):(a.roots=s,a.index=o?o.array:null,a.indirectBuffer=r),a}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:r,indirectBuffer:o}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),l(r));const a=new Pf(t,{...i,[hf]:!0});if(a._roots=r,a._indirectBuffer=o||null,i.setIndex){const c=t.getIndex();if(c===null){const h=new v.BufferAttribute(e.index,1,!1);t.setIndex(h)}else c.array!==s&&(c.array.set(s),c.needsUpdate=!0)}return a;function l(c){for(let h=0;h<c.length;h++){const d=c[h],f=new Uint32Array(d),u=new Uint16Array(d);for(let g=0,p=d.byteLength/ai;g<p;g++){const m=Wt*g,A=2*m;Ht(A,u)||(f[m+6]=f[m+6]/Wt-g)}}}}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...BT,[hf]:!1},t),t.useSharedArrayBuffer&&!TT())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[hf]||(XI(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new v.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}shiftTriangleOffsets(e){const t=this._indirectBuffer;if(t)for(let i=0,s=t.length;i<s;i++)t[i]+=e;else{const i=this._roots;for(let s=0;s<i.length;s++){const r=i[s],o=new Uint32Array(r),a=new Uint16Array(r),l=r.byteLength/ai;for(let c=0;c<l;c++){const h=Wt*c,d=2*h;Ht(d,a)&&(o[h+6]+=e)}}}}refit(e=null){return(this.indirect?bT:oT)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),r=new Uint16Array(i);o(0);function o(a,l=0){const c=a*2,h=Ht(c,r);if(h){const d=s[a+6],f=r[c+14];e(l,h,new Float32Array(i,a*4,6),d,f)}else{const d=qt(a),f=Yt(a,s),u=xf(a,s);e(l,h,new Float32Array(i,a*4,6),u)||(o(d,l+1),o(f,l+1))}}}raycast(e,t=v.FrontSide,i=0,s=1/0){const r=this._roots,o=[],a=this.indirect?yT:hT;for(let l=0,c=r.length;l<c;l++)a(this,l,t,e,o,i,s);return o}raycastFirst(e,t=v.FrontSide,i=0,s=1/0){const r=this._roots;let o=null;const a=this.indirect?_T:uT;for(let l=0,c=r.length;l<c;l++){const h=a(this,l,t,e,i,s);h!=null&&(o==null||h.distance<o.distance)&&(o=h)}return o}intersectsGeometry(e,t){let i=!1;const s=this._roots,r=this.indirect?CT:fT;for(let o=0,a=s.length;o<a&&(i=r(this,o,e,t),!i);o++);return i}shapecast(e){const t=Qi.getPrimitive(),i=this.indirect?cT:rT;let{boundsTraverseOrder:s,intersectsBounds:r,intersectsRange:o,intersectsTriangle:a}=e;if(o&&a){const d=o;o=(f,u,g,p,m)=>d(f,u,g,p,m)?!0:i(f,u,this,a,g,p,t)}else o||(a?o=(d,f,u,g)=>i(d,f,this,a,u,g,t):o=(d,f,u)=>u);let l=!1,c=0;const h=this._roots;for(let d=0,f=h.length;d<f;d++){const u=h[d];if(l=JI(this,d,r,o,s,c),l)break;c+=u.byteLength/ai}return Qi.releasePrimitive(t),l}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:r}=i;const o=Qi.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?g=>{const p=this.resolveTriangleIndex(g);Ut(o,p*3,a,l)}:g=>{Ut(o,g*3,a,l)},h=Qi.getPrimitive(),d=e.geometry.index,f=e.geometry.attributes.position,u=e.indirect?g=>{const p=e.resolveTriangleIndex(g);Ut(h,p*3,d,f)}:g=>{Ut(h,g*3,d,f)};if(r){const g=(p,m,A,x,b,y,_,w)=>{for(let S=A,D=A+x;S<D;S++){u(S),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let M=p,I=p+m;M<I;M++)if(c(M),o.needsUpdate=!0,r(o,h,M,S,b,y,_,w))return!0}return!1};if(s){const p=s;s=function(m,A,x,b,y,_,w,S){return p(m,A,x,b,y,_,w,S)?!0:g(m,A,x,b,y,_,w,S)}}else s=g}return DT(this,e,t,s)}intersectsBox(e,t){return Xc.set(e.min,e.max,t),Xc.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Xc.intersectsBox(i),intersectsTriangle:i=>Xc.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},r=0,o=1/0){return(this.indirect?IT:xT)(this,e,t,i,s,r,o)}closestPointToPoint(e,t={},i=0,s=1/0){return eT(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{Et(0,new Float32Array(i),NA),e.union(NA)}),e}}const zA=1e-6,PT=zA*.5,GA=Math.pow(10,-Math.log10(zA)),LT=PT*GA;function wn(n){return~~(n*GA+LT)}function RT(n){return`${wn(n.x)},${wn(n.y)}`}function VA(n){return`${wn(n.x)},${wn(n.y)},${wn(n.z)}`}function kT(n){return`${wn(n.x)},${wn(n.y)},${wn(n.z)},${wn(n.w)}`}function FT(n,e,t){t.direction.subVectors(e,n).normalize();const i=n.dot(t.direction);return t.origin.copy(n).addScaledVector(t.direction,-i),t}function QA(){return typeof SharedArrayBuffer<"u"}function OT(n){if(n.buffer instanceof SharedArrayBuffer)return n;const e=n.constructor,t=n.buffer,i=new SharedArrayBuffer(t.byteLength),s=new Uint8Array(t);return new Uint8Array(i).set(s,0),new e(i)}function UT(n,e=ArrayBuffer){return n>65535?new Uint32Array(new e(4*n)):new Uint16Array(new e(2*n))}function NT(n,e){if(!n.index){const t=n.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=UT(t,i);n.setIndex(new v.BufferAttribute(s,1));for(let r=0;r<t;r++)s[r]=r}}function zT(n){return n.index?n.index.count:n.attributes.position.count}function Lf(n){return zT(n)/3}const GT=1e-8,VT=new v.Vector3;function QT(n){return~~(n/3)}function jT(n){return n%3}function jA(n,e){return n.start-e.start}function WA(n,e){return VT.subVectors(e,n.origin).dot(n.direction)}function WT(n,e,t,i=GT){n.sort(jA),e.sort(jA);for(let a=0;a<n.length;a++){const l=n[a];for(let c=0;c<e.length;c++){const h=e[c];if(!(h.start>l.end)){if(l.end<h.start||h.end<l.start)continue;if(l.start<=h.start&&l.end>=h.end)r(h.end,l.end)||n.splice(a+1,0,{start:h.end,end:l.end,index:l.index}),l.end=h.start,h.start=0,h.end=0;else if(l.start>=h.start&&l.end<=h.end)r(l.end,h.end)||e.splice(c+1,0,{start:l.end,end:h.end,index:h.index}),h.end=l.start,l.start=0,l.end=0;else if(l.start<=h.start&&l.end<=h.end){const d=l.end;l.end=h.start,h.start=d}else if(l.start>=h.start&&l.end>=h.end){const d=h.end;h.end=l.start,l.start=d}else throw new Error}if(t.has(l.index)||t.set(l.index,[]),t.has(h.index)||t.set(h.index,[]),t.get(l.index).push(h.index),t.get(h.index).push(l.index),o(h)&&(e.splice(c,1),c--),o(l)){n.splice(a,1),a--;break}}}s(n),s(e);function s(a){for(let l=0;l<a.length;l++)o(a[l])&&(a.splice(l,1),l--)}function r(a,l){return Math.abs(l-a)<i}function o(a){return Math.abs(a.end-a.start)<i}}const HA=1e-5,XA=1e-4;class HT{constructor(){this._rays=[]}addRay(e){this._rays.push(e)}findClosestRay(e){const t=this._rays,i=e.clone();i.direction.multiplyScalar(-1);let s=1/0,r=null;for(let l=0,c=t.length;l<c;l++){const h=t[l];if(o(h,e)&&o(h,i))continue;const d=a(h,e),f=a(h,i),u=Math.min(d,f);u<s&&(s=u,r=h)}return r;function o(l,c){const h=l.origin.distanceTo(c.origin)>HA;return l.direction.angleTo(c.direction)>XA||h}function a(l,c){const h=l.origin.distanceTo(c.origin),d=l.direction.angleTo(c.direction);return h/HA+d/XA}}}const Rf=new v.Vector3,kf=new v.Vector3,qc=new v.Ray;function XT(n,e,t){const i=n.attributes,s=n.index,r=i.position,o=new Map,a=new Map,l=Array.from(e),c=new HT;for(let h=0,d=l.length;h<d;h++){const f=l[h],u=QT(f),g=jT(f);let p=3*u+g,m=3*u+(g+1)%3;s&&(p=s.getX(p),m=s.getX(m)),Rf.fromBufferAttribute(r,p),kf.fromBufferAttribute(r,m),FT(Rf,kf,qc);let A,x=c.findClosestRay(qc);x===null&&(x=qc.clone(),c.addRay(x)),a.has(x)||a.set(x,{forward:[],reverse:[],ray:x}),A=a.get(x);let b=WA(x,Rf),y=WA(x,kf);b>y&&([b,y]=[y,b]),qc.direction.dot(x.direction)<0?A.reverse.push({start:b,end:y,index:f}):A.forward.push({start:b,end:y,index:f})}return a.forEach(({forward:h,reverse:d},f)=>{WT(h,d,o,t),h.length===0&&d.length===0&&a.delete(f)}),{disjointConnectivityMap:o,fragmentMap:a}}const qT=new v.Vector2,Ff=new v.Vector3,YT=new v.Vector4,Of=["","",""];class KT{constructor(e=null){this.data=null,this.disjointConnections=null,this.unmatchedDisjointEdges=null,this.unmatchedEdges=-1,this.matchedEdges=-1,this.useDrawRange=!0,this.useAllAttributes=!1,this.matchDisjointEdges=!1,this.degenerateEpsilon=1e-8,e&&this.updateFrom(e)}getSiblingTriangleIndex(e,t){const i=this.data[e*3+t];return i===-1?-1:~~(i/3)}getSiblingEdgeIndex(e,t){const i=this.data[e*3+t];return i===-1?-1:i%3}getDisjointSiblingTriangleIndices(e,t){const i=e*3+t,s=this.disjointConnections.get(i);return s?s.map(r=>~~(r/3)):[]}getDisjointSiblingEdgeIndices(e,t){const i=e*3+t,s=this.disjointConnections.get(i);return s?s.map(r=>r%3):[]}isFullyConnected(){return this.unmatchedEdges===0}updateFrom(e){const{useAllAttributes:t,useDrawRange:i,matchDisjointEdges:s,degenerateEpsilon:r}=this,o=t?b:x,a=new Map,{attributes:l}=e,c=t?Object.keys(l):null,h=e.index,d=l.position;let f=Lf(e);const u=f;let g=0;i&&(g=e.drawRange.start,e.drawRange.count!==1/0&&(f=~~(e.drawRange.count/3)));let p=this.data;(!p||p.length<3*u)&&(p=new Int32Array(3*u)),p.fill(-1);let m=0,A=new Set;for(let y=g,_=f*3+g;y<_;y+=3){const w=y;for(let S=0;S<3;S++){let D=w+S;h&&(D=h.getX(D)),Of[S]=o(D)}for(let S=0;S<3;S++){const D=(S+1)%3,M=Of[S],I=Of[D],P=`${I}_${M}`;if(a.has(P)){const T=w+S,L=a.get(P);p[T]=L,p[L]=T,a.delete(P),m+=2,A.delete(L)}else{const T=`${M}_${I}`,L=w+S;a.set(T,L),A.add(L)}}}if(s){const{fragmentMap:y,disjointConnectivityMap:_}=XT(e,A,r);A.clear(),y.forEach(({forward:w,reverse:S})=>{w.forEach(({index:D})=>A.add(D)),S.forEach(({index:D})=>A.add(D))}),this.unmatchedDisjointEdges=y,this.disjointConnections=_,m=f*3-A.size}this.matchedEdges=m,this.unmatchedEdges=A.size,this.data=p;function x(y){return Ff.fromBufferAttribute(d,y),VA(Ff)}function b(y){let _="";for(let w=0,S=c.length;w<S;w++){const D=l[c[w]];let M;switch(D.itemSize){case 1:M=wn(D.getX(y));break;case 2:M=RT(qT.fromBufferAttribute(D,y));break;case 3:M=VA(Ff.fromBufferAttribute(D,y));break;case 4:M=kT(YT.fromBufferAttribute(D,y));break}_!==""&&(_+="|"),_+=M}return _}}}class Yc extends v.Mesh{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new v.Matrix4,this._previousMatrix.elements.fill(0)}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){const{matrix:e,_previousMatrix:t}=this,i=e.elements,s=t.elements;for(let r=0;r<16;r++)if(i[r]!==s[r])return!0;return!1}prepareGeometry(){const e=this.geometry,t=e.attributes,i=QA();if(i)for(const s in t){const r=t[s];if(r.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");r.array=OT(r.array)}if(e.boundsTree||(NT(e,{useSharedArrayBuffer:i}),e.boundsTree=new Pf(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:i})),e.halfEdges||(e.halfEdges=new KT(e)),!e.groupIndices){const s=Lf(e),r=new Uint16Array(s),o=e.groups;for(let a=0,l=o.length;a<l;a++){const{start:c,count:h}=o[a];for(let d=c/3,f=(c+h)/3;d<f;d++)r[d]=a}e.groupIndices=r}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const $T=1e-14,Uf=new v.Vector3,qA=new v.Vector3,YA=new v.Vector3;function Ds(n,e=$T){Uf.subVectors(n.b,n.a),qA.subVectors(n.c,n.a),YA.subVectors(n.b,n.c);const t=Uf.angleTo(qA),i=Uf.angleTo(YA),s=Math.PI-t-i;return Math.abs(t)<e||Math.abs(i)<e||Math.abs(s)<e||n.a.distanceToSquared(n.b)<e||n.a.distanceToSquared(n.c)<e||n.b.distanceToSquared(n.c)<e}const Nf=1e-10,Da=1e-10,ZT=1e-10,ts=new v.Line3,kt=new v.Line3,is=new v.Vector3,zf=new v.Vector3,KA=new v.Vector3,Kc=new v.Plane,Gf=new Vi;class JT{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new v.Triangle),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class e5{constructor(){this.trianglePool=new JT,this.triangles=[],this.normal=new v.Vector3,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:i,normal:s}=this;if(Array.isArray(e))for(let r=0,o=e.length;r<o;r++){const a=e[r];if(r===0)a.getNormal(s);else if(Math.abs(1-a.getNormal(is).dot(s))>Nf)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");const l=i.getTriangle();l.copy(a),t.push(l)}else{e.getNormal(s);const r=i.getTriangle();r.copy(e),t.push(r)}}splitByTriangle(e){const{normal:t,triangles:i}=this;if(e.getNormal(zf).normalize(),Math.abs(1-Math.abs(zf.dot(t)))<ZT){this.coplanarTriangleUsed=!0;for(let r=0,o=i.length;r<o;r++){const a=i[r];a.coplanarCount=0}const s=[e.a,e.b,e.c];for(let r=0;r<3;r++){const o=(r+1)%3,a=s[r],l=s[o];is.subVectors(l,a).normalize(),KA.crossVectors(zf,is),Kc.setFromNormalAndCoplanarPoint(KA,a),this.splitByPlane(Kc,e)}}else e.getPlane(Kc),this.splitByPlane(Kc,e)}splitByPlane(e,t){const{triangles:i,trianglePool:s}=this;Gf.copy(t),Gf.needsUpdate=!0;for(let r=0,o=i.length;r<o;r++){const a=i[r];if(!Gf.intersectsTriangle(a,ts,!0))continue;const{a:l,b:c,c:h}=a;let d=0,f=-1,u=!1,g=[],p=[];const m=[l,c,h];for(let A=0;A<3;A++){const x=(A+1)%3;ts.start.copy(m[A]),ts.end.copy(m[x]);const b=e.distanceToPoint(ts.start),y=e.distanceToPoint(ts.end);if(Math.abs(b)<Da&&Math.abs(y)<Da){u=!0;break}if(b>0?g.push(A):p.push(A),Math.abs(b)<Da)continue;let _=!!e.intersectLine(ts,is);!_&&Math.abs(y)<Da&&(is.copy(ts.end),_=!0),_&&!(is.distanceTo(ts.start)<Nf)&&(is.distanceTo(ts.end)<Nf&&(f=A),d===0?kt.start.copy(is):kt.end.copy(is),d++)}if(!u&&d===2&&kt.distance()>Da)if(f!==-1){f=(f+1)%3;let A=0;A===f&&(A=(A+1)%3);let x=A+1;x===f&&(x=(x+1)%3);const b=s.getTriangle();b.a.copy(m[x]),b.b.copy(kt.end),b.c.copy(kt.start),Ds(b)||i.push(b),a.a.copy(m[A]),a.b.copy(kt.start),a.c.copy(kt.end),Ds(a)&&(i.splice(r,1),r--,o--)}else{const A=g.length>=2?p[0]:g[0];if(A===0){let w=kt.start;kt.start=kt.end,kt.end=w}const x=(A+1)%3,b=(A+2)%3,y=s.getTriangle(),_=s.getTriangle();m[x].distanceToSquared(kt.start)<m[b].distanceToSquared(kt.end)?(y.a.copy(m[x]),y.b.copy(kt.start),y.c.copy(kt.end),_.a.copy(m[x]),_.b.copy(m[b]),_.c.copy(kt.start)):(y.a.copy(m[b]),y.b.copy(kt.start),y.c.copy(kt.end),_.a.copy(m[x]),_.b.copy(m[b]),_.c.copy(kt.end)),a.a.copy(m[A]),a.b.copy(kt.end),a.c.copy(kt.start),Ds(y)||i.push(y),Ds(_)||i.push(_),Ds(a)&&(i.splice(r,1),r--,o--)}else d===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}function t5(n){return n=~~n,n+4-n%4}class $A{constructor(e,t=500){this.expansionFactor=1.5,this.type=e,this.length=0,this.array=null,this.setSize(t)}setType(e){if(this.length!==0)throw new Error("TypeBackedArray: Cannot change the type while there is used data in the buffer.");const t=this.array.buffer;this.array=new e(t),this.type=e}setSize(e){if(this.array&&e===this.array.length)return;const t=this.type,i=QA()?SharedArrayBuffer:ArrayBuffer,s=new t(new i(t5(e*t.BYTES_PER_ELEMENT)));this.array&&s.set(this.array,0),this.array=s}expand(){const{array:e,expansionFactor:t}=this;this.setSize(e.length*t)}push(...e){let{array:t,length:i}=this;i+e.length>t.length&&(this.expand(),t=this.array);for(let s=0,r=e.length;s<r;s++)t[i+s]=e[s];this.length+=e.length}clear(){this.length=0}}class i5{constructor(){this.groupAttributes=[{}],this.groupCount=0}getType(e){return this.groupAttributes[0][e].type}getItemSize(e){return this.groupAttributes[0][e].itemSize}getNormalized(e){return this.groupAttributes[0][e].normalized}getCount(e){if(this.groupCount<=e)return 0;const t=this.getGroupAttrArray("position",e);return t.length/t.itemSize}getTotalLength(e){const{groupCount:t,groupAttributes:i}=this;let s=0;for(let r=0;r<t;r++){const o=i[r];s+=o[e].length}return s}getGroupAttrSet(e=0){const{groupAttributes:t}=this;if(t[e])return this.groupCount=Math.max(this.groupCount,e+1),t[e];const i=t[0];for(this.groupCount=Math.max(this.groupCount,e+1);e>=t.length;){const s={};t.push(s);for(const r in i){const o=i[r],a=new $A(o.type);a.itemSize=o.itemSize,a.normalized=o.normalized,s[r]=a}}return t[e]}getGroupAttrArray(e,t=0){const{groupAttributes:i}=this;if(!i[0][e])throw new Error(`TypedAttributeData: Attribute with "${e}" has not been initialized`);return this.getGroupAttrSet(t)[e]}initializeArray(e,t,i,s){const{groupAttributes:r}=this,a=r[0][e];if(a){if(a.type!==t)for(let l=0,c=r.length;l<c;l++){const h=r[l][e];h.setType(t),h.itemSize=i,h.normalized=s}}else for(let l=0,c=r.length;l<c;l++){const h=new $A(t);h.itemSize=i,h.normalized=s,r[l][e]=h}}clear(){this.groupCount=0;const{groupAttributes:e}=this;e.forEach(t=>{for(const i in t)t[i].clear()})}delete(e){this.groupAttributes.forEach(t=>{delete t[e]})}reset(){this.groupAttributes=[],this.groupCount=0}}class ZA{constructor(){this.intersectionSet={},this.ids=[]}add(e,t){const{intersectionSet:i,ids:s}=this;i[e]||(i[e]=[],s.push(e)),i[e].push(t)}}const n5=0,s5=1,r5=2,JA=3,o5=4,ex=5,tx=6,Wi=new v.Ray,ix=new v.Matrix4,ci=new v.Triangle,ns=new v.Vector3,nx=new v.Vector4,sx=new v.Vector4,rx=new v.Vector4,Vf=new v.Vector4,$c=new v.Vector4,Zc=new v.Vector4,ox=new v.Line3,Qf=new v.Vector3,jf=1e-8,a5=1e-15,xr=-1,br=1,Jc=-2,eh=2,Ba=0,yr=1,Wf=2,l5=1e-14;let th=null;function ax(n){th=n}function lx(n,e){n.getMidpoint(Wi.origin),n.getNormal(Wi.direction);const t=e.raycastFirst(Wi,v.DoubleSide);return!!(t&&Wi.direction.dot(t.face.normal)>0)?xr:br}function c5(n,e){function t(){return Math.random()-.5}n.getNormal(Qf),Wi.direction.copy(Qf),n.getMidpoint(Wi.origin);const i=3;let s=0,r=1/0;for(let o=0;o<i;o++){Wi.direction.x+=t()*jf,Wi.direction.y+=t()*jf,Wi.direction.z+=t()*jf,Wi.direction.multiplyScalar(-1);const a=e.raycastFirst(Wi,v.DoubleSide);if(!!(a&&Wi.direction.dot(a.face.normal)>0)&&s++,a!==null&&(r=Math.min(r,a.distance)),r<=a5)return a.face.normal.dot(Qf)>0?eh:Jc;if(s/i>.5||(o-s+1)/i>.5)break}return s/i>.5?xr:br}function h5(n,e){const t=new ZA,i=new ZA;return ix.copy(n.matrixWorld).invert().multiply(e.matrixWorld),n.geometry.boundsTree.bvhcast(e.geometry.boundsTree,ix,{intersectsTriangles(s,r,o,a){if(!Ds(s)&&!Ds(r)){let l=s.intersectsTriangle(r,ox,!0);if(!l){const c=s.plane,h=r.plane,d=c.normal,f=h.normal;d.dot(f)===1&&Math.abs(c.constant-h.constant)<l5&&(l=!0)}if(l){let c=n.geometry.boundsTree.resolveTriangleIndex(o),h=e.geometry.boundsTree.resolveTriangleIndex(a);t.add(c,h),i.add(h,c),th&&(th.addEdge(ox),th.addIntersectingTriangles(o,s,a,r))}}return!1}}),{aIntersections:t,bIntersections:i}}function d5(n,e,t,i,s,r,o=!1){const a=t.attributes,l=t.index,c=n*3,h=l.getX(c+0),d=l.getX(c+1),f=l.getX(c+2);for(const u in r){const g=a[u],p=r[u];if(!(u in a))throw new Error(`CSG Operations: Attribute ${u} not available on geometry.`);const m=g.itemSize;u==="position"?(ci.a.fromBufferAttribute(g,h).applyMatrix4(i),ci.b.fromBufferAttribute(g,d).applyMatrix4(i),ci.c.fromBufferAttribute(g,f).applyMatrix4(i),Hf(ci.a,ci.b,ci.c,e,3,p,o)):u==="normal"?(ci.a.fromBufferAttribute(g,h).applyNormalMatrix(s),ci.b.fromBufferAttribute(g,d).applyNormalMatrix(s),ci.c.fromBufferAttribute(g,f).applyNormalMatrix(s),o&&(ci.a.multiplyScalar(-1),ci.b.multiplyScalar(-1),ci.c.multiplyScalar(-1)),Hf(ci.a,ci.b,ci.c,e,3,p,o,!0)):(nx.fromBufferAttribute(g,h),sx.fromBufferAttribute(g,d),rx.fromBufferAttribute(g,f),Hf(nx,sx,rx,e,m,p,o))}}function u5(n,e,t,i,s,r,o,a=!1){Xf(n,i,s,r,o,a),Xf(a?t:e,i,s,r,o,a),Xf(a?e:t,i,s,r,o,a)}function cx(n,e,t=!1){switch(n){case n5:if(e===br||e===eh&&!t)return yr;break;case s5:if(t){if(e===xr)return Ba}else if(e===br||e===Jc)return yr;break;case r5:if(t){if(e===br||e===Jc)return yr}else if(e===xr)return Ba;break;case o5:if(e===xr)return Ba;if(e===br)return yr;break;case JA:if(e===xr||e===eh&&!t)return yr;break;case ex:if(!t&&(e===br||e===Jc))return yr;break;case tx:if(!t&&(e===xr||e===eh))return yr;break;default:throw new Error(`Unrecognized CSG operation enum "${n}".`)}return Wf}function Hf(n,e,t,i,s,r,o=!1,a=!1){const l=c=>{r.push(c.x),s>1&&r.push(c.y),s>2&&r.push(c.z),s>3&&r.push(c.w)};Vf.set(0,0,0,0).addScaledVector(n,i.a.x).addScaledVector(e,i.a.y).addScaledVector(t,i.a.z),$c.set(0,0,0,0).addScaledVector(n,i.b.x).addScaledVector(e,i.b.y).addScaledVector(t,i.b.z),Zc.set(0,0,0,0).addScaledVector(n,i.c.x).addScaledVector(e,i.c.y).addScaledVector(t,i.c.z),a&&(Vf.normalize(),$c.normalize(),Zc.normalize()),l(Vf),o?(l(Zc),l($c)):(l($c),l(Zc))}function Xf(n,e,t,i,s,r=!1){for(const o in s){const a=e[o],l=s[o];if(!(o in e))throw new Error(`CSG Operations: Attribute ${o} no available on geometry.`);const c=a.itemSize;o==="position"?(ns.fromBufferAttribute(a,n).applyMatrix4(t),l.push(ns.x,ns.y,ns.z)):o==="normal"?(ns.fromBufferAttribute(a,n).applyNormalMatrix(i),r&&ns.multiplyScalar(-1),l.push(ns.x,ns.y,ns.z)):(l.push(a.getX(n)),c>1&&l.push(a.getY(n)),c>2&&l.push(a.getZ(n)),c>3&&l.push(a.getW(n)))}}class f5{constructor(e){this.triangle=new v.Triangle().copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=new v.Triangle().copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const i in t)e.push(t[i]);return e}}class hx{constructor(){this.data={}}addTriangleIntersection(e,t,i,s){const{data:r}=this;r[e]||(r[e]=new f5(t)),r[e].addTriangle(i,s)}getTrianglesAsArray(e=null){const{data:t}=this,i=[];if(e!==null)e in t&&i.push(t[e].triangle);else for(const s in t)i.push(t[s].triangle);return i}getTriangleIndices(){return Object.keys(this.data).map(e=>parseInt(e))}getIntersectionIndices(e){const{data:t}=this;return t[e]?Object.keys(t[e].intersects).map(i=>parseInt(i)):[]}getIntersectionsAsArray(e=null,t=null){const{data:i}=this,s=new Set,r=[],o=a=>{if(i[a])if(t!==null)i[a].intersects[t]&&r.push(i[a].intersects[t]);else{const l=i[a].intersects;for(const c in l)s.has(c)||(s.add(c),r.push(l[c]))}};if(e!==null)o(e);else for(const a in i)o(a);return r}reset(){this.data={}}}class p5{constructor(){this.enabled=!1,this.triangleIntersectsA=new hx,this.triangleIntersectsB=new hx,this.intersectionEdges=[]}addIntersectingTriangles(e,t,i,s){const{triangleIntersectsA:r,triangleIntersectsB:o}=this;r.addTriangleIntersection(e,t,i,s),o.addTriangleIntersection(i,s,e,t)}addEdge(e){this.intersectionEdges.push(e.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),ax(this))}complete(){this.enabled&&ax(null)}}const Bs=new v.Matrix4,ih=new v.Matrix3,vr=new v.Triangle,nh=new v.Triangle,Ps=new v.Triangle,sh=new v.Triangle,rn=[],_r=[];function g5(n){for(const e of n)return e}function m5(n,e,t,i,s,r={}){const{useGroups:o=!0}=r,{aIntersections:a,bIntersections:l}=h5(n,e),c=[];let h=null,d;return d=o?0:-1,dx(n,e,a,t,!1,i,s,d),ux(n,e,a,t,!1,s,d),t.findIndex(u=>u!==tx&&u!==ex)!==-1&&(d=o?n.geometry.groups.length||1:-1,dx(e,n,l,t,!0,i,s,d),ux(e,n,l,t,!0,s,d)),rn.length=0,_r.length=0,{groups:c,materials:h}}function dx(n,e,t,i,s,r,o,a=0){const l=n.matrixWorld.determinant()<0;Bs.copy(e.matrixWorld).invert().multiply(n.matrixWorld),ih.getNormalMatrix(n.matrixWorld).multiplyScalar(l?-1:1);const c=n.geometry.groupIndices,h=n.geometry.index,d=n.geometry.attributes.position,f=e.geometry.boundsTree,u=e.geometry.index,g=e.geometry.attributes.position,p=t.ids,m=t.intersectionSet;for(let A=0,x=p.length;A<x;A++){const b=p[A],y=a===-1?0:c[b]+a,_=3*b,w=h.getX(_+0),S=h.getX(_+1),D=h.getX(_+2);vr.a.fromBufferAttribute(d,w).applyMatrix4(Bs),vr.b.fromBufferAttribute(d,S).applyMatrix4(Bs),vr.c.fromBufferAttribute(d,D).applyMatrix4(Bs),r.reset(),r.initialize(vr);const M=m[b];for(let P=0,T=M.length;P<T;P++){const L=3*M[P],E=u.getX(L+0),F=u.getX(L+1),z=u.getX(L+2);nh.a.fromBufferAttribute(g,E),nh.b.fromBufferAttribute(g,F),nh.c.fromBufferAttribute(g,z),r.splitByTriangle(nh)}const I=r.triangles;for(let P=0,T=I.length;P<T;P++){const L=I[P],E=r.coplanarTriangleUsed?c5(L,f):lx(L,f);rn.length=0,_r.length=0;for(let F=0,z=i.length;F<z;F++){const X=cx(i[F],E,s);X!==Wf&&(_r.push(X),rn.push(o[F].getGroupAttrSet(y)))}if(rn.length!==0){vr.getBarycoord(L.a,sh.a),vr.getBarycoord(L.b,sh.b),vr.getBarycoord(L.c,sh.c);for(let F=0,z=rn.length;F<z;F++){const X=rn[F],N=_r[F]===Ba;d5(b,sh,n.geometry,n.matrixWorld,ih,X,l!==N)}}}}return p.length}function ux(n,e,t,i,s,r,o=0){const a=n.matrixWorld.determinant()<0;Bs.copy(e.matrixWorld).invert().multiply(n.matrixWorld),ih.getNormalMatrix(n.matrixWorld).multiplyScalar(a?-1:1);const l=e.geometry.boundsTree,c=n.geometry.groupIndices,h=n.geometry.index,d=n.geometry.attributes,f=d.position,u=[],g=n.geometry.halfEdges,p=new Set,m=Lf(n.geometry);for(let A=0,x=m;A<x;A++)A in t.intersectionSet||p.add(A);for(;p.size>0;){const A=g5(p);p.delete(A),u.push(A);const x=3*A,b=h.getX(x+0),y=h.getX(x+1),_=h.getX(x+2);Ps.a.fromBufferAttribute(f,b).applyMatrix4(Bs),Ps.b.fromBufferAttribute(f,y).applyMatrix4(Bs),Ps.c.fromBufferAttribute(f,_).applyMatrix4(Bs);const w=lx(Ps,l);_r.length=0,rn.length=0;for(let S=0,D=i.length;S<D;S++){const M=cx(i[S],w,s);M!==Wf&&(_r.push(M),rn.push(r[S]))}for(;u.length>0;){const S=u.pop();for(let D=0;D<3;D++){const M=g.getSiblingTriangleIndex(S,D);M!==-1&&p.has(M)&&(u.push(M),p.delete(M))}if(rn.length!==0){const D=3*S,M=h.getX(D+0),I=h.getX(D+1),P=h.getX(D+2),T=o===-1?0:c[S]+o;if(Ps.a.fromBufferAttribute(f,M),Ps.b.fromBufferAttribute(f,I),Ps.c.fromBufferAttribute(f,P),!Ds(Ps))for(let L=0,E=rn.length;L<E;L++){const F=_r[L],z=rn[L].getGroupAttrSet(T),X=F===Ba;u5(M,I,P,d,n.matrixWorld,ih,z,X!==a)}}}}}function A5(n){for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(t.materialIndex===i.materialIndex){const s=t.start,r=i.start+i.count;i.start=s,i.count=r-s,n.splice(e,1),e--}}}function x5(n,e,t,i){t.clear();const s=n.attributes;for(let r=0,o=i.length;r<o;r++){const a=i[r],l=s[a];t.initializeArray(a,l.array.constructor,l.itemSize,l.normalized)}for(const r in t.attributes)i.includes(r)||t.delete(r);for(const r in e.attributes)i.includes(r)||(e.deleteAttribute(r),e.dispose())}function b5(n,e,t){let i=!1,s=-1;const r=n.attributes,o=e.groupAttributes[0];for(const l in o){const c=e.getTotalLength(l),h=e.getType(l),d=e.getItemSize(l),f=e.getNormalized(l);let u=r[l];(!u||u.array.length<c)&&(u=new v.BufferAttribute(new h(c),d,f),n.setAttribute(l,u),i=!0);let g=0;for(let p=0,m=Math.min(t.length,e.groupCount);p<m;p++){const A=t[p].index,{array:x,type:b,length:y}=e.groupAttributes[A][l],_=new b(x.buffer,0,y);u.array.set(_,g),g+=_.length}u.needsUpdate=!0,s=c/u.itemSize}if(n.index){const l=n.index.array;if(l.length<s)n.index=null,i=!0;else for(let c=0,h=l.length;c<h;c++)l[c]=c}let a=0;n.clearGroups();for(let l=0,c=Math.min(t.length,e.groupCount);l<c;l++){const{index:h,materialIndex:d}=t[l],f=e.getCount(h);f!==0&&(n.addGroup(a,f,d),a+=f)}n.setDrawRange(0,s),n.boundsTree=null,i&&n.dispose()}function fx(n,e){let t=e;return Array.isArray(e)||(t=[],n.forEach(i=>{t[i.materialIndex]=e})),t}class y5{constructor(){this.triangleSplitter=new e5,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new p5}getGroupRanges(e){return!this.useGroups||e.groups.length===0?[{start:0,count:1/0,materialIndex:0}]:e.groups.map(t=>({...t}))}evaluate(e,t,i,s=new Yc){let r=!0;if(Array.isArray(i)||(i=[i]),Array.isArray(s)||(s=[s],r=!1),s.length!==i.length)throw new Error("Evaluator: operations and target array passed as different sizes.");e.prepareGeometry(),t.prepareGeometry();const{triangleSplitter:o,attributeData:a,attributes:l,useGroups:c,consolidateGroups:h,debug:d}=this;for(;a.length<s.length;)a.push(new i5);s.forEach((A,x)=>{x5(e.geometry,A.geometry,a[x],l)}),d.init(),m5(e,t,i,o,a,{useGroups:c}),d.complete();const f=this.getGroupRanges(e.geometry),u=fx(f,e.material),g=this.getGroupRanges(t.geometry),p=fx(g,t.material);g.forEach(A=>A.materialIndex+=u.length);let m=[...f,...g].map((A,x)=>({...A,index:x}));if(c){const A=[...u,...p];h&&(m=m.map(b=>{const y=A[b.materialIndex];return b.materialIndex=A.indexOf(y),b}).sort((b,y)=>b.materialIndex-y.materialIndex));const x=[];for(let b=0,y=A.length;b<y;b++){let _=!1;for(let w=0,S=m.length;w<S;w++){const D=m[w];D.materialIndex===b&&(_=!0,D.materialIndex=x.length)}_&&x.push(A[b])}s.forEach(b=>{b.material=x})}else m=[{start:0,count:1/0,index:0,materialIndex:0}],s.forEach(A=>{A.material=u[0]});return s.forEach((A,x)=>{const b=A.geometry;b5(b,a[x],m),h&&A5(b.groups)}),r?s:s[0]}evaluateHierarchy(e,t=new Yc){e.updateMatrixWorld(!0);const i=(r,o)=>{const a=r.children;for(let l=0,c=a.length;l<c;l++){const h=a[l];h.isOperationGroup?i(h,o):o(h)}},s=r=>{const o=r.children;let a=!1;for(let c=0,h=o.length;c<h;c++){const d=o[c];a=s(d)||a}const l=r.isDirty();if(l&&r.markUpdated(),a&&!r.isOperationGroup){let c;return i(r,h=>{c?c=this.evaluate(c,h,h.operation):c=this.evaluate(r,h,h.operation)}),r._cachedGeometry=c.geometry,r._cachedMaterials=c.material,!0}else return a||l};return s(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}class v5{engine;evaluator;fillMeshName="ClippingFaceFillMesh";fillMeshes=new Map;maxCandidates=22e5;maxTriangleCountPerMesh=12e4;fillMaterial;fillTextureRepeat=60;fillTextureRotation=0;constructor(e){this.engine=e,this.evaluator=new y5;const t=new URL("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAsTAAALEwEAmpwYAAAJT0lEQVR4nO3cT44dVxmG8bdbmSBLCGMmIBYAQkRiF0BYQwiDMGYdrIBkQpaQQbIGFmCQ3EgeGywDA8i4GSR23O6+99afU1XnO8/zLOCopNLvVakG5+qrmz/exobpb3//R37920/y6t9fNTvzyeNH+eLPH+f9n/6o2Zm2TX+9eZEPPvp08vu/3vh5bMfEz24u/sQBGCbxs1uCP3EAhkj87JbiTxyA8omf3Rr8iQNQOvGzW4s/cQDKJn52LfAnDkDJxM+uFf7EASiX+Nm1xJ84AKUSP7vW+BMHoEziZ7cF/iePHzkAFRI/u63wf/nZ7x2A3hM/uy3x//wnP3QAek787LbGn/gPoNvEz24P/IkD0GXiZ7cX/sQB6C7xs9sTf+IAdJX42e2NP3EAukn87I7AnzgAXSR+dkfhTxyAwxM/u6fPjsOfOACHJn52T5+9yG9+dxz+xAE4LPGz6wF/4gAckvjZ9YI/cQB2T/zsesKfOAC7Jn52veFPHIDdEj+7HvEnDsAuiZ9dr/gTB2DzxM+uZ/yJA7Bp4mfXO/7EAdgs8bOrgD9xADZJ/Oyq4E8cgOaJn10l/IkD0DTxs6uGP3EAmiV+dhXxJw5Ak8TPrir+xAFYnfjZVcafOACrEj+76vgTB2Bx4mc3Av7EAViU+NmNgj9xAGYnfnYj4U8cgFmJn91o+BMHYHLiZzci/sQBmJT42Y2KP3EALiZ+diPjTxyAs4mf3ej4EwfgZOJnR8CfOAAPJn52FPyJA3Av8bMj4U8cgDuJnx0Nf+IAvEn87Ij4EwcgifjpUfEnDoD44ZHxJ/ABED87Ov4EPADiZyf+r0MOgPjZif/bcAMgfnbivxtqAMTPTvz3wwyA+NmJ/+EQAyB+duI/3fADIH524j/f0AMgfnbiv9ywAyB+duKf1pADIH524p/ecAMgfnbin9dQAyB+duKf3zADIH524l/WEAMgfnbiX175ARA/O/Gvq/QAiJ+d+NdXdgDEz078bSo5AOJnJ/52lRsA8bMTf9tKDYD42Ym/fWUGQPzsxL9NJQZA/OzEv13dD4D42Yl/27oeAPGzE//2dTsA4mcn/n3qcgDEz078+9XdAIifnfj3rasBED878e9fNwMgfnbiP6YuBkD87MR/XIcPgPjZif/YDh0A8bMT//EdNgDiZyf+PjpkAMTPTvz9tPsAiJ+d+Ptq1wEQPzvx99duAyB+duLvs10GQPzsxN9vmw+A+NmJv+82HQDxsxN//202AOJnJ/4abTIA4mcn/jo1HwDxsxN/rZoOgPjZib9ezQZA/OzEX7MmAyB+duKv2+oBED878ddu1QCIn53467d4AMTPTvxjtGgAxM9O/OM0ewDEz078YzVrAMTPTvzjNXkAxM9O/GM2aQDEz07843ZxAMTPTvxjd3YAxM9O/ON3cgDEz078jB4cAPGzEz+newMgfnbiZ3VnAMTPTvy83gyA+NmJn9l1In564ud2LX524md39YPvP7oVPzPxs7t5/jJXSW5bHSj+Oomf3c3zl/nlh39qdymo+Oskfnav8b989b82AyD+Oomf3dv4kwaXgoq/TuJn9y7+ZOUAiL9O4mf3EP5kxQCIv07iZ3cKf7JwAMRfJ/GzO4c/WTAA4q+T+Nldwp/MHADx10n87KbgT2YMgPjrJH52U/EnEwdA/HUSP7s5+JMJAyD+Oomf3Vz8yYUBEH+dxM9uCf7kzACIv07iZ7cUf3JiAMRfJ/GzW4M/eWAAxF8n8bNbiz95ZwDEXyfxs2uBP3lrAMRfJ/Gza4U/+WYAxF8n8bO7ef4yv/rwkyb4k+Ra/HUSP7vX+P/56r/Nzrz6y+d/uBV//4mf3Rb4v/fd7+Ra/P0nfnZb4f/is4/bXQpq2yR+dlvi/8XPfuwA9Jz42W2NP2lwKahtk/jZ7YE/cQC6TPzs9sKfOADdJX52e+JPHICuEj+7vfEnDkA3iZ/dEfgTB6CLxM/uKPyJA3B44md3JP7EATg08bM7Gn/iAByW+Nn1gD9xAA5J/Ox6wZ84ALsnfnY94U8cgF0TP7ve8CcOwG6Jn12P+BMHYJfEz65X/IkDsHniZ9cz/sQB2DTxs+sdf+IAbJb42VXAnzgAmyR+dlXwJw5A88TPrhL+xAFomvjZVcOfOADNEj+7ivgTB6BJ4mdXFX/iAKxO/Owq408cgFWJn111/IkDsDjxsxsBf+IALEr87EbBnzgAsxM/u5HwJw7ArMTPbjT8iQMwOfGzGxF/4gBMSvzsRsWfOAAXEz+7kfEnDsDZxM9udPyJA3Ay8bMj4E8cgAcTPzsK/sQBuJf42ZHwJw7AncTPjoY/cQDeJH52RPyJA5BE/PSo+BMHQPzwyPgT+ACInx0dfwIeAPGzE//XIQdA/OzE/224ARA/O/HfDTUA4mcn/vthBkD87MT/cIgBED878Z9u+AEQPzvxn2/oARA/O/FfbtgBED878U9ryAEQPzvxT2+4ARA/O/HPa6gBED878c9vmAEQPzvxL2uIARA/O/Ev772jH2BtT5+9yAcffZp//Uf8xMS/rtJfAOJnJ/71lR0A8bMTf5tKDoD42Ym/XeUGQPzsxN+2UgMgfnbib1+ZARA/O/FvU4kBED878W9X9wMgfnbi37auB0D87MS/fd0OgPjZiX+fuhwA8bMT/351NwDiZyf+fetqAMTPTvz7180AiJ+d+I+piwEQPzvxH9fhAyB+duI/tkMHQPzsxH98hw2A+NmJv48OGQDxsxN/P+0+AOJnJ/6+2nUAxM9O/P212wCIn534+2yXARA/O/H32+YDIH524u+7TQdA/OzE33+bDYD42Ym/RpsMgPjZib9OzQdA/OzEX6umAyB+duKvV7MBED878desyQCIn53467Z6AMTPTvy1WzUA4mcn/votHgDxsxP/GC0aAPGzE/84zR4A8bMT/1jNGgDxsxP/eE0eAPGzE/+YTRoA8bMT/7hdHADxsxP/2J0dAPGzE//4nRwA8bMTP6MHB0D87MTP6d4AiJ+d+FndGQDxsxM/rzcDIH524md2nYifnvi5XYufnfjZXT15/OhW/MzEb1dJblsdJv46id+ShpeCir9O4rfXNRkA8ddJ/PZ2qwdA/HUSv73bqgEQf53Ebw+1eADEXyfx26kWDYD46yR+O9fsARB/ncRvl5o1AOKvk/htSpMHQPx1Er9N7f/Udadd2eKhBAAAAABJRU5ErkJggg==",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,i=new C.TextureLoader().load(t);i.wrapS=C.RepeatWrapping,i.wrapT=C.RepeatWrapping,i.center.set(.5,.5),i.rotation=this.fillTextureRotation,this.fillMaterial=new C.MeshStandardMaterial({color:16112010,map:i,side:C.DoubleSide,toneMapped:!1}),this.fillMaterial.clipShadows=!0,this.fillMaterial.clippingPlanes=e.sectionPlane}clear(){this.fillMeshes.forEach(e=>{e.parent?.remove(e),e.geometry?.dispose?.();const t=e.material;Array.isArray(t)?t.forEach(i=>i.dispose?.()):t&&t!==this.fillMaterial&&t.dispose?.()}),this.fillMeshes.clear()}updataFace(e){this.clear(),e instanceof C.Plane&&this.engine.clipping.fillCutFace&&this.buildSinglePlaneFill(e,"face")}updataFaces(e){this.clear(),!(!Array.isArray(e)||e.length===0)&&this.engine.clipping.fillCutFace&&e.forEach((t,i)=>{if(!(t instanceof C.Plane))return;const s=`plane-${i}-${String(t.name??i)}`;this.buildSinglePlaneFill(t,s)})}buildSinglePlaneFill(e,t){const i=this.engine?.octreeBox?.getBoundingBox?.();if(i==null||i.min==null||i.max==null)return;const s=this.collectCandidateMeshesFromOctree(e);if(s.length===0)return;const r=this.filterMeshesByBoxAndComplexity(e,s);if(r.length===0)return;const o=i.min.distanceTo(i.max),a=o*5,l=.1,c=this.createPlaneBrush(e,a,l),h=[];for(const p of r.slice(0,this.maxCandidates)){const m=this.createWorldBrushFromMesh(p);if(m!=null)try{const x=this.evaluator.evaluate(m,c,JA)?.geometry;if(!x)continue;const b=this.extractPlaneCapGeometry(x,e,l);b&&h.push(b),x.dispose()}catch{}finally{m.geometry.dispose()}}if(c.geometry.dispose(),h.length===0)return;const d=Cs(h,!1);if(h.forEach(p=>p.dispose()),!d)return;this.applyPlanarUv(d,e);const f=this.getFaceOffsetDistance(o),u=this.getFaceOffsetSign();d.translate(e.normal.x*f*u,e.normal.y*f*u,e.normal.z*f*u);const g=new C.Mesh(d,this.fillMaterial);g.name=`${this.fillMeshName}_${t}`,g.frustumCulled=!1,g.renderOrder=20,g.castShadow=!1,g.receiveShadow=!1,this.engine.scene.add(g),this.fillMeshes.set(t,g)}getFaceOffsetDistance(e){return-.001}getFaceOffsetSign(){const e=this.engine?.engineStatus?.clippingFaceOffsetSign;return e===1||e===-1?e:-1}collectCandidateMeshesFromOctree(e){const t=[],i=new Set,s=Array.isArray(this.engine?.engineStatus?.models)?this.engine.engineStatus.models:[];for(const r of s){const o=this.engine.models?.find?.(c=>c.url===r.url);if(!o?.nodesMap)continue;const a=this.getIgnoredIds(r.url),l=Array.isArray(r?.info?.lods)?r.info.lods:[];for(const c of l){const h=c?.octreeBox;if(!h)continue;const d=this.collectIntersectElementIds(h,e);for(const f of d){if(a.has(f))continue;const u=o.nodesMap.get(f);if(!(u?.instance===!0||!Array.isArray(u?.infos)))for(const g of u.infos){const p=g?.mesh;p instanceof C.Mesh&&(i.has(p.uuid)||(i.add(p.uuid),t.push(p)))}}}}return t}getIgnoredIds(e){const t=new Set,i=Array.isArray(this.engine?.engineStatus?.hideModels)?this.engine.engineStatus.hideModels:[],s=Array.isArray(this.engine?.engineStatus?.translucentModels)?this.engine.engineStatus.translucentModels:[],r=i.find(a=>a.url===e)?.ids;Array.isArray(r)&&r.forEach(a=>t.add(a));const o=s.find(a=>a.url===e)?.ids;return Array.isArray(o)&&o.forEach(a=>t.add(a)),t}collectIntersectElementIds(e,t){const i=new Set,s=[e];for(;s.length>0;){const r=s.pop();if(!r)continue;const o=this.octreeNodeToBox3(r);!o||!t.intersectsBox(o)||(Array.isArray(r.elements)&&r.elements.forEach(a=>i.add(a)),Array.isArray(r.children)&&r.children.forEach(a=>s.push(a)))}return i}octreeNodeToBox3(e){if(!e?.min||!e?.max)return null;const t=new C.Vector3(e.min.X*.3048,e.min.Z*.3048,-e.min.Y*.3048),i=new C.Vector3(e.max.X*.3048,e.max.Z*.3048,-e.max.Y*.3048),s=new C.Vector3(Math.min(t.x,i.x),Math.min(t.y,i.y),Math.min(t.z,i.z)),r=new C.Vector3(Math.max(t.x,i.x),Math.max(t.y,i.y),Math.max(t.z,i.z));return new C.Box3(s,r)}filterMeshesByBoxAndComplexity(e,t){const i=[],s=new C.Box3;for(const r of t){const o=r.geometry,a=o?.attributes?.position;!o||!a||a.count===0||(o.index?Math.floor(o.index.count/3):Math.floor(a.count/3))>this.maxTriangleCountPerMesh||(o.boundingBox||o.computeBoundingBox(),o.boundingBox&&(s.copy(o.boundingBox),r.updateWorldMatrix(!0,!1),s.applyMatrix4(r.matrixWorld),e.intersectsBox(s)&&(r.geometry.attributes.position.count>500||i.push(r))))}return i}createPlaneBrush(e,t,i){const s=new C.BoxGeometry(t,t,i),r=e.coplanarPoint(new C.Vector3),o=new C.Quaternion().setFromUnitVectors(new C.Vector3(0,0,1),e.normal.clone().normalize()),a=new C.Matrix4().compose(r,o,new C.Vector3(1,1,1));s.applyMatrix4(a);const l=this.toCsgReadyGeometry(s);return s.dispose(),new Yc(l)}createWorldBrushFromMesh(e){const t=e.geometry;if(!t||!t.attributes?.position)return null;e.updateWorldMatrix(!0,!1);const i=t.clone();i.applyMatrix4(e.matrixWorld);const s=this.toCsgReadyGeometry(i);return i.dispose(),new Yc(s)}toCsgReadyGeometry(e){const t=e.index?e.toNonIndexed():e.clone();t.getAttribute("normal")||t.computeVertexNormals();const i=t.getAttribute("position");if(i&&!t.getAttribute("uv")){const r=new Float32Array(i.count*2);t.setAttribute("uv",new C.Float32BufferAttribute(r,2))}const s=new Set(["position","normal","uv"]);return Object.keys(t.attributes).forEach(r=>{s.has(r)||t.deleteAttribute(r)}),t}extractPlaneCapGeometry(e,t,i){const s=e.index?e.toNonIndexed():e.clone(),r=s.getAttribute("position");if(!r||r.count<3)return s.dispose(),null;const o=t.normal.clone().normalize(),a=new C.Vector3,l=new C.Vector3,c=new C.Vector3,h=new C.Vector3,d=new C.Vector3,f=new C.Vector3,u=new C.Vector3,g=new C.Vector3,p=new C.Vector3,m=Math.max(i*.35,1e-4),A=Math.max(i*.7,1e-4),x=[];for(let y=0;y<r.count;y+=3){if(h.fromBufferAttribute(r,y),d.fromBufferAttribute(r,y+1),f.fromBufferAttribute(r,y+2),l.subVectors(d,h),c.subVectors(f,h),a.crossVectors(l,c),a.lengthSq()<1e-14||(a.normalize(),Math.abs(a.dot(o))<.9))continue;const _=t.distanceToPoint(h),w=t.distanceToPoint(d),S=t.distanceToPoint(f),D=Math.min(_,w,S);if(Math.max(_,w,S)-D>m)continue;const I=(_+w+S)/3;Math.abs(I)>A||I<0||(u.copy(h).addScaledVector(o,-_),g.copy(d).addScaledVector(o,-w),p.copy(f).addScaledVector(o,-S),a.dot(o)<=0?(x.push(u.x,u.y,u.z),x.push(g.x,g.y,g.z),x.push(p.x,p.y,p.z)):(x.push(u.x,u.y,u.z),x.push(p.x,p.y,p.z),x.push(g.x,g.y,g.z)))}if(s.dispose(),x.length<9)return null;const b=new C.BufferGeometry;return b.setAttribute("position",new C.Float32BufferAttribute(x,3)),b.computeVertexNormals(),b}applyPlanarUv(e,t){const i=e.getAttribute("position");if(!i||i.count===0)return;const{tangent:s,bitangent:r}=this.getPlaneBasis(t.normal.clone().normalize()),o=new C.Vector3,a=new Float32Array(i.count*2);let l=1/0,c=-1/0,h=1/0,d=-1/0;for(let g=0;g<i.count;g++){o.fromBufferAttribute(i,g);const p=o.dot(s),m=o.dot(r),A=g*2;a[A]=p,a[A+1]=m,l=Math.min(l,p),c=Math.max(c,p),h=Math.min(h,m),d=Math.max(d,m)}const f=Math.max(c-l,1e-6),u=Math.max(d-h,1e-6);for(let g=0;g<a.length;g+=2)a[g]=(a[g]-l)/f*this.fillTextureRepeat,a[g+1]=(a[g+1]-h)/u*this.fillTextureRepeat;e.setAttribute("uv",new C.BufferAttribute(a,2))}getPlaneBasis(e){const t=new C.Vector3(1,0,0),i=new C.Vector3(0,1,0),s=new C.Vector3(0,0,1),r=Math.abs(e.dot(t)),o=Math.abs(e.dot(i)),a=Math.abs(e.dot(s));let l=t;o<=r&&o<=a?l=i:a<=r&&a<=o&&(l=s),l=l.clone().sub(e.clone().multiplyScalar(l.dot(e))).normalize();const c=new C.Vector3().crossVectors(e,l).normalize();return{tangent:l,bitangent:c}}}class _5{engine;clippingTolerance=1e-4;sectionBox;sectionFace;clippingStencil;clippingCSGSimple=null;currentClippingMode="";fillCutFace=!0;constructor(e){this.engine=e;let t=new C.Plane(new C.Vector3(0,0,1),1e5);t.name="前";let i=new C.Plane(new C.Vector3(0,0,1),1e5);i.name="左";let s=new C.Plane(new C.Vector3(0,0,1),1e5);s.name="后";let r=new C.Plane(new C.Vector3(0,0,1),1e5);r.name="右";let o=new C.Plane(new C.Vector3(0,0,1),1e5);o.name="顶";let a=new C.Plane(new C.Vector3(0,0,1),1e5);a.name="底";let l=new C.Plane(new C.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,i,s,r,o,a,l]}init(){this.sectionBox=new TI(this.engine),this.sectionFace=new DI(this.engine),this.clippingCSGSimple=new v5(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}setFillCutFace(e){this.fillCutFace=e}getFillCutFace(){return this.fillCutFace}clippingModel(e){let t=[];e.forEach(r=>{let o=this.engine.models.find(a=>a.url===r.url);r.ids.forEach(a=>{o.nodesMap.get(a).infos.forEach(l=>{t.push(l.box)})})}),this.active("box");let i=s(t);this.sectionBox.setBox(i);function s(r){let o=new C.Vector3(1e8,1e9,1e10),a=new C.Vector3(-1e8,-1e9,-1e10);return r.forEach(l=>{l.min.x<o.x&&(o.x=l.min.x),l.min.y<o.y&&(o.y=l.min.y),l.min.z<o.z&&(o.z=l.min.z),l.max.x>a.x&&(a.x=l.max.x),l.max.y>a.y&&(a.y=l.max.y),l.max.z>a.z&&(a.z=l.max.z)}),new C.Box3(o,a)}}updateClippingValue(e){let t=this.sectionBox.maxBox,i=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,s=t.min.y+(t.max.y-t.min.y)*e.y.min*.01,r=t.min.z+(t.max.z-t.min.z)*e.z.min*.01,o=t.min.x+(t.max.x-t.min.x)*e.x.max*.01,a=t.min.y+(t.max.y-t.min.y)*e.y.max*.01,l=t.min.z+(t.max.z-t.min.z)*e.z.max*.01;this.sectionBox.setboxXyz({minX:i,minY:s,minZ:r,maxX:o,maxY:a,maxZ:l})}active(e){if(this.engine.engineStatus.isForceFree=!0,this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=e,e=="x")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(Math.PI/2,0,0);else if(e=="y")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,Math.PI/2,0);else if(e=="z")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,0,Math.PI/2);else if(e=="box")this.sectionBox.init(),this.sectionBox.active();else if(e=="face"){let t=new BI(this.engine);t.init(),t.catch_face(i=>{this.sectionFace.init(),this.sectionFace.active();let s=this.engine.octreeBox.getBoundingBox(),r=s.min.clone().add(s.max.clone()).multiplyScalar(.5),o=i.position.clone().sub(r),a=new C.Vector3(i.dir.x,i.dir.y,i.dir.z),l=o.dot(a);this.sectionFace.setFaceNormal(i.dir,l)})}}disabled(){this.currentClippingMode=="box"?this.sectionBox.disabled():this.sectionFace.disabled(),this.engine.engineStatus.isForceFree=!1}recover(){this.currentClippingMode=="box"?this.sectionBox.recover():this.sectionFace.recover()}reverse(){this.sectionFace.reverse()}disActive(){this.sectionFace.disActive(),this.sectionBox.disActive(),this.clippingCSGSimple?.clear(),this.currentClippingMode="",this.engine.engineStatus.isForceFree=!1}isPointInClippingRange(e,t=this.clippingTolerance){if(!this.isVector3Like(e))return!1;const i=this.getEffectiveClippingPlanes();return i.length===0?!0:i.every(s=>s.distanceToPoint(e)>=-t)}filterIntersectionsByClipping(e,t=this.clippingTolerance){return!Array.isArray(e)||e.length===0?[]:e.filter(i=>this.isPointInClippingRange(i?.point,t))}getEffectiveClippingPlanes(){const e=Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:[];if(this.currentClippingMode==="box")return e.slice(0,6).filter(t=>t instanceof C.Plane);if(this.currentClippingMode==="x"||this.currentClippingMode==="y"||this.currentClippingMode==="z"||this.currentClippingMode==="face"){const t=e[6];return t instanceof C.Plane?[t]:[]}return[]}isVector3Like(e){return e!=null&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"}setSectionByView(e,t){this.sectionFace.disActive(),this.sectionBox.disActive(),this.scaleBox(),this.sectionFace.init(!0);const i=this.engine.octreeBox.getBoundingBox(),s=new C.Vector3((i.min.x+i.max.x)/2,(i.min.y+i.max.y)/2,(i.min.z+i.max.z)/2),o=new C.Vector3(t.x,t.y,t.z).normalize().clone().negate(),l=new C.Vector3(e.x,e.y,e.z).clone().sub(s).dot(o);this.sectionFace.setFaceNormalPlaneOnly(o,l),this.sectionFace.activateClippingOnly(),this.currentClippingMode="face"}}class C5{engine;constructor(e){this.engine=e}getLevelTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeLevel,name:t.info.baseInfo.name,url:t.url})}),e}getTypeTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeType,name:t.info.baseInfo.name,url:t.url})}),e}getMajorTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeMajor,name:t.info.baseInfo.name,url:t.url})}),e}}class w5{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,i=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(s=>{if(s instanceof C.Mesh){const r=s.geometry;if(r&&r.attributes){const o=r.attributes.position;if(o){const a=o.count;e+=a;let l=0;r.index?l=r.index.count/3:l=a/3,t+=l}}}}),this.engine.engineStatus.models.forEach(s=>{i=i+(Array.isArray(s?.info?.modelEdge)?s.info.modelEdge.length:0)}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:i})}}class S5{engine;extended‌=new Map;constructor(e){this.engine=e}init(){}updateExtended(e,t){let i=this.extended‌.get(e);i==null?this.extended‌.set(e,t):t.forEach((s,r)=>{i.set(r,s)})}getModelPropertiesWithName(e,t,i,s){let r=this.extended‌.get(e),o=this.engine.engineStatus.models.find(l=>l.url===e);o.properties==null?ha(e+"/property",l=>{let c=JSON.parse(l);o.properties=c,setTimeout(()=>{a(c,i,t,s)},100)},()=>{},o?.key):a(o.properties,i,t,s);function a(l,c,h,d){let f={};l.models[h.toString()||""].forEach(g=>{i.includes(l.names[g[1]])&&(f[l.names[g[1]]]=l.values[g[2]])}),r!=null&&r.has(h)&&f.push(r.get(h)),d?.({id:h,properties:f})}}getModelProperties(e,t,i){let s=this.extended‌.get(e),r=this.engine.engineStatus.models.find(a=>a.url===e);r.properties==null&&ha(e+"/property",a=>{let l=JSON.parse(a);r.properties=l,setTimeout(()=>{o(l,t,i)},100)},()=>{},r?.key),o(r.properties,t,i);function o(a,l,c){let h=[],d=a.models[l.toString()||""],f=d.map(u=>u[0]);f=f.filter((u,g)=>f.indexOf(u)===g),f.forEach(u=>{let g={name:a.categorys[u],children:[]};h.push(g),d.filter(p=>p[0]===u).forEach(p=>{g.children.push({name:a.names[p[1]],value:a.values[p[2]]})})}),s!=null&&s.has(l)&&h.push(s.get(l)),c?.({properties:h,materials:h})}}}class M5{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(s=>{e.push(s.typeName)})}),e=e.filter((t,i,s)=>s.indexOf(t)===i),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(s=>{e.push(s.majorName)})}),e=e.filter((t,i,s)=>s.indexOf(t)===i),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(s=>{e.push(s.levelName)})}),e=e.filter((t,i,s)=>s.indexOf(t)===i),e}getModelMappers(e){}getModelMapper(e,t){let i=this.engine.engineStatus.models.find(o=>o.url==e);return i?i.info.modelMapper.find(o=>o.id==t):null}getModelsWithLevelType(e,t,i=null){let s=[];return this.engine.engineStatus.models.forEach(r=>{let o={url:r.url,ids:[]};s.push(o),r.info.modelMapper.filter(l=>l.levelName===e&&l.typeName===t).forEach(l=>{o.ids.push(Number(l.id))})}),i&&i(s),s}getModelsWithType(e,t=null){let i=[];return this.engine.engineStatus.models.forEach(s=>{let r={url:s.url,ids:[]};i.push(r),s.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithLevel(e,t){let i=[];return this.engine.engineStatus.models.forEach(s=>{let r={url:s.url,ids:[]};i.push(r),s.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithMajor(e,t){let i=[];return this.engine.engineStatus.models.forEach(s=>{let r={url:s.url,ids:[]};i.push(r),s.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(i),i}}class E5{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,i=setTimeout(()=>t.abort(),this.config.timeout);try{const s=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!1}),signal:t.signal});if(clearTimeout(i),!s.ok){const o=await s.json().catch(()=>({}));throw new Error(`API请求失败 (${s.status}): ${o.error?.message||o.message||s.statusText}`)}return(await s.json()).choices?.[0]?.message?.content||""}catch(s){throw clearTimeout(i),s.name==="AbortError"?new Error("请求超时,请重试"):s.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
5260
+ }`};const gA={turbidity:10,rayleigh:3,mieCoefficient:.005,mieDirectionalG:.7,elevation:2,azimuth:180,exposure:.5,orthoExposureScale:1.5,cloudCoverage:.4,cloudDensity:.4,cloudElevation:.5,showSunDisc:!0},af="sunrise_clear",mA=.2,lf=[{id:"sunrise_clear",names:["晴朗日出","晴朗日出","Clear Sunrise"],params:{turbidity:4,rayleigh:1.8,mieCoefficient:.004,mieDirectionalG:.72,elevation:8,azimuth:105,exposure:.42,cloudCoverage:.12,cloudDensity:.2,cloudElevation:.45,showSunDisc:!0}},{id:"morning_mist",names:["晨雾薄云","晨雾薄云","Misty Morning"],params:{turbidity:14,rayleigh:2.4,mieCoefficient:.018,mieDirectionalG:.68,elevation:12,azimuth:120,exposure:.35,cloudCoverage:.45,cloudDensity:.5,cloudElevation:.35,showSunDisc:!0}},{id:"noon_clear",names:["晴空正午","晴空正午","Clear Noon"],params:{turbidity:2,rayleigh:1,mieCoefficient:.002,mieDirectionalG:.82,elevation:68,azimuth:180,exposure:.58,cloudCoverage:.05,cloudDensity:.12,cloudElevation:.55,showSunDisc:!0}},{id:"afternoon_cloudy",names:["午后多云","午后多云","Cloudy Afternoon"],params:{turbidity:8,rayleigh:1.7,mieCoefficient:.008,mieDirectionalG:.74,elevation:42,azimuth:220,exposure:.5,cloudCoverage:.48,cloudDensity:.42,cloudElevation:.52,showSunDisc:!0}},{id:"sunset_glow",names:["落日晚霞","落日晚霞","Sunset Glow"],params:{turbidity:10,rayleigh:2,mieCoefficient:.006,mieDirectionalG:.7,elevation:6,azimuth:245,exposure:.6,cloudCoverage:.3,cloudDensity:.36,cloudElevation:.5,showSunDisc:!0}},{id:"blue_hour",names:["暮色蓝调","暮色蓝调","Blue Hour"],params:{turbidity:7,rayleigh:1.2,mieCoefficient:.003,mieDirectionalG:.76,elevation:-4,azimuth:255,exposure:.22,cloudCoverage:.2,cloudDensity:.24,cloudElevation:.48,showSunDisc:!1}},{id:"overcast_day",names:["阴天白昼","阴天白昼","Overcast Day"],params:{turbidity:20,rayleigh:2,mieCoefficient:.02,mieDirectionalG:.6,elevation:32,azimuth:180,exposure:.38,cloudCoverage:.86,cloudDensity:.68,cloudElevation:.4,showSunDisc:!1}},{id:"storm_rain",names:["暴雨雷云","暴雨雷云","Storm Rain"],params:{turbidity:19,rayleigh:.9,mieCoefficient:.03,mieDirectionalG:.58,elevation:18,azimuth:210,exposure:.2,cloudCoverage:.95,cloudDensity:.9,cloudElevation:.28,showSunDisc:!1}},{id:"snow_day",names:["雪天漫射","雪天漫射","Snowy Day"],params:{turbidity:15,rayleigh:2.6,mieCoefficient:.012,mieDirectionalG:.65,elevation:24,azimuth:170,exposure:.5,cloudCoverage:.78,cloudDensity:.72,cloudElevation:.43,showSunDisc:!1}},{id:"moonlit_night",names:["月夜星空","月夜星空","Moonlit Night"],params:{turbidity:4,rayleigh:.35,mieCoefficient:.001,mieDirectionalG:.82,elevation:-18,azimuth:160,exposure:.14,cloudCoverage:.1,cloudDensity:.14,cloudElevation:.55,showSunDisc:!1}}],AA=lf.reduce((n,e)=>(n[e.id]=e,n),{}),xA=2e6;class xI{engine;sky=null;sun=new C.Vector3;params={...gA,...AA[af].params};currentPreset=af;currentIntensity=mA;currentEnvironmentTarget=null;skyScale=45e4;skyName="bim_engine_sky";savedCameraFar=null;previousBackground=null;previousEnvironment=null;previousBackgroundIntensity=1;previousEnvironmentIntensity=1;previousToneMapping=C.NoToneMapping;previousToneMappingExposure=1;hasCapturedSceneState=!1;constructor(e){this.engine=e}activate(){if(!this.engine?.scene)return;if(this.sky){this.sky.visible=!0,this._captureSceneState(),this._expandCameraFarForSky(),this._applyParamsToSky();return}const e=new Dc;e.scale.setScalar(this.skyScale),e.name=this.skyName,this.sky=e,this.engine.scene.add(e),this._captureSceneState(),this._expandCameraFarForSky(),this.engine.renderer&&(this.engine.renderer.toneMapping=C.ACESFilmicToneMapping,this.engine.scene.background=null),this._applyParamsToSky()}close(e=!0){this.sky&&(this._restoreCameraFar(),this._restoreSceneState(e),e?(this.engine?.scene?.remove(this.sky),this.sky.material.dispose(),this.sky.geometry.dispose(),this.sky=null):this.sky.visible=!1)}isActive(){return this.sky!=null&&this.engine?.scene?.children?.includes(this.sky)}getParams(){return{...this.params}}setParams(e){Object.assign(this.params,e),this._applyParamsToSky(),this.engine?.renderer&&(e.exposure!==void 0||e.orthoExposureScale!==void 0)&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure())}setPreset(e){const t=AA[e];t&&(this.currentPreset=e,this.params={...gA,...t.params},this._applyParamsToSky(),this.engine?.renderer&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure()))}getCurrentPreset(){return this.currentPreset}getPresetNames(){return lf.map(e=>e.id)}getPresetList(){return lf.map(e=>({id:e.id,names:[...e.names],params:{...e.params}}))}setIntensity(e){if(this.currentIntensity=Math.max(e,0),!(!this.sky?.visible||!this.engine?.scene)){if(!this.currentEnvironmentTarget){this._refreshEnvironmentMap();return}this.engine.scene.environmentIntensity=this.currentIntensity}}getIntensity(){return this.currentIntensity}update(e){if(!this.sky?.visible)return;const t=this.sky.material.uniforms;t&&"time"in t&&(t.time.value=e??performance.now()*.001),this.engine?.renderer&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure())}_isOrthographicCamera(){const e=this.engine?.camera;return e!=null&&e.type==="OrthographicCamera"}_getEffectiveExposure(){const e=this.params.exposure;return this._isOrthographicCamera()?e*this.params.orthoExposureScale:e}_expandCameraFarForSky(){const e=this.engine?.camera;if(!e||typeof e.far!="number")return;const t=e.far;t>=xA||(this.savedCameraFar==null&&(this.savedCameraFar=t),e.far=xA,typeof e.updateProjectionMatrix=="function"&&e.updateProjectionMatrix())}_restoreCameraFar(){if(this.savedCameraFar==null||!this.engine?.camera)return;const e=this.engine.camera;typeof e.far=="number"&&(e.far=this.savedCameraFar,typeof e.updateProjectionMatrix=="function"&&e.updateProjectionMatrix(),this.savedCameraFar=null)}_applyParamsToSky(){if(!this.sky)return;const e=this.sky.material.uniforms;this._setUniformValue(e,"turbidity",this.params.turbidity),this._setUniformValue(e,"rayleigh",this.params.rayleigh),this._setUniformValue(e,"mieCoefficient",this.params.mieCoefficient),this._setUniformValue(e,"mieDirectionalG",this.params.mieDirectionalG),this._setUniformValue(e,"cloudCoverage",this.params.cloudCoverage),this._setUniformValue(e,"cloudDensity",this.params.cloudDensity),this._setUniformValue(e,"cloudElevation",this.params.cloudElevation),this._setUniformValue(e,"showSunDisc",this.params.showSunDisc?1:0);const t=C.MathUtils.degToRad(90-this.params.elevation),i=C.MathUtils.degToRad(this.params.azimuth);this.sun.setFromSphericalCoords(1,t,i),this._setUniformValue(e,"sunPosition",this.sun),this.engine?.renderer&&(this.engine.renderer.toneMapping=C.ACESFilmicToneMapping,this.engine.renderer.toneMappingExposure=this._getEffectiveExposure(),this.sky.visible&&this._refreshEnvironmentMap())}_captureSceneState(){this.hasCapturedSceneState||!this.engine?.scene||(this.previousBackground=this.engine.scene.background,this.previousEnvironment=this.engine.scene.environment,this.previousBackgroundIntensity=this.engine.scene.backgroundIntensity??1,this.previousEnvironmentIntensity=this.engine.scene.environmentIntensity??1,this.previousToneMapping=this.engine.renderer?.toneMapping??C.NoToneMapping,this.previousToneMappingExposure=this.engine.renderer?.toneMappingExposure??1,this.hasCapturedSceneState=!0)}_restoreSceneState(e){!this.hasCapturedSceneState||!this.engine?.scene||(this.engine.scene.background=this.previousBackground,this.engine.scene.environment=this.previousEnvironment,this.engine.scene.backgroundIntensity=this.previousBackgroundIntensity,this.engine.scene.environmentIntensity=this.previousEnvironmentIntensity,this.engine.renderer&&(this.engine.renderer.toneMapping=this.previousToneMapping,this.engine.renderer.toneMappingExposure=this.previousToneMappingExposure),e&&(this._disposeEnvironmentTarget(),this.previousBackground=null,this.previousEnvironment=null,this.previousBackgroundIntensity=1,this.previousEnvironmentIntensity=1,this.previousToneMapping=C.NoToneMapping,this.previousToneMappingExposure=1,this.hasCapturedSceneState=!1))}_refreshEnvironmentMap(){if(!this.sky||!this.engine?.renderer||!this.engine?.scene)return;this._disposeEnvironmentTarget();const e=new C.Scene,t=this.sky.clone();t.material=this.sky.material.clone(),e.add(t);const i=new C.PMREMGenerator(this.engine.renderer);this.currentEnvironmentTarget=i.fromScene(e,0,.1,this.skyScale*2),i.dispose(),this.engine.scene.background=null,this.engine.scene.environment=this.currentEnvironmentTarget.texture,this.engine.scene.environmentIntensity=this.currentIntensity,t.material.dispose()}_disposeEnvironmentTarget(){this.currentEnvironmentTarget?.dispose(),this.currentEnvironmentTarget=null}_setUniformValue(e,t,i){const s=e[t];s&&(i instanceof C.Vector3&&typeof s.value?.copy=="function"?s.value.copy(i):s.value=i)}}class bI{engine;defaultSettings;settings;environmentApplyVersion=0;constructor(e){this.engine=e,this.defaultSettings=this._buildDefaultSettingsFromModules(),this.settings=this._clone(this.defaultSettings)}init(){this.defaultSettings=this._buildDefaultSettingsFromModules(),this.settings=this._clone(this.defaultSettings)}getSettings(){return this._syncSettingsFromModules(),this._clone(this.settings)}getPresetLists(){const e=this.engine.ground?.getGroundList()||[],t=this.engine.hdr?.getHdrList()||[],i=this.engine.skyManager?.getPresetList()||[];return{ground:e.map(s=>this._toPresetItem(s)),hdr:t.map(s=>this._toPresetItem(s)),sky:i.map(s=>this._toPresetItem(s))}}async setSettings(e){e.render&&(Object.assign(this.settings.render,e.render),this._applyRenderSettings(this.settings.render)),e.display&&(Object.assign(this.settings.display,e.display),this._applyDisplaySettings(this.settings.display)),e.environment&&(this._mergeEnvironmentSettings(e.environment),await this._applyEnvironmentSettings(this._clone(this.settings.environment)))}async resetToDefault(){this.settings=this._clone(this.defaultSettings),this._applyRenderSettings(this.settings.render),this._applyDisplaySettings(this.settings.display),await this._applyEnvironmentSettings(this._clone(this.settings.environment))}setRenderMode(e){this.settings.render.mode=e,this.engine.engineModelModule?.switchModel(e)}setContrast(e){this.settings.render.contrast=e,this.engine.engineModelModule?.setContrastValue(.5+e/100)}setSaturation(e){this.settings.render.saturation=e,this.engine.engineModelModule?.setSaturationValue(.5+e/100)}setShadowIntensity(e){this.settings.render.shadowIntensity=e,this._updateDirectionalLight(t=>{t.shadow.intensity=e/100*2})}setLightIntensity(e){this.settings.render.lightIntensity=e,this.setAmbientLightIntensity(e/100)}setGTAOIntensity(e){this.settings.render.gtaoIntensity=e,this.engine.engineModelModule?.setGTAOIntensity(e/100)}setShowEdge(e){this.settings.display.showEdge=e,e?this.engine.modelEdge?.active():this.engine.modelEdge?.disActive()}setEdgeOpacity(e){this.settings.display.edgeOpacity=e,this.engine.modelEdge?.setOpacity(e/100)}setShowGrid(e){this.settings.display.showGrid=e,e?this.engine.grid?.show():this.engine.grid?.hide()}setShowLevel(e){this.settings.display.showLevel=e,e?this.engine.level?.show():this.engine.level?.hide()}setShowGround(e){this.settings.display.showGround=e,e?this.engine.ground?.show():this.engine.ground?.hide()}setGroundId(e){this.settings.display.groundId=e,this.engine.ground?.setGround(e)}setGroundHeight(e){this.settings.display.groundHeight=e,this.engine.ground?.setHeight(e)}async setEnvironmentType(e){this.settings.environment.type=e,await this._applyEnvironmentSettings(this._clone(this.settings.environment))}async setHdrId(e){this.settings.environment.hdrId=e,this.settings.environment.type==="hdr"&&await this._applyEnvironmentSettings(this._clone(this.settings.environment))}setHdrIntensity(e){this.settings.environment.hdrIntensity=e,this.settings.environment.type==="hdr"&&this.engine.hdr?.setIntensity(e/100)}setSkyPreset(e){this.settings.environment.skyPreset=e,this.settings.environment.skyParams={},this.settings.environment.type==="sky"&&this.engine.skyManager?.setPreset(e)}setSkyParams(e){this.settings.environment.skyParams=this._clone(e),this.settings.environment.type==="sky"&&this.engine.skyManager?.setParams(this.settings.environment.skyParams)}setSkyIntensity(e){this.settings.environment.skyIntensity=e,this.settings.environment.type==="sky"&&this.engine.skyManager?.setIntensity(e/100)}setAmbientLightIntensity(e){this.engine.renderer.toneMappingExposure=2*e}_syncSettingsFromModules(){this.settings=this._readCurrentSettingsFromModules()}_buildDefaultSettingsFromModules(){const e=this.engine.composerModule?.saturationPass?.uniforms?.saturation?.value,t=this.engine.composerModule?.saturationPass?.uniforms?.contrast?.value,i=this.engine.composerModule?.gtaoPass?.blendIntensity,s=this.engine.renderer?.toneMappingExposure,r=this.engine.modelEdge?.getOpacity?.(),o=this.engine.hdr?.getCurrentHdrId?.()??Cn,a=this.engine.hdr?.getIntensity?.(),l=this.engine.skyManager?.getIntensity?.(),c=this.engine.skyManager?.getCurrentPreset?.()??af,h=this.engine.skyManager?.isActive?.()===!0;return{render:{mode:this._toRenderMode(this.engine.engineModelModule?.getCurrentMode?.()),contrast:this._uniformToPercent(t,Vg),saturation:this._uniformToPercent(e,Gg),shadowIntensity:this._shadowToPercent(this._getDirectionalLightShadowIntensity(),_c),lightIntensity:this._exposureToPercent(s,Pg),gtaoIntensity:this._unitToPercent(i,zg)},display:{showEdge:this.engine.modelEdge?.isEnabled?.()??of,edgeOpacity:this._unitToPercent(r,pA),showGrid:this.engine.grid?.getVisible?.()??sf,showLevel:this.engine.level?.getVisible?.()??fA,showGround:this.engine.ground?.getVisible?.()??dA,groundId:this.engine.ground?.getCurrentId?.()??cA,groundHeight:this.engine.ground?.getHeight?.()??hA},environment:{type:h?"sky":o!==Cn?"hdr":"none",hdrId:o,hdrIntensity:this._unitToPercent(a,uA),skyPreset:c,skyParams:{},skyIntensity:this._unitToPercent(l,mA)}}}_readCurrentSettingsFromModules(){const e=this.engine.composerModule?.saturationPass?.uniforms?.saturation?.value,t=this.engine.composerModule?.saturationPass?.uniforms?.contrast?.value,i=this.engine.composerModule?.gtaoPass?.blendIntensity,s=this.engine.renderer?.toneMappingExposure,r=this.engine.modelEdge?.getOpacity?.(),o=this.engine.hdr?.getCurrentHdrId?.()??this.settings.environment.hdrId,a=this.engine.hdr?.getIntensity?.(),l=this.engine.skyManager?.getIntensity?.(),c=this.engine.skyManager?.getCurrentPreset?.()??this.settings.environment.skyPreset,h=this.engine.skyManager?.getParams?.(),d=this.engine.skyManager?.isActive?.()===!0;return{render:{mode:this._toRenderMode(this.engine.engineModelModule?.getCurrentMode?.()??this.settings.render.mode),contrast:this._uniformToPercent(t,this.settings.render.contrast/100+.5),saturation:this._uniformToPercent(e,this.settings.render.saturation/100+.5),shadowIntensity:this._shadowToPercent(this._getDirectionalLightShadowIntensity(),this.settings.render.shadowIntensity/50),lightIntensity:this._exposureToPercent(s,this.settings.render.lightIntensity/50),gtaoIntensity:this._unitToPercent(i,this.settings.render.gtaoIntensity/100)},display:{showEdge:this.engine.modelEdge?.isEnabled?.()??this.settings.display.showEdge,edgeOpacity:this._unitToPercent(r,this.settings.display.edgeOpacity/100),showGrid:this.engine.grid?.getVisible?.()??this.settings.display.showGrid,showLevel:this.engine.level?.getVisible?.()??this.settings.display.showLevel,showGround:this.engine.ground?.getVisible?.()??this.settings.display.showGround,groundId:this.engine.ground?.getCurrentId?.()??this.settings.display.groundId,groundHeight:this.engine.ground?.getHeight?.()??this.settings.display.groundHeight},environment:{type:d?"sky":o!==Cn?"hdr":"none",hdrId:o,hdrIntensity:this._unitToPercent(a,this.settings.environment.hdrIntensity/100),skyPreset:c,skyParams:h?this._clone(h):this._clone(this.settings.environment.skyParams),skyIntensity:this._unitToPercent(l,this.settings.environment.skyIntensity/100)}}}_toRenderMode(e){return e==="simple"||e==="balance"||e==="advanced"?e:q2}_uniformToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent((i-.5)*100)}_shadowToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent(i*50)}_exposureToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent(i*50)}_unitToPercent(e,t){const i=typeof e=="number"?e:t;return this._clampPercent(i*100)}_clampPercent(e){return Math.min(100,Math.max(0,Math.round(e)))}_getDirectionalLightShadowIntensity(){const e=this.engine.scene?.children?.filter(i=>i instanceof C.DirectionalLight);return!e||e.length===0?_c:(e.find(i=>i.castShadow)??e[0]).shadow?.intensity??_c}_applyRenderSettings(e){this.setRenderMode(e.mode),this.setContrast(e.contrast),this.setSaturation(e.saturation),this.setShadowIntensity(e.shadowIntensity),this.setLightIntensity(e.lightIntensity),this.setGTAOIntensity(e.gtaoIntensity)}_applyDisplaySettings(e){this.setShowEdge(e.showEdge),this.setEdgeOpacity(e.edgeOpacity),this.setShowGrid(e.showGrid),this.setShowLevel(e.showLevel),this.setShowGround(e.showGround),this.setGroundId(e.groundId),this.setGroundHeight(e.groundHeight)}async _applyEnvironmentSettings(e){const t=++this.environmentApplyVersion;if(await this.engine.hdr?.setHdr(Cn),t===this.environmentApplyVersion&&(this.engine.skyManager?.close(!0),t===this.environmentApplyVersion))switch(e.type){case"none":break;case"hdr":if(e.hdrId!==Cn){if(await this.engine.hdr?.setHdr(e.hdrId),t!==this.environmentApplyVersion){this._applyEnvironmentSettings(this._clone(this.settings.environment));return}this.engine.hdr?.setIntensity(e.hdrIntensity/100)}break;case"sky":this.engine.skyManager?.activate(),this.engine.skyManager?.setPreset(e.skyPreset),Object.keys(e.skyParams).length>0&&this.engine.skyManager?.setParams(this._clone(e.skyParams)),this.engine.skyManager?.setIntensity(e.skyIntensity/100);break}}_updateDirectionalLight(e){const t=this.engine.scene?.children.find(i=>i instanceof C.DirectionalLight);t&&e(t)}_mergeEnvironmentSettings(e){Object.assign(this.settings.environment,e),e.skyPreset!==void 0&&e.skyParams===void 0&&(this.settings.environment.skyParams={}),e.skyParams!==void 0&&(this.settings.environment.skyParams=this._clone(e.skyParams))}_toPresetItem(e){const t=Array.isArray(e.names)?[...e.names]:[];return{id:e.id,name:t[0]??e.id,names:t}}_clone(e){return JSON.parse(JSON.stringify(e))}}function Kn(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var e=Math.random()*16|0,t=n=="x"?e:e&3|8;return t.toString(16)})}class $n{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=_u(e),this.handelBehaved.init(this,null),this.setting={unit:"m",precision:3}}getSetting(){return this.setting}saveSetting(e){this.setting=e}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}getMeasureText(e,t){if(e==null)return null;let i=this.setting.unit,s=i;return t==1?i=="mm"?e=e*1e3:i=="cm"?e=e*100:i=="dm"?e=e*10:i=="m"?e=e*1:i=="km"&&(e=e*.001):t==2&&(i=="mm"?e=e*1e3*1e3:i=="cm"?e=e*100*100:i=="dm"?e=e*10*10:i=="m"?e=e*1*1:i=="km"&&(e=e*.001*.001),s=s+"²"),e.toFixed(this.setting.precision)+" "+s}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(i=>{i.highlight==!0&&(i.highlight=!1,i.container.classList.remove("Hight"),i.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let i=e[t].length-1;i>=0;i--){let s=e[t][i];s.isSelect==!0&&(s.container.remove(),e[t].splice(i,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let i=e[t].length-1;i>=0;i--){let s=e[t][i];s.highlight==!0&&(s.container.remove(),e[t].splice(i,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(i=>{i.highlight=!1,i.container.classList.remove("Hight"),i.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(g=>{u(g)}),this.engine.measure.annotationData.elevationAnnotation.forEach(g=>{f(g)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(g=>{d(g)}),this.engine.measure.annotationData.angleAnnotation.forEach(g=>{l(g)}),this.engine.measure.annotationData.areaAnnotation.forEach(g=>{c(g)}),this.engine.measure.annotationData.slopeAnnotation.forEach(g=>{h(g)});function l(g){if(g.container==null){let S=['<svg class="measureSvg">','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel">'+g.text+"</text>","</svg>"].join("");g.container=document.createElement("div"),g.container.className="angle-annotation",g.container.id=g.id,g.container.style.pointerEvents="none",g.container.innerHTML=S,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}let p=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point1),m=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point2),A=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point3),x=e.engine.reactBoundingClientRect.left,b=e.engine.reactBoundingClientRect.top;p.x+=x,p.y+=b,m.x+=x,m.y+=b,A.x+=x,A.y+=b;let y=g.container;y.getElementsByTagName("circle")[0].setAttribute("cx",p.x),y.getElementsByTagName("circle")[0].setAttribute("cy",p.y),y.getElementsByTagName("circle")[1].setAttribute("cx",m.x),y.getElementsByTagName("circle")[1].setAttribute("cy",m.y),y.getElementsByTagName("circle")[2].setAttribute("cx",A.x),y.getElementsByTagName("circle")[2].setAttribute("cy",A.y),y.getElementsByTagName("polyline")[0].setAttribute("points",p.x+","+p.y+" "+m.x+","+m.y),y.getElementsByTagName("polyline")[1].setAttribute("points",m.x+","+m.y+" "+A.x+","+A.y);let _=m.x,w=m.y-30;y.getElementsByTagName("rect")[0].setAttribute("x",_-40),y.getElementsByTagName("rect")[0].setAttribute("y",w-12.5),y.getElementsByTagName("text")[0].setAttribute("x",_),y.getElementsByTagName("text")[0].setAttribute("y",w+4),y.getElementsByTagName("text")[0].innerHTML=g.text,y.style.top="0px",y.style.left="0px"}function c(g){if(g.container==null){let D=['<svg class="measureSvg">','<polygon fill="rgba(0, 0, 255, 0.1)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>','<polyline class="measureLine" stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel"> '+e.getMeasureText(g.text,2)+"</text>","</svg>"].join("");g.container=document.createElement("div"),g.container.className="area-annotation",g.container.id=g.id,g.container.innerHTML=D,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}if(!g.points||g.points.length<3)return;let p=e.engine.reactBoundingClientRect.left,m=e.engine.reactBoundingClientRect.top,A=[],x=0,b=0;for(let D=0;D<g.points.length;D++){let M=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.points[D]);M.x+=p,M.y+=m,A.push(M),x+=M.x,b+=M.y}x=x/A.length,b=b/A.length;let y=A.map(D=>D.x+","+D.y).join(" "),_=g.container;_.getElementsByTagName("polygon")[0].setAttribute("points",y),_.getElementsByTagName("polyline")[0].setAttribute("points",y);let w=x,S=b;_.getElementsByTagName("rect")[0].setAttribute("x",w-40),_.getElementsByTagName("rect")[0].setAttribute("y",S-12.5),_.getElementsByTagName("text")[0].setAttribute("x",w+10),_.getElementsByTagName("text")[0].setAttribute("y",S+4),_.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(g.text,2),_.style.top="0px",_.style.left="0px"}function h(g){if(g.container==null){let w=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+g.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path class="measureLine" d="M0,0 L0,6 L9,3 z"/>',"</marker>","</defs>",'<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-'+g.id+')" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel"> '+g.text+"</text>","</svg>"].join("");g.container=document.createElement("div"),g.container.className="slope-annotation",g.container.id=g.id,g.container.innerHTML=w,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}let p=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point1),m=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point2),A=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;p.x+=A,p.y+=x,m.x+=A,m.y+=x;let b=g.container;b.getElementsByTagName("polyline")[0].setAttribute("points",p.x+","+p.y+" "+m.x+","+m.y);let y=(p.x+m.x)/2,_=(p.y+m.y)/2-30;b.getElementsByTagName("rect")[0].setAttribute("x",y-50),b.getElementsByTagName("rect")[0].setAttribute("y",_-12.5),b.getElementsByTagName("text")[0].setAttribute("x",y),b.getElementsByTagName("text")[0].setAttribute("y",_+4),b.getElementsByTagName("text")[0].innerHTML=g.text,b.style.top="0px",b.style.left="0px"}function d(g){if(g.container==null){let S=['<svg class="measureSvg">','<circle class="measurePointer" cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="50" y="-11" text-anchor="middle" class="measureLabel"> X: '+e.getMeasureText(g.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="50" y="25" text-anchor="middle" class="measureLabel"> Y: '+e.getMeasureText(-g.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="50" y="51" text-anchor="middle" class="measureLabel"> Z: '+e.getMeasureText(g.textY,1)+"</text>","</svg>"].join("");g.container=document.createElement("div"),g.container.className="coordinate-annotation",g.container.id=g.id,g.container.style.position="absolute",g.container.style.pointerEvents="none",g.container.innerHTML=S,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}let p=g.container,m=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point),A=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;m.x+=A,m.y+=x,p.style.top="0px",p.style.left="0px";let b=p.getElementsByTagName("circle")[0];b&&(b.setAttribute("cx",m.x),b.setAttribute("cy",m.y));let y=p.getElementsByTagName("rect"),_=p.getElementsByTagName("text"),w=-55;y[0]&&(y[0].setAttribute("x",m.x+10),y[0].setAttribute("y",m.y+10+w)),_[0]&&(_[0].setAttribute("x",m.x+10+50),_[0].setAttribute("y",m.y+10+16+w)),y[1]&&(y[1].setAttribute("x",m.x+10),y[1].setAttribute("y",m.y+10+30+w)),_[1]&&(_[1].setAttribute("x",m.x+10+50),_[1].setAttribute("y",m.y+10+46+w)),y[2]&&(y[2].setAttribute("x",m.x+10),y[2].setAttribute("y",m.y+10+60+w)),_[2]&&(_[2].setAttribute("x",m.x+10+50),_[2].setAttribute("y",m.y+10+76+w)),_[0]&&(_[0].innerHTML="X: "+e.getMeasureText(g.textX,1)),_[1]&&(_[1].innerHTML="Y: "+e.getMeasureText(-g.textZ,1)),_[2]&&(_[2].innerHTML="Z: "+e.getMeasureText(g.textY,1))}function f(g){if(g.container==null){let b=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel"> '+e.getMeasureText(g.text,1)+"</text>",'<polyline class="measureLine" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");g.container=document.createElement("div"),g.container.className="elevation-annotation",g.container.id=g.id,g.container.style.position="absolute",g.container.style.pointerEvents="none",g.container.innerHTML=b,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}let p=g.container,m=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point),A=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;p.style.top=m.y+x-48+"px",p.style.left=m.x+A-16+"px",p.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(g.text,1)}function u(g){if(g.container==null){let y=['<svg class="measureSvg">','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline class="measureLine" stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel"> '+e.getMeasureText(g.text,1)+"</text>","</svg>"].join("");g.container=document.createElement("div"),g.container.className="normal-annotation",g.container.id=g.id,g.container.innerHTML=y,e.engine.measure.annotationContainer.appendChild(g.container),g.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0,e.engine.events.trigger(Mt.MeasureClick,g)}),g.isSelect&&(g.container.getElementsByTagName("svg")[0].classList.add("Hight"),g.highlight=!0)}let p=g.container;if(g.point1==null||g.point2==null){p.style.display="none";return}else p.style.display="block";let m=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point1),A=new lt(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(g.point2),x=e.engine.reactBoundingClientRect.left,b=e.engine.reactBoundingClientRect.top;m.x+=x,m.y+=b,A.x+=x,A.y+=b,p.getElementsByTagName("polyline")[0].setAttribute("points",m.x+","+m.y+" "+A.x+","+A.y),p.getElementsByTagName("circle")[0].setAttribute("cx",m.x),p.getElementsByTagName("circle")[0].setAttribute("cy",m.y),p.getElementsByTagName("circle")[1].setAttribute("cx",A.x),p.getElementsByTagName("circle")[1].setAttribute("cy",A.y),p.getElementsByTagName("rect")[0].setAttribute("x",m.x*.5+A.x*.5-40),p.getElementsByTagName("rect")[0].setAttribute("y",m.y*.5+A.y*.5-12.5),p.getElementsByTagName("text")[0].setAttribute("x",m.x*.5+A.x*.5+50-40),p.getElementsByTagName("text")[0].setAttribute("y",m.y*.5+A.y*.5+16-12.5),p.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(g.text,1),p.style.top="0px",p.style.left="0px"}}}class yI{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}setDirection(e){this.catchDir=e}setSelectType(e){this.type=e}getMeshesMinMaxY(e){if(!Array.isArray(e)||e.length===0)return null;let t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(let s=0;s<e.length;s++){const r=e[s];if(!r)continue;typeof r.updateMatrixWorld=="function"&&r.updateMatrixWorld(!0);const o=new C.Box3().setFromObject(r);!Number.isFinite(o.min.y)||!Number.isFinite(o.max.y)||(o.min.y<t&&(t=o.min.y),o.max.y>i&&(i=o.max.y))}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minY:t,maxY:i}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let r=this.engine.interactionModule.getCatchMeshs(e);var i=this.getMeshesMinMaxY(r);this.catchDir==0?t.set(t.x,i?.minY,t.z):t.set(t.x,i?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(t);return}let s=this.engine.measure.annotationData.normalAnnotation.find(r=>r.isSelect==!0);s!=null&&(s.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);t==null&&(t={text:null,id:Kn(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let i=e.catch;if(this.type=="element"){let s=e.catch.point.clone();s.set(s.x,this.points[0].y,s.z);let r=new C.Raycaster(s.add(new C.Vector3(0,.01,0)),new C.Vector3(0,this.catchDir==0?-1:1,0));i.point=this.points[0];const o=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(r))??this.engine.octreeBox.rayInterationModel(r);if(o.length===0){t.point2=null;return}t.point1=s,t.point2=o[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Mt.MeasureChanged,t)}else{let s=new C.Raycaster(e.catch.point.clone().add(new C.Vector3(0,.01,0)),new C.Vector3(0,this.catchDir==0?-1:1,0));const r=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(s))??this.engine.octreeBox.rayInterationModel(s);if(r.length===0){t.point2=null;return}t.point1=i.point,t.point2=r[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Mt.MeasureChanged,t)}}}class vI{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.isActive=!1,this.engine.handelBehaved.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1){let i=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);if(i==null)return;i.point2=t.point,i.isSelect=!1,this.points=[],this.engine.events.trigger(Mt.MeasureChanged,i)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let i=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);i==null&&(i={id:Kn(),point1:this.points[0].clone(),point2:t.point.clone(),text:this.points[0].clone().distanceTo(t.point.clone()),type:"distance",isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(i)),i.point2=t.point,i.text=i.point1.clone().distanceTo(i.point2.clone())}}}class _I{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(o=>o.isSelect==!0);t==null&&(t={text:null,id:Kn(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let i=new C.Raycaster(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.normal);const s=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(i))??this.engine.octreeBox.rayInterationModel(i);if(s.length==0){t.point2=null;return}let r=e.catch;t.point1=r.point,t.point2=s[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Mt.MeasureChanged,t)}}class CI{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(i=>i.isSelect==!0);t==null&&(t={id:Kn(),point:e.catch.point.clone(),text:e.catch.point.y,isSelect:!0,type:"elevation"},this.engine.measure.annotationData.elevationAnnotation.push(t)),t.point=e.catch.point.clone(),t.text=e.catch.point.y}handleMouseClick(e){if(e.catch==null)return;this.engine.measure.tools.clearHighlight();let t=this.engine.measure.annotationData.elevationAnnotation.find(i=>i.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(Mt.MeasureChanged,t))}}class wI{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseUp(e){this.engine.deviceType!="PC"&&this.createMeasure()}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(i=>i.isSelect==!0);t!=null&&(t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z)}handleMouseClick(e){if(e.catch==null)return;this.engine.measure.tools.clearHighlight();let t=this.engine.measure.annotationData.coordinateAnnotation.find(i=>i.isSelect==!0);if(t==null){t={id:Kn(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t);return}t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,t.isSelect=!1,this.engine.events.trigger(Mt.MeasureChanged,t)}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(Mt.MeasureChanged,e))}}class SI{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,i){const s=new C.Vector3().subVectors(e,t),r=new C.Vector3().subVectors(i,t),o=s.length(),a=r.length();if(o===0||a===0)return 0;const c=s.dot(r)/(o*a),h=Math.max(-1,Math.min(1,c));return Math.acos(h)*(180/Math.PI)}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1)this.points.push(t.point);else if(this.points.length==2){let i=this.engine.measure.annotationData.angleAnnotation.find(s=>s.isSelect==!0);if(i==null)return;i.point3=t.point.clone(),i.angle=this.calculateAngle(i.point1,i.point2,i.point3),i.text=i.angle.toFixed(2)+"°",i.isSelect=!1,i.type="angle",this.points=[],this.engine.events.trigger(Mt.MeasureChanged,i)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);t==null&&(t={id:Kn(),point1:this.points[0].clone(),point2:this.points[1].clone(),point3:e.catch.point.clone(),angle:0,text:"0.00°",isSelect:!0,type:"angle"},this.engine.measure.annotationData.angleAnnotation.push(t)),t.point3=e.catch.point.clone(),t.angle=this.calculateAngle(t.point1,t.point2,t.point3),t.text=t.angle.toFixed(2)+"°",console.log("角度",t.text)}}}class MI{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateArea(e){if(e.length<3)return 0;const t=e.length,i=new C.Vector3(0,0,0);for(let s=0;s<t;s++){const r=(s+1)%t;i.x+=(e[s].y-e[r].y)*(e[s].z+e[r].z),i.y+=(e[s].z-e[r].z)*(e[s].x+e[r].x),i.z+=(e[s].x-e[r].x)*(e[s].y+e[r].y)}return i.length()/2}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.push(t.point.clone()),this.points.length>=3){let i=this.engine.measure.annotationData.areaAnnotation.find(s=>s.isSelect==!0);i==null?(i={id:Kn(),points:this.points.map(s=>s.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(i)):(this.points.push(t.point.clone()),i.points=this.points.map(s=>s.clone())),i.area=this.calculateArea(i.points),i.text=i.area,console.log("面积",i.text)}else this.engine.measure.tools.clearHighlight()}handleMouseMove(e){if(e.catch!=null&&this.points.length>=2){let t=this.engine.measure.annotationData.areaAnnotation.find(i=>i.isSelect==!0);if(t==null){if(this.points.length>=2){let i=this.points.map(s=>s.clone());i.push(e.catch.point.clone()),i.length>=3&&(t={id:Kn(),points:i,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const i=t.points.length-1;t.points[i]=e.catch.point.clone()}else t.points=this.points.map(i=>i.clone()),t.points.push(e.catch.point.clone());t&&t.points.length>=3&&(t.area=this.calculateArea(t.points),t.text=t.area)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){this.points=this.points.slice(0,this.points.length-1);let e=this.engine.measure.annotationData.areaAnnotation.find(t=>t.isSelect==!0);e!=null&&e.points.length>=3&&(e.points.length>this.points.length&&(e.points=this.points.map(t=>t.clone())),e.area=this.calculateArea(e.points),e.text=e.area,e.isSelect=!1,this.points=[],this.engine.events.trigger(Mt.MeasureChanged,e))}}class EI{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new $n(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateSlope(e,t){const i=t.y-e.y,s=t.x-e.x,r=t.z-e.z,o=Math.sqrt(s*s+r*r);if(o===0)return{percentage:0,angle:0,heightDiff:i,horizontalDist:0,type:"slope"};const a=i/o*100,c=Math.atan(i/o)*(180/Math.PI);return{percentage:a,angle:c,heightDiff:i,horizontalDist:o,type:"slope"}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1){let i=this.engine.measure.annotationData.slopeAnnotation.find(r=>r.isSelect==!0);if(i==null)return;console.log("进来了"),i.point2=t.point.clone();const s=this.calculateSlope(i.point1,i.point2);i.slopePercentage=s.percentage,i.slopeAngle=s.angle,i.heightDiff=s.heightDiff,i.horizontalDist=s.horizontalDist,i.text=s.percentage.toFixed(2)+"% ("+s.angle.toFixed(2)+"°)",i.isSelect=!1,this.points=[],this.engine.events.trigger(Mt.MeasureChanged,i)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let i=this.engine.measure.annotationData.slopeAnnotation.find(r=>r.isSelect==!0);i==null&&(i={id:Kn(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0,type:"slope"},this.engine.measure.annotationData.slopeAnnotation.push(i)),i.point2=t.point.clone();const s=this.calculateSlope(i.point1,i.point2);i.slopePercentage=s.percentage,i.slopeAngle=s.angle,i.heightDiff=s.heightDiff,i.horizontalDist=s.horizontalDist,i.text=s.percentage.toFixed(2)+"% ("+s.angle.toFixed(2)+"°)"}}}class II{isActive=!1;engine;clearHeightMeasure;distanceMeasure;clearDistanceMeasure;elevationMeasure;pointMeasure;angleMeasure;areaMeasure;slopeMeasure;tools;annotationContainer;annotationData={normalAnnotation:[],textAnnotation:[],coordinateAnnotation:[],angleAnnotation:[],distanceAnnotation:[],areaAnnotation:[],slopeAnnotation:[],elevationAnnotation:[],volumeAnnotation:[]};constructor(e){this.engine=e,this.clearHeightMeasure=new yI(e),this.distanceMeasure=new vI(e),this.clearDistanceMeasure=new _I(e),this.elevationMeasure=new CI(e),this.pointMeasure=new wI(e),this.angleMeasure=new SI(e),this.areaMeasure=new MI(e),this.slopeMeasure=new EI(e),this.tools=new $n(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.engine.modelEdge.loadModelEdge(),this.tools.active()}disActive(){this.tools.disActive(),this.clearAll(),this.isActive=!1,this.clearHeightMeasure.disActive(),this.distanceMeasure.disActive(),this.clearDistanceMeasure.disActive(),this.elevationMeasure.disActive(),this.pointMeasure.disActive(),this.angleMeasure.disActive(),this.areaMeasure.disActive(),this.slopeMeasure.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active()}clearAllPoints(){this.clearHeightMeasure.clearAllPoints(),this.distanceMeasure.clearAllPoints(),this.clearDistanceMeasure.clearAllPoints(),this.elevationMeasure.clearAllPoints(),this.pointMeasure.clearAllPoints(),this.angleMeasure.clearAllPoints(),this.areaMeasure.clearAllPoints(),this.slopeMeasure.clearAllPoints()}clearAll(){e(this.annotationData.normalAnnotation),e(this.annotationData.textAnnotation),e(this.annotationData.coordinateAnnotation),e(this.annotationData.angleAnnotation),e(this.annotationData.distanceAnnotation),e(this.annotationData.areaAnnotation),e(this.annotationData.slopeAnnotation),e(this.annotationData.elevationAnnotation),e(this.annotationData.volumeAnnotation);function e(t){for(let i=0;i<t.length;i++)t[i].container.remove();t=[]}}saveSetting(e){this.tools.saveSetting(e)}getSetting(){return this.tools.getSetting()}update(){this.isActive&&this.tools.drawNormalAnnotation()}}class TI{engine;isActive=!1;isCtrlDown=!1;listenersAttached=!1;box;pickPoint;pickNormal;pickMesh;box_;plane;meshs;isDrag=!1;maxBox;faceIdleOpacity=0;faceHoverOpacity=.05;transformControls=new Map;transformAnchors=new Map;transformHelpers=new Map;faceMetaMap=new Map;isSyncingTransform=!1;transformHandleSize=1.05;transformHandleColor=16777215;transformHandleHoverColor=16776960;handleNativeMouseDown=e=>{if(e.button!==0||!(this.isCtrlDown||e.ctrlKey))return;const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);i.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:i}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:i})};handleNativeMouseUp=e=>{e.button!==0||!this.isDrag||(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseUp({button:e.button}))};handleNativeKeyDown=e=>{e.key==="Control"&&(this.isCtrlDown=!0)};handleNativeKeyUp=e=>{e.key==="Control"&&(this.isCtrlDown=!1,this.isDrag&&this.handleMouseUp({button:0}),this.resetMeshOpacity())};constructor(e,t){this.engine=e,this.meshs=[]}active(){this.isActive||(this.attachListeners(),this.init(),this.setTransformControlsVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}disActive(){this.init(!1),this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0},!1),this.setTransformControlsVisible(!1),this.clearClippingBoxFill(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}disabled(){this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0},!1),this.setTransformControlsVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}recover(){this.isActive||(this.attachListeners(),this.setTransformControlsVisible(!0),this.updateClippingBoxFill(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}init(e=!0){const t=this.engine.octreeBox.getBoundingBox();t.min.x-=.1,t.min.y-=.1,t.min.z-=.1,t.max.x+=.1,t.max.y+=.1,t.max.z+=.1,this.maxBox=JSON.parse(JSON.stringify(t)),this.box=t,this.updata_face(t),e&&this.updateClippingBoxFill()}getboxXyz(){return{minX:this.box.min.x,minY:this.box.min.y,minZ:this.box.min.z,maxX:this.box.max.x,maxY:this.box.max.y,maxZ:this.box.max.z}}setboxXyz(e){this.box.min.x=e.minX,this.box.min.y=e.minY,this.box.min.z=e.minZ,this.box.max.x=e.maxX,this.box.max.y=e.maxY,this.box.max.z=e.maxZ,this.updata_face(this.box),this.updateClippingBoxFill()}setBox(e){this.box=e,this.updata_face(e),this.updateClippingBoxFill()}reverseBox(){}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){this.clearClippingBoxFill();const i=t[0];this.isDrag=!0,this.pickPoint=i.point.clone(),this.pickMesh=i.object;const s=this.pickMesh?.userData?.dragNormal?.clone?.(),r=i.face?.normal?.clone?.();if(this.pickNormal=(s??r??new C.Vector3(0,0,1)).clone().normalize(),this.engine.controls.enabled=!1,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.pickNormal.y==0){const o=new C.Plane;o.setFromNormalAndCoplanarPoint(new C.Vector3(0,1,0),this.pickPoint),this.plane=o}else{const o=new C.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z),a=new C.Plane;a.setFromNormalAndCoplanarPoint(o.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=a}}else this.isDrag=!1}handleMouseUp(e,t=!0){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.plane=null,this.engine.controls.enabled=!0,t&&this.updateClippingBoxFill()}clampVector3(e,t,i){return new C.Vector3(Math.max(t.x,Math.min(i.x,e.x)),Math.max(t.y,Math.min(i.y,e.y)),Math.max(t.z,Math.min(i.z,e.z)))}handleMouseMove(e){this.resetMeshOpacity();const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=this.faceHoverOpacity),this.pickPoint!=null){const i=new C.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,i)){const s=i.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());if(!!this.pickMesh?.userData?.isMinFace){const o=this.box_.min.clone().add(this.pickNormal.clone().setLength(s));this.box.min=this.clampVector3(o,this.maxBox.min,this.box.max)}else{const o=this.box_.max.clone().add(this.pickNormal.clone().setLength(s));this.box.max=this.clampVector3(o,this.box.min,this.maxBox.max)}this.updata_face(this.box),this.calculate_ratio()}}}calculate_ratio(){const e=this.maxBox.max.x-this.maxBox.min.x,t=this.maxBox.max.y-this.maxBox.min.y,i=this.maxBox.max.z-this.maxBox.min.z,s=this.toPercent((this.box.min.x-this.maxBox.min.x)/e*100),r=this.toPercent((this.box.max.x-this.maxBox.min.x)/e*100),o=this.toPercent((this.box.min.y-this.maxBox.min.y)/t*100),a=this.toPercent((this.box.max.y-this.maxBox.min.y)/t*100),l=this.toPercent((this.box.min.z-this.maxBox.min.z)/i*100),c=this.toPercent((this.box.max.z-this.maxBox.min.z)/i*100),h={x:{min:s,max:r},y:{min:o,max:a},z:{min:l,max:c}};this.engine.events.trigger(Mt.SectionMove,h)}toPercent(e){return e<0?0:e>100?100:e}getInteractiveMeshes(){return this.meshs.filter(e=>e.type==="Mesh")}createRaycasterFromMouseEvent(e){const t=new C.Raycaster,i=new C.Vector2,s=this.engine.renderer.domElement.clientWidth,r=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/s*2-1,i.y=-(e.offsetY/r)*2+1,t.setFromCamera(i,this.engine.camera),t}attachListeners(){if(this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.handleNativeMouseDown,!0),e.addEventListener("mousemove",this.handleNativeMouseMove,!0),e.addEventListener("mouseup",this.handleNativeMouseUp,!0),window.addEventListener("keydown",this.handleNativeKeyDown),window.addEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!0)}detachListeners(){if(!this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.handleNativeMouseDown,!0),e.removeEventListener("mousemove",this.handleNativeMouseMove,!0),e.removeEventListener("mouseup",this.handleNativeMouseUp,!0)),window.removeEventListener("keydown",this.handleNativeKeyDown),window.removeEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!1,this.isCtrlDown=!1}resetMeshOpacity(){this.getInteractiveMeshes().forEach(e=>{e.material&&(e.material.opacity=this.faceIdleOpacity)})}updateClippingBoxFill(){const e=(Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:[]).slice(0,6).filter(t=>t instanceof C.Plane);if(e.length===0){this.clearClippingBoxFill();return}this.engine.clipping?.clippingCSGSimple?.updataFaces?.(e)}clearClippingBoxFill(){this.engine.clipping?.clippingCSGSimple?.clear?.()}getFaceTransformOffset(){if(!this.box)return .06;const e=this.box.min.distanceTo(this.box.max);return Math.max(e*.015,.06)}keepSingleDirectionArrow(e,t="X"){const i=e.getHelper(),s=[];i.traverse(r=>{if(r?.name!==t||!r.geometry)return;const o=r.geometry;o.boundingBox||o.computeBoundingBox();const a=o.boundingBox;if(!a)return;const l=a.getCenter(new C.Vector3);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const h=o.parameters,d=h&&h.radiusTop===0&&h.radiusBottom===.04&&h.height===.1,f=h&&h.radiusTop===.2&&h.radiusBottom===0&&h.height===.6;(d||f)&&s.push(r)}),s.forEach(r=>{r.parent?.remove(r)})}setTransformControlsVisible(e){this.transformControls.forEach(t=>{t.enabled=e}),this.transformHelpers.forEach(t=>{t.visible=e}),this.transformAnchors.forEach(t=>{t.visible=e}),e||(this.engine.controls.enabled=!0)}ensureFaceTransformControl(e){if(this.transformControls.has(e)&&this.transformAnchors.has(e))return;const t=this.engine.renderer?.domElement,i=this.engine.camera;if(!t||!i)return;const s=new C.Object3D;s.name=`SectionBoxTransformAnchor_${e}`,s.visible=this.isActive,this.engine.scene.add(s);const r=new sA(i,t);r.name=`SectionBoxTransformControl_${e}`,r.setMode("translate"),r.setSpace("local"),r.showX=!0,r.showY=!1,r.showZ=!1,r.size=this.transformHandleSize,r.setColors(this.transformHandleColor,this.transformHandleColor,this.transformHandleColor,this.transformHandleHoverColor),r.enabled=this.isActive,r.attach(s),this.keepSingleDirectionArrow(r,"X"),r.addEventListener("dragging-changed",a=>{this.engine.controls.enabled=!a.value,a.value===!0?this.clearClippingBoxFill():this.updateClippingBoxFill()}),r.addEventListener("objectChange",()=>{this.handleTransformObjectChange(e)});const o=r.getHelper();o.visible=this.isActive,this.engine.scene.add(o),this.transformAnchors.set(e,s),this.transformControls.set(e,r),this.transformHelpers.set(e,o)}updateFaceTransformControl(e,t,i,s){this.ensureFaceTransformControl(e);const r=this.transformAnchors.get(e),o=this.transformControls.get(e);if(!r||!o)return;const a=this.getFaceTransformOffset(),l=new C.Quaternion().setFromUnitVectors(new C.Vector3(1,0,0),t.clone().normalize()),c=i.clone().add(t.clone().setLength(a));this.faceMetaMap.set(e,{normal:t.clone().normalize(),isMinFace:s,center:i.clone()}),this.isSyncingTransform=!0,r.position.copy(c),r.quaternion.copy(l),r.visible=this.isActive,o.object!==r&&o.attach(r),o.enabled=this.isActive;const h=this.transformHelpers.get(e);h&&(h.visible=this.isActive),this.isSyncingTransform=!1}getDominantAxis(e){const t=Math.abs(e.x),i=Math.abs(e.y),s=Math.abs(e.z);return t>=i&&t>=s?"x":i>=t&&i>=s?"y":"z"}handleTransformObjectChange(e){if(this.isSyncingTransform)return;const t=this.transformAnchors.get(e),i=this.faceMetaMap.get(e);if(!t||!i||!this.box||!this.maxBox)return;const s=i.normal,r=this.getDominantAxis(s),o=this.getFaceTransformOffset(),a=s[r],l=t.position[r]-a*o;if(i.isMinFace){const c=this.maxBox.min[r],h=this.box.max[r];this.box.min[r]=Math.max(c,Math.min(h,l))}else{const c=this.box.min[r],h=this.maxBox.max[r];this.box.max[r]=Math.max(c,Math.min(h,l))}this.updata_face(this.box),this.calculate_ratio()}updata_face(e){let t=this.engine.scene.children.find(s=>s.type=="Group"&&s.name=="ClippingBox");t==null&&(t=new C.Group,t.name="ClippingBox",this.engine.scene.add(t)),[{name:"前",normal:new C.Vector3(0,0,-1),isMinFace:!0,planePoint:e.min,vertices:[new C.Vector3(e.min.x,e.max.y,e.min.z),new C.Vector3(e.max.x,e.max.y,e.min.z),new C.Vector3(e.max.x,e.min.y,e.min.z),new C.Vector3(e.min.x,e.min.y,e.min.z)]},{name:"后",normal:new C.Vector3(0,0,1),isMinFace:!1,planePoint:e.max,vertices:[new C.Vector3(e.min.x,e.min.y,e.max.z),new C.Vector3(e.max.x,e.min.y,e.max.z),new C.Vector3(e.max.x,e.max.y,e.max.z),new C.Vector3(e.min.x,e.max.y,e.max.z)]},{name:"右",normal:new C.Vector3(1,0,0),isMinFace:!1,planePoint:e.max,vertices:[new C.Vector3(e.max.x,e.min.y,e.max.z),new C.Vector3(e.max.x,e.min.y,e.min.z),new C.Vector3(e.max.x,e.max.y,e.min.z),new C.Vector3(e.max.x,e.max.y,e.max.z)]},{name:"左",normal:new C.Vector3(-1,0,0),isMinFace:!0,planePoint:e.min,vertices:[new C.Vector3(e.min.x,e.min.y,e.min.z),new C.Vector3(e.min.x,e.min.y,e.max.z),new C.Vector3(e.min.x,e.max.y,e.max.z),new C.Vector3(e.min.x,e.max.y,e.min.z)]},{name:"顶",normal:new C.Vector3(0,1,0),isMinFace:!1,planePoint:e.max,vertices:[new C.Vector3(e.min.x,e.max.y,e.max.z),new C.Vector3(e.max.x,e.max.y,e.max.z),new C.Vector3(e.max.x,e.max.y,e.min.z),new C.Vector3(e.min.x,e.max.y,e.min.z)]},{name:"底",normal:new C.Vector3(0,-1,0),isMinFace:!0,planePoint:e.min,vertices:[new C.Vector3(e.min.x,e.min.y,e.min.z),new C.Vector3(e.max.x,e.min.y,e.min.z),new C.Vector3(e.max.x,e.min.y,e.max.z),new C.Vector3(e.min.x,e.min.y,e.max.z)]}].forEach(s=>{this.createFace(t,s.vertices,s.normal,s.name,s.isMinFace,s.planePoint)}),this.engine.scene.children.filter(s=>s.type=="Mesh"&&s.url).forEach(s=>{s.material&&Array.isArray(s.material)?s.material.forEach(r=>{r.clippingPlanes=this.engine.sectionPlane}):s.material.clippingPlanes=this.engine.sectionPlane})}createFace(e,t,i,s,r,o){const a=new C.BufferGeometry,l=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z]),c=[0,2,1,0,3,2];a.setAttribute("position",new C.BufferAttribute(l,3)),a.setIndex(c);let h=this.meshs.find(A=>A.name===s);if(h==null){const A=new C.MeshBasicMaterial({color:65280,transparent:!0,opacity:this.faceIdleOpacity,side:C.DoubleSide});A.polygonOffset=!0,A.polygonOffsetFactor=1,A.polygonOffsetUnits=4,h=new C.Mesh(a,A),h.name=s,e.add(h),this.meshs.push(h)}else h.geometry=a;h.userData={dragNormal:i.clone(),isMinFace:r,faceName:s};const d=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z,t[0].x,t[0].y,t[0].z]),f=new C.LineBasicMaterial({color:255}),u=new C.BufferGeometry;u.setAttribute("position",new C.BufferAttribute(d,3));let g=this.meshs.find(A=>A.name===s+"Line");g==null?(g=new C.Line(u,f),g.name=s+"Line",e.add(g),this.meshs.push(g)):(g.geometry=u,g.material=f);const p=new C.Vector3;t.forEach(A=>p.add(A)),p.multiplyScalar(1/t.length),this.updateFaceTransformControl(s,i,p,r);const m=this.engine.sectionPlane.find(A=>A.name==s);m&&m.setFromNormalAndCoplanarPoint(i.clone().setLength(-1),o)}}class DI{engine;isActive=!1;isDrag=!1;isCtrlDown=!1;listenersAttached=!1;meshs=[];box=null;pickPoint=null;pickNormal=null;plane=null;angleX=0;angleY=0;angleZ=0;direction=1;normal=new C.Vector3(0,0,1);distance=0;center=null;current_center=null;dragStartDistance=0;idleOpacity=.02;hoverOpacity=.05;transformControl=null;transformAnchor=null;transformHelper=null;isSyncingTransformControl=!1;moveEpsilon=1e-5;transformHandleSize=1.15;transformHandleColor=16777215;transformHandleHoverColor=16776960;handleNativeMouseDown=e=>{if(e.button!==0||!(this.isCtrlDown||e.ctrlKey))return;const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);i.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:i}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:i})};handleNativeMouseUp=e=>{e.button!==0||!this.isDrag||(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseUp({button:e.button}))};handleNativeKeyDown=e=>{e.key==="Control"&&(this.isCtrlDown=!0)};handleNativeKeyUp=e=>{e.key==="Control"&&(this.isCtrlDown=!1,this.isDrag&&this.handleMouseUp({button:0}),this.resetMeshOpacity())};handleTransformObjectChange=()=>{if(this.isSyncingTransformControl||!this.transformAnchor||!this.center)return;const e=this.normal.clone().normalize(),t=this.getDistanceRange(e),i=this.getTransformHandleOffset(),s=this.transformAnchor.position.clone().sub(this.center).dot(e)-i,r=Math.min(t.max,Math.max(t.min,s));Math.abs(r-Number(this.distance))>this.moveEpsilon?this.updata_face(r):Math.abs(s-r)>this.moveEpsilon&&this.updateTransformControl(e)};constructor(e){this.engine=e,this.meshs=[],this.box=null}active(){if(this.isActive==!0)return;this.isActive=!0,this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(i=>{i.name.includes("face")&&(i.visible=!0)})}),this.attachListeners(),this.ensureTransformControl(),this.setTransformControlVisible(!0);const e=this;e.engine.scene.children.filter(t=>t.type=="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(i=>{i.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(i=>i.name=="face"),t)}),this.init()}disActive(){this.init(),this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0},!1),this.setTransformControlVisible(!1),this.clearClippingFaceFill();const e=this.engine.sectionPlane.find(t=>t.name=="face");e&&(e.constant=1e5),this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(i=>{i.name.includes("face")&&(i.visible=!1)})})}init(e){const t=this.engine.octreeBox.getBoundingBox();this.box=t,this.distance=0,this.center=new C.Vector3((t.min.x+t.max.x)/2,(t.min.y+t.max.y)/2,(t.min.z+t.max.z)/2),this.current_center=this.center.clone(),!e&&this.updata_face(0)}disabled(){this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0},!1),this.setTransformControlVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!1)})})}recover(){this.isActive||(this.attachListeners(),this.setTransformControlVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!0)})}),this.isActive=!0)}setFaceAngle(e,t,i){this.angleX=e,this.angleY=t,this.angleZ=i,this.distance=0,this.normal=new C.Vector3(0,1,0).applyAxisAngle(new C.Vector3(1,0,0),e).applyAxisAngle(new C.Vector3(0,0,1),t).applyAxisAngle(new C.Vector3(0,1,0),i).normalize(),this.updata_face(0),this.updateClippingFaceFill()}setFaceNormal(e,t=0){this.normal=e.clone().normalize(),this.distance=t,this.updata_face(t),this.updateClippingFaceFill()}setFaceNormalPlaneOnly(e,t){if(this.normal=e.clone().normalize(),this.distance=t,!this.center||!this.box)return;const i=this.engine.sectionPlane?.find(s=>s.name==="face");if(i){const s=this.center.clone().add(this.normal.clone().multiplyScalar(t));i.setFromNormalAndCoplanarPoint(this.normal.clone().multiplyScalar(this.direction),s)}this.updateClippingFaceFill()}activateClippingOnly(){if(this.isActive)return;this.isActive=!0;const e=this;e.engine.scene.children.filter(t=>t.type==="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(i=>{i.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(i=>i.name==="face"),t)})}reverse(){this.direction=this.direction*-1,this.updata_face(this.distance),this.updateClippingFaceFill()}getFaceAngle(){return{angleX:this.angleX,angleY:this.angleY,angleZ:this.angleZ,direction:this.direction}}updata_face(e){if(!this.box)return;this.distance=e;let t=this.engine.scene.children.find(b=>b.type=="Group"&&b.name=="ClippingBox");t==null&&(t=new C.Group,t.name="ClippingBox",this.engine.scene.add(t));const i=this.normal.clone().normalize(),s=this.center??new C.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2);this.center=s.clone();const{tangent:r,bitangent:o}=this.getPlaneBasis(i),a=this.getBoxCorners(this.box),l=this.box.min.distanceTo(this.box.max),c=Math.max(l*.02,.01);let h=1/0,d=-1/0,f=1/0,u=-1/0;a.forEach(b=>{const y=b.clone().sub(s),_=y.dot(r),w=y.dot(o);h=Math.min(h,_),d=Math.max(d,_),f=Math.min(f,w),u=Math.max(u,w)}),h-=c,d+=c,f-=c,u+=c;const g=i.clone().multiplyScalar(e),p=s.clone().add(r.clone().multiplyScalar(h)).add(o.clone().multiplyScalar(f)).add(g),m=s.clone().add(r.clone().multiplyScalar(d)).add(o.clone().multiplyScalar(f)).add(g),A=s.clone().add(r.clone().multiplyScalar(d)).add(o.clone().multiplyScalar(u)).add(g),x=s.clone().add(r.clone().multiplyScalar(h)).add(o.clone().multiplyScalar(u)).add(g);this.current_center=s.clone().add(g),this.createFace(t,[p,m,A,x],i,"face"),this.updateTransformControl(i)}createFace(e,t,i,s){const r=new C.BufferGeometry,o=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z]),a=[0,1,2,0,2,3];r.setAttribute("position",new C.BufferAttribute(o,3)),r.setIndex(a);let l=this.meshs.find(g=>g.name==s);if(l==null){const g=new C.MeshBasicMaterial({color:65280,transparent:!0,opacity:this.idleOpacity,side:C.DoubleSide});g.polygonOffset=!0,g.polygonOffsetFactor=1,g.polygonOffsetUnits=4,l=new C.Mesh(r,g),l.name=s,e.add(l),this.meshs.push(l)}else l.geometry=r;l.normal=i.clone();const c=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z,t[0].x,t[0].y,t[0].z]),h=new C.LineBasicMaterial({color:255}),d=new C.BufferGeometry;d.setAttribute("position",new C.BufferAttribute(c,3));let f=this.meshs.find(g=>g.name==s+"Line");f==null?(f=new C.Line(d,h),f.name=s+"Line",e.add(f),this.meshs.push(f)):(f.geometry=d,f.material=h);const u=this.engine.sectionPlane.find(g=>g.name==s);u&&this.current_center&&u.setFromNormalAndCoplanarPoint(i.clone().setLength(this.direction),this.current_center)}getPlaneBasis(e){const t=new C.Vector3(1,0,0),i=new C.Vector3(0,1,0),s=new C.Vector3(0,0,1),r=Math.abs(e.dot(t)),o=Math.abs(e.dot(i)),a=Math.abs(e.dot(s));let l=t;o<=r&&o<=a?l=i:a<=r&&a<=o&&(l=s),l=l.clone().sub(e.clone().multiplyScalar(l.dot(e))).normalize();const c=new C.Vector3().crossVectors(e,l).normalize();return{tangent:l,bitangent:c}}getBoxCorners(e){return[new C.Vector3(e.min.x,e.min.y,e.min.z),new C.Vector3(e.min.x,e.min.y,e.max.z),new C.Vector3(e.min.x,e.max.y,e.min.z),new C.Vector3(e.min.x,e.max.y,e.max.z),new C.Vector3(e.max.x,e.min.y,e.min.z),new C.Vector3(e.max.x,e.min.y,e.max.z),new C.Vector3(e.max.x,e.max.y,e.min.z),new C.Vector3(e.max.x,e.max.y,e.max.z)]}getDistanceRange(e){if(!this.box)return{min:0,max:0};const t=this.center??new C.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2),i=this.getBoxCorners(this.box);let s=1/0,r=-1/0;return i.forEach(o=>{const a=o.clone().sub(t).dot(e);s=Math.min(s,a),r=Math.max(r,a)}),{min:s,max:r}}getInteractiveMeshes(){return this.meshs.filter(e=>e.type==="Mesh")}getTransformHandleOffset(){if(!this.box)return .06;const e=this.box.min.distanceTo(this.box.max);return Math.max(e*.015,.06)}keepSingleDirectionArrow(e,t="X"){const i=e.getHelper(),s=[];i.traverse(r=>{if(r?.name!==t||!r.geometry)return;const o=r.geometry;o.boundingBox||o.computeBoundingBox();const a=o.boundingBox;if(!a)return;const l=a.getCenter(new C.Vector3);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const h=o.parameters,d=h&&h.radiusTop===0&&h.radiusBottom===.04&&h.height===.1,f=h&&h.radiusTop===.2&&h.radiusBottom===0&&h.height===.6;(d||f)&&s.push(r)}),s.forEach(r=>{r.parent?.remove(r)})}ensureTransformControl(){if(this.transformControl&&this.transformAnchor)return;const e=this.engine.renderer?.domElement,t=this.engine.camera;if(!e||!t)return;const i=new C.Object3D;i.name="SectionFaceTransformAnchor",i.visible=this.isActive,this.engine.scene.add(i);const s=new sA(t,e);s.name="SectionFaceTransformControl",s.setMode("translate"),s.setSpace("local"),s.showX=!0,s.showY=!1,s.showZ=!1,s.size=this.transformHandleSize,s.setColors(this.transformHandleColor,this.transformHandleColor,this.transformHandleColor,this.transformHandleHoverColor),s.enabled=this.isActive,s.attach(i),this.keepSingleDirectionArrow(s,"X"),s.addEventListener("dragging-changed",o=>{this.engine.controls.enabled=!o.value,o.value===!0?this.clearClippingFaceFill():this.updateClippingFaceFill()}),s.addEventListener("objectChange",this.handleTransformObjectChange);const r=s.getHelper();r.visible=this.isActive,this.engine.scene.add(r),this.transformAnchor=i,this.transformControl=s,this.transformHelper=r}setTransformControlVisible(e){this.ensureTransformControl(),this.transformControl&&(this.transformControl.enabled=e),this.transformHelper&&(this.transformHelper.visible=e),this.transformAnchor&&(this.transformAnchor.visible=e),e||(this.engine.controls.enabled=!0)}updateTransformControl(e){if(this.ensureTransformControl(),!this.transformControl||!this.transformAnchor||!this.current_center)return;const t=this.getTransformHandleOffset(),i=this.current_center.clone().add(e.clone().setLength(t)),s=new C.Quaternion().setFromUnitVectors(new C.Vector3(1,0,0),e.clone().normalize().multiplyScalar(-1));this.isSyncingTransformControl=!0,this.transformAnchor.position.copy(i),this.transformAnchor.quaternion.copy(s),this.transformAnchor.visible=this.isActive,this.transformControl.object!==this.transformAnchor&&this.transformControl.attach(this.transformAnchor),this.transformControl.enabled=this.isActive,this.transformHelper&&(this.transformHelper.visible=this.isActive),this.isSyncingTransformControl=!1}createRaycasterFromMouseEvent(e){const t=new C.Raycaster,i=new C.Vector2,s=this.engine.renderer.domElement.clientWidth,r=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/s*2-1,i.y=-(e.offsetY/r)*2+1,t.setFromCamera(i,this.engine.camera),t}attachListeners(){if(this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.handleNativeMouseDown,!0),e.addEventListener("mousemove",this.handleNativeMouseMove,!0),e.addEventListener("mouseup",this.handleNativeMouseUp,!0),window.addEventListener("keydown",this.handleNativeKeyDown),window.addEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!0)}detachListeners(){if(!this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.handleNativeMouseDown,!0),e.removeEventListener("mousemove",this.handleNativeMouseMove,!0),e.removeEventListener("mouseup",this.handleNativeMouseUp,!0)),window.removeEventListener("keydown",this.handleNativeKeyDown),window.removeEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!1,this.isCtrlDown=!1}resetMeshOpacity(){this.getInteractiveMeshes().forEach(e=>{e.material&&(e.material.opacity=this.idleOpacity)})}updateClippingFaceFill(){const e=this.engine.sectionPlane?.find?.(t=>t.name==="face");if(e){this.engine.clipping?.clippingCSGSimple?.updataFace?.(e);return}this.clearClippingFaceFill()}clearClippingFaceFill(){this.engine.clipping?.clippingCSGSimple?.clear?.()}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){this.clearClippingFaceFill();const i=t[0],s=i.point.clone();this.isDrag=!0,this.pickPoint=s;const o=(i.face?.normal?.clone()??this.normal.clone()).clone();if(o.dot(this.normal)<0&&o.multiplyScalar(-1),o.normalize(),this.pickNormal=o,this.engine.controls.enabled=!1,this.dragStartDistance=Number(this.distance)||0,o.y==0){const a=new C.Plane;a.setFromNormalAndCoplanarPoint(new C.Vector3(0,1,0),s),this.plane=a}else{const a=new C.Vector3(this.engine.camera.position.x,s.y,this.engine.camera.position.z),l=new C.Plane;l.setFromNormalAndCoplanarPoint(a.clone().sub(s.clone()).setLength(1),s),this.plane=l}}else this.isDrag=!1}handleMouseUp(e,t=!0){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.plane=null,this.engine.controls.enabled=!0,t&&this.updateClippingFaceFill()}handleMouseMove(e){this.resetMeshOpacity();const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);t!=null&&t.length>0&&(t[0].object.material.opacity=this.hoverOpacity);const i=this.pickPoint,s=this.pickNormal,r=this.plane;if(i!=null&&s!=null&&r!=null){const o=new C.Vector3;if(e.raycaster.ray.intersectPlane(r,o)){const a=o.clone().sub(i.clone()).dot(s.clone()),l=this.getDistanceRange(this.normal.clone().normalize()),c=this.dragStartDistance+a;this.distance=Math.min(l.max,Math.max(l.min,c)),this.updata_face(this.distance)}}}}class BI{engine;callback_;constructor(e){this.engine=e}init(){this.engine.handelBehaved.init(this,{showCatch:!0}),this.engine.handelBehaved.active()}catch_face(e){this.callback_=e}handleMouseMove(e){}handleMouseClick(e){if(e.catch?.normal==null&&(e.catch.normal=e.catch.face?.normal),!e.catch?.normal||!e.catch?.point)return;let t=e.catch.normal.setLength(-1);this.engine.handelBehaved.disActive(),this.callback_({dir:t,position:e.catch.point})}}const bA=0,PI=1,LI=2,yA=2,cf=1.25,vA=1,ai=32,Wt=ai/4,_A=65535,RI=Math.pow(2,-24),hf=Symbol("SKIP_GENERATION");function kI(n){return n.index?n.index.count:n.attributes.position.count}function pr(n){return kI(n)/3}function FI(n,e=ArrayBuffer){return n>65535?new Uint32Array(new e(4*n)):new Uint16Array(new e(2*n))}function OI(n,e){if(!n.index){const t=n.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=FI(t,i);n.setIndex(new v.BufferAttribute(s,1));for(let r=0;r<t;r++)s[r]=r}}function CA(n,e){const t=pr(n),i=e||n.drawRange,s=i.start/3,r=(i.start+i.count)/3,o=Math.max(0,s),a=Math.min(t,r)-o;return[{offset:Math.floor(o),count:Math.floor(a)}]}function wA(n,e){if(!n.groups||!n.groups.length)return CA(n,e);const t=[],i=e||n.drawRange,s=i.start/3,r=(i.start+i.count)/3,o=pr(n),a=[];for(const h of n.groups){const{start:d,count:f}=h,u=d/3,g=isFinite(f)?f:o*3-d,p=(d+g)/3;u<r&&p>s&&(a.push({pos:Math.max(s,u),isStart:!0}),a.push({pos:Math.min(r,p),isStart:!1}))}a.sort((h,d)=>h.pos!==d.pos?h.pos-d.pos:h.type==="end"?-1:1);let l=0,c=null;for(const h of a){const d=h.pos;l!==0&&d!==c&&t.push({offset:c,count:d-c}),l+=h.isStart?1:-1,c=d}return t}function df(n,e,t,i,s){let r=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0,d=1/0,f=1/0,u=1/0,g=-1/0,p=-1/0,m=-1/0;const A=n.offset||0;for(let x=(e-A)*6,b=(e+t-A)*6;x<b;x+=6){const y=n[x+0],_=n[x+1],w=y-_,S=y+_;w<r&&(r=w),S>l&&(l=S),y<d&&(d=y),y>g&&(g=y);const D=n[x+2],M=n[x+3],I=D-M,P=D+M;I<o&&(o=I),P>c&&(c=P),D<f&&(f=D),D>p&&(p=D);const T=n[x+4],L=n[x+5],E=T-L,F=T+L;E<a&&(a=E),F>h&&(h=F),T<u&&(u=T),T>m&&(m=T)}i[0]=r,i[1]=o,i[2]=a,i[3]=l,i[4]=c,i[5]=h,s[0]=d,s[1]=f,s[2]=u,s[3]=g,s[4]=p,s[5]=m}function SA(n,e,t=null,i=null,s=null){const r=n.attributes.position,o=n.index?n.index.array:null,a=r.normalized;if(s===null)s=new Float32Array(t*6),s.offset=e;else if(e<0||t+e>s.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=r.array,c=r.offset||0;let h=3;r.isInterleavedBufferAttribute&&(h=r.data.stride);const d=["getX","getY","getZ"],f=s.offset;for(let u=e,g=e+t;u<g;u++){const m=(i?i[u]:u)*3,A=(u-f)*6;let x=m+0,b=m+1,y=m+2;o&&(x=o[x],b=o[b],y=o[y]),a||(x=x*h+c,b=b*h+c,y=y*h+c);for(let _=0;_<3;_++){let w,S,D;a?(w=r[d[_]](x),S=r[d[_]](b),D=r[d[_]](y)):(w=l[x+_],S=l[b+_],D=l[y+_]);let M=w;S<M&&(M=S),D<M&&(M=D);let I=w;S>I&&(I=S),D>I&&(I=D);const P=(I-M)/2,T=_*2;s[A+T+0]=M+P,s[A+T+1]=P+(Math.abs(M)+P)*RI}}return s}function Et(n,e,t){return t.min.x=e[n],t.min.y=e[n+1],t.min.z=e[n+2],t.max.x=e[n+3],t.max.y=e[n+4],t.max.z=e[n+5],t}function MA(n){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=n[i+3]-n[i];s>t&&(t=s,e=i)}return e}function EA(n,e){e.set(n)}function IA(n,e,t){let i,s;for(let r=0;r<3;r++){const o=r+3;i=n[r],s=e[r],t[r]=i<s?i:s,i=n[o],s=e[o],t[o]=i>s?i:s}}function Bc(n,e,t){for(let i=0;i<3;i++){const s=e[n+2*i],r=e[n+2*i+1],o=s-r,a=s+r;o<t[i]&&(t[i]=o),a>t[i+3]&&(t[i+3]=a)}}function _a(n){const e=n[3]-n[0],t=n[4]-n[1],i=n[5]-n[2];return 2*(e*t+t*i+i*e)}const Zn=32,UI=(n,e)=>n.candidate-e.candidate,Ms=new Array(Zn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Pc=new Float32Array(6);function NI(n,e,t,i,s,r){let o=-1,a=0;if(r===bA)o=MA(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(r===PI)o=MA(n),o!==-1&&(a=zI(t,i,s,o));else if(r===LI){const l=_a(n);let c=cf*s;const h=t.offset||0,d=(i-h)*6,f=(i+s-h)*6;for(let u=0;u<3;u++){const g=e[u],A=(e[u+3]-g)/Zn;if(s<Zn/4){const x=[...Ms];x.length=s;let b=0;for(let _=d;_<f;_+=6,b++){const w=x[b];w.candidate=t[_+2*u],w.count=0;const{bounds:S,leftCacheBounds:D,rightCacheBounds:M}=w;for(let I=0;I<3;I++)M[I]=1/0,M[I+3]=-1/0,D[I]=1/0,D[I+3]=-1/0,S[I]=1/0,S[I+3]=-1/0;Bc(_,t,S)}x.sort(UI);let y=s;for(let _=0;_<y;_++){const w=x[_];for(;_+1<y&&x[_+1].candidate===w.candidate;)x.splice(_+1,1),y--}for(let _=d;_<f;_+=6){const w=t[_+2*u];for(let S=0;S<y;S++){const D=x[S];w>=D.candidate?Bc(_,t,D.rightCacheBounds):(Bc(_,t,D.leftCacheBounds),D.count++)}}for(let _=0;_<y;_++){const w=x[_],S=w.count,D=s-w.count,M=w.leftCacheBounds,I=w.rightCacheBounds;let P=0;S!==0&&(P=_a(M)/l);let T=0;D!==0&&(T=_a(I)/l);const L=vA+cf*(P*S+T*D);L<c&&(o=u,c=L,a=w.candidate)}}else{for(let y=0;y<Zn;y++){const _=Ms[y];_.count=0,_.candidate=g+A+y*A;const w=_.bounds;for(let S=0;S<3;S++)w[S]=1/0,w[S+3]=-1/0}for(let y=d;y<f;y+=6){let S=~~((t[y+2*u]-g)/A);S>=Zn&&(S=Zn-1);const D=Ms[S];D.count++,Bc(y,t,D.bounds)}const x=Ms[Zn-1];EA(x.bounds,x.rightCacheBounds);for(let y=Zn-2;y>=0;y--){const _=Ms[y],w=Ms[y+1];IA(_.bounds,w.rightCacheBounds,_.rightCacheBounds)}let b=0;for(let y=0;y<Zn-1;y++){const _=Ms[y],w=_.count,S=_.bounds,M=Ms[y+1].rightCacheBounds;w!==0&&(b===0?EA(S,Pc):IA(S,Pc,Pc)),b+=w;let I=0,P=0;b!==0&&(I=_a(Pc)/l);const T=s-b;T!==0&&(P=_a(M)/l);const L=vA+cf*(I*b+P*T);L<c&&(o=u,c=L,a=_.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:a}}function zI(n,e,t,i){let s=0;const r=n.offset;for(let o=e,a=e+t;o<a;o++)s+=n[(o-r)*6+i*2];return s/t}class uf{constructor(){this.boundingData=new Float32Array(6)}}function GI(n,e,t,i,s,r){let o=i,a=i+s-1;const l=r.pos,c=r.axis*2,h=t.offset||0;for(;;){for(;o<=a&&t[(o-h)*6+c]<l;)o++;for(;o<=a&&t[(a-h)*6+c]>=l;)a--;if(o<a){for(let d=0;d<3;d++){let f=e[o*3+d];e[o*3+d]=e[a*3+d],e[a*3+d]=f}for(let d=0;d<6;d++){const f=o-h,u=a-h,g=t[f*6+d];t[f*6+d]=t[u*6+d],t[u*6+d]=g}o++,a--}else return o}}function VI(n,e,t,i,s,r){let o=i,a=i+s-1;const l=r.pos,c=r.axis*2,h=t.offset||0;for(;;){for(;o<=a&&t[(o-h)*6+c]<l;)o++;for(;o<=a&&t[(a-h)*6+c]>=l;)a--;if(o<a){let d=n[o];n[o]=n[a],n[a]=d;for(let f=0;f<6;f++){const u=o-h,g=a-h,p=t[u*6+f];t[u*6+f]=t[g*6+f],t[g*6+f]=p}o++,a--}else return o}}let TA,Lc,ff,DA;const QI=Math.pow(2,32);function pf(n){return"count"in n?1:1+pf(n.left)+pf(n.right)}function jI(n,e,t){return TA=new Float32Array(t),Lc=new Uint32Array(t),ff=new Uint16Array(t),DA=new Uint8Array(t),gf(n,e)}function gf(n,e){const t=n/4,i=n/2,s="count"in e,r=e.boundingData;for(let o=0;o<6;o++)TA[t+o]=r[o];if(s)return e.buffer?(DA.set(new Uint8Array(e.buffer),n),n+e.buffer.byteLength):(Lc[t+6]=e.offset,ff[i+14]=e.count,ff[i+15]=_A,n+ai);{const{left:o,right:a,splitAxis:l}=e,c=n+ai;let h=gf(c,o);const d=n/ai,u=h/ai-d;if(u>QI)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Lc[t+6]=u,Lc[t+7]=l,gf(h,a)}}function WI(n,e,t){const s=(n.index?n.index.count:n.attributes.position.count)/3>2**16,r=t.reduce((h,d)=>h+d.count,0),o=s?4:2,a=e?new SharedArrayBuffer(r*o):new ArrayBuffer(r*o),l=s?new Uint32Array(a):new Uint16Array(a);let c=0;for(let h=0;h<t.length;h++){const{offset:d,count:f}=t[h];for(let u=0;u<f;u++)l[c+u]=d+u;c+=f}return l}function HI(n,e,t,i,s){const{maxDepth:r,verbose:o,maxLeafTris:a,strategy:l,onProgress:c,indirect:h}=s,d=n._indirectBuffer,f=n.geometry,u=f.index?f.index.array:null,g=h?VI:GI,p=pr(f),m=new Float32Array(6);let A=!1;const x=new uf;return df(e,t,i,x.boundingData,m),y(x,t,i,m),x;function b(_){c&&c(_/p)}function y(_,w,S,D=null,M=0){if(!A&&M>=r&&(A=!0,o&&(console.warn(`MeshBVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`),console.warn(f))),S<=a||M>=r)return b(w+S),_.offset=w,_.count=S,_;const I=NI(_.boundingData,D,e,w,S,l);if(I.axis===-1)return b(w+S),_.offset=w,_.count=S,_;const P=g(d,u,e,w,S,I);if(P===w||P===w+S)b(w+S),_.offset=w,_.count=S;else{_.splitAxis=I.axis;const T=new uf,L=w,E=P-w;_.left=T,df(e,L,E,T.boundingData,m),y(T,L,E,m,M+1);const F=new uf,z=P,X=S-E;_.right=F,df(e,z,X,F.boundingData,m),y(F,z,X,m,M+1)}return _}}function XI(n,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=n.geometry;let s,r;if(e.indirect){const o=wA(i,e.range),a=WI(i,e.useSharedArrayBuffer,o);n._indirectBuffer=a,s=SA(i,0,a.length,a),r=[{offset:0,count:a.length}]}else{OI(i,e);const o=CA(i,e.range)[0];s=SA(i,o.offset,o.count),r=wA(i,e.range)}n._roots=r.map(o=>{const a=HI(n,s,o.offset,o.count,e),l=pf(a),c=new t(ai*l);return jI(0,a,c),c})}class Jn{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let r=0,o=e.length;r<o;r++){const l=e[r][t];i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let r=0,o=t.length;r<o;r++){const a=t[r],l=e.dot(a);i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}Jn.prototype.setFromBox=(function(){const n=new v.Vector3;return function(t,i){const s=i.min,r=i.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){n.x=s.x*l+r.x*(1-l),n.y=s.y*c+r.y*(1-c),n.z=s.z*h+r.z*(1-h);const d=t.dot(n);o=Math.min(d,o),a=Math.max(d,a)}this.min=o,this.max=a}})();const qI=(function(){const n=new v.Vector3,e=new v.Vector3,t=new v.Vector3;return function(s,r,o){const a=s.start,l=n,c=r.start,h=e;t.subVectors(a,c),n.subVectors(s.end,s.start),e.subVectors(r.end,r.start);const d=t.dot(h),f=h.dot(l),u=h.dot(h),g=t.dot(l),m=l.dot(l)*u-f*f;let A,x;m!==0?A=(d*f-g*u)/m:A=0,x=(d+A*f)/u,o.x=A,o.y=x}})(),mf=(function(){const n=new v.Vector2,e=new v.Vector3,t=new v.Vector3;return function(s,r,o,a){qI(s,r,n);let l=n.x,c=n.y;if(l>=0&&l<=1&&c>=0&&c<=1){s.at(l,o),r.at(c,a);return}else if(l>=0&&l<=1){c<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?s.at(0,o):s.at(1,o),r.closestPointToPoint(o,!0,a);return}else{let h;l<0?h=s.start:h=s.end;let d;c<0?d=r.start:d=r.end;const f=e,u=t;if(s.closestPointToPoint(d,!0,e),r.closestPointToPoint(h,!0,t),f.distanceToSquared(d)<=u.distanceToSquared(h)){o.copy(f),a.copy(d);return}else{o.copy(h),a.copy(u);return}}}})(),YI=(function(){const n=new v.Vector3,e=new v.Vector3,t=new v.Plane,i=new v.Line3;return function(r,o){const{radius:a,center:l}=r,{a:c,b:h,c:d}=o;if(i.start=c,i.end=h,i.closestPointToPoint(l,!0,n).distanceTo(l)<=a||(i.start=c,i.end=d,i.closestPointToPoint(l,!0,n).distanceTo(l)<=a)||(i.start=h,i.end=d,i.closestPointToPoint(l,!0,n).distanceTo(l)<=a))return!0;const p=o.getPlane(t);if(Math.abs(p.distanceToPoint(l))<=a){const A=p.projectPoint(l,e);if(o.containsPoint(A))return!0}return!1}})(),KI=["x","y","z"],es=1e-15,BA=es*es;function Gi(n){return Math.abs(n)<es}class Vi extends v.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new v.Vector3),this.satBounds=new Array(4).fill().map(()=>new Jn),this.points=[this.a,this.b,this.c],this.plane=new v.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new v.Line3,this.needsUpdate=!0}intersectsSphere(e){return YI(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,r=this.satAxes,o=this.satBounds,a=r[0],l=o[0];this.getNormal(a),l.setFromPoints(a,s);const c=r[1],h=o[1];c.subVectors(e,t),h.setFromPoints(c,s);const d=r[2],f=o[2];d.subVectors(t,i),f.setFromPoints(d,s);const u=r[3],g=o[3];u.subVectors(i,e),g.setFromPoints(u,s);const p=c.length(),m=d.length(),A=u.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,p<es?m<es||A<es?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(i)):m<es?A<es?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):A<es&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(i),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}Vi.prototype.closestPointToSegment=(function(){const n=new v.Vector3,e=new v.Vector3,t=new v.Line3;return function(s,r=null,o=null){const{start:a,end:l}=s,c=this.points;let h,d=1/0;for(let f=0;f<3;f++){const u=(f+1)%3;t.start.copy(c[f]),t.end.copy(c[u]),mf(t,s,n,e),h=n.distanceToSquared(e),h<d&&(d=h,r&&r.copy(n),o&&o.copy(e))}return this.closestPointToPoint(a,n),h=a.distanceToSquared(n),h<d&&(d=h,r&&r.copy(n),o&&o.copy(a)),this.closestPointToPoint(l,n),h=l.distanceToSquared(n),h<d&&(d=h,r&&r.copy(n),o&&o.copy(l)),Math.sqrt(d)}})(),Vi.prototype.intersectsTriangle=(function(){const n=new Vi,e=new Jn,t=new Jn,i=new v.Vector3,s=new v.Vector3,r=new v.Vector3,o=new v.Vector3,a=new v.Line3,l=new v.Line3,c=new v.Vector3,h=new v.Vector2,d=new v.Vector2;function f(b,y,_,w){const S=i;!b.isDegenerateIntoPoint&&!b.isDegenerateIntoSegment?S.copy(b.plane.normal):S.copy(y.plane.normal);const D=b.satBounds,M=b.satAxes;for(let T=1;T<4;T++){const L=D[T],E=M[T];if(e.setFromPoints(E,y.points),L.isSeparated(e)||(o.copy(S).cross(E),e.setFromPoints(o,b.points),t.setFromPoints(o,y.points),e.isSeparated(t)))return!1}const I=y.satBounds,P=y.satAxes;for(let T=1;T<4;T++){const L=I[T],E=P[T];if(e.setFromPoints(E,b.points),L.isSeparated(e)||(o.crossVectors(S,E),e.setFromPoints(o,b.points),t.setFromPoints(o,y.points),e.isSeparated(t)))return!1}return _&&(w||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),_.start.set(0,0,0),_.end.set(0,0,0)),!0}function u(b,y,_,w,S,D,M,I,P,T,L){let E=M/(M-I);T.x=w+(S-w)*E,L.start.subVectors(y,b).multiplyScalar(E).add(b),E=M/(M-P),T.y=w+(D-w)*E,L.end.subVectors(_,b).multiplyScalar(E).add(b)}function g(b,y,_,w,S,D,M,I,P,T,L){if(S>0)u(b.c,b.a,b.b,w,y,_,P,M,I,T,L);else if(D>0)u(b.b,b.a,b.c,_,y,w,I,M,P,T,L);else if(I*P>0||M!=0)u(b.a,b.b,b.c,y,_,w,M,I,P,T,L);else if(I!=0)u(b.b,b.a,b.c,_,y,w,I,M,P,T,L);else if(P!=0)u(b.c,b.a,b.b,w,y,_,P,M,I,T,L);else return!0;return!1}function p(b,y,_,w){const S=y.degenerateSegment,D=b.plane.distanceToPoint(S.start),M=b.plane.distanceToPoint(S.end);return Gi(D)?Gi(M)?f(b,y,_,w):(_&&(_.start.copy(S.start),_.end.copy(S.start)),b.containsPoint(S.start)):Gi(M)?(_&&(_.start.copy(S.end),_.end.copy(S.end)),b.containsPoint(S.end)):b.plane.intersectLine(S,i)!=null?(_&&(_.start.copy(i),_.end.copy(i)),b.containsPoint(i)):!1}function m(b,y,_){const w=y.a;return Gi(b.plane.distanceToPoint(w))&&b.containsPoint(w)?(_&&(_.start.copy(w),_.end.copy(w)),!0):!1}function A(b,y,_){const w=b.degenerateSegment,S=y.a;return w.closestPointToPoint(S,!0,i),S.distanceToSquared(i)<BA?(_&&(_.start.copy(S),_.end.copy(S)),!0):!1}function x(b,y,_,w){if(b.isDegenerateIntoSegment)if(y.isDegenerateIntoSegment){const S=b.degenerateSegment,D=y.degenerateSegment,M=s,I=r;S.delta(M),D.delta(I);const P=i.subVectors(D.start,S.start),T=M.x*I.y-M.y*I.x;if(Gi(T))return!1;const L=(P.x*I.y-P.y*I.x)/T,E=-(M.x*P.y-M.y*P.x)/T;if(L<0||L>1||E<0||E>1)return!1;const F=S.start.z+M.z*L,z=D.start.z+I.z*E;return Gi(F-z)?(_&&(_.start.copy(S.start).addScaledVector(M,L),_.end.copy(S.start).addScaledVector(M,L)),!0):!1}else return y.isDegenerateIntoPoint?A(b,y,_):p(y,b,_,w);else{if(b.isDegenerateIntoPoint)return y.isDegenerateIntoPoint?y.a.distanceToSquared(b.a)<BA?(_&&(_.start.copy(b.a),_.end.copy(b.a)),!0):!1:y.isDegenerateIntoSegment?A(y,b,_):m(y,b,_);if(y.isDegenerateIntoPoint)return m(b,y,_);if(y.isDegenerateIntoSegment)return p(b,y,_,w)}}return function(y,_=null,w=!1){this.needsUpdate&&this.update(),y.isExtendedTriangle?y.needsUpdate&&y.update():(n.copy(y),n.update(),y=n);const S=x(this,y,_,w);if(S!==void 0)return S;const D=this.plane,M=y.plane;let I=M.distanceToPoint(this.a),P=M.distanceToPoint(this.b),T=M.distanceToPoint(this.c);Gi(I)&&(I=0),Gi(P)&&(P=0),Gi(T)&&(T=0);const L=I*P,E=I*T;if(L>0&&E>0)return!1;let F=D.distanceToPoint(y.a),z=D.distanceToPoint(y.b),X=D.distanceToPoint(y.c);Gi(F)&&(F=0),Gi(z)&&(z=0),Gi(X)&&(X=0);const j=F*z,N=F*X;if(j>0&&N>0)return!1;s.copy(D.normal),r.copy(M.normal);const Y=s.cross(r);let V=0,H=Math.abs(Y.x);const oe=Math.abs(Y.y);oe>H&&(H=oe,V=1),Math.abs(Y.z)>H&&(V=2);const ue=KI[V],re=this.a[ue],de=this.b[ue],Ae=this.c[ue],ye=y.a[ue],Me=y.b[ue],Oe=y.c[ue];if(g(this,re,de,Ae,L,E,I,P,T,h,a))return f(this,y,_,w);if(g(y,ye,Me,Oe,j,N,F,z,X,d,l))return f(this,y,_,w);if(h.y<h.x){const nt=h.y;h.y=h.x,h.x=nt,c.copy(a.start),a.start.copy(a.end),a.end.copy(c)}if(d.y<d.x){const nt=d.y;d.y=d.x,d.x=nt,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return h.y<d.x||d.y<h.x?!1:(_&&(d.x>h.x?_.start.copy(l.start):_.start.copy(a.start),d.y<h.y?_.end.copy(l.end):_.end.copy(a.end)),!0)}})(),Vi.prototype.distanceToPoint=(function(){const n=new v.Vector3;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}})(),Vi.prototype.distanceToTriangle=(function(){const n=new v.Vector3,e=new v.Vector3,t=["a","b","c"],i=new v.Line3,s=new v.Line3;return function(o,a=null,l=null){const c=a||l?i:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let h=1/0;for(let d=0;d<3;d++){let f;const u=t[d],g=o[u];this.closestPointToPoint(g,n),f=g.distanceToSquared(n),f<h&&(h=f,a&&a.copy(n),l&&l.copy(g));const p=this[u];o.closestPointToPoint(p,n),f=p.distanceToSquared(n),f<h&&(h=f,a&&a.copy(p),l&&l.copy(n))}for(let d=0;d<3;d++){const f=t[d],u=t[(d+1)%3];i.set(this[f],this[u]);for(let g=0;g<3;g++){const p=t[g],m=t[(g+1)%3];s.set(o[p],o[m]),mf(i,s,n,e);const A=n.distanceToSquared(e);A<h&&(h=A,a&&a.copy(n),l&&l.copy(e))}}return Math.sqrt(h)}})();class li{constructor(e,t,i){this.isOrientedBox=!0,this.min=new v.Vector3,this.max=new v.Vector3,this.matrix=new v.Matrix4,this.invMatrix=new v.Matrix4,this.points=new Array(8).fill().map(()=>new v.Vector3),this.satAxes=new Array(3).fill().map(()=>new v.Vector3),this.satBounds=new Array(3).fill().map(()=>new Jn),this.alignedSatBounds=new Array(3).fill().map(()=>new Jn),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}li.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let c=0;c<=1;c++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){const f=1*c|2*h|4*d,u=s[f];u.x=c?i.x:t.x,u.y=h?i.y:t.y,u.z=d?i.z:t.z,u.applyMatrix4(e)}const r=this.satBounds,o=this.satAxes,a=s[0];for(let c=0;c<3;c++){const h=o[c],d=r[c],f=1<<c,u=s[f];h.subVectors(a,u),d.setFromPoints(h,s)}const l=this.alignedSatBounds;l[0].setFromPointsField(s,"x"),l[1].setFromPointsField(s,"y"),l[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),li.prototype.intersectsBox=(function(){const n=new Jn;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,r=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(n.min=i.x,n.max=s.x,a[0].isSeparated(n)||(n.min=i.y,n.max=s.y,a[1].isSeparated(n))||(n.min=i.z,n.max=s.z,a[2].isSeparated(n)))return!1;for(let l=0;l<3;l++){const c=o[l],h=r[l];if(n.setFromBox(c,t),h.isSeparated(n))return!1}return!0}})(),li.prototype.intersectsTriangle=(function(){const n=new Vi,e=new Array(3),t=new Jn,i=new Jn,s=new v.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(n.copy(o),n.update(),o=n);const a=this.satBounds,l=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let f=0;f<3;f++){const u=a[f],g=l[f];if(t.setFromPoints(g,e),u.isSeparated(t))return!1}const c=o.satBounds,h=o.satAxes,d=this.points;for(let f=0;f<3;f++){const u=c[f],g=h[f];if(t.setFromPoints(g,d),u.isSeparated(t))return!1}for(let f=0;f<3;f++){const u=l[f];for(let g=0;g<4;g++){const p=h[g];if(s.crossVectors(u,p),t.setFromPoints(s,e),i.setFromPoints(s,d),t.isSeparated(i))return!1}}return!0}})(),li.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})(),li.prototype.distanceToPoint=(function(){const n=new v.Vector3;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}})(),li.prototype.distanceToBox=(function(){const n=["x","y","z"],e=new Array(12).fill().map(()=>new v.Line3),t=new Array(12).fill().map(()=>new v.Line3),i=new v.Vector3,s=new v.Vector3;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),l&&l.copy(i),c&&c.copy(s)),0;const h=a*a,d=o.min,f=o.max,u=this.points;let g=1/0;for(let m=0;m<8;m++){const A=u[m];s.copy(A).clamp(d,f);const x=A.distanceToSquared(s);if(x<g&&(g=x,l&&l.copy(A),c&&c.copy(s),x<h))return Math.sqrt(x)}let p=0;for(let m=0;m<3;m++)for(let A=0;A<=1;A++)for(let x=0;x<=1;x++){const b=(m+1)%3,y=(m+2)%3,_=A<<b|x<<y,w=1<<m|A<<b|x<<y,S=u[_],D=u[w];e[p].set(S,D);const I=n[m],P=n[b],T=n[y],L=t[p],E=L.start,F=L.end;E[I]=d[I],E[P]=A?d[P]:f[P],E[T]=x?d[T]:f[P],F[I]=f[I],F[P]=A?d[P]:f[P],F[T]=x?d[T]:f[P],p++}for(let m=0;m<=1;m++)for(let A=0;A<=1;A++)for(let x=0;x<=1;x++){s.x=m?f.x:d.x,s.y=A?f.y:d.y,s.z=x?f.z:d.z,this.closestPointToPoint(s,i);const b=s.distanceToSquared(i);if(b<g&&(g=b,l&&l.copy(i),c&&c.copy(s),b<h))return Math.sqrt(b)}for(let m=0;m<12;m++){const A=e[m];for(let x=0;x<12;x++){const b=t[x];mf(A,b,i,s);const y=i.distanceToSquared(s);if(y<g&&(g=y,l&&l.copy(i),c&&c.copy(s),y<h))return Math.sqrt(y)}}return Math.sqrt(g)}})();class Af{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class $I extends Af{constructor(){super(()=>new Vi)}}const Qi=new $I;function Ht(n,e){return e[n+15]===_A}function Ii(n,e){return e[n+6]}function ji(n,e){return e[n+14]}function qt(n){return n+Wt}function Yt(n,e){const t=e[n+6];return n+t*Wt}function xf(n,e){return e[n+7]}function z6(n){return n}class ZI{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const vt=new ZI;let Es,Ao;const xo=[],Rc=new Af(()=>new v.Box3);function JI(n,e,t,i,s,r){Es=Rc.getPrimitive(),Ao=Rc.getPrimitive(),xo.push(Es,Ao),vt.setBuffer(n._roots[e]);const o=bf(0,n.geometry,t,i,s,r);vt.clearBuffer(),Rc.releasePrimitive(Es),Rc.releasePrimitive(Ao),xo.pop(),xo.pop();const a=xo.length;return a>0&&(Ao=xo[a-1],Es=xo[a-2]),o}function bf(n,e,t,i,s=null,r=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:c}=vt;let h=n*2;if(Ht(h,l)){const f=Ii(n,c),u=ji(h,l);return Et(n,a,Es),i(f,u,!1,o,r+n/Wt,Es)}else{let I=function(T){const{uint16Array:L,uint32Array:E}=vt;let F=T*2;for(;!Ht(F,L);)T=qt(T),F=T*2;return Ii(T,E)},P=function(T){const{uint16Array:L,uint32Array:E}=vt;let F=T*2;for(;!Ht(F,L);)T=Yt(T,E),F=T*2;return Ii(T,E)+ji(F,L)};const f=qt(n),u=Yt(n,c);let g=f,p=u,m,A,x,b;if(s&&(x=Es,b=Ao,Et(g,a,x),Et(p,a,b),m=s(x),A=s(b),A<m)){g=u,p=f;const T=m;m=A,A=T,x=b}x||(x=Es,Et(g,a,x));const y=Ht(g*2,l),_=t(x,y,m,o+1,r+g/Wt);let w;if(_===yA){const T=I(g),E=P(g)-T;w=i(T,E,!0,o+1,r+g/Wt,x)}else w=_&&bf(g,e,t,i,s,r,o+1);if(w)return!0;b=Ao,Et(p,a,b);const S=Ht(p*2,l),D=t(b,S,A,o+1,r+p/Wt);let M;if(D===yA){const T=I(p),E=P(p)-T;M=i(T,E,!0,o+1,r+p/Wt,b)}else M=D&&bf(p,e,t,i,s,r,o+1);return!!M}}const Ca=new v.Vector3,yf=new v.Vector3;function eT(n,e,t={},i=0,s=1/0){const r=i*i,o=s*s;let a=1/0,l=null;if(n.shapecast({boundsTraverseOrder:h=>(Ca.copy(e).clamp(h.min,h.max),Ca.distanceToSquared(e)),intersectsBounds:(h,d,f)=>f<a&&f<o,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,Ca);const f=e.distanceToSquared(Ca);return f<a&&(yf.copy(Ca),a=f,l=d),f<r}}),a===1/0)return null;const c=Math.sqrt(a);return t.point?t.point.copy(yf):t.point=yf.clone(),t.distance=c,t.faceIndex=l,t}const kc=parseInt(v.REVISION)>=169,tT=parseInt(v.REVISION)<=161,gr=new v.Vector3,mr=new v.Vector3,Ar=new v.Vector3,Fc=new v.Vector2,Oc=new v.Vector2,Uc=new v.Vector2,PA=new v.Vector3,LA=new v.Vector3,RA=new v.Vector3,wa=new v.Vector3;function iT(n,e,t,i,s,r,o,a){let l;if(r===v.BackSide?l=n.intersectTriangle(i,t,e,!0,s):l=n.intersectTriangle(e,t,i,r!==v.DoubleSide,s),l===null)return null;const c=n.origin.distanceTo(s);return c<o||c>a?null:{distance:c,point:s.clone()}}function kA(n,e,t,i,s,r,o,a,l,c,h){gr.fromBufferAttribute(e,r),mr.fromBufferAttribute(e,o),Ar.fromBufferAttribute(e,a);const d=iT(n,gr,mr,Ar,wa,l,c,h);if(d){if(i){Fc.fromBufferAttribute(i,r),Oc.fromBufferAttribute(i,o),Uc.fromBufferAttribute(i,a),d.uv=new v.Vector2;const u=v.Triangle.getInterpolation(wa,gr,mr,Ar,Fc,Oc,Uc,d.uv);kc||(d.uv=u)}if(s){Fc.fromBufferAttribute(s,r),Oc.fromBufferAttribute(s,o),Uc.fromBufferAttribute(s,a),d.uv1=new v.Vector2;const u=v.Triangle.getInterpolation(wa,gr,mr,Ar,Fc,Oc,Uc,d.uv1);kc||(d.uv1=u),tT&&(d.uv2=d.uv1)}if(t){PA.fromBufferAttribute(t,r),LA.fromBufferAttribute(t,o),RA.fromBufferAttribute(t,a),d.normal=new v.Vector3;const u=v.Triangle.getInterpolation(wa,gr,mr,Ar,PA,LA,RA,d.normal);d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1),kc||(d.normal=u)}const f={a:r,b:o,c:a,normal:new v.Vector3,materialIndex:0};if(v.Triangle.getNormal(gr,mr,Ar,f.normal),d.face=f,d.faceIndex=r,kc){const u=new v.Vector3;v.Triangle.getBarycoord(wa,gr,mr,Ar,u),d.barycoord=u}}return d}function FA(n){return n&&n.isMaterial?n.side:n}function Nc(n,e,t,i,s,r,o){const a=i*3;let l=a+0,c=a+1,h=a+2;const{index:d,groups:f}=n;n.index&&(l=d.getX(l),c=d.getX(c),h=d.getX(h));const{position:u,normal:g,uv:p,uv1:m}=n.attributes;if(Array.isArray(e)){const A=i*3;for(let x=0,b=f.length;x<b;x++){const{start:y,count:_,materialIndex:w}=f[x];if(A>=y&&A<y+_){const S=FA(e[w]),D=kA(t,u,g,p,m,l,c,h,S,r,o);if(D)if(D.faceIndex=i,D.face.materialIndex=w,s)s.push(D);else return D}}}else{const A=FA(e),x=kA(t,u,g,p,m,l,c,h,A,r,o);if(x)if(x.faceIndex=i,x.face.materialIndex=0,s)s.push(x);else return x}return null}function Ut(n,e,t,i){const s=n.a,r=n.b,o=n.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),s.x=i.getX(a),s.y=i.getY(a),s.z=i.getZ(a),r.x=i.getX(l),r.y=i.getY(l),r.z=i.getZ(l),o.x=i.getX(c),o.y=i.getY(c),o.z=i.getZ(c)}function nT(n,e,t,i,s,r,o,a){const{geometry:l,_indirectBuffer:c}=n;for(let h=i,d=i+s;h<d;h++)Nc(l,e,t,h,r,o,a)}function sT(n,e,t,i,s,r,o){const{geometry:a,_indirectBuffer:l}=n;let c=1/0,h=null;for(let d=i,f=i+s;d<f;d++){let u;u=Nc(a,e,t,d,null,r,o),u&&u.distance<c&&(h=u,c=u.distance)}return h}function rT(n,e,t,i,s,r,o){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=n,d=e+n;h<d;h++){let f;if(f=h,Ut(o,f*3,l,c),o.needsUpdate=!0,i(o,f,s,r))return!0}return!1}function oT(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,a,l,c=0;const h=n._roots;for(let f=0,u=h.length;f<u;f++)r=h[f],o=new Uint32Array(r),a=new Uint16Array(r),l=new Float32Array(r),d(0,c),c+=r.byteLength;function d(f,u,g=!1){const p=f*2;if(Ht(p,a)){const m=o[f+6],A=a[p+14];let x=1/0,b=1/0,y=1/0,_=-1/0,w=-1/0,S=-1/0;for(let D=3*m,M=3*(m+A);D<M;D++){let I=i[D];const P=s.getX(I),T=s.getY(I),L=s.getZ(I);P<x&&(x=P),P>_&&(_=P),T<b&&(b=T),T>w&&(w=T),L<y&&(y=L),L>S&&(S=L)}return l[f+0]!==x||l[f+1]!==b||l[f+2]!==y||l[f+3]!==_||l[f+4]!==w||l[f+5]!==S?(l[f+0]=x,l[f+1]=b,l[f+2]=y,l[f+3]=_,l[f+4]=w,l[f+5]=S,!0):!1}else{const m=qt(f),A=Yt(f,o);let x=g,b=!1,y=!1;if(e){if(!x){const I=m/Wt+u/ai,P=A/Wt+u/ai;b=e.has(I),y=e.has(P),x=!b&&!y}}else b=!0,y=!0;const _=x||b,w=x||y;let S=!1;_&&(S=d(m,u,x));let D=!1;w&&(D=d(A,u,x));const M=S||D;if(M)for(let I=0;I<3;I++){const P=m+I,T=A+I,L=l[P],E=l[P+3],F=l[T],z=l[T+3];l[f+I]=L<F?L:F,l[f+I+3]=E>z?E:z}return M}}}function Is(n,e,t,i,s){let r,o,a,l,c,h;const d=1/t.direction.x,f=1/t.direction.y,u=1/t.direction.z,g=t.origin.x,p=t.origin.y,m=t.origin.z;let A=e[n],x=e[n+3],b=e[n+1],y=e[n+3+1],_=e[n+2],w=e[n+3+2];return d>=0?(r=(A-g)*d,o=(x-g)*d):(r=(x-g)*d,o=(A-g)*d),f>=0?(a=(b-p)*f,l=(y-p)*f):(a=(y-p)*f,l=(b-p)*f),r>l||a>o||((a>r||isNaN(r))&&(r=a),(l<o||isNaN(o))&&(o=l),u>=0?(c=(_-m)*u,h=(w-m)*u):(c=(w-m)*u,h=(_-m)*u),r>h||c>o)?!1:((c>r||r!==r)&&(r=c),(h<o||o!==o)&&(o=h),r<=s&&o>=i)}function aT(n,e,t,i,s,r,o,a){const{geometry:l,_indirectBuffer:c}=n;for(let h=i,d=i+s;h<d;h++){let f=c?c[h]:h;Nc(l,e,t,f,r,o,a)}}function lT(n,e,t,i,s,r,o){const{geometry:a,_indirectBuffer:l}=n;let c=1/0,h=null;for(let d=i,f=i+s;d<f;d++){let u;u=Nc(a,e,t,l?l[d]:d,null,r,o),u&&u.distance<c&&(h=u,c=u.distance)}return h}function cT(n,e,t,i,s,r,o){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=n,d=e+n;h<d;h++){let f;if(f=t.resolveTriangleIndex(h),Ut(o,f*3,l,c),o.needsUpdate=!0,i(o,f,s,r))return!0}return!1}function hT(n,e,t,i,s,r,o){vt.setBuffer(n._roots[e]),vf(0,n,t,i,s,r,o),vt.clearBuffer()}function vf(n,e,t,i,s,r,o){const{float32Array:a,uint16Array:l,uint32Array:c}=vt,h=n*2;if(Ht(h,l)){const f=Ii(n,c),u=ji(h,l);nT(e,t,i,f,u,s,r,o)}else{const f=qt(n);Is(f,a,i,r,o)&&vf(f,e,t,i,s,r,o);const u=Yt(n,c);Is(u,a,i,r,o)&&vf(u,e,t,i,s,r,o)}}const dT=["x","y","z"];function uT(n,e,t,i,s,r){vt.setBuffer(n._roots[e]);const o=_f(0,n,t,i,s,r);return vt.clearBuffer(),o}function _f(n,e,t,i,s,r){const{float32Array:o,uint16Array:a,uint32Array:l}=vt;let c=n*2;if(Ht(c,a)){const d=Ii(n,l),f=ji(c,a);return sT(e,t,i,d,f,s,r)}else{const d=xf(n,l),f=dT[d],g=i.direction[f]>=0;let p,m;g?(p=qt(n),m=Yt(n,l)):(p=Yt(n,l),m=qt(n));const x=Is(p,o,i,s,r)?_f(p,e,t,i,s,r):null;if(x){const _=x.point[f];if(g?_<=o[m+d]:_>=o[m+d+3])return x}const y=Is(m,o,i,s,r)?_f(m,e,t,i,s,r):null;return x&&y?x.distance<=y.distance?x:y:x||y||null}}const zc=new v.Box3,bo=new Vi,yo=new Vi,Sa=new v.Matrix4,OA=new li,Gc=new li;function fT(n,e,t,i){vt.setBuffer(n._roots[e]);const s=Cf(0,n,t,i);return vt.clearBuffer(),s}function Cf(n,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:a}=vt;let l=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),OA.set(t.boundingBox.min,t.boundingBox.max,i),s=OA),Ht(l,o)){const h=e.geometry,d=h.index,f=h.attributes.position,u=t.index,g=t.attributes.position,p=Ii(n,a),m=ji(l,o);if(Sa.copy(i).invert(),t.boundsTree)return Et(n,r,Gc),Gc.matrix.copy(Sa),Gc.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Gc.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(i),x.b.applyMatrix4(i),x.c.applyMatrix4(i),x.needsUpdate=!0;for(let b=p*3,y=(m+p)*3;b<y;b+=3)if(Ut(yo,b,d,f),yo.needsUpdate=!0,x.intersectsTriangle(yo))return!0;return!1}});{const A=pr(t);for(let x=p*3,b=(m+p)*3;x<b;x+=3){Ut(bo,x,d,f),bo.a.applyMatrix4(Sa),bo.b.applyMatrix4(Sa),bo.c.applyMatrix4(Sa),bo.needsUpdate=!0;for(let y=0,_=A*3;y<_;y+=3)if(Ut(yo,y,u,g),yo.needsUpdate=!0,bo.intersectsTriangle(yo))return!0}}}else{const h=qt(n),d=Yt(n,a);return Et(h,r,zc),!!(s.intersectsBox(zc)&&Cf(h,e,t,i,s)||(Et(d,r,zc),s.intersectsBox(zc)&&Cf(d,e,t,i,s)))}}const Vc=new v.Matrix4,wf=new li,Ma=new li,pT=new v.Vector3,gT=new v.Vector3,mT=new v.Vector3,AT=new v.Vector3;function xT(n,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),wf.set(e.boundingBox.min,e.boundingBox.max,t),wf.needsUpdate=!0;const a=n.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,d=e.index,f=Qi.getPrimitive(),u=Qi.getPrimitive();let g=pT,p=gT,m=null,A=null;s&&(m=mT,A=AT);let x=1/0,b=null,y=null;return Vc.copy(t).invert(),Ma.matrix.copy(Vc),n.shapecast({boundsTraverseOrder:_=>wf.distanceToBox(_),intersectsBounds:(_,w,S)=>S<x&&S<o?(w&&(Ma.min.copy(_.min),Ma.max.copy(_.max),Ma.needsUpdate=!0),!0):!1,intersectsRange:(_,w)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:D=>Ma.distanceToBox(D),intersectsBounds:(D,M,I)=>I<x&&I<o,intersectsRange:(D,M)=>{for(let I=D,P=D+M;I<P;I++){Ut(u,3*I,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let T=_,L=_+w;T<L;T++){Ut(f,3*T,c,l),f.needsUpdate=!0;const E=f.distanceToTriangle(u,g,m);if(E<x&&(p.copy(g),A&&A.copy(m),x=E,b=T,y=I),E<r)return!0}}}});{const S=pr(e);for(let D=0,M=S;D<M;D++){Ut(u,3*D,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let I=_,P=_+w;I<P;I++){Ut(f,3*I,c,l),f.needsUpdate=!0;const T=f.distanceToTriangle(u,g,m);if(T<x&&(p.copy(g),A&&A.copy(m),x=T,b=I,y=D),T<r)return!0}}}}}),Qi.releasePrimitive(f),Qi.releasePrimitive(u),x===1/0?null:(i.point?i.point.copy(p):i.point=p.clone(),i.distance=x,i.faceIndex=b,s&&(s.point?s.point.copy(A):s.point=A.clone(),s.point.applyMatrix4(Vc),p.applyMatrix4(Vc),s.distance=p.sub(s.point).length(),s.faceIndex=y),i)}function bT(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,a,l,c=0;const h=n._roots;for(let f=0,u=h.length;f<u;f++)r=h[f],o=new Uint32Array(r),a=new Uint16Array(r),l=new Float32Array(r),d(0,c),c+=r.byteLength;function d(f,u,g=!1){const p=f*2;if(Ht(p,a)){const m=o[f+6],A=a[p+14];let x=1/0,b=1/0,y=1/0,_=-1/0,w=-1/0,S=-1/0;for(let D=m,M=m+A;D<M;D++){const I=3*n.resolveTriangleIndex(D);for(let P=0;P<3;P++){let T=I+P;T=i?i[T]:T;const L=s.getX(T),E=s.getY(T),F=s.getZ(T);L<x&&(x=L),L>_&&(_=L),E<b&&(b=E),E>w&&(w=E),F<y&&(y=F),F>S&&(S=F)}}return l[f+0]!==x||l[f+1]!==b||l[f+2]!==y||l[f+3]!==_||l[f+4]!==w||l[f+5]!==S?(l[f+0]=x,l[f+1]=b,l[f+2]=y,l[f+3]=_,l[f+4]=w,l[f+5]=S,!0):!1}else{const m=qt(f),A=Yt(f,o);let x=g,b=!1,y=!1;if(e){if(!x){const I=m/Wt+u/ai,P=A/Wt+u/ai;b=e.has(I),y=e.has(P),x=!b&&!y}}else b=!0,y=!0;const _=x||b,w=x||y;let S=!1;_&&(S=d(m,u,x));let D=!1;w&&(D=d(A,u,x));const M=S||D;if(M)for(let I=0;I<3;I++){const P=m+I,T=A+I,L=l[P],E=l[P+3],F=l[T],z=l[T+3];l[f+I]=L<F?L:F,l[f+I+3]=E>z?E:z}return M}}}function yT(n,e,t,i,s,r,o){vt.setBuffer(n._roots[e]),Sf(0,n,t,i,s,r,o),vt.clearBuffer()}function Sf(n,e,t,i,s,r,o){const{float32Array:a,uint16Array:l,uint32Array:c}=vt,h=n*2;if(Ht(h,l)){const f=Ii(n,c),u=ji(h,l);aT(e,t,i,f,u,s,r,o)}else{const f=qt(n);Is(f,a,i,r,o)&&Sf(f,e,t,i,s,r,o);const u=Yt(n,c);Is(u,a,i,r,o)&&Sf(u,e,t,i,s,r,o)}}const vT=["x","y","z"];function _T(n,e,t,i,s,r){vt.setBuffer(n._roots[e]);const o=Mf(0,n,t,i,s,r);return vt.clearBuffer(),o}function Mf(n,e,t,i,s,r){const{float32Array:o,uint16Array:a,uint32Array:l}=vt;let c=n*2;if(Ht(c,a)){const d=Ii(n,l),f=ji(c,a);return lT(e,t,i,d,f,s,r)}else{const d=xf(n,l),f=vT[d],g=i.direction[f]>=0;let p,m;g?(p=qt(n),m=Yt(n,l)):(p=Yt(n,l),m=qt(n));const x=Is(p,o,i,s,r)?Mf(p,e,t,i,s,r):null;if(x){const _=x.point[f];if(g?_<=o[m+d]:_>=o[m+d+3])return x}const y=Is(m,o,i,s,r)?Mf(m,e,t,i,s,r):null;return x&&y?x.distance<=y.distance?x:y:x||y||null}}const Qc=new v.Box3,vo=new Vi,_o=new Vi,Ea=new v.Matrix4,UA=new li,jc=new li;function CT(n,e,t,i){vt.setBuffer(n._roots[e]);const s=Ef(0,n,t,i);return vt.clearBuffer(),s}function Ef(n,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:a}=vt;let l=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),UA.set(t.boundingBox.min,t.boundingBox.max,i),s=UA),Ht(l,o)){const h=e.geometry,d=h.index,f=h.attributes.position,u=t.index,g=t.attributes.position,p=Ii(n,a),m=ji(l,o);if(Ea.copy(i).invert(),t.boundsTree)return Et(n,r,jc),jc.matrix.copy(Ea),jc.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>jc.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(i),x.b.applyMatrix4(i),x.c.applyMatrix4(i),x.needsUpdate=!0;for(let b=p,y=m+p;b<y;b++)if(Ut(_o,3*e.resolveTriangleIndex(b),d,f),_o.needsUpdate=!0,x.intersectsTriangle(_o))return!0;return!1}});{const A=pr(t);for(let x=p,b=m+p;x<b;x++){const y=e.resolveTriangleIndex(x);Ut(vo,3*y,d,f),vo.a.applyMatrix4(Ea),vo.b.applyMatrix4(Ea),vo.c.applyMatrix4(Ea),vo.needsUpdate=!0;for(let _=0,w=A*3;_<w;_+=3)if(Ut(_o,_,u,g),_o.needsUpdate=!0,vo.intersectsTriangle(_o))return!0}}}else{const h=qt(n),d=Yt(n,a);return Et(h,r,Qc),!!(s.intersectsBox(Qc)&&Ef(h,e,t,i,s)||(Et(d,r,Qc),s.intersectsBox(Qc)&&Ef(d,e,t,i,s)))}}const Wc=new v.Matrix4,If=new li,Ia=new li,wT=new v.Vector3,ST=new v.Vector3,MT=new v.Vector3,ET=new v.Vector3;function IT(n,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),If.set(e.boundingBox.min,e.boundingBox.max,t),If.needsUpdate=!0;const a=n.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,d=e.index,f=Qi.getPrimitive(),u=Qi.getPrimitive();let g=wT,p=ST,m=null,A=null;s&&(m=MT,A=ET);let x=1/0,b=null,y=null;return Wc.copy(t).invert(),Ia.matrix.copy(Wc),n.shapecast({boundsTraverseOrder:_=>If.distanceToBox(_),intersectsBounds:(_,w,S)=>S<x&&S<o?(w&&(Ia.min.copy(_.min),Ia.max.copy(_.max),Ia.needsUpdate=!0),!0):!1,intersectsRange:(_,w)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:D=>Ia.distanceToBox(D),intersectsBounds:(D,M,I)=>I<x&&I<o,intersectsRange:(D,M)=>{for(let I=D,P=D+M;I<P;I++){const T=S.resolveTriangleIndex(I);Ut(u,3*T,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let L=_,E=_+w;L<E;L++){const F=n.resolveTriangleIndex(L);Ut(f,3*F,c,l),f.needsUpdate=!0;const z=f.distanceToTriangle(u,g,m);if(z<x&&(p.copy(g),A&&A.copy(m),x=z,b=L,y=I),z<r)return!0}}}})}else{const S=pr(e);for(let D=0,M=S;D<M;D++){Ut(u,3*D,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let I=_,P=_+w;I<P;I++){const T=n.resolveTriangleIndex(I);Ut(f,3*T,c,l),f.needsUpdate=!0;const L=f.distanceToTriangle(u,g,m);if(L<x&&(p.copy(g),A&&A.copy(m),x=L,b=I,y=D),L<r)return!0}}}}}),Qi.releasePrimitive(f),Qi.releasePrimitive(u),x===1/0?null:(i.point?i.point.copy(p):i.point=p.clone(),i.distance=x,i.faceIndex=b,s&&(s.point?s.point.copy(A):s.point=A.clone(),s.point.applyMatrix4(Wc),p.applyMatrix4(Wc),s.distance=p.sub(s.point).length(),s.faceIndex=y),i)}function TT(){return typeof SharedArrayBuffer<"u"}const Ta=new vt.constructor,Hc=new vt.constructor,Ts=new Af(()=>new v.Box3),Co=new v.Box3,wo=new v.Box3,Tf=new v.Box3,Df=new v.Box3;let Bf=!1;function DT(n,e,t,i){if(Bf)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Bf=!0;const s=n._roots,r=e._roots;let o,a=0,l=0;const c=new v.Matrix4().copy(t).invert();for(let h=0,d=s.length;h<d;h++){Ta.setBuffer(s[h]),l=0;const f=Ts.getPrimitive();Et(0,Ta.float32Array,f),f.applyMatrix4(c);for(let u=0,g=r.length;u<g&&(Hc.setBuffer(r[u]),o=sn(0,0,t,c,i,a,l,0,0,f),Hc.clearBuffer(),l+=r[u].byteLength/ai,!o);u++);if(Ts.releasePrimitive(f),Ta.clearBuffer(),a+=s[h].byteLength/ai,o)break}return Bf=!1,o}function sn(n,e,t,i,s,r=0,o=0,a=0,l=0,c=null,h=!1){let d,f;h?(d=Hc,f=Ta):(d=Ta,f=Hc);const u=d.float32Array,g=d.uint32Array,p=d.uint16Array,m=f.float32Array,A=f.uint32Array,x=f.uint16Array,b=n*2,y=e*2,_=Ht(b,p),w=Ht(y,x);let S=!1;if(w&&_)h?S=s(Ii(e,A),ji(e*2,x),Ii(n,g),ji(n*2,p),l,o+e/Wt,a,r+n/Wt):S=s(Ii(n,g),ji(n*2,p),Ii(e,A),ji(e*2,x),a,r+n/Wt,l,o+e/Wt);else if(w){const D=Ts.getPrimitive();Et(e,m,D),D.applyMatrix4(t);const M=qt(n),I=Yt(n,g);Et(M,u,Co),Et(I,u,wo);const P=D.intersectsBox(Co),T=D.intersectsBox(wo);S=P&&sn(e,M,i,t,s,o,r,l,a+1,D,!h)||T&&sn(e,I,i,t,s,o,r,l,a+1,D,!h),Ts.releasePrimitive(D)}else{const D=qt(e),M=Yt(e,A);Et(D,m,Tf),Et(M,m,Df);const I=c.intersectsBox(Tf),P=c.intersectsBox(Df);if(I&&P)S=sn(n,D,t,i,s,r,o,a,l+1,c,h)||sn(n,M,t,i,s,r,o,a,l+1,c,h);else if(I)if(_)S=sn(n,D,t,i,s,r,o,a,l+1,c,h);else{const T=Ts.getPrimitive();T.copy(Tf).applyMatrix4(t);const L=qt(n),E=Yt(n,g);Et(L,u,Co),Et(E,u,wo);const F=T.intersectsBox(Co),z=T.intersectsBox(wo);S=F&&sn(D,L,i,t,s,o,r,l,a+1,T,!h)||z&&sn(D,E,i,t,s,o,r,l,a+1,T,!h),Ts.releasePrimitive(T)}else if(P)if(_)S=sn(n,M,t,i,s,r,o,a,l+1,c,h);else{const T=Ts.getPrimitive();T.copy(Df).applyMatrix4(t);const L=qt(n),E=Yt(n,g);Et(L,u,Co),Et(E,u,wo);const F=T.intersectsBox(Co),z=T.intersectsBox(wo);S=F&&sn(M,L,i,t,s,o,r,l,a+1,T,!h)||z&&sn(M,E,i,t,s,o,r,l,a+1,T,!h),Ts.releasePrimitive(T)}}return S}const Xc=new li,NA=new v.Box3,BT={strategy:bA,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Pf{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,r=e._indirectBuffer,o=i.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(a.roots=s.map(l=>l.slice()),a.index=o?o.array.slice():null,a.indirectBuffer=r?r.slice():null):(a.roots=s,a.index=o?o.array:null,a.indirectBuffer=r),a}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:r,indirectBuffer:o}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),l(r));const a=new Pf(t,{...i,[hf]:!0});if(a._roots=r,a._indirectBuffer=o||null,i.setIndex){const c=t.getIndex();if(c===null){const h=new v.BufferAttribute(e.index,1,!1);t.setIndex(h)}else c.array!==s&&(c.array.set(s),c.needsUpdate=!0)}return a;function l(c){for(let h=0;h<c.length;h++){const d=c[h],f=new Uint32Array(d),u=new Uint16Array(d);for(let g=0,p=d.byteLength/ai;g<p;g++){const m=Wt*g,A=2*m;Ht(A,u)||(f[m+6]=f[m+6]/Wt-g)}}}}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...BT,[hf]:!1},t),t.useSharedArrayBuffer&&!TT())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[hf]||(XI(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new v.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}shiftTriangleOffsets(e){const t=this._indirectBuffer;if(t)for(let i=0,s=t.length;i<s;i++)t[i]+=e;else{const i=this._roots;for(let s=0;s<i.length;s++){const r=i[s],o=new Uint32Array(r),a=new Uint16Array(r),l=r.byteLength/ai;for(let c=0;c<l;c++){const h=Wt*c,d=2*h;Ht(d,a)&&(o[h+6]+=e)}}}}refit(e=null){return(this.indirect?bT:oT)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),r=new Uint16Array(i);o(0);function o(a,l=0){const c=a*2,h=Ht(c,r);if(h){const d=s[a+6],f=r[c+14];e(l,h,new Float32Array(i,a*4,6),d,f)}else{const d=qt(a),f=Yt(a,s),u=xf(a,s);e(l,h,new Float32Array(i,a*4,6),u)||(o(d,l+1),o(f,l+1))}}}raycast(e,t=v.FrontSide,i=0,s=1/0){const r=this._roots,o=[],a=this.indirect?yT:hT;for(let l=0,c=r.length;l<c;l++)a(this,l,t,e,o,i,s);return o}raycastFirst(e,t=v.FrontSide,i=0,s=1/0){const r=this._roots;let o=null;const a=this.indirect?_T:uT;for(let l=0,c=r.length;l<c;l++){const h=a(this,l,t,e,i,s);h!=null&&(o==null||h.distance<o.distance)&&(o=h)}return o}intersectsGeometry(e,t){let i=!1;const s=this._roots,r=this.indirect?CT:fT;for(let o=0,a=s.length;o<a&&(i=r(this,o,e,t),!i);o++);return i}shapecast(e){const t=Qi.getPrimitive(),i=this.indirect?cT:rT;let{boundsTraverseOrder:s,intersectsBounds:r,intersectsRange:o,intersectsTriangle:a}=e;if(o&&a){const d=o;o=(f,u,g,p,m)=>d(f,u,g,p,m)?!0:i(f,u,this,a,g,p,t)}else o||(a?o=(d,f,u,g)=>i(d,f,this,a,u,g,t):o=(d,f,u)=>u);let l=!1,c=0;const h=this._roots;for(let d=0,f=h.length;d<f;d++){const u=h[d];if(l=JI(this,d,r,o,s,c),l)break;c+=u.byteLength/ai}return Qi.releasePrimitive(t),l}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:r}=i;const o=Qi.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?g=>{const p=this.resolveTriangleIndex(g);Ut(o,p*3,a,l)}:g=>{Ut(o,g*3,a,l)},h=Qi.getPrimitive(),d=e.geometry.index,f=e.geometry.attributes.position,u=e.indirect?g=>{const p=e.resolveTriangleIndex(g);Ut(h,p*3,d,f)}:g=>{Ut(h,g*3,d,f)};if(r){const g=(p,m,A,x,b,y,_,w)=>{for(let S=A,D=A+x;S<D;S++){u(S),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let M=p,I=p+m;M<I;M++)if(c(M),o.needsUpdate=!0,r(o,h,M,S,b,y,_,w))return!0}return!1};if(s){const p=s;s=function(m,A,x,b,y,_,w,S){return p(m,A,x,b,y,_,w,S)?!0:g(m,A,x,b,y,_,w,S)}}else s=g}return DT(this,e,t,s)}intersectsBox(e,t){return Xc.set(e.min,e.max,t),Xc.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Xc.intersectsBox(i),intersectsTriangle:i=>Xc.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},r=0,o=1/0){return(this.indirect?IT:xT)(this,e,t,i,s,r,o)}closestPointToPoint(e,t={},i=0,s=1/0){return eT(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{Et(0,new Float32Array(i),NA),e.union(NA)}),e}}const zA=1e-6,PT=zA*.5,GA=Math.pow(10,-Math.log10(zA)),LT=PT*GA;function wn(n){return~~(n*GA+LT)}function RT(n){return`${wn(n.x)},${wn(n.y)}`}function VA(n){return`${wn(n.x)},${wn(n.y)},${wn(n.z)}`}function kT(n){return`${wn(n.x)},${wn(n.y)},${wn(n.z)},${wn(n.w)}`}function FT(n,e,t){t.direction.subVectors(e,n).normalize();const i=n.dot(t.direction);return t.origin.copy(n).addScaledVector(t.direction,-i),t}function QA(){return typeof SharedArrayBuffer<"u"}function OT(n){if(n.buffer instanceof SharedArrayBuffer)return n;const e=n.constructor,t=n.buffer,i=new SharedArrayBuffer(t.byteLength),s=new Uint8Array(t);return new Uint8Array(i).set(s,0),new e(i)}function UT(n,e=ArrayBuffer){return n>65535?new Uint32Array(new e(4*n)):new Uint16Array(new e(2*n))}function NT(n,e){if(!n.index){const t=n.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=UT(t,i);n.setIndex(new v.BufferAttribute(s,1));for(let r=0;r<t;r++)s[r]=r}}function zT(n){return n.index?n.index.count:n.attributes.position.count}function Lf(n){return zT(n)/3}const GT=1e-8,VT=new v.Vector3;function QT(n){return~~(n/3)}function jT(n){return n%3}function jA(n,e){return n.start-e.start}function WA(n,e){return VT.subVectors(e,n.origin).dot(n.direction)}function WT(n,e,t,i=GT){n.sort(jA),e.sort(jA);for(let a=0;a<n.length;a++){const l=n[a];for(let c=0;c<e.length;c++){const h=e[c];if(!(h.start>l.end)){if(l.end<h.start||h.end<l.start)continue;if(l.start<=h.start&&l.end>=h.end)r(h.end,l.end)||n.splice(a+1,0,{start:h.end,end:l.end,index:l.index}),l.end=h.start,h.start=0,h.end=0;else if(l.start>=h.start&&l.end<=h.end)r(l.end,h.end)||e.splice(c+1,0,{start:l.end,end:h.end,index:h.index}),h.end=l.start,l.start=0,l.end=0;else if(l.start<=h.start&&l.end<=h.end){const d=l.end;l.end=h.start,h.start=d}else if(l.start>=h.start&&l.end>=h.end){const d=h.end;h.end=l.start,l.start=d}else throw new Error}if(t.has(l.index)||t.set(l.index,[]),t.has(h.index)||t.set(h.index,[]),t.get(l.index).push(h.index),t.get(h.index).push(l.index),o(h)&&(e.splice(c,1),c--),o(l)){n.splice(a,1),a--;break}}}s(n),s(e);function s(a){for(let l=0;l<a.length;l++)o(a[l])&&(a.splice(l,1),l--)}function r(a,l){return Math.abs(l-a)<i}function o(a){return Math.abs(a.end-a.start)<i}}const HA=1e-5,XA=1e-4;class HT{constructor(){this._rays=[]}addRay(e){this._rays.push(e)}findClosestRay(e){const t=this._rays,i=e.clone();i.direction.multiplyScalar(-1);let s=1/0,r=null;for(let l=0,c=t.length;l<c;l++){const h=t[l];if(o(h,e)&&o(h,i))continue;const d=a(h,e),f=a(h,i),u=Math.min(d,f);u<s&&(s=u,r=h)}return r;function o(l,c){const h=l.origin.distanceTo(c.origin)>HA;return l.direction.angleTo(c.direction)>XA||h}function a(l,c){const h=l.origin.distanceTo(c.origin),d=l.direction.angleTo(c.direction);return h/HA+d/XA}}}const Rf=new v.Vector3,kf=new v.Vector3,qc=new v.Ray;function XT(n,e,t){const i=n.attributes,s=n.index,r=i.position,o=new Map,a=new Map,l=Array.from(e),c=new HT;for(let h=0,d=l.length;h<d;h++){const f=l[h],u=QT(f),g=jT(f);let p=3*u+g,m=3*u+(g+1)%3;s&&(p=s.getX(p),m=s.getX(m)),Rf.fromBufferAttribute(r,p),kf.fromBufferAttribute(r,m),FT(Rf,kf,qc);let A,x=c.findClosestRay(qc);x===null&&(x=qc.clone(),c.addRay(x)),a.has(x)||a.set(x,{forward:[],reverse:[],ray:x}),A=a.get(x);let b=WA(x,Rf),y=WA(x,kf);b>y&&([b,y]=[y,b]),qc.direction.dot(x.direction)<0?A.reverse.push({start:b,end:y,index:f}):A.forward.push({start:b,end:y,index:f})}return a.forEach(({forward:h,reverse:d},f)=>{WT(h,d,o,t),h.length===0&&d.length===0&&a.delete(f)}),{disjointConnectivityMap:o,fragmentMap:a}}const qT=new v.Vector2,Ff=new v.Vector3,YT=new v.Vector4,Of=["","",""];class KT{constructor(e=null){this.data=null,this.disjointConnections=null,this.unmatchedDisjointEdges=null,this.unmatchedEdges=-1,this.matchedEdges=-1,this.useDrawRange=!0,this.useAllAttributes=!1,this.matchDisjointEdges=!1,this.degenerateEpsilon=1e-8,e&&this.updateFrom(e)}getSiblingTriangleIndex(e,t){const i=this.data[e*3+t];return i===-1?-1:~~(i/3)}getSiblingEdgeIndex(e,t){const i=this.data[e*3+t];return i===-1?-1:i%3}getDisjointSiblingTriangleIndices(e,t){const i=e*3+t,s=this.disjointConnections.get(i);return s?s.map(r=>~~(r/3)):[]}getDisjointSiblingEdgeIndices(e,t){const i=e*3+t,s=this.disjointConnections.get(i);return s?s.map(r=>r%3):[]}isFullyConnected(){return this.unmatchedEdges===0}updateFrom(e){const{useAllAttributes:t,useDrawRange:i,matchDisjointEdges:s,degenerateEpsilon:r}=this,o=t?b:x,a=new Map,{attributes:l}=e,c=t?Object.keys(l):null,h=e.index,d=l.position;let f=Lf(e);const u=f;let g=0;i&&(g=e.drawRange.start,e.drawRange.count!==1/0&&(f=~~(e.drawRange.count/3)));let p=this.data;(!p||p.length<3*u)&&(p=new Int32Array(3*u)),p.fill(-1);let m=0,A=new Set;for(let y=g,_=f*3+g;y<_;y+=3){const w=y;for(let S=0;S<3;S++){let D=w+S;h&&(D=h.getX(D)),Of[S]=o(D)}for(let S=0;S<3;S++){const D=(S+1)%3,M=Of[S],I=Of[D],P=`${I}_${M}`;if(a.has(P)){const T=w+S,L=a.get(P);p[T]=L,p[L]=T,a.delete(P),m+=2,A.delete(L)}else{const T=`${M}_${I}`,L=w+S;a.set(T,L),A.add(L)}}}if(s){const{fragmentMap:y,disjointConnectivityMap:_}=XT(e,A,r);A.clear(),y.forEach(({forward:w,reverse:S})=>{w.forEach(({index:D})=>A.add(D)),S.forEach(({index:D})=>A.add(D))}),this.unmatchedDisjointEdges=y,this.disjointConnections=_,m=f*3-A.size}this.matchedEdges=m,this.unmatchedEdges=A.size,this.data=p;function x(y){return Ff.fromBufferAttribute(d,y),VA(Ff)}function b(y){let _="";for(let w=0,S=c.length;w<S;w++){const D=l[c[w]];let M;switch(D.itemSize){case 1:M=wn(D.getX(y));break;case 2:M=RT(qT.fromBufferAttribute(D,y));break;case 3:M=VA(Ff.fromBufferAttribute(D,y));break;case 4:M=kT(YT.fromBufferAttribute(D,y));break}_!==""&&(_+="|"),_+=M}return _}}}class Yc extends v.Mesh{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new v.Matrix4,this._previousMatrix.elements.fill(0)}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){const{matrix:e,_previousMatrix:t}=this,i=e.elements,s=t.elements;for(let r=0;r<16;r++)if(i[r]!==s[r])return!0;return!1}prepareGeometry(){const e=this.geometry,t=e.attributes,i=QA();if(i)for(const s in t){const r=t[s];if(r.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");r.array=OT(r.array)}if(e.boundsTree||(NT(e,{useSharedArrayBuffer:i}),e.boundsTree=new Pf(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:i})),e.halfEdges||(e.halfEdges=new KT(e)),!e.groupIndices){const s=Lf(e),r=new Uint16Array(s),o=e.groups;for(let a=0,l=o.length;a<l;a++){const{start:c,count:h}=o[a];for(let d=c/3,f=(c+h)/3;d<f;d++)r[d]=a}e.groupIndices=r}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const $T=1e-14,Uf=new v.Vector3,qA=new v.Vector3,YA=new v.Vector3;function Ds(n,e=$T){Uf.subVectors(n.b,n.a),qA.subVectors(n.c,n.a),YA.subVectors(n.b,n.c);const t=Uf.angleTo(qA),i=Uf.angleTo(YA),s=Math.PI-t-i;return Math.abs(t)<e||Math.abs(i)<e||Math.abs(s)<e||n.a.distanceToSquared(n.b)<e||n.a.distanceToSquared(n.c)<e||n.b.distanceToSquared(n.c)<e}const Nf=1e-10,Da=1e-10,ZT=1e-10,ts=new v.Line3,kt=new v.Line3,is=new v.Vector3,zf=new v.Vector3,KA=new v.Vector3,Kc=new v.Plane,Gf=new Vi;class JT{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new v.Triangle),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class e5{constructor(){this.trianglePool=new JT,this.triangles=[],this.normal=new v.Vector3,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:i,normal:s}=this;if(Array.isArray(e))for(let r=0,o=e.length;r<o;r++){const a=e[r];if(r===0)a.getNormal(s);else if(Math.abs(1-a.getNormal(is).dot(s))>Nf)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");const l=i.getTriangle();l.copy(a),t.push(l)}else{e.getNormal(s);const r=i.getTriangle();r.copy(e),t.push(r)}}splitByTriangle(e){const{normal:t,triangles:i}=this;if(e.getNormal(zf).normalize(),Math.abs(1-Math.abs(zf.dot(t)))<ZT){this.coplanarTriangleUsed=!0;for(let r=0,o=i.length;r<o;r++){const a=i[r];a.coplanarCount=0}const s=[e.a,e.b,e.c];for(let r=0;r<3;r++){const o=(r+1)%3,a=s[r],l=s[o];is.subVectors(l,a).normalize(),KA.crossVectors(zf,is),Kc.setFromNormalAndCoplanarPoint(KA,a),this.splitByPlane(Kc,e)}}else e.getPlane(Kc),this.splitByPlane(Kc,e)}splitByPlane(e,t){const{triangles:i,trianglePool:s}=this;Gf.copy(t),Gf.needsUpdate=!0;for(let r=0,o=i.length;r<o;r++){const a=i[r];if(!Gf.intersectsTriangle(a,ts,!0))continue;const{a:l,b:c,c:h}=a;let d=0,f=-1,u=!1,g=[],p=[];const m=[l,c,h];for(let A=0;A<3;A++){const x=(A+1)%3;ts.start.copy(m[A]),ts.end.copy(m[x]);const b=e.distanceToPoint(ts.start),y=e.distanceToPoint(ts.end);if(Math.abs(b)<Da&&Math.abs(y)<Da){u=!0;break}if(b>0?g.push(A):p.push(A),Math.abs(b)<Da)continue;let _=!!e.intersectLine(ts,is);!_&&Math.abs(y)<Da&&(is.copy(ts.end),_=!0),_&&!(is.distanceTo(ts.start)<Nf)&&(is.distanceTo(ts.end)<Nf&&(f=A),d===0?kt.start.copy(is):kt.end.copy(is),d++)}if(!u&&d===2&&kt.distance()>Da)if(f!==-1){f=(f+1)%3;let A=0;A===f&&(A=(A+1)%3);let x=A+1;x===f&&(x=(x+1)%3);const b=s.getTriangle();b.a.copy(m[x]),b.b.copy(kt.end),b.c.copy(kt.start),Ds(b)||i.push(b),a.a.copy(m[A]),a.b.copy(kt.start),a.c.copy(kt.end),Ds(a)&&(i.splice(r,1),r--,o--)}else{const A=g.length>=2?p[0]:g[0];if(A===0){let w=kt.start;kt.start=kt.end,kt.end=w}const x=(A+1)%3,b=(A+2)%3,y=s.getTriangle(),_=s.getTriangle();m[x].distanceToSquared(kt.start)<m[b].distanceToSquared(kt.end)?(y.a.copy(m[x]),y.b.copy(kt.start),y.c.copy(kt.end),_.a.copy(m[x]),_.b.copy(m[b]),_.c.copy(kt.start)):(y.a.copy(m[b]),y.b.copy(kt.start),y.c.copy(kt.end),_.a.copy(m[x]),_.b.copy(m[b]),_.c.copy(kt.end)),a.a.copy(m[A]),a.b.copy(kt.end),a.c.copy(kt.start),Ds(y)||i.push(y),Ds(_)||i.push(_),Ds(a)&&(i.splice(r,1),r--,o--)}else d===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}function t5(n){return n=~~n,n+4-n%4}class $A{constructor(e,t=500){this.expansionFactor=1.5,this.type=e,this.length=0,this.array=null,this.setSize(t)}setType(e){if(this.length!==0)throw new Error("TypeBackedArray: Cannot change the type while there is used data in the buffer.");const t=this.array.buffer;this.array=new e(t),this.type=e}setSize(e){if(this.array&&e===this.array.length)return;const t=this.type,i=QA()?SharedArrayBuffer:ArrayBuffer,s=new t(new i(t5(e*t.BYTES_PER_ELEMENT)));this.array&&s.set(this.array,0),this.array=s}expand(){const{array:e,expansionFactor:t}=this;this.setSize(e.length*t)}push(...e){let{array:t,length:i}=this;i+e.length>t.length&&(this.expand(),t=this.array);for(let s=0,r=e.length;s<r;s++)t[i+s]=e[s];this.length+=e.length}clear(){this.length=0}}class i5{constructor(){this.groupAttributes=[{}],this.groupCount=0}getType(e){return this.groupAttributes[0][e].type}getItemSize(e){return this.groupAttributes[0][e].itemSize}getNormalized(e){return this.groupAttributes[0][e].normalized}getCount(e){if(this.groupCount<=e)return 0;const t=this.getGroupAttrArray("position",e);return t.length/t.itemSize}getTotalLength(e){const{groupCount:t,groupAttributes:i}=this;let s=0;for(let r=0;r<t;r++){const o=i[r];s+=o[e].length}return s}getGroupAttrSet(e=0){const{groupAttributes:t}=this;if(t[e])return this.groupCount=Math.max(this.groupCount,e+1),t[e];const i=t[0];for(this.groupCount=Math.max(this.groupCount,e+1);e>=t.length;){const s={};t.push(s);for(const r in i){const o=i[r],a=new $A(o.type);a.itemSize=o.itemSize,a.normalized=o.normalized,s[r]=a}}return t[e]}getGroupAttrArray(e,t=0){const{groupAttributes:i}=this;if(!i[0][e])throw new Error(`TypedAttributeData: Attribute with "${e}" has not been initialized`);return this.getGroupAttrSet(t)[e]}initializeArray(e,t,i,s){const{groupAttributes:r}=this,a=r[0][e];if(a){if(a.type!==t)for(let l=0,c=r.length;l<c;l++){const h=r[l][e];h.setType(t),h.itemSize=i,h.normalized=s}}else for(let l=0,c=r.length;l<c;l++){const h=new $A(t);h.itemSize=i,h.normalized=s,r[l][e]=h}}clear(){this.groupCount=0;const{groupAttributes:e}=this;e.forEach(t=>{for(const i in t)t[i].clear()})}delete(e){this.groupAttributes.forEach(t=>{delete t[e]})}reset(){this.groupAttributes=[],this.groupCount=0}}class ZA{constructor(){this.intersectionSet={},this.ids=[]}add(e,t){const{intersectionSet:i,ids:s}=this;i[e]||(i[e]=[],s.push(e)),i[e].push(t)}}const n5=0,s5=1,r5=2,JA=3,o5=4,ex=5,tx=6,Wi=new v.Ray,ix=new v.Matrix4,ci=new v.Triangle,ns=new v.Vector3,nx=new v.Vector4,sx=new v.Vector4,rx=new v.Vector4,Vf=new v.Vector4,$c=new v.Vector4,Zc=new v.Vector4,ox=new v.Line3,Qf=new v.Vector3,jf=1e-8,a5=1e-15,xr=-1,br=1,Jc=-2,eh=2,Ba=0,yr=1,Wf=2,l5=1e-14;let th=null;function ax(n){th=n}function lx(n,e){n.getMidpoint(Wi.origin),n.getNormal(Wi.direction);const t=e.raycastFirst(Wi,v.DoubleSide);return!!(t&&Wi.direction.dot(t.face.normal)>0)?xr:br}function c5(n,e){function t(){return Math.random()-.5}n.getNormal(Qf),Wi.direction.copy(Qf),n.getMidpoint(Wi.origin);const i=3;let s=0,r=1/0;for(let o=0;o<i;o++){Wi.direction.x+=t()*jf,Wi.direction.y+=t()*jf,Wi.direction.z+=t()*jf,Wi.direction.multiplyScalar(-1);const a=e.raycastFirst(Wi,v.DoubleSide);if(!!(a&&Wi.direction.dot(a.face.normal)>0)&&s++,a!==null&&(r=Math.min(r,a.distance)),r<=a5)return a.face.normal.dot(Qf)>0?eh:Jc;if(s/i>.5||(o-s+1)/i>.5)break}return s/i>.5?xr:br}function h5(n,e){const t=new ZA,i=new ZA;return ix.copy(n.matrixWorld).invert().multiply(e.matrixWorld),n.geometry.boundsTree.bvhcast(e.geometry.boundsTree,ix,{intersectsTriangles(s,r,o,a){if(!Ds(s)&&!Ds(r)){let l=s.intersectsTriangle(r,ox,!0);if(!l){const c=s.plane,h=r.plane,d=c.normal,f=h.normal;d.dot(f)===1&&Math.abs(c.constant-h.constant)<l5&&(l=!0)}if(l){let c=n.geometry.boundsTree.resolveTriangleIndex(o),h=e.geometry.boundsTree.resolveTriangleIndex(a);t.add(c,h),i.add(h,c),th&&(th.addEdge(ox),th.addIntersectingTriangles(o,s,a,r))}}return!1}}),{aIntersections:t,bIntersections:i}}function d5(n,e,t,i,s,r,o=!1){const a=t.attributes,l=t.index,c=n*3,h=l.getX(c+0),d=l.getX(c+1),f=l.getX(c+2);for(const u in r){const g=a[u],p=r[u];if(!(u in a))throw new Error(`CSG Operations: Attribute ${u} not available on geometry.`);const m=g.itemSize;u==="position"?(ci.a.fromBufferAttribute(g,h).applyMatrix4(i),ci.b.fromBufferAttribute(g,d).applyMatrix4(i),ci.c.fromBufferAttribute(g,f).applyMatrix4(i),Hf(ci.a,ci.b,ci.c,e,3,p,o)):u==="normal"?(ci.a.fromBufferAttribute(g,h).applyNormalMatrix(s),ci.b.fromBufferAttribute(g,d).applyNormalMatrix(s),ci.c.fromBufferAttribute(g,f).applyNormalMatrix(s),o&&(ci.a.multiplyScalar(-1),ci.b.multiplyScalar(-1),ci.c.multiplyScalar(-1)),Hf(ci.a,ci.b,ci.c,e,3,p,o,!0)):(nx.fromBufferAttribute(g,h),sx.fromBufferAttribute(g,d),rx.fromBufferAttribute(g,f),Hf(nx,sx,rx,e,m,p,o))}}function u5(n,e,t,i,s,r,o,a=!1){Xf(n,i,s,r,o,a),Xf(a?t:e,i,s,r,o,a),Xf(a?e:t,i,s,r,o,a)}function cx(n,e,t=!1){switch(n){case n5:if(e===br||e===eh&&!t)return yr;break;case s5:if(t){if(e===xr)return Ba}else if(e===br||e===Jc)return yr;break;case r5:if(t){if(e===br||e===Jc)return yr}else if(e===xr)return Ba;break;case o5:if(e===xr)return Ba;if(e===br)return yr;break;case JA:if(e===xr||e===eh&&!t)return yr;break;case ex:if(!t&&(e===br||e===Jc))return yr;break;case tx:if(!t&&(e===xr||e===eh))return yr;break;default:throw new Error(`Unrecognized CSG operation enum "${n}".`)}return Wf}function Hf(n,e,t,i,s,r,o=!1,a=!1){const l=c=>{r.push(c.x),s>1&&r.push(c.y),s>2&&r.push(c.z),s>3&&r.push(c.w)};Vf.set(0,0,0,0).addScaledVector(n,i.a.x).addScaledVector(e,i.a.y).addScaledVector(t,i.a.z),$c.set(0,0,0,0).addScaledVector(n,i.b.x).addScaledVector(e,i.b.y).addScaledVector(t,i.b.z),Zc.set(0,0,0,0).addScaledVector(n,i.c.x).addScaledVector(e,i.c.y).addScaledVector(t,i.c.z),a&&(Vf.normalize(),$c.normalize(),Zc.normalize()),l(Vf),o?(l(Zc),l($c)):(l($c),l(Zc))}function Xf(n,e,t,i,s,r=!1){for(const o in s){const a=e[o],l=s[o];if(!(o in e))throw new Error(`CSG Operations: Attribute ${o} no available on geometry.`);const c=a.itemSize;o==="position"?(ns.fromBufferAttribute(a,n).applyMatrix4(t),l.push(ns.x,ns.y,ns.z)):o==="normal"?(ns.fromBufferAttribute(a,n).applyNormalMatrix(i),r&&ns.multiplyScalar(-1),l.push(ns.x,ns.y,ns.z)):(l.push(a.getX(n)),c>1&&l.push(a.getY(n)),c>2&&l.push(a.getZ(n)),c>3&&l.push(a.getW(n)))}}class f5{constructor(e){this.triangle=new v.Triangle().copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=new v.Triangle().copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const i in t)e.push(t[i]);return e}}class hx{constructor(){this.data={}}addTriangleIntersection(e,t,i,s){const{data:r}=this;r[e]||(r[e]=new f5(t)),r[e].addTriangle(i,s)}getTrianglesAsArray(e=null){const{data:t}=this,i=[];if(e!==null)e in t&&i.push(t[e].triangle);else for(const s in t)i.push(t[s].triangle);return i}getTriangleIndices(){return Object.keys(this.data).map(e=>parseInt(e))}getIntersectionIndices(e){const{data:t}=this;return t[e]?Object.keys(t[e].intersects).map(i=>parseInt(i)):[]}getIntersectionsAsArray(e=null,t=null){const{data:i}=this,s=new Set,r=[],o=a=>{if(i[a])if(t!==null)i[a].intersects[t]&&r.push(i[a].intersects[t]);else{const l=i[a].intersects;for(const c in l)s.has(c)||(s.add(c),r.push(l[c]))}};if(e!==null)o(e);else for(const a in i)o(a);return r}reset(){this.data={}}}class p5{constructor(){this.enabled=!1,this.triangleIntersectsA=new hx,this.triangleIntersectsB=new hx,this.intersectionEdges=[]}addIntersectingTriangles(e,t,i,s){const{triangleIntersectsA:r,triangleIntersectsB:o}=this;r.addTriangleIntersection(e,t,i,s),o.addTriangleIntersection(i,s,e,t)}addEdge(e){this.intersectionEdges.push(e.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),ax(this))}complete(){this.enabled&&ax(null)}}const Bs=new v.Matrix4,ih=new v.Matrix3,vr=new v.Triangle,nh=new v.Triangle,Ps=new v.Triangle,sh=new v.Triangle,rn=[],_r=[];function g5(n){for(const e of n)return e}function m5(n,e,t,i,s,r={}){const{useGroups:o=!0}=r,{aIntersections:a,bIntersections:l}=h5(n,e),c=[];let h=null,d;return d=o?0:-1,dx(n,e,a,t,!1,i,s,d),ux(n,e,a,t,!1,s,d),t.findIndex(u=>u!==tx&&u!==ex)!==-1&&(d=o?n.geometry.groups.length||1:-1,dx(e,n,l,t,!0,i,s,d),ux(e,n,l,t,!0,s,d)),rn.length=0,_r.length=0,{groups:c,materials:h}}function dx(n,e,t,i,s,r,o,a=0){const l=n.matrixWorld.determinant()<0;Bs.copy(e.matrixWorld).invert().multiply(n.matrixWorld),ih.getNormalMatrix(n.matrixWorld).multiplyScalar(l?-1:1);const c=n.geometry.groupIndices,h=n.geometry.index,d=n.geometry.attributes.position,f=e.geometry.boundsTree,u=e.geometry.index,g=e.geometry.attributes.position,p=t.ids,m=t.intersectionSet;for(let A=0,x=p.length;A<x;A++){const b=p[A],y=a===-1?0:c[b]+a,_=3*b,w=h.getX(_+0),S=h.getX(_+1),D=h.getX(_+2);vr.a.fromBufferAttribute(d,w).applyMatrix4(Bs),vr.b.fromBufferAttribute(d,S).applyMatrix4(Bs),vr.c.fromBufferAttribute(d,D).applyMatrix4(Bs),r.reset(),r.initialize(vr);const M=m[b];for(let P=0,T=M.length;P<T;P++){const L=3*M[P],E=u.getX(L+0),F=u.getX(L+1),z=u.getX(L+2);nh.a.fromBufferAttribute(g,E),nh.b.fromBufferAttribute(g,F),nh.c.fromBufferAttribute(g,z),r.splitByTriangle(nh)}const I=r.triangles;for(let P=0,T=I.length;P<T;P++){const L=I[P],E=r.coplanarTriangleUsed?c5(L,f):lx(L,f);rn.length=0,_r.length=0;for(let F=0,z=i.length;F<z;F++){const X=cx(i[F],E,s);X!==Wf&&(_r.push(X),rn.push(o[F].getGroupAttrSet(y)))}if(rn.length!==0){vr.getBarycoord(L.a,sh.a),vr.getBarycoord(L.b,sh.b),vr.getBarycoord(L.c,sh.c);for(let F=0,z=rn.length;F<z;F++){const X=rn[F],N=_r[F]===Ba;d5(b,sh,n.geometry,n.matrixWorld,ih,X,l!==N)}}}}return p.length}function ux(n,e,t,i,s,r,o=0){const a=n.matrixWorld.determinant()<0;Bs.copy(e.matrixWorld).invert().multiply(n.matrixWorld),ih.getNormalMatrix(n.matrixWorld).multiplyScalar(a?-1:1);const l=e.geometry.boundsTree,c=n.geometry.groupIndices,h=n.geometry.index,d=n.geometry.attributes,f=d.position,u=[],g=n.geometry.halfEdges,p=new Set,m=Lf(n.geometry);for(let A=0,x=m;A<x;A++)A in t.intersectionSet||p.add(A);for(;p.size>0;){const A=g5(p);p.delete(A),u.push(A);const x=3*A,b=h.getX(x+0),y=h.getX(x+1),_=h.getX(x+2);Ps.a.fromBufferAttribute(f,b).applyMatrix4(Bs),Ps.b.fromBufferAttribute(f,y).applyMatrix4(Bs),Ps.c.fromBufferAttribute(f,_).applyMatrix4(Bs);const w=lx(Ps,l);_r.length=0,rn.length=0;for(let S=0,D=i.length;S<D;S++){const M=cx(i[S],w,s);M!==Wf&&(_r.push(M),rn.push(r[S]))}for(;u.length>0;){const S=u.pop();for(let D=0;D<3;D++){const M=g.getSiblingTriangleIndex(S,D);M!==-1&&p.has(M)&&(u.push(M),p.delete(M))}if(rn.length!==0){const D=3*S,M=h.getX(D+0),I=h.getX(D+1),P=h.getX(D+2),T=o===-1?0:c[S]+o;if(Ps.a.fromBufferAttribute(f,M),Ps.b.fromBufferAttribute(f,I),Ps.c.fromBufferAttribute(f,P),!Ds(Ps))for(let L=0,E=rn.length;L<E;L++){const F=_r[L],z=rn[L].getGroupAttrSet(T),X=F===Ba;u5(M,I,P,d,n.matrixWorld,ih,z,X!==a)}}}}}function A5(n){for(let e=0;e<n.length-1;e++){const t=n[e],i=n[e+1];if(t.materialIndex===i.materialIndex){const s=t.start,r=i.start+i.count;i.start=s,i.count=r-s,n.splice(e,1),e--}}}function x5(n,e,t,i){t.clear();const s=n.attributes;for(let r=0,o=i.length;r<o;r++){const a=i[r],l=s[a];t.initializeArray(a,l.array.constructor,l.itemSize,l.normalized)}for(const r in t.attributes)i.includes(r)||t.delete(r);for(const r in e.attributes)i.includes(r)||(e.deleteAttribute(r),e.dispose())}function b5(n,e,t){let i=!1,s=-1;const r=n.attributes,o=e.groupAttributes[0];for(const l in o){const c=e.getTotalLength(l),h=e.getType(l),d=e.getItemSize(l),f=e.getNormalized(l);let u=r[l];(!u||u.array.length<c)&&(u=new v.BufferAttribute(new h(c),d,f),n.setAttribute(l,u),i=!0);let g=0;for(let p=0,m=Math.min(t.length,e.groupCount);p<m;p++){const A=t[p].index,{array:x,type:b,length:y}=e.groupAttributes[A][l],_=new b(x.buffer,0,y);u.array.set(_,g),g+=_.length}u.needsUpdate=!0,s=c/u.itemSize}if(n.index){const l=n.index.array;if(l.length<s)n.index=null,i=!0;else for(let c=0,h=l.length;c<h;c++)l[c]=c}let a=0;n.clearGroups();for(let l=0,c=Math.min(t.length,e.groupCount);l<c;l++){const{index:h,materialIndex:d}=t[l],f=e.getCount(h);f!==0&&(n.addGroup(a,f,d),a+=f)}n.setDrawRange(0,s),n.boundsTree=null,i&&n.dispose()}function fx(n,e){let t=e;return Array.isArray(e)||(t=[],n.forEach(i=>{t[i.materialIndex]=e})),t}class y5{constructor(){this.triangleSplitter=new e5,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new p5}getGroupRanges(e){return!this.useGroups||e.groups.length===0?[{start:0,count:1/0,materialIndex:0}]:e.groups.map(t=>({...t}))}evaluate(e,t,i,s=new Yc){let r=!0;if(Array.isArray(i)||(i=[i]),Array.isArray(s)||(s=[s],r=!1),s.length!==i.length)throw new Error("Evaluator: operations and target array passed as different sizes.");e.prepareGeometry(),t.prepareGeometry();const{triangleSplitter:o,attributeData:a,attributes:l,useGroups:c,consolidateGroups:h,debug:d}=this;for(;a.length<s.length;)a.push(new i5);s.forEach((A,x)=>{x5(e.geometry,A.geometry,a[x],l)}),d.init(),m5(e,t,i,o,a,{useGroups:c}),d.complete();const f=this.getGroupRanges(e.geometry),u=fx(f,e.material),g=this.getGroupRanges(t.geometry),p=fx(g,t.material);g.forEach(A=>A.materialIndex+=u.length);let m=[...f,...g].map((A,x)=>({...A,index:x}));if(c){const A=[...u,...p];h&&(m=m.map(b=>{const y=A[b.materialIndex];return b.materialIndex=A.indexOf(y),b}).sort((b,y)=>b.materialIndex-y.materialIndex));const x=[];for(let b=0,y=A.length;b<y;b++){let _=!1;for(let w=0,S=m.length;w<S;w++){const D=m[w];D.materialIndex===b&&(_=!0,D.materialIndex=x.length)}_&&x.push(A[b])}s.forEach(b=>{b.material=x})}else m=[{start:0,count:1/0,index:0,materialIndex:0}],s.forEach(A=>{A.material=u[0]});return s.forEach((A,x)=>{const b=A.geometry;b5(b,a[x],m),h&&A5(b.groups)}),r?s:s[0]}evaluateHierarchy(e,t=new Yc){e.updateMatrixWorld(!0);const i=(r,o)=>{const a=r.children;for(let l=0,c=a.length;l<c;l++){const h=a[l];h.isOperationGroup?i(h,o):o(h)}},s=r=>{const o=r.children;let a=!1;for(let c=0,h=o.length;c<h;c++){const d=o[c];a=s(d)||a}const l=r.isDirty();if(l&&r.markUpdated(),a&&!r.isOperationGroup){let c;return i(r,h=>{c?c=this.evaluate(c,h,h.operation):c=this.evaluate(r,h,h.operation)}),r._cachedGeometry=c.geometry,r._cachedMaterials=c.material,!0}else return a||l};return s(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}class v5{engine;evaluator;fillMeshName="ClippingFaceFillMesh";fillMeshes=new Map;maxCandidates=22e5;maxTriangleCountPerMesh=12e4;fillMaterial;fillTextureRepeat=60;fillTextureRotation=0;constructor(e){this.engine=e,this.evaluator=new y5;const t=new URL("/texture/fill.png",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,i=new C.TextureLoader().load(t);i.wrapS=C.RepeatWrapping,i.wrapT=C.RepeatWrapping,i.center.set(.5,.5),i.rotation=this.fillTextureRotation,this.fillMaterial=new C.MeshStandardMaterial({color:16112010,map:i,side:C.DoubleSide,toneMapped:!1}),this.fillMaterial.clipShadows=!0,this.fillMaterial.clippingPlanes=e.sectionPlane}clear(){this.fillMeshes.forEach(e=>{e.parent?.remove(e),e.geometry?.dispose?.();const t=e.material;Array.isArray(t)?t.forEach(i=>i.dispose?.()):t&&t!==this.fillMaterial&&t.dispose?.()}),this.fillMeshes.clear()}updataFace(e){this.clear(),e instanceof C.Plane&&this.engine.clipping.fillCutFace&&this.buildSinglePlaneFill(e,"face")}updataFaces(e){this.clear(),!(!Array.isArray(e)||e.length===0)&&this.engine.clipping.fillCutFace&&e.forEach((t,i)=>{if(!(t instanceof C.Plane))return;const s=`plane-${i}-${String(t.name??i)}`;this.buildSinglePlaneFill(t,s)})}buildSinglePlaneFill(e,t){const i=this.engine?.octreeBox?.getBoundingBox?.();if(i==null||i.min==null||i.max==null)return;const s=this.collectCandidateMeshesFromOctree(e);if(s.length===0)return;const r=this.filterMeshesByBoxAndComplexity(e,s);if(r.length===0)return;const o=i.min.distanceTo(i.max),a=o*5,l=.1,c=this.createPlaneBrush(e,a,l),h=[];for(const p of r.slice(0,this.maxCandidates)){const m=this.createWorldBrushFromMesh(p);if(m!=null)try{const x=this.evaluator.evaluate(m,c,JA)?.geometry;if(!x)continue;const b=this.extractPlaneCapGeometry(x,e,l);b&&h.push(b),x.dispose()}catch{}finally{m.geometry.dispose()}}if(c.geometry.dispose(),h.length===0)return;const d=Cs(h,!1);if(h.forEach(p=>p.dispose()),!d)return;this.applyPlanarUv(d,e);const f=this.getFaceOffsetDistance(o),u=this.getFaceOffsetSign();d.translate(e.normal.x*f*u,e.normal.y*f*u,e.normal.z*f*u);const g=new C.Mesh(d,this.fillMaterial);g.name=`${this.fillMeshName}_${t}`,g.frustumCulled=!1,g.renderOrder=20,g.castShadow=!1,g.receiveShadow=!1,this.engine.scene.add(g),this.fillMeshes.set(t,g)}getFaceOffsetDistance(e){return-.001}getFaceOffsetSign(){const e=this.engine?.engineStatus?.clippingFaceOffsetSign;return e===1||e===-1?e:-1}collectCandidateMeshesFromOctree(e){const t=[],i=new Set,s=Array.isArray(this.engine?.engineStatus?.models)?this.engine.engineStatus.models:[];for(const r of s){const o=this.engine.models?.find?.(c=>c.url===r.url);if(!o?.nodesMap)continue;const a=this.getIgnoredIds(r.url),l=Array.isArray(r?.info?.lods)?r.info.lods:[];for(const c of l){const h=c?.octreeBox;if(!h)continue;const d=this.collectIntersectElementIds(h,e);for(const f of d){if(a.has(f))continue;const u=o.nodesMap.get(f);if(!(u?.instance===!0||!Array.isArray(u?.infos)))for(const g of u.infos){const p=g?.mesh;p instanceof C.Mesh&&(i.has(p.uuid)||(i.add(p.uuid),t.push(p)))}}}}return t}getIgnoredIds(e){const t=new Set,i=Array.isArray(this.engine?.engineStatus?.hideModels)?this.engine.engineStatus.hideModels:[],s=Array.isArray(this.engine?.engineStatus?.translucentModels)?this.engine.engineStatus.translucentModels:[],r=i.find(a=>a.url===e)?.ids;Array.isArray(r)&&r.forEach(a=>t.add(a));const o=s.find(a=>a.url===e)?.ids;return Array.isArray(o)&&o.forEach(a=>t.add(a)),t}collectIntersectElementIds(e,t){const i=new Set,s=[e];for(;s.length>0;){const r=s.pop();if(!r)continue;const o=this.octreeNodeToBox3(r);!o||!t.intersectsBox(o)||(Array.isArray(r.elements)&&r.elements.forEach(a=>i.add(a)),Array.isArray(r.children)&&r.children.forEach(a=>s.push(a)))}return i}octreeNodeToBox3(e){if(!e?.min||!e?.max)return null;const t=new C.Vector3(e.min.X*.3048,e.min.Z*.3048,-e.min.Y*.3048),i=new C.Vector3(e.max.X*.3048,e.max.Z*.3048,-e.max.Y*.3048),s=new C.Vector3(Math.min(t.x,i.x),Math.min(t.y,i.y),Math.min(t.z,i.z)),r=new C.Vector3(Math.max(t.x,i.x),Math.max(t.y,i.y),Math.max(t.z,i.z));return new C.Box3(s,r)}filterMeshesByBoxAndComplexity(e,t){const i=[],s=new C.Box3;for(const r of t){const o=r.geometry,a=o?.attributes?.position;!o||!a||a.count===0||(o.index?Math.floor(o.index.count/3):Math.floor(a.count/3))>this.maxTriangleCountPerMesh||(o.boundingBox||o.computeBoundingBox(),o.boundingBox&&(s.copy(o.boundingBox),r.updateWorldMatrix(!0,!1),s.applyMatrix4(r.matrixWorld),e.intersectsBox(s)&&(r.geometry.attributes.position.count>500||i.push(r))))}return i}createPlaneBrush(e,t,i){const s=new C.BoxGeometry(t,t,i),r=e.coplanarPoint(new C.Vector3),o=new C.Quaternion().setFromUnitVectors(new C.Vector3(0,0,1),e.normal.clone().normalize()),a=new C.Matrix4().compose(r,o,new C.Vector3(1,1,1));s.applyMatrix4(a);const l=this.toCsgReadyGeometry(s);return s.dispose(),new Yc(l)}createWorldBrushFromMesh(e){const t=e.geometry;if(!t||!t.attributes?.position)return null;e.updateWorldMatrix(!0,!1);const i=t.clone();i.applyMatrix4(e.matrixWorld);const s=this.toCsgReadyGeometry(i);return i.dispose(),new Yc(s)}toCsgReadyGeometry(e){const t=e.index?e.toNonIndexed():e.clone();t.getAttribute("normal")||t.computeVertexNormals();const i=t.getAttribute("position");if(i&&!t.getAttribute("uv")){const r=new Float32Array(i.count*2);t.setAttribute("uv",new C.Float32BufferAttribute(r,2))}const s=new Set(["position","normal","uv"]);return Object.keys(t.attributes).forEach(r=>{s.has(r)||t.deleteAttribute(r)}),t}extractPlaneCapGeometry(e,t,i){const s=e.index?e.toNonIndexed():e.clone(),r=s.getAttribute("position");if(!r||r.count<3)return s.dispose(),null;const o=t.normal.clone().normalize(),a=new C.Vector3,l=new C.Vector3,c=new C.Vector3,h=new C.Vector3,d=new C.Vector3,f=new C.Vector3,u=new C.Vector3,g=new C.Vector3,p=new C.Vector3,m=Math.max(i*.35,1e-4),A=Math.max(i*.7,1e-4),x=[];for(let y=0;y<r.count;y+=3){if(h.fromBufferAttribute(r,y),d.fromBufferAttribute(r,y+1),f.fromBufferAttribute(r,y+2),l.subVectors(d,h),c.subVectors(f,h),a.crossVectors(l,c),a.lengthSq()<1e-14||(a.normalize(),Math.abs(a.dot(o))<.9))continue;const _=t.distanceToPoint(h),w=t.distanceToPoint(d),S=t.distanceToPoint(f),D=Math.min(_,w,S);if(Math.max(_,w,S)-D>m)continue;const I=(_+w+S)/3;Math.abs(I)>A||I<0||(u.copy(h).addScaledVector(o,-_),g.copy(d).addScaledVector(o,-w),p.copy(f).addScaledVector(o,-S),a.dot(o)<=0?(x.push(u.x,u.y,u.z),x.push(g.x,g.y,g.z),x.push(p.x,p.y,p.z)):(x.push(u.x,u.y,u.z),x.push(p.x,p.y,p.z),x.push(g.x,g.y,g.z)))}if(s.dispose(),x.length<9)return null;const b=new C.BufferGeometry;return b.setAttribute("position",new C.Float32BufferAttribute(x,3)),b.computeVertexNormals(),b}applyPlanarUv(e,t){const i=e.getAttribute("position");if(!i||i.count===0)return;const{tangent:s,bitangent:r}=this.getPlaneBasis(t.normal.clone().normalize()),o=new C.Vector3,a=new Float32Array(i.count*2);let l=1/0,c=-1/0,h=1/0,d=-1/0;for(let g=0;g<i.count;g++){o.fromBufferAttribute(i,g);const p=o.dot(s),m=o.dot(r),A=g*2;a[A]=p,a[A+1]=m,l=Math.min(l,p),c=Math.max(c,p),h=Math.min(h,m),d=Math.max(d,m)}const f=Math.max(c-l,1e-6),u=Math.max(d-h,1e-6);for(let g=0;g<a.length;g+=2)a[g]=(a[g]-l)/f*this.fillTextureRepeat,a[g+1]=(a[g+1]-h)/u*this.fillTextureRepeat;e.setAttribute("uv",new C.BufferAttribute(a,2))}getPlaneBasis(e){const t=new C.Vector3(1,0,0),i=new C.Vector3(0,1,0),s=new C.Vector3(0,0,1),r=Math.abs(e.dot(t)),o=Math.abs(e.dot(i)),a=Math.abs(e.dot(s));let l=t;o<=r&&o<=a?l=i:a<=r&&a<=o&&(l=s),l=l.clone().sub(e.clone().multiplyScalar(l.dot(e))).normalize();const c=new C.Vector3().crossVectors(e,l).normalize();return{tangent:l,bitangent:c}}}class _5{engine;clippingTolerance=1e-4;sectionBox;sectionFace;clippingStencil;clippingCSGSimple=null;currentClippingMode="";fillCutFace=!0;constructor(e){this.engine=e;let t=new C.Plane(new C.Vector3(0,0,1),1e5);t.name="前";let i=new C.Plane(new C.Vector3(0,0,1),1e5);i.name="左";let s=new C.Plane(new C.Vector3(0,0,1),1e5);s.name="后";let r=new C.Plane(new C.Vector3(0,0,1),1e5);r.name="右";let o=new C.Plane(new C.Vector3(0,0,1),1e5);o.name="顶";let a=new C.Plane(new C.Vector3(0,0,1),1e5);a.name="底";let l=new C.Plane(new C.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,i,s,r,o,a,l]}init(){this.sectionBox=new TI(this.engine),this.sectionFace=new DI(this.engine),this.clippingCSGSimple=new v5(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}setFillCutFace(e){this.fillCutFace=e}getFillCutFace(){return this.fillCutFace}clippingModel(e){let t=[];e.forEach(r=>{let o=this.engine.models.find(a=>a.url===r.url);r.ids.forEach(a=>{o.nodesMap.get(a).infos.forEach(l=>{t.push(l.box)})})}),this.active("box");let i=s(t);this.sectionBox.setBox(i);function s(r){let o=new C.Vector3(1e8,1e9,1e10),a=new C.Vector3(-1e8,-1e9,-1e10);return r.forEach(l=>{l.min.x<o.x&&(o.x=l.min.x),l.min.y<o.y&&(o.y=l.min.y),l.min.z<o.z&&(o.z=l.min.z),l.max.x>a.x&&(a.x=l.max.x),l.max.y>a.y&&(a.y=l.max.y),l.max.z>a.z&&(a.z=l.max.z)}),new C.Box3(o,a)}}updateClippingValue(e){let t=this.sectionBox.maxBox,i=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,s=t.min.y+(t.max.y-t.min.y)*e.y.min*.01,r=t.min.z+(t.max.z-t.min.z)*e.z.min*.01,o=t.min.x+(t.max.x-t.min.x)*e.x.max*.01,a=t.min.y+(t.max.y-t.min.y)*e.y.max*.01,l=t.min.z+(t.max.z-t.min.z)*e.z.max*.01;this.sectionBox.setboxXyz({minX:i,minY:s,minZ:r,maxX:o,maxY:a,maxZ:l})}active(e){if(this.engine.engineStatus.isForceFree=!0,this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=e,e=="x")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(Math.PI/2,0,0);else if(e=="y")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,Math.PI/2,0);else if(e=="z")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,0,Math.PI/2);else if(e=="box")this.sectionBox.init(),this.sectionBox.active();else if(e=="face"){let t=new BI(this.engine);t.init(),t.catch_face(i=>{this.sectionFace.init(),this.sectionFace.active();let s=this.engine.octreeBox.getBoundingBox(),r=s.min.clone().add(s.max.clone()).multiplyScalar(.5),o=i.position.clone().sub(r),a=new C.Vector3(i.dir.x,i.dir.y,i.dir.z),l=o.dot(a);this.sectionFace.setFaceNormal(i.dir,l)})}}disabled(){this.currentClippingMode=="box"?this.sectionBox.disabled():this.sectionFace.disabled(),this.engine.engineStatus.isForceFree=!1}recover(){this.currentClippingMode=="box"?this.sectionBox.recover():this.sectionFace.recover()}reverse(){this.sectionFace.reverse()}disActive(){this.sectionFace.disActive(),this.sectionBox.disActive(),this.clippingCSGSimple?.clear(),this.currentClippingMode="",this.engine.engineStatus.isForceFree=!1}isPointInClippingRange(e,t=this.clippingTolerance){if(!this.isVector3Like(e))return!1;const i=this.getEffectiveClippingPlanes();return i.length===0?!0:i.every(s=>s.distanceToPoint(e)>=-t)}filterIntersectionsByClipping(e,t=this.clippingTolerance){return!Array.isArray(e)||e.length===0?[]:e.filter(i=>this.isPointInClippingRange(i?.point,t))}getEffectiveClippingPlanes(){const e=Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:[];if(this.currentClippingMode==="box")return e.slice(0,6).filter(t=>t instanceof C.Plane);if(this.currentClippingMode==="x"||this.currentClippingMode==="y"||this.currentClippingMode==="z"||this.currentClippingMode==="face"){const t=e[6];return t instanceof C.Plane?[t]:[]}return[]}isVector3Like(e){return e!=null&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"}setSectionByView(e,t){this.sectionFace.disActive(),this.sectionBox.disActive(),this.scaleBox(),this.sectionFace.init(!0);const i=this.engine.octreeBox.getBoundingBox(),s=new C.Vector3((i.min.x+i.max.x)/2,(i.min.y+i.max.y)/2,(i.min.z+i.max.z)/2),o=new C.Vector3(t.x,t.y,t.z).normalize().clone().negate(),l=new C.Vector3(e.x,e.y,e.z).clone().sub(s).dot(o);this.sectionFace.setFaceNormalPlaneOnly(o,l),this.sectionFace.activateClippingOnly(),this.currentClippingMode="face"}}class C5{engine;constructor(e){this.engine=e}getLevelTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeLevel,name:t.info.baseInfo.name,url:t.url})}),e}getTypeTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeType,name:t.info.baseInfo.name,url:t.url})}),e}getMajorTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeMajor,name:t.info.baseInfo.name,url:t.url})}),e}}class w5{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,i=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(s=>{if(s instanceof C.Mesh){const r=s.geometry;if(r&&r.attributes){const o=r.attributes.position;if(o){const a=o.count;e+=a;let l=0;r.index?l=r.index.count/3:l=a/3,t+=l}}}}),this.engine.engineStatus.models.forEach(s=>{i=i+(Array.isArray(s?.info?.modelEdge)?s.info.modelEdge.length:0)}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:i})}}class S5{engine;extended‌=new Map;constructor(e){this.engine=e}init(){}updateExtended(e,t){let i=this.extended‌.get(e);i==null?this.extended‌.set(e,t):t.forEach((s,r)=>{i.set(r,s)})}getModelPropertiesWithName(e,t,i,s){let r=this.extended‌.get(e),o=this.engine.engineStatus.models.find(l=>l.url===e);o.properties==null?ha(e+"/property",l=>{let c=JSON.parse(l);o.properties=c,setTimeout(()=>{a(c,i,t,s)},100)},()=>{},o?.key):a(o.properties,i,t,s);function a(l,c,h,d){let f={};l.models[h.toString()||""].forEach(g=>{i.includes(l.names[g[1]])&&(f[l.names[g[1]]]=l.values[g[2]])}),r!=null&&r.has(h)&&f.push(r.get(h)),d?.({id:h,properties:f})}}getModelProperties(e,t,i){let s=this.extended‌.get(e),r=this.engine.engineStatus.models.find(a=>a.url===e);r.properties==null&&ha(e+"/property",a=>{let l=JSON.parse(a);r.properties=l,setTimeout(()=>{o(l,t,i)},100)},()=>{},r?.key),o(r.properties,t,i);function o(a,l,c){let h=[],d=a.models[l.toString()||""],f=d.map(u=>u[0]);f=f.filter((u,g)=>f.indexOf(u)===g),f.forEach(u=>{let g={name:a.categorys[u],children:[]};h.push(g),d.filter(p=>p[0]===u).forEach(p=>{g.children.push({name:a.names[p[1]],value:a.values[p[2]]})})}),s!=null&&s.has(l)&&h.push(s.get(l)),c?.({properties:h,materials:h})}}}class M5{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(s=>{e.push(s.typeName)})}),e=e.filter((t,i,s)=>s.indexOf(t)===i),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(s=>{e.push(s.majorName)})}),e=e.filter((t,i,s)=>s.indexOf(t)===i),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(s=>{e.push(s.levelName)})}),e=e.filter((t,i,s)=>s.indexOf(t)===i),e}getModelMappers(e){}getModelMapper(e,t){let i=this.engine.engineStatus.models.find(o=>o.url==e);return i?i.info.modelMapper.find(o=>o.id==t):null}getModelsWithLevelType(e,t,i=null){let s=[];return this.engine.engineStatus.models.forEach(r=>{let o={url:r.url,ids:[]};s.push(o),r.info.modelMapper.filter(l=>l.levelName===e&&l.typeName===t).forEach(l=>{o.ids.push(Number(l.id))})}),i&&i(s),s}getModelsWithType(e,t=null){let i=[];return this.engine.engineStatus.models.forEach(s=>{let r={url:s.url,ids:[]};i.push(r),s.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithLevel(e,t){let i=[];return this.engine.engineStatus.models.forEach(s=>{let r={url:s.url,ids:[]};i.push(r),s.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithMajor(e,t){let i=[];return this.engine.engineStatus.models.forEach(s=>{let r={url:s.url,ids:[]};i.push(r),s.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(i),i}}class E5{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,i=setTimeout(()=>t.abort(),this.config.timeout);try{const s=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!1}),signal:t.signal});if(clearTimeout(i),!s.ok){const o=await s.json().catch(()=>({}));throw new Error(`API请求失败 (${s.status}): ${o.error?.message||o.message||s.statusText}`)}return(await s.json()).choices?.[0]?.message?.content||""}catch(s){throw clearTimeout(i),s.name==="AbortError"?new Error("请求超时,请重试"):s.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
5261
5261
  1. 网络连接
5262
5262
  2. API地址是否正确
5263
5263
  3. 是否有CORS限制`):s}}async chatStream(e,t){const i=new AbortController,s=setTimeout(()=>i.abort(),this.config.timeout);try{const r=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!0}),signal:i.signal});if(clearTimeout(s),!r.ok){const c=await r.json().catch(()=>({}));throw new Error(`API请求失败 (${r.status}): ${c.error?.message||c.message||r.statusText}`)}const o=r.body?.getReader();if(!o)throw new Error("无法读取响应流");const a=new TextDecoder;let l="";for(;;){const{done:c,value:h}=await o.read();if(c){t("",!0);break}l+=a.decode(h,{stream:!0});const d=l.split(`
@@ -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:()=>bB,BlendColor:()=>$a,BlendImage:()=>Za,Blur:()=>Ja,Brightness:()=>el,Brownie:()=>fB,ColorMatrix:()=>kr,Composed:()=>Wp,Contrast:()=>tl,Convolute:()=>il,Gamma:()=>nl,Grayscale:()=>sl,HueRotation:()=>zh,Invert:()=>rl,Kodachrome:()=>gB,Noise:()=>ol,Pixelate:()=>al,Polaroid:()=>AB,RemoveColor:()=>ll,Resize:()=>cl,Saturation:()=>hl,Sepia:()=>xB,Technicolor:()=>mB,Vibrance:()=>dl,Vintage:()=>pB});function CB(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=wB(s,r,o);if(!SB(a)){const f=MB(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 wB(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 SB(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 MB(n,e,t){const i=n?.renderer,s=n?.scene,r=n?.camera;if(!i||!s||!r)return null;const o=new C.WebGLRenderTarget(e,t,{minFilter:C.LinearFilter,magFilter:C.LinearFilter,format:C.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),EB(h,e,t)}catch{return null}finally{i.setRenderTarget(a),i.autoClear=l,i.xr&&(i.xr.enabled=c),o.dispose()}}function EB(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 IB={none:new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M17.13%2045.7359L21.708%2045.7359L21.708%2048L17.13%2048L17.13%2045.7359ZM7.97408%2045.7359L12.5521%2045.7359L12.5521%2048L7.97408%2048L7.97408%2045.7359ZM2.26408%2044.6039L0%2044.6039L0%2048L3.39615%2048L3.39615%2045.7359L2.26408%2045.7359L2.26408%2044.6039ZM0%2026.2859L2.26408%2026.2859L2.26408%2030.8638L0%2030.8638L0%2026.2859ZM0%207.97408L2.26408%207.97408L2.26408%2012.5521L0%2012.5521L0%207.97408ZM0%2035.448L2.26408%2035.448L2.26408%2040.0259L0%2040.0259L0%2035.448ZM0%2017.13L2.26408%2017.13L2.26408%2021.708L0%2021.708L0%2017.13ZM0%203.39615L2.26408%203.39615L2.26408%202.26408L3.39615%202.26408L3.39615%200L0%200L0%203.39615ZM26.2921%200L30.87%200L30.87%202.26408L26.2921%202.26408L26.2921%200ZM35.448%200L40.0259%200L40.0259%202.26408L35.448%202.26408L35.448%200ZM17.13%200L21.708%200L21.708%202.26408L17.13%202.26408L17.13%200ZM7.97408%200L12.5521%200L12.5521%202.26408L7.97408%202.26408L7.97408%200ZM44.6039%200L44.6039%202.26408L45.7359%202.26408L45.7359%203.39615L48%203.39615L48%200L44.6039%200ZM45.7359%2017.13L48%2017.13L48%2021.708L45.7359%2021.708L45.7359%2017.13ZM45.7359%207.97408L48%207.97408L48%2012.5521L45.7359%2012.5521L45.7359%207.97408ZM36.4432%2031.2308L40.2747%2028.2638C40.5609%2028.0399%2040.7163%2027.6916%2040.6853%2027.3309C40.6542%2026.9701%2040.4427%2026.6466%2040.1255%2026.4787L20.7376%2016.0415C20.3644%2015.8424%2019.9104%2015.8798%2019.5745%2016.1348C19.2386%2016.396%2019.0893%2016.8252%2019.1888%2017.2357L24.4323%2038.6202C24.5194%2038.9748%2024.7744%2039.2547%2025.1165%2039.3728C25.4586%2039.491%2025.838%2039.4288%2026.1242%2039.2111L29.9557%2036.2441L38.2408%2046.9426C38.4522%2047.2163%2038.7695%2047.3593%2039.0867%2047.3593C39.3168%2047.3593%2039.547%2047.2847%2039.7398%2047.1354L44.5292%2043.4283C44.7531%2043.2541%2044.9024%2042.9991%2044.9336%2042.7192C44.9708%2042.4393%2044.89%2042.1532%2044.7158%2041.9293L36.4432%2031.2308Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M48%2023.5C48%2023.5409%2047.9993%2023.5818%2047.9979%2023.6227C47.9966%2023.6635%2047.9946%2023.7043%2047.9918%2023.7451C47.989%2023.7858%2047.9855%2023.8264%2047.9814%2023.8668C47.9773%2023.9073%2047.9725%2023.9476%2047.9671%2023.9878C47.9616%2024.0279%2047.9554%2024.0678%2047.9487%2024.1074C47.9418%2024.1471%2047.9343%2024.1865%2047.9262%2024.2257C47.918%2024.2649%2047.9092%2024.3037%2047.8998%2024.3422C47.8904%2024.3807%2047.8803%2024.4189%2047.8695%2024.4566C47.8587%2024.4945%2047.8474%2024.5319%2047.8354%2024.5689C47.8234%2024.6059%2047.8108%2024.6424%2047.7976%2024.6785C47.7844%2024.7145%2047.7705%2024.7501%2047.7561%2024.7853C47.7417%2024.8204%2047.7267%2024.8549%2047.7111%2024.8889C47.6954%2024.923%2047.6793%2024.9564%2047.6626%2024.9892C47.6459%2025.0221%2047.6286%2025.0543%2047.6109%2025.0859C47.5931%2025.1176%2047.5747%2025.1486%2047.5559%2025.1789C47.537%2025.2092%2047.5177%2025.2388%2047.4978%2025.2677C47.478%2025.2967%2047.4577%2025.3249%2047.4369%2025.3523C47.4161%2025.3799%2047.3949%2025.4066%2047.3732%2025.4326C47.3515%2025.4585%2047.3294%2025.4837%2047.3068%2025.5081C47.2843%2025.5324%2047.2614%2025.5559%2047.2381%2025.5786C47.2148%2025.6014%2047.191%2025.6233%2047.167%2025.6443C47.1429%2025.6654%2047.1185%2025.6855%2047.0938%2025.7048C47.0691%2025.7241%2047.044%2025.7425%2047.0186%2025.76C46.9933%2025.7775%2046.9676%2025.794%2046.9416%2025.8096C46.9158%2025.8254%2046.8896%2025.8401%2046.8632%2025.8539C46.8367%2025.8676%2046.8101%2025.8804%2046.7832%2025.8923C46.7564%2025.9042%2046.7294%2025.9152%2046.7022%2025.9251C46.6749%2025.935%2046.6476%2025.944%2046.6201%2025.952C46.5925%2025.9599%2046.5649%2025.9669%2046.5372%2025.9729C46.5094%2025.9789%2046.4816%2025.9839%2046.4537%2025.988C46.4257%2025.992%2046.3978%2025.995%2046.3697%2025.997C46.3417%2025.999%2046.3137%2026%2046.2856%2026L1.71205%2026C1.68401%2025.9999%201.656%2025.9989%201.62803%2025.9969C1.59999%2025.9948%201.57204%2025.9917%201.54418%2025.9876C1.51626%2025.9836%201.48844%2025.9785%201.4607%2025.9725C1.43302%2025.9664%201.40543%2025.9594%201.37792%2025.9513C1.35042%2025.9433%201.3231%2025.9343%201.29596%2025.9243C1.26875%2025.9144%201.24173%2025.9034%201.21488%2025.8915C1.18809%2025.8796%201.16151%2025.8668%201.13514%2025.853C1.10871%2025.8391%201.08258%2025.8243%201.05675%2025.8087C1.03085%2025.793%201.00523%2025.7764%200.979869%2025.7589C0.954573%2025.7414%200.929572%2025.723%200.904865%2025.7036C0.880102%2025.6844%200.855725%2025.6642%200.831737%2025.6431C0.807688%2025.6221%200.784026%2025.6002%200.760751%2025.5775C0.737417%2025.5547%200.714499%2025.5312%200.691998%2025.5068C0.669497%2025.4824%200.647443%2025.4572%200.625834%2025.4312C0.604167%2025.4053%200.582945%2025.3786%200.562171%2025.3512C0.541396%2025.3237%200.521126%2025.2954%200.501364%2025.2665C0.481542%2025.2376%200.462225%2025.208%200.443414%2025.1777C0.424604%2025.1474%200.4063%2025.1164%200.388501%2025.0848C0.370762%2025.0532%200.35353%2025.021%200.336802%2024.9882C0.320135%2024.9552%200.304033%2024.9218%200.288496%2024.8879C0.272901%2024.8539%200.2579%2024.8193%200.243495%2024.7842C0.229089%2024.7492%200.215308%2024.7136%200.202154%2024.6776C0.188938%2024.6415%200.176349%2024.6049%200.164383%2024.568C0.152358%2024.5311%200.140988%2024.4937%200.130274%2024.4559C0.119559%2024.4181%200.109499%2024.38%200.100094%2024.3415C0.0906294%2024.303%200.0818497%2024.2642%200.0737539%2024.2251C0.0655983%2024.186%200.0581279%2024.1466%200.0513415%2024.1069C0.0444965%2024.0672%200.0383654%2024.0274%200.0329483%2023.9874C0.0274712%2023.9473%200.0226795%2023.907%200.018573%2023.8665C0.0144653%2023.8261%200.0110427%2023.7855%200.00830418%2023.7448C0.00556564%2023.7042%200.00351242%2023.6634%200.00214315%2023.6225C0.000713928%2023.5817%200%2023.5409%200%2023.5C0%2023.4591%200.000713928%2023.4183%200.00214315%2023.3775C0.00351242%2023.3366%200.00556564%2023.2958%200.00830418%2023.2552C0.0110427%2023.2145%200.0144653%2023.1739%200.018573%2023.1335C0.0226795%2023.093%200.0274712%2023.0528%200.0329483%2023.0128C0.038424%2022.9727%200.0445564%2022.9328%200.0513415%2022.8931C0.0581279%2022.8534%200.0655983%2022.814%200.0737539%2022.7749C0.0818497%2022.7358%200.0906294%2022.697%200.100094%2022.6585C0.109499%2022.62%200.119559%2022.5819%200.130274%2022.5441C0.140988%2022.5063%200.152358%2022.4689%200.164383%2022.432C0.176349%2022.3951%200.188938%2022.3585%200.202154%2022.3224C0.215308%2022.2864%200.229089%2022.2508%200.243495%2022.2158C0.2579%2022.1807%200.272901%2022.1461%200.288496%2022.1121C0.304033%2022.0782%200.320135%2022.0448%200.336802%2022.0119C0.35353%2021.979%200.370762%2021.9468%200.388501%2021.9152C0.4063%2021.8836%200.424604%2021.8526%200.443414%2021.8223C0.462225%2021.792%200.481542%2021.7624%200.501364%2021.7335C0.521126%2021.7046%200.541396%2021.6763%200.562171%2021.6488C0.582945%2021.6214%200.604167%2021.5947%200.625834%2021.5688C0.647443%2021.5428%200.669497%2021.5176%200.691998%2021.4932C0.714499%2021.4688%200.737417%2021.4453%200.760751%2021.4225C0.784026%2021.3998%200.807688%2021.3779%200.831737%2021.3569C0.855725%2021.3358%200.880102%2021.3156%200.904865%2021.2964C0.929572%2021.277%200.954573%2021.2586%200.979869%2021.2411C1.00523%2021.2236%201.03085%2021.207%201.05675%2021.1913C1.08258%2021.1756%201.10871%2021.1608%201.13514%2021.147C1.16151%2021.1332%201.18809%2021.1204%201.21488%2021.1085C1.24173%2021.0966%201.26875%2021.0856%201.29596%2021.0757C1.3231%2021.0657%201.35042%2021.0566%201.37792%2021.0486C1.40543%2021.0406%201.43302%2021.0336%201.4607%2021.0275C1.48844%2021.0215%201.51626%2021.0165%201.54418%2021.0124C1.57204%2021.0083%201.59999%2021.0052%201.62803%2021.0031C1.656%2021.0011%201.68401%2021.0001%201.71205%2021L46.2856%2021C46.3137%2021%2046.3417%2021.001%2046.3697%2021.003C46.3978%2021.005%2046.4257%2021.008%2046.4537%2021.0121C46.4816%2021.0161%2046.5094%2021.0211%2046.5372%2021.0271C46.5649%2021.0331%2046.5925%2021.0401%2046.6201%2021.048C46.6476%2021.056%2046.6749%2021.065%2046.7022%2021.0749C46.7294%2021.0849%2046.7564%2021.0958%2046.7832%2021.1077C46.8101%2021.1196%2046.8368%2021.1324%2046.8632%2021.1461C46.8896%2021.1599%2046.9158%2021.1747%2046.9417%2021.1904C46.9676%2021.206%2046.9933%2021.2226%2047.0186%2021.2401C47.044%2021.2576%2047.0691%2021.2759%2047.0938%2021.2952C47.1185%2021.3145%2047.143%2021.3346%2047.167%2021.3557C47.191%2021.3767%2047.2148%2021.3986%2047.2381%2021.4214C47.2614%2021.4441%2047.2843%2021.4676%2047.3068%2021.4919C47.3294%2021.5163%2047.3515%2021.5415%2047.3732%2021.5674C47.3949%2021.5934%2047.4161%2021.6201%2047.4369%2021.6477C47.4577%2021.6751%2047.478%2021.7033%2047.4978%2021.7323C47.5177%2021.7612%2047.537%2021.7908%2047.5559%2021.8211C47.5747%2021.8514%2047.5931%2021.8824%2047.6109%2021.9141C47.6286%2021.9457%2047.646%2021.9779%2047.6627%2022.0108C47.6794%2022.0436%2047.6954%2022.077%2047.7111%2022.1111C47.7267%2022.1451%2047.7417%2022.1796%2047.7561%2022.2147C47.7705%2022.2499%2047.7844%2022.2855%2047.7976%2022.3215C47.8108%2022.3576%2047.8234%2022.3941%2047.8354%2022.4311C47.8474%2022.4681%2047.8587%2022.5055%2047.8695%2022.5434C47.8803%2022.5811%2047.8904%2022.6193%2047.8998%2022.6578C47.9092%2022.6964%2047.918%2022.7352%2047.9262%2022.7743C47.9343%2022.8135%2047.9418%2022.8529%2047.9487%2022.8926C47.9554%2022.9323%2047.9616%2022.9721%2047.9671%2023.0122C47.9725%2023.0524%2047.9773%2023.0928%2047.9814%2023.1332C47.9855%2023.1737%2047.989%2023.2142%2047.9918%2023.2549C47.9946%2023.2957%2047.9966%2023.3365%2047.9979%2023.3773C47.9993%2023.4182%2048%2023.4591%2048%2023.5Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M2.77325%2047L32.7244%2018.0388L29.9511%2015.3572L0%2044.3184L2.77325%2047Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3cpath%20d='M41.3441%2025.7529L47.9999%200.999853L22.1448%207.18811L41.3441%2025.7529Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M46%2048L2%2048C1.96725%2048%201.93454%2047.9992%201.90188%2047.9976C1.86917%2047.996%201.83652%2047.9936%201.80394%2047.9904C1.77139%2047.9872%201.73894%2047.9832%201.70656%2047.9784C1.67419%2047.9736%201.64194%2047.9679%201.60981%2047.9616C1.57773%2047.9552%201.54581%2047.948%201.51406%2047.9401C1.48231%2047.9321%201.45077%2047.9234%201.41944%2047.9139C1.38811%2047.9044%201.35704%2047.8941%201.32625%2047.8831C1.29542%2047.8721%201.26488%2047.8603%201.23462%2047.8478C1.20438%2047.8352%201.17446%2047.8219%201.14488%2047.8079C1.11529%2047.794%201.08606%2047.7793%201.05719%2047.7638C1.02836%2047.7484%200.999894%2047.7323%200.971812%2047.7154C0.943731%2047.6986%200.916081%2047.6811%200.888875%2047.6629C0.861669%2047.6447%200.834919%2047.6259%200.808625%2047.6064C0.782331%2047.5869%200.756519%2047.5668%200.731188%2047.546C0.705894%2047.5252%200.681125%2047.5039%200.656875%2047.4819C0.632625%2047.4599%200.608938%2047.4374%200.585813%2047.4142C0.562646%2047.3911%200.540083%2047.3674%200.518124%2047.3431C0.496125%2047.3189%200.474749%2047.2941%200.454001%2047.2688C0.433209%2047.2435%200.413062%2047.2177%200.393562%2047.1914C0.374063%2047.1651%200.355229%2047.1383%200.337063%2047.1111C0.318896%2047.0839%200.301396%2047.0563%200.284562%2047.0282C0.267729%2047.0001%200.251604%2046.9716%200.236188%2046.9428C0.220729%2046.9139%200.206001%2046.8847%200.192001%2046.8551C0.178001%2046.8255%200.16475%2046.7956%200.15225%2046.7654C0.139709%2046.7351%200.127937%2046.7046%200.116938%2046.6738C0.105896%2046.6429%200.095625%2046.6119%200.0861256%2046.5806C0.076625%2046.5493%200.0678956%2046.5177%200.0599375%2046.4859C0.0519791%2046.4542%200.0448122%2046.4222%200.0384378%2046.3902C0.0320625%2046.3581%200.0264587%2046.3258%200.0216246%2046.2934C0.0168333%2046.2611%200.0128336%2046.2286%200.00962544%2046.1961C0.00641631%2046.1635%200.00402069%2046.1308%200.00243759%2046.0981C0.000812531%2046.0654%200%2046.0327%200%2046L0%202C0%201.96725%200.000812531%201.93454%200.00243759%201.90188C0.00402069%201.86917%200.00641631%201.83652%200.00962544%201.80394C0.0128336%201.77139%200.0168333%201.73894%200.0216246%201.70656C0.0264587%201.67419%200.0320625%201.64194%200.0384378%201.60981C0.0448122%201.57773%200.0519791%201.54581%200.0599375%201.51406C0.0678956%201.48231%200.076625%201.45077%200.0861256%201.41944C0.095625%201.38811%200.105896%201.35704%200.116938%201.32625C0.127937%201.29542%200.139709%201.26488%200.15225%201.23462C0.16475%201.20438%200.178001%201.17446%200.192001%201.14488C0.206001%201.11529%200.220729%201.08606%200.236188%201.05719C0.251604%201.02836%200.267729%200.999894%200.284562%200.971812C0.301396%200.943731%200.318896%200.916081%200.337063%200.888875C0.355229%200.861669%200.374063%200.834919%200.393562%200.808625C0.413062%200.782331%200.433209%200.756519%200.454001%200.731188C0.474749%200.705894%200.496125%200.681125%200.518124%200.656875C0.540083%200.632625%200.562646%200.608938%200.585813%200.585813C0.608938%200.562646%200.632625%200.540083%200.656875%200.518124C0.681125%200.496125%200.705894%200.474749%200.731188%200.454001C0.756519%200.433209%200.782331%200.413062%200.808625%200.393562C0.834919%200.374063%200.861669%200.355229%200.888875%200.337063C0.916081%200.318896%200.943731%200.301396%200.971812%200.284562C0.999894%200.267729%201.02836%200.251604%201.05719%200.236188C1.08606%200.220729%201.11529%200.206001%201.14488%200.192001C1.17446%200.178001%201.20438%200.16475%201.23462%200.15225C1.26488%200.139709%201.29542%200.127937%201.32625%200.116938C1.35704%200.105896%201.38811%200.095625%201.41944%200.0861256C1.45077%200.076625%201.48231%200.0678956%201.51406%200.0599375C1.54581%200.0519791%201.57773%200.0448122%201.60981%200.0384378C1.64194%200.0320625%201.67419%200.0264587%201.70656%200.0216246C1.73894%200.0168333%201.77139%200.0128336%201.80394%200.00962544C1.83652%200.00641631%201.86917%200.00402069%201.90188%200.00243759C1.93454%200.000812531%201.96725%200%202%200L46%200C46.0327%200%2046.0654%200.000812531%2046.0981%200.00243759C46.1308%200.00402069%2046.1635%200.00641631%2046.1961%200.00962544C46.2286%200.0128336%2046.2611%200.0168333%2046.2934%200.0216246C46.3258%200.0264587%2046.3581%200.0320625%2046.3902%200.0384378C46.4222%200.0448122%2046.4542%200.0519791%2046.4859%200.0599375C46.5177%200.0678956%2046.5493%200.076625%2046.5806%200.0861256C46.6119%200.095625%2046.6429%200.105896%2046.6738%200.116938C46.7046%200.127937%2046.7351%200.139709%2046.7654%200.15225C46.7956%200.16475%2046.8256%200.178001%2046.8551%200.192001C46.8847%200.206001%2046.9139%200.220729%2046.9428%200.236188C46.9716%200.251604%2047.0001%200.267729%2047.0282%200.284562C47.0563%200.301396%2047.0839%200.318896%2047.1111%200.337063C47.1383%200.355229%2047.1651%200.374063%2047.1914%200.393562C47.2177%200.413062%2047.2435%200.433209%2047.2688%200.454001C47.2941%200.474749%2047.3189%200.496125%2047.3431%200.518124C47.3674%200.540083%2047.3911%200.562646%2047.4142%200.585813C47.4374%200.608938%2047.4599%200.632625%2047.4819%200.656875C47.5039%200.681125%2047.5252%200.705894%2047.546%200.731188C47.5668%200.756519%2047.5869%200.782331%2047.6064%200.808625C47.6259%200.834919%2047.6447%200.861669%2047.6629%200.888875C47.6811%200.916081%2047.6986%200.943731%2047.7154%200.971812C47.7323%200.999894%2047.7484%201.02836%2047.7638%201.05719C47.7793%201.08606%2047.794%201.11529%2047.808%201.14488C47.8219%201.17446%2047.8352%201.20438%2047.8478%201.23462C47.8603%201.26488%2047.8721%201.29542%2047.8831%201.32625C47.8941%201.35704%2047.9044%201.38811%2047.9139%201.41944C47.9234%201.45077%2047.9321%201.48231%2047.9401%201.51406C47.948%201.54581%2047.9552%201.57773%2047.9616%201.60981C47.9679%201.64194%2047.9736%201.67419%2047.9784%201.70656C47.9832%201.73894%2047.9872%201.77139%2047.9904%201.80394C47.9936%201.83652%2047.996%201.86917%2047.9976%201.90188C47.9992%201.93454%2048%201.96725%2048%202L48%2046C48%2046.0327%2047.9992%2046.0654%2047.9976%2046.0981C47.996%2046.1308%2047.9936%2046.1635%2047.9904%2046.1961C47.9872%2046.2286%2047.9832%2046.2611%2047.9784%2046.2934C47.9736%2046.3258%2047.9679%2046.3581%2047.9616%2046.3902C47.9552%2046.4222%2047.948%2046.4542%2047.9401%2046.4859C47.9321%2046.5177%2047.9234%2046.5493%2047.9139%2046.5806C47.9044%2046.6119%2047.8941%2046.6429%2047.8831%2046.6738C47.8721%2046.7046%2047.8603%2046.7351%2047.8478%2046.7654C47.8352%2046.7956%2047.8219%2046.8256%2047.8079%2046.8551C47.794%2046.8847%2047.7793%2046.9139%2047.7638%2046.9428C47.7484%2046.9716%2047.7323%2047.0001%2047.7154%2047.0282C47.6986%2047.0563%2047.6811%2047.0839%2047.6629%2047.1111C47.6447%2047.1383%2047.6259%2047.1651%2047.6064%2047.1914C47.5869%2047.2177%2047.5668%2047.2435%2047.546%2047.2688C47.5252%2047.2941%2047.5039%2047.3189%2047.4819%2047.3431C47.4599%2047.3674%2047.4374%2047.3911%2047.4142%2047.4142C47.3911%2047.4374%2047.3674%2047.4599%2047.3431%2047.4819C47.3189%2047.5039%2047.2941%2047.5252%2047.2688%2047.546C47.2435%2047.5668%2047.2177%2047.5869%2047.1914%2047.6064C47.1651%2047.6259%2047.1383%2047.6447%2047.1111%2047.6629C47.0839%2047.6811%2047.0563%2047.6986%2047.0282%2047.7154C47.0001%2047.7323%2046.9716%2047.7484%2046.9428%2047.7638C46.9139%2047.7793%2046.8847%2047.794%2046.8551%2047.808C46.8255%2047.8219%2046.7956%2047.8352%2046.7654%2047.8478C46.7351%2047.8603%2046.7046%2047.8721%2046.6738%2047.8831C46.6429%2047.8941%2046.6119%2047.9044%2046.5806%2047.9139C46.5493%2047.9234%2046.5177%2047.9321%2046.4859%2047.9401C46.4542%2047.948%2046.4222%2047.9552%2046.3902%2047.9616C46.3581%2047.9679%2046.3258%2047.9736%2046.2934%2047.9784C46.2611%2047.9832%2046.2286%2047.9872%2046.1961%2047.9904C46.1635%2047.9936%2046.1308%2047.996%2046.0981%2047.9976C46.0654%2047.9992%2046.0327%2048%2046%2048ZM4%2044L44%2044L44%204L4%204L4%2044Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M24%2048C10.7668%2048%200%2037.2332%200%2024C0%2010.7668%2010.7668%200%2024%200C37.2332%200%2048%2010.7668%2048%2024C48%2037.2332%2037.2332%2048%2024%2048ZM24%203.69231C12.8031%203.69231%203.69231%2012.8031%203.69231%2024C3.69231%2035.1969%2012.8031%2044.3077%2024%2044.3077C35.1969%2044.3077%2044.3077%2035.1969%2044.3077%2024C44.3077%2012.8031%2035.1969%203.69231%2024%203.69231Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M24.0001%2048C22.6801%2048%2021.6001%2046.9425%2021.6001%2045.65L21.6001%203.35C21.6001%202.0575%2022.6801%201%2024.0001%201C25.3201%201%2026.4001%202.0575%2026.4001%203.35L26.4001%2045.65C26.4001%2046.9425%2025.3201%2048%2024.0001%2048Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3cpath%20d='M0%203.35C0%202.0575%201.08%201%202.4%201L45.6%201C46.92%201%2048%202.0575%2048%203.35C48%204.6425%2046.92%205.7%2045.6%205.7L2.4%205.7C1.08%205.7%200%204.6425%200%203.35Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M31.6062%205.51994L31.6062%205.56835L31.6062%205.39893C31.6062%205.44249%2031.6062%205.48122%2031.6062%205.52478C31.6062%205.51994%2031.6062%205.5151%2031.6062%205.51026C31.6062%205.51026%2031.6062%205.5151%2031.6062%205.51994Z'%20fill='%23FFFFFF'%20%3e%3c/path%3e%3cpath%20d='M47%2024C47%2021.2305%2045.7237%2018.6513%2043.5889%2016.9719C45.7237%2015.2926%2047%2012.7134%2047%209.94392C47%205.0127%2042.9856%201%2038.0524%201C35.2865%201%2032.7108%202.27108%2031.0308%204.40036C29.3462%202.27108%2026.7752%201%2024.0046%201C21.234%201%2018.6537%202.27571%2016.9738%204.40964C15.2938%202.27571%2012.7135%201%209.94289%201C5.01432%201%201%205.0127%201%209.94392C1%2012.7134%202.27623%2015.2926%204.41101%2016.9719C2.27623%2018.6513%201%2021.2305%201%2024C1%2026.7694%202.27623%2029.3487%204.41101%2031.028C2.27623%2032.7073%201%2035.2866%201%2038.056C1%2042.9872%205.01432%2047%209.94753%2047C12.7181%2047%2015.2984%2045.7242%2016.9784%2043.5903C18.6584%2045.7242%2021.2387%2047%2024.0093%2047C26.7752%2047%2029.3509%2045.7289%2031.0308%2043.5996C32.7108%2045.7242%2035.2865%2047%2038.0524%2047C42.9856%2047%2047%2042.9872%2047%2038.056C47%2035.2866%2045.7237%2032.7073%2043.5889%2031.028C45.7237%2029.3487%2047%2026.7694%2047%2024ZM41.4124%2031.863C43.6864%2033.097%2045.0972%2035.4721%2045.0972%2038.056C45.0972%2041.9388%2041.9368%2045.098%2038.0524%2045.098C35.4675%2045.098%2033.096%2043.6877%2031.8615%2041.4146L31.0401%2039.907L31.0262%2039.8791L30.9612%2040.0044L30.1908%2041.4193C30.1816%2041.4378%2030.1676%2041.461%2030.1537%2041.4796L30.1305%2041.5213L30.1444%2041.5306C28.8914%2043.7388%2026.5524%2045.1026%2024.0139%2045.1026C21.429%2045.1026%2019.0575%2043.6924%2017.8184%2041.4193L16.983%2039.8791L16.1477%2041.4193C14.9132%2043.6924%2012.5371%2045.1026%209.95217%2045.1026C6.06779%2045.1026%202.90739%2041.9435%202.90739%2038.0607C2.90739%2035.4768%204.3182%2033.1063%206.59221%2031.8677L8.13296%2031.0326L6.59221%2030.1976C4.3182%2028.9637%202.90739%2026.5885%202.90739%2024.0046C2.90739%2021.4207%204.3182%2019.0502%206.59221%2017.8116L8.13296%2016.9766L6.59221%2016.1416C4.3182%2014.9076%202.90739%2012.5325%202.90739%209.94856C2.90739%206.06575%206.06779%202.90661%209.95217%202.90661C12.5371%202.90661%2014.9086%204.31686%2016.1477%206.58995L16.983%208.13008L17.8184%206.58995C19.0528%204.31686%2021.429%202.90661%2024.0139%202.90661C26.5571%202.90661%2028.8914%204.27047%2030.1444%206.47861L30.1305%206.48789L30.1584%206.53428C30.1676%206.55284%2030.1816%206.57603%2030.1908%206.59459L30.9612%208.00947L31.0262%208.13472L31.0401%208.10689L31.8615%206.59923C33.096%204.32614%2035.4721%202.91589%2038.0571%202.91589C41.9414%202.91589%2045.1019%206.07503%2045.1019%209.95784C45.1019%2012.5417%2043.691%2014.9122%2041.417%2016.1509L39.8763%2016.9859L41.417%2017.8209C43.691%2019.0548%2045.1019%2021.43%2045.1019%2024.0139C45.1019%2026.5978%2043.691%2028.9683%2041.417%2030.2069L39.8763%2031.0419L41.4124%2031.863Z'%20stroke='rgba(44,%2044,%2044,%201)'%20stroke-width='1'%20fill='%232C2C2C'%20%3e%3c/path%3e%3cpath%20d='M31.6062%205.51994L31.6062%205.56835L31.6062%205.39893C31.6062%205.44249%2031.6062%205.48122%2031.6062%205.52478C31.6062%205.51994%2031.6062%205.5151%2031.6062%205.51026C31.6062%205.51026%2031.6062%205.5151%2031.6062%205.51994Z'%20fill='%23000000'%20%3e%3c/path%3e%3c/svg%3e",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},TB=new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M31.6062%205.51994L31.6062%205.56835L31.6062%205.39893C31.6062%205.44249%2031.6062%205.48122%2031.6062%205.52478C31.6062%205.51994%2031.6062%205.5151%2031.6062%205.51026C31.6062%205.51026%2031.6062%205.5151%2031.6062%205.51994Z'%20fill='%23FFFFFF'%20%3e%3c/path%3e%3cpath%20d='M31.6062%205.51994L31.6062%205.56835L31.6062%205.39893C31.6062%205.44249%2031.6062%205.48122%2031.6062%205.52478C31.6062%205.51994%2031.6062%205.5151%2031.6062%205.51026C31.6062%205.51026%2031.6062%205.5151%2031.6062%205.51994Z'%20fill='%23000000'%20%3e%3c/path%3e%3cpath%20d='M47.4452%2011.6515L36.3485%200.55483C35.6088%20-0.184944%2034.4422%20-0.184944%2033.7024%200.55483L0.55483%2033.7024C-0.184944%2034.4422%20-0.184944%2035.6088%200.55483%2036.3485L11.6515%2047.4452C12.3912%2048.1849%2013.5578%2048.1849%2014.2976%2047.4452L47.4452%2014.2976C48.1849%2013.5862%2048.1849%2012.3912%2047.4452%2011.6515ZM12.9887%2043.4618L4.53823%2035.0113L6.6722%2032.8773L8.1233%2034.3284C8.86307%2035.0682%2010.0296%2035.0682%2010.7694%2034.3284C11.5092%2033.5886%2011.5092%2032.4221%2010.7694%2031.6823L9.31832%2030.2312L11.4523%2028.0972L12.9034%2029.5483C13.6432%2030.2881%2014.8097%2030.2881%2015.5495%2029.5483C16.2893%2028.8085%2016.2893%2027.642%2015.5495%2026.9022L14.0984%2025.4511L16.2324%2023.3171L17.6835%2024.7682C18.4232%2025.508%2019.5898%2025.508%2020.3296%2024.7682C21.0694%2024.0285%2021.0694%2022.8619%2020.3296%2022.1221L18.8785%2020.671L21.0124%2018.537L22.4635%2019.9881C23.2033%2020.7279%2024.3699%2020.7279%2025.1097%2019.9881C25.8494%2019.2484%2025.8494%2018.0818%2025.1097%2017.342L23.6586%2015.8909L25.7925%2013.757L27.2436%2015.2081C27.9834%2015.9478%2029.15%2015.9478%2029.8897%2015.2081C30.6295%2014.4683%2030.6295%2013.3017%2029.8897%2012.5619L28.4386%2011.1108L30.5726%208.97688L32.0237%2010.428C32.7635%2011.1678%2033.9301%2011.1678%2034.6698%2010.428C35.4096%209.6882%2035.4096%208.52164%2034.6698%207.78186L33.2187%206.33076L35.0682%204.48133L43.5187%2012.9318L12.9887%2043.4618Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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,DB=new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M1%201L6.11109%201L6.11109%205.88887L1%205.88887L1%201ZM11.2222%201L16.3333%201L16.3333%205.88887L11.2222%205.88887L11.2222%201ZM21.4444%201L26.5556%201L26.5556%205.88887L21.4444%205.88887L21.4444%201ZM31.6667%201L36.7778%201L36.7778%205.88887L31.6667%205.88887L31.6667%201ZM41.8889%201L47%201L47%205.88887L41.8889%205.88887L41.8889%201ZM41.8889%2010.7778L47%2010.7778L47%2015.6667L41.8889%2015.6667L41.8889%2010.7778ZM1%2040.1111L6.11109%2040.1111L6.11109%2045L1%2045L1%2040.1111ZM1%2030.3333L6.11109%2030.3333L6.11109%2035.2222L1%2035.2222L1%2030.3333ZM1%2020.5555L6.11109%2020.5555L6.11109%2025.4445L1%2025.4445L1%2020.5555ZM1%2010.7778L6.11109%2010.7778L6.11109%2015.6667L1%2015.6667L1%2010.7778ZM20.5934%2020.5555L23.241%2016.7545C23.2556%2016.7337%2023.2704%2016.713%2023.2856%2016.6926C23.3007%2016.6723%2023.3162%2016.6521%2023.332%2016.6322C23.3479%2016.6123%2023.364%2016.5926%2023.3805%2016.5731C23.397%2016.5537%2023.4137%2016.5345%2023.4307%2016.5156C23.4478%2016.4966%2023.4653%2016.4779%2023.4829%2016.4594C23.5006%2016.441%2023.5186%2016.4228%2023.5368%2016.4049C23.5551%2016.3869%2023.5736%2016.3693%2023.5924%2016.3519C23.6113%2016.3346%2023.6304%2016.3175%2023.6497%2016.3007C23.6691%2016.2839%2023.6887%2016.2673%2023.7087%2016.2511C23.7286%2016.2349%2023.7487%2016.219%2023.7691%2016.2033C23.7895%2016.1877%2023.8102%2016.1723%2023.8311%2016.1573C23.852%2016.1422%2023.8731%2016.1275%2023.8945%2016.1131C23.9159%2016.0987%2023.9375%2016.0846%2023.9594%2016.0708C23.9812%2016.057%2024.0032%2016.0435%2024.0255%2016.0304C24.0478%2016.0173%2024.0703%2016.0045%2024.093%2015.992C24.1157%2015.9795%2024.1385%2015.9674%2024.1615%2015.9556C24.1846%2015.9438%2024.2079%2015.9323%2024.2313%2015.9212C24.2547%2015.9101%2024.2783%2015.8993%2024.3021%2015.8889C24.3259%2015.8785%2024.3499%2015.8684%2024.3739%2015.8587C24.3981%2015.849%2024.4223%2015.8396%2024.4467%2015.8306C24.4711%2015.8216%2024.4956%2015.813%2024.5204%2015.8047C24.5451%2015.7964%2024.5698%2015.7885%2024.5948%2015.7809C24.6197%2015.7733%2024.6448%2015.7661%2024.6699%2015.7593C24.6951%2015.7525%2024.7204%2015.746%2024.7458%2015.7399C24.7711%2015.7339%2024.7966%2015.7281%2024.8221%2015.7228C24.8477%2015.7175%2024.8733%2015.7126%2024.899%2015.708C24.9247%2015.7034%2024.9505%2015.6992%2024.9764%2015.6954C25.0022%2015.6915%2025.0282%2015.6881%2025.0541%2015.6851C25.0801%2015.682%2025.1061%2015.6793%2025.1322%2015.677C25.1582%2015.6747%2025.1843%2015.6728%2025.2104%2015.6713C25.2365%2015.6697%2025.2626%2015.6686%2025.2888%2015.6678C25.315%2015.6671%2025.3411%2015.6667%2025.3672%2015.6667L32.855%2015.6667C32.8812%2015.6667%2032.9073%2015.6671%2032.9335%2015.6678C32.9596%2015.6686%2032.9858%2015.6697%2033.0119%2015.6713C33.0379%2015.6728%2033.064%2015.6747%2033.0901%2015.677C33.1161%2015.6793%2033.1421%2015.682%2033.1681%2015.6851C33.194%2015.6881%2033.2199%2015.6915%2033.2458%2015.6954C33.2716%2015.6992%2033.2975%2015.7034%2033.3231%2015.708C33.3488%2015.7126%2033.3745%2015.7175%2033.4001%2015.7228C33.4256%2015.7281%2033.4511%2015.7339%2033.4765%2015.7399C33.5018%2015.7461%2033.5271%2015.7525%2033.5523%2015.7593C33.5775%2015.7661%2033.6025%2015.7733%2033.6275%2015.7809C33.6524%2015.7885%2033.6772%2015.7964%2033.7019%2015.8047C33.7265%2015.813%2033.7511%2015.8216%2033.7755%2015.8306C33.7999%2015.8396%2033.8242%2015.849%2033.8483%2015.8587C33.8724%2015.8684%2033.8963%2015.8785%2033.9201%2015.8889C33.9438%2015.8993%2033.9675%2015.9101%2033.9909%2015.9212C34.0143%2015.9323%2034.0376%2015.9438%2034.0606%2015.9556C34.0837%2015.9674%2034.1066%2015.9795%2034.1293%2015.992C34.152%2016.0045%2034.1744%2016.0173%2034.1967%2016.0304C34.2189%2016.0435%2034.241%2016.057%2034.2629%2016.0708C34.2847%2016.0846%2034.3063%2016.0987%2034.3277%2016.1131C34.349%2016.1275%2034.3702%2016.1422%2034.3911%2016.1573C34.412%2016.1723%2034.4327%2016.1877%2034.4531%2016.2033C34.4735%2016.219%2034.4936%2016.2349%2034.5136%2016.2511C34.5335%2016.2673%2034.5531%2016.2839%2034.5725%2016.3007C34.5919%2016.3175%2034.611%2016.3346%2034.6298%2016.3519C34.6486%2016.3693%2034.6671%2016.3869%2034.6854%2016.4049C34.7037%2016.4228%2034.7217%2016.441%2034.7393%2016.4594C34.757%2016.4779%2034.7744%2016.4966%2034.7914%2016.5156C34.8085%2016.5345%2034.8253%2016.5537%2034.8417%2016.5731C34.8582%2016.5926%2034.8743%2016.6123%2034.8901%2016.6322C34.906%2016.6521%2034.9215%2016.6723%2034.9367%2016.6926C34.9518%2016.713%2034.9667%2016.7337%2034.9812%2016.7545L37.6288%2020.5555L44.4444%2020.5555C44.4863%2020.5555%2044.5281%2020.5565%2044.5698%2020.5585C44.6116%2020.5605%2044.6533%2020.5634%2044.6949%2020.5673C44.7365%2020.5712%2044.778%2020.5761%2044.8194%2020.582C44.8608%2020.5879%2044.902%2020.5947%2044.943%2020.6025C44.984%2020.6104%2045.0248%2020.6191%2045.0654%2020.6288C45.1059%2020.6386%2045.1462%2020.6492%2045.1863%2020.6608C45.2263%2020.6725%2045.266%2020.685%2045.3054%2020.6984C45.3447%2020.7119%2045.3838%2020.7263%2045.4224%2020.7416C45.461%2020.7569%2045.4993%2020.7731%2045.5371%2020.7903C45.5749%2020.8074%2045.6122%2020.8253%2045.6491%2020.8442C45.686%2020.863%2045.7224%2020.8828%2045.7582%2020.9034C45.7941%2020.9239%2045.8295%2020.9453%2045.8643%2020.9675C45.899%2020.9897%2045.9332%2021.0128%2045.9668%2021.0366C46.0004%2021.0604%2046.0333%2021.085%2046.0657%2021.1104C46.098%2021.1358%2046.1297%2021.1619%2046.1606%2021.1888C46.1916%2021.2157%2046.222%2021.2432%2046.2515%2021.2715C46.2811%2021.2998%2046.3099%2021.3288%2046.338%2021.3584C46.3661%2021.388%2046.3934%2021.4183%2046.4199%2021.4493C46.4464%2021.4802%2046.4721%2021.5117%2046.4971%2021.5438C46.522%2021.576%2046.5461%2021.6087%2046.5693%2021.642C46.5925%2021.6752%2046.6149%2021.709%2046.6364%2021.7433C46.6579%2021.7776%2046.6785%2021.8124%2046.6982%2021.8477C46.7179%2021.883%2046.7368%2021.9187%2046.7546%2021.9549C46.7725%2021.991%2046.7895%2022.0276%2046.8055%2022.0645C46.8214%2022.1015%2046.8365%2022.1388%2046.8506%2022.1765C46.8647%2022.2141%2046.8778%2022.2521%2046.89%2022.2904C46.9021%2022.3287%2046.9133%2022.3673%2046.9234%2022.4061C46.9336%2022.4448%2046.9427%2022.4839%2046.9509%2022.5231C46.959%2022.5623%2046.9662%2022.6017%2046.9723%2022.6413C46.9785%2022.6809%2046.9836%2022.7206%2046.9877%2022.7604C46.9918%2022.8002%2046.9949%2022.8401%2046.9969%2022.88C46.999%2022.92%2047%2022.96%2047%2023L47%2042.5555C47%2042.5956%2046.999%2042.6356%2046.9969%2042.6755C46.9949%2042.7154%2046.9918%2042.7553%2046.9877%2042.7951C46.9836%2042.8349%2046.9785%2042.8747%2046.9723%2042.9142C46.9662%2042.9538%2046.959%2042.9932%2046.9509%2043.0324C46.9427%2043.0717%2046.9336%2043.1107%2046.9234%2043.1495C46.9133%2043.1883%2046.9021%2043.2268%2046.89%2043.2652C46.8778%2043.3034%2046.8647%2043.3414%2046.8506%2043.379C46.8365%2043.4167%2046.8214%2043.454%2046.8055%2043.491C46.7895%2043.5279%2046.7725%2043.5646%2046.7546%2043.6007C46.7368%2043.6369%2046.7179%2043.6726%2046.6982%2043.7078C46.6785%2043.7431%2046.6579%2043.7779%2046.6364%2043.8122C46.6149%2043.8465%2046.5925%2043.8803%2046.5693%2043.9136C46.5461%2043.9469%2046.522%2043.9796%2046.4971%2044.0117C46.4722%2044.0439%2046.4464%2044.0754%2046.4199%2044.1063C46.3934%2044.1372%2046.3661%2044.1675%2046.338%2044.1971C46.3099%2044.2268%2046.2811%2044.2558%2046.2515%2044.284C46.222%2044.3123%2046.1916%2044.3399%2046.1606%2044.3668C46.1297%2044.3936%2046.098%2044.4198%2046.0657%2044.4451C46.0333%2044.4705%2046.0004%2044.4951%2045.9668%2044.5189C45.9332%2044.5428%2045.899%2044.5658%2045.8643%2044.588C45.8295%2044.6102%2045.7941%2044.6317%2045.7582%2044.6522C45.7224%2044.6728%2045.686%2044.6925%2045.6491%2044.7114C45.6122%2044.7302%2045.5749%2044.7482%2045.5371%2044.7653C45.4993%2044.7824%2045.461%2044.7986%2045.4224%2044.8139C45.3838%2044.8292%2045.3447%2044.8437%2045.3054%2044.8571C45.266%2044.8706%2045.2263%2044.8831%2045.1863%2044.8948C45.1462%2044.9064%2045.1059%2044.917%2045.0654%2044.9267C45.0248%2044.9365%2044.984%2044.9452%2044.943%2044.953C44.902%2044.9609%2044.8608%2044.9677%2044.8194%2044.9735C44.778%2044.9794%2044.7365%2044.9843%2044.6949%2044.9883C44.6533%2044.9921%2044.6116%2044.9951%2044.5698%2044.9971C44.5281%2044.999%2044.4863%2045%2044.4444%2045L13.7778%2045C13.736%2045%2013.6941%2044.999%2013.6524%2044.9971C13.6106%2044.9951%2013.5689%2044.9921%2013.5273%2044.9883C13.4856%2044.9843%2013.4442%2044.9794%2013.4028%2044.9735C13.3614%2044.9677%2013.3202%2044.9609%2013.2792%2044.953C13.2382%2044.9452%2013.1974%2044.9365%2013.1568%2044.9267C13.1163%2044.917%2013.076%2044.9064%2013.0359%2044.8948C12.9959%2044.8831%2012.9562%2044.8706%2012.9168%2044.8571C12.8775%2044.8437%2012.8384%2044.8292%2012.7998%2044.8139C12.7611%2044.7986%2012.7229%2044.7824%2012.6851%2044.7653C12.6473%2044.7482%2012.61%2044.7302%2012.5731%2044.7114C12.5362%2044.6925%2012.4998%2044.6728%2012.4639%2044.6522C12.4281%2044.6317%2012.3928%2044.6102%2012.358%2044.588C12.3232%2044.5658%2012.289%2044.5428%2012.2554%2044.519C12.2218%2044.4951%2012.1889%2044.4705%2012.1566%2044.4451C12.1242%2044.4198%2012.0925%2044.3936%2012.0616%2044.3668C12.0306%2044.3399%2012.0003%2044.3123%2011.9707%2044.284C11.9412%2044.2558%2011.9123%2044.2268%2011.8842%2044.1971C11.8561%2044.1675%2011.8289%2044.1372%2011.8023%2044.1063C11.7758%2044.0754%2011.75%2044.0439%2011.7251%2044.0117C11.7002%2043.9796%2011.6761%2043.9469%2011.6529%2043.9136C11.6297%2043.8803%2011.6073%2043.8465%2011.5858%2043.8122C11.5643%2043.7779%2011.5437%2043.7431%2011.524%2043.7078C11.5043%2043.6726%2011.4855%2043.6369%2011.4676%2043.6007C11.4497%2043.5646%2011.4327%2043.5279%2011.4167%2043.491C11.4007%2043.454%2011.3857%2043.4167%2011.3716%2043.379C11.3575%2043.3414%2011.3444%2043.3034%2011.3323%2043.2652C11.3201%2043.2268%2011.309%2043.1883%2011.2988%2043.1495C11.2887%2043.1107%2011.2795%2043.0717%2011.2714%2043.0324C11.2632%2042.9932%2011.256%2042.9538%2011.2499%2042.9142C11.2437%2042.8747%2011.2387%2042.8349%2011.2345%2042.7951C11.2304%2042.7553%2011.2273%2042.7154%2011.2253%2042.6755C11.2233%2042.6356%2011.2222%2042.5956%2011.2222%2042.5555L11.2222%2023C11.2222%2022.96%2011.2233%2022.92%2011.2253%2022.88C11.2273%2022.8401%2011.2304%2022.8002%2011.2345%2022.7604C11.2387%2022.7206%2011.2437%2022.6809%2011.2499%2022.6414C11.256%2022.6018%2011.2632%2022.5623%2011.2714%2022.5231C11.2795%2022.4839%2011.2887%2022.4448%2011.2988%2022.4061C11.309%2022.3673%2011.3201%2022.3287%2011.3323%2022.2904C11.3444%2022.2521%2011.3575%2022.2141%2011.3716%2022.1765C11.3857%2022.1388%2011.4007%2022.1015%2011.4167%2022.0645C11.4327%2022.0276%2011.4497%2021.991%2011.4676%2021.9549C11.4855%2021.9187%2011.5043%2021.883%2011.524%2021.8477C11.5437%2021.8124%2011.5643%2021.7776%2011.5858%2021.7433C11.6073%2021.709%2011.6297%2021.6752%2011.6529%2021.642C11.6761%2021.6087%2011.7002%2021.576%2011.7251%2021.5438C11.75%2021.5117%2011.7758%2021.4802%2011.8023%2021.4493C11.8289%2021.4183%2011.8561%2021.388%2011.8842%2021.3584C11.9123%2021.3288%2011.9412%2021.2998%2011.9707%2021.2715C12.0003%2021.2432%2012.0306%2021.2157%2012.0616%2021.1888C12.0925%2021.1619%2012.1242%2021.1358%2012.1566%2021.1104C12.1889%2021.085%2012.2218%2021.0604%2012.2554%2021.0366C12.289%2021.0128%2012.3232%2020.9897%2012.358%2020.9675C12.3928%2020.9453%2012.4281%2020.9239%2012.4639%2020.9034C12.4998%2020.8828%2012.5362%2020.863%2012.5731%2020.8442C12.61%2020.8253%2012.6473%2020.8074%2012.6851%2020.7903C12.7229%2020.7731%2012.7612%2020.7569%2012.7998%2020.7416C12.8385%2020.7263%2012.8775%2020.7119%2012.9168%2020.6984C12.9562%2020.685%2012.9959%2020.6725%2013.0359%2020.6608C13.076%2020.6492%2013.1163%2020.6386%2013.1568%2020.6288C13.1974%2020.6191%2013.2382%2020.6103%2013.2792%2020.6025C13.3202%2020.5947%2013.3614%2020.5879%2013.4028%2020.582C13.4442%2020.5761%2013.4856%2020.5712%2013.5273%2020.5673C13.5689%2020.5634%2013.6106%2020.5605%2013.6524%2020.5585C13.6941%2020.5565%2013.736%2020.5555%2013.7778%2020.5555L20.5934%2020.5555ZM16.3333%2040.1111L41.8889%2040.1111L41.8889%2025.4445L34.8943%2025.4445L31.4878%2020.5555L26.7344%2020.5555L23.3279%2025.4445L16.3333%2025.4445L16.3333%2040.1111ZM29.1111%2037.6667C29.0274%2037.6667%2028.9439%2037.6647%2028.8603%2037.6608C28.7768%2037.6568%2028.6934%2037.651%2028.6101%2037.6431C28.5269%2037.6353%2028.4439%2037.6255%2028.3611%2037.6137C28.2784%2037.602%2028.196%2037.5883%2028.114%2037.5727C28.0319%2037.5571%2027.9504%2037.5396%2027.8692%2037.5202C27.7881%2037.5008%2027.7075%2037.4794%2027.6274%2037.4562C27.5474%2037.4329%2027.468%2037.4078%2027.3892%2037.3809C27.3104%2037.3539%2027.2325%2037.3251%2027.1552%2037.2945C27.0779%2037.2639%2027.0014%2037.2315%2026.9259%2037.1973C26.8502%2037.1631%2026.7755%2037.1271%2026.7017%2037.0894C26.628%2037.0516%2026.5552%2037.0122%2026.4835%2036.9711C26.4117%2036.93%2026.3411%2036.8872%2026.2715%2036.8428C26.202%2036.7983%2026.1336%2036.7522%2026.0664%2036.7046C25.9993%2036.6569%2025.9333%2036.6077%2025.8686%2036.5569C25.804%2036.5062%2025.7407%2036.4539%2025.6787%2036.4002C25.6167%2036.3465%2025.5562%2036.2913%2025.497%2036.2347C25.4379%2036.1782%2025.3802%2036.1203%2025.324%2036.061C25.2679%2036.0017%2025.2132%2035.9411%2025.1602%2035.8793C25.1071%2035.8174%2025.0557%2035.7543%2025.0058%2035.6901C24.956%2035.6258%2024.9078%2035.5604%2024.8614%2035.4939C24.8149%2035.4274%2024.7701%2035.3598%2024.7271%2035.2912C24.6841%2035.2225%2024.6429%2035.1529%2024.6035%2035.0824C24.5641%2035.0118%2024.5265%2034.9404%2024.4907%2034.868C24.455%2034.7957%2024.4211%2034.7226%2024.3891%2034.6487C24.357%2034.5747%2024.327%2034.5002%2024.2988%2034.4248C24.2705%2034.3495%2024.2443%2034.2735%2024.2201%2034.197C24.1958%2034.1204%2024.1735%2034.0433%2024.1532%2033.9657C24.1328%2033.8881%2024.1145%2033.81%2024.0982%2033.7315C24.0819%2033.6531%2024.0676%2033.5743%2024.0553%2033.4951C24.0431%2033.416%2024.0328%2033.3366%2024.0246%2033.257C24.0164%2033.1773%2024.0103%2033.0976%2024.0062%2033.0177C24.002%2032.9378%2024%2032.8578%2024%2032.7778C24%2032.6978%2024.002%2032.6178%2024.0062%2032.5379C24.0103%2032.458%2024.0164%2032.3782%2024.0246%2032.2986C24.0328%2032.219%2024.0431%2032.1396%2024.0553%2032.0604C24.0676%2031.9813%2024.0819%2031.9024%2024.0982%2031.824C24.1145%2031.7455%2024.1328%2031.6675%2024.1532%2031.5899C24.1735%2031.5122%2024.1958%2031.4352%2024.2201%2031.3586C24.2443%2031.282%2024.2705%2031.2061%2024.2988%2031.1308C24.327%2031.0554%2024.357%2030.9808%2024.3891%2030.9069C24.4211%2030.833%2024.455%2030.7599%2024.4907%2030.6875C24.5265%2030.6152%2024.5641%2030.5437%2024.6035%2030.4732C24.6429%2030.4026%2024.6841%2030.333%2024.7271%2030.2644C24.7701%2030.1958%2024.8149%2030.1282%2024.8614%2030.0617C24.9078%2029.9951%2024.956%2029.9297%2025.0058%2029.8655C25.0557%2029.8012%2025.1071%2029.7381%2025.1602%2029.6763C25.2132%2029.6144%2025.2679%2029.5539%2025.324%2029.4946C25.3802%2029.4353%2025.4379%2029.3774%2025.497%2029.3208C25.5562%2029.2643%2025.6167%2029.2091%2025.6787%2029.1554C25.7407%2029.1016%2025.804%2029.0494%2025.8686%2028.9986C25.9333%2028.9478%2025.9993%2028.8986%2026.0664%2028.851C26.1336%2028.8033%2026.202%2028.7572%2026.2715%2028.7128C26.3411%2028.6684%2026.4117%2028.6256%2026.4835%2028.5844C26.5552%2028.5433%2026.628%2028.5039%2026.7017%2028.4661C26.7755%2028.4284%2026.8502%2028.3925%2026.9259%2028.3583C27.0014%2028.3241%2027.0779%2028.2916%2027.1552%2028.261C27.2325%2028.2304%2027.3104%2028.2016%2027.3892%2028.1747C27.468%2028.1477%2027.5474%2028.1226%2027.6274%2028.0994C27.7075%2028.0762%2027.7881%2028.0548%2027.8692%2028.0354C27.9504%2028.016%2028.0319%2027.9985%2028.114%2027.9828C28.196%2027.9672%2028.2784%2027.9536%2028.3611%2027.9418C28.4439%2027.9301%2028.5269%2027.9203%2028.6101%2027.9124C28.6934%2027.9046%2028.7768%2027.8987%2028.8603%2027.8948C28.9439%2027.8908%2029.0274%2027.8889%2029.1111%2027.8889C29.1948%2027.8889%2029.2783%2027.8908%2029.3619%2027.8948C29.4454%2027.8987%2029.5289%2027.9046%2029.6121%2027.9124C29.6953%2027.9203%2029.7783%2027.9301%2029.861%2027.9418C29.9438%2027.9536%2030.0262%2027.9672%2030.1082%2027.9828C30.1903%2027.9985%2030.2719%2028.016%2030.353%2028.0354C30.4342%2028.0548%2030.5147%2028.0762%2030.5948%2028.0994C30.6749%2028.1226%2030.7542%2028.1477%2030.833%2028.1747C30.9117%2028.2016%2030.9898%2028.2304%2031.067%2028.261C31.1443%2028.2916%2031.2207%2028.3241%2031.2964%2028.3583C31.372%2028.3925%2031.4467%2028.4284%2031.5205%2028.4661C31.5943%2028.5039%2031.667%2028.5433%2031.7387%2028.5844C31.8105%2028.6256%2031.8812%2028.6684%2031.9507%2028.7128C32.0202%2028.7572%2032.0886%2028.8033%2032.1558%2028.851C32.223%2028.8986%2032.2889%2028.9478%2032.3536%2028.9986C32.4182%2029.0494%2032.4816%2029.1016%2032.5435%2029.1554C32.6055%2029.2091%2032.6661%2029.2643%2032.7252%2029.3208C32.7843%2029.3774%2032.842%2029.4353%2032.8982%2029.4946C32.9544%2029.5539%2033.009%2029.6144%2033.0621%2029.6763C33.1151%2029.7381%2033.1666%2029.8012%2033.2164%2029.8655C33.2662%2029.9297%2033.3144%2029.9951%2033.3608%2030.0617C33.4073%2030.1282%2033.452%2030.1958%2033.495%2030.2644C33.5381%2030.333%2033.5793%2030.4026%2033.6187%2030.4732C33.6581%2030.5437%2033.6958%2030.6152%2033.7315%2030.6875C33.7673%2030.7599%2033.8011%2030.833%2033.8332%2030.9069C33.8652%2030.9808%2033.8953%2031.0554%2033.9234%2031.1308C33.9516%2031.2061%2033.9779%2031.282%2034.0021%2031.3586C34.0264%2031.4352%2034.0487%2031.5122%2034.069%2031.5899C34.0893%2031.6675%2034.1077%2031.7455%2034.124%2031.824C34.1404%2031.9024%2034.1546%2031.9813%2034.1669%2032.0604C34.1792%2032.1396%2034.1894%2032.219%2034.1976%2032.2986C34.2058%2032.3782%2034.2119%2032.458%2034.2161%2032.5379C34.2202%2032.6178%2034.2222%2032.6978%2034.2222%2032.7778C34.2222%2032.8578%2034.2202%2032.9378%2034.2161%2033.0177C34.2119%2033.0976%2034.2058%2033.1773%2034.1976%2033.257C34.1894%2033.3366%2034.1792%2033.416%2034.1669%2033.4951C34.1546%2033.5743%2034.1404%2033.6531%2034.124%2033.7315C34.1077%2033.81%2034.0893%2033.8881%2034.069%2033.9657C34.0487%2034.0433%2034.0264%2034.1204%2034.0021%2034.197C33.9779%2034.2735%2033.9516%2034.3495%2033.9234%2034.4248C33.8953%2034.5002%2033.8652%2034.5747%2033.8332%2034.6487C33.8011%2034.7226%2033.7673%2034.7957%2033.7315%2034.868C33.6958%2034.9404%2033.6581%2035.0118%2033.6187%2035.0824C33.5793%2035.1529%2033.5381%2035.2225%2033.495%2035.2912C33.452%2035.3598%2033.4073%2035.4274%2033.3608%2035.4939C33.3144%2035.5604%2033.2662%2035.6258%2033.2164%2035.6901C33.1666%2035.7543%2033.1151%2035.8174%2033.0621%2035.8793C33.009%2035.9411%2032.9544%2036.0017%2032.8982%2036.061C32.842%2036.1203%2032.7843%2036.1782%2032.7252%2036.2347C32.6661%2036.2913%2032.6055%2036.3465%2032.5435%2036.4002C32.4816%2036.4539%2032.4182%2036.5062%2032.3536%2036.5569C32.2889%2036.6077%2032.223%2036.6569%2032.1558%2036.7046C32.0886%2036.7522%2032.0202%2036.7983%2031.9507%2036.8428C31.8812%2036.8872%2031.8105%2036.93%2031.7387%2036.9711C31.667%2037.0123%2031.5943%2037.0517%2031.5205%2037.0894C31.4467%2037.1271%2031.372%2037.1631%2031.2964%2037.1973C31.2207%2037.2315%2031.1443%2037.2639%2031.067%2037.2945C30.9898%2037.3251%2030.9117%2037.3539%2030.833%2037.3809C30.7542%2037.4078%2030.6749%2037.4329%2030.5948%2037.4562C30.5147%2037.4794%2030.4342%2037.5008%2030.353%2037.5202C30.2719%2037.5396%2030.1903%2037.5571%2030.1082%2037.5727C30.0262%2037.5883%2029.9438%2037.602%2029.861%2037.6137C29.7783%2037.6255%2029.6953%2037.6353%2029.6121%2037.6431C29.5289%2037.651%2029.4454%2037.6568%2029.3619%2037.6608C29.2783%2037.6647%2029.1948%2037.6667%2029.1111%2037.6667Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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,BB=new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M0%207L48%207L48%2010.3L0%2010.3L0%207ZM0%2016.9L48%2016.9L48%2023.5L0%2023.5L0%2016.9ZM0%2030.1L48%2030.1L48%2040L0%2040L0%2030.1Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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,PB=new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M12.1443%204L0%2041.3958L5.12362%2041.3958L8.08329%2031.7577L21.6395%2031.7577L24.5992%2041.3958L29.7665%2041.3958L17.6222%204L12.1443%204ZM9.53887%2027.0451L14.7935%2010.1281L14.9682%2010.1281L20.1791%2027.0451L9.53887%2027.0451ZM40.2806%2018.7995C37.9856%2018.7995%2036.1177%2019.2656%2034.7543%2020.2898C33.1774%2021.3946%2032.173%2023.1841%2031.7752%2025.5663L35.5451%2025.9518C35.7586%2024.7205%2036.2972%2023.8228%2037.1608%2023.2302C37.8789%2022.7181%2038.8493%2022.4649%2040.0332%2022.4649C42.8327%2022.4649%2044.2301%2023.9955%2044.2301%2027.0624L44.2301%2027.9543L40.0671%2028.0809C37.3403%2028.1672%2035.1861%2028.8059%2033.682%2030.0833C32.0323%2031.401%2031.2075%2033.3171%2031.2075%2035.7856C31.2075%2037.6154%2031.78%2039.1057%2032.9639%2040.2565C34.041%2041.4073%2035.5451%2042%2037.4859%2042C39.1356%2042%2040.5717%2041.6145%2041.7895%2040.9355C42.8667%2040.2968%2043.7643%2039.4049%2044.4824%2038.2944L44.4824%2041.4016L48%2041.4016L48%2027.3501C48%2024.6687%2047.4275%2022.626%2046.3115%2021.222C45.0161%2019.6051%2043.0074%2018.7995%2040.2806%2018.7995ZM44.2252%2031.2226L44.2252%2032.5C44.2252%2034.2032%2043.6139%2035.6475%2042.4688%2036.7983C41.3189%2037.9491%2039.9555%2038.5418%2038.3447%2038.5418C37.3743%2038.5418%2036.5883%2038.2426%2036.0109%2037.6902C35.3996%2037.1378%2035.1133%2036.4588%2035.1133%2035.6072C35.1133%2032.8855%2036.8357%2031.4355%2040.3146%2031.3492L44.2252%2031.2226Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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,LB=[{type:"distance",label:"距离"},{type:"clearDistance",label:"垂距"},{type:"clearHeight",label:"净高"},{type:"elevation",label:"标高"},{type:"point",label:"坐标"},{type:"angle",label:"角度"},{type:"area",label:"面积"},{type:"slope",label:"坡度"}],RB={distance:new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%3e%3cdefs%3e%3cstyle%3e%20.cls-1%20{%20fill:%20none;%20}%20.cls-2%20{%20clip-path:%20url(%23clip-距离);%20}%20.cls-3%20{%20clip-path:%20url(%23clip-path);%20}%20.cls-4%20{%20fill:%20%23fff;%20}%20%3c/style%3e%3cclipPath%20id='clip-path'%3e%3crect%20id='矩形_1'%20data-name='矩形%201'%20class='cls-1'%20width='32'%20height='23.606'%20transform='translate(0%200)'/%3e%3c/clipPath%3e%3cclipPath%20id='clip-距离'%3e%3crect%20width='32'%20height='32'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20id='距离'%20class='cls-2'%3e%3crect%20class='cls-4'%20width='32'%20height='32'/%3e%3cg%20id='组_2'%20data-name='组%202'%20transform='translate(0%204.197)'%3e%3cg%20id='组_1'%20data-name='组%201'%20class='cls-3'%3e%3cpath%20id='路径_1'%20data-name='路径%201'%20d='M29.692,3.03,27.55.919a.529.529,0,0,1-.014-.756A.549.549,0,0,1,28.3.15l.014.013,3.067,3.023a.529.529,0,0,1,0,.756L28.317,6.966a.549.549,0,0,1-.767.013.529.529,0,0,1-.014-.756l.014-.013L29.692,4.1H2.31L4.452,6.21a.528.528,0,0,1,.013.756.547.547,0,0,1-.766.013l-.014-.013L.616,3.942a.531.531,0,0,1,0-.756L3.685.163a.548.548,0,0,1,.767.014.528.528,0,0,1,0,.742L2.31,3.03ZM24.136,15.055H23.051V18H21.966v-2.94H20.882V18H19.8v-2.94H18.712V18H17.627v-2.94H16.543v5.078H15.458V15.055H14.373V18H13.288v-2.94H12.2V18H11.119v-2.94H10.034V18H8.949v-2.94H7.865V18H6.78v-2.94H5.7v5.078H4.61V15.055H1.9a.27.27,0,0,0-.272.268v6.413A.269.269,0,0,0,1.9,22H30.1a.268.268,0,0,0,.271-.267V15.323a.269.269,0,0,0-.271-.268H27.39v5.078H26.305V15.055H25.221V18H24.136Zm5.966-1.6A1.884,1.884,0,0,1,32,15.323v6.413a1.885,1.885,0,0,1-1.9,1.871H1.9A1.885,1.885,0,0,1,0,21.736V15.323a1.885,1.885,0,0,1,1.9-1.871Z'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M15.2619%2020.2135C15.2619%2020.8776%2014.5628%2021.2125%2014.0415%2021.0436L4.13531%2016.0541C4.10363%2016.0394%204.07281%2016.023%204.04285%2016.005C4.0129%2015.987%203.98397%2015.9675%203.95607%2015.9464C3.92817%2015.9254%203.90144%2015.9029%203.87591%2015.879C3.85037%2015.8552%203.82615%2015.83%203.80326%2015.8036L3.80909%2035.8838C3.80909%2036.8159%203.18577%2037.4393%202.2537%2037.4393C1.32163%2037.4393%200.701223%2036.8159%200.701223%2035.8838L0.701223%209.16557C0.698312%208.2335%201.31872%207.61016%202.25079%207.61016C3.18286%207.61016%203.80618%208.2335%203.80618%209.16557L3.80035%2014.8075C3.82324%2014.7811%203.84746%2014.7559%203.873%2014.7321C3.89853%2014.7082%203.92525%2014.6858%203.95315%2014.6647C3.98106%2014.6437%204.00999%2014.6242%204.03994%2014.6062C4.0699%2014.5881%204.10072%2014.5718%204.1324%2014.557L14.0444%209.56752C14.5687%209.23546%2015.2619%209.56752%2015.2619%2010.2316L15.2619%2013.9074L32.9566%2013.9074C33.3644%2013.9074%2033.6557%2013.6628%2033.7314%2013.2725L33.7488%2013.0686L33.7488%2010.2142C33.7488%209.71316%2034.3838%209.20925%2034.8557%209.54422L43.8938%2014.5803C44.0132%2014.6415%2044.1181%2014.7259%2044.2026%2014.8337L44.1968%208.07624C44.1968%207.14413%2044.8201%206.52374%2045.7521%206.52374C46.6842%206.52374%2047.3044%207.14413%2047.3044%208.07624L47.3044%2036.0383C47.3044%2036.0637%2047.3038%2036.0891%2047.3025%2036.1145C47.3016%2036.1399%2047.2998%2036.1652%2047.2974%2036.1905C47.2948%2036.2158%2047.2917%2036.241%2047.288%2036.2662C47.2842%2036.2914%2047.2798%2036.3164%2047.2749%2036.3413C47.2698%2036.3663%2047.2642%2036.3911%2047.258%2036.4157C47.252%2036.4404%2047.2453%2036.4649%2047.2378%2036.4892C47.2303%2036.5136%2047.2224%2036.5377%2047.2139%2036.5617C47.2055%2036.5856%2047.1964%2036.6093%2047.1867%2036.6328C47.1767%2036.6563%2047.1664%2036.6795%2047.1558%2036.7025C47.1448%2036.7255%2047.1334%2036.7482%2047.1216%2036.7707C47.1094%2036.7931%2047.0969%2036.8152%2047.0841%2036.837C47.0709%2036.8588%2047.0574%2036.8803%2047.0433%2036.9015C47.0289%2036.9226%2047.0142%2036.9434%2046.9992%2036.9638C46.9842%2036.9843%2046.9686%2037.0043%2046.9524%2037.024C46.9361%2037.0436%2046.9195%2037.0629%2046.9027%2037.0818C46.8855%2037.1006%2046.8679%2037.119%2046.8501%2037.137C46.8321%2037.155%2046.8137%2037.1726%2046.7949%2037.1897C46.7761%2037.2068%2046.7569%2037.2234%2046.7372%2037.2395C46.7176%2037.2557%2046.6975%2037.2713%2046.6772%2037.2865C46.6568%2037.3017%2046.636%2037.3163%2046.6149%2037.3305C46.5937%2037.3447%2046.5723%2037.3583%2046.5505%2037.3714C46.5287%2037.3845%2046.5066%2037.397%2046.4842%2037.409C46.4618%2037.4211%2046.4391%2037.4325%2046.4161%2037.4434C46.3932%2037.4543%2046.3699%2037.4646%2046.3464%2037.4744C46.323%2037.4842%2046.2993%2037.4933%2046.2754%2037.5019C46.2514%2037.5105%2046.2273%2037.5186%2046.203%2037.526C46.1786%2037.5334%2046.1542%2037.5402%2046.1296%2037.5464C46.1049%2037.5526%2046.0801%2037.5582%2046.0552%2037.5632C46.0302%2037.5683%2046.0052%2037.5726%2045.9801%2037.5764C45.9549%2037.5802%2045.9297%2037.5833%2045.9044%2037.5859C45.8791%2037.5884%2045.8537%2037.5903%2045.8284%2037.5916C45.803%2037.5929%2045.7775%2037.5936%2045.7521%2037.5936C44.8201%2037.5936%2044.1968%2036.9732%2044.1968%2036.0412L44.1997%2015.8357C44.1783%2015.8546%2044.1554%2015.8715%2044.1309%2015.8861C44.1064%2015.9008%2044.0807%2015.9131%2044.054%2015.9231L35.0188%2020.9562C34.544%2021.2912%2033.9091%2020.9562%2033.9091%2020.2863L33.9091%2017.4318C33.9091%2016.9279%2033.5887%2016.593%2033.1168%2016.593L15.2619%2016.59L15.2619%2020.2135L15.2619%2020.2135ZM41.0889%2024.2796L41.0889%2036.0412C41.0889%2036.8975%2040.3899%2037.5936%2039.5335%2037.5936C38.6014%2037.5936%2037.981%2036.9732%2037.981%2036.0412L37.981%2024.2796C37.981%2023.3475%2038.6014%2022.7243%2039.5335%2022.7243C40.4656%2022.7243%2041.0889%2023.3475%2041.0889%2024.2796ZM28.6604%2024.2796L28.6604%2036.0412C28.6603%2036.0665%2028.6596%2036.0919%2028.6584%2036.1173C28.657%2036.1426%2028.6551%2036.168%2028.6526%2036.1932C28.6501%2036.2185%2028.6469%2036.2437%2028.6432%2036.2688C28.6394%2036.2939%2028.6351%2036.3189%2028.63%2036.3438C28.625%2036.3687%2028.6194%2036.3935%2028.6133%2036.4181C28.607%2036.4427%2028.6002%2036.4672%2028.5929%2036.4915C28.5855%2036.5158%2028.5774%2036.5399%2028.5689%2036.5638C28.5603%2036.5877%2028.5512%2036.6113%2028.5414%2036.6348C28.5317%2036.6583%2028.5213%2036.6815%2028.5105%2036.7044C28.4996%2036.7274%2028.4881%2036.75%2028.4762%2036.7724C28.4642%2036.7948%2028.4517%2036.8168%2028.4386%2036.8386C28.4255%2036.8604%2028.4119%2036.8819%2028.3978%2036.903C28.3837%2036.9241%2028.369%2036.9448%2028.3539%2036.9652C28.3388%2036.9856%2028.3232%2037.0056%2028.3071%2037.0253C28.2909%2037.0449%2028.2744%2037.0641%2028.2573%2037.0829C28.2402%2037.1017%2028.2227%2037.1201%2028.2048%2037.1381C28.1868%2037.156%2028.1684%2037.1735%2028.1496%2037.1906C28.1308%2037.2076%2028.1116%2037.2242%2028.092%2037.2404C28.0723%2037.2564%2028.0523%2037.2721%2028.032%2037.2872C28.0115%2037.3024%2027.9908%2037.317%2027.9697%2037.3311C27.9486%2037.3452%2027.9272%2037.3588%2027.9054%2037.3719C27.8836%2037.385%2027.8615%2037.3975%2027.8391%2037.4094C27.8167%2037.4214%2027.7941%2037.4329%2027.7712%2037.4438C27.7482%2037.4546%2027.725%2037.4649%2027.7015%2037.4747C27.6781%2037.4844%2027.6544%2037.4936%2027.6305%2037.5022C27.6066%2037.5107%2027.5825%2037.5187%2027.5582%2037.5261C27.5339%2037.5335%2027.5094%2037.5403%2027.4848%2037.5465C27.4602%2037.5527%2027.4354%2037.5583%2027.4105%2037.5633C27.3857%2037.5683%2027.3606%2037.5727%2027.3355%2037.5765C27.3104%2037.5802%2027.2852%2037.5833%2027.2599%2037.5859C27.2347%2037.5884%2027.2094%2037.5903%2027.184%2037.5916C27.1586%2037.5929%2027.1333%2037.5936%2027.1079%2037.5936C26.1758%2037.5936%2025.5525%2036.9732%2025.5525%2036.0412L25.5525%2024.2796C25.5525%2023.3475%2026.1758%2022.7243%2027.1079%2022.7243C28.0399%2022.7243%2028.6604%2023.3475%2028.6604%2024.2796ZM10.019%2024.2796L10.019%2036.0412C10.0189%2036.0666%2010.0183%2036.092%2010.017%2036.1174C10.0156%2036.1428%2010.0138%2036.1681%2010.0112%2036.1934C10.0087%2036.2187%2010.0055%2036.2439%2010.0018%2036.2691C9.99798%2036.2942%209.99357%2036.3193%209.9886%2036.3442C9.98359%2036.3691%209.97796%2036.3939%209.97178%2036.4185C9.96554%2036.4432%209.95874%2036.4677%209.95134%2036.492C9.94393%2036.5163%209.93592%2036.5404%209.92729%2036.5644C9.91867%2036.5883%209.90952%2036.612%209.89978%2036.6355C9.88998%2036.659%209.87967%2036.6822%209.86879%2036.7051C9.85787%2036.7281%209.84638%2036.7508%209.83438%2036.7732C9.82238%2036.7956%209.80982%2036.8177%209.79674%2036.8395C9.78362%2036.8613%209.77003%2036.8828%209.75587%2036.9039C9.74171%2036.925%209.72704%2036.9458%209.7119%2036.9662C9.69671%2036.9866%209.68101%2037.0066%209.66488%2037.0262C9.64876%2037.0459%209.63212%2037.0651%209.61506%2037.0839C9.59795%2037.1027%209.58042%2037.1212%209.56242%2037.1391C9.54442%2037.1571%209.52599%2037.1745%209.50715%2037.1916C9.48826%2037.2087%209.46899%2037.2253%209.44935%2037.2414C9.42967%2037.2575%209.40965%2037.2731%209.38921%2037.2883C9.36878%2037.3034%209.34796%2037.318%209.32682%2037.3321C9.30563%2037.3462%209.28417%2037.3598%209.26237%2037.3729C9.24053%2037.3859%209.2184%2037.3984%209.19599%2037.4104C9.17359%2037.4224%209.15085%2037.4338%209.12788%2037.4446C9.10487%2037.4555%209.08162%2037.4658%209.05818%2037.4755C9.03465%2037.4852%209.01093%2037.4944%208.98703%2037.5029C8.96303%2037.5115%208.93888%2037.5195%208.9146%2037.5268C8.89023%2037.5342%208.86576%2037.541%208.8411%2037.5471C8.81645%2037.5533%208.79165%2037.5589%208.76671%2037.5638C8.74178%2037.5688%208.7167%2037.5731%208.69157%2037.5768C8.6664%2037.5805%208.64118%2037.5837%208.61587%2037.5862C8.59056%2037.5886%208.56524%2037.5905%208.53984%2037.5917C8.51443%2037.593%208.48903%2037.5936%208.46362%2037.5936C7.53156%2037.5936%206.90821%2036.9732%206.90821%2036.0412L6.90821%2024.2796C6.90821%2023.3475%207.53156%2022.7243%208.46362%2022.7243C9.39568%2022.7243%2010.0161%2023.3475%2010.0161%2024.2796L10.019%2024.2796ZM33.3207%2029.7147C34.2527%2029.7147%2034.8732%2030.3381%2034.8732%2031.2701L34.8732%2036.0412C34.8731%2036.0665%2034.8724%2036.0919%2034.8712%2036.1173C34.8699%2036.1426%2034.8679%2036.168%2034.8654%2036.1932C34.8629%2036.2185%2034.8597%2036.2437%2034.856%2036.2688C34.8522%2036.2939%2034.8478%2036.3189%2034.8429%2036.3438C34.8378%2036.3687%2034.8323%2036.3935%2034.8261%2036.4181C34.8198%2036.4427%2034.813%2036.4672%2034.8057%2036.4915C34.7983%2036.5158%2034.7903%2036.5399%2034.7817%2036.5638C34.7731%2036.5877%2034.7639%2036.6113%2034.7542%2036.6348C34.7445%2036.6583%2034.7341%2036.6815%2034.7233%2036.7044C34.7124%2036.7274%2034.701%2036.75%2034.689%2036.7724C34.677%2036.7948%2034.6644%2036.8168%2034.6514%2036.8386C34.6383%2036.8604%2034.6247%2036.8819%2034.6106%2036.903C34.5965%2036.9241%2034.5819%2036.9448%2034.5668%2036.9652C34.5516%2036.9856%2034.536%2037.0056%2034.5199%2037.0253C34.5038%2037.0449%2034.4872%2037.0641%2034.4701%2037.0829C34.453%2037.1017%2034.4356%2037.1201%2034.4176%2037.1381C34.3996%2037.156%2034.3812%2037.1735%2034.3624%2037.1906C34.3436%2037.2076%2034.3244%2037.2242%2034.3048%2037.2404C34.2851%2037.2564%2034.2652%2037.2721%2034.2448%2037.2872C34.2244%2037.3024%2034.2036%2037.317%2034.1825%2037.3311C34.1614%2037.3452%2034.1399%2037.3588%2034.1182%2037.3719C34.0964%2037.385%2034.0743%2037.3975%2034.0519%2037.4094C34.0296%2037.4214%2034.0069%2037.4329%2033.9839%2037.4438C33.961%2037.4546%2033.9378%2037.4649%2033.9144%2037.4747C33.8909%2037.4844%2033.8672%2037.4936%2033.8433%2037.5022C33.8194%2037.5107%2033.7953%2037.5187%2033.771%2037.5261C33.7467%2037.5335%2033.7223%2037.5403%2033.6977%2037.5465C33.673%2037.5527%2033.6482%2037.5583%2033.6234%2037.5633C33.5984%2037.5683%2033.5734%2037.5727%2033.5484%2037.5765C33.5232%2037.5802%2033.498%2037.5833%2033.4727%2037.5859C33.4475%2037.5884%2033.4222%2037.5903%2033.3968%2037.5916C33.3714%2037.5929%2033.3461%2037.5936%2033.3207%2037.5936C32.3886%2037.5936%2031.7682%2036.9732%2031.7682%2036.0412L31.7682%2031.2701C31.7682%2030.3381%2032.3886%2029.7147%2033.3207%2029.7147ZM22.4446%2031.2701L22.4446%2036.0412C22.4446%2036.8975%2021.7485%2037.5936%2020.8892%2037.5936C19.9572%2037.5936%2019.3367%2036.9732%2019.3367%2036.0412L19.3367%2031.2701C19.3367%2030.3381%2019.9572%2029.7147%2020.8892%2029.7147C21.8213%2029.7147%2022.4446%2030.3381%2022.4446%2031.2701ZM16.2289%2031.2701L16.2289%2036.0412C16.2288%2036.0665%2016.2282%2036.0919%2016.2269%2036.1173C16.2256%2036.1426%2016.2237%2036.168%2016.2211%2036.1932C16.2186%2036.2185%2016.2155%2036.2437%2016.2117%2036.2688C16.2079%2036.2939%2016.2036%2036.3189%2016.1986%2036.3438C16.1936%2036.3687%2016.188%2036.3935%2016.1818%2036.4181C16.1756%2036.4427%2016.1688%2036.4672%2016.1614%2036.4915C16.154%2036.5158%2016.146%2036.5399%2016.1374%2036.5638C16.1288%2036.5877%2016.1197%2036.6113%2016.11%2036.6348C16.1002%2036.6583%2016.0899%2036.6815%2016.079%2036.7044C16.0681%2036.7274%2016.0567%2036.75%2016.0447%2036.7724C16.0328%2036.7948%2016.0202%2036.8168%2016.0072%2036.8386C15.994%2036.8604%2015.9804%2036.8819%2015.9664%2036.903C15.9522%2036.9241%2015.9376%2036.9448%2015.9225%2036.9652C15.9073%2036.9856%2015.8917%2037.0056%2015.8756%2037.0253C15.8595%2037.0449%2015.8429%2037.0641%2015.8259%2037.0829C15.8088%2037.1017%2015.7913%2037.1201%2015.7734%2037.1381C15.7554%2037.156%2015.737%2037.1735%2015.7182%2037.1906C15.6994%2037.2076%2015.6801%2037.2242%2015.6605%2037.2404C15.6409%2037.2564%2015.6209%2037.2721%2015.6005%2037.2872C15.5801%2037.3024%2015.5594%2037.317%2015.5382%2037.3311C15.5171%2037.3452%2015.4957%2037.3588%2015.4739%2037.3719C15.4521%2037.385%2015.43%2037.3975%2015.4077%2037.4094C15.3853%2037.4214%2015.3626%2037.4329%2015.3397%2037.4438C15.3167%2037.4546%2015.2935%2037.4649%2015.2701%2037.4747C15.2466%2037.4844%2015.2229%2037.4936%2015.199%2037.5022C15.1751%2037.5107%2015.151%2037.5187%2015.1268%2037.5261C15.1025%2037.5335%2015.078%2037.5403%2015.0534%2037.5465C15.0287%2037.5527%2015.0039%2037.5583%2014.9791%2037.5633C14.9542%2037.5683%2014.9292%2037.5727%2014.9041%2037.5765C14.8789%2037.5802%2014.8538%2037.5833%2014.8285%2037.5859C14.8032%2037.5884%2014.7779%2037.5903%2014.7526%2037.5916C14.7271%2037.5929%2014.7018%2037.5936%2014.6764%2037.5936C13.7444%2037.5936%2013.1239%2036.9732%2013.1239%2036.0412L13.1239%2031.2701C13.1239%2030.3381%2013.7444%2029.7147%2014.6764%2029.7147C15.6085%2029.7147%2016.2289%2030.3381%2016.2289%2031.2701Z'%20fill='%23404040'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M19.0032%2032.1184C18.712%2032.1184%2018.4032%2032.1184%2018.112%2032.4096C17.512%2032.6992%2017.8224%2033.5904%2018.112%2033.8816L23.1472%2038.6256C23.7472%2038.9152%2024.6192%2038.9152%2024.928%2038.6256L29.9632%2033.8816C30.2528%2033.5904%2030.2528%2033.2816%2030.2528%2032.9904C30.2528%2032.3904%2029.6528%2032.1008%2029.072%2032.1008L25.7856%2032.1008L25.7856%2016.2192L29.0256%2016.2192C29.3152%2016.2192%2029.6256%2016.2192%2029.9152%2015.928C30.5152%2015.6368%2030.2064%2014.7472%2029.9152%2014.456L24.8816%209.7072C24.2816%209.4176%2023.4096%209.4176%2023.0992%209.7072L18.0656%2014.4512C17.7744%2014.7424%2017.7744%2015.0512%2017.7744%2015.3424C17.7744%2015.9424%2018.3744%2016.232%2018.9568%2016.232L22.24%2016.232L22.24%2032.1328L19.0016%2032.1328L19.0016%2032.1184L19.0032%2032.1184ZM4.75842%206.80639L43.2384%206.80639C44.128%206.80639%2044.7104%206.20639%2044.7104%205.33442C44.7104%204.1536%2044.1088%203.2624%2043.2384%203.2624L4.75678%203.2624C4.1568%203.2624%203.5744%203.8624%203.2848%204.73442C3.2848%205.62561%203.8848%206.5152%204.75678%206.80639L4.75842%206.80639ZM43.256%2041.1936L4.75842%2041.1936C4.1584%2041.1936%203.576%2041.7936%203.2864%2042.6656C3.2864%2043.5568%203.8864%2044.4464%204.75842%2044.7376L43.2384%2044.7376C44.128%2044.7376%2044.7104%2044.1376%2044.7104%2043.2656C44.728%2042.08%2044.1328%2041.1936%2043.256%2041.1936Z'%20fill='%23404040'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%3e%3cdefs%3e%3cstyle%3e%20.cls-1%20{%20clip-path:%20url(%23clip-标高);%20}%20.cls-2%20{%20fill:%20%23fff;%20}%20%3c/style%3e%3cclipPath%20id='clip-标高'%3e%3crect%20width='32'%20height='32'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20id='标高'%20class='cls-1'%3e%3crect%20class='cls-2'%20width='32'%20height='32'/%3e%3cpath%20id='路径_8'%20data-name='路径%208'%20d='M84.131,193.119a1.056,1.056,0,0,1,1.116.982v7.857a1.056,1.056,0,0,1-1.116.982H54.367a1.056,1.056,0,0,1-1.116-.982V194.1a1.056,1.056,0,0,1,1.116-.982Zm-1.116,1.964H55.483v5.893H83.015Zm1.116-13.749a1.064,1.064,0,0,1,1.114.935,1.032,1.032,0,0,1-1.007,1.025l-.107,0H71.2l-7.858,6.914a1.227,1.227,0,0,1-1.578,0l-8.185-7.2-.018-.016-.032-.031.049.047a1.107,1.107,0,0,1-.092-.092l-.011-.014a.869.869,0,0,1-.182-.857l0-.008L53.31,182l.012-.029.02-.045.019-.035a1.1,1.1,0,0,1,.891-.552h.007q.053,0,.107,0ZM68.043,183.3H57.06l5.492,4.831Z'%20transform='translate(-53.247%20-176.136)'/%3e%3c/g%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M40.1698%2018.0929C40.1428%2020.5301%2039.3645%2022.7586%2038.3131%2024.9092C36.7378%2028.1319%2034.6461%2031.0118%2032.3727%2033.7664C30.2564%2036.3308%2027.9853%2038.7519%2025.5613%2041.0284C24.7143%2041.8237%2023.9413%2041.8481%2023.073%2041.0687C18.5767%2037.0334%2014.5359%2032.6092%2011.4515%2027.3755C10.9495%2026.5238%2010.4945%2025.6458%2010.1025%2024.7372C9.73107%2023.8761%2010.0514%2022.9753%2010.8534%2022.6034C11.6577%2022.2304%2012.582%2022.5576%2012.9732%2023.4086C14.8167%2027.4176%2017.5132%2030.8241%2020.4598%2034.0548C21.596%2035.3006%2022.7863%2036.4939%2024.0184%2037.6454C24.1708%2037.7877%2024.2667%2037.9033%2024.4831%2037.6853C28.5664%2033.5709%2032.3892%2029.2509%2035.1723%2024.1156C35.9836%2022.6186%2036.66%2021.0543%2036.8866%2019.3498C37.2281%2016.7802%2036.712%2014.3356%2035.493%2012.0807C33.1715%207.78618%2029.5679%205.33714%2024.6496%205.16445C19.0467%204.96786%2014.0685%208.58606%2012.3051%2013.9294C11.8621%2015.2717%2011.6275%2016.6474%2011.6092%2018.061C11.5962%2019.0717%2010.9335%2019.7853%2010.0201%2019.783C9.10383%2019.7808%208.43479%2019.0505%208.43746%2018.056C8.45818%2010.5393%2013.6357%204.02759%2020.9324%202.34148C26.9693%200.946299%2033.4364%203.45514%2037.0904%208.60424C39.1088%2011.4483%2040.1115%2014.6187%2040.1698%2018.0929ZM6.42075%2043.1971C18.363%2043.1971%2030.2366%2043.1971%2042.1204%2043.1971C42.1186%2042.9919%2041.9834%2042.8579%2041.8977%2042.7076C40.3484%2039.9866%2038.7956%2037.2673%2037.2401%2034.5498C36.9062%2033.9668%2036.8856%2033.3861%2037.257%2032.8222C37.5915%2032.314%2038.0819%2032.0681%2038.6918%2032.1099C39.2399%2032.1477%2039.6712%2032.4169%2039.9425%2032.8899C42.0656%2036.5932%2044.1915%2040.2948%2046.2926%2044.0105C46.9411%2045.1576%2046.1392%2046.3818%2044.7752%2046.3821C37.6695%2046.3845%2030.564%2046.3832%2023.4585%2046.3832C16.9643%2046.3832%2010.4699%2046.3507%203.97625%2046.4082C2.51885%2046.4212%201.62531%2045.0904%202.42647%2043.7424C4.52293%2040.2152%206.51577%2036.6264%208.55216%2033.0634C8.99072%2032.2962%209.67627%2031.9592%2010.3942%2032.1457C11.456%2032.4219%2011.9181%2033.5491%2011.3553%2034.5444C10.2685%2036.467%209.16594%2038.3807%208.07099%2040.2987C7.53258%2041.2418%206.99643%2042.1859%206.42075%2043.1971ZM30.6461%2017.8271C30.6465%2021.3322%2027.7864%2024.1813%2024.2754%2024.1734C20.7946%2024.1656%2017.9554%2021.3147%2017.9555%2017.8276C17.9557%2014.3185%2020.8087%2011.4763%2024.3244%2011.4829C27.8051%2011.4893%2030.6458%2014.3402%2030.6461%2017.8271ZM24.3201%2014.6556C22.5583%2014.656%2021.1314%2016.0714%2021.1285%2017.8213C21.1256%2019.591%2022.5741%2021.0173%2024.3575%2021.0005C26.0699%2020.9844%2027.4807%2019.5391%2027.4733%2017.8085C27.4659%2016.0808%2026.0403%2014.6552%2024.3201%2014.6556Z'%20fill='%23404040'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%3e%3cdefs%3e%3cstyle%3e%20.cls-1%20{%20clip-path:%20url(%23clip-角度);%20}%20.cls-2%20{%20fill:%20%23fff;%20}%20%3c/style%3e%3cclipPath%20id='clip-角度'%3e%3crect%20width='32'%20height='32'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20id='角度'%20class='cls-1'%3e%3crect%20class='cls-2'%20width='32'%20height='32'/%3e%3cpath%20id='路径_7'%20data-name='路径%207'%20d='M39.587,50.766h13.7a1,1,0,0,1,0,2H23.171a1,1,0,0,1,0-2h1.418l6.582-7.006v-.006a.517.517,0,0,1,.14-.357.456.456,0,0,1,.337-.144l12.1-12.876a.451.451,0,0,1,.665,0,.524.524,0,0,1,0,.708L32.883,43.355a8.3,8.3,0,0,1,6.7,7.411Zm-.949,0a7.254,7.254,0,0,0-6.611-6.5l-6.108,6.5Z'%20transform='translate(-22.229%20-26.489)'/%3e%3c/g%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M28.7725%2016.8582L16.6882%2028.9801C16.0335%2029.6368%2016.0335%2030.7313%2016.6882%2031.3881C17.0156%2031.7164%2017.452%2031.8806%2017.8885%2031.8806C18.3249%2031.8806%2018.7614%2031.7164%2019.0887%2031.3881L31.173%2019.2662C31.8277%2018.6094%2031.8277%2017.5149%2031.173%2016.8582C30.5183%2016.2015%2029.4272%2016.2015%2028.7725%2016.8582Z'%20fill='%23404040'%20%3e%3c/path%3e%3cpath%20d='M44.5667%2011.9055C45.385%2011.9055%2046.0397%2011.2488%2046.0397%2010.4552L46.0397%203.47761C46.0397%202.65672%2045.385%202%2044.5667%202L37.6107%202C36.7924%202%2036.1377%202.65672%2036.1377%203.47761L36.1377%205.06468L11.9418%205.06468L11.9418%203.47761C11.9418%202.65672%2011.2871%202%2010.4688%202L3.51277%202C2.69442%202%202.03974%202.65672%202.03974%203.47761L2.03974%2010.4279C2.03974%2011.2488%202.69442%2011.9055%203.51277%2011.9055L5.20403%2011.9055L5.20403%2036.0671L3.51277%2036.0671C2.69442%2036.0671%202.03974%2036.7239%202.03974%2037.5448L2.03974%2044.5224C2.03974%2045.3433%202.69442%2046%203.51277%2046L10.4688%2046C11.2598%2046%2011.9145%2045.3433%2011.9418%2044.5224L11.9418%2042.7438L36.1377%2042.7438L36.1377%2044.5224C36.1377%2045.3433%2036.7924%2046%2037.6107%2046L44.5667%2046C45.385%2046%2046.0397%2045.3433%2046.0397%2044.5224L46.0397%2037.5448C46.0397%2036.7239%2045.385%2036.0671%2044.5667%2036.0671L42.7936%2036.0671L42.7936%2011.9055L44.5667%2011.9055ZM39.0837%204.92786L43.0937%204.92786L43.0937%208.95024L39.0837%208.95024L39.0837%204.92786ZM4.9858%204.92786L8.99572%204.92786L8.99572%208.95024L4.9858%208.95024L4.9858%204.92786ZM8.99572%2043.0448L4.9858%2043.0448L4.9858%2039.0224L8.99572%2039.0224L8.99572%2043.0448ZM43.0937%2043.0448L39.0837%2043.0448L39.0837%2039.0224L43.0937%2039.0224L43.0937%2043.0448ZM39.3838%2036.0671L37.6107%2036.0671C36.7924%2036.0671%2036.1377%2036.7239%2036.1377%2037.5448L36.1377%2039.3234L11.9418%2039.3234L11.9418%2037.5448C11.9418%2036.7239%2011.2871%2036.0671%2010.4688%2036.0671L8.61382%2036.0671L8.61382%2011.9055L10.4688%2011.9055C11.2598%2011.9055%2011.9145%2011.2488%2011.9418%2010.4552L11.9418%208.48507L36.1377%208.48507L36.1377%2010.4279C36.1377%2011.2488%2036.7924%2011.9055%2037.6107%2011.9055L39.3838%2011.9055L39.3838%2036.0671Z'%20fill='%23404040'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%3e%3cdefs%3e%3cstyle%3e%20.cls-1%20{%20clip-path:%20url(%23clip-坡度);%20}%20.cls-2%20{%20fill:%20%23fff;%20}%20%3c/style%3e%3cclipPath%20id='clip-坡度'%3e%3crect%20width='32'%20height='32'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20id='坡度'%20class='cls-1'%3e%3crect%20class='cls-2'%20width='32'%20height='32'/%3e%3cpath%20id='路径_15'%20data-name='路径%2015'%20d='M202.1,188.337l2.629-2.191-8.447-3.106,1.533,8.871,2.629-2.194,9.341,11.209,1.656-1.379Zm-13.726-.435a1.075,1.075,0,0,0-1.07-.341,1.057,1.057,0,0,0-.5.277l-5.11,4.08a1.08,1.08,0,0,0-.406.84l-.007,17.386a1.079,1.079,0,0,0,1.077,1.077L205.7,211.2a1.078,1.078,0,0,0,.822-1.774Zm-4.934,21.164.007-15.788,3.968-3.171,15.974,18.941Z'%20transform='translate(-180.36%20-181.131)'/%3e%3c/g%3e%3c/svg%3e",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 kB{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,IB[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,BB,"线宽")),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,PB,"字号")),this.distanceButton=this.createIconButton("测量",TB),this.distanceButton.onclick=()=>this.handlers.onMeasureToggle(),i.appendChild(this.distanceButton);const r=this.createIconButton("截图",DB);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",LB.forEach(c=>{const h=this.createSmallIconButton(c.label,RB[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 FB{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 kB({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?CB(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`,w=new Br(_,{fill:i.stroke,stroke:i.stroke,strokeWidth:1,selectable:!1,evented:!1,objectCaching:!1}),S=new Gs([y,w],{selectable:s,evented:s,objectCaching:!1});return S.annotationType="arrow",S}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,w=b+g*i*y;r+=` Q ${_} ${w} ${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 OB{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 C.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 C.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 C.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 UB{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.5.2";versionEl=null;container;constructor(e){if(window.THREE=C,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new ME(this),this.engineModelModule.init(),this.ai=new I5(this),this.deviceModule=new iy(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new gn(this),this.sceneModule=new ty(this),this.scene=this.sceneModule.scene,this.renderModule=new Lw(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 Jw(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new _5(this),this.clipping.init(),this.composerModule=new uS(this),this.composerModule.init(),this.events=new bE,this.engineStatus=new xE(this),this.engineStatus.init(),this.loaderModule=new AE(this),this.lightModule=new yE(this),this.lightModule.init(),this.viewCube=new rI(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=oI(this),this.rangeScale=new aI(this),this.rangeScale.init(),this.setting=new bI(this),this.engineModelModule.init(),this.handelBehaved=_u(this),this.modelMapperBatch=new M5(this),this.measure=new II(this),this.modelToolModule=new _E(this),this.modelProperties=new S5(this),this.interactionModule=new vE(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new Cc(this),this.modelEdge=new AI(this),this.modelTree=new C5(this),this.viewTree=new O5(this),this.merge2d=new W5(this),this.engineInfo=new w5(this),this.pathRoaming=new T5(this),this.pathRoaming.init(),this.oneClickEncoding=new F5(this),this.minMap=new D5(this),this.linkElement2d3d=new L5(this),this.linkView2d3d=new R5(this),this.grid=new hI(this),this.level=new mI(this),this.issueReport=new B5(this),this.fabricDraw=new FB(this),this.drawingPin=new OB(this),this.text=new P5(this),this.hdr=new fI(this),this.ground=new rf(this),this.ground.init(),this.skyManager=new xI(this),this.setting.init(),this.worldToScreen=new lt(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new DE,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 C.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 C.Vector3;e.getWorldDirection(i);const s=100,r=new C.Vector3().copy(i).multiplyScalar(-s),o=new C.Vector3(0,1,0),a=new C.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 C.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 C.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 C.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof C.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof C.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 C.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 C.Texture&&s.dispose()}),e.dispose()}}const NB=`
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:()=>bB,BlendColor:()=>$a,BlendImage:()=>Za,Blur:()=>Ja,Brightness:()=>el,Brownie:()=>fB,ColorMatrix:()=>kr,Composed:()=>Wp,Contrast:()=>tl,Convolute:()=>il,Gamma:()=>nl,Grayscale:()=>sl,HueRotation:()=>zh,Invert:()=>rl,Kodachrome:()=>gB,Noise:()=>ol,Pixelate:()=>al,Polaroid:()=>AB,RemoveColor:()=>ll,Resize:()=>cl,Saturation:()=>hl,Sepia:()=>xB,Technicolor:()=>mB,Vibrance:()=>dl,Vintage:()=>pB});function CB(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=wB(s,r,o);if(!SB(a)){const f=MB(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 wB(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 SB(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 MB(n,e,t){const i=n?.renderer,s=n?.scene,r=n?.camera;if(!i||!s||!r)return null;const o=new C.WebGLRenderTarget(e,t,{minFilter:C.LinearFilter,magFilter:C.LinearFilter,format:C.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),EB(h,e,t)}catch{return null}finally{i.setRenderTarget(a),i.autoClear=l,i.xr&&(i.xr.enabled=c),o.dispose()}}function EB(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 IB={none:new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M17.13%2045.7359L21.708%2045.7359L21.708%2048L17.13%2048L17.13%2045.7359ZM7.97408%2045.7359L12.5521%2045.7359L12.5521%2048L7.97408%2048L7.97408%2045.7359ZM2.26408%2044.6039L0%2044.6039L0%2048L3.39615%2048L3.39615%2045.7359L2.26408%2045.7359L2.26408%2044.6039ZM0%2026.2859L2.26408%2026.2859L2.26408%2030.8638L0%2030.8638L0%2026.2859ZM0%207.97408L2.26408%207.97408L2.26408%2012.5521L0%2012.5521L0%207.97408ZM0%2035.448L2.26408%2035.448L2.26408%2040.0259L0%2040.0259L0%2035.448ZM0%2017.13L2.26408%2017.13L2.26408%2021.708L0%2021.708L0%2017.13ZM0%203.39615L2.26408%203.39615L2.26408%202.26408L3.39615%202.26408L3.39615%200L0%200L0%203.39615ZM26.2921%200L30.87%200L30.87%202.26408L26.2921%202.26408L26.2921%200ZM35.448%200L40.0259%200L40.0259%202.26408L35.448%202.26408L35.448%200ZM17.13%200L21.708%200L21.708%202.26408L17.13%202.26408L17.13%200ZM7.97408%200L12.5521%200L12.5521%202.26408L7.97408%202.26408L7.97408%200ZM44.6039%200L44.6039%202.26408L45.7359%202.26408L45.7359%203.39615L48%203.39615L48%200L44.6039%200ZM45.7359%2017.13L48%2017.13L48%2021.708L45.7359%2021.708L45.7359%2017.13ZM45.7359%207.97408L48%207.97408L48%2012.5521L45.7359%2012.5521L45.7359%207.97408ZM36.4432%2031.2308L40.2747%2028.2638C40.5609%2028.0399%2040.7163%2027.6916%2040.6853%2027.3309C40.6542%2026.9701%2040.4427%2026.6466%2040.1255%2026.4787L20.7376%2016.0415C20.3644%2015.8424%2019.9104%2015.8798%2019.5745%2016.1348C19.2386%2016.396%2019.0893%2016.8252%2019.1888%2017.2357L24.4323%2038.6202C24.5194%2038.9748%2024.7744%2039.2547%2025.1165%2039.3728C25.4586%2039.491%2025.838%2039.4288%2026.1242%2039.2111L29.9557%2036.2441L38.2408%2046.9426C38.4522%2047.2163%2038.7695%2047.3593%2039.0867%2047.3593C39.3168%2047.3593%2039.547%2047.2847%2039.7398%2047.1354L44.5292%2043.4283C44.7531%2043.2541%2044.9024%2042.9991%2044.9336%2042.7192C44.9708%2042.4393%2044.89%2042.1532%2044.7158%2041.9293L36.4432%2031.2308Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M48%2023.5C48%2023.5409%2047.9993%2023.5818%2047.9979%2023.6227C47.9966%2023.6635%2047.9946%2023.7043%2047.9918%2023.7451C47.989%2023.7858%2047.9855%2023.8264%2047.9814%2023.8668C47.9773%2023.9073%2047.9725%2023.9476%2047.9671%2023.9878C47.9616%2024.0279%2047.9554%2024.0678%2047.9487%2024.1074C47.9418%2024.1471%2047.9343%2024.1865%2047.9262%2024.2257C47.918%2024.2649%2047.9092%2024.3037%2047.8998%2024.3422C47.8904%2024.3807%2047.8803%2024.4189%2047.8695%2024.4566C47.8587%2024.4945%2047.8474%2024.5319%2047.8354%2024.5689C47.8234%2024.6059%2047.8108%2024.6424%2047.7976%2024.6785C47.7844%2024.7145%2047.7705%2024.7501%2047.7561%2024.7853C47.7417%2024.8204%2047.7267%2024.8549%2047.7111%2024.8889C47.6954%2024.923%2047.6793%2024.9564%2047.6626%2024.9892C47.6459%2025.0221%2047.6286%2025.0543%2047.6109%2025.0859C47.5931%2025.1176%2047.5747%2025.1486%2047.5559%2025.1789C47.537%2025.2092%2047.5177%2025.2388%2047.4978%2025.2677C47.478%2025.2967%2047.4577%2025.3249%2047.4369%2025.3523C47.4161%2025.3799%2047.3949%2025.4066%2047.3732%2025.4326C47.3515%2025.4585%2047.3294%2025.4837%2047.3068%2025.5081C47.2843%2025.5324%2047.2614%2025.5559%2047.2381%2025.5786C47.2148%2025.6014%2047.191%2025.6233%2047.167%2025.6443C47.1429%2025.6654%2047.1185%2025.6855%2047.0938%2025.7048C47.0691%2025.7241%2047.044%2025.7425%2047.0186%2025.76C46.9933%2025.7775%2046.9676%2025.794%2046.9416%2025.8096C46.9158%2025.8254%2046.8896%2025.8401%2046.8632%2025.8539C46.8367%2025.8676%2046.8101%2025.8804%2046.7832%2025.8923C46.7564%2025.9042%2046.7294%2025.9152%2046.7022%2025.9251C46.6749%2025.935%2046.6476%2025.944%2046.6201%2025.952C46.5925%2025.9599%2046.5649%2025.9669%2046.5372%2025.9729C46.5094%2025.9789%2046.4816%2025.9839%2046.4537%2025.988C46.4257%2025.992%2046.3978%2025.995%2046.3697%2025.997C46.3417%2025.999%2046.3137%2026%2046.2856%2026L1.71205%2026C1.68401%2025.9999%201.656%2025.9989%201.62803%2025.9969C1.59999%2025.9948%201.57204%2025.9917%201.54418%2025.9876C1.51626%2025.9836%201.48844%2025.9785%201.4607%2025.9725C1.43302%2025.9664%201.40543%2025.9594%201.37792%2025.9513C1.35042%2025.9433%201.3231%2025.9343%201.29596%2025.9243C1.26875%2025.9144%201.24173%2025.9034%201.21488%2025.8915C1.18809%2025.8796%201.16151%2025.8668%201.13514%2025.853C1.10871%2025.8391%201.08258%2025.8243%201.05675%2025.8087C1.03085%2025.793%201.00523%2025.7764%200.979869%2025.7589C0.954573%2025.7414%200.929572%2025.723%200.904865%2025.7036C0.880102%2025.6844%200.855725%2025.6642%200.831737%2025.6431C0.807688%2025.6221%200.784026%2025.6002%200.760751%2025.5775C0.737417%2025.5547%200.714499%2025.5312%200.691998%2025.5068C0.669497%2025.4824%200.647443%2025.4572%200.625834%2025.4312C0.604167%2025.4053%200.582945%2025.3786%200.562171%2025.3512C0.541396%2025.3237%200.521126%2025.2954%200.501364%2025.2665C0.481542%2025.2376%200.462225%2025.208%200.443414%2025.1777C0.424604%2025.1474%200.4063%2025.1164%200.388501%2025.0848C0.370762%2025.0532%200.35353%2025.021%200.336802%2024.9882C0.320135%2024.9552%200.304033%2024.9218%200.288496%2024.8879C0.272901%2024.8539%200.2579%2024.8193%200.243495%2024.7842C0.229089%2024.7492%200.215308%2024.7136%200.202154%2024.6776C0.188938%2024.6415%200.176349%2024.6049%200.164383%2024.568C0.152358%2024.5311%200.140988%2024.4937%200.130274%2024.4559C0.119559%2024.4181%200.109499%2024.38%200.100094%2024.3415C0.0906294%2024.303%200.0818497%2024.2642%200.0737539%2024.2251C0.0655983%2024.186%200.0581279%2024.1466%200.0513415%2024.1069C0.0444965%2024.0672%200.0383654%2024.0274%200.0329483%2023.9874C0.0274712%2023.9473%200.0226795%2023.907%200.018573%2023.8665C0.0144653%2023.8261%200.0110427%2023.7855%200.00830418%2023.7448C0.00556564%2023.7042%200.00351242%2023.6634%200.00214315%2023.6225C0.000713928%2023.5817%200%2023.5409%200%2023.5C0%2023.4591%200.000713928%2023.4183%200.00214315%2023.3775C0.00351242%2023.3366%200.00556564%2023.2958%200.00830418%2023.2552C0.0110427%2023.2145%200.0144653%2023.1739%200.018573%2023.1335C0.0226795%2023.093%200.0274712%2023.0528%200.0329483%2023.0128C0.038424%2022.9727%200.0445564%2022.9328%200.0513415%2022.8931C0.0581279%2022.8534%200.0655983%2022.814%200.0737539%2022.7749C0.0818497%2022.7358%200.0906294%2022.697%200.100094%2022.6585C0.109499%2022.62%200.119559%2022.5819%200.130274%2022.5441C0.140988%2022.5063%200.152358%2022.4689%200.164383%2022.432C0.176349%2022.3951%200.188938%2022.3585%200.202154%2022.3224C0.215308%2022.2864%200.229089%2022.2508%200.243495%2022.2158C0.2579%2022.1807%200.272901%2022.1461%200.288496%2022.1121C0.304033%2022.0782%200.320135%2022.0448%200.336802%2022.0119C0.35353%2021.979%200.370762%2021.9468%200.388501%2021.9152C0.4063%2021.8836%200.424604%2021.8526%200.443414%2021.8223C0.462225%2021.792%200.481542%2021.7624%200.501364%2021.7335C0.521126%2021.7046%200.541396%2021.6763%200.562171%2021.6488C0.582945%2021.6214%200.604167%2021.5947%200.625834%2021.5688C0.647443%2021.5428%200.669497%2021.5176%200.691998%2021.4932C0.714499%2021.4688%200.737417%2021.4453%200.760751%2021.4225C0.784026%2021.3998%200.807688%2021.3779%200.831737%2021.3569C0.855725%2021.3358%200.880102%2021.3156%200.904865%2021.2964C0.929572%2021.277%200.954573%2021.2586%200.979869%2021.2411C1.00523%2021.2236%201.03085%2021.207%201.05675%2021.1913C1.08258%2021.1756%201.10871%2021.1608%201.13514%2021.147C1.16151%2021.1332%201.18809%2021.1204%201.21488%2021.1085C1.24173%2021.0966%201.26875%2021.0856%201.29596%2021.0757C1.3231%2021.0657%201.35042%2021.0566%201.37792%2021.0486C1.40543%2021.0406%201.43302%2021.0336%201.4607%2021.0275C1.48844%2021.0215%201.51626%2021.0165%201.54418%2021.0124C1.57204%2021.0083%201.59999%2021.0052%201.62803%2021.0031C1.656%2021.0011%201.68401%2021.0001%201.71205%2021L46.2856%2021C46.3137%2021%2046.3417%2021.001%2046.3697%2021.003C46.3978%2021.005%2046.4257%2021.008%2046.4537%2021.0121C46.4816%2021.0161%2046.5094%2021.0211%2046.5372%2021.0271C46.5649%2021.0331%2046.5925%2021.0401%2046.6201%2021.048C46.6476%2021.056%2046.6749%2021.065%2046.7022%2021.0749C46.7294%2021.0849%2046.7564%2021.0958%2046.7832%2021.1077C46.8101%2021.1196%2046.8368%2021.1324%2046.8632%2021.1461C46.8896%2021.1599%2046.9158%2021.1747%2046.9417%2021.1904C46.9676%2021.206%2046.9933%2021.2226%2047.0186%2021.2401C47.044%2021.2576%2047.0691%2021.2759%2047.0938%2021.2952C47.1185%2021.3145%2047.143%2021.3346%2047.167%2021.3557C47.191%2021.3767%2047.2148%2021.3986%2047.2381%2021.4214C47.2614%2021.4441%2047.2843%2021.4676%2047.3068%2021.4919C47.3294%2021.5163%2047.3515%2021.5415%2047.3732%2021.5674C47.3949%2021.5934%2047.4161%2021.6201%2047.4369%2021.6477C47.4577%2021.6751%2047.478%2021.7033%2047.4978%2021.7323C47.5177%2021.7612%2047.537%2021.7908%2047.5559%2021.8211C47.5747%2021.8514%2047.5931%2021.8824%2047.6109%2021.9141C47.6286%2021.9457%2047.646%2021.9779%2047.6627%2022.0108C47.6794%2022.0436%2047.6954%2022.077%2047.7111%2022.1111C47.7267%2022.1451%2047.7417%2022.1796%2047.7561%2022.2147C47.7705%2022.2499%2047.7844%2022.2855%2047.7976%2022.3215C47.8108%2022.3576%2047.8234%2022.3941%2047.8354%2022.4311C47.8474%2022.4681%2047.8587%2022.5055%2047.8695%2022.5434C47.8803%2022.5811%2047.8904%2022.6193%2047.8998%2022.6578C47.9092%2022.6964%2047.918%2022.7352%2047.9262%2022.7743C47.9343%2022.8135%2047.9418%2022.8529%2047.9487%2022.8926C47.9554%2022.9323%2047.9616%2022.9721%2047.9671%2023.0122C47.9725%2023.0524%2047.9773%2023.0928%2047.9814%2023.1332C47.9855%2023.1737%2047.989%2023.2142%2047.9918%2023.2549C47.9946%2023.2957%2047.9966%2023.3365%2047.9979%2023.3773C47.9993%2023.4182%2048%2023.4591%2048%2023.5Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M2.77325%2047L32.7244%2018.0388L29.9511%2015.3572L0%2044.3184L2.77325%2047Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3cpath%20d='M41.3441%2025.7529L47.9999%200.999853L22.1448%207.18811L41.3441%2025.7529Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M46%2048L2%2048C1.96725%2048%201.93454%2047.9992%201.90188%2047.9976C1.86917%2047.996%201.83652%2047.9936%201.80394%2047.9904C1.77139%2047.9872%201.73894%2047.9832%201.70656%2047.9784C1.67419%2047.9736%201.64194%2047.9679%201.60981%2047.9616C1.57773%2047.9552%201.54581%2047.948%201.51406%2047.9401C1.48231%2047.9321%201.45077%2047.9234%201.41944%2047.9139C1.38811%2047.9044%201.35704%2047.8941%201.32625%2047.8831C1.29542%2047.8721%201.26488%2047.8603%201.23462%2047.8478C1.20438%2047.8352%201.17446%2047.8219%201.14488%2047.8079C1.11529%2047.794%201.08606%2047.7793%201.05719%2047.7638C1.02836%2047.7484%200.999894%2047.7323%200.971812%2047.7154C0.943731%2047.6986%200.916081%2047.6811%200.888875%2047.6629C0.861669%2047.6447%200.834919%2047.6259%200.808625%2047.6064C0.782331%2047.5869%200.756519%2047.5668%200.731188%2047.546C0.705894%2047.5252%200.681125%2047.5039%200.656875%2047.4819C0.632625%2047.4599%200.608938%2047.4374%200.585813%2047.4142C0.562646%2047.3911%200.540083%2047.3674%200.518124%2047.3431C0.496125%2047.3189%200.474749%2047.2941%200.454001%2047.2688C0.433209%2047.2435%200.413062%2047.2177%200.393562%2047.1914C0.374063%2047.1651%200.355229%2047.1383%200.337063%2047.1111C0.318896%2047.0839%200.301396%2047.0563%200.284562%2047.0282C0.267729%2047.0001%200.251604%2046.9716%200.236188%2046.9428C0.220729%2046.9139%200.206001%2046.8847%200.192001%2046.8551C0.178001%2046.8255%200.16475%2046.7956%200.15225%2046.7654C0.139709%2046.7351%200.127937%2046.7046%200.116938%2046.6738C0.105896%2046.6429%200.095625%2046.6119%200.0861256%2046.5806C0.076625%2046.5493%200.0678956%2046.5177%200.0599375%2046.4859C0.0519791%2046.4542%200.0448122%2046.4222%200.0384378%2046.3902C0.0320625%2046.3581%200.0264587%2046.3258%200.0216246%2046.2934C0.0168333%2046.2611%200.0128336%2046.2286%200.00962544%2046.1961C0.00641631%2046.1635%200.00402069%2046.1308%200.00243759%2046.0981C0.000812531%2046.0654%200%2046.0327%200%2046L0%202C0%201.96725%200.000812531%201.93454%200.00243759%201.90188C0.00402069%201.86917%200.00641631%201.83652%200.00962544%201.80394C0.0128336%201.77139%200.0168333%201.73894%200.0216246%201.70656C0.0264587%201.67419%200.0320625%201.64194%200.0384378%201.60981C0.0448122%201.57773%200.0519791%201.54581%200.0599375%201.51406C0.0678956%201.48231%200.076625%201.45077%200.0861256%201.41944C0.095625%201.38811%200.105896%201.35704%200.116938%201.32625C0.127937%201.29542%200.139709%201.26488%200.15225%201.23462C0.16475%201.20438%200.178001%201.17446%200.192001%201.14488C0.206001%201.11529%200.220729%201.08606%200.236188%201.05719C0.251604%201.02836%200.267729%200.999894%200.284562%200.971812C0.301396%200.943731%200.318896%200.916081%200.337063%200.888875C0.355229%200.861669%200.374063%200.834919%200.393562%200.808625C0.413062%200.782331%200.433209%200.756519%200.454001%200.731188C0.474749%200.705894%200.496125%200.681125%200.518124%200.656875C0.540083%200.632625%200.562646%200.608938%200.585813%200.585813C0.608938%200.562646%200.632625%200.540083%200.656875%200.518124C0.681125%200.496125%200.705894%200.474749%200.731188%200.454001C0.756519%200.433209%200.782331%200.413062%200.808625%200.393562C0.834919%200.374063%200.861669%200.355229%200.888875%200.337063C0.916081%200.318896%200.943731%200.301396%200.971812%200.284562C0.999894%200.267729%201.02836%200.251604%201.05719%200.236188C1.08606%200.220729%201.11529%200.206001%201.14488%200.192001C1.17446%200.178001%201.20438%200.16475%201.23462%200.15225C1.26488%200.139709%201.29542%200.127937%201.32625%200.116938C1.35704%200.105896%201.38811%200.095625%201.41944%200.0861256C1.45077%200.076625%201.48231%200.0678956%201.51406%200.0599375C1.54581%200.0519791%201.57773%200.0448122%201.60981%200.0384378C1.64194%200.0320625%201.67419%200.0264587%201.70656%200.0216246C1.73894%200.0168333%201.77139%200.0128336%201.80394%200.00962544C1.83652%200.00641631%201.86917%200.00402069%201.90188%200.00243759C1.93454%200.000812531%201.96725%200%202%200L46%200C46.0327%200%2046.0654%200.000812531%2046.0981%200.00243759C46.1308%200.00402069%2046.1635%200.00641631%2046.1961%200.00962544C46.2286%200.0128336%2046.2611%200.0168333%2046.2934%200.0216246C46.3258%200.0264587%2046.3581%200.0320625%2046.3902%200.0384378C46.4222%200.0448122%2046.4542%200.0519791%2046.4859%200.0599375C46.5177%200.0678956%2046.5493%200.076625%2046.5806%200.0861256C46.6119%200.095625%2046.6429%200.105896%2046.6738%200.116938C46.7046%200.127937%2046.7351%200.139709%2046.7654%200.15225C46.7956%200.16475%2046.8256%200.178001%2046.8551%200.192001C46.8847%200.206001%2046.9139%200.220729%2046.9428%200.236188C46.9716%200.251604%2047.0001%200.267729%2047.0282%200.284562C47.0563%200.301396%2047.0839%200.318896%2047.1111%200.337063C47.1383%200.355229%2047.1651%200.374063%2047.1914%200.393562C47.2177%200.413062%2047.2435%200.433209%2047.2688%200.454001C47.2941%200.474749%2047.3189%200.496125%2047.3431%200.518124C47.3674%200.540083%2047.3911%200.562646%2047.4142%200.585813C47.4374%200.608938%2047.4599%200.632625%2047.4819%200.656875C47.5039%200.681125%2047.5252%200.705894%2047.546%200.731188C47.5668%200.756519%2047.5869%200.782331%2047.6064%200.808625C47.6259%200.834919%2047.6447%200.861669%2047.6629%200.888875C47.6811%200.916081%2047.6986%200.943731%2047.7154%200.971812C47.7323%200.999894%2047.7484%201.02836%2047.7638%201.05719C47.7793%201.08606%2047.794%201.11529%2047.808%201.14488C47.8219%201.17446%2047.8352%201.20438%2047.8478%201.23462C47.8603%201.26488%2047.8721%201.29542%2047.8831%201.32625C47.8941%201.35704%2047.9044%201.38811%2047.9139%201.41944C47.9234%201.45077%2047.9321%201.48231%2047.9401%201.51406C47.948%201.54581%2047.9552%201.57773%2047.9616%201.60981C47.9679%201.64194%2047.9736%201.67419%2047.9784%201.70656C47.9832%201.73894%2047.9872%201.77139%2047.9904%201.80394C47.9936%201.83652%2047.996%201.86917%2047.9976%201.90188C47.9992%201.93454%2048%201.96725%2048%202L48%2046C48%2046.0327%2047.9992%2046.0654%2047.9976%2046.0981C47.996%2046.1308%2047.9936%2046.1635%2047.9904%2046.1961C47.9872%2046.2286%2047.9832%2046.2611%2047.9784%2046.2934C47.9736%2046.3258%2047.9679%2046.3581%2047.9616%2046.3902C47.9552%2046.4222%2047.948%2046.4542%2047.9401%2046.4859C47.9321%2046.5177%2047.9234%2046.5493%2047.9139%2046.5806C47.9044%2046.6119%2047.8941%2046.6429%2047.8831%2046.6738C47.8721%2046.7046%2047.8603%2046.7351%2047.8478%2046.7654C47.8352%2046.7956%2047.8219%2046.8256%2047.8079%2046.8551C47.794%2046.8847%2047.7793%2046.9139%2047.7638%2046.9428C47.7484%2046.9716%2047.7323%2047.0001%2047.7154%2047.0282C47.6986%2047.0563%2047.6811%2047.0839%2047.6629%2047.1111C47.6447%2047.1383%2047.6259%2047.1651%2047.6064%2047.1914C47.5869%2047.2177%2047.5668%2047.2435%2047.546%2047.2688C47.5252%2047.2941%2047.5039%2047.3189%2047.4819%2047.3431C47.4599%2047.3674%2047.4374%2047.3911%2047.4142%2047.4142C47.3911%2047.4374%2047.3674%2047.4599%2047.3431%2047.4819C47.3189%2047.5039%2047.2941%2047.5252%2047.2688%2047.546C47.2435%2047.5668%2047.2177%2047.5869%2047.1914%2047.6064C47.1651%2047.6259%2047.1383%2047.6447%2047.1111%2047.6629C47.0839%2047.6811%2047.0563%2047.6986%2047.0282%2047.7154C47.0001%2047.7323%2046.9716%2047.7484%2046.9428%2047.7638C46.9139%2047.7793%2046.8847%2047.794%2046.8551%2047.808C46.8255%2047.8219%2046.7956%2047.8352%2046.7654%2047.8478C46.7351%2047.8603%2046.7046%2047.8721%2046.6738%2047.8831C46.6429%2047.8941%2046.6119%2047.9044%2046.5806%2047.9139C46.5493%2047.9234%2046.5177%2047.9321%2046.4859%2047.9401C46.4542%2047.948%2046.4222%2047.9552%2046.3902%2047.9616C46.3581%2047.9679%2046.3258%2047.9736%2046.2934%2047.9784C46.2611%2047.9832%2046.2286%2047.9872%2046.1961%2047.9904C46.1635%2047.9936%2046.1308%2047.996%2046.0981%2047.9976C46.0654%2047.9992%2046.0327%2048%2046%2048ZM4%2044L44%2044L44%204L4%204L4%2044Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M24%2048C10.7668%2048%200%2037.2332%200%2024C0%2010.7668%2010.7668%200%2024%200C37.2332%200%2048%2010.7668%2048%2024C48%2037.2332%2037.2332%2048%2024%2048ZM24%203.69231C12.8031%203.69231%203.69231%2012.8031%203.69231%2024C3.69231%2035.1969%2012.8031%2044.3077%2024%2044.3077C35.1969%2044.3077%2044.3077%2035.1969%2044.3077%2024C44.3077%2012.8031%2035.1969%203.69231%2024%203.69231Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M24.0001%2048C22.6801%2048%2021.6001%2046.9425%2021.6001%2045.65L21.6001%203.35C21.6001%202.0575%2022.6801%201%2024.0001%201C25.3201%201%2026.4001%202.0575%2026.4001%203.35L26.4001%2045.65C26.4001%2046.9425%2025.3201%2048%2024.0001%2048Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3cpath%20d='M0%203.35C0%202.0575%201.08%201%202.4%201L45.6%201C46.92%201%2048%202.0575%2048%203.35C48%204.6425%2046.92%205.7%2045.6%205.7L2.4%205.7C1.08%205.7%200%204.6425%200%203.35Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M31.6062%205.51994L31.6062%205.56835L31.6062%205.39893C31.6062%205.44249%2031.6062%205.48122%2031.6062%205.52478C31.6062%205.51994%2031.6062%205.5151%2031.6062%205.51026C31.6062%205.51026%2031.6062%205.5151%2031.6062%205.51994Z'%20fill='%23FFFFFF'%20%3e%3c/path%3e%3cpath%20d='M47%2024C47%2021.2305%2045.7237%2018.6513%2043.5889%2016.9719C45.7237%2015.2926%2047%2012.7134%2047%209.94392C47%205.0127%2042.9856%201%2038.0524%201C35.2865%201%2032.7108%202.27108%2031.0308%204.40036C29.3462%202.27108%2026.7752%201%2024.0046%201C21.234%201%2018.6537%202.27571%2016.9738%204.40964C15.2938%202.27571%2012.7135%201%209.94289%201C5.01432%201%201%205.0127%201%209.94392C1%2012.7134%202.27623%2015.2926%204.41101%2016.9719C2.27623%2018.6513%201%2021.2305%201%2024C1%2026.7694%202.27623%2029.3487%204.41101%2031.028C2.27623%2032.7073%201%2035.2866%201%2038.056C1%2042.9872%205.01432%2047%209.94753%2047C12.7181%2047%2015.2984%2045.7242%2016.9784%2043.5903C18.6584%2045.7242%2021.2387%2047%2024.0093%2047C26.7752%2047%2029.3509%2045.7289%2031.0308%2043.5996C32.7108%2045.7242%2035.2865%2047%2038.0524%2047C42.9856%2047%2047%2042.9872%2047%2038.056C47%2035.2866%2045.7237%2032.7073%2043.5889%2031.028C45.7237%2029.3487%2047%2026.7694%2047%2024ZM41.4124%2031.863C43.6864%2033.097%2045.0972%2035.4721%2045.0972%2038.056C45.0972%2041.9388%2041.9368%2045.098%2038.0524%2045.098C35.4675%2045.098%2033.096%2043.6877%2031.8615%2041.4146L31.0401%2039.907L31.0262%2039.8791L30.9612%2040.0044L30.1908%2041.4193C30.1816%2041.4378%2030.1676%2041.461%2030.1537%2041.4796L30.1305%2041.5213L30.1444%2041.5306C28.8914%2043.7388%2026.5524%2045.1026%2024.0139%2045.1026C21.429%2045.1026%2019.0575%2043.6924%2017.8184%2041.4193L16.983%2039.8791L16.1477%2041.4193C14.9132%2043.6924%2012.5371%2045.1026%209.95217%2045.1026C6.06779%2045.1026%202.90739%2041.9435%202.90739%2038.0607C2.90739%2035.4768%204.3182%2033.1063%206.59221%2031.8677L8.13296%2031.0326L6.59221%2030.1976C4.3182%2028.9637%202.90739%2026.5885%202.90739%2024.0046C2.90739%2021.4207%204.3182%2019.0502%206.59221%2017.8116L8.13296%2016.9766L6.59221%2016.1416C4.3182%2014.9076%202.90739%2012.5325%202.90739%209.94856C2.90739%206.06575%206.06779%202.90661%209.95217%202.90661C12.5371%202.90661%2014.9086%204.31686%2016.1477%206.58995L16.983%208.13008L17.8184%206.58995C19.0528%204.31686%2021.429%202.90661%2024.0139%202.90661C26.5571%202.90661%2028.8914%204.27047%2030.1444%206.47861L30.1305%206.48789L30.1584%206.53428C30.1676%206.55284%2030.1816%206.57603%2030.1908%206.59459L30.9612%208.00947L31.0262%208.13472L31.0401%208.10689L31.8615%206.59923C33.096%204.32614%2035.4721%202.91589%2038.0571%202.91589C41.9414%202.91589%2045.1019%206.07503%2045.1019%209.95784C45.1019%2012.5417%2043.691%2014.9122%2041.417%2016.1509L39.8763%2016.9859L41.417%2017.8209C43.691%2019.0548%2045.1019%2021.43%2045.1019%2024.0139C45.1019%2026.5978%2043.691%2028.9683%2041.417%2030.2069L39.8763%2031.0419L41.4124%2031.863Z'%20stroke='rgba(44,%2044,%2044,%201)'%20stroke-width='1'%20fill='%232C2C2C'%20%3e%3c/path%3e%3cpath%20d='M31.6062%205.51994L31.6062%205.56835L31.6062%205.39893C31.6062%205.44249%2031.6062%205.48122%2031.6062%205.52478C31.6062%205.51994%2031.6062%205.5151%2031.6062%205.51026C31.6062%205.51026%2031.6062%205.5151%2031.6062%205.51994Z'%20fill='%23000000'%20%3e%3c/path%3e%3c/svg%3e",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},TB=new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M31.6062%205.51994L31.6062%205.56835L31.6062%205.39893C31.6062%205.44249%2031.6062%205.48122%2031.6062%205.52478C31.6062%205.51994%2031.6062%205.5151%2031.6062%205.51026C31.6062%205.51026%2031.6062%205.5151%2031.6062%205.51994Z'%20fill='%23FFFFFF'%20%3e%3c/path%3e%3cpath%20d='M31.6062%205.51994L31.6062%205.56835L31.6062%205.39893C31.6062%205.44249%2031.6062%205.48122%2031.6062%205.52478C31.6062%205.51994%2031.6062%205.5151%2031.6062%205.51026C31.6062%205.51026%2031.6062%205.5151%2031.6062%205.51994Z'%20fill='%23000000'%20%3e%3c/path%3e%3cpath%20d='M47.4452%2011.6515L36.3485%200.55483C35.6088%20-0.184944%2034.4422%20-0.184944%2033.7024%200.55483L0.55483%2033.7024C-0.184944%2034.4422%20-0.184944%2035.6088%200.55483%2036.3485L11.6515%2047.4452C12.3912%2048.1849%2013.5578%2048.1849%2014.2976%2047.4452L47.4452%2014.2976C48.1849%2013.5862%2048.1849%2012.3912%2047.4452%2011.6515ZM12.9887%2043.4618L4.53823%2035.0113L6.6722%2032.8773L8.1233%2034.3284C8.86307%2035.0682%2010.0296%2035.0682%2010.7694%2034.3284C11.5092%2033.5886%2011.5092%2032.4221%2010.7694%2031.6823L9.31832%2030.2312L11.4523%2028.0972L12.9034%2029.5483C13.6432%2030.2881%2014.8097%2030.2881%2015.5495%2029.5483C16.2893%2028.8085%2016.2893%2027.642%2015.5495%2026.9022L14.0984%2025.4511L16.2324%2023.3171L17.6835%2024.7682C18.4232%2025.508%2019.5898%2025.508%2020.3296%2024.7682C21.0694%2024.0285%2021.0694%2022.8619%2020.3296%2022.1221L18.8785%2020.671L21.0124%2018.537L22.4635%2019.9881C23.2033%2020.7279%2024.3699%2020.7279%2025.1097%2019.9881C25.8494%2019.2484%2025.8494%2018.0818%2025.1097%2017.342L23.6586%2015.8909L25.7925%2013.757L27.2436%2015.2081C27.9834%2015.9478%2029.15%2015.9478%2029.8897%2015.2081C30.6295%2014.4683%2030.6295%2013.3017%2029.8897%2012.5619L28.4386%2011.1108L30.5726%208.97688L32.0237%2010.428C32.7635%2011.1678%2033.9301%2011.1678%2034.6698%2010.428C35.4096%209.6882%2035.4096%208.52164%2034.6698%207.78186L33.2187%206.33076L35.0682%204.48133L43.5187%2012.9318L12.9887%2043.4618Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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,DB=new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M1%201L6.11109%201L6.11109%205.88887L1%205.88887L1%201ZM11.2222%201L16.3333%201L16.3333%205.88887L11.2222%205.88887L11.2222%201ZM21.4444%201L26.5556%201L26.5556%205.88887L21.4444%205.88887L21.4444%201ZM31.6667%201L36.7778%201L36.7778%205.88887L31.6667%205.88887L31.6667%201ZM41.8889%201L47%201L47%205.88887L41.8889%205.88887L41.8889%201ZM41.8889%2010.7778L47%2010.7778L47%2015.6667L41.8889%2015.6667L41.8889%2010.7778ZM1%2040.1111L6.11109%2040.1111L6.11109%2045L1%2045L1%2040.1111ZM1%2030.3333L6.11109%2030.3333L6.11109%2035.2222L1%2035.2222L1%2030.3333ZM1%2020.5555L6.11109%2020.5555L6.11109%2025.4445L1%2025.4445L1%2020.5555ZM1%2010.7778L6.11109%2010.7778L6.11109%2015.6667L1%2015.6667L1%2010.7778ZM20.5934%2020.5555L23.241%2016.7545C23.2556%2016.7337%2023.2704%2016.713%2023.2856%2016.6926C23.3007%2016.6723%2023.3162%2016.6521%2023.332%2016.6322C23.3479%2016.6123%2023.364%2016.5926%2023.3805%2016.5731C23.397%2016.5537%2023.4137%2016.5345%2023.4307%2016.5156C23.4478%2016.4966%2023.4653%2016.4779%2023.4829%2016.4594C23.5006%2016.441%2023.5186%2016.4228%2023.5368%2016.4049C23.5551%2016.3869%2023.5736%2016.3693%2023.5924%2016.3519C23.6113%2016.3346%2023.6304%2016.3175%2023.6497%2016.3007C23.6691%2016.2839%2023.6887%2016.2673%2023.7087%2016.2511C23.7286%2016.2349%2023.7487%2016.219%2023.7691%2016.2033C23.7895%2016.1877%2023.8102%2016.1723%2023.8311%2016.1573C23.852%2016.1422%2023.8731%2016.1275%2023.8945%2016.1131C23.9159%2016.0987%2023.9375%2016.0846%2023.9594%2016.0708C23.9812%2016.057%2024.0032%2016.0435%2024.0255%2016.0304C24.0478%2016.0173%2024.0703%2016.0045%2024.093%2015.992C24.1157%2015.9795%2024.1385%2015.9674%2024.1615%2015.9556C24.1846%2015.9438%2024.2079%2015.9323%2024.2313%2015.9212C24.2547%2015.9101%2024.2783%2015.8993%2024.3021%2015.8889C24.3259%2015.8785%2024.3499%2015.8684%2024.3739%2015.8587C24.3981%2015.849%2024.4223%2015.8396%2024.4467%2015.8306C24.4711%2015.8216%2024.4956%2015.813%2024.5204%2015.8047C24.5451%2015.7964%2024.5698%2015.7885%2024.5948%2015.7809C24.6197%2015.7733%2024.6448%2015.7661%2024.6699%2015.7593C24.6951%2015.7525%2024.7204%2015.746%2024.7458%2015.7399C24.7711%2015.7339%2024.7966%2015.7281%2024.8221%2015.7228C24.8477%2015.7175%2024.8733%2015.7126%2024.899%2015.708C24.9247%2015.7034%2024.9505%2015.6992%2024.9764%2015.6954C25.0022%2015.6915%2025.0282%2015.6881%2025.0541%2015.6851C25.0801%2015.682%2025.1061%2015.6793%2025.1322%2015.677C25.1582%2015.6747%2025.1843%2015.6728%2025.2104%2015.6713C25.2365%2015.6697%2025.2626%2015.6686%2025.2888%2015.6678C25.315%2015.6671%2025.3411%2015.6667%2025.3672%2015.6667L32.855%2015.6667C32.8812%2015.6667%2032.9073%2015.6671%2032.9335%2015.6678C32.9596%2015.6686%2032.9858%2015.6697%2033.0119%2015.6713C33.0379%2015.6728%2033.064%2015.6747%2033.0901%2015.677C33.1161%2015.6793%2033.1421%2015.682%2033.1681%2015.6851C33.194%2015.6881%2033.2199%2015.6915%2033.2458%2015.6954C33.2716%2015.6992%2033.2975%2015.7034%2033.3231%2015.708C33.3488%2015.7126%2033.3745%2015.7175%2033.4001%2015.7228C33.4256%2015.7281%2033.4511%2015.7339%2033.4765%2015.7399C33.5018%2015.7461%2033.5271%2015.7525%2033.5523%2015.7593C33.5775%2015.7661%2033.6025%2015.7733%2033.6275%2015.7809C33.6524%2015.7885%2033.6772%2015.7964%2033.7019%2015.8047C33.7265%2015.813%2033.7511%2015.8216%2033.7755%2015.8306C33.7999%2015.8396%2033.8242%2015.849%2033.8483%2015.8587C33.8724%2015.8684%2033.8963%2015.8785%2033.9201%2015.8889C33.9438%2015.8993%2033.9675%2015.9101%2033.9909%2015.9212C34.0143%2015.9323%2034.0376%2015.9438%2034.0606%2015.9556C34.0837%2015.9674%2034.1066%2015.9795%2034.1293%2015.992C34.152%2016.0045%2034.1744%2016.0173%2034.1967%2016.0304C34.2189%2016.0435%2034.241%2016.057%2034.2629%2016.0708C34.2847%2016.0846%2034.3063%2016.0987%2034.3277%2016.1131C34.349%2016.1275%2034.3702%2016.1422%2034.3911%2016.1573C34.412%2016.1723%2034.4327%2016.1877%2034.4531%2016.2033C34.4735%2016.219%2034.4936%2016.2349%2034.5136%2016.2511C34.5335%2016.2673%2034.5531%2016.2839%2034.5725%2016.3007C34.5919%2016.3175%2034.611%2016.3346%2034.6298%2016.3519C34.6486%2016.3693%2034.6671%2016.3869%2034.6854%2016.4049C34.7037%2016.4228%2034.7217%2016.441%2034.7393%2016.4594C34.757%2016.4779%2034.7744%2016.4966%2034.7914%2016.5156C34.8085%2016.5345%2034.8253%2016.5537%2034.8417%2016.5731C34.8582%2016.5926%2034.8743%2016.6123%2034.8901%2016.6322C34.906%2016.6521%2034.9215%2016.6723%2034.9367%2016.6926C34.9518%2016.713%2034.9667%2016.7337%2034.9812%2016.7545L37.6288%2020.5555L44.4444%2020.5555C44.4863%2020.5555%2044.5281%2020.5565%2044.5698%2020.5585C44.6116%2020.5605%2044.6533%2020.5634%2044.6949%2020.5673C44.7365%2020.5712%2044.778%2020.5761%2044.8194%2020.582C44.8608%2020.5879%2044.902%2020.5947%2044.943%2020.6025C44.984%2020.6104%2045.0248%2020.6191%2045.0654%2020.6288C45.1059%2020.6386%2045.1462%2020.6492%2045.1863%2020.6608C45.2263%2020.6725%2045.266%2020.685%2045.3054%2020.6984C45.3447%2020.7119%2045.3838%2020.7263%2045.4224%2020.7416C45.461%2020.7569%2045.4993%2020.7731%2045.5371%2020.7903C45.5749%2020.8074%2045.6122%2020.8253%2045.6491%2020.8442C45.686%2020.863%2045.7224%2020.8828%2045.7582%2020.9034C45.7941%2020.9239%2045.8295%2020.9453%2045.8643%2020.9675C45.899%2020.9897%2045.9332%2021.0128%2045.9668%2021.0366C46.0004%2021.0604%2046.0333%2021.085%2046.0657%2021.1104C46.098%2021.1358%2046.1297%2021.1619%2046.1606%2021.1888C46.1916%2021.2157%2046.222%2021.2432%2046.2515%2021.2715C46.2811%2021.2998%2046.3099%2021.3288%2046.338%2021.3584C46.3661%2021.388%2046.3934%2021.4183%2046.4199%2021.4493C46.4464%2021.4802%2046.4721%2021.5117%2046.4971%2021.5438C46.522%2021.576%2046.5461%2021.6087%2046.5693%2021.642C46.5925%2021.6752%2046.6149%2021.709%2046.6364%2021.7433C46.6579%2021.7776%2046.6785%2021.8124%2046.6982%2021.8477C46.7179%2021.883%2046.7368%2021.9187%2046.7546%2021.9549C46.7725%2021.991%2046.7895%2022.0276%2046.8055%2022.0645C46.8214%2022.1015%2046.8365%2022.1388%2046.8506%2022.1765C46.8647%2022.2141%2046.8778%2022.2521%2046.89%2022.2904C46.9021%2022.3287%2046.9133%2022.3673%2046.9234%2022.4061C46.9336%2022.4448%2046.9427%2022.4839%2046.9509%2022.5231C46.959%2022.5623%2046.9662%2022.6017%2046.9723%2022.6413C46.9785%2022.6809%2046.9836%2022.7206%2046.9877%2022.7604C46.9918%2022.8002%2046.9949%2022.8401%2046.9969%2022.88C46.999%2022.92%2047%2022.96%2047%2023L47%2042.5555C47%2042.5956%2046.999%2042.6356%2046.9969%2042.6755C46.9949%2042.7154%2046.9918%2042.7553%2046.9877%2042.7951C46.9836%2042.8349%2046.9785%2042.8747%2046.9723%2042.9142C46.9662%2042.9538%2046.959%2042.9932%2046.9509%2043.0324C46.9427%2043.0717%2046.9336%2043.1107%2046.9234%2043.1495C46.9133%2043.1883%2046.9021%2043.2268%2046.89%2043.2652C46.8778%2043.3034%2046.8647%2043.3414%2046.8506%2043.379C46.8365%2043.4167%2046.8214%2043.454%2046.8055%2043.491C46.7895%2043.5279%2046.7725%2043.5646%2046.7546%2043.6007C46.7368%2043.6369%2046.7179%2043.6726%2046.6982%2043.7078C46.6785%2043.7431%2046.6579%2043.7779%2046.6364%2043.8122C46.6149%2043.8465%2046.5925%2043.8803%2046.5693%2043.9136C46.5461%2043.9469%2046.522%2043.9796%2046.4971%2044.0117C46.4722%2044.0439%2046.4464%2044.0754%2046.4199%2044.1063C46.3934%2044.1372%2046.3661%2044.1675%2046.338%2044.1971C46.3099%2044.2268%2046.2811%2044.2558%2046.2515%2044.284C46.222%2044.3123%2046.1916%2044.3399%2046.1606%2044.3668C46.1297%2044.3936%2046.098%2044.4198%2046.0657%2044.4451C46.0333%2044.4705%2046.0004%2044.4951%2045.9668%2044.5189C45.9332%2044.5428%2045.899%2044.5658%2045.8643%2044.588C45.8295%2044.6102%2045.7941%2044.6317%2045.7582%2044.6522C45.7224%2044.6728%2045.686%2044.6925%2045.6491%2044.7114C45.6122%2044.7302%2045.5749%2044.7482%2045.5371%2044.7653C45.4993%2044.7824%2045.461%2044.7986%2045.4224%2044.8139C45.3838%2044.8292%2045.3447%2044.8437%2045.3054%2044.8571C45.266%2044.8706%2045.2263%2044.8831%2045.1863%2044.8948C45.1462%2044.9064%2045.1059%2044.917%2045.0654%2044.9267C45.0248%2044.9365%2044.984%2044.9452%2044.943%2044.953C44.902%2044.9609%2044.8608%2044.9677%2044.8194%2044.9735C44.778%2044.9794%2044.7365%2044.9843%2044.6949%2044.9883C44.6533%2044.9921%2044.6116%2044.9951%2044.5698%2044.9971C44.5281%2044.999%2044.4863%2045%2044.4444%2045L13.7778%2045C13.736%2045%2013.6941%2044.999%2013.6524%2044.9971C13.6106%2044.9951%2013.5689%2044.9921%2013.5273%2044.9883C13.4856%2044.9843%2013.4442%2044.9794%2013.4028%2044.9735C13.3614%2044.9677%2013.3202%2044.9609%2013.2792%2044.953C13.2382%2044.9452%2013.1974%2044.9365%2013.1568%2044.9267C13.1163%2044.917%2013.076%2044.9064%2013.0359%2044.8948C12.9959%2044.8831%2012.9562%2044.8706%2012.9168%2044.8571C12.8775%2044.8437%2012.8384%2044.8292%2012.7998%2044.8139C12.7611%2044.7986%2012.7229%2044.7824%2012.6851%2044.7653C12.6473%2044.7482%2012.61%2044.7302%2012.5731%2044.7114C12.5362%2044.6925%2012.4998%2044.6728%2012.4639%2044.6522C12.4281%2044.6317%2012.3928%2044.6102%2012.358%2044.588C12.3232%2044.5658%2012.289%2044.5428%2012.2554%2044.519C12.2218%2044.4951%2012.1889%2044.4705%2012.1566%2044.4451C12.1242%2044.4198%2012.0925%2044.3936%2012.0616%2044.3668C12.0306%2044.3399%2012.0003%2044.3123%2011.9707%2044.284C11.9412%2044.2558%2011.9123%2044.2268%2011.8842%2044.1971C11.8561%2044.1675%2011.8289%2044.1372%2011.8023%2044.1063C11.7758%2044.0754%2011.75%2044.0439%2011.7251%2044.0117C11.7002%2043.9796%2011.6761%2043.9469%2011.6529%2043.9136C11.6297%2043.8803%2011.6073%2043.8465%2011.5858%2043.8122C11.5643%2043.7779%2011.5437%2043.7431%2011.524%2043.7078C11.5043%2043.6726%2011.4855%2043.6369%2011.4676%2043.6007C11.4497%2043.5646%2011.4327%2043.5279%2011.4167%2043.491C11.4007%2043.454%2011.3857%2043.4167%2011.3716%2043.379C11.3575%2043.3414%2011.3444%2043.3034%2011.3323%2043.2652C11.3201%2043.2268%2011.309%2043.1883%2011.2988%2043.1495C11.2887%2043.1107%2011.2795%2043.0717%2011.2714%2043.0324C11.2632%2042.9932%2011.256%2042.9538%2011.2499%2042.9142C11.2437%2042.8747%2011.2387%2042.8349%2011.2345%2042.7951C11.2304%2042.7553%2011.2273%2042.7154%2011.2253%2042.6755C11.2233%2042.6356%2011.2222%2042.5956%2011.2222%2042.5555L11.2222%2023C11.2222%2022.96%2011.2233%2022.92%2011.2253%2022.88C11.2273%2022.8401%2011.2304%2022.8002%2011.2345%2022.7604C11.2387%2022.7206%2011.2437%2022.6809%2011.2499%2022.6414C11.256%2022.6018%2011.2632%2022.5623%2011.2714%2022.5231C11.2795%2022.4839%2011.2887%2022.4448%2011.2988%2022.4061C11.309%2022.3673%2011.3201%2022.3287%2011.3323%2022.2904C11.3444%2022.2521%2011.3575%2022.2141%2011.3716%2022.1765C11.3857%2022.1388%2011.4007%2022.1015%2011.4167%2022.0645C11.4327%2022.0276%2011.4497%2021.991%2011.4676%2021.9549C11.4855%2021.9187%2011.5043%2021.883%2011.524%2021.8477C11.5437%2021.8124%2011.5643%2021.7776%2011.5858%2021.7433C11.6073%2021.709%2011.6297%2021.6752%2011.6529%2021.642C11.6761%2021.6087%2011.7002%2021.576%2011.7251%2021.5438C11.75%2021.5117%2011.7758%2021.4802%2011.8023%2021.4493C11.8289%2021.4183%2011.8561%2021.388%2011.8842%2021.3584C11.9123%2021.3288%2011.9412%2021.2998%2011.9707%2021.2715C12.0003%2021.2432%2012.0306%2021.2157%2012.0616%2021.1888C12.0925%2021.1619%2012.1242%2021.1358%2012.1566%2021.1104C12.1889%2021.085%2012.2218%2021.0604%2012.2554%2021.0366C12.289%2021.0128%2012.3232%2020.9897%2012.358%2020.9675C12.3928%2020.9453%2012.4281%2020.9239%2012.4639%2020.9034C12.4998%2020.8828%2012.5362%2020.863%2012.5731%2020.8442C12.61%2020.8253%2012.6473%2020.8074%2012.6851%2020.7903C12.7229%2020.7731%2012.7612%2020.7569%2012.7998%2020.7416C12.8385%2020.7263%2012.8775%2020.7119%2012.9168%2020.6984C12.9562%2020.685%2012.9959%2020.6725%2013.0359%2020.6608C13.076%2020.6492%2013.1163%2020.6386%2013.1568%2020.6288C13.1974%2020.6191%2013.2382%2020.6103%2013.2792%2020.6025C13.3202%2020.5947%2013.3614%2020.5879%2013.4028%2020.582C13.4442%2020.5761%2013.4856%2020.5712%2013.5273%2020.5673C13.5689%2020.5634%2013.6106%2020.5605%2013.6524%2020.5585C13.6941%2020.5565%2013.736%2020.5555%2013.7778%2020.5555L20.5934%2020.5555ZM16.3333%2040.1111L41.8889%2040.1111L41.8889%2025.4445L34.8943%2025.4445L31.4878%2020.5555L26.7344%2020.5555L23.3279%2025.4445L16.3333%2025.4445L16.3333%2040.1111ZM29.1111%2037.6667C29.0274%2037.6667%2028.9439%2037.6647%2028.8603%2037.6608C28.7768%2037.6568%2028.6934%2037.651%2028.6101%2037.6431C28.5269%2037.6353%2028.4439%2037.6255%2028.3611%2037.6137C28.2784%2037.602%2028.196%2037.5883%2028.114%2037.5727C28.0319%2037.5571%2027.9504%2037.5396%2027.8692%2037.5202C27.7881%2037.5008%2027.7075%2037.4794%2027.6274%2037.4562C27.5474%2037.4329%2027.468%2037.4078%2027.3892%2037.3809C27.3104%2037.3539%2027.2325%2037.3251%2027.1552%2037.2945C27.0779%2037.2639%2027.0014%2037.2315%2026.9259%2037.1973C26.8502%2037.1631%2026.7755%2037.1271%2026.7017%2037.0894C26.628%2037.0516%2026.5552%2037.0122%2026.4835%2036.9711C26.4117%2036.93%2026.3411%2036.8872%2026.2715%2036.8428C26.202%2036.7983%2026.1336%2036.7522%2026.0664%2036.7046C25.9993%2036.6569%2025.9333%2036.6077%2025.8686%2036.5569C25.804%2036.5062%2025.7407%2036.4539%2025.6787%2036.4002C25.6167%2036.3465%2025.5562%2036.2913%2025.497%2036.2347C25.4379%2036.1782%2025.3802%2036.1203%2025.324%2036.061C25.2679%2036.0017%2025.2132%2035.9411%2025.1602%2035.8793C25.1071%2035.8174%2025.0557%2035.7543%2025.0058%2035.6901C24.956%2035.6258%2024.9078%2035.5604%2024.8614%2035.4939C24.8149%2035.4274%2024.7701%2035.3598%2024.7271%2035.2912C24.6841%2035.2225%2024.6429%2035.1529%2024.6035%2035.0824C24.5641%2035.0118%2024.5265%2034.9404%2024.4907%2034.868C24.455%2034.7957%2024.4211%2034.7226%2024.3891%2034.6487C24.357%2034.5747%2024.327%2034.5002%2024.2988%2034.4248C24.2705%2034.3495%2024.2443%2034.2735%2024.2201%2034.197C24.1958%2034.1204%2024.1735%2034.0433%2024.1532%2033.9657C24.1328%2033.8881%2024.1145%2033.81%2024.0982%2033.7315C24.0819%2033.6531%2024.0676%2033.5743%2024.0553%2033.4951C24.0431%2033.416%2024.0328%2033.3366%2024.0246%2033.257C24.0164%2033.1773%2024.0103%2033.0976%2024.0062%2033.0177C24.002%2032.9378%2024%2032.8578%2024%2032.7778C24%2032.6978%2024.002%2032.6178%2024.0062%2032.5379C24.0103%2032.458%2024.0164%2032.3782%2024.0246%2032.2986C24.0328%2032.219%2024.0431%2032.1396%2024.0553%2032.0604C24.0676%2031.9813%2024.0819%2031.9024%2024.0982%2031.824C24.1145%2031.7455%2024.1328%2031.6675%2024.1532%2031.5899C24.1735%2031.5122%2024.1958%2031.4352%2024.2201%2031.3586C24.2443%2031.282%2024.2705%2031.2061%2024.2988%2031.1308C24.327%2031.0554%2024.357%2030.9808%2024.3891%2030.9069C24.4211%2030.833%2024.455%2030.7599%2024.4907%2030.6875C24.5265%2030.6152%2024.5641%2030.5437%2024.6035%2030.4732C24.6429%2030.4026%2024.6841%2030.333%2024.7271%2030.2644C24.7701%2030.1958%2024.8149%2030.1282%2024.8614%2030.0617C24.9078%2029.9951%2024.956%2029.9297%2025.0058%2029.8655C25.0557%2029.8012%2025.1071%2029.7381%2025.1602%2029.6763C25.2132%2029.6144%2025.2679%2029.5539%2025.324%2029.4946C25.3802%2029.4353%2025.4379%2029.3774%2025.497%2029.3208C25.5562%2029.2643%2025.6167%2029.2091%2025.6787%2029.1554C25.7407%2029.1016%2025.804%2029.0494%2025.8686%2028.9986C25.9333%2028.9478%2025.9993%2028.8986%2026.0664%2028.851C26.1336%2028.8033%2026.202%2028.7572%2026.2715%2028.7128C26.3411%2028.6684%2026.4117%2028.6256%2026.4835%2028.5844C26.5552%2028.5433%2026.628%2028.5039%2026.7017%2028.4661C26.7755%2028.4284%2026.8502%2028.3925%2026.9259%2028.3583C27.0014%2028.3241%2027.0779%2028.2916%2027.1552%2028.261C27.2325%2028.2304%2027.3104%2028.2016%2027.3892%2028.1747C27.468%2028.1477%2027.5474%2028.1226%2027.6274%2028.0994C27.7075%2028.0762%2027.7881%2028.0548%2027.8692%2028.0354C27.9504%2028.016%2028.0319%2027.9985%2028.114%2027.9828C28.196%2027.9672%2028.2784%2027.9536%2028.3611%2027.9418C28.4439%2027.9301%2028.5269%2027.9203%2028.6101%2027.9124C28.6934%2027.9046%2028.7768%2027.8987%2028.8603%2027.8948C28.9439%2027.8908%2029.0274%2027.8889%2029.1111%2027.8889C29.1948%2027.8889%2029.2783%2027.8908%2029.3619%2027.8948C29.4454%2027.8987%2029.5289%2027.9046%2029.6121%2027.9124C29.6953%2027.9203%2029.7783%2027.9301%2029.861%2027.9418C29.9438%2027.9536%2030.0262%2027.9672%2030.1082%2027.9828C30.1903%2027.9985%2030.2719%2028.016%2030.353%2028.0354C30.4342%2028.0548%2030.5147%2028.0762%2030.5948%2028.0994C30.6749%2028.1226%2030.7542%2028.1477%2030.833%2028.1747C30.9117%2028.2016%2030.9898%2028.2304%2031.067%2028.261C31.1443%2028.2916%2031.2207%2028.3241%2031.2964%2028.3583C31.372%2028.3925%2031.4467%2028.4284%2031.5205%2028.4661C31.5943%2028.5039%2031.667%2028.5433%2031.7387%2028.5844C31.8105%2028.6256%2031.8812%2028.6684%2031.9507%2028.7128C32.0202%2028.7572%2032.0886%2028.8033%2032.1558%2028.851C32.223%2028.8986%2032.2889%2028.9478%2032.3536%2028.9986C32.4182%2029.0494%2032.4816%2029.1016%2032.5435%2029.1554C32.6055%2029.2091%2032.6661%2029.2643%2032.7252%2029.3208C32.7843%2029.3774%2032.842%2029.4353%2032.8982%2029.4946C32.9544%2029.5539%2033.009%2029.6144%2033.0621%2029.6763C33.1151%2029.7381%2033.1666%2029.8012%2033.2164%2029.8655C33.2662%2029.9297%2033.3144%2029.9951%2033.3608%2030.0617C33.4073%2030.1282%2033.452%2030.1958%2033.495%2030.2644C33.5381%2030.333%2033.5793%2030.4026%2033.6187%2030.4732C33.6581%2030.5437%2033.6958%2030.6152%2033.7315%2030.6875C33.7673%2030.7599%2033.8011%2030.833%2033.8332%2030.9069C33.8652%2030.9808%2033.8953%2031.0554%2033.9234%2031.1308C33.9516%2031.2061%2033.9779%2031.282%2034.0021%2031.3586C34.0264%2031.4352%2034.0487%2031.5122%2034.069%2031.5899C34.0893%2031.6675%2034.1077%2031.7455%2034.124%2031.824C34.1404%2031.9024%2034.1546%2031.9813%2034.1669%2032.0604C34.1792%2032.1396%2034.1894%2032.219%2034.1976%2032.2986C34.2058%2032.3782%2034.2119%2032.458%2034.2161%2032.5379C34.2202%2032.6178%2034.2222%2032.6978%2034.2222%2032.7778C34.2222%2032.8578%2034.2202%2032.9378%2034.2161%2033.0177C34.2119%2033.0976%2034.2058%2033.1773%2034.1976%2033.257C34.1894%2033.3366%2034.1792%2033.416%2034.1669%2033.4951C34.1546%2033.5743%2034.1404%2033.6531%2034.124%2033.7315C34.1077%2033.81%2034.0893%2033.8881%2034.069%2033.9657C34.0487%2034.0433%2034.0264%2034.1204%2034.0021%2034.197C33.9779%2034.2735%2033.9516%2034.3495%2033.9234%2034.4248C33.8953%2034.5002%2033.8652%2034.5747%2033.8332%2034.6487C33.8011%2034.7226%2033.7673%2034.7957%2033.7315%2034.868C33.6958%2034.9404%2033.6581%2035.0118%2033.6187%2035.0824C33.5793%2035.1529%2033.5381%2035.2225%2033.495%2035.2912C33.452%2035.3598%2033.4073%2035.4274%2033.3608%2035.4939C33.3144%2035.5604%2033.2662%2035.6258%2033.2164%2035.6901C33.1666%2035.7543%2033.1151%2035.8174%2033.0621%2035.8793C33.009%2035.9411%2032.9544%2036.0017%2032.8982%2036.061C32.842%2036.1203%2032.7843%2036.1782%2032.7252%2036.2347C32.6661%2036.2913%2032.6055%2036.3465%2032.5435%2036.4002C32.4816%2036.4539%2032.4182%2036.5062%2032.3536%2036.5569C32.2889%2036.6077%2032.223%2036.6569%2032.1558%2036.7046C32.0886%2036.7522%2032.0202%2036.7983%2031.9507%2036.8428C31.8812%2036.8872%2031.8105%2036.93%2031.7387%2036.9711C31.667%2037.0123%2031.5943%2037.0517%2031.5205%2037.0894C31.4467%2037.1271%2031.372%2037.1631%2031.2964%2037.1973C31.2207%2037.2315%2031.1443%2037.2639%2031.067%2037.2945C30.9898%2037.3251%2030.9117%2037.3539%2030.833%2037.3809C30.7542%2037.4078%2030.6749%2037.4329%2030.5948%2037.4562C30.5147%2037.4794%2030.4342%2037.5008%2030.353%2037.5202C30.2719%2037.5396%2030.1903%2037.5571%2030.1082%2037.5727C30.0262%2037.5883%2029.9438%2037.602%2029.861%2037.6137C29.7783%2037.6255%2029.6953%2037.6353%2029.6121%2037.6431C29.5289%2037.651%2029.4454%2037.6568%2029.3619%2037.6608C29.2783%2037.6647%2029.1948%2037.6667%2029.1111%2037.6667Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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,BB=new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M0%207L48%207L48%2010.3L0%2010.3L0%207ZM0%2016.9L48%2016.9L48%2023.5L0%2023.5L0%2016.9ZM0%2030.1L48%2030.1L48%2040L0%2040L0%2030.1Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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,PB=new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M12.1443%204L0%2041.3958L5.12362%2041.3958L8.08329%2031.7577L21.6395%2031.7577L24.5992%2041.3958L29.7665%2041.3958L17.6222%204L12.1443%204ZM9.53887%2027.0451L14.7935%2010.1281L14.9682%2010.1281L20.1791%2027.0451L9.53887%2027.0451ZM40.2806%2018.7995C37.9856%2018.7995%2036.1177%2019.2656%2034.7543%2020.2898C33.1774%2021.3946%2032.173%2023.1841%2031.7752%2025.5663L35.5451%2025.9518C35.7586%2024.7205%2036.2972%2023.8228%2037.1608%2023.2302C37.8789%2022.7181%2038.8493%2022.4649%2040.0332%2022.4649C42.8327%2022.4649%2044.2301%2023.9955%2044.2301%2027.0624L44.2301%2027.9543L40.0671%2028.0809C37.3403%2028.1672%2035.1861%2028.8059%2033.682%2030.0833C32.0323%2031.401%2031.2075%2033.3171%2031.2075%2035.7856C31.2075%2037.6154%2031.78%2039.1057%2032.9639%2040.2565C34.041%2041.4073%2035.5451%2042%2037.4859%2042C39.1356%2042%2040.5717%2041.6145%2041.7895%2040.9355C42.8667%2040.2968%2043.7643%2039.4049%2044.4824%2038.2944L44.4824%2041.4016L48%2041.4016L48%2027.3501C48%2024.6687%2047.4275%2022.626%2046.3115%2021.222C45.0161%2019.6051%2043.0074%2018.7995%2040.2806%2018.7995ZM44.2252%2031.2226L44.2252%2032.5C44.2252%2034.2032%2043.6139%2035.6475%2042.4688%2036.7983C41.3189%2037.9491%2039.9555%2038.5418%2038.3447%2038.5418C37.3743%2038.5418%2036.5883%2038.2426%2036.0109%2037.6902C35.3996%2037.1378%2035.1133%2036.4588%2035.1133%2035.6072C35.1133%2032.8855%2036.8357%2031.4355%2040.3146%2031.3492L44.2252%2031.2226Z'%20fill='%232C2C2C'%20%3e%3c/path%3e%3c/svg%3e",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,LB=[{type:"distance",label:"距离"},{type:"clearDistance",label:"垂距"},{type:"clearHeight",label:"净高"},{type:"elevation",label:"标高"},{type:"point",label:"坐标"},{type:"angle",label:"角度"},{type:"area",label:"面积"},{type:"slope",label:"坡度"}],RB={distance:new URL("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%3e%3cdefs%3e%3cstyle%3e%20.cls-1%20{%20fill:%20none;%20}%20.cls-2%20{%20clip-path:%20url(%23clip-距离);%20}%20.cls-3%20{%20clip-path:%20url(%23clip-path);%20}%20.cls-4%20{%20fill:%20%23fff;%20}%20%3c/style%3e%3cclipPath%20id='clip-path'%3e%3crect%20id='矩形_1'%20data-name='矩形%201'%20class='cls-1'%20width='32'%20height='23.606'%20transform='translate(0%200)'/%3e%3c/clipPath%3e%3cclipPath%20id='clip-距离'%3e%3crect%20width='32'%20height='32'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20id='距离'%20class='cls-2'%3e%3crect%20class='cls-4'%20width='32'%20height='32'/%3e%3cg%20id='组_2'%20data-name='组%202'%20transform='translate(0%204.197)'%3e%3cg%20id='组_1'%20data-name='组%201'%20class='cls-3'%3e%3cpath%20id='路径_1'%20data-name='路径%201'%20d='M29.692,3.03,27.55.919a.529.529,0,0,1-.014-.756A.549.549,0,0,1,28.3.15l.014.013,3.067,3.023a.529.529,0,0,1,0,.756L28.317,6.966a.549.549,0,0,1-.767.013.529.529,0,0,1-.014-.756l.014-.013L29.692,4.1H2.31L4.452,6.21a.528.528,0,0,1,.013.756.547.547,0,0,1-.766.013l-.014-.013L.616,3.942a.531.531,0,0,1,0-.756L3.685.163a.548.548,0,0,1,.767.014.528.528,0,0,1,0,.742L2.31,3.03ZM24.136,15.055H23.051V18H21.966v-2.94H20.882V18H19.8v-2.94H18.712V18H17.627v-2.94H16.543v5.078H15.458V15.055H14.373V18H13.288v-2.94H12.2V18H11.119v-2.94H10.034V18H8.949v-2.94H7.865V18H6.78v-2.94H5.7v5.078H4.61V15.055H1.9a.27.27,0,0,0-.272.268v6.413A.269.269,0,0,0,1.9,22H30.1a.268.268,0,0,0,.271-.267V15.323a.269.269,0,0,0-.271-.268H27.39v5.078H26.305V15.055H25.221V18H24.136Zm5.966-1.6A1.884,1.884,0,0,1,32,15.323v6.413a1.885,1.885,0,0,1-1.9,1.871H1.9A1.885,1.885,0,0,1,0,21.736V15.323a1.885,1.885,0,0,1,1.9-1.871Z'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M15.2619%2020.2135C15.2619%2020.8776%2014.5628%2021.2125%2014.0415%2021.0436L4.13531%2016.0541C4.10363%2016.0394%204.07281%2016.023%204.04285%2016.005C4.0129%2015.987%203.98397%2015.9675%203.95607%2015.9464C3.92817%2015.9254%203.90144%2015.9029%203.87591%2015.879C3.85037%2015.8552%203.82615%2015.83%203.80326%2015.8036L3.80909%2035.8838C3.80909%2036.8159%203.18577%2037.4393%202.2537%2037.4393C1.32163%2037.4393%200.701223%2036.8159%200.701223%2035.8838L0.701223%209.16557C0.698312%208.2335%201.31872%207.61016%202.25079%207.61016C3.18286%207.61016%203.80618%208.2335%203.80618%209.16557L3.80035%2014.8075C3.82324%2014.7811%203.84746%2014.7559%203.873%2014.7321C3.89853%2014.7082%203.92525%2014.6858%203.95315%2014.6647C3.98106%2014.6437%204.00999%2014.6242%204.03994%2014.6062C4.0699%2014.5881%204.10072%2014.5718%204.1324%2014.557L14.0444%209.56752C14.5687%209.23546%2015.2619%209.56752%2015.2619%2010.2316L15.2619%2013.9074L32.9566%2013.9074C33.3644%2013.9074%2033.6557%2013.6628%2033.7314%2013.2725L33.7488%2013.0686L33.7488%2010.2142C33.7488%209.71316%2034.3838%209.20925%2034.8557%209.54422L43.8938%2014.5803C44.0132%2014.6415%2044.1181%2014.7259%2044.2026%2014.8337L44.1968%208.07624C44.1968%207.14413%2044.8201%206.52374%2045.7521%206.52374C46.6842%206.52374%2047.3044%207.14413%2047.3044%208.07624L47.3044%2036.0383C47.3044%2036.0637%2047.3038%2036.0891%2047.3025%2036.1145C47.3016%2036.1399%2047.2998%2036.1652%2047.2974%2036.1905C47.2948%2036.2158%2047.2917%2036.241%2047.288%2036.2662C47.2842%2036.2914%2047.2798%2036.3164%2047.2749%2036.3413C47.2698%2036.3663%2047.2642%2036.3911%2047.258%2036.4157C47.252%2036.4404%2047.2453%2036.4649%2047.2378%2036.4892C47.2303%2036.5136%2047.2224%2036.5377%2047.2139%2036.5617C47.2055%2036.5856%2047.1964%2036.6093%2047.1867%2036.6328C47.1767%2036.6563%2047.1664%2036.6795%2047.1558%2036.7025C47.1448%2036.7255%2047.1334%2036.7482%2047.1216%2036.7707C47.1094%2036.7931%2047.0969%2036.8152%2047.0841%2036.837C47.0709%2036.8588%2047.0574%2036.8803%2047.0433%2036.9015C47.0289%2036.9226%2047.0142%2036.9434%2046.9992%2036.9638C46.9842%2036.9843%2046.9686%2037.0043%2046.9524%2037.024C46.9361%2037.0436%2046.9195%2037.0629%2046.9027%2037.0818C46.8855%2037.1006%2046.8679%2037.119%2046.8501%2037.137C46.8321%2037.155%2046.8137%2037.1726%2046.7949%2037.1897C46.7761%2037.2068%2046.7569%2037.2234%2046.7372%2037.2395C46.7176%2037.2557%2046.6975%2037.2713%2046.6772%2037.2865C46.6568%2037.3017%2046.636%2037.3163%2046.6149%2037.3305C46.5937%2037.3447%2046.5723%2037.3583%2046.5505%2037.3714C46.5287%2037.3845%2046.5066%2037.397%2046.4842%2037.409C46.4618%2037.4211%2046.4391%2037.4325%2046.4161%2037.4434C46.3932%2037.4543%2046.3699%2037.4646%2046.3464%2037.4744C46.323%2037.4842%2046.2993%2037.4933%2046.2754%2037.5019C46.2514%2037.5105%2046.2273%2037.5186%2046.203%2037.526C46.1786%2037.5334%2046.1542%2037.5402%2046.1296%2037.5464C46.1049%2037.5526%2046.0801%2037.5582%2046.0552%2037.5632C46.0302%2037.5683%2046.0052%2037.5726%2045.9801%2037.5764C45.9549%2037.5802%2045.9297%2037.5833%2045.9044%2037.5859C45.8791%2037.5884%2045.8537%2037.5903%2045.8284%2037.5916C45.803%2037.5929%2045.7775%2037.5936%2045.7521%2037.5936C44.8201%2037.5936%2044.1968%2036.9732%2044.1968%2036.0412L44.1997%2015.8357C44.1783%2015.8546%2044.1554%2015.8715%2044.1309%2015.8861C44.1064%2015.9008%2044.0807%2015.9131%2044.054%2015.9231L35.0188%2020.9562C34.544%2021.2912%2033.9091%2020.9562%2033.9091%2020.2863L33.9091%2017.4318C33.9091%2016.9279%2033.5887%2016.593%2033.1168%2016.593L15.2619%2016.59L15.2619%2020.2135L15.2619%2020.2135ZM41.0889%2024.2796L41.0889%2036.0412C41.0889%2036.8975%2040.3899%2037.5936%2039.5335%2037.5936C38.6014%2037.5936%2037.981%2036.9732%2037.981%2036.0412L37.981%2024.2796C37.981%2023.3475%2038.6014%2022.7243%2039.5335%2022.7243C40.4656%2022.7243%2041.0889%2023.3475%2041.0889%2024.2796ZM28.6604%2024.2796L28.6604%2036.0412C28.6603%2036.0665%2028.6596%2036.0919%2028.6584%2036.1173C28.657%2036.1426%2028.6551%2036.168%2028.6526%2036.1932C28.6501%2036.2185%2028.6469%2036.2437%2028.6432%2036.2688C28.6394%2036.2939%2028.6351%2036.3189%2028.63%2036.3438C28.625%2036.3687%2028.6194%2036.3935%2028.6133%2036.4181C28.607%2036.4427%2028.6002%2036.4672%2028.5929%2036.4915C28.5855%2036.5158%2028.5774%2036.5399%2028.5689%2036.5638C28.5603%2036.5877%2028.5512%2036.6113%2028.5414%2036.6348C28.5317%2036.6583%2028.5213%2036.6815%2028.5105%2036.7044C28.4996%2036.7274%2028.4881%2036.75%2028.4762%2036.7724C28.4642%2036.7948%2028.4517%2036.8168%2028.4386%2036.8386C28.4255%2036.8604%2028.4119%2036.8819%2028.3978%2036.903C28.3837%2036.9241%2028.369%2036.9448%2028.3539%2036.9652C28.3388%2036.9856%2028.3232%2037.0056%2028.3071%2037.0253C28.2909%2037.0449%2028.2744%2037.0641%2028.2573%2037.0829C28.2402%2037.1017%2028.2227%2037.1201%2028.2048%2037.1381C28.1868%2037.156%2028.1684%2037.1735%2028.1496%2037.1906C28.1308%2037.2076%2028.1116%2037.2242%2028.092%2037.2404C28.0723%2037.2564%2028.0523%2037.2721%2028.032%2037.2872C28.0115%2037.3024%2027.9908%2037.317%2027.9697%2037.3311C27.9486%2037.3452%2027.9272%2037.3588%2027.9054%2037.3719C27.8836%2037.385%2027.8615%2037.3975%2027.8391%2037.4094C27.8167%2037.4214%2027.7941%2037.4329%2027.7712%2037.4438C27.7482%2037.4546%2027.725%2037.4649%2027.7015%2037.4747C27.6781%2037.4844%2027.6544%2037.4936%2027.6305%2037.5022C27.6066%2037.5107%2027.5825%2037.5187%2027.5582%2037.5261C27.5339%2037.5335%2027.5094%2037.5403%2027.4848%2037.5465C27.4602%2037.5527%2027.4354%2037.5583%2027.4105%2037.5633C27.3857%2037.5683%2027.3606%2037.5727%2027.3355%2037.5765C27.3104%2037.5802%2027.2852%2037.5833%2027.2599%2037.5859C27.2347%2037.5884%2027.2094%2037.5903%2027.184%2037.5916C27.1586%2037.5929%2027.1333%2037.5936%2027.1079%2037.5936C26.1758%2037.5936%2025.5525%2036.9732%2025.5525%2036.0412L25.5525%2024.2796C25.5525%2023.3475%2026.1758%2022.7243%2027.1079%2022.7243C28.0399%2022.7243%2028.6604%2023.3475%2028.6604%2024.2796ZM10.019%2024.2796L10.019%2036.0412C10.0189%2036.0666%2010.0183%2036.092%2010.017%2036.1174C10.0156%2036.1428%2010.0138%2036.1681%2010.0112%2036.1934C10.0087%2036.2187%2010.0055%2036.2439%2010.0018%2036.2691C9.99798%2036.2942%209.99357%2036.3193%209.9886%2036.3442C9.98359%2036.3691%209.97796%2036.3939%209.97178%2036.4185C9.96554%2036.4432%209.95874%2036.4677%209.95134%2036.492C9.94393%2036.5163%209.93592%2036.5404%209.92729%2036.5644C9.91867%2036.5883%209.90952%2036.612%209.89978%2036.6355C9.88998%2036.659%209.87967%2036.6822%209.86879%2036.7051C9.85787%2036.7281%209.84638%2036.7508%209.83438%2036.7732C9.82238%2036.7956%209.80982%2036.8177%209.79674%2036.8395C9.78362%2036.8613%209.77003%2036.8828%209.75587%2036.9039C9.74171%2036.925%209.72704%2036.9458%209.7119%2036.9662C9.69671%2036.9866%209.68101%2037.0066%209.66488%2037.0262C9.64876%2037.0459%209.63212%2037.0651%209.61506%2037.0839C9.59795%2037.1027%209.58042%2037.1212%209.56242%2037.1391C9.54442%2037.1571%209.52599%2037.1745%209.50715%2037.1916C9.48826%2037.2087%209.46899%2037.2253%209.44935%2037.2414C9.42967%2037.2575%209.40965%2037.2731%209.38921%2037.2883C9.36878%2037.3034%209.34796%2037.318%209.32682%2037.3321C9.30563%2037.3462%209.28417%2037.3598%209.26237%2037.3729C9.24053%2037.3859%209.2184%2037.3984%209.19599%2037.4104C9.17359%2037.4224%209.15085%2037.4338%209.12788%2037.4446C9.10487%2037.4555%209.08162%2037.4658%209.05818%2037.4755C9.03465%2037.4852%209.01093%2037.4944%208.98703%2037.5029C8.96303%2037.5115%208.93888%2037.5195%208.9146%2037.5268C8.89023%2037.5342%208.86576%2037.541%208.8411%2037.5471C8.81645%2037.5533%208.79165%2037.5589%208.76671%2037.5638C8.74178%2037.5688%208.7167%2037.5731%208.69157%2037.5768C8.6664%2037.5805%208.64118%2037.5837%208.61587%2037.5862C8.59056%2037.5886%208.56524%2037.5905%208.53984%2037.5917C8.51443%2037.593%208.48903%2037.5936%208.46362%2037.5936C7.53156%2037.5936%206.90821%2036.9732%206.90821%2036.0412L6.90821%2024.2796C6.90821%2023.3475%207.53156%2022.7243%208.46362%2022.7243C9.39568%2022.7243%2010.0161%2023.3475%2010.0161%2024.2796L10.019%2024.2796ZM33.3207%2029.7147C34.2527%2029.7147%2034.8732%2030.3381%2034.8732%2031.2701L34.8732%2036.0412C34.8731%2036.0665%2034.8724%2036.0919%2034.8712%2036.1173C34.8699%2036.1426%2034.8679%2036.168%2034.8654%2036.1932C34.8629%2036.2185%2034.8597%2036.2437%2034.856%2036.2688C34.8522%2036.2939%2034.8478%2036.3189%2034.8429%2036.3438C34.8378%2036.3687%2034.8323%2036.3935%2034.8261%2036.4181C34.8198%2036.4427%2034.813%2036.4672%2034.8057%2036.4915C34.7983%2036.5158%2034.7903%2036.5399%2034.7817%2036.5638C34.7731%2036.5877%2034.7639%2036.6113%2034.7542%2036.6348C34.7445%2036.6583%2034.7341%2036.6815%2034.7233%2036.7044C34.7124%2036.7274%2034.701%2036.75%2034.689%2036.7724C34.677%2036.7948%2034.6644%2036.8168%2034.6514%2036.8386C34.6383%2036.8604%2034.6247%2036.8819%2034.6106%2036.903C34.5965%2036.9241%2034.5819%2036.9448%2034.5668%2036.9652C34.5516%2036.9856%2034.536%2037.0056%2034.5199%2037.0253C34.5038%2037.0449%2034.4872%2037.0641%2034.4701%2037.0829C34.453%2037.1017%2034.4356%2037.1201%2034.4176%2037.1381C34.3996%2037.156%2034.3812%2037.1735%2034.3624%2037.1906C34.3436%2037.2076%2034.3244%2037.2242%2034.3048%2037.2404C34.2851%2037.2564%2034.2652%2037.2721%2034.2448%2037.2872C34.2244%2037.3024%2034.2036%2037.317%2034.1825%2037.3311C34.1614%2037.3452%2034.1399%2037.3588%2034.1182%2037.3719C34.0964%2037.385%2034.0743%2037.3975%2034.0519%2037.4094C34.0296%2037.4214%2034.0069%2037.4329%2033.9839%2037.4438C33.961%2037.4546%2033.9378%2037.4649%2033.9144%2037.4747C33.8909%2037.4844%2033.8672%2037.4936%2033.8433%2037.5022C33.8194%2037.5107%2033.7953%2037.5187%2033.771%2037.5261C33.7467%2037.5335%2033.7223%2037.5403%2033.6977%2037.5465C33.673%2037.5527%2033.6482%2037.5583%2033.6234%2037.5633C33.5984%2037.5683%2033.5734%2037.5727%2033.5484%2037.5765C33.5232%2037.5802%2033.498%2037.5833%2033.4727%2037.5859C33.4475%2037.5884%2033.4222%2037.5903%2033.3968%2037.5916C33.3714%2037.5929%2033.3461%2037.5936%2033.3207%2037.5936C32.3886%2037.5936%2031.7682%2036.9732%2031.7682%2036.0412L31.7682%2031.2701C31.7682%2030.3381%2032.3886%2029.7147%2033.3207%2029.7147ZM22.4446%2031.2701L22.4446%2036.0412C22.4446%2036.8975%2021.7485%2037.5936%2020.8892%2037.5936C19.9572%2037.5936%2019.3367%2036.9732%2019.3367%2036.0412L19.3367%2031.2701C19.3367%2030.3381%2019.9572%2029.7147%2020.8892%2029.7147C21.8213%2029.7147%2022.4446%2030.3381%2022.4446%2031.2701ZM16.2289%2031.2701L16.2289%2036.0412C16.2288%2036.0665%2016.2282%2036.0919%2016.2269%2036.1173C16.2256%2036.1426%2016.2237%2036.168%2016.2211%2036.1932C16.2186%2036.2185%2016.2155%2036.2437%2016.2117%2036.2688C16.2079%2036.2939%2016.2036%2036.3189%2016.1986%2036.3438C16.1936%2036.3687%2016.188%2036.3935%2016.1818%2036.4181C16.1756%2036.4427%2016.1688%2036.4672%2016.1614%2036.4915C16.154%2036.5158%2016.146%2036.5399%2016.1374%2036.5638C16.1288%2036.5877%2016.1197%2036.6113%2016.11%2036.6348C16.1002%2036.6583%2016.0899%2036.6815%2016.079%2036.7044C16.0681%2036.7274%2016.0567%2036.75%2016.0447%2036.7724C16.0328%2036.7948%2016.0202%2036.8168%2016.0072%2036.8386C15.994%2036.8604%2015.9804%2036.8819%2015.9664%2036.903C15.9522%2036.9241%2015.9376%2036.9448%2015.9225%2036.9652C15.9073%2036.9856%2015.8917%2037.0056%2015.8756%2037.0253C15.8595%2037.0449%2015.8429%2037.0641%2015.8259%2037.0829C15.8088%2037.1017%2015.7913%2037.1201%2015.7734%2037.1381C15.7554%2037.156%2015.737%2037.1735%2015.7182%2037.1906C15.6994%2037.2076%2015.6801%2037.2242%2015.6605%2037.2404C15.6409%2037.2564%2015.6209%2037.2721%2015.6005%2037.2872C15.5801%2037.3024%2015.5594%2037.317%2015.5382%2037.3311C15.5171%2037.3452%2015.4957%2037.3588%2015.4739%2037.3719C15.4521%2037.385%2015.43%2037.3975%2015.4077%2037.4094C15.3853%2037.4214%2015.3626%2037.4329%2015.3397%2037.4438C15.3167%2037.4546%2015.2935%2037.4649%2015.2701%2037.4747C15.2466%2037.4844%2015.2229%2037.4936%2015.199%2037.5022C15.1751%2037.5107%2015.151%2037.5187%2015.1268%2037.5261C15.1025%2037.5335%2015.078%2037.5403%2015.0534%2037.5465C15.0287%2037.5527%2015.0039%2037.5583%2014.9791%2037.5633C14.9542%2037.5683%2014.9292%2037.5727%2014.9041%2037.5765C14.8789%2037.5802%2014.8538%2037.5833%2014.8285%2037.5859C14.8032%2037.5884%2014.7779%2037.5903%2014.7526%2037.5916C14.7271%2037.5929%2014.7018%2037.5936%2014.6764%2037.5936C13.7444%2037.5936%2013.1239%2036.9732%2013.1239%2036.0412L13.1239%2031.2701C13.1239%2030.3381%2013.7444%2029.7147%2014.6764%2029.7147C15.6085%2029.7147%2016.2289%2030.3381%2016.2289%2031.2701Z'%20fill='%23404040'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M19.0032%2032.1184C18.712%2032.1184%2018.4032%2032.1184%2018.112%2032.4096C17.512%2032.6992%2017.8224%2033.5904%2018.112%2033.8816L23.1472%2038.6256C23.7472%2038.9152%2024.6192%2038.9152%2024.928%2038.6256L29.9632%2033.8816C30.2528%2033.5904%2030.2528%2033.2816%2030.2528%2032.9904C30.2528%2032.3904%2029.6528%2032.1008%2029.072%2032.1008L25.7856%2032.1008L25.7856%2016.2192L29.0256%2016.2192C29.3152%2016.2192%2029.6256%2016.2192%2029.9152%2015.928C30.5152%2015.6368%2030.2064%2014.7472%2029.9152%2014.456L24.8816%209.7072C24.2816%209.4176%2023.4096%209.4176%2023.0992%209.7072L18.0656%2014.4512C17.7744%2014.7424%2017.7744%2015.0512%2017.7744%2015.3424C17.7744%2015.9424%2018.3744%2016.232%2018.9568%2016.232L22.24%2016.232L22.24%2032.1328L19.0016%2032.1328L19.0016%2032.1184L19.0032%2032.1184ZM4.75842%206.80639L43.2384%206.80639C44.128%206.80639%2044.7104%206.20639%2044.7104%205.33442C44.7104%204.1536%2044.1088%203.2624%2043.2384%203.2624L4.75678%203.2624C4.1568%203.2624%203.5744%203.8624%203.2848%204.73442C3.2848%205.62561%203.8848%206.5152%204.75678%206.80639L4.75842%206.80639ZM43.256%2041.1936L4.75842%2041.1936C4.1584%2041.1936%203.576%2041.7936%203.2864%2042.6656C3.2864%2043.5568%203.8864%2044.4464%204.75842%2044.7376L43.2384%2044.7376C44.128%2044.7376%2044.7104%2044.1376%2044.7104%2043.2656C44.728%2042.08%2044.1328%2041.1936%2043.256%2041.1936Z'%20fill='%23404040'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%3e%3cdefs%3e%3cstyle%3e%20.cls-1%20{%20clip-path:%20url(%23clip-标高);%20}%20.cls-2%20{%20fill:%20%23fff;%20}%20%3c/style%3e%3cclipPath%20id='clip-标高'%3e%3crect%20width='32'%20height='32'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20id='标高'%20class='cls-1'%3e%3crect%20class='cls-2'%20width='32'%20height='32'/%3e%3cpath%20id='路径_8'%20data-name='路径%208'%20d='M84.131,193.119a1.056,1.056,0,0,1,1.116.982v7.857a1.056,1.056,0,0,1-1.116.982H54.367a1.056,1.056,0,0,1-1.116-.982V194.1a1.056,1.056,0,0,1,1.116-.982Zm-1.116,1.964H55.483v5.893H83.015Zm1.116-13.749a1.064,1.064,0,0,1,1.114.935,1.032,1.032,0,0,1-1.007,1.025l-.107,0H71.2l-7.858,6.914a1.227,1.227,0,0,1-1.578,0l-8.185-7.2-.018-.016-.032-.031.049.047a1.107,1.107,0,0,1-.092-.092l-.011-.014a.869.869,0,0,1-.182-.857l0-.008L53.31,182l.012-.029.02-.045.019-.035a1.1,1.1,0,0,1,.891-.552h.007q.053,0,.107,0ZM68.043,183.3H57.06l5.492,4.831Z'%20transform='translate(-53.247%20-176.136)'/%3e%3c/g%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M40.1698%2018.0929C40.1428%2020.5301%2039.3645%2022.7586%2038.3131%2024.9092C36.7378%2028.1319%2034.6461%2031.0118%2032.3727%2033.7664C30.2564%2036.3308%2027.9853%2038.7519%2025.5613%2041.0284C24.7143%2041.8237%2023.9413%2041.8481%2023.073%2041.0687C18.5767%2037.0334%2014.5359%2032.6092%2011.4515%2027.3755C10.9495%2026.5238%2010.4945%2025.6458%2010.1025%2024.7372C9.73107%2023.8761%2010.0514%2022.9753%2010.8534%2022.6034C11.6577%2022.2304%2012.582%2022.5576%2012.9732%2023.4086C14.8167%2027.4176%2017.5132%2030.8241%2020.4598%2034.0548C21.596%2035.3006%2022.7863%2036.4939%2024.0184%2037.6454C24.1708%2037.7877%2024.2667%2037.9033%2024.4831%2037.6853C28.5664%2033.5709%2032.3892%2029.2509%2035.1723%2024.1156C35.9836%2022.6186%2036.66%2021.0543%2036.8866%2019.3498C37.2281%2016.7802%2036.712%2014.3356%2035.493%2012.0807C33.1715%207.78618%2029.5679%205.33714%2024.6496%205.16445C19.0467%204.96786%2014.0685%208.58606%2012.3051%2013.9294C11.8621%2015.2717%2011.6275%2016.6474%2011.6092%2018.061C11.5962%2019.0717%2010.9335%2019.7853%2010.0201%2019.783C9.10383%2019.7808%208.43479%2019.0505%208.43746%2018.056C8.45818%2010.5393%2013.6357%204.02759%2020.9324%202.34148C26.9693%200.946299%2033.4364%203.45514%2037.0904%208.60424C39.1088%2011.4483%2040.1115%2014.6187%2040.1698%2018.0929ZM6.42075%2043.1971C18.363%2043.1971%2030.2366%2043.1971%2042.1204%2043.1971C42.1186%2042.9919%2041.9834%2042.8579%2041.8977%2042.7076C40.3484%2039.9866%2038.7956%2037.2673%2037.2401%2034.5498C36.9062%2033.9668%2036.8856%2033.3861%2037.257%2032.8222C37.5915%2032.314%2038.0819%2032.0681%2038.6918%2032.1099C39.2399%2032.1477%2039.6712%2032.4169%2039.9425%2032.8899C42.0656%2036.5932%2044.1915%2040.2948%2046.2926%2044.0105C46.9411%2045.1576%2046.1392%2046.3818%2044.7752%2046.3821C37.6695%2046.3845%2030.564%2046.3832%2023.4585%2046.3832C16.9643%2046.3832%2010.4699%2046.3507%203.97625%2046.4082C2.51885%2046.4212%201.62531%2045.0904%202.42647%2043.7424C4.52293%2040.2152%206.51577%2036.6264%208.55216%2033.0634C8.99072%2032.2962%209.67627%2031.9592%2010.3942%2032.1457C11.456%2032.4219%2011.9181%2033.5491%2011.3553%2034.5444C10.2685%2036.467%209.16594%2038.3807%208.07099%2040.2987C7.53258%2041.2418%206.99643%2042.1859%206.42075%2043.1971ZM30.6461%2017.8271C30.6465%2021.3322%2027.7864%2024.1813%2024.2754%2024.1734C20.7946%2024.1656%2017.9554%2021.3147%2017.9555%2017.8276C17.9557%2014.3185%2020.8087%2011.4763%2024.3244%2011.4829C27.8051%2011.4893%2030.6458%2014.3402%2030.6461%2017.8271ZM24.3201%2014.6556C22.5583%2014.656%2021.1314%2016.0714%2021.1285%2017.8213C21.1256%2019.591%2022.5741%2021.0173%2024.3575%2021.0005C26.0699%2020.9844%2027.4807%2019.5391%2027.4733%2017.8085C27.4659%2016.0808%2026.0403%2014.6552%2024.3201%2014.6556Z'%20fill='%23404040'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%3e%3cdefs%3e%3cstyle%3e%20.cls-1%20{%20clip-path:%20url(%23clip-角度);%20}%20.cls-2%20{%20fill:%20%23fff;%20}%20%3c/style%3e%3cclipPath%20id='clip-角度'%3e%3crect%20width='32'%20height='32'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20id='角度'%20class='cls-1'%3e%3crect%20class='cls-2'%20width='32'%20height='32'/%3e%3cpath%20id='路径_7'%20data-name='路径%207'%20d='M39.587,50.766h13.7a1,1,0,0,1,0,2H23.171a1,1,0,0,1,0-2h1.418l6.582-7.006v-.006a.517.517,0,0,1,.14-.357.456.456,0,0,1,.337-.144l12.1-12.876a.451.451,0,0,1,.665,0,.524.524,0,0,1,0,.708L32.883,43.355a8.3,8.3,0,0,1,6.7,7.411Zm-.949,0a7.254,7.254,0,0,0-6.611-6.5l-6.108,6.5Z'%20transform='translate(-22.229%20-26.489)'/%3e%3c/g%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%3e%3cpath%20d='M28.7725%2016.8582L16.6882%2028.9801C16.0335%2029.6368%2016.0335%2030.7313%2016.6882%2031.3881C17.0156%2031.7164%2017.452%2031.8806%2017.8885%2031.8806C18.3249%2031.8806%2018.7614%2031.7164%2019.0887%2031.3881L31.173%2019.2662C31.8277%2018.6094%2031.8277%2017.5149%2031.173%2016.8582C30.5183%2016.2015%2029.4272%2016.2015%2028.7725%2016.8582Z'%20fill='%23404040'%20%3e%3c/path%3e%3cpath%20d='M44.5667%2011.9055C45.385%2011.9055%2046.0397%2011.2488%2046.0397%2010.4552L46.0397%203.47761C46.0397%202.65672%2045.385%202%2044.5667%202L37.6107%202C36.7924%202%2036.1377%202.65672%2036.1377%203.47761L36.1377%205.06468L11.9418%205.06468L11.9418%203.47761C11.9418%202.65672%2011.2871%202%2010.4688%202L3.51277%202C2.69442%202%202.03974%202.65672%202.03974%203.47761L2.03974%2010.4279C2.03974%2011.2488%202.69442%2011.9055%203.51277%2011.9055L5.20403%2011.9055L5.20403%2036.0671L3.51277%2036.0671C2.69442%2036.0671%202.03974%2036.7239%202.03974%2037.5448L2.03974%2044.5224C2.03974%2045.3433%202.69442%2046%203.51277%2046L10.4688%2046C11.2598%2046%2011.9145%2045.3433%2011.9418%2044.5224L11.9418%2042.7438L36.1377%2042.7438L36.1377%2044.5224C36.1377%2045.3433%2036.7924%2046%2037.6107%2046L44.5667%2046C45.385%2046%2046.0397%2045.3433%2046.0397%2044.5224L46.0397%2037.5448C46.0397%2036.7239%2045.385%2036.0671%2044.5667%2036.0671L42.7936%2036.0671L42.7936%2011.9055L44.5667%2011.9055ZM39.0837%204.92786L43.0937%204.92786L43.0937%208.95024L39.0837%208.95024L39.0837%204.92786ZM4.9858%204.92786L8.99572%204.92786L8.99572%208.95024L4.9858%208.95024L4.9858%204.92786ZM8.99572%2043.0448L4.9858%2043.0448L4.9858%2039.0224L8.99572%2039.0224L8.99572%2043.0448ZM43.0937%2043.0448L39.0837%2043.0448L39.0837%2039.0224L43.0937%2039.0224L43.0937%2043.0448ZM39.3838%2036.0671L37.6107%2036.0671C36.7924%2036.0671%2036.1377%2036.7239%2036.1377%2037.5448L36.1377%2039.3234L11.9418%2039.3234L11.9418%2037.5448C11.9418%2036.7239%2011.2871%2036.0671%2010.4688%2036.0671L8.61382%2036.0671L8.61382%2011.9055L10.4688%2011.9055C11.2598%2011.9055%2011.9145%2011.2488%2011.9418%2010.4552L11.9418%208.48507L36.1377%208.48507L36.1377%2010.4279C36.1377%2011.2488%2036.7924%2011.9055%2037.6107%2011.9055L39.3838%2011.9055L39.3838%2036.0671Z'%20fill='%23404040'%20%3e%3c/path%3e%3c/svg%3e",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("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%3e%3cdefs%3e%3cstyle%3e%20.cls-1%20{%20clip-path:%20url(%23clip-坡度);%20}%20.cls-2%20{%20fill:%20%23fff;%20}%20%3c/style%3e%3cclipPath%20id='clip-坡度'%3e%3crect%20width='32'%20height='32'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20id='坡度'%20class='cls-1'%3e%3crect%20class='cls-2'%20width='32'%20height='32'/%3e%3cpath%20id='路径_15'%20data-name='路径%2015'%20d='M202.1,188.337l2.629-2.191-8.447-3.106,1.533,8.871,2.629-2.194,9.341,11.209,1.656-1.379Zm-13.726-.435a1.075,1.075,0,0,0-1.07-.341,1.057,1.057,0,0,0-.5.277l-5.11,4.08a1.08,1.08,0,0,0-.406.84l-.007,17.386a1.079,1.079,0,0,0,1.077,1.077L205.7,211.2a1.078,1.078,0,0,0,.822-1.774Zm-4.934,21.164.007-15.788,3.968-3.171,15.974,18.941Z'%20transform='translate(-180.36%20-181.131)'/%3e%3c/g%3e%3c/svg%3e",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 kB{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,IB[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,BB,"线宽")),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,PB,"字号")),this.distanceButton=this.createIconButton("测量",TB),this.distanceButton.onclick=()=>this.handlers.onMeasureToggle(),i.appendChild(this.distanceButton);const r=this.createIconButton("截图",DB);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",LB.forEach(c=>{const h=this.createSmallIconButton(c.label,RB[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 FB{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 kB({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?CB(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`,w=new Br(_,{fill:i.stroke,stroke:i.stroke,strokeWidth:1,selectable:!1,evented:!1,objectCaching:!1}),S=new Gs([y,w],{selectable:s,evented:s,objectCaching:!1});return S.annotationType="arrow",S}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,w=b+g*i*y;r+=` Q ${_} ${w} ${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 OB{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 C.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 C.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 C.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 UB{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.5.3";versionEl=null;container;constructor(e){if(window.THREE=C,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new ME(this),this.engineModelModule.init(),this.ai=new I5(this),this.deviceModule=new iy(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new gn(this),this.sceneModule=new ty(this),this.scene=this.sceneModule.scene,this.renderModule=new Lw(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 Jw(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new _5(this),this.clipping.init(),this.composerModule=new uS(this),this.composerModule.init(),this.events=new bE,this.engineStatus=new xE(this),this.engineStatus.init(),this.loaderModule=new AE(this),this.lightModule=new yE(this),this.lightModule.init(),this.viewCube=new rI(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=oI(this),this.rangeScale=new aI(this),this.rangeScale.init(),this.setting=new bI(this),this.engineModelModule.init(),this.handelBehaved=_u(this),this.modelMapperBatch=new M5(this),this.measure=new II(this),this.modelToolModule=new _E(this),this.modelProperties=new S5(this),this.interactionModule=new vE(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new Cc(this),this.modelEdge=new AI(this),this.modelTree=new C5(this),this.viewTree=new O5(this),this.merge2d=new W5(this),this.engineInfo=new w5(this),this.pathRoaming=new T5(this),this.pathRoaming.init(),this.oneClickEncoding=new F5(this),this.minMap=new D5(this),this.linkElement2d3d=new L5(this),this.linkView2d3d=new R5(this),this.grid=new hI(this),this.level=new mI(this),this.issueReport=new B5(this),this.fabricDraw=new FB(this),this.drawingPin=new OB(this),this.text=new P5(this),this.hdr=new fI(this),this.ground=new rf(this),this.ground.init(),this.skyManager=new xI(this),this.setting.init(),this.worldToScreen=new lt(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new DE,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 C.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 C.Vector3;e.getWorldDirection(i);const s=100,r=new C.Vector3().copy(i).multiplyScalar(-s),o=new C.Vector3(0,1,0),a=new C.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 C.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 C.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 C.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof C.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof C.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 C.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 C.Texture&&s.dispose()}),e.dispose()}}const NB=`
6057
6057
  varying vec2 vWorldPos;
6058
6058
 
6059
6059
  void main() {