@arcgis/core 4.34.0-next.17 → 4.34.0-next.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EULA.pdf +0 -0
- package/applications/MapViewer/templateUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{fa894be8cfb6ed485df9.js → 025891f445869e33252b.js} +1 -1
- package/assets/esri/core/workers/chunks/{827919fe23e06e40a330.js → 1a82f903b442a3856bfa.js} +1 -1
- package/assets/esri/core/workers/chunks/{400a4c9fa62964f8fa1d.js → 1f48d6c76f0014064eca.js} +1 -1
- package/assets/esri/core/workers/chunks/22206d13a75d61d77023.js +1 -0
- package/assets/esri/core/workers/chunks/227d25fcbb5f590c4581.js +1 -0
- package/assets/esri/core/workers/chunks/{2ad538440cfb3ab94787.js → 2c0c97acb7714b1e0e01.js} +1 -1
- package/assets/esri/core/workers/chunks/3cf31e51266f40072f71.js +1 -0
- package/assets/esri/core/workers/chunks/3e07de009d5febd62b19.js +1 -0
- package/assets/esri/core/workers/chunks/4072ab8378c235a268ca.js +1 -0
- package/assets/esri/core/workers/chunks/52410198c4b2eccfeadd.js +1 -0
- package/assets/esri/core/workers/chunks/{04e558a970c6a77f243e.js → 5cbaf4ff688aafa6643e.js} +1 -1
- package/assets/esri/core/workers/chunks/5e53c7e29bb6d43d08be.js +1 -0
- package/assets/esri/core/workers/chunks/606782a94adcce6975af.js +1 -0
- package/assets/esri/core/workers/chunks/6f8de923519bb16af8ba.js +1 -0
- package/assets/esri/core/workers/chunks/{53e43798d08ad2075c1f.js → 758776e841fd370e3353.js} +1 -1
- package/assets/esri/core/workers/chunks/764e505f2bafdf5afaf9.js +1 -0
- package/assets/esri/core/workers/chunks/8637b9cb30170ac4eae2.js +1 -0
- package/assets/esri/core/workers/chunks/8656c145ff0ca2e51ea6.js +1 -0
- package/assets/esri/core/workers/chunks/8b4a35e3ed39d8be3394.js +1 -0
- package/assets/esri/core/workers/chunks/903c7a0a47c14442d3c1.js +1 -0
- package/assets/esri/core/workers/chunks/933d4a3b0cee82cc80fe.js +1 -0
- package/assets/esri/core/workers/chunks/{d33a5d79f2163ad62b1d.js → 9965961bad09910f577b.js} +1 -1
- package/assets/esri/core/workers/chunks/9d499a37b960273c3f84.js +1 -0
- package/assets/esri/core/workers/chunks/a507192771e5f4f82973.js +1 -0
- package/assets/esri/core/workers/chunks/{66c8816e91e3f9e214d4.js → a92a344763fbc3cec71e.js} +1 -1
- package/assets/esri/core/workers/chunks/a9e1caf05c81055ae194.js +1 -0
- package/assets/esri/core/workers/chunks/{1415d4e2f5f3193be004.js → aa4ae0e54a0507e8dd0f.js} +1 -1
- package/assets/esri/core/workers/chunks/{2d89e354eeadadca4f7f.js → b421986cb4e45c632f7c.js} +1 -1
- package/assets/esri/core/workers/chunks/c1822b03302c3db71b1f.js +1 -0
- package/assets/esri/core/workers/chunks/d3bfd0c382c2f39a787b.js +1 -0
- package/assets/esri/core/workers/chunks/d568070513f2b98fd9b5.js +1 -0
- package/assets/esri/core/workers/chunks/d6df12bed626d56cd6b2.js +1 -0
- package/assets/esri/core/workers/chunks/{5bfccd5dffda74740aa4.js → df811b31e0446de5d322.js} +1 -1
- package/assets/esri/core/workers/chunks/e0146db608959ead9c97.js +1 -0
- package/assets/esri/core/workers/chunks/ec339075bb4faeec1413.js +1 -0
- package/assets/esri/core/workers/chunks/f4442a2b40e44f90b461.js +1 -0
- package/assets/esri/core/workers/chunks/{fa5715ca3ce95d005b0a.js → faa892ad4cc8a90b6c79.js} +1 -1
- package/assets/esri/themes/base/widgets/_Legend.scss +3 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ar.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bg.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bs.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ca.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_cs.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_da.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_de.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_el.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_es.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_et.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fi.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_he.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hu.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_id.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_it.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ja.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ko.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lt.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lv.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_nl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_no.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-BR.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-PT.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ro.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ru.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sk.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sv.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_th.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_tr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_uk.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_vi.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-CN.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-HK.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-TW.json +1 -1
- package/chunks/sphere.js +1 -1
- package/config.js +1 -1
- package/core/accessorSupport/trackingUtils.js +1 -1
- package/core/sql.js +1 -1
- package/geometry/spatialReferenceEllipsoidUtils.js +1 -1
- package/geometry/support/coordsUtils.js +1 -1
- package/geometry/support/sphere.js +1 -1
- package/interfaces.d.ts +101 -49
- package/kernel.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/OrientedImageryLayer.js +1 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/VectorTileLayer.js +1 -1
- package/layers/VideoLayer.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/mixins/FeatureLayerBase.js +1 -1
- package/layers/orientedImagery/core/ExposurePoint.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/orientedImagery/core/utils.js +1 -1
- package/layers/orientedImagery/transformations/updateElevation.js +1 -1
- package/layers/orientedImagery/transformations/updateElevationUtils.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/TitleCreator.js +1 -1
- package/layers/support/arcgisLayers.js +1 -1
- package/layers/support/fetchService.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/video/VideoCameraSensorModel.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/networks/UtilityNetwork.js +1 -1
- package/package.json +1 -1
- package/portal/support/layersLoader.js +1 -1
- package/portal/support/loadUtils.js +1 -1
- package/portal/support/portalLayers.js +1 -1
- package/request.js +1 -1
- package/rest/knowledgeGraphService.js +1 -1
- package/rest/support/DateBinParameters.js +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/renderers/support/spikeUtils.js +1 -1
- package/support/requestUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/effects/EffectRadial.js +1 -1
- package/symbols/cim/utils.js +1 -1
- package/symbols/support/previewCIMSymbol.js +1 -1
- package/symbols/support/previewSymbol2D.js +1 -1
- package/symbols/support/svgUtils.js +1 -1
- package/views/2d/engine/vectorTiles/style/StyleRepository.js +1 -1
- package/views/3d/analysis/DimensionAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSightAnalysisView3D.js +1 -1
- package/views/3d/analysis/SliceAnalysisView3D.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/controllers/PointToPointAnimationController.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/popupHitTest.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/SourceGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
- package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/analysis/analysisViewUtils.js +1 -1
- package/views/layers/DimensionLayerView.js +1 -1
- package/views/layers/LineOfSightLayerView.js +1 -1
- package/views/layers/ViewshedLayerView.js +1 -1
- package/views/support/drapedUtils.js +1 -1
- package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
- package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
- package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
- package/widgets/Expand.js +1 -1
- package/widgets/FeatureTable/support/templateUtils.js +1 -1
- package/widgets/Legend/styles/support/sizeRampUtils.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Legend/support/sizeRampUtils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/support/GridControls.js +1 -1
- package/assets/esri/core/workers/chunks/1443520c9fb23381f8d5.js +0 -1
- package/assets/esri/core/workers/chunks/254c4f7e277ae9915dce.js +0 -1
- package/assets/esri/core/workers/chunks/273beed633cc37416ad7.js +0 -1
- package/assets/esri/core/workers/chunks/3f8cc157b65a9d570921.js +0 -1
- package/assets/esri/core/workers/chunks/49a57dc1e6d1048fa949.js +0 -1
- package/assets/esri/core/workers/chunks/500fb5f615f0c1db1b66.js +0 -1
- package/assets/esri/core/workers/chunks/513dc2467e9b8b8c6df4.js +0 -1
- package/assets/esri/core/workers/chunks/52239e958a82ebcd2e7a.js +0 -1
- package/assets/esri/core/workers/chunks/5ef1095842e21090f1f4.js +0 -1
- package/assets/esri/core/workers/chunks/7716a9fb380d66ba7292.js +0 -1
- package/assets/esri/core/workers/chunks/78a57f5aeb277b84b3da.js +0 -1
- package/assets/esri/core/workers/chunks/7c56740cac444419e5b4.js +0 -1
- package/assets/esri/core/workers/chunks/802c6b1a6cb9264b8e4f.js +0 -1
- package/assets/esri/core/workers/chunks/8855f1a6224ffbd0bb66.js +0 -1
- package/assets/esri/core/workers/chunks/885e8e90dfe5dbd5053d.js +0 -1
- package/assets/esri/core/workers/chunks/88b1214c284c2ec7d51b.js +0 -1
- package/assets/esri/core/workers/chunks/932808e485f305b6a26a.js +0 -1
- package/assets/esri/core/workers/chunks/beb01d400f1aa089d2dc.js +0 -1
- package/assets/esri/core/workers/chunks/cc1328cacc4ac07eb548.js +0 -1
- package/assets/esri/core/workers/chunks/cfc5e0ec9b0290407383.js +0 -1
- package/assets/esri/core/workers/chunks/d2139307f62ea8bf999a.js +0 -1
- package/assets/esri/core/workers/chunks/ddb66fe6fcd0764daa7a.js +0 -1
- package/assets/esri/core/workers/chunks/eac7af86166c09c6a9be.js +0 -1
- package/assets/esri/core/workers/chunks/ec49e2849766402ad5c7.js +0 -1
- package/assets/esri/core/workers/chunks/f3e179b48bca50c94538.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../analysis/Viewshed.js";import{makeHandle as i}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{mapCollection as s}from"../../../../core/mapCollectionUtils.js";import{rad2deg as a}from"../../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../../core/maybe.js";import{when as o,watch as l,syncAndInitial as r,sync as d,initial as c}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as m,H as g,i as v,p as w,e as _}from"../../../../chunks/vec32.js";import{create as V}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../../geometry/Point.js";import{fromPositionAndNormal as b,create as y,projectPoint as S}from"../../../../geometry/support/plane.js";import{creationVerticalOffset as T}from"./ViewshedConfiguration.js";import{ViewshedSubTool as C}from"./ViewshedSubTool.js";import{Manipulator3D as D}from"../../interactive/Manipulator3D.js";import{Settings as M}from"../../interactive/editingTools/settings.js";import{ExtendedLineVisualElement as j}from"../../interactive/visualElements/ExtendedLineVisualElement.js";import{LaserlineVisualElement as H}from"../../interactive/visualElements/LaserlineVisualElement.js";import{toGraphic as I}from"../../webgl-engine/lib/intersectorUtilsConversions.js";import{RenderOccludedFlag as P}from"../../webgl-engine/lib/Material.js";import{AnalysisToolBase as E}from"../../../interactive/AnalysisToolBase.js";import{sketchKeys as L}from"../../../interactive/keybindings.js";import{newToolIntersector as k}from"../../../interactive/ToolIntersector.js";import{createScreenPointArrayFromEvent as O}from"../../../support/screenUtils.js";const R=Symbol("interactionVisuals");let W=class extends E{constructor(e){super(e),this.removeIncompleteOnCancel=!1,this.automaticManipulatorSelection=!1,this._stagedViewshed=null,this._stagedViewshedComputedData=null,this._placementMode=q,this._creationState=!1,this._interactionVisualElements=null,this._settings=new M({getTheme:()=>this.view.effectiveTheme}),this._selectedManipulator=null}initialize(){this._intersector=k(this.view.state.viewingMode),this._createInteractionVisuals();const e=this.analysisViewData.viewshedComputedDataHandles;this.subToolHandles=s((()=>e),(({viewshedComputedData:e})=>{const t=new C({analysis:this.analysis,analysisViewData:this.analysisViewData,parentTool:this,view:this.view,viewshedComputedData:e});return{subTool:t,remove:()=>{this.selectedViewshed===e.viewshed&&(this.selectedViewshed=null),t.destroy()}}})),this.addHandles([o((()=>this._valid),(()=>this.finishToolCreation()),r),l((()=>this._stagedViewshed),(e=>{const t=this.analysisViewData.viewshedComputedDataHandles;this._stagedViewshedComputedData=null!=e&&null!=t?this._findSubTool(e)?.viewshedComputedData:null}),r),this.analysis.viewsheds.on("after-remove",(e=>{const t=this._stagedViewshed;null!=t&&e.item===t&&this.analysis.viewsheds.add(t)})),l((()=>this.firstGrabbedManipulator),(e=>{if(null!=e){const t=this._findSubTool(e)?.viewshed;this.selectedViewshed=t,this._selectManipulator(e)}else this._selectedSubTool?.onManipulatorSelectionChanged()}),d),l((()=>this.view.activeTool),(e=>{e!==this&&null!=e&&(this.selectedViewshed=null)})),o((()=>{const e=this.selectedViewshedComputedData;return null==e?null:{subTool:this._selectedSubTool,observer:e.observerRenderSpace,target:e.targetRenderSpace}}),(e=>{const{subTool:t,observer:i,target:s}=e;t?.moveInteractionState.dragging?this._updateInteractionVisualsLocation(i,!0):t?.scaleOrientInteractionState.dragging&&this._updateInteractionVisualsLocation(s,!1)}),c),l((()=>this.creating),(()=>this.updateInteractionVisualsVisibility())),l((()=>this.selectedViewshed),(e=>{const t=this._selectedManipulator,i=this._selectedSubTool;null==e?this._selectManipulator(null):null!=t&&i.hasManipulator(t)||this._selectManipulator(i.discManipulator)}),c)])}destroy(){this.subToolHandles=n(this.subToolHandles),this.removeHandles(R)}onDeactivate(){this.removeStaged(),this._creationState=!1}get _valid(){return this.analysisViewData.viewshedComputedDataHandles?.some((e=>e.viewshedComputedData.valid))??!1}get cursor(){return this.creating?"crosshair":null}get _selectedSubTool(){return this._findSubTool(this.selectedViewshed)}_selectManipulator(e){const t=this._selectedManipulator;t!==e&&(this._selectedManipulator=e,null!=t&&(t.selected=!1),null!=e&&(e.selected=!0),this._findSubTool(t)?.onManipulatorSelectionChanged(),this._selectedSubTool?.onManipulatorSelectionChanged())}get selectedViewshed(){return this.analysisViewData.selectedViewshed}set selectedViewshed(e){this.analysisViewData.selectedViewshed=e}get selectedViewshedComputedData(){return this._selectedSubTool?.viewshedComputedData}get stagedViewshed(){return this._stagedViewshed}get grabbing(){return this.subToolHandles.some((({subTool:e})=>e.grabbing))}get creating(){return this._creationState&&this.active}get isPlacingTarget(){return"placing-target"===this._creationState}place(e){this.selectedViewshed=null,this._placementMode=e,this._creationState="placing-observer",this._finishToolCreationIfValid()}onManipulatorSelectionChanged(){this.subToolHandles.forEach((e=>e.subTool.onManipulatorSelectionChanged()))}onInputEvent(e){switch(e.type){case"immediate-double-click":this._doubleClickHandler(e);break;case"pointer-move":this._pointerMoveHandler(e);break;case"key-down":L.cancel===e.key?this._cancelKeyHandler(e):L.delete.includes(e.key)&&this._deleteKeyHandler();break;case"hold":this.updateInteractionVisualsVisibility(!0)}}onInputEventAfter(e){if("immediate-click"===e.type)this._clickPlacementHandler(e)}onActivate(){this._placementMode=q}_clickPlacementHandler(e){if(!this.creating||this.hasFocusedManipulators)return;const i=this._intersectScreen(e,B);if(null!=i){if("placing-observer"===this._creationState){i.mapPoint.z=(i.mapPoint.z??0)+T;const e=new t({observer:i.mapPoint.clone(),feature:i.feature});this.analysis.viewsheds.add(e),this._stagedViewshed=e,this._creationState="placing-target",this._updateStagedViewshed(i.scenePoint)}else if("placing-target"===this._creationState){this._updateStagedViewshed(i.scenePoint);const e=this._stagedViewshed;this._stagedViewshed=null,"multiple"===this._placementMode?(this._creationState="placing-observer",this.selectedViewshed=e):(this._creationState=!1,this._stagedViewshed=null,this.selectedViewshed=null,this._finishToolCreationIfValid(),this.view.activeTool=null)}e.stopPropagation()}}_doubleClickHandler(e){this.creating&&(this.removeStaged(),this._creationState=!1,this.view.activeTool=null,e.stopPropagation())}_pointerMoveHandler(e){if(!this.creating)return;const t=this._intersectScreen(e,B);null!=t&&(this._updateInteractionVisualsLocation(t.scenePoint,!1),this._updateStagedViewshed(t.scenePoint))}_cancelKeyHandler(e){this.creating?this._onCancelWhileCreating(e):this.grabbing||(this.selectedViewshed=null,e.stopPropagation())}_onCancelWhileCreating(e){const t=this.removeStaged();this._finishToolCreationIfValid(),t?(this._creationState="placing-observer",this.selectedViewshed=null,"multiple"===this._placementMode&&e.stopPropagation()):this._creationState=!1}_deleteKeyHandler(){this.creating&&(this.removeStaged(),this._creationState="placing-observer"),null!=this.selectedViewshed&&this.analysis.viewsheds.remove(this.selectedViewshed)}_finishToolCreationIfValid(){this._valid&&this.finishToolCreation()}_updateStagedViewshed(e){const t=this._stagedViewshed,i=this._stagedViewshedComputedData;if(null==t||null==i)return;const{heading:s,tilt:a,farDistance:n}=x(this.view,i,e);t.farDistance=n,t.tilt=a,t.heading=s}removeStaged(){const e=this._stagedViewshed;return null!=e&&(this._stagedViewshed=null,this.analysis.viewsheds.remove(e),!0)}_intersectScreen(e,t){const i=O(e);this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(i,this._intersector);const s=this._intersector.results.min,a=t.scenePoint;if(!s.getIntersectionPoint(a))return null;const n=t.mapPoint;return n.spatialReference=this.view.spatialReference,this.view.renderCoordsHelper.fromRenderCoords(a,n),null==n?null:(t.feature=I(s,this.view),t)}_createInteractionVisuals(){this.removeHandles(R);const e=this._settings.visualElements,t=new H({view:this.view,attached:!1,style:{glowWidth:e.heightPlane.glowWidth,innerWidth:e.heightPlane.innerWidth},isDecoration:!0}),s=new j({view:this.view,extensionType:e.zVerticalLine.extensionType,attached:!1,innerWidth:1,writeDepthEnabled:!1,renderOccluded:P.OccludeAndTransparent,isDecoration:!0});this._interactionVisualElements={laserline:t,verticalLine:s},this.addHandles([l((()=>e.zVerticalLine),(e=>e.apply(s)),r),l((()=>e.heightPlane),(e=>e.apply(t)),r),i((()=>{t.destroy(),s.destroy(),this._interactionVisualElements=null}))],R)}updateInteractionVisualsVisibility(e=!1){const t=this.creating,i=this.analysisViewData.visible,s=this._selectedSubTool,a=this.selectedViewshedComputedData,n=(e,t)=>{const i=this._interactionVisualElements;null!=i&&(i.verticalLine.attached=t,i.laserline.attached=e)};if(t)return void n(i,!1);if(null==s||null==a)return void n(!1,!1);const o=s.moveInteractionState,l=e?o.grabbing:o.dragging,r=s.scaleOrientInteractionState,d=e?r.grabbing:r.dragging,c=i&&(l||d);if(n(c,l),c){const e=l?a.observerRenderSpace:a.targetRenderSpace;this._updateInteractionVisualsLocation(e,l)}}_updateInteractionVisualsLocation(e,t){const i=this._interactionVisualElements;if(null==i)return;const{laserline:s,verticalLine:a}=i;s.heightManifoldTarget=e,s.intersectsWorldUpAtLocation=t?e:null,null!=e&&a.setStartEndFromWorldDownAtLocation(e)}_findSubTool(e){if(null==e)return null;const t=e instanceof D?t=>t.subTool.hasManipulator(e):t=>t.subTool.viewshed===e;return this.subToolHandles?.find(t)?.subTool}get test(){}};function x(e,t,i){const s=t.observerRenderSpace,n=m(U,i,s),o=g(n)*t.metersPerUnit,l=e.renderCoordsHelper.basisMatrixAtPosition(s,F),r=v(A,l[8],l[9],l[10]),d=b(s,r,G),c=S(d,i,z),h=m(c,c,s),u=(g(h)<1e-4?90:a(w(n,h)))*(_(r,n)<0?-1:1)+90,p=v(K,l[4],l[5],l[6]),V=a(w(p,h)),f=v(K,l[0],l[1],l[2]);return{heading:_(h,f)<0?360-V:V,tilt:u,farDistance:o}}e([h({constructOnly:!0})],W.prototype,"view",void 0),e([h()],W.prototype,"analysisViewData",void 0),e([h()],W.prototype,"removeIncompleteOnCancel",void 0),e([h()],W.prototype,"automaticManipulatorSelection",void 0),e([h({constructOnly:!0})],W.prototype,"analysis",void 0),e([h()],W.prototype,"subToolHandles",void 0),e([h()],W.prototype,"_stagedViewshed",void 0),e([h()],W.prototype,"_stagedViewshedComputedData",void 0),e([h()],W.prototype,"_placementMode",void 0),e([h()],W.prototype,"_creationState",void 0),e([h()],W.prototype,"_valid",null),e([h({readOnly:!0})],W.prototype,"cursor",null),e([h()],W.prototype,"_selectedManipulator",void 0),e([h()],W.prototype,"_selectedSubTool",null),e([h()],W.prototype,"selectedViewshed",null),e([h()],W.prototype,"selectedViewshedComputedData",null),e([h()],W.prototype,"stagedViewshed",null),e([h()],W.prototype,"grabbing",null),e([h()],W.prototype,"creating",null),e([h()],W.prototype,"isPlacingTarget",null),W=e([u("esri.views.3d.analysis.Viewshed.ViewshedTool")],W);const U=V(),A=V(),z=V(),K=V(),F=p(),G=y(),B={mapPoint:new f,scenePoint:V(),feature:null},q="multiple";export{W as default};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../analysis/Viewshed.js";import{makeHandle as i}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{mapCollection as s}from"../../../../core/mapCollectionUtils.js";import{rad2deg as a}from"../../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../../core/maybe.js";import{when as o,watch as l,syncAndInitial as r,sync as d,initial as c}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as m,H as g,i as v,p as w,e as _}from"../../../../chunks/vec32.js";import{create as V}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../../geometry/Point.js";import{fromPositionAndNormal as b,create as y,projectPoint as S}from"../../../../geometry/support/plane.js";import{creationVerticalOffset as T}from"./ViewshedConfiguration.js";import{ViewshedSubTool as C}from"./ViewshedSubTool.js";import{Manipulator3D as D}from"../../interactive/Manipulator3D.js";import{Settings as M}from"../../interactive/editingTools/settings.js";import{ExtendedLineVisualElement as j}from"../../interactive/visualElements/ExtendedLineVisualElement.js";import{LaserlineVisualElement as H}from"../../interactive/visualElements/LaserlineVisualElement.js";import{toGraphic as I}from"../../webgl-engine/lib/intersectorUtilsConversions.js";import{RenderOccludedFlag as P}from"../../webgl-engine/lib/Material.js";import{AnalysisToolBase as E}from"../../../interactive/AnalysisToolBase.js";import{sketchKeys as L}from"../../../interactive/keybindings.js";import{newToolIntersector as k}from"../../../interactive/ToolIntersector.js";import{createScreenPointArrayFromEvent as O}from"../../../support/screenUtils.js";const R=Symbol("interactionVisuals");let W=class extends E{constructor(e){super(e),this.removeIncompleteOnCancel=!1,this.automaticManipulatorSelection=!1,this._stagedViewshed=null,this._stagedViewshedComputedData=null,this._placementMode=q,this._creationState=!1,this._interactionVisualElements=null,this._settings=new M({getTheme:()=>this.view.effectiveTheme}),this._selectedManipulator=null}initialize(){this._intersector=k(this.view.state.viewingMode),this._createInteractionVisuals();const e=this.analysisViewData.viewshedComputedDataHandles;this.subToolHandles=s((()=>e),(({viewshedComputedData:e})=>{const t=new C({analysis:this.analysis,analysisViewData:this.analysisViewData,parentTool:this,view:this.view,viewshedComputedData:e});return{subTool:t,remove:()=>{this.selectedViewshed===e.viewshed&&(this.selectedViewshed=null),t.destroy()}}})),this.addHandles([o((()=>this._valid),(()=>this.finishToolCreation()),r),l((()=>this._stagedViewshed),(e=>{const t=this.analysisViewData.viewshedComputedDataHandles;this._stagedViewshedComputedData=null!=e&&null!=t?this._findSubTool(e)?.viewshedComputedData:null}),r),this.analysis.viewsheds.on("after-remove",(e=>{const t=this._stagedViewshed;null!=t&&e.item===t&&this.analysis.viewsheds.add(t)})),l((()=>this.firstGrabbedManipulator),(e=>{if(null!=e){const t=this._findSubTool(e)?.viewshed;this.selectedViewshed=t,this._selectManipulator(e)}else this._selectedSubTool?.onManipulatorSelectionChanged()}),d),l((()=>this.view.activeTool),(e=>{e!==this&&null!=e&&(this.selectedViewshed=null)})),o((()=>{const e=this.selectedViewshedComputedData;return null==e?null:{subTool:this._selectedSubTool,observer:e.observerRenderSpace,target:e.targetRenderSpace}}),(e=>{const{subTool:t,observer:i,target:s}=e;t?.moveInteractionState.dragging?this._updateInteractionVisualsLocation(i,!0):t?.scaleOrientInteractionState.dragging&&this._updateInteractionVisualsLocation(s,!1)}),c),l((()=>this.creating),(()=>this.updateInteractionVisualsVisibility())),l((()=>this.selectedViewshed),(e=>{const t=this._selectedManipulator,i=this._selectedSubTool;null==e?this._selectManipulator(null):null!=t&&i.hasManipulator(t)||this._selectManipulator(i.discManipulator)}),c)])}destroy(){this.subToolHandles=n(this.subToolHandles),this.removeHandles(R)}onDeactivate(){this.removeStaged(),this._creationState=!1}get _valid(){return this.analysisViewData.viewshedComputedDataHandles?.some((e=>e.viewshedComputedData.valid))??!1}get cursor(){return this.creating?"crosshair":null}get _selectedSubTool(){return this._findSubTool(this.selectedViewshed)}_selectManipulator(e){const t=this._selectedManipulator;t!==e&&(this._selectedManipulator=e,null!=t&&(t.selected=!1),null!=e&&(e.selected=!0),this._findSubTool(t)?.onManipulatorSelectionChanged(),this._selectedSubTool?.onManipulatorSelectionChanged())}get selectedViewshed(){return this.analysisViewData.selectedViewshed}set selectedViewshed(e){this.analysisViewData.selectedViewshed=e}get selectedViewshedComputedData(){return this._selectedSubTool?.viewshedComputedData}get stagedViewshed(){return this._stagedViewshed}get grabbing(){return this.subToolHandles.some((({subTool:e})=>e.grabbing))}get creating(){return this._creationState&&this.active}get isPlacingTarget(){return"placing-target"===this._creationState}place(e){this.selectedViewshed=null,this._placementMode=e,this._creationState="placing-observer",this._finishToolCreationIfValid()}onManipulatorSelectionChanged(){this.subToolHandles.forEach((e=>e.subTool.onManipulatorSelectionChanged()))}onInputEvent(e){switch(e.type){case"immediate-double-click":this._doubleClickHandler(e);break;case"pointer-move":this._pointerMoveHandler(e);break;case"key-down":L.cancel===e.key?this._cancelKeyHandler(e):L.delete.includes(e.key)&&this._deleteKeyHandler();break;case"hold":this.updateInteractionVisualsVisibility(!0)}}onInputEventAfter(e){if("immediate-click"===e.type)this._clickPlacementHandler(e)}onActivate(){this._placementMode=q}_clickPlacementHandler(e){if(!this.creating||this.hasFocusedManipulators)return;const i=this._intersectScreen(e,B);if(null!=i){if("placing-observer"===this._creationState){i.mapPoint.z=(i.mapPoint.z??0)+T;const e=new t({observer:i.mapPoint.clone(),feature:i.feature});this.analysis.viewsheds.add(e),this._stagedViewshed=e,this._creationState="placing-target",this._updateStagedViewshed(i.scenePoint)}else if("placing-target"===this._creationState){this._updateStagedViewshed(i.scenePoint);const e=this._stagedViewshed;this._stagedViewshed=null,"multiple"===this._placementMode?this._creationState="placing-observer":(this._creationState=!1,this._stagedViewshed=null,this._finishToolCreationIfValid(),this.view.activeTool=null),this.selectedViewshed=e}e.stopPropagation()}}_doubleClickHandler(e){this.creating&&(this.removeStaged(),this._creationState=!1,this.view.activeTool=null,e.stopPropagation())}_pointerMoveHandler(e){if(!this.creating)return;const t=this._intersectScreen(e,B);null!=t&&(this._updateInteractionVisualsLocation(t.scenePoint,!1),this._updateStagedViewshed(t.scenePoint))}_cancelKeyHandler(e){this.creating?this._onCancelWhileCreating(e):this.grabbing||(this.selectedViewshed=null,e.stopPropagation())}_onCancelWhileCreating(e){const t=this.removeStaged();this._finishToolCreationIfValid(),t?(this._creationState="placing-observer",this.selectedViewshed=null,"multiple"===this._placementMode&&e.stopPropagation()):this._creationState=!1}_deleteKeyHandler(){this.creating&&(this.removeStaged(),this._creationState="placing-observer"),null!=this.selectedViewshed&&this.analysis.viewsheds.remove(this.selectedViewshed)}_finishToolCreationIfValid(){this._valid&&this.finishToolCreation()}_updateStagedViewshed(e){const t=this._stagedViewshed,i=this._stagedViewshedComputedData;if(null==t||null==i)return;const{heading:s,tilt:a,farDistance:n}=x(this.view,i,e);t.farDistance=n,t.tilt=a,t.heading=s}removeStaged(){const e=this._stagedViewshed;return null!=e&&(this._stagedViewshed=null,this.analysis.viewsheds.remove(e),!0)}_intersectScreen(e,t){const i=O(e);this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(i,this._intersector);const s=this._intersector.results.min,a=t.scenePoint;if(!s.getIntersectionPoint(a))return null;const n=t.mapPoint;return n.spatialReference=this.view.spatialReference,this.view.renderCoordsHelper.fromRenderCoords(a,n),null==n?null:(t.feature=I(s,this.view),t)}_createInteractionVisuals(){this.removeHandles(R);const e=this._settings.visualElements,t=new H({view:this.view,attached:!1,style:{glowWidth:e.heightPlane.glowWidth,innerWidth:e.heightPlane.innerWidth},isDecoration:!0}),s=new j({view:this.view,extensionType:e.zVerticalLine.extensionType,attached:!1,innerWidth:1,writeDepthEnabled:!1,renderOccluded:P.OccludeAndTransparent,isDecoration:!0});this._interactionVisualElements={laserline:t,verticalLine:s},this.addHandles([l((()=>e.zVerticalLine),(e=>e.apply(s)),r),l((()=>e.heightPlane),(e=>e.apply(t)),r),i((()=>{t.destroy(),s.destroy(),this._interactionVisualElements=null}))],R)}updateInteractionVisualsVisibility(e=!1){const t=this.creating,i=this.analysisViewData.visible,s=this._selectedSubTool,a=this.selectedViewshedComputedData,n=(e,t)=>{const i=this._interactionVisualElements;null!=i&&(i.verticalLine.attached=t,i.laserline.attached=e)};if(t)return void n(i,!1);if(null==s||null==a)return void n(!1,!1);const o=s.moveInteractionState,l=e?o.grabbing:o.dragging,r=s.scaleOrientInteractionState,d=e?r.grabbing:r.dragging,c=i&&(l||d);if(n(c,l),c){const e=l?a.observerRenderSpace:a.targetRenderSpace;this._updateInteractionVisualsLocation(e,l)}}_updateInteractionVisualsLocation(e,t){const i=this._interactionVisualElements;if(null==i)return;const{laserline:s,verticalLine:a}=i;s.heightManifoldTarget=e,s.intersectsWorldUpAtLocation=t?e:null,null!=e&&a.setStartEndFromWorldDownAtLocation(e)}_findSubTool(e){if(null==e)return null;const t=e instanceof D?t=>t.subTool.hasManipulator(e):t=>t.subTool.viewshed===e;return this.subToolHandles?.find(t)?.subTool}get test(){}};function x(e,t,i){const s=t.observerRenderSpace,n=m(U,i,s),o=g(n)*t.metersPerUnit,l=e.renderCoordsHelper.basisMatrixAtPosition(s,F),r=v(A,l[8],l[9],l[10]),d=b(s,r,G),c=S(d,i,z),h=m(c,c,s),u=(g(h)<1e-4?90:a(w(n,h)))*(_(r,n)<0?-1:1)+90,p=v(K,l[4],l[5],l[6]),V=a(w(p,h)),f=v(K,l[0],l[1],l[2]);return{heading:_(h,f)<0?360-V:V,tilt:u,farDistance:o}}e([h({constructOnly:!0})],W.prototype,"view",void 0),e([h()],W.prototype,"analysisViewData",void 0),e([h()],W.prototype,"removeIncompleteOnCancel",void 0),e([h()],W.prototype,"automaticManipulatorSelection",void 0),e([h({constructOnly:!0})],W.prototype,"analysis",void 0),e([h()],W.prototype,"subToolHandles",void 0),e([h()],W.prototype,"_stagedViewshed",void 0),e([h()],W.prototype,"_stagedViewshedComputedData",void 0),e([h()],W.prototype,"_placementMode",void 0),e([h()],W.prototype,"_creationState",void 0),e([h()],W.prototype,"_valid",null),e([h({readOnly:!0})],W.prototype,"cursor",null),e([h()],W.prototype,"_selectedManipulator",void 0),e([h()],W.prototype,"_selectedSubTool",null),e([h()],W.prototype,"selectedViewshed",null),e([h()],W.prototype,"selectedViewshedComputedData",null),e([h()],W.prototype,"stagedViewshed",null),e([h()],W.prototype,"grabbing",null),e([h()],W.prototype,"creating",null),e([h()],W.prototype,"isPlacingTarget",null),W=e([u("esri.views.3d.analysis.Viewshed.ViewshedTool")],W);const U=V(),A=V(),z=V(),K=V(),F=p(),G=y(),B={mapPoint:new f,scenePoint:V(),feature:null},q="multiple";export{W as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{getFeatureId as t,updatePointsFromFeatureReference as s}from"../../../analysis/featureReferenceUtils.js";import i from"../../../core/Accessor.js";import"../../../core/has.js";import r from"../../../core/Logger.js";import{mapCollection as o}from"../../../core/mapCollectionUtils.js";import{abortMaybe as a,destroyMaybe as n}from"../../../core/maybe.js";import{watch as d,initial as l,when as h,syncAndInitial as c}from"../../../core/reactiveUtils.js";import{property as p}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{c as u,q as w}from"../../../chunks/vec32.js";import{create as v}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectWithoutEngine as f,isLoaded as V,projectOrLoad as y}from"../../../geometry/projectionUtils.js";import{projectBoundingRect as _}from"../../../geometry/projection/projectBoundingRect.js";import{containsPoint as g,empty as j}from"../../../geometry/support/aaBoundingRect.js";import{AnalysisView3D as R}from"./AnalysisView3D.js";import{logFailedGeometryProjectionError as b}from"./support/projectionUtils.js";import{ViewshedAnalysisVisualization as D}from"./Viewshed/ViewshedAnalysisVisualization.js";import{ViewshedComputedData as C}from"./Viewshed/ViewshedComputedData.js";import F from"./Viewshed/ViewshedTool.js";import{Intersector as H}from"../webgl-engine/lib/Intersector.js";import{StoreResults as O}from"../webgl-engine/lib/IntersectorInterfaces.js";import{Viewshed as U}from"../webgl-engine/lib/Viewshed.js";import{connectAnalysisViewToTool as A,removeAnalysisViewTool as S,startPlaceOperation as z}from"../../analysis/analysisViewUtils.js";let I=class extends(R(i)){constructor(e){super(e),this.type="viewshed-view-3d",this.analysis=null,this.tool=null,this._selectedViewshed=null,this.viewshedComputedDataHandles=null,this.userOperation=null,this._viewshedRenderer=null,this._intersector=null}get selectedViewshed(){return this._selectedViewshed}set selectedViewshed(e){this._unselectOtherViewsheds(e),this._selectedViewshed=e}get selectedViewshedComputedData(){return this.tool?.selectedViewshedComputedData}get _isDecoration(){return!this.parent}initialize(){const e=this.view;this._viewshedRenderer=new U({view:e,selectedViewshed:()=>this.selectedViewshed??this.tool?.stagedViewshed,isDecoration:this._isDecoration}),this._intersector=new H(this.view.state.viewingMode),this._intersector.options.hud=!1,this._intersector.options.store=O.MIN,this.viewshedComputedDataHandles=o((()=>this.analysis.viewsheds),(t=>{const s=new C({renderCoordsHelper:e.renderCoordsHelper,viewshed:t}),i=Symbol();return this.addHandles([d((()=>({valid:s.valid,canProject:f(s.observer?.spatialReference,this.view.spatialReference)||V()})),(({valid:e,canProject:t},i)=>{this.visible&&(e&&t?this._addViewshedsToRenderer(s):i?.valid&&i?.canProject&&this._removeViewshedsFromRenderer(s),t||b(this.analysis,s.observer.spatialReference,r.getLogger(this)))}),l),...this._createFeatureReferenceHandles(s)],i),{viewshedComputedData:s,remove:()=>{this.removeHandles(i),this._removeViewshedsFromRenderer(s),s.destroy()}}})),this._analysisVisualization=new D({view:e,analysisViewData:this,isDecoration:this._isDecoration}),this.addHandles([d((()=>this.visible),(e=>{const t=this.viewshedComputedDataHandles;if(null==t)return;e||(this.selectedViewshed=null);const s=t.map((e=>e.viewshedComputedData)).filter((e=>e.valid)).toArray();e?this._addViewshedsToRenderer(s):this._removeViewshedsFromRenderer(s)})),d((()=>e.renderCoordsHelper),(e=>{this.viewshedComputedDataHandles?.forEach((({viewshedComputedData:t})=>t.renderCoordsHelper=e))})),A(this,F),h((()=>this.interactive),(()=>{this._unselectOtherViewsheds(this.selectedViewshed)}),c)])}destroy(){this.userOperation=a(this.userOperation),S(this),this._analysisVisualization=n(this._analysisVisualization);const e=this.viewshedComputedDataHandles;null!=e&&this._removeViewshedsFromRenderer(e.map((e=>e.viewshedComputedData)).toArray())}_createFeatureReferenceHandles(e){const{view:t}=this;return[d((()=>[t.state.camera,t.slice.plane,e.viewshed.observer,e.targetRenderSpace,e.verticalFieldOfView,e.horizontalFieldOfView,e.feature]),(()=>{this._updateObserverFromFeature(t,e)}),l),this._createElevationUpdateHandle(e),h((()=>e.needUpdateByFeature),(()=>{this._updateObserverFromFeature(t,e),e.needUpdateByFeature=!1}))]}_createElevationUpdateHandle(e){const t=(s,i)=>{const{view:r}=this,{observer:o}=e;if(null==o)return;const a=y(o,r.spatialReference);if(null!=a.pending)return void a.pending.finally((()=>t(s,i)));const n=a.geometry;null!=n&&(_(s,i,x,r.spatialReference),g(x,[n.x,n.y])&&(e.needUpdateByFeature=!0))};return this.view.elevationProvider.on("elevation-change",(({extent:e,spatialReference:s})=>t(e,s)))}async createViewsheds(e){
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{getFeatureId as t,updatePointsFromFeatureReference as s}from"../../../analysis/featureReferenceUtils.js";import i from"../../../core/Accessor.js";import"../../../core/has.js";import r from"../../../core/Logger.js";import{mapCollection as o}from"../../../core/mapCollectionUtils.js";import{abortMaybe as a,destroyMaybe as n}from"../../../core/maybe.js";import{watch as d,initial as l,when as h,syncAndInitial as c}from"../../../core/reactiveUtils.js";import{property as p}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{c as u,q as w}from"../../../chunks/vec32.js";import{create as v}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectWithoutEngine as f,isLoaded as V,projectOrLoad as y}from"../../../geometry/projectionUtils.js";import{projectBoundingRect as _}from"../../../geometry/projection/projectBoundingRect.js";import{containsPoint as g,empty as j}from"../../../geometry/support/aaBoundingRect.js";import{AnalysisView3D as R}from"./AnalysisView3D.js";import{logFailedGeometryProjectionError as b}from"./support/projectionUtils.js";import{ViewshedAnalysisVisualization as D}from"./Viewshed/ViewshedAnalysisVisualization.js";import{ViewshedComputedData as C}from"./Viewshed/ViewshedComputedData.js";import F from"./Viewshed/ViewshedTool.js";import{Intersector as H}from"../webgl-engine/lib/Intersector.js";import{StoreResults as O}from"../webgl-engine/lib/IntersectorInterfaces.js";import{Viewshed as U}from"../webgl-engine/lib/Viewshed.js";import{connectAnalysisViewToTool as A,removeAnalysisViewTool as S,startPlaceOperation as z}from"../../analysis/analysisViewUtils.js";let I=class extends(R(i)){constructor(e){super(e),this.type="viewshed-view-3d",this.analysis=null,this.tool=null,this._selectedViewshed=null,this.viewshedComputedDataHandles=null,this.userOperation=null,this._viewshedRenderer=null,this._intersector=null}get selectedViewshed(){return this._selectedViewshed}set selectedViewshed(e){this._unselectOtherViewsheds(e),this._selectedViewshed=e}get selectedViewshedComputedData(){return this.tool?.selectedViewshedComputedData}get _isDecoration(){return!this.parent}initialize(){const e=this.view;this._viewshedRenderer=new U({view:e,selectedViewshed:()=>this.selectedViewshed??this.tool?.stagedViewshed,isDecoration:this._isDecoration}),this._intersector=new H(this.view.state.viewingMode),this._intersector.options.hud=!1,this._intersector.options.store=O.MIN,this.viewshedComputedDataHandles=o((()=>this.analysis.viewsheds),(t=>{const s=new C({renderCoordsHelper:e.renderCoordsHelper,viewshed:t}),i=Symbol();return this.addHandles([d((()=>({valid:s.valid,canProject:f(s.observer?.spatialReference,this.view.spatialReference)||V()})),(({valid:e,canProject:t},i)=>{this.visible&&(e&&t?this._addViewshedsToRenderer(s):i?.valid&&i?.canProject&&this._removeViewshedsFromRenderer(s),t||b(this.analysis,s.observer.spatialReference,r.getLogger(this)))}),l),...this._createFeatureReferenceHandles(s)],i),{viewshedComputedData:s,remove:()=>{this.removeHandles(i),this._removeViewshedsFromRenderer(s),s.destroy()}}})),this._analysisVisualization=new D({view:e,analysisViewData:this,isDecoration:this._isDecoration}),this.addHandles([d((()=>this.visible),(e=>{const t=this.viewshedComputedDataHandles;if(null==t)return;e||(this.selectedViewshed=null);const s=t.map((e=>e.viewshedComputedData)).filter((e=>e.valid)).toArray();e?this._addViewshedsToRenderer(s):this._removeViewshedsFromRenderer(s)})),d((()=>e.renderCoordsHelper),(e=>{this.viewshedComputedDataHandles?.forEach((({viewshedComputedData:t})=>t.renderCoordsHelper=e))})),A(this,F),h((()=>this.interactive),(()=>{this._unselectOtherViewsheds(this.selectedViewshed)}),c)])}destroy(){this.userOperation=a(this.userOperation),S(this),this._analysisVisualization=n(this._analysisVisualization);const e=this.viewshedComputedDataHandles;null!=e&&this._removeViewshedsFromRenderer(e.map((e=>e.viewshedComputedData)).toArray())}_createFeatureReferenceHandles(e){const{view:t}=this;return[d((()=>[t.state.camera,t.slice.plane,e.viewshed.observer,e.targetRenderSpace,e.verticalFieldOfView,e.horizontalFieldOfView,e.feature]),(()=>{this._updateObserverFromFeature(t,e)}),l),this._createElevationUpdateHandle(e),h((()=>e.needUpdateByFeature),(()=>{this._updateObserverFromFeature(t,e),e.needUpdateByFeature=!1}))]}_createElevationUpdateHandle(e){const t=(s,i)=>{const{view:r}=this,{observer:o}=e;if(null==o)return;const a=y(o,r.spatialReference);if(null!=a.pending)return void a.pending.finally((()=>t(s,i)));const n=a.geometry;null!=n&&(_(s,i,x,r.spatialReference),g(x,[n.x,n.y])&&(e.needUpdateByFeature=!0))};return this.view.elevationProvider.on("elevation-change",(({extent:e,spatialReference:s})=>t(e,s)))}async createViewsheds(e){await z(this,{placementOptions:e,onToolActivated:e=>e.place("multiple")})}place(e){return z(this,{placementOptions:e,onToolActivated:e=>e.place("single")})}_addViewshedsToRenderer(e){this._viewshedRenderer.updateViewsheds({adds:e})}_removeViewshedsFromRenderer(e){this._viewshedRenderer.updateViewsheds({removes:e})}_updateObserverFromFeature(e,i){const r=i.observerRenderSpace,o=i.targetRenderSpace,a=u(v(),r),n={observer:r,observerSurfaceNormal:null,observerAdjusted:a,observerFeatureId:t(i.feature),target:o,targetSurfaceNormal:null,targetAdjusted:u(v(),o),targetFeatureId:null};s(e,this._intersector,n,(e=>Math.min(e,.05*i.farDistanceRenderSpace))),i.observerRenderSpaceOverride=w(a,r)?null:a}_unselectOtherViewsheds(e){if(null!=e)for(const t of this.view.tools.items)t!==this.tool&&t instanceof F&&(t.analysisViewData.selectedViewshed=null)}get test(){}};e([p({readOnly:!0})],I.prototype,"type",void 0),e([p({constructOnly:!0,nonNullable:!0})],I.prototype,"analysis",void 0),e([p()],I.prototype,"tool",void 0),e([p()],I.prototype,"_selectedViewshed",void 0),e([p()],I.prototype,"selectedViewshed",null),e([p()],I.prototype,"selectedViewshedComputedData",null),e([p()],I.prototype,"viewshedComputedDataHandles",void 0),e([p()],I.prototype,"userOperation",void 0),e([p()],I.prototype,"_analysisVisualization",void 0),e([p()],I.prototype,"_viewshedRenderer",void 0),I=e([m("esri.views.3d.analysis.ViewshedAnalysisView3D")],I);const T=I,x=j();export{T as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{neverReached as e}from"../../../../core/compilerUtils.js";import{acosClamped as t,clamp as r,asinClamped as n,deg2rad as i}from"../../../../core/mathUtils.js";import{fromRotation as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d as o,t as c,g as u,f as l,k as m,j as d,e as f,n as p,l as M}from"../../../../chunks/vec32.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as y}from"../../../../geometry/ellipsoidUtils.js";import{
|
|
5
|
+
import{neverReached as e}from"../../../../core/compilerUtils.js";import{acosClamped as t,clamp as r,asinClamped as n,deg2rad as i}from"../../../../core/mathUtils.js";import{fromRotation as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d as o,t as c,g as u,f as l,k as m,j as d,e as f,n as p,l as M}from"../../../../chunks/vec32.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as y}from"../../../../geometry/ellipsoidUtils.js";import{e as C,b as T,t as I}from"../../../../chunks/sphere.js";import{defaultConstraintOptions as O,hasConstraintType as A,adjustRangeForInteraction as x}from"./common.js";import{ConstraintTypes as S}from"./ConstraintTypes.js";import{InteractionType as v}from"./InteractionType.js";import{TiltMode as R}from"./TiltMode.js";import{viewAngle as j}from"../../state/utils/viewUtils.js";function w(t,r,n,i=!0){W.eyeCenterDistance=0,W.requiresTwoSteps=!1;const s=U(t,r,n,O,W);if(0===s)return!1;switch(a(_,-s,r.viewRight),n.tiltMode){case R.LOOK_AROUND:c(K,r.viewForward,_),u(K,K,W.eyeCenterDistance),r.center=l(z,r.eye,K);break;case R.TUMBLE:o(K,r.center,r.eye),c(K,K,_),r.eye=o(z,r.center,K);break;default:e(n.tiltMode)}return r.up=c(z,r.up,_),!W.requiresTwoSteps||!i||w(t,r,n,!1)}function U(e,t,r,n=O,i){if(!e.state.constraints.tilt)return 0;const a=Math.min(t.relativeElevation*J,t.distance),s=e.state.constraints.tilt(a,Q);return N(e,r,s),n.interactionType===v.TUMBLE&&A(n.selection,S.ALTITUDE)&&B(e,n.interactionStartCamera,s),r.tiltMode===R.LOOK_AROUND||n.tiltMode===R.LOOK_AROUND?P(e,t,s,i):D(e,t,s)}function D(e,t,n){const i=j(e.renderCoordsHelper,t.center,t.eye),a=i-r(i,n.min,n.max);return g(a)?a:0}function P(e,t,r,n){switch(n&&(n.requiresTwoSteps=!1),e.viewingMode){case"global":return E(e,t,r,n);case"local":return b(e,t,r,n)}}function b(e,t,n,i){const a=j(e.renderCoordsHelper,t.center,t.eye),s=r(a,n.min,n.max),o=a-s;if(!g(o))return 0;if(i){const r=Math.abs(e.pointsOfInterest.centerOnSurfaceFrequent.estimatedSurfaceAltitude),n=e.renderCoordsHelper.getAltitude(t.eye)-r,a=Math.max(Math.cos(s),1e-4);Math.abs(a)>1e-4?i.eyeCenterDistance=n/a:i.eyeCenterDistance=t.distance}return o}function E(e,t,n,i){const a=L(e,t,V),s=r(a.tiltAtCenter,n.min,n.max);if(!g(a.tiltAtCenter-s))return 0;let o,c;return a.centerIsOnSurface?(o=q(a),c=k(a,o)):(o=a.constraints.clampTilt(a.distance,a.tiltAtCenter),i&&o<Math.PI/2&&(i.requiresTwoSteps=!0,o=Math.PI/2-1e-5),c=F(a,o)),i&&(i.eyeCenterDistance=H(a,o)),c}function L(e,r,n){const i=e.pointsOfInterest.centerOnSurfaceFrequent.estimatedSurfaceAltitude,a=i+y(e.spatialReference).radius,s=e.renderCoordsHelper.intersectManifold(r.ray,i,z);return n.distance=Math.min(r.relativeElevation*J,r.distance),n.centerIsOnSurface=!1,null!=s?(n.distance=Math.min(r.relativeElevation*J,d(r.eye,s)),n.tiltAtCenter=j(e.renderCoordsHelper,s,r.eye),n.centerIsOnSurface=!0):e.state.isLocal?n.tiltAtCenter=j(e.renderCoordsHelper,r.center,r.eye):(C(T(I,a),r.ray,z),n.distance=Math.min(r.relativeElevation*J,d(r.eye,z)),n.tiltAtCenter=t(-f(r.viewForward,p(z,z)))),n.radius=a,n.eyeRadius=M(r.eye),n.constraints=e.state.constraints,n}function g(e){return Math.abs(e)>1e-9}function q(e){const{constraints:t,distance:r,tiltAtCenter:n}=e;let i=n,a=t.clampTilt(r,n);const s=H(e,a);if(t.clampTilt(s,n)===a)return a;let o=0;for(;o<10&&g(a-i);){const r=(i+a)/2,n=H(e,r);g(t.clampTilt(n,r)-r)?i=r:a=r,o++}return a}function H(e,t){if(!e.centerIsOnSurface)return e.distance;const i=Math.PI-r(t,0,Math.PI),a=n(e.radius/e.eyeRadius*Math.sin(i)),s=Math.PI-i-a,o=Math.sin(s)/Math.sin(i);if(e.eyeRadius<e.radius&&o>1){const t=Math.PI-a,r=Math.PI-i-t;return Math.sin(r)/Math.sin(i)*e.eyeRadius}return o*e.eyeRadius}function k(e,t){const r=n(e.radius/e.eyeRadius*Math.sin(e.tiltAtCenter)),i=n(e.radius/e.eyeRadius*Math.sin(t));return e.eyeRadius>e.radius?r-i:i-r}function F(e,t){return e.tiltAtCenter-Math.PI/2-(t-Math.PI/2)}function N(e,t,r){if(t.interactionType===v.NONE)return;const{interactionStartCamera:n,interactionFactor:i}=t;if(!n)return;const{min:a,max:s}=r,o=U(e,n,O,t),c=0===o?0:j(e.renderCoordsHelper,n.center,n.eye);r.min=a,r.max=s,t.interactionType===v.TUMBLE?(A(t.selection,S.ALTITUDE)&&B(e,n,r),x(o,c,!0,i,G,r)):x(o,c,!1,i,G,r)}function B(e,r,n){const i=e.state.constraints;if(e.state.isLocal||!i.altitude||!r)return;const a=m(r.center),s=Math.sqrt(a),o=r.distance,c=y(e.spatialReference).radius,u=i.altitude.min+c,l=i.altitude.max+c,d=(u*u-o*o-a)/(-2*s*o),f=(l*l-o*o-a)/(-2*s*o);n.min=Math.max(n.min,Math.min(Math.PI-t(f),n.max)),n.max=Math.min(n.max,Math.PI-t(d))}const K=h(),_=s(),z=h(),G=i(5),J=30,Q={min:0,max:0},V={constraints:null,radius:0,eyeRadius:0,centerIsOnSurface:!0,distance:0,tiltAtCenter:0},W={eyeCenterDistance:0,requiresTwoSteps:!1};export{w as applyTiltConstraint,U as getTiltConstraintError};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{c as e,s as r,g as t,d as n,f as i,e as o,l as s}from"../../../chunks/vec32.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{containsPoint as l}from"../../../geometry/support/aaBoundingRect.js";import d from"../webgl/RenderCamera.js";import{DepthRange as g}from"../webgl-engine/lib/DepthRange.js";import{Intersector as f}from"../webgl-engine/lib/Intersector.js";function u(e,r,t,n){return null!=e.renderCoordsHelper.fromRenderCoords(r.eye,
|
|
5
|
+
import{c as e,s as r,g as t,d as n,f as i,e as o,l as s}from"../../../chunks/vec32.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{containsPoint as l}from"../../../geometry/support/aaBoundingRect.js";import d from"../webgl/RenderCamera.js";import{DepthRange as g}from"../webgl-engine/lib/DepthRange.js";import{Intersector as f}from"../webgl-engine/lib/Intersector.js";function u(e,r,t,n){return null!=e.renderCoordsHelper.fromRenderCoords(r.eye,j,n)&&l(t,j)}function m(e,r){return e.elevationProvider?e.elevationProvider.getElevation(r[0],r[1],r[2],e.renderCoordsHelper.spatialReference,"ground")??0:0}function p(o,s,a,c){const l=o.state.camera.clone();s&&a&&c&&(l.eye=s,l.center=a,l.up=c),v(o,l.ray,R)||e(R,l.center);const d=o.state.constraints,g=d.minimumPoiDistance;if(r(l.eye,R)<g){const r=d.collision.enabled;e(C,l.viewForward),t(C,C,g),r?l.eye=n(j,R,C):i(R,l.eye,C);const s=o.renderCoordsHelper,a=s.getAltitude(l.eye),c=d.collision.elevationMargin;r&&a<c&&(n(C,R,l.eye),l.eye=s.setAltitude(j,c,l.eye),i(R,l.eye,C))}return l.center=R,l}function y(e,t,n){if(!e.state.isGlobal||!e.stateManager.constraintsManager)return!1;const i=m(e,t),o=e.stateManager.constraintsManager.nearFarHeuristic;let s=H.get(e);void 0===s&&(s=new d,H.set(e,s)),s.eye=t,s.center=n;const{far:a}=o.compute(s,e.renderDataExtent,g.infinite,i),c=a*a;return r(t,n)>c}function v(e,r,t){let n=w[e.viewingMode];n||(n=new f(e.state.viewingMode),n.options.backfacesTerrain=!e.state.isGlobal,n.options.invisibleTerrain=!0,w[e.viewingMode]=n);const{isGlobal:i}=e.state;return!(!e.sceneIntersectionHelper.intersectRay(r,n,t)||y(e,r.origin,t))||(!(!e.renderCoordsHelper.intersectManifold(r,0,t)||y(e,r.origin,t))||!!i&&b(r,t,c(e.spatialReference).radius))}function b(e,r,n){const a=o(e.origin,e.origin)-n*n,c=a>0?Math.sqrt(a)/3:1;return t(r,e.direction,c/s(e.direction)),i(r,r,e.origin),!0}let w={};function M(){w={}}const j=a(),R=a(),C=a(),H=new WeakMap;export{p as cameraOnContentAlongViewDirection,M as cleanupIntersectionUtils,u as eyeWithinExtent,m as surfaceElevationBelowRenderLocation};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/Collection.js";import{handlesGroup as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/Collection.js";import s from"../../../core/Error.js";import{handlesGroup as i}from"../../../core/handleUtils.js";import o from"../../../core/Logger.js";import{getOrCreateMapValue as n}from"../../../core/MapUtils.js";import{abortMaybe as l}from"../../../core/maybe.js";import{isAbortError as a,allSettledValues as u,throwIfAborted as p,createResolver as h}from"../../../core/promiseUtils.js";import{watch as c,syncAndInitial as y}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as f}from"../../../core/accessorSupport/decorators/subclass.js";import"../../../layers/buildingSublayers/BuildingGroupSublayer.js";import{isQuery as g,isGraphic as m}from"../../../support/guards.js";import w from"./BuildingComponentSublayerView3D.js";import{BuildingSublayerView3DMixin as b}from"./BuildingSublayerView3D.js";import{LayerView3D as V}from"./LayerView3D.js";import{parseFilterMode as j}from"./i3s/BuildingFilterUtil.js";import{checkSpatialReference as _}from"./i3s/I3SUtil.js";import{emptyHighlightHandle as S,normalizeHighlightTargetExceptQuery as C}from"./support/highlightUtils.js";import{LayerViewPerformanceInfo as v}from"./support/LayerViewPerformanceInfo.js";import{updatingProgress as B}from"../support/updatingProperties.js";import M from"../../layers/BuildingSceneLayerView.js";import{isInEffectiveScaleRange as E}from"../../support/layerViewUtils.js";const F=b(r);let P=class extends(V(M)){constructor(e){super(e),this.type="building-scene-3d",this.sublayerViews=new t,this._rejectedSublayerViews=new Map,this._abortController=new AbortController,this._loadingComponents=0,this._pendingWhenSublayerViews=new Map,this.ignoresMemoryFactor=!1}get filterExpression(){const e=this.layer.activeFilterId,r=null!=e?this.layer.filters.find((r=>r.id===e)):null,t=null!=r?r.filterBlocks?.find((e=>"solid"===e.filterMode.type)):null;return t?t.filterExpression:null}get filterExpressions(){const e=this.layer.activeFilterId,r=null!=e?this.layer.filters.find((r=>r.id===e)):null;return r?.filterBlocks?r.filterBlocks.toArray().map((e=>[e.filterExpression??"",j(e)])):[]}get updatingProgressValue(){const e=this.sublayerViews,r=this._loadingComponents+(e?e.length:0);return e.reduce(((e,r)=>e+r.updatingProgress),0)/r}get visibleAtCurrentScale(){return E(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){return this._loadingComponents>0||this.sublayerViews&&this.sublayerViews.some((e=>e.updating))}initialize(){_(this.layer.spatialReference,this.view.spatialReference,this.view.viewingMode),this._initializeSublayerViews(this.layer.sublayers,this)}destroy(){this.sublayerViews&&(this.sublayerViews.forEach((e=>e.destroy())),this.sublayerViews=null),this._rejectedSublayerViews=null,this._abortController=l(this._abortController)}_initializeSublayerViews(e,r){const t=this,i=this.view;e.forEach((e=>{if(!e.isEmpty)if("building-group"===e.type){const t=new F({sublayer:e,view:i,parent:r});this._initializeSublayerViews(e.sublayers,t)}else"mesh"===e.geometryType?(this._loadingComponents++,e.load({signal:this._abortController.signal}).then((()=>{const s=new w({sublayer:e,layerView:t,view:i,parent:r});this.sublayerViews.push(s);const o=this._pendingWhenSublayerViews.get(e);if(o){for(const e of o)e.resolve(s);this._pendingWhenSublayerViews.delete(e)}this.addHandles([c((()=>s.updating),(()=>this.notifyChange("updating")),y),c((()=>s.updatingProgress),(()=>this.notifyChange("updatingProgressValue")),y)])})).catch((r=>{a(r)||o.getLogger(this).error(`Error while creating view for sublayer ${e.id}\nLayer: ${this.layer.url}\n`,r),this._rejectWhenSublayerView(e,r)})).then((()=>{this._loadingComponents--,this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}))):this._rejectWhenSublayerView(e,new s("view:no-layerview-for-sublayer",`No layerview created for sublayer ${e.id}`))}))}getGraphicFromIntersectorTarget(e,r){for(const t of this.sublayerViews.items)if(t.sublayer.id===e.sublayerId)return t.getGraphicFromIntersectorTarget(e,r);return null}async fetchPopupFeaturesFromGraphics(e,r){if(0===e.length)return[];const t=I(e,(e=>e.sourceLayer)),s=[];for(const[o,n]of t){const e=this._findComponent(o);null!=e&&s.push(e.fetchPopupFeaturesFromGraphics(n,r))}const i=await u(s);return p(r),i.flat()}whenGraphicBounds(e){const r=this._findComponent(e.sourceLayer);return null==r?Promise.reject():r.whenGraphicBounds(e)}getAABBFromIntersectorTarget(e){for(const r of this.sublayerViews.items)if(r.sublayer.id===e.sublayerId)return r.getAABBFromIntersectorTarget(e);return null}async whenSublayerView(e){const r=this._findComponent(e);if(null!=r)return r;const t=this._rejectedSublayerViews.get(e);if(null!=t)throw t;const s=this._pendingWhenSublayerViews.get(e),i=h();return s?s.push(i):this._pendingWhenSublayerViews.set(e,[i]),i.promise}_rejectWhenSublayerView(e,r){this._rejectedSublayerViews.set(e,r);const t=this._pendingWhenSublayerViews.get(e);if(t){for(const e of t)e.reject(r);this._pendingWhenSublayerViews.delete(e)}}_findComponent(e){return this.sublayerViews.find((r=>e===r.sublayer))}highlight(e,r){if(g(e))return S;const t=C(e);if(0===t.length)return S;if(m(t[0])){const e=t,s=new Map;for(const r of e)n(s,r.sourceLayer,(()=>[])).push(r);const o=[];return this.sublayerViews.forEach((e=>{const t=s.get(e.sublayer);t&&o.push(e.highlight(t,r))})),i(o)}return S}get usedMemory(){return this.sublayerViews.reduce(((e,r)=>e+r.usedMemory),0)}get unloadedMemory(){return this.sublayerViews.reduce(((e,r)=>e+r.unloadedMemory),0)}get performanceInfo(){return new v(this.usedMemory)}};function I(e,r){const t=new Map,s=e.length;for(let i=0;i<s;i++){const s=e[i],o=r(s,i,e),n=t.get(o);n?n.push(s):t.set(o,[s])}return t}e([d()],P.prototype,"sublayerViews",void 0),e([d()],P.prototype,"_rejectedSublayerViews",void 0),e([d({readOnly:!0})],P.prototype,"filterExpression",null),e([d({readOnly:!0})],P.prototype,"filterExpressions",null),e([d(B)],P.prototype,"updatingProgress",void 0),e([d({readOnly:!0,dependsOn:[]})],P.prototype,"updatingProgressValue",null),e([d({readOnly:!0})],P.prototype,"visibleAtCurrentScale",null),P=e([f("esri.views.3d.layers.BuildingSceneLayerView3D")],P);const L=P;export{L as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s,isSome as r}from"../../../core/arrayUtils.js";import{ByteSizeUnit as o}from"../../../core/ByteSizeUnit.js";import has from"../../../core/has.js";import a from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as l}from"../../../core/maybe.js";import d from"../../../core/PooledArray.js";import{ignoreAbortErrors as h,isAbortError as c,throwIfAborted as u,createResolver as _}from"../../../core/promiseUtils.js";import{initial as m,watch as g}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{equals as p}from"../../../core/SetUtils.js";import{isArrayBuffer as b}from"../../../core/typedArrayUtil.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as v,invert as C}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as M}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as w,getTranslation as x}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as E,create as R}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as O}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as j,t as S,o as A,a as T,f as D,g as F,d as V,H as N}from"../../../chunks/vec32.js";import{create as P}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as H}from"../../../chunks/vec42.js";import{fromValues as U}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as k}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as L}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as G}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as B}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as q}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as W}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as K,create as $,toRect as Q}from"../../../geometry/support/aaBoundingBox.js";import{create as X,intersects as Y}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as J}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{a as te,f as ie,g as se}from"../../../chunks/sphere.js";import{newUByteArray as re}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as oe}from"../../../layers/LayerConstants.js";import ae from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as ne}from"../../../layers/support/fieldUtils.js";import le from"../../../layers/support/SceneModification.js";import{getColor as de,getOpacity as he}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as ce}from"../../../support/basemapUtils.js";import{getElevationOffset as ue}from"../../../support/elevationInfoUtils.js";import{isQuery as _e}from"../../../support/guards.js";import{loadArcade as me}from"../../../support/loadArcade.js";import ge from"../../../symbols/MeshSymbol3D.js";import fe from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as pe}from"./ContentGeometryLayerView.js";import be from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as ye}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as Ie,toWasmModification as ve}from"./I3SMeshWorkerHandle.js";import{ElevationMode as Ce,ForAllFeaturesReturnType as Me,ForAllFeaturesMode as we}from"./II3SMeshView3D.js";import{initialize as xe,setModificationsSync as Ee,filterObbsForModificationsSync as Re,interpretObbModificationResults as Oe}from"./SceneLayerWorker.js";import{overrideColor as je}from"./graphics/graphicUtils.js";import{areLabelsVisible as Se}from"./graphics/Labeler.js";import{TextureUsage as Ae,TextureEncoding as Te}from"./i3s/enums.js";import De from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Fe}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Ve}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Ne,NodeCrossfadeMetaData as Pe}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as He}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ue}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as ke,selectEncoding as Le,defaultMaterial as Ge,createTexture as Be,configureMaterial as qe}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as We,NodeState as ze}from"./i3s/I3SNode.js";import{I3SOverrides as Ke}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as $e}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Qe,checkSceneLayerValid as Xe,checkSceneLayerCompatibleWithView as Ye,whenGraphicAttributes as Je,computeVisibilityObb as Ze,filterInPlace as et,intersectBoundingRectWithMbs as tt,MbsIntersectResult as it,addWraparound as st,getSymbolInfo as rt,transparentEdgeMaterial as ot,getClipRect as at}from"./i3s/I3SUtil.js";import{IDBCache as nt}from"./i3s/IDBCache.js";import{IDBMockCache as lt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as dt}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as ht}from"./i3s/SymbologyInfo.js";import{attributeLookup as ct}from"./support/attributeUtils.js";import{emptyHighlightHandle as ut,normalizeHighlightTargetExceptQuery as _t}from"./support/highlightUtils.js";import{makeScheduleFunction as mt}from"./support/makeScheduleFunction.js";import{ColorMixModeEnum as gt}from"./support/symbolColorUtils.js";import{debugFlags as ft}from"../support/debugFlags.js";import{ElevationRange as pt}from"../support/ElevationRange.js";import{toBoundingRect as bt}from"../support/extentUtils.js";import{Obb as yt}from"../support/orientedBoundingBox.js";import{updatingProgress as It}from"../support/updatingProperties.js";import{glLayout as vt}from"../support/buffer/glUtil.js";import{ObjectParameters as Ct}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as Mt,GeometryParameters as wt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as xt}from"../webgl-engine/collections/Component/Transform.js";import{TextureCoordinateType as Et}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasisTranscoder as Rt}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as Ot}from"../webgl-engine/lib/edgeRendering/interfaces.js";import{defaultHighlightName as jt}from"../../support/HighlightDefaults.js";import{TextureCompressionTracker as St}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as At}from"../../../webscene/support/AlphaCutoff.js";const Tt=[1,1,1,1];class Dt extends Pe{constructor(e,t,i,s,r,o,a,n,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=a,this.anchorIds=n,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}get cachedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}var Ft;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(Ft||(Ft={}));const Vt=26,Nt=100*o.MEGABYTES,Pt=t=>{let o=class extends t{constructor(){super(...arguments),this._applySSAO=!0,this._shadeNormals=!0,this._updatingHandles=new k,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new St,this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new Ne(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerViewUid(){return this.uid}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get _isIntegratedMesh(){return"integrated-mesh"===this.i3slayer.type}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>At}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Qe(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Ae.AllTexturesPBR:Ae.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Ae.GeometryTexturesPBR:Ae.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?ue(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new Jt(Ce.Absolute,0);const t=ue(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new Jt(Ce.Absolute,t);case"relative-to-ground":return new Jt(Ce.RelativeToGround,t);case"on-the-ground":return new Jt(Ce.OnTheGround,0);default:return new Jt(Ce.Absolute,0)}}get supportedTextureEncodings(){return ke(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new pt;for(const i of e.values()){if(null==i)continue;const{node:{serviceMbsInIndexSR:e}}=i,[s,r,o,a]=e;t.expandElevationRangeValues(o-a,o+a)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new lt(this.view,e):new nt("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Ke({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new Ie(mt(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(h)),Xe(this.i3slayer),Ye(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new ae({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color;const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const n=this._controller,d=this._nodeId2Meta,c=this._nodeId2MetaReloading,u=e=>{const t=n.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=d.get(i)||c.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Ue({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:u}),this._elevationProvider=new dt({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),m),this._updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this._updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),m),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==Ce.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),ti):t&&this.removeHandles(ti)}),m),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const _=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),_),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),m),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),m),this.addHandles([g((()=>ft.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&ft.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||ft.I3S_TREE_SHOW_TILES||(this._treeDebugger=l(this._treeDebugger))}),m),g((()=>ft.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),m)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch((e=>a.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`)));const{view:f}=this,{viewingMode:p,renderCoordsHelper:b}=f;this._planetRadiusInGlobalMode="local"===p?0:b.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=l(this._elevationTask),this.i3sOverrides=l(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContextAndSelf(this.uid),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=l(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=l(this._labeler),this._treeDebugger=l(this._treeDebugger),this._controller=l(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=l(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=l(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.usedMemory;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=null!=t?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=null!=t?t.node.memory:0)),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(Se(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new be({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=xe().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=ve(this._layerClippingArea,this._modifications,t);Ee({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new d:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==We.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!ft.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o=new fe({...t,color:e[s.type]});this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>{this._nodeId2Meta.get(e)===s&&this._attributeValuesChanged(s)}),i).catch((e=>{c(e)||a.getLogger(this).warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear(),this._addTasks.forEach((e=>e.allowMemCache=!1))}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>t&&e.push(this._collection.getComponentObb(t.objectHandle)))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!==(this.supportedTextureEncodings&Te.Basis)&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&&Rt()}_getVertexBufferLayout(e,t){return vt(Mt(this._getGeometryParameters({hasTexture:Wt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.i3slayer.objectIdField||oe}_getGlobalIdField(){return this.i3slayer.globalIdField}_findGraphicNodeAndIndex(e){const t=ct(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const a of t){const e=ct(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this.getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this.getAABB(e.nodeIndex,e.componentIndex)}getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=He(t,this._collection,s,J(24),0),o=this.view.renderSpatialReference,a=this.view.spatialReference;return q(r,o,0,r,a,0)?K(r):null}whenGraphicAttributes(e,t){return Je(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(r)))}getGraphicFromIntersectorTarget(e,t){if(null==e.nodeIndex||null==e.componentIndex)return null;const i=this._nodeId2Meta.get(e.nodeIndex);if(null==i?.featureIds||e.componentIndex>=i.featureIds.length)return null;const s=this._createLayerGraphic(this._createAttributes(e.componentIndex,i));return t.defer?(t.defer((async()=>(s.geometry=(await import("./i3s/meshUtils.js")).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),s))),null):s}_getCacheKey(e){return`${this._layerUrl}/v${Vt}/${e}${this._cacheKeySuffix}`}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return si;if(e===L(e))return ri;return this.i3slayer.spatialReference.equals(e)?ii:null!=e.wkid?`@${e.wkid}`:null}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0===(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=Le(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===Ce.Absolute&&(e.geometryObbInRenderSR=yt.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=$t(s.transformedGeometry,s.textureData),s.textureData.every(Kt)&&this._indexedDbSizeCheck(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>a.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),u(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return zt(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:n,anchorIds:l,anchors:d,transformedGeometry:h,globalTrafo:c}=s,u=j(Zt,r.center.x,r.center.y,r.center.z);S(u,u,c);const _=new yt(u,[r.extents.x,r.extents.y,r.extents.z],O(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===Ce.Absolute&&(e.geometryObbInRenderSR=_),t.geometryData.componentOffsets=o,n&&(t.geometryData.featureIds=Array.from(n)),t.geometryData.anchorIds=l,t.geometryData.anchors=d;const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:h,globalTrafo:c,geometryObbData:_.data,byteSize:$t(h,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,m)){const t=null!=m.textureData?m.textureData.map((e=>Kt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...m,textureData:t}).catch((t=>a.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new pt,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,a=e[3],n=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=n.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=n.getServiceMbsInRenderSR(i),d&&(_=d[3]);if(_>=0&&a>=1*_)return null!=r?ni(t,r,l):null!=d&&d[3]>=0&&li(t,d,l),!1;const m=ai;if(m.elevationRangeMin=1/0,m.elevationRangeMax=-1/0,(null!=r||null!=d)&&(null!=r?ni(m,r,l):null!=d&&li(m,d,l),m.elevationRangeMin>=t.elevationRangeMin&&m.elevationRangeMax<=t.elevationRangeMax))return!1;const g=o.get(i.index);if(g){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(a>0*s.radius)return ni(t,s,l),!1}const{objectHandle:e}=g,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(g?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Ze(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=this.i3slayer.normalReferenceFrame,a=t.normalReferenceFrame??o??"none",n=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=$e(n,l,a,d,c),_=W(d,h),m=W(h,c);if(null==_||null==m)return Promise.resolve(null);const g={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:n,obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._controller.isMeshPyramid,normalReferenceFrame:a,indexToVertexProjector:_,vertexToRenderProjector:m};return this._worker.invoke(g,i)}get _supportsNodeCrossFading(){return!this.view?.stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===Ce.Absolute&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==Ce.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const l=null!=t.textureData?t.textureData.filter((e=>null!=e&&0!==(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&l.some((e=>null!=e&&(e.encoding===Te.Basis||e.encoding===Te.KTX2)))&&await Rt(),e.memory=0;const{componentOffsets:d,geometries:h,featureIds:c,anchorIds:u,anchors:_}=r,m=this._collection,g=h[0],{layout:f,indices:p,interleavedVertexData:b,positionData:y,hasColors:I}=o,{material:O,geometryParameters:j}=this._materialParameters(g,f),S=d||new Uint32Array([0,p?p.length:b.byteLength/f[0].stride]),D={vertices:{data:b,count:b.byteLength/f[0].stride,layoutParameters:j},positionData:{positions:Z(y.data),indices:ee(y.indices)},indices:p,componentOffsets:S},F=g.transformation?E(g.transformation):R();w(F,n,F);const V=x(P(),F),N=v(M(),F),H=this.view.renderSpatialReference,k=this.view.basemapTerrain.spatialReference,L=yt.fromData(t.geometryObbData).center,B=[1,1,1];G(L,H,B,k)||a.getLogger(this).errorOnce("Unsupported coordinate system for IM overlay");const q=P();z(L,H,q,k);const W=M();C(W,N);const K=P();A(K,T(K,L,V),W);const $=q[0]-K[0]*B[0],Q=q[1]-K[1]*B[1],X=m.createObject(new Ct(U($,Q,B[0],B[1]),new xt(V,N),yt.fromData(t.geometryObbData),D)),Y=j.textureCoordinates===Et.Atlas,{textures:J,texturePromise:te}=this._initMaterialAndTextures(X,O,l,Y,e);e.memory+=this._memEstimateGeometryAdded(X),e.memory+=J.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const ie=!!O.hasParametersFromSource,se="blend"!==O.alphaMode&&O.metallicRoughness.baseColorFactor[3]>=1,re=new Dt(e,c,X,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:ie,isOpaque:se},J,u,_);s.meta=re,this._hasTextures||=t.requiredTextures?.some((({usage:e})=>0!==(e&Ae.ColorTextures)))||!!e.resources.texture,this._hasData=!0,this._hasColors||=I,this.notifyChange("hasTexturesOrVertexColors");const oe=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(re),te]).then((([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(re.objectHandle,!1).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,re),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);m.setObjectVisibility(X,!0),t?.updateObjectVisibility(re.objectHandle,!0).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),re.attributeInfo=i.attributeInfo;const s=re.cachedRendererVersion!==this._rendererVersion,r=oe!==this.slicePlaneEnabled;this._updateElevationOffsets(re);const o=re.elevationOffsets;this._updateComponentData(re);const a=this._applyFiltersToNode(re);(s||null!=t&&(r||a||o))&&this._addOrUpdateEdgeRendering(re),null!=this._labeler&&this._addMetaToLabeler(this._labeler,re),this._visibleGeometryChanged(re,Ht.ADD),this._highlights.objectCreated(re),this._updateMaterial(re),this._setNewNodeOpacity(re),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{const{meta:t,allowMemCache:i}=s;throw s.meta=null,t&&i?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){a.getLogger(this).error("Removing duplicated node");const t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Yt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,a=s.mode;if(null==t||null==o||a===Ce.Absolute)return void(e.elevationOffsets=null);const n=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Zt,d=ei,h=a===Ce.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=J(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const a=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(j(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),D(l,l,te(e.node.serviceMbsInIndexSR)),z(l,i,l,o),s[a]=l[0],s[a+1]=l[1],s[a+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),j(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),A(l,l,n.rotationScale),D(l,l,n.position),s[a+2]=c.getAltitude(l),z(l,t,l,o),s[a]=l[0],s[a+1]=l[1])}return s})(),m=s.offset,g=e.elevationOffsets,f=(e,t)=>{const i=h?_[3*e+2]:0;g[e]=m+(t??0)-i};r.getElevations(_,u,f)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Fe(this.view.resourceController.scheduler,(e=>this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference)?.filterInPlace((e=>null!=this._nodeId2Meta.get(e)))),(e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e))),(()=>this.elevationInfo?.mode))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==Ce.Absolute,s=!!t&&t!==e&&t.mode!==Ce.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Ht.UPDATE),this._elevationProvider.objectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return u(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ge(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Wt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s,r){const o=this._stage.renderView,a=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,r.memory-=e},n=i.map((e=>Be(e,t,s,o,this._compressionTracker,a)));this._stage.addTextures(n);let l=null;return this._collection.updateMaterial(e,(e=>{l=qe(e,t,n,i,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:n,texturePromise:l}}_getGeometryParameters(e){return new wt(this._hasVertexColors,e.hasTexture?e.hasRegions?Et.Atlas:Et.Default:Et.None,e.hasNormals,this._shadeNormals,this._applySSAO)}_addData(e,t,i){let s=this._addTasks.get(e.index);if(s)s.attributeInfo=t;else{const r=_();s=new Xt(t,null,r.promise),this._addTasks.set(e.index,s),i().then(r.resolve,r.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))}return s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=X();this._renderClippingArea=bt(this.view.clippingArea,i,e)?i:null;const s=X();this._layerClippingArea=bt(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=_i(this._nodeId2Meta.values()),this._filteredIdCounts=_i(this._nodeId2Meta.values(),ui.Filtered),this._weaklyRemovedIdCounts=_i(this._nodeId2Meta.values(),ui.WeaklyRemoved),this.addHandles(g((()=>this._controller.updating),(e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())}),{sync:!0}),"updateFinished")):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles("updateFinished"),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,ci(this._featureIdCounts,e.featureIds,t),ci(this._filteredIdCounts,e.filteredIds,t),ci(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,ci(this._filteredIdCounts,t,-1),ci(this._filteredIdCounts,e.filteredIds,1),ci(this._weaklyRemovedIdCounts,i,-1),ci(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&a.getLogger(this).error("checkFeatureIdNodeCountInvariant()","LayerView should have feature id node counts if and only if it has a geometry filter",{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;const t=_i(this._nodeId2Meta.values());n(this._featureIdCounts,t)||a.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=_i(this._nodeId2Meta.values(),ui.Filtered);n(this._filteredIdCounts,i)||a.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=_i(this._nodeId2Meta.values(),ui.WeaklyRemoved);n(this._weaklyRemovedIdCounts,s)||a.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _weaklyRemovedIdCounts",{layerView:this,counts:this._weaklyRemovedIdCounts,expected:i})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(const[i,s]of this._filteredIdCounts){const r=this._featureIdCounts.get(i);if(r!==s){s+(this._weaklyRemovedIdCounts?.get(i)??0)===r?(e??=new Set,e.add(i)):(t??=new Set,t.add(i))}}p(e,this._mismatchShow)&&p(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach((e=>{if(!e?.filteredIds)return;const t=hi(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,Ht.UPDATE)})))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Ht.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===n||null!=d?.[e]))&&et(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?Ve(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return B(e.node.serviceMbsInIndexSR,this._controller.crsIndex,qt,this.view.renderSpatialReference),tt(t,qt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Ut),Q(Ut,kt),Y(i,kt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===it.INSIDE)return;if(r===it.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const a=this._transformClippingArea(Lt,i,t.objectHandle);et(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,a)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e);s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const o=this._edgeView;if(!o)return null;const a=o.hasObject(i);if(s){if(a){if(this.nodeCrossfadingEnabled){Yt(r,this.getNodeOpacity(e))}return o.updateAllComponentMaterials(i,r,this.slicePlaneEnabled,t).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),o.updateObjectVisibility(i,!0).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),o.updateAllVerticalOffsets(i,e.elevationOffsets).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),o}const s=await this._collection.addEdges(i,o,r,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,o}return a&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,o.removeObject(i)),null}_applyFiltersToNode(e){const t=e.filteredIds,i=e.weaklyRemovedIds;return!!this._applyFiltersToNodeComponents(e)&&(this._updateFilteredIdCounts(e,t,i),this._labeler?.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(null!=e.filteredIds&&e.appliedFilters===this._filters||(e.weaklyRemovedIds=null,e.filteredIds=di(e,this._filters),e.appliedFilters=this._filters),s&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every((e=>!this._mismatchHide?.has(e)))))return!r;const o=hi(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=l(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Ht.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._updateFeatureIdCounts(s,-1),this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.removeTexture(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===ze.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=st(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return st(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=st(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await me()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:a.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.symbols)"mesh-3d"!==t.type&&a.getLogger(this).error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;H(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255);const o=this._stage.renderView.olidRenderHelper;if(o){const t=e.featureIds[i],r=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,a=ce(this.view,this.uid);o.setUidToObjectAndLayerId(t,t,this.layerId,r,this.layerPopupEnabledAndHasTemplate&&!a,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=o.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:r})}s.externalColorMixMode=t[r+4]&(1<<Ft.CastShadows)-1,s.castShadows=!!(t[r+4]&1<<Ft.CastShadows),s.pickable=!!(t[r+4]&1<<Ft.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ge))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=rt(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?ne(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=e.featureIds?this.i3slayer.objectIdField:null,a=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let n=null,l=null;if(a&&null!=this._symbologyFields){n=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(n.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=re(5*e.featureIds.length));const d=new ht,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=Ot.OPAQUE,m=ot,g=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=Ve(l[e],f);const r=s?this._getSymbolInfo(s,t):null;let h,p;if(d.pickable=!0,s&&"visualVariables"in s){if(this._colorVariable){const e=de(this._colorVariable,t,{color:Bt,arcade:this._arcade});e&&(h=d.color,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,h[3]=e.a??1,this._opacityVariable||null===e.a||(p=e.a))}this._opacityVariable&&(p=he(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?je(h,p,e.color,e.alpha,Tt,d.color):je(h,p,null,null,Tt,d.color)}if(h??=H(d.color,1,1,1,1),d.colorMixMode=r?.material?.colorMixMode??gt.Multiply,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=gt.Replace),d.pickable&&=h[3]>=At,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||d.colorMixMode===gt.Replace)?Ot.OPAQUE:Ot.TRANSPARENT;d.edgeMaterial===u&&t===_||(m={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[f]=m}else e.cachedEdgeMaterials[f]=ot;e.cachedSymbology[g++]=Math.round(255*h[0]),e.cachedSymbology[g++]=Math.round(255*h[1]),e.cachedSymbology[g++]=Math.round(255*h[2]),e.cachedSymbology[g++]=Math.round(255*h[3]),e.cachedSymbology[g++]=d.colorMixMode|+d.castShadows<<Ft.CastShadows|+d.pickable<<Ft.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Yt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==ot)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?ot:(r=r||t!==ot,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Yt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Ht.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{null!=t&&this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return this._shadeNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?Me.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values()){if(null==s)continue;if(null!=t){switch(t(s.node.serviceMbsInIndexSR)){case Me.EXIT:return;case Me.SKIP:continue}}let r=Me.CONTINUE;switch(i){case we.ALL:r=this._forAllFeaturesOfNode(s,e);break;case we.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case we.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}if(r===Me.EXIT)return}}_forAllFeaturesOfNode(e,t){let i=Me.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===Me.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=Me.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===Me.CONTINUE))),i}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(s===it.OUTSIDE)return Me.CONTINUE;if(s===it.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=Me.CONTINUE,o=e.featureIds,a=e.objectHandle,n=at(this._renderClippingArea,this._collection.getObjectTransform(a));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,n))continue;const t=i(o[l],l,e);if(t===Me.EXIT)return t}return r}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=Ve(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){if(_e(e))return ut;const s=_t(e);if(0===s.length)return ut;const r=t?.name??jt,o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return ut;const{set:a,handle:n}=this._highlights.acquireSet(r);return this._highlights.setFeatureIds(a,o),n}_featureIdsFromGraphics(e){const t=this.i3slayer.fieldsIndex,i=this._getObjectIdField();return e.map((e=>ct(t,e.attributes,i)))}resetHighlights(){l(this._highlights),this._highlights=new De({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,we.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{const{node:t}=e,i=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(null!=i){const e=$();i.toAaBoundingBox(e),this.emit("visible-geometry-changed",new pe(e))}else this.emit("visible-geometry-changed");this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t),this._elevationProvider.objectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new ye(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}checkInvariants(){}get test(){}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;Yt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>this._logEdgeViewError(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Qt(e);if(s){const t={context:i,buffer:s.buffer};Re(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=Oe(i);e.imModificationImpact=s,s!==We.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.running||this._needFilterResolve||this._compressionTracker.compressing}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>s(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===Ce.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=P(),n=P(),l=(e,t)=>{D(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),D(e,e,F(n,n,t)),V(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Ht.REMOVE&&t!==Ht.UPDATE||r.events.remove(i),t!==Ht.ADD&&t!==Ht.UPDATE||r.events.add(i,s)}_logEdgeViewError(e,t){c(e)||a.getLogger(this).warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>Nt?(a.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}};return e([y()],o.prototype,"_hasLoadedPBRTextures",void 0),e([y()],o.prototype,"_asyncModuleLoading",void 0),e([y()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([y()],o.prototype,"view",void 0),e([y()],o.prototype,"i3slayer",void 0),e([y()],o.prototype,"_controller",void 0),e([y()],o.prototype,"_labeler",void 0),e([y()],o.prototype,"updating",void 0),e([y()],o.prototype,"suspended",void 0),e([y()],o.prototype,"contentVisible",null),e([y({readOnly:!0})],o.prototype,"legendEnabled",null),e([y(It)],o.prototype,"updatingProgress",void 0),e([y()],o.prototype,"updatingProgressValue",null),e([y()],o.prototype,"hasTexturesOrVertexColors",null),e([y()],o.prototype,"rendererTextureUsage",null),e([y()],o.prototype,"elevationOffset",null),e([y()],o.prototype,"elevationInfo",null),e([y({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([y()],o.prototype,"supportedTextureEncodings",null),e([y({type:[le]})],o.prototype,"_modifications",void 0),e([y({readOnly:!0})],o.prototype,"clientGeometry",null),e([y()],o.prototype,"elevationRange",null),e([y()],o.prototype,"fullExtent",null),e([y()],o.prototype,"_elevationTask",void 0),e([y({readOnly:!0})],o.prototype,"_usePBR",null),o=e([I("esri.views.3d.layers.I3SMeshView3D")],o),o};var Ht;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Ht||(Ht={}));const Ut=$(),kt=X(),Lt=X(),Gt=new yt,Bt=new t([0,0,0,0]),qt=ie(0,0,0,0);function Wt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function zt(e){return"geometryData"in e}function Kt(e){return null!=e&&b(e.data)}function $t(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&b(s.data)&&(i+=s.data.byteLength);return i}function Qt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Gt,t.center=te(e.serviceMbsInIndexSR),t.halfSize=[e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}class Xt{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function Yt(e,t){e.forEach((e=>e.opacity=t))}class Jt{constructor(e,t){this.mode=e,this.offset=t}}const Zt=P(),ei=$(),ti="elevation-change",ii="",si="@null",ri="@ECEF",oi=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],ai=new pt;function ni(e,t,i){let s=e.elevationRangeMin,r=e.elevationRangeMax;const o=i;if(o>0){t.getCorners(oi);for(const e of oi){const t=N(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(oi);for(const e of oi){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function li(e,t,i){const s=te(t),r=i>0?N(s)-i:s[2],o=se(t);e.expandElevationRangeValues(r-o,r+o)}function di(e,t){const i=e.featureIds.slice();for(const s of t)if(s(i,e),0===i.length)break;return i.length===e.featureIds.length?e.featureIds:i}function hi(e,t,i){const s=new Array,r=e.filteredIds;if(null==r||t?.size||i?.size){if(null!=r){let o=0;e.featureIds.forEach(((e,a)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(a)}))}}else e.featureIds.forEach(((e,t)=>{r[s.length]===e&&s.push(t)}));return s}function ci(e,t,i){if(e&&t)for(const s of t){const t=(e.get(s)??0)+i;t>0?e.set(s,t):e.delete(s)}}var ui;function _i(e,t=ui.All){const i=new Map;for(const s of e){ci(i,t===ui.All?s?.featureIds:t===ui.Filtered?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}!function(e){e[e.All=0]="All",e[e.Filtered=1]="Filtered",e[e.WeaklyRemoved=2]="WeaklyRemoved"}(ui||(ui={}));export{Pt as I3SMeshView3D};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s,isSome as r}from"../../../core/arrayUtils.js";import{ByteSizeUnit as o}from"../../../core/ByteSizeUnit.js";import has from"../../../core/has.js";import a from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as l}from"../../../core/maybe.js";import d from"../../../core/PooledArray.js";import{ignoreAbortErrors as h,isAbortError as c,throwIfAborted as u,createResolver as _}from"../../../core/promiseUtils.js";import{initial as m,watch as g}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{equals as p}from"../../../core/SetUtils.js";import{isArrayBuffer as b}from"../../../core/typedArrayUtil.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as v,invert as C}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as M}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as w,getTranslation as x}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as E,create as R}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as O}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as j,t as S,o as A,a as T,f as D,g as F,d as V,H as N}from"../../../chunks/vec32.js";import{create as P}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as H}from"../../../chunks/vec42.js";import{fromValues as U}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as k}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as L}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as G}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as B}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as q}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as W}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as K,create as $,toRect as Q}from"../../../geometry/support/aaBoundingBox.js";import{create as X,intersects as Y}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as J}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{a as te,f as ie,g as se}from"../../../chunks/sphere.js";import{newUByteArray as re}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as oe}from"../../../layers/LayerConstants.js";import ae from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as ne}from"../../../layers/support/fieldUtils.js";import le from"../../../layers/support/SceneModification.js";import{getColor as de,getOpacity as he}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as ce}from"../../../support/basemapUtils.js";import{getElevationOffset as ue}from"../../../support/elevationInfoUtils.js";import{isQuery as _e}from"../../../support/guards.js";import{loadArcade as me}from"../../../support/loadArcade.js";import ge from"../../../symbols/MeshSymbol3D.js";import fe from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as pe}from"./ContentGeometryLayerView.js";import be from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as ye}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as Ie,toWasmModification as ve}from"./I3SMeshWorkerHandle.js";import{ElevationMode as Ce,ForAllFeaturesReturnType as Me,ForAllFeaturesMode as we}from"./II3SMeshView3D.js";import{initialize as xe,setModificationsSync as Ee,filterObbsForModificationsSync as Re,interpretObbModificationResults as Oe}from"./SceneLayerWorker.js";import{overrideColor as je}from"./graphics/graphicUtils.js";import{areLabelsVisible as Se}from"./graphics/Labeler.js";import{TextureUsage as Ae,TextureEncoding as Te}from"./i3s/enums.js";import De from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Fe}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Ve}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Ne,NodeCrossfadeMetaData as Pe}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as He}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ue}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as ke,selectEncoding as Le,defaultMaterial as Ge,createTexture as Be,configureMaterial as qe}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as We,NodeState as ze}from"./i3s/I3SNode.js";import{I3SOverrides as Ke}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as $e}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Qe,checkSceneLayerValid as Xe,checkSceneLayerCompatibleWithView as Ye,whenGraphicAttributes as Je,computeVisibilityObb as Ze,filterInPlace as et,intersectBoundingRectWithMbs as tt,MbsIntersectResult as it,addWraparound as st,getSymbolInfo as rt,transparentEdgeMaterial as ot,getClipRect as at}from"./i3s/I3SUtil.js";import{IDBCache as nt}from"./i3s/IDBCache.js";import{IDBMockCache as lt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as dt}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as ht}from"./i3s/SymbologyInfo.js";import{attributeLookup as ct}from"./support/attributeUtils.js";import{emptyHighlightHandle as ut,normalizeHighlightTargetExceptQuery as _t}from"./support/highlightUtils.js";import{makeScheduleFunction as mt}from"./support/makeScheduleFunction.js";import{ColorMixModeEnum as gt}from"./support/symbolColorUtils.js";import{debugFlags as ft}from"../support/debugFlags.js";import{ElevationRange as pt}from"../support/ElevationRange.js";import{toBoundingRect as bt}from"../support/extentUtils.js";import{Obb as yt}from"../support/orientedBoundingBox.js";import{updatingProgress as It}from"../support/updatingProperties.js";import{glLayout as vt}from"../support/buffer/glUtil.js";import{ObjectParameters as Ct}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as Mt,GeometryParameters as wt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as xt}from"../webgl-engine/collections/Component/Transform.js";import{TextureCoordinateType as Et}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasisTranscoder as Rt}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as Ot}from"../webgl-engine/lib/edgeRendering/interfaces.js";import{defaultHighlightName as jt}from"../../support/HighlightDefaults.js";import{TextureCompressionTracker as St}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as At}from"../../../webscene/support/AlphaCutoff.js";const Tt=[1,1,1,1];class Dt extends Pe{constructor(e,t,i,s,r,o,a,n,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=a,this.anchorIds=n,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}get cachedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}var Ft;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(Ft||(Ft={}));const Vt=26,Nt=100*o.MEGABYTES,Pt=t=>{let o=class extends t{constructor(){super(...arguments),this._applySSAO=!0,this._shadeNormals=!0,this._updatingHandles=new k,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new St,this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new Ne(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerViewUid(){return this.uid}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get _isIntegratedMesh(){return"integrated-mesh"===this.i3slayer.type}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>At}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Qe(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Ae.AllTexturesPBR:Ae.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Ae.GeometryTexturesPBR:Ae.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?ue(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new Jt(Ce.Absolute,0);const t=ue(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new Jt(Ce.Absolute,t);case"relative-to-ground":return new Jt(Ce.RelativeToGround,t);case"on-the-ground":return new Jt(Ce.OnTheGround,0);default:return new Jt(Ce.Absolute,0)}}get supportedTextureEncodings(){return ke(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new pt;for(const i of e.values()){if(null==i)continue;const{node:{serviceMbsInIndexSR:e}}=i,[s,r,o,a]=e;t.expandElevationRangeValues(o-a,o+a)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new lt(this.view,e):new nt("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Ke({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new Ie(mt(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(h)),Xe(this.i3slayer),Ye(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new ae({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color;const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const n=this._controller,d=this._nodeId2Meta,c=this._nodeId2MetaReloading,u=e=>{const t=n.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=d.get(i)||c.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Ue({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:u}),this._elevationProvider=new dt({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),m),this._updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this._updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),m),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==Ce.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),ti):t&&this.removeHandles(ti)}),m),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const _=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),_),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),m),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),m),this.addHandles([g((()=>ft.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&ft.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||ft.I3S_TREE_SHOW_TILES||(this._treeDebugger=l(this._treeDebugger))}),m),g((()=>ft.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),m)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch((e=>a.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`)));const{view:f}=this,{viewingMode:p,renderCoordsHelper:b}=f;this._planetRadiusInGlobalMode="local"===p?0:b.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=l(this._elevationTask),this.i3sOverrides=l(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContextAndSelf(this.uid),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=l(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=l(this._labeler),this._treeDebugger=l(this._treeDebugger),this._controller=l(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=l(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=l(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.usedMemory;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=null!=t?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=null!=t?t.node.memory:0)),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(Se(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new be({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=xe().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=ve(this._layerClippingArea,this._modifications,t);Ee({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new d:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==We.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!ft.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o=new fe({...t,color:e[s.type]});this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>{this._nodeId2Meta.get(e)===s&&this._attributeValuesChanged(s)}),i).catch((e=>{c(e)||a.getLogger(this).warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear(),this._addTasks.forEach((e=>e.allowMemCache=!1))}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>t&&e.push(this._collection.getComponentObb(t.objectHandle)))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!==(this.supportedTextureEncodings&Te.Basis)&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&&Rt()}_getVertexBufferLayout(e,t){return vt(Mt(this._getGeometryParameters({hasTexture:Wt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.i3slayer.objectIdField||oe}_getGlobalIdField(){return this.i3slayer.globalIdField}_findGraphicNodeAndIndex(e){const t=ct(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const a of t){const e=ct(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this.getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this.getAABB(e.nodeIndex,e.componentIndex)}getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=He(t,this._collection,s,J(24),0),o=this.view.renderSpatialReference,a=this.view.spatialReference;return q(r,o,0,r,a,0)?K(r):null}whenGraphicAttributes(e,t){return Je(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(r)))}getGraphicFromIntersectorTarget(e,t){if(null==e.nodeIndex||null==e.componentIndex)return null;const i=this._nodeId2Meta.get(e.nodeIndex);if(null==i?.featureIds||e.componentIndex>=i.featureIds.length)return null;const s=this._createLayerGraphic(this._createAttributes(e.componentIndex,i));return t.defer?(t.defer((async()=>(s.geometry=(await import("./i3s/meshUtils.js")).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),s))),null):s}_getCacheKey(e){return`${this._layerUrl}/v${Vt}/${e}${this._cacheKeySuffix}`}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return si;if(e===L(e))return ri;return this.i3slayer.spatialReference.equals(e)?ii:null!=e.wkid?`@${e.wkid}`:null}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0===(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=Le(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===Ce.Absolute&&(e.geometryObbInRenderSR=yt.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=$t(s.transformedGeometry,s.textureData),s.textureData.every(Kt)&&this._indexedDbSizeCheck(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>a.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),u(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return zt(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:n,anchorIds:l,anchors:d,transformedGeometry:h,globalTrafo:c}=s,u=j(Zt,r.center.x,r.center.y,r.center.z);S(u,u,c);const _=new yt(u,[r.extents.x,r.extents.y,r.extents.z],O(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===Ce.Absolute&&(e.geometryObbInRenderSR=_),t.geometryData.componentOffsets=o,n&&(t.geometryData.featureIds=Array.from(n)),t.geometryData.anchorIds=l,t.geometryData.anchors=d;const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:h,globalTrafo:c,geometryObbData:_.data,byteSize:$t(h,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,m)){const t=null!=m.textureData?m.textureData.map((e=>Kt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...m,textureData:t}).catch((t=>a.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new pt,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,a=e[3],n=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=n.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=n.getServiceMbsInRenderSR(i),d&&(_=d[3]);if(_>=0&&a>=1*_)return null!=r?ni(t,r,l):null!=d&&d[3]>=0&&li(t,d,l),!1;const m=ai;if(m.elevationRangeMin=1/0,m.elevationRangeMax=-1/0,(null!=r||null!=d)&&(null!=r?ni(m,r,l):null!=d&&li(m,d,l),m.elevationRangeMin>=t.elevationRangeMin&&m.elevationRangeMax<=t.elevationRangeMax))return!1;const g=o.get(i.index);if(g){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(a>0*s.radius)return ni(t,s,l),!1}const{objectHandle:e}=g,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(g?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Ze(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=this.i3slayer.normalReferenceFrame,a=t.normalReferenceFrame??o??"none",n=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=$e(n,l,a,d,c),_=W(d,h),m=W(h,c);if(null==_||null==m)return Promise.resolve(null);const g={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:n,obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._controller.isMeshPyramid,normalReferenceFrame:a,indexToVertexProjector:_,vertexToRenderProjector:m};return this._worker.invoke(g,i)}get _supportsNodeCrossFading(){return!this.view?.stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===Ce.Absolute&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==Ce.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const l=null!=t.textureData?t.textureData.filter((e=>null!=e&&0!==(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&l.some((e=>null!=e&&(e.encoding===Te.Basis||e.encoding===Te.KTX2)))&&await Rt(),e.memory=0;const{componentOffsets:d,geometries:h,featureIds:c,anchorIds:u,anchors:_}=r,m=this._collection,g=h[0],{layout:f,indices:p,interleavedVertexData:b,positionData:y,hasColors:I}=o,{material:O,geometryParameters:j}=this._materialParameters(g,f),S=d||new Uint32Array([0,p?p.length:b.byteLength/f[0].stride]),D={vertices:{data:b,count:b.byteLength/f[0].stride,layoutParameters:j},positionData:{positions:Z(y.data),indices:ee(y.indices)},indices:p,componentOffsets:S},F=g.transformation?E(g.transformation):R();w(F,n,F);const V=x(P(),F),N=v(M(),F),H=this.view.renderSpatialReference,k=this.view.basemapTerrain.spatialReference,L=yt.fromData(t.geometryObbData).center,B=[1,1,1];G(L,H,B,k)||a.getLogger(this).errorOnce("Unsupported coordinate system for IM overlay");const q=P();z(L,H,q,k);const W=M();C(W,N);const K=P();A(K,T(K,L,V),W);const $=q[0]-K[0]*B[0],Q=q[1]-K[1]*B[1],X=m.createObject(new Ct(U($,Q,B[0],B[1]),new xt(V,N),yt.fromData(t.geometryObbData),D)),Y=j.textureCoordinates===Et.Atlas,{textures:J,texturePromise:te}=this._initMaterialAndTextures(X,O,l,Y,e);e.memory+=this._memEstimateGeometryAdded(X),e.memory+=J.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const ie=!!O.hasParametersFromSource,se="blend"!==O.alphaMode&&O.metallicRoughness.baseColorFactor[3]>=1,re=new Dt(e,c,X,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:ie,isOpaque:se},J,u,_);s.meta=re,this._hasTextures||=t.requiredTextures?.some((({usage:e})=>0!==(e&Ae.ColorTextures)))||!!e.resources.texture,this._hasData=!0,this._hasColors||=I,this.notifyChange("hasTexturesOrVertexColors");const oe=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(re),te]).then((([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(re.objectHandle,!1).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,re),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);m.setObjectVisibility(X,!0),t?.updateObjectVisibility(re.objectHandle,!0).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),re.attributeInfo=i.attributeInfo;const s=re.cachedRendererVersion!==this._rendererVersion,r=oe!==this.slicePlaneEnabled;this._updateElevationOffsets(re);const o=re.elevationOffsets;this._updateComponentData(re);const a=this._applyFiltersToNode(re);(s||null!=t&&(r||a||o))&&this._addOrUpdateEdgeRendering(re),null!=this._labeler&&this._addMetaToLabeler(this._labeler,re),this._visibleGeometryChanged(re,Ht.ADD),this._highlights.objectCreated(re),this._updateMaterial(re),this._setNewNodeOpacity(re),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{const{meta:t,allowMemCache:i}=s;throw s.meta=null,t&&i?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){a.getLogger(this).error("Removing duplicated node");const t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Yt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,a=s.mode;if(null==t||null==o||a===Ce.Absolute)return void(e.elevationOffsets=null);const n=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Zt,d=ei,h=a===Ce.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=J(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const a=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(j(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),D(l,l,te(e.node.serviceMbsInIndexSR)),z(l,i,l,o),s[a]=l[0],s[a+1]=l[1],s[a+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),j(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),A(l,l,n.rotationScale),D(l,l,n.position),s[a+2]=c.getAltitude(l),z(l,t,l,o),s[a]=l[0],s[a+1]=l[1])}return s})(),m=s.offset,g=e.elevationOffsets,f=(e,t)=>{const i=h?_[3*e+2]:0;g[e]=m+(t??0)-i};r.getElevations(_,u,f)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Fe(this.view.resourceController.scheduler,(e=>this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference)?.filterInPlace((e=>null!=this._nodeId2Meta.get(e)))),(e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e))),(()=>this.elevationInfo?.mode))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==Ce.Absolute,s=!!t&&t!==e&&t.mode!==Ce.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Ht.UPDATE),this._elevationProvider.objectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return u(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ge(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Wt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s,r){const o=this._stage.renderView,a=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,r.memory-=e},n=i.map((e=>Be(e,t,s,o,this._compressionTracker,a)));this._stage.addTextures(n);let l=null;return this._collection.updateMaterial(e,(e=>{l=qe(e,t,n,i,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:n,texturePromise:l}}_getGeometryParameters(e){return new wt(this._hasVertexColors,e.hasTexture?e.hasRegions?Et.Atlas:Et.Default:Et.None,e.hasNormals,this._shadeNormals,this._applySSAO)}_addData(e,t,i){let s=this._addTasks.get(e.index);if(s)s.attributeInfo=t;else{const r=_();s=new Xt(t,null,r.promise),this._addTasks.set(e.index,s),i().then(r.resolve,r.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))}return s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=X();this._renderClippingArea=bt(this.view.clippingArea,i,e)?i:null;const s=X();this._layerClippingArea=bt(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=_i(this._nodeId2Meta.values()),this._filteredIdCounts=_i(this._nodeId2Meta.values(),ui.Filtered),this._weaklyRemovedIdCounts=_i(this._nodeId2Meta.values(),ui.WeaklyRemoved),this.addHandles(g((()=>this._controller.updating),(e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())}),{sync:!0}),"updateFinished")):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles("updateFinished"),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,ci(this._featureIdCounts,e.featureIds,t),ci(this._filteredIdCounts,e.filteredIds,t),ci(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,ci(this._filteredIdCounts,t,-1),ci(this._filteredIdCounts,e.filteredIds,1),ci(this._weaklyRemovedIdCounts,i,-1),ci(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&a.getLogger(this).error("checkFeatureIdNodeCountInvariant()","LayerView should have feature id node counts if and only if it has a geometry filter",{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;const t=_i(this._nodeId2Meta.values());n(this._featureIdCounts,t)||a.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=_i(this._nodeId2Meta.values(),ui.Filtered);n(this._filteredIdCounts,i)||a.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=_i(this._nodeId2Meta.values(),ui.WeaklyRemoved);n(this._weaklyRemovedIdCounts,s)||a.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _weaklyRemovedIdCounts",{layerView:this,counts:this._weaklyRemovedIdCounts,expected:i})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(const[i,s]of this._filteredIdCounts){const r=this._featureIdCounts.get(i);if(r!==s){s+(this._weaklyRemovedIdCounts?.get(i)??0)===r?(e??=new Set,e.add(i)):(t??=new Set,t.add(i))}}p(e,this._mismatchShow)&&p(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach((e=>{if(!e?.filteredIds)return;const t=hi(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,Ht.UPDATE)})))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Ht.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===n||null!=d?.[e]))&&et(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?Ve(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return B(e.node.serviceMbsInIndexSR,this._controller.crsIndex,qt,this.view.renderSpatialReference),tt(t,qt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Ut),Q(Ut,kt),Y(i,kt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===it.INSIDE)return;if(r===it.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const a=this._transformClippingArea(Lt,i,t.objectHandle);et(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,a)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e);s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const o=this._edgeView;if(!o)return null;const a=o.hasObject(i);if(s){if(a){if(this.nodeCrossfadingEnabled){Yt(r,this.getNodeOpacity(e))}return o.updateAllComponentMaterials(i,r,this.slicePlaneEnabled,t).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),o.updateObjectVisibility(i,!0).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),o.updateAllVerticalOffsets(i,e.elevationOffsets).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),o}const s=await this._collection.addEdges(i,o,r,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,o}return a&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,o.removeObject(i)),null}_applyFiltersToNode(e){const{filteredIds:t,weaklyRemovedIds:i}=e,s=this._applyFiltersToNodeComponents(e);return this._updateFilteredIdCounts(e,t,i),s&&this._labeler?.applyFilterChange(e),s}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(null!=e.filteredIds&&e.appliedFilters===this._filters||(e.weaklyRemovedIds=null,e.filteredIds=di(e,this._filters),e.appliedFilters=this._filters),s&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every((e=>!this._mismatchHide?.has(e)))))return!r;const o=hi(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=l(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>this._logEdgeViewError(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Ht.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._updateFeatureIdCounts(s,-1),this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.removeTexture(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===ze.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=st(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return st(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=st(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await me()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:a.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.symbols)"mesh-3d"!==t.type&&a.getLogger(this).error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;H(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255);const o=this._stage.renderView.olidRenderHelper;if(o){const t=e.featureIds[i],r=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,a=ce(this.view,this.uid);o.setUidToObjectAndLayerId(t,t,this.layerId,r,this.layerPopupEnabledAndHasTemplate&&!a,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=o.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:r})}s.externalColorMixMode=t[r+4]&(1<<Ft.CastShadows)-1,s.castShadows=!!(t[r+4]&1<<Ft.CastShadows),s.pickable=!!(t[r+4]&1<<Ft.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ge))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=rt(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?ne(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=e.featureIds?this.i3slayer.objectIdField:null,a=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let n=null,l=null;if(a&&null!=this._symbologyFields){n=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(n.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=re(5*e.featureIds.length));const d=new ht,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=Ot.OPAQUE,m=ot,g=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=Ve(l[e],f);const r=s?this._getSymbolInfo(s,t):null;let h,p;if(d.pickable=!0,s&&"visualVariables"in s){if(this._colorVariable){const e=de(this._colorVariable,t,{color:Bt,arcade:this._arcade});e&&(h=d.color,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,h[3]=e.a??1,this._opacityVariable||null===e.a||(p=e.a))}this._opacityVariable&&(p=he(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?je(h,p,e.color,e.alpha,Tt,d.color):je(h,p,null,null,Tt,d.color)}if(h??=H(d.color,1,1,1,1),d.colorMixMode=r?.material?.colorMixMode??gt.Multiply,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=gt.Replace),d.pickable&&=h[3]>=At,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||d.colorMixMode===gt.Replace)?Ot.OPAQUE:Ot.TRANSPARENT;d.edgeMaterial===u&&t===_||(m={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[f]=m}else e.cachedEdgeMaterials[f]=ot;e.cachedSymbology[g++]=Math.round(255*h[0]),e.cachedSymbology[g++]=Math.round(255*h[1]),e.cachedSymbology[g++]=Math.round(255*h[2]),e.cachedSymbology[g++]=Math.round(255*h[3]),e.cachedSymbology[g++]=d.colorMixMode|+d.castShadows<<Ft.CastShadows|+d.pickable<<Ft.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Yt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==ot)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?ot:(r=r||t!==ot,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Yt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Ht.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{null!=t&&this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return this._shadeNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?Me.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values()){if(null==s)continue;if(null!=t){switch(t(s.node.serviceMbsInIndexSR)){case Me.EXIT:return;case Me.SKIP:continue}}let r=Me.CONTINUE;switch(i){case we.ALL:r=this._forAllFeaturesOfNode(s,e);break;case we.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case we.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}if(r===Me.EXIT)return}}_forAllFeaturesOfNode(e,t){let i=Me.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===Me.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=Me.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===Me.CONTINUE))),i}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(s===it.OUTSIDE)return Me.CONTINUE;if(s===it.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=Me.CONTINUE,o=e.featureIds,a=e.objectHandle,n=at(this._renderClippingArea,this._collection.getObjectTransform(a));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,n))continue;const t=i(o[l],l,e);if(t===Me.EXIT)return t}return r}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=Ve(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){if(_e(e))return ut;const s=_t(e);if(0===s.length)return ut;const r=t?.name??jt,o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return ut;const{set:a,handle:n}=this._highlights.acquireSet(r);return this._highlights.setFeatureIds(a,o),n}_featureIdsFromGraphics(e){const t=this.i3slayer.fieldsIndex,i=this._getObjectIdField();return e.map((e=>ct(t,e.attributes,i)))}resetHighlights(){l(this._highlights),this._highlights=new De({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,we.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{const{node:t}=e,i=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(null!=i){const e=$();i.toAaBoundingBox(e),this.emit("visible-geometry-changed",new pe(e))}else this.emit("visible-geometry-changed");this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t),this._elevationProvider.objectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new ye(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}checkInvariants(){}get test(){}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;Yt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>this._logEdgeViewError(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Qt(e);if(s){const t={context:i,buffer:s.buffer};Re(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=Oe(i);e.imModificationImpact=s,s!==We.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.running||this._needFilterResolve||this._compressionTracker.compressing}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>s(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===Ce.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=P(),n=P(),l=(e,t)=>{D(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),D(e,e,F(n,n,t)),V(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Ht.REMOVE&&t!==Ht.UPDATE||r.events.remove(i),t!==Ht.ADD&&t!==Ht.UPDATE||r.events.add(i,s)}_logEdgeViewError(e,t){c(e)||a.getLogger(this).warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>Nt?(a.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}};return e([y()],o.prototype,"_hasLoadedPBRTextures",void 0),e([y()],o.prototype,"_asyncModuleLoading",void 0),e([y()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([y()],o.prototype,"view",void 0),e([y()],o.prototype,"i3slayer",void 0),e([y()],o.prototype,"_controller",void 0),e([y()],o.prototype,"_labeler",void 0),e([y()],o.prototype,"updating",void 0),e([y()],o.prototype,"suspended",void 0),e([y()],o.prototype,"contentVisible",null),e([y({readOnly:!0})],o.prototype,"legendEnabled",null),e([y(It)],o.prototype,"updatingProgress",void 0),e([y()],o.prototype,"updatingProgressValue",null),e([y()],o.prototype,"hasTexturesOrVertexColors",null),e([y()],o.prototype,"rendererTextureUsage",null),e([y()],o.prototype,"elevationOffset",null),e([y()],o.prototype,"elevationInfo",null),e([y({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([y()],o.prototype,"supportedTextureEncodings",null),e([y({type:[le]})],o.prototype,"_modifications",void 0),e([y({readOnly:!0})],o.prototype,"clientGeometry",null),e([y()],o.prototype,"elevationRange",null),e([y()],o.prototype,"fullExtent",null),e([y()],o.prototype,"_elevationTask",void 0),e([y({readOnly:!0})],o.prototype,"_usePBR",null),o=e([I("esri.views.3d.layers.I3SMeshView3D")],o),o};var Ht;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Ht||(Ht={}));const Ut=$(),kt=X(),Lt=X(),Gt=new yt,Bt=new t([0,0,0,0]),qt=ie(0,0,0,0);function Wt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function zt(e){return"geometryData"in e}function Kt(e){return null!=e&&b(e.data)}function $t(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&b(s.data)&&(i+=s.data.byteLength);return i}function Qt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Gt,t.center=te(e.serviceMbsInIndexSR),t.halfSize=[e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}class Xt{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function Yt(e,t){e.forEach((e=>e.opacity=t))}class Jt{constructor(e,t){this.mode=e,this.offset=t}}const Zt=P(),ei=$(),ti="elevation-change",ii="",si="@null",ri="@ECEF",oi=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],ai=new pt;function ni(e,t,i){let s=e.elevationRangeMin,r=e.elevationRangeMax;const o=i;if(o>0){t.getCorners(oi);for(const e of oi){const t=N(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(oi);for(const e of oi){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function li(e,t,i){const s=te(t),r=i>0?N(s)-i:s[2],o=se(t);e.expandElevationRangeValues(r-o,r+o)}function di(e,t){const i=e.featureIds.slice();for(const s of t)if(s(i,e),0===i.length)break;return i.length===e.featureIds.length?e.featureIds:i}function hi(e,t,i){const s=new Array,r=e.filteredIds;if(null==r||t?.size||i?.size){if(null!=r){let o=0;e.featureIds.forEach(((e,a)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(a)}))}}else e.featureIds.forEach(((e,t)=>{r[s.length]===e&&s.push(t)}));return s}function ci(e,t,i){if(e&&t)for(const s of t){const t=(e.get(s)??0)+i;t>0?e.set(s,t):e.delete(s)}}var ui;function _i(e,t=ui.All){const i=new Map;for(const s of e){ci(i,t===ui.All?s?.featureIds:t===ui.Filtered?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}!function(e){e[e.All=0]="All",e[e.Filtered=1]="Filtered",e[e.WeaklyRemoved=2]="WeaklyRemoved"}(ui||(ui={}));export{Pt as I3SMeshView3D};
|