@arcgis/core 5.0.0-next.57 → 5.0.0-next.59
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/Graphic.d.ts +2 -2
- package/Viewpoint.d.ts +1 -1
- package/applications/Components/arcadeFeatureUtils.d.ts +20 -1
- package/applications/Components/arcadeFeatureUtils.js +1 -1
- package/applications/Urban/meshUtils.d.ts +2 -2
- package/arcade.d.ts +1 -1
- package/arcade.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0bd73a66baea2f52e8a6.js +1 -0
- package/assets/esri/core/workers/chunks/18ce7b1559a45d017c45.js +1 -0
- package/assets/esri/core/workers/chunks/262c5794650853457acc.js +1 -0
- package/assets/esri/core/workers/chunks/3405a23973f9e701a4d6.js +1 -0
- package/assets/esri/core/workers/chunks/352c674730c7b7258ae3.js +1 -0
- package/assets/esri/core/workers/chunks/55a9ea536c64976c3409.js +1 -0
- package/assets/esri/core/workers/chunks/62752cd6821959cf6751.js +1 -0
- package/assets/esri/core/workers/chunks/72e3a48aa365542b0689.js +1 -0
- package/assets/esri/core/workers/chunks/{5f9e64f00329cb646f0c.js → 741d170187e58e81584d.js} +1 -1
- package/assets/esri/core/workers/chunks/a6b1e3ec30f6d641aea9.js +1 -0
- package/assets/esri/core/workers/chunks/{da2c41ac0f82f32013c1.js → a7aa87e2c4197ba595ef.js} +10 -10
- package/assets/esri/core/workers/chunks/{d76513a6260d9ec4ea25.js → bf82bb1cdd8b31e7f2aa.js} +1 -1
- package/assets/esri/layers/raster/formats/lerc-wasm.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/assets/esri/themes/base/widgets/_Attribution.scss +2 -2
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +24 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ar.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bg.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bs.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ca.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_cs.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_da.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_de.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_el.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_es.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_et.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fi.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fr.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_he.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hr.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hu.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_id.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_it.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ja.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ko.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lt.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lv.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_nl.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_no.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pl.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-BR.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-PT.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ro.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ru.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sk.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sl.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sr.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sv.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_th.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_tr.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_uk.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_vi.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-CN.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-HK.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-TW.json +1 -1
- package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_fr.json +1 -1
- package/chunks/lerc-wasm.js +1 -1
- package/config.js +1 -1
- package/core/workers/workerFactory.js +1 -1
- package/editing/sharedTemplates/executor/builders/offsetLine.js +1 -1
- package/editing/sharedTemplates/executor/builders/offsetPrimaryLine.js +1 -1
- package/editing/sharedTemplates/executor/builders/polygonBoundary.js +1 -1
- package/editing/sharedTemplates/executor/builders/polygonBoundaryTwoPoint.js +1 -1
- package/editing/sharedTemplates/executor/builders/polygonVertices.js +1 -1
- package/editing/sharedTemplates/executor/builders/support/builderUtils.js +1 -1
- package/editing/sharedTemplates/executor/builders/support/shapeUtils.js +1 -1
- package/editing/sharedTemplates/executor/support/createFeatureServiceEdit.js +1 -1
- package/editing/sharedTemplates/executor/support/createPresetServiceEdit.js +1 -1
- package/geometry/Extent.d.ts +1 -1
- package/geometry/Mesh.d.ts +2 -2
- package/geometry/SpatialReference.js +1 -1
- package/geometry/geometryEngine.d.ts +3 -3
- package/geometry/{geometryEngineInterfaces.d.ts → geometryEngineTypes.d.ts} +1 -1
- package/geometry/operators/affineTransformOperator.d.ts +3 -3
- package/geometry/operators/alphaShapeOperator.d.ts +1 -1
- package/geometry/operators/areaOperator.d.ts +1 -1
- package/geometry/operators/boundaryOperator.d.ts +3 -3
- package/geometry/operators/bufferOperator.d.ts +1 -1
- package/geometry/operators/centroidOperator.d.ts +1 -1
- package/geometry/operators/clipOperator.d.ts +3 -3
- package/geometry/operators/containsOperator.d.ts +1 -1
- package/geometry/operators/convexHullOperator.d.ts +3 -3
- package/geometry/operators/crossesOperator.d.ts +1 -1
- package/geometry/operators/cutOperator.d.ts +2 -2
- package/geometry/operators/densifyOperator.d.ts +3 -3
- package/geometry/operators/differenceOperator.d.ts +3 -3
- package/geometry/operators/disjointOperator.d.ts +1 -1
- package/geometry/operators/distanceOperator.d.ts +1 -1
- package/geometry/operators/equalsOperator.d.ts +1 -1
- package/geometry/operators/generalizeOperator.d.ts +3 -3
- package/geometry/operators/geodesicBufferOperator.d.ts +1 -2
- package/geometry/operators/geodesicProximityOperator.d.ts +2 -5
- package/geometry/operators/geodeticAreaOperator.d.ts +1 -2
- package/geometry/operators/geodeticDensifyOperator.d.ts +3 -4
- package/geometry/operators/geodeticDistanceOperator.d.ts +1 -2
- package/geometry/operators/geodeticLengthOperator.d.ts +1 -2
- package/geometry/operators/geodeticUtilsOperator.d.ts +1 -1
- package/geometry/operators/graphicBufferOperator.d.ts +1 -1
- package/geometry/operators/integrateOperator.d.ts +2 -2
- package/geometry/operators/intersectionOperator.d.ts +3 -3
- package/geometry/operators/intersectsOperator.d.ts +1 -1
- package/geometry/operators/isNearOperator.d.ts +1 -1
- package/geometry/operators/labelPointOperator.d.ts +1 -1
- package/geometry/operators/lengthOperator.d.ts +1 -1
- package/geometry/operators/linesToPolygonsOperator.d.ts +1 -1
- package/geometry/operators/locateBetweenOperator.d.ts +2 -2
- package/geometry/operators/minimumBoundingCircleOperator.d.ts +1 -1
- package/geometry/operators/multiPartToSinglePartOperator.d.ts +2 -2
- package/geometry/operators/offsetOperator.d.ts +3 -3
- package/geometry/operators/overlapsOperator.d.ts +1 -1
- package/geometry/operators/projectOperator.d.ts +4 -6
- package/geometry/operators/proximityOperator.d.ts +2 -2
- package/geometry/operators/relateOperator.d.ts +1 -1
- package/geometry/operators/shapePreservingProjectOperator.d.ts +3 -3
- package/geometry/operators/simplifyOGCOperator.d.ts +3 -3
- package/geometry/operators/simplifyOperator.d.ts +3 -3
- package/geometry/operators/symmetricDifferenceOperator.d.ts +3 -3
- package/geometry/operators/touchesOperator.d.ts +1 -1
- package/geometry/operators/{support/proximityResult.d.ts → types.d.ts} +18 -3
- package/geometry/operators/unionOperator.d.ts +3 -3
- package/geometry/operators/withinOperator.d.ts +1 -1
- package/geometry/projection/projectBoundingSphere.js +1 -1
- package/geometry/support/curves/curveUtils.js +1 -1
- package/geometry/support/geodesicUtils.d.ts +15 -2
- package/geometry/support/jsonUtils.d.ts +1 -1
- package/geometry/support/meshUtils/types.d.ts +34 -0
- package/geometry/support/meshUtils.d.ts +4 -7
- package/geometry/support/sphere.js +1 -1
- package/geometry/support/webMercatorUtils.d.ts +1 -1
- package/geometry/types.d.ts +23 -1
- package/geometry.d.ts +1 -1
- package/interfaces.d.ts +69 -72
- package/kernel.js +1 -1
- package/layers/CSVLayer.d.ts +0 -2
- package/layers/CatalogLayer.d.ts +1 -1
- package/layers/FeatureLayer.d.ts +1 -1
- package/layers/GeoJSONLayer.d.ts +1 -1
- package/layers/KnowledgeGraphLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/OGCFeatureLayer.d.ts +1 -1
- package/layers/OrientedImageryLayer.d.ts +1 -3
- package/layers/ParquetLayer.d.ts +1 -1
- package/layers/WFSLayer.d.ts +1 -1
- package/layers/catalog/CatalogFootprintLayer.d.ts +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.d.ts +3 -3
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/knowledgeGraph/layerUtils.js +1 -1
- package/layers/mixins/APIKeyMixin.d.ts +2 -2
- package/layers/mixins/ArcGISImageService.d.ts +4 -3
- package/layers/mixins/BlendLayer.d.ts +16 -15
- package/layers/mixins/DisplayFilteredLayer.d.ts +6 -3
- package/layers/mixins/FeatureEffectLayer.d.ts +23 -21
- package/layers/mixins/FeatureLayerBase.d.ts +23 -20
- package/layers/mixins/ImageryTileMixin.d.ts +5 -5
- package/layers/mixins/PortalLayer.d.ts +7 -7
- package/layers/mixins/RasterPresetRendererMixin.d.ts +6 -3
- package/layers/mixins/SceneService.d.ts +2 -2
- package/layers/mixins/TemporalLayer.d.ts +8 -7
- package/layers/mixins/TemporalSceneLayer.d.ts +2 -2
- package/layers/mixins/TrackableLayer.d.ts +4 -4
- package/layers/ogc/wfsUtils.d.ts +1 -1
- package/layers/raster/formats/Lerc.js +1 -1
- package/layers/raster/functions/creators/createSurfaceFunctions.d.ts +2 -2
- package/layers/support/DisplayFilterInfo.d.ts +7 -7
- package/layers/support/FeatureReductionCluster.d.ts +5 -5
- package/layers/support/FieldsIndex.d.ts +1 -2
- package/layers/support/RasterBandInfo.d.ts +1 -1
- package/layers/support/RasterInfo.d.ts +2 -2
- package/layers/support/RasterSensorInfo.d.ts +1 -1
- package/layers/support/Sublayer.d.ts +3 -3
- package/layers/support/SubtypeSublayer.d.ts +1 -1
- package/layers/support/TrackInfo.d.ts +2 -2
- package/layers/support/arcgisLayerUrl.js +1 -1
- package/layers/support/fieldUtils.d.ts +0 -1
- package/layers/support/source/QueryTableDataSource.d.ts +2 -2
- package/layers/support/types.d.ts +2 -2
- package/layers/types.d.ts +1 -1
- package/package.json +2 -2
- package/popup/FieldInfo.d.ts +8 -8
- package/popup/content/AttachmentsContent.d.ts +2 -2
- package/popup/content/CustomContent.d.ts +1 -1
- package/portal/interfaces.d.ts +2 -2
- package/portal/support/resourceUtils.d.ts +6 -7
- package/rest/featureService/types.d.ts +1 -1
- package/rest/geometryService.d.ts +2 -2
- package/rest/imageService.d.ts +1 -1
- package/rest/knowledgeGraph/GraphAnyValue.d.ts +1 -1
- package/rest/query/support/AttachmentInfo.d.ts +1 -1
- package/rest/query.d.ts +1 -1
- package/rest/support/BufferParameters.d.ts +1 -1
- package/rest/support/DataLayer.d.ts +1 -1
- package/rest/support/DensifyParameters.d.ts +1 -1
- package/rest/support/DistanceParameters.d.ts +1 -1
- package/rest/support/FeatureSet.d.ts +2 -2
- package/rest/support/FindImagesParameters.d.ts +1 -1
- package/rest/support/GeneralizeParameters.d.ts +1 -1
- package/rest/support/IdentifyParameters.d.ts +1 -1
- package/rest/support/ImageGPSInfoParameters.d.ts +1 -1
- package/rest/support/ImageMeasureResultAreaValue.d.ts +1 -1
- package/rest/support/ImageToMapMultirayParameters.d.ts +1 -1
- package/rest/support/OffsetParameters.d.ts +1 -1
- package/rest/support/ProjectParameters.d.ts +1 -1
- package/rest/support/Query.d.ts +1 -1
- package/rest/support/QueryMixin.d.ts +1 -1
- package/rest/support/RelationParameters.d.ts +1 -1
- package/rest/support/RelationshipQuery.d.ts +1 -1
- package/rest/support/TopFeaturesQuery.d.ts +1 -1
- package/smartMapping/labels/bins.d.ts +3 -6
- package/smartMapping/labels/clusters.d.ts +2 -2
- package/smartMapping/popup/clusters.d.ts +4 -4
- package/smartMapping/popup/templates.d.ts +4 -4
- package/smartMapping/renderers/color.d.ts +6 -6
- package/smartMapping/renderers/size.d.ts +6 -6
- package/smartMapping/statistics/support/ageUtils.d.ts +5 -5
- package/smartMapping/statistics/types.d.ts +5 -5
- package/smartMapping/types.d.ts +9 -1
- package/support/revision.js +1 -1
- package/unionTypes.d.ts +1 -1
- package/views/2d/MapViewConstraints.d.ts +5 -4
- package/views/2d/engine/webgl/Painter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/GLSLShaderModule.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/GraphShaderModule.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/graph/GlslGraphWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/features/PipelineConnectionHandlers.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
- package/views/3d/layers/i3s/I3SNode.js +1 -1
- package/views/3d/layers/i3s/I3SUtil.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
- package/views/3d/support/ElevationRange.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/BreakpointsOwner.d.ts +1 -1
- package/views/LinkChartView.d.ts +1 -2
- package/views/MapView.d.ts +1 -2
- package/views/SceneView.d.ts +1 -2
- package/views/View.d.ts +1 -1
- package/views/Viewport2DMixin.d.ts +1 -1
- package/views/draw/MultipointDrawAction.d.ts +1 -1
- package/views/draw/MultipointDrawAction.js +1 -1
- package/views/draw/PointDrawAction.d.ts +1 -1
- package/views/draw/PointDrawAction.js +1 -1
- package/views/draw/PolygonDrawAction.d.ts +1 -1
- package/views/draw/PolygonDrawAction.js +1 -1
- package/views/draw/PolylineDrawAction.d.ts +1 -1
- package/views/draw/PolylineDrawAction.js +1 -1
- package/views/draw/SegmentDrawAction.d.ts +1 -1
- package/views/draw/SegmentDrawAction.js +1 -1
- package/views/input/{IViewEvents.js → mouseButtons.js} +1 -1
- package/views/input/types.d.ts +602 -1
- package/views/layers/BuildingSceneLayerView.d.ts +1 -1
- package/views/layers/FeatureLayerViewMixin.d.ts +1 -1
- package/views/layers/ImageryLayerViewMixin.d.ts +1 -1
- package/views/layers/MediaLayerViewMixin.d.ts +1 -1
- package/views/layers/PointCloudLayerView.d.ts +1 -1
- package/views/layers/SceneLayerView.d.ts +2 -2
- package/views/types.d.ts +148 -2
- package/webdoc/geotriggersInfo/FeatureFilter.d.ts +1 -1
- package/webscene/support/FeatureReferenceObjectId.d.ts +1 -1
- package/widgets/BasemapLayerList/BasemapLayerListViewModel.d.ts +1 -2
- package/widgets/BasemapLayerList.d.ts +3 -4
- package/widgets/CatalogLayerList/CatalogLayerListViewModel.d.ts +1 -1
- package/widgets/CatalogLayerList.d.ts +2 -4
- package/widgets/Directions/DirectionsViewModel.d.ts +1 -1
- package/widgets/Editor/types.d.ts +1 -1
- package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.d.ts +46 -5
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
- package/widgets/FeatureTable/VisibleElements.d.ts +30 -9
- package/widgets/FeatureTable/VisibleElements.js +1 -1
- package/widgets/FeatureTable/support/AttachmentsViewOptions.d.ts +1 -1
- package/widgets/FeatureTable/support/FeatureStore.d.ts +1 -0
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable/support/interfaces.d.ts +2 -2
- package/widgets/FeatureTable.d.ts +46 -5
- package/widgets/FeatureTable.js +1 -1
- package/widgets/LayerList/LayerListViewModel.d.ts +9 -10
- package/widgets/LayerList/ListItem.d.ts +9 -11
- package/widgets/LayerList/ListItemPanel.d.ts +1 -1
- package/widgets/LayerList.d.ts +7 -4
- package/widgets/Legend/LegendViewModel.d.ts +5 -5
- package/widgets/Legend/support/ActiveLayerInfo.d.ts +5 -5
- package/widgets/Legend.d.ts +4 -4
- package/widgets/Popup/types.d.ts +3 -3
- package/widgets/Popup.d.ts +3 -3
- package/widgets/TableList/TableListViewModel.d.ts +2 -4
- package/widgets/TableList.d.ts +1 -1
- package/widgets/UtilityNetworkTrace/types.d.ts +1 -1
- package/assets/esri/core/workers/chunks/052ded41dc06c93ec0a7.js +0 -1
- package/assets/esri/core/workers/chunks/30184e39129d9c66ea54.js +0 -1
- package/assets/esri/core/workers/chunks/5340887a4a48bde3407a.js +0 -1
- package/assets/esri/core/workers/chunks/537de53ef1e9101468f5.js +0 -1
- package/assets/esri/core/workers/chunks/94f02082a006003ef5a9.js +0 -1
- package/assets/esri/core/workers/chunks/a1f264abbd6354c333bf.js +0 -1
- package/assets/esri/core/workers/chunks/d3db7244fac7398cc700.js +0 -1
- package/assets/esri/core/workers/chunks/d94a2ad5a91de7086fbe.js +0 -1
- package/assets/esri/core/workers/chunks/ed38c1043e6a83f49f93.js +0 -1
- package/geometry/geodesicUtils.d.ts +0 -19
- package/geometry/operators/support/geodeticCurveType.d.ts +0 -2
- package/geometry/operators/support/projectionTransformation.d.ts +0 -16
- package/geometry/support/MeshVertexSpace.d.ts +0 -4
- package/geometry/support/meshUtils/elevation.d.ts +0 -16
- package/geometry/support/meshUtils/elevationSampler.d.ts +0 -9
- package/geometry/support/meshUtils/georeference.d.ts +0 -10
- package/geometry/support/typeUtils.d.ts +0 -16
- package/smartMapping/popup/support/utils.d.ts +0 -13
- package/smartMapping/support/binningUtils.d.ts +0 -11
- package/smartMapping/support/clusterUtils.d.ts +0 -11
- package/smartMapping/support/utils.d.ts +0 -4
- package/views/2d/constraints/GeometryConstraint.d.ts +0 -4
- package/views/HitTestItem3D.d.ts +0 -20
- package/views/HitTestOptions.d.ts +0 -25
- package/views/IBreakpointsOwner.d.ts +0 -55
- package/views/IObjectId.d.ts +0 -2
- package/views/ISceneView.d.ts +0 -5
- package/views/IView.d.ts +0 -43
- package/views/input/IViewEvents.d.ts +0 -602
- /package/views/draw/input/{CursorUpdateEvents.d.ts → CursorUpdateEvent.d.ts} +0 -0
- /package/views/draw/input/{CursorUpdateEvents.js → CursorUpdateEvent.js} +0 -0
- /package/views/layers/{HighlightableLayerView.d.ts → types.d.ts} +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{EventEmitter as a}from"../../../../../core/Evented.js";import n from"../../../../../core/Handles.js";import{handlesGroup as o,makeHandle as s,destroyHandle as r}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as l,removeMaybe as p}from"../../../../../core/maybe.js";import{watch as h,on as d,initial as u,syncAndInitial as c,when as m,sync as g}from"../../../../../core/reactiveUtils.js";import{property as f,subclass as _}from"../../../../../core/accessorSupport/decorators.js";import{IDENTITY as v}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{b as M,e as b,l as x,h as y,i as O,j as E}from"../../../../../chunks/vec32.js";import{fromValues as j,create as I}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as S}from"../../../../../core/support/UpdatingHandles.js";import w from"../../../../../geometry/Point.js";import H from"../../../../../geometry/Polyline.js";import V from"../../../../../geometry/SpatialReference.js";import{makeDehydratedPoint as D}from"../../../../../layers/graphics/dehydratedPoint.js";import{isVolumetricSymbol as A}from"../../../../../symbols/support/utils.js";import{Manipulator3D as T}from"../../Manipulator3D.js";import{createManipulatorMaterial as G,createManipulatorOutlineMaterial as U,placeAtObject as P}from"../../manipulatorUtils.js";import{RenderObject as k}from"../../RenderObject.js";import{SegmentLabels3D as C}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as L}from"../../SnappingVisualizer3D.js";import{screenToMapXYAtLocation as R,screenToRenderPlaneFromEvent as z,convertToMapCoordinates as F}from"../dragEventPipeline3D.js";import{orientation as Z}from"../geometryUtils.js";import{canMoveZOperations as B}from"../manipulatorUtils.js";import{Settings as N}from"../settings.js";import{createVisualElements as q}from"../visualElementUtils.js";import{discRadiusSmall as X}from"../manipulations/config.js";import{MoveManipulation as Y}from"../manipulations/MoveManipulation.js";import{MoveXYObjectManipulation as W}from"../manipulations/MoveXYObjectManipulation.js";import{getMapPointAtEdgeOffsetManipulatorElevation as K,createEdgeOffsetIntersectionPlane as J,createEdgeOffsetOperation as Q,edgeOffsetRotationMatrix as $,screenEdgeLengthSquared as ee,getDistanceInGeometrySR as te}from"./edgeOffsetUtils.js";import{createTooltipInfos as ie,connectTooltipToManipulatedObject as ae,getUpdatedTranslateObjectTooltipInfo as ne,getUpdatedEdgeOffsetTooltipInfo as oe}from"./reshapeTooltipUtils3D.js";import{OutlineVisualElement as se}from"../../visualElements/OutlineVisualElement.js";import{createExtrudedTriangle as re,createSphereGeometry as le}from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as pe}from"../../../../input/IViewEvents.js";import{sceneSnappingAtLocation as he,addMapDelta as de,createManipulatorDragEventPipeline as ue,dragAtLocation as ce,addScreenDelta as me}from"../../../../interactive/dragEventPipeline.js";import{tooltipKeys as ge}from"../../../../interactive/keybindings.js";import{SnappingContext as fe}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as _e}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as ve,enterInputModeIfAvailable as Me}from"../../../../interactive/tooltip/tooltipCommonUtils.js";const be=Symbol();let xe=class extends t{get _operations(){return this.object.operations}constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new n,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=0,this._pendingEdgeOffsetInfo=null,this._updatingHandles=new S,this._recreatingManipulators=!1,this._settings=new N({getTheme:()=>this.view.effectiveTheme}),this.events=new a,this.activeTooltipInfo=null,this._vertexLaserLineVisualElement=null,this._tooltipCallbacks={onBeforeReshape:()=>this.tool.endDrag(),onReshapeStart:()=>this._updateEventState(2),onReshape:()=>this.events.emit("reshape",{type:"reshape",object:this.object}),onReshapeStop:()=>this._updateEventState(0,{forceEnd:!0}),onMoveStart:()=>this._updateEventState(1),onMove:()=>this.events.emit("move",{type:"move",object:this.object,dx:0,dy:0}),onMoveStop:()=>this._updateEventState(0,{forceEnd:!0})}}initialize(){const{view:e}=this,t=this._settings.manipulators,i=t.vertex;this.tooltipInfos=ie(this._sketchOptions,e),this._vertexManipulatorMaterial=G(i.color.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorOutlineMaterial=U(i.outlineColor.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=U(i.hoverOutlineColor.toUnitRGBA(),i.renderOccluded);const a=t.edge;this._edgeManipulatorMaterial=G(a.color.toUnitRGBA(),a.renderOccluded),this._edgeManipulatorOutlineMaterial=U(a.outlineColor.toUnitRGBA(),a.renderOccluded);const n=t.edgeOffset;this._edgeOffsetManipulatorMaterial=G(n.color.toUnitRGBA(),n.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=G(n.hoverColor.toUnitRGBA(),n.renderOccluded,!1);const o=t.selected;this._selectedManipulatorMaterial=G(o.color.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorOutlineMaterial=U(o.outlineColor.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=U(o.hoverOutlineColor.toUnitRGBA(),o.renderOccluded),this.tooltip=ve(()=>({view:e,options:this._sketchOptions.tooltips})),this.addHandles([h(()=>{const e=this._settings.manipulators;return{vertexSettings:e.vertex,edgeSettings:e.edge,edgeOffsetSettings:e.edgeOffset,selectedSettings:e.selected}},({vertexSettings:e,edgeSettings:t,edgeOffsetSettings:i,selectedSettings:a})=>{e.applyColor(this._vertexManipulatorMaterial),e.applyOutline(this._vertexManipulatorOutlineMaterial),e.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),t.applyColor(this._edgeManipulatorMaterial),t.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),a.applyColor(this._selectedManipulatorMaterial),a.applyOutline(this._selectedManipulatorOutlineMaterial),a.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)}),h(()=>this.object.visible,e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e,Ie(t)&&(t.edgeManipulator.available=e)}),h(()=>this._numGrabbing+this._numDragging===0,e=>this._toggleAutoHideManipulators(e)),h(()=>({labels:this._segmentLabels,enabled:this._sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset}),({labels:e,enabled:t,edgeOffsetEnabled:i})=>{null!=e&&(e.visible=t,e.edgeDistance=i?"far":"default")},u),ae(this.tooltip,this.object,()=>this._tooltipsContext),h(()=>this.tooltip.mode,(e,t)=>{"input"===t&&"input"!==e&&this._resetTooltip()}),d(()=>this._operations,"vertex-update",e=>this._updateManipulatorPositions(e.vertices),{onListenerAdd:()=>this._recreateManipulators()}),d(()=>this._operations?.data,"change",e=>{"undo"!==e.operation&&"redo"!==e.operation||this._recreateManipulators()})])}destroy(){this._removeManipulators(),this._updatingHandles.destroy(),this._segmentLabels=l(this._segmentLabels),this.tooltip=l(this.tooltip)}get updating(){return this._updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get automaticAreaMeasurementUtils(){return this.tool.automaticAreaMeasurementUtils}get automaticLengthMeasurementUtils(){return this.tool.automaticLengthMeasurementUtils}get object(){return this.tool.object}get enableZShape(){return this.tool.enableZShape}get enableDeleteVertices(){return this.tool.enableDeleteVertices}get enableZVertex(){return this.tool.enableZVertex}get autoHideManipulators(){return this.tool.autoHideManipulators}get enableMoveObject(){return this.tool.enableMoveObject}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}enterInputModeIfAvailable(e){return"key-down"===e.type&&e.key===ge.enterInputMode&&("reshape-edge-offset"===this.activeTooltipInfo?.type?this._enterInputModeDuringEdgeOffset(e):!!Me(e,this.tooltip)&&(this.tool.endDrag(),!0))}removeSelectedVertices(){const e=this._manipulatorInfos.filter(e=>e.manipulator.selected&&"vertex"===e.type);return this._removeVertices(e),e.length}onManipulatorSelectionChanged(){this.events.emit("manipulators-changed")}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=l(this._moveManipulation),this._objectMoveManipulation=l(this._objectMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._operations)return;const t=this.object.elevationInfo;for(const{vertices:i,segments:a,index:n}of this._operations.data.parts){const o=e?.byPartIndex.get(n);for(const e of i){const i=o?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of a)"line"===e.type&&this._createVertexOrEdgeManipulator(e,t)}this._createObjectMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}recordUndo(e){this._operations?.recordUndo(e)}get canRedo(){return this._operations?.canRedo??!1}get canUndo(){return this._operations?.canUndo??!1}redo(){return this._operations?.redo()}undo(){return this.events.emit("undo"),this._operations?.undo()}_recreateManipulators(){if(!this._recreatingManipulators){if(this._recreatingManipulators=!0,this._removeManipulators(),this._resetTooltip(),this._operations&&this._segmentLabels?.context?.editGeometryOperations===this._operations||(this._segmentLabels=l(this._segmentLabels)),this._createManipulators(),!this._segmentLabels&&this._operations){const e=this._sketchOptions.labels;this._segmentLabels=new C({context:{view:this.view,editGeometryOperations:this._operations,elevationInfo:this.object.elevationInfo,labelOptions:e,automaticLengthMeasurementUtils:this.automaticLengthMeasurementUtils},visible:e.enabled})}this._recreatingManipulators=!1}}_perObjectManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],n=this._manipulatorInfos.some(e=>"vertex"===e.type&&e.manipulator.selected),o=1===e&&n;for(const s of this._manipulatorInfos)"vertex"===s.type&&(s.manipulator.grabbing||o&&!s.manipulator.selected||a.push(s),i++);this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(1),this.destroyed)return t;this.events.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,object:this.object})}else{if(this._updateEventState(2),this.destroyed)return t;this.events.emit("reshape",{type:"reshape",object:this.object})}return t}_toggleAutoHideManipulators(e){this.autoHideManipulators&&(e?this.removeHandles(be):this.tool.manipulators.forEach(({manipulator:e})=>{const t=e.disableDisplay?.();t&&this.addHandles(t,be)}))}_isMultiVertexSelection(){return this._manipulatorInfos.reduce((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e,0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(2),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const n=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===e.info)&&n.push(o);this._moveVertices(n,e,1),this.events.emit("reshape",{type:"reshape",object:this.object})}_updateEventState(e,t={}){if(e===this._reshapeEventState)return!1;switch(e){case 0:if(!t.forceEnd&&(0!==this._numGrabbing||0!==this._numDragging))return!1;switch(this._reshapeEventState){case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object})}break;case 1:switch(this._reshapeEventState){case 0:this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object}),this.destroyed||this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object})}break;case 2:switch(this._reshapeEventState){case 0:this.events.emit("reshape",{type:"reshape-start",object:this.object});break;case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object}),this.destroyed||this.events.emit("reshape",{type:"reshape-start",object:this.object})}}if(this.destroyed)return!1;const i=this._reshapeEventState!==e;return this._reshapeEventState=e,i}_createObjectMoveManipulation(){const{tool:e,view:t,object:i,_operations:a}=this;if(a){if(this._objectMoveManipulation=new W({tool:e,view:t,object:i}),this.enableMoveObject){let e=null;this._manipulatorHandles.add(this._objectMoveManipulation.createDragPipeline((t,i,n)=>{i.next(e=>this._trackNumDragging(e)).next(t=>("start"===t.action&&(e=a.createUndoGroup()),t)).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(t=>{"end"===t.action&&(this._resetTooltip(),e=p(e))}),n.next(()=>this._onDragCancel(!0,()=>e=p(e)))})),this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1)))}else this._objectMoveManipulation.forEachManipulator(e=>{e.grabbable=!1,e.cursor=null});this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(e.events.on("immediate-click",e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})))}}_createMoveManipulation(e){const{object:t,tool:i,view:a,_operations:n}=this;if(!n)return;this._moveManipulation=new Y({tool:i,view:a,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&B(t.operations,t.elevationInfo),snapToScene:!1,radius:Y.radiusForSymbol(t.graphic?.symbol)}),this._moveManipulation.forEachManipulator(e=>this.addHandles([e.events.on("immediate-click",t=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some(e=>e.manipulator.selected)||this.events.emit("immediate-click",{...t,object:this.object}),t.stopPropagation()}),this._watchAndUpdateGrabState(e,!1)]));const o=e=>t=>{this.addHandles([t.events.on("focus-changed",({action:t})=>{"focus"===t?this._updateTranslateTooltip(e):this._resetTooltip()})])};this._moveManipulation.xyManipulation.forEachManipulator(o(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o(1)),this._moveManipulation.zManipulation.forEachManipulator(o(2)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=n.data.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline((a,o,s,r,l)=>{const{snappingStep:p,cancelSnapping:h}=_e({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new fe({editGeometryOperations:n,elevationInfo:e,pointer:l,excludeFeature:t.graphic,visualizer:new L}),updatingHandles:this._updatingHandles,useZ:!1});return r=r.next(e=>(this._onDragCancel(),e)).next(h),{steps:s=s.next(e=>this._trackNumDragging(e)).next(e=>{const t=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.manipulatorType&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e}).next(he(this.view,e,t.graphic??void 0)).next(...p).next(de()).next(e=>this._perObjectManipulatorDragAction(1,e)).next(e=>(this._updateTranslateTooltip(a,e),e)),cancel:r}},e,s,t.graphic),h(()=>t.visible,()=>this._updateMoveManipulationPosition(),u),t.on("committed",()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()}),h(()=>t.isDraped,e=>{this._updateMoveManipulationPosition();const t="align-move-manipulation";e?this.addHandles(this.view.elevationProvider.on("elevation-change",()=>this._updateMoveManipulationPosition()),t):this.removeHandles(t)},u)])}_createVisualElements(){const{object:e,view:t}=this,i=q({view:t,object:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._objectMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,1)}},onManipulatorsChanged:e=>this.events.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof se?i.visualElement:null);const a=this._outlineVisualElement;if(null!=a){const t=()=>{e.isDraped||this._updateMoveManipulationPosition()};this._manipulatorHandles.add(d(()=>a.events,"attachment-origin-changed",t,{onListenerAdd:t}))}this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=this.object.elevationInfo){const i=this.view,a=this._operations;if(e.part.vertices.length<=2||!a)return null;const n=a.data.spatialReference,s=this._settings.manipulators.edgeOffset,r=s.size/2,l=r+s.collisionPadding,p=r/l,h=p/2,d=p*Math.sqrt(3)/2,{height:u,offset:c}=s,m=this._edgeOffsetManipulatorMaterial;if(!this._edgeOffsetManipulatorGeometryInside){const e=re(m,d,h,h,u,c);this._edgeOffsetManipulatorGeometryInside=e}if(!this._edgeOffsetManipulatorGeometryOutside){const e=re(m,-d,h,h,u,-c);this._edgeOffsetManipulatorGeometryOutside=e}const g=[new k(this._edgeOffsetManipulatorGeometryInside.instantiate(),1),new k(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate(),1),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2)],f=new T({view:i,renderObjects:g,elevationInfo:"on-the-ground"!==t.mode||A(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:l,available:this.object.visible,collisionType:{type:"disc",direction:j(0,0,1)},collisionPriority:1,metadata:{deleting:!1},location:je(n)}),_=new T({view:i,worldSized:!0,worldOriented:!1,available:this.object.visible,collisionPriority:-10,cursor:this.enableMoveObject?"move":"default",metadata:{deleting:!1},location:je(n)}),v={manipulator:f,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:_,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(v,s.minSquaredEdgeLength);const M=()=>this._updateEdgeOffsetManipulator(v);M(),v.locationUpdateHandle=o([e.leftVertex,e.rightVertex].map(e=>{const t=this._getManipulatorInfoFromHandle(e);return t?.manipulator.events.on("location-update",M)}));const b=e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()};return this._manipulatorHandles.add([v.locationUpdateHandle,this._watchAndUpdateGrabState(f,!0),this._watchAndUpdateGrabState(_,!0),ue(f,this._createEdgeOffsetPipeline(v,t,a)),ue(_,this._createEdgePipeline(v,t,a)),_.events.on("immediate-click",b),f.events.on("immediate-click",b),f.events.on("focus-changed",()=>this._resetTooltip()),f.events.on("grab-changed",({screenPoint:e,action:t})=>{v.grabMapPoint="start"===t?K(e,this.view,this.object,v):null})],f),this._manipulatorInfos.push(v),this.manipulators.addMany([f,_]),this.events.emit("manipulators-changed"),v}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,a=e.edgeManipulator,n=()=>{e.visibilityHandle=p(e.visibilityHandle);const n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=n&&null!=r&&ee(n.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||l)&&(i.grabbable=!l,a.grabbable=!l,e.visibilityHandle=o([i.disableDisplay(),s(()=>{i.grabbable=!0,a.grabbable=this.enableMoveObject})]))};this._manipulatorHandles.add([i.events.on("focus-changed",n),a.events.on("focus-changed",n),s(()=>{p(e.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)})],i),n()}_updateEdgeOffsetManipulator(e){if(!this._operations)return;this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._operations.data,i=J(this.view,e.manipulator.elevationAlignedLocation,Q(t,e.handle,e.manipulator.elevationInfo)),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==a||null==n)return;const o=a.manipulator.renderLocation,s=n.manipulator.renderLocation,r=null!=i?$(i,o,s):v;e.manipulator.modelTransform=r,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=r;const l=M(b(we,o,s))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgePipeline(e,t,i){return(a,n,o,s)=>{if("touch"===s){this._createEdgeOffsetPipeline(e,t,i)(a,n,o)}else if(this.enableMoveObject){const e=this.object.graphic,s=i.data.spatialReference,{elevationAlignedLocation:r}=a;n.next(e=>this._trackNumDragging(e)).next(ce(this.view,r)).next(R(this.view,r,t,s,e)).next(me()).next(de()).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(e=>{"end"===e.action&&this._resetTooltip()}),o.next(()=>this._onDragCancel(!a.metadata.deleting))}}}_createEdgeOffsetPipeline(e,t,i){return(a,n,o)=>{const s=this._pendingEdgeOffsetInfo;if(s?.manipulatorInfo===e&&"drag"!==s.mode)return void o.execute({action:"cancel"});this._clearSelection();const{initializeStep:r,cleanup:l}=this._initializeEdgeOffset(e,t,i,o),p=this._applyEdgeOffsetStep(e);n.next(e=>this._trackNumDragging(e)).next(ce(this.view,a.elevationAlignedLocation)).next(r).next(z(this.view)).next(F(this.view,i.data.spatialReference)).next(de()).next(ye()).next(e=>this._pendingEdgeOffsetInfo?e:p(e)).next(e=>{"end"!==e.action||this._pendingEdgeOffsetInfo||l()}),o.next(()=>{this._exitEdgeOffsetInputMode(),a.metadata.deleting||(l(),this._onDragCancel())})}}_initializeEdgeOffset(e,t,i,a){const{view:n,object:s}=this,r=Q(i.data.coordinateHelper,e.handle,t),l=i.createUndoGroup(),h=J(n,e.manipulator.elevationAlignedLocation,r);let d;this._splitEdgesBeforeEdgeOffset(e,r),this._selectEdgeOffsetArrow(e,r);const u=()=>{this._cleanEdgeOffsetCollapsedEdges(e,i),d=p(d)},c=this.events.on("undo",u);return d=o([this._initializeEdgeOffsetVisualElement(e,s,t,i),l,c,this._connectEdgeOffsetTooltip(e,r,i,()=>{a.execute({action:"cancel"})})]),{initializeStep:e=>null==r||null==h?(u(),null):{...e,operation:r,plane:h},cleanup:u}}_initializeEdgeOffsetVisualElement(e,t,i,a){const n=()=>new H({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:a.data.spatialReference}),s=new se({view:this.view,isDraped:t.isDraped,geometry:n(),elevationInfo:i,width:this._settings.visualElements.lineObjects.outline.width,attached:!1,isDecoration:!0}),l=o([h(()=>({color:this._accentColor,draped:t.isDraped}),({color:e,draped:t})=>{s.color=e.toUnitRGBA(),s.isDraped=t},c),t.on("committed",()=>{s.geometry=n()}),r(s)]);return s.attached=!0,l}_applyEdgeOffsetStep(e){return t=>(this.destroyed||null==t.operation||!this._operations||(this._updateEventState(2),null==t.signedDistance?this._resetTooltip():((t.mapDeltaX||t.mapDeltaY||t.mapDeltaZ)&&(this._offsetEdge(e,t.operation,t.signedDistance),this.events.emit("reshape",{type:"reshape",object:this.object})),this._updateEdgeOffsetTooltip(t))),t)}_cleanEdgeOffsetCollapsedEdges(e,t){const i=e.handle.leftVertex.leftSegment?.leftVertex,a=e.handle.leftVertex,n=e.handle.rightVertex.rightSegment?.rightVertex,o=e.handle.rightVertex,s=t.data.coordinateHelper,r=this.view.pixelSizeAt(s.vectorToDehydratedPoint(a.pos),s.spatialReference),l=[];if(i&&s.distance(i.pos,a.pos)<He){const e=this._getManipulatorInfoFromHandle(a);null!=e&&l.push(e)}if(s.distance(a.pos,o.pos)<r||n&&s.distance(n.pos,o.pos)<He){const e=this._getManipulatorInfoFromHandle(o);null!=e&&l.push(e)}l.length&&this._removeVertices(l)}_enterInputModeDuringEdgeOffset(e){const t=this._findActiveEdgeOffsetManipulatorInfo();return!!t&&(!!Me(e,this.tooltip)&&(t.manipulator.dragging?(this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"drag"},!0):(this._clearSelection(),this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"hover"},this._connectEdgeOffsetTooltipOnHover(t),!0)))}_exitEdgeOffsetInputMode(){this.tooltip&&(this._pendingEdgeOffsetInfo=null,this._resetTooltip(),this.tooltip.exitInputMode())}_findActiveEdgeOffsetManipulatorInfo(){return this._manipulatorInfos.filter(Ie).find(({manipulator:e})=>e.hovering||e.grabbing||e.dragging)}_connectEdgeOffsetTooltipOnHover(e){const{_operations:t,object:i}=this;if(!t)return;const{elevationInfo:a}=i,n=Q(t.data.coordinateHelper,e.handle,a);this._selectEdgeOffsetArrow(e,n),this.addHandles([this._initializeEdgeOffsetVisualElement(e,i,a,t),this._connectEdgeOffsetTooltip(e,n,t,()=>{this.removeHandles(n),this._exitEdgeOffsetInputMode()})],n)}_splitEdgesBeforeEdgeOffset(e,t){if(t.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftSegment);null!=t&&this._splitEdgeManipulator(t,1)}if(t.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightSegment);null!=t&&this._splitEdgeManipulator(t,0)}}_selectEdgeOffsetArrow(e,t){const i=e.grabMapPoint??K(this.view.inputManager?.latestPointerInfo?.location,this.view,this.object,e);i&&t.selectArrowFromStartPoint(i)}_connectEdgeOffsetTooltip(e,t,i,a){const n=()=>this.tooltipInfos.edgeOffset.distance.actual,s=n=>{a(),queueMicrotask(()=>{this.view.focus();const a=i.createUndoGroup();this._tooltipCallbacks.onReshapeStart?.(),this._splitEdgesBeforeEdgeOffset(e,t),this._offsetEdge(e,t,te(n,e.manipulator.location,t,i)),this._tooltipCallbacks.onReshape?.(),this._tooltipCallbacks.onReshapeStop?.(),this._cleanEdgeOffsetCollapsedEdges(e,i),a.remove()})},r=()=>{const e=n();null!=e?s(e):a()};return o([m(()=>this.tooltip&&!this.tooltip.focused,()=>r(),g),this.tooltip.on("discard",a),this.tooltip.on("commit",e=>{"commit-and-exit"===e.type&&r()})])}_createVertexOrEdgeManipulator(e,t=this.object.elevationInfo,i=!1){const a=this.view,n=this._operations,s=this._settings;if(!n)return null;const r=n.data.type,l=n.data.spatialReference;if("line"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=Oe(s.manipulators.vertex);this._vertexManipulatorGeometry=le(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=le(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=Oe(s.manipulators.edge);this._edgeManipulatorGeometry=le(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=le(this._edgeManipulatorOutlineMaterial,t,16,16)}const h="point"===r||"mesh"===r?[]:[new k(this._vertexManipulatorGeometry.instantiate(),4|Ve),new k(this._vertexManipulatorOutlineGeometry.instantiate(),5|Ve),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|Ve),new k(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),8),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),9),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),10)];this.enableMidpoints&&h.push(new k(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),6|De),new k(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|De),new k(this._edgeManipulatorGeometry.instantiate(),5|De),new k(this._edgeManipulatorOutlineGeometry.instantiate(),5|De));const d=new T({view:a,renderObjects:h,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:this.object.visible,metadata:{deleting:!1},location:je(l)});d.selected=i,this._setTypeSpecificManipulatorSettings(d,e,t);const u="vertex"===e.type?{manipulator:d,handle:e,type:"vertex",selectedIndex:0}:{manipulator:d,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0};if(this._manipulatorInfos.push(u),this.manipulators.add(d),this._updateManipulatorPosition(u),"edge"===u.type){const e=[];for(const t of[u.handle.leftVertex,u.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",()=>this._updateManipulatorPosition(u)))}u.locationUpdateHandle=o(e),this._manipulatorHandles.add(u.locationUpdateHandle,d)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(d,!0),d);const c=ue(d,(e,i,o,s)=>{let r=null;const{snappingStep:h,cancelSnapping:d}=_e({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new fe({editGeometryOperations:n,elevationInfo:t,pointer:s,excludeFeature:this.object.graphic,visualizer:new L}),updatingHandles:this._updatingHandles,useZ:!1});o=o.next(t=>(this._onDragCancel(!e.metadata.deleting,()=>r=p(r)),t)).next(d);const{elevationAlignedLocation:c}=e,m=this.object.graphic??void 0;i.next(e=>this._trackNumDragging(e)).next(e=>{if("start"===e.action&&n&&(r=n.createUndoGroup()),"edge"===u.type){const t=this._splitEdgeManipulator(u);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:u,snapOrigin:u.handle.pos}}).next(ce(a,c)).next(R(a,c,t,l,m)).next(he(a,t,m)).next(...h).next(de()).next(e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(r=p(r)),this._resetTooltip()})});return this._manipulatorHandles.add([c,d.events.on("immediate-click",e=>this._manipulatorClickCallback(e,u)),d.events.on("select-changed",()=>{u.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition(),this._resetTooltip()}),d.events.on("focus-changed",()=>{this._resetTooltip()})],d),this.events.emit("manipulators-changed"),u}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&this.undo(),this.tool.snappingManager?.doneSnapping(),this._resetTooltip(),this._reshapeEventState){case 0:break;case 1:this.events.emit("move",{type:"move",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape",object:this.object})}t?.(),this.destroyed||this._updateEventState(0)}_setTypeSpecificManipulatorSettings(e,t,i){const a=this._settings;switch(t.type){case"vertex":{e.state=Ve,e.selectable=!0,e.cursor="move",e.collisionPriority=2;const{size:t,collisionPadding:n}=a.manipulators.vertex;e.radius=t/2+n,e.elevationInfo=i;const o=this._operations?.data.type;e.interactive=null!=o&&"point"!==o&&"mesh"!==o;break}case"line":{e.state=De,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1;const{size:t,collisionPadding:n}=a.manipulators.edge;e.radius=t/2+n,e.elevationInfo="on-the-ground"!==i.mode||A(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",i=>{this._onGrabStateChanged(e,t,i.action,i.pointerType)})}_onGrabStateChanged(e,t,i,a="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(0),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach(e=>{const{manipulator:t}=e,i=this._operations?.data.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=i&&"point"!==i&&"mesh"!==i,Ie(e)&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)}),this._objectMoveManipulation.forEachManipulator(e=>{e.interactive=e.grabbing||!this._numGrabbing}))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1);this._pendingEdgeOffsetInfo=null}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.events.emit("manipulators-changed"))}_removeManipulator(e){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),this.events.emit("manipulators-changed"),this._resetTooltip())}_getManipulatorInfoFromHandle(e){return this._manipulatorInfos.find(t=>t.handle===e)}_updateManipulatorPositions(e){for(const t of e)this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t))}_updateManipulatorPosition(e){const t=this._operations;if(null!=e&&t)if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,Se),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==a)return;const n=i.manipulator,o=a.manipulator;if("on-the-ground"===e.manipulator.elevationInfo?.mode){const i=n.location,a=o.location,s=.5,r=i.x+s*(a.x-i.x),l=i.y+s*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;e.manipulator.location=D(r,l,p,t.data.spatialReference)}else x(we,n.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=we}}_splitEdgeManipulator(e,t=.5){const i=this._operations,a=i.splitSegment(e.handle,t).createdVertex;e.locationUpdateHandle=p(e.locationUpdateHandle);const n=this.object.elevationInfo;let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(a)):(o=e,o.handle=a,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,n)),"line"===a.leftSegment?.type&&this._createVertexOrEdgeManipulator(a.leftSegment),"line"===a.rightSegment?.type&&this._createVertexOrEdgeManipulator(a.rightSegment),this._updateManipulatorPosition(o),this.enableEdgeOffset||this._resetTooltip(),this._updateSelection(e.manipulator);const s=this._updateEventState(2),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.parts.indexOf(a.part);return this.events.emit("vertex-add",{type:"vertex-add",object:this.object,vertices:[{coordinates:r,componentIndex:l,vertexIndex:a.index}],added:r}),s&&this._updateEventState(0),o}_updateMoveManipulationPosition(){const e=y(we,0,0,0);let t=0,i=!1,a=null,n=null;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.selected?(t++,O(e,e,r.manipulator.renderLocation),null==a||r.selectedIndex>a.selectedIndex?(n=a,a=r):(null==n||r.selectedIndex>n.selectedIndex)&&(n=r)):i=!0);const o=this.object,s=this._operations?.data.geometry;if(0===t){const e=o.visible&&this.enableMoveObject;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&B(this._operations,o.elevationInfo),this._moveManipulation.angle=Z(s),this._moveManipulation.radius=Y.radiusForSymbol(o.graphic?.symbol)}else{const e=o.visible;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&B(this._operations,this.object.elevationInfo),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=a){const e=a.handle.pos,t=null!=n?n.handle.pos:a.handle.leftSegment?.leftVertex?a.handle.leftSegment.leftVertex.pos:null,o=null==n&&a.handle.rightSegment?.rightVertex?a.handle.rightSegment.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=Ee(t,e):o&&(i=Ee(e,o))}this._moveManipulation.angle=i,this._moveManipulation.radius=X}0!==t&&i?(E(e,e,1/t),Se.spatialReference=this._operations.data.spatialReference,Se.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,Se),this._moveManipulation.elevationAlignedLocation=Se):null==this._outlineVisualElement||this.object.isDraped||null==this._outlineVisualElement.attachmentOrigin?P(this._moveManipulation,this.object):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=this._operations;if(i){for(const a of e){const e=a.handle.part;if("vertex"===a.type&&i.canRemoveVertex(e)){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftSegment)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightSegment));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdSegment;o&&"line"===o.type?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&e.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(e.segments[0]))}}if(t.length>0){const e=t.map(e=>{const t=i.data.parts.indexOf(e.part);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:e.index}}),a=this._updateEventState(2);if(this.destroyed)return;if(this.events.emit("vertex-remove",{type:"vertex-remove",object:this.object,removed:e.map(e=>e.coordinates),vertices:e}),this.destroyed)return;if(a&&(this._updateEventState(0),this.destroyed))return;this._updateMoveManipulationPosition()}}}_moveVertices(e,t,i=("start"===t.action?0:1)){const a=this._operations;if(a){e.length>0&&a.moveVertices(e.map(e=>e.handle),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);for(const t of e)this._updateManipulatorPosition(t)}}_offsetEdge(e,t,i){if(!this._operations)return;const a=t.clone();a.distance=i,this._operations.updateVertices([e.handle.leftVertex,e.handle.rightVertex],a),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,this.enableDeleteVertices&&e.button===pe.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===pe.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){null!=this._defaultTooltipInfo?this._resetTooltip():this._updateTranslateObjectTooltip(e,t)}_updateTranslateObjectTooltip(e,t){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=ne(e,t,this._tooltipsContext))}_updateEdgeOffsetTooltip(e){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=oe(this.object,e,this._tooltipsContext))}_resetTooltip(){const e=this.activeTooltipInfo;if(this._pendingEdgeOffsetInfo&&"reshape-edge-offset"===e?.type)return;let t=null;t=this._pendingEdgeOffsetInfo||null!=this._findActiveEdgeOffsetManipulatorInfo()?oe(this.object,null,this._tooltipsContext):this._defaultTooltipInfo,t!==e&&(null!=e&&null!=t&&"input"===this.tooltip.mode||(this.activeTooltipInfo=t))}get _defaultTooltipInfo(){const e=this._operations?.data.type;switch(e){case"polyline":case"polygon":return this._selectedVertexManipulatorInfo?this.tooltipInfos.selectedVertex:null;case"point":case"mesh":return this.tooltipInfos.movePoint;default:return null}}get _selectedVertexManipulatorInfo(){const e=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.length?e[0]:null}get _tooltipsContext(){const{tooltipInfos:e,activeTooltipInfo:t,automaticAreaMeasurementUtils:i,automaticLengthMeasurementUtils:a}=this;return{sketchOptions:this._sketchOptions,tooltipInfos:e,activeTooltipInfo:t,selectedVertexManipulatorInfo:this._selectedVertexManipulatorInfo,callbacks:this._tooltipCallbacks,automaticAreaMeasurementUtils:i,automaticLengthMeasurementUtils:a}}get test(){}};function ye(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:{...e,signedDistance:t.signedDistanceToPoint(i)}}}function Oe(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}function Ee(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function je(e){return new w({x:0,y:0,z:0,spatialReference:e})}function Ie(e){return"edge"===e.type&&"edgeManipulator"in e}e([f()],xe.prototype,"_numGrabbing",void 0),e([f()],xe.prototype,"_numDragging",void 0),e([f()],xe.prototype,"_pendingEdgeOffsetInfo",void 0),e([f()],xe.prototype,"_operations",null),e([f()],xe.prototype,"_segmentLabels",void 0),e([f({constructOnly:!0})],xe.prototype,"tool",void 0),e([f()],xe.prototype,"tooltip",void 0),e([f()],xe.prototype,"activeTooltipInfo",void 0),e([f({readOnly:!0})],xe.prototype,"updating",null),e([f()],xe.prototype,"manipulators",null),e([f()],xe.prototype,"view",null),e([f()],xe.prototype,"automaticAreaMeasurementUtils",null),e([f()],xe.prototype,"automaticLengthMeasurementUtils",null),e([f()],xe.prototype,"object",null),e([f()],xe.prototype,"enableZShape",null),e([f()],xe.prototype,"enableDeleteVertices",null),e([f()],xe.prototype,"enableZVertex",null),e([f()],xe.prototype,"autoHideManipulators",null),e([f()],xe.prototype,"enableMoveObject",null),e([f()],xe.prototype,"enableMidpoints",null),e([f()],xe.prototype,"enableEdgeOffset",null),e([f()],xe.prototype,"_sketchOptions",null),e([f()],xe.prototype,"_accentColor",null),e([f()],xe.prototype,"_tooltipsContext",null),xe=e([_("esri.views.3d.interactive.editingTools.reshape.ReshapeOperation")],xe);const Se=D(0,0,void 0,V.WGS84),we=I(),He=1e-6,Ve=16,De=32;export{xe as ReshapeOperation};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{EventEmitter as a}from"../../../../../core/Evented.js";import n from"../../../../../core/Handles.js";import{handlesGroup as o,makeHandle as s,destroyHandle as r}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as l,removeMaybe as p}from"../../../../../core/maybe.js";import{watch as h,on as d,initial as u,syncAndInitial as c,when as m,sync as g}from"../../../../../core/reactiveUtils.js";import{property as f,subclass as _}from"../../../../../core/accessorSupport/decorators.js";import{IDENTITY as v}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{b as M,e as b,l as x,h as y,i as O,j as E}from"../../../../../chunks/vec32.js";import{fromValues as j,create as I}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as S}from"../../../../../core/support/UpdatingHandles.js";import w from"../../../../../geometry/Point.js";import H from"../../../../../geometry/Polyline.js";import V from"../../../../../geometry/SpatialReference.js";import{makeDehydratedPoint as D}from"../../../../../layers/graphics/dehydratedPoint.js";import{isVolumetricSymbol as A}from"../../../../../symbols/support/utils.js";import{Manipulator3D as T}from"../../Manipulator3D.js";import{createManipulatorMaterial as G,createManipulatorOutlineMaterial as U,placeAtObject as P}from"../../manipulatorUtils.js";import{RenderObject as k}from"../../RenderObject.js";import{SegmentLabels3D as C}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as L}from"../../SnappingVisualizer3D.js";import{screenToMapXYAtLocation as R,screenToRenderPlaneFromEvent as z,convertToMapCoordinates as F}from"../dragEventPipeline3D.js";import{orientation as Z}from"../geometryUtils.js";import{canMoveZOperations as B}from"../manipulatorUtils.js";import{Settings as N}from"../settings.js";import{createVisualElements as q}from"../visualElementUtils.js";import{discRadiusSmall as X}from"../manipulations/config.js";import{MoveManipulation as Y}from"../manipulations/MoveManipulation.js";import{MoveXYObjectManipulation as W}from"../manipulations/MoveXYObjectManipulation.js";import{getMapPointAtEdgeOffsetManipulatorElevation as K,createEdgeOffsetIntersectionPlane as J,createEdgeOffsetOperation as Q,edgeOffsetRotationMatrix as $,screenEdgeLengthSquared as ee,getDistanceInGeometrySR as te}from"./edgeOffsetUtils.js";import{createTooltipInfos as ie,connectTooltipToManipulatedObject as ae,getUpdatedTranslateObjectTooltipInfo as ne,getUpdatedEdgeOffsetTooltipInfo as oe}from"./reshapeTooltipUtils3D.js";import{OutlineVisualElement as se}from"../../visualElements/OutlineVisualElement.js";import{createExtrudedTriangle as re,createSphereGeometry as le}from"../../../webgl-engine/lib/GeometryUtil.js";import{mouseButtons as pe}from"../../../../input/mouseButtons.js";import{sceneSnappingAtLocation as he,addMapDelta as de,createManipulatorDragEventPipeline as ue,dragAtLocation as ce,addScreenDelta as me}from"../../../../interactive/dragEventPipeline.js";import{tooltipKeys as ge}from"../../../../interactive/keybindings.js";import{SnappingContext as fe}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as _e}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as ve,enterInputModeIfAvailable as Me}from"../../../../interactive/tooltip/tooltipCommonUtils.js";const be=Symbol();let xe=class extends t{get _operations(){return this.object.operations}constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new n,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=0,this._pendingEdgeOffsetInfo=null,this._updatingHandles=new S,this._recreatingManipulators=!1,this._settings=new N({getTheme:()=>this.view.effectiveTheme}),this.events=new a,this.activeTooltipInfo=null,this._vertexLaserLineVisualElement=null,this._tooltipCallbacks={onBeforeReshape:()=>this.tool.endDrag(),onReshapeStart:()=>this._updateEventState(2),onReshape:()=>this.events.emit("reshape",{type:"reshape",object:this.object}),onReshapeStop:()=>this._updateEventState(0,{forceEnd:!0}),onMoveStart:()=>this._updateEventState(1),onMove:()=>this.events.emit("move",{type:"move",object:this.object,dx:0,dy:0}),onMoveStop:()=>this._updateEventState(0,{forceEnd:!0})}}initialize(){const{view:e}=this,t=this._settings.manipulators,i=t.vertex;this.tooltipInfos=ie(this._sketchOptions,e),this._vertexManipulatorMaterial=G(i.color.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorOutlineMaterial=U(i.outlineColor.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=U(i.hoverOutlineColor.toUnitRGBA(),i.renderOccluded);const a=t.edge;this._edgeManipulatorMaterial=G(a.color.toUnitRGBA(),a.renderOccluded),this._edgeManipulatorOutlineMaterial=U(a.outlineColor.toUnitRGBA(),a.renderOccluded);const n=t.edgeOffset;this._edgeOffsetManipulatorMaterial=G(n.color.toUnitRGBA(),n.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=G(n.hoverColor.toUnitRGBA(),n.renderOccluded,!1);const o=t.selected;this._selectedManipulatorMaterial=G(o.color.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorOutlineMaterial=U(o.outlineColor.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=U(o.hoverOutlineColor.toUnitRGBA(),o.renderOccluded),this.tooltip=ve(()=>({view:e,options:this._sketchOptions.tooltips})),this.addHandles([h(()=>{const e=this._settings.manipulators;return{vertexSettings:e.vertex,edgeSettings:e.edge,edgeOffsetSettings:e.edgeOffset,selectedSettings:e.selected}},({vertexSettings:e,edgeSettings:t,edgeOffsetSettings:i,selectedSettings:a})=>{e.applyColor(this._vertexManipulatorMaterial),e.applyOutline(this._vertexManipulatorOutlineMaterial),e.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),t.applyColor(this._edgeManipulatorMaterial),t.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),a.applyColor(this._selectedManipulatorMaterial),a.applyOutline(this._selectedManipulatorOutlineMaterial),a.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)}),h(()=>this.object.visible,e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e,Ie(t)&&(t.edgeManipulator.available=e)}),h(()=>this._numGrabbing+this._numDragging===0,e=>this._toggleAutoHideManipulators(e)),h(()=>({labels:this._segmentLabels,enabled:this._sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset}),({labels:e,enabled:t,edgeOffsetEnabled:i})=>{null!=e&&(e.visible=t,e.edgeDistance=i?"far":"default")},u),ae(this.tooltip,this.object,()=>this._tooltipsContext),h(()=>this.tooltip.mode,(e,t)=>{"input"===t&&"input"!==e&&this._resetTooltip()}),d(()=>this._operations,"vertex-update",e=>this._updateManipulatorPositions(e.vertices),{onListenerAdd:()=>this._recreateManipulators()}),d(()=>this._operations?.data,"change",e=>{"undo"!==e.operation&&"redo"!==e.operation||this._recreateManipulators()})])}destroy(){this._removeManipulators(),this._updatingHandles.destroy(),this._segmentLabels=l(this._segmentLabels),this.tooltip=l(this.tooltip)}get updating(){return this._updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get automaticAreaMeasurementUtils(){return this.tool.automaticAreaMeasurementUtils}get automaticLengthMeasurementUtils(){return this.tool.automaticLengthMeasurementUtils}get object(){return this.tool.object}get enableZShape(){return this.tool.enableZShape}get enableDeleteVertices(){return this.tool.enableDeleteVertices}get enableZVertex(){return this.tool.enableZVertex}get autoHideManipulators(){return this.tool.autoHideManipulators}get enableMoveObject(){return this.tool.enableMoveObject}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}enterInputModeIfAvailable(e){return"key-down"===e.type&&e.key===ge.enterInputMode&&("reshape-edge-offset"===this.activeTooltipInfo?.type?this._enterInputModeDuringEdgeOffset(e):!!Me(e,this.tooltip)&&(this.tool.endDrag(),!0))}removeSelectedVertices(){const e=this._manipulatorInfos.filter(e=>e.manipulator.selected&&"vertex"===e.type);return this._removeVertices(e),e.length}onManipulatorSelectionChanged(){this.events.emit("manipulators-changed")}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=l(this._moveManipulation),this._objectMoveManipulation=l(this._objectMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._operations)return;const t=this.object.elevationInfo;for(const{vertices:i,segments:a,index:n}of this._operations.data.parts){const o=e?.byPartIndex.get(n);for(const e of i){const i=o?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of a)"line"===e.type&&this._createVertexOrEdgeManipulator(e,t)}this._createObjectMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}recordUndo(e){this._operations?.recordUndo(e)}get canRedo(){return this._operations?.canRedo??!1}get canUndo(){return this._operations?.canUndo??!1}redo(){return this._operations?.redo()}undo(){return this.events.emit("undo"),this._operations?.undo()}_recreateManipulators(){if(!this._recreatingManipulators){if(this._recreatingManipulators=!0,this._removeManipulators(),this._resetTooltip(),this._operations&&this._segmentLabels?.context?.editGeometryOperations===this._operations||(this._segmentLabels=l(this._segmentLabels)),this._createManipulators(),!this._segmentLabels&&this._operations){const e=this._sketchOptions.labels;this._segmentLabels=new C({context:{view:this.view,editGeometryOperations:this._operations,elevationInfo:this.object.elevationInfo,labelOptions:e,automaticLengthMeasurementUtils:this.automaticLengthMeasurementUtils},visible:e.enabled})}this._recreatingManipulators=!1}}_perObjectManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],n=this._manipulatorInfos.some(e=>"vertex"===e.type&&e.manipulator.selected),o=1===e&&n;for(const s of this._manipulatorInfos)"vertex"===s.type&&(s.manipulator.grabbing||o&&!s.manipulator.selected||a.push(s),i++);this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(1),this.destroyed)return t;this.events.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,object:this.object})}else{if(this._updateEventState(2),this.destroyed)return t;this.events.emit("reshape",{type:"reshape",object:this.object})}return t}_toggleAutoHideManipulators(e){this.autoHideManipulators&&(e?this.removeHandles(be):this.tool.manipulators.forEach(({manipulator:e})=>{const t=e.disableDisplay?.();t&&this.addHandles(t,be)}))}_isMultiVertexSelection(){return this._manipulatorInfos.reduce((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e,0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(2),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const n=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===e.info)&&n.push(o);this._moveVertices(n,e,1),this.events.emit("reshape",{type:"reshape",object:this.object})}_updateEventState(e,t={}){if(e===this._reshapeEventState)return!1;switch(e){case 0:if(!t.forceEnd&&(0!==this._numGrabbing||0!==this._numDragging))return!1;switch(this._reshapeEventState){case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object})}break;case 1:switch(this._reshapeEventState){case 0:this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object}),this.destroyed||this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object})}break;case 2:switch(this._reshapeEventState){case 0:this.events.emit("reshape",{type:"reshape-start",object:this.object});break;case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object}),this.destroyed||this.events.emit("reshape",{type:"reshape-start",object:this.object})}}if(this.destroyed)return!1;const i=this._reshapeEventState!==e;return this._reshapeEventState=e,i}_createObjectMoveManipulation(){const{tool:e,view:t,object:i,_operations:a}=this;if(a){if(this._objectMoveManipulation=new W({tool:e,view:t,object:i}),this.enableMoveObject){let e=null;this._manipulatorHandles.add(this._objectMoveManipulation.createDragPipeline((t,i,n)=>{i.next(e=>this._trackNumDragging(e)).next(t=>("start"===t.action&&(e=a.createUndoGroup()),t)).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(t=>{"end"===t.action&&(this._resetTooltip(),e=p(e))}),n.next(()=>this._onDragCancel(!0,()=>e=p(e)))})),this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1)))}else this._objectMoveManipulation.forEachManipulator(e=>{e.grabbable=!1,e.cursor=null});this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(e.events.on("immediate-click",e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})))}}_createMoveManipulation(e){const{object:t,tool:i,view:a,_operations:n}=this;if(!n)return;this._moveManipulation=new Y({tool:i,view:a,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&B(t.operations,t.elevationInfo),snapToScene:!1,radius:Y.radiusForSymbol(t.graphic?.symbol)}),this._moveManipulation.forEachManipulator(e=>this.addHandles([e.events.on("immediate-click",t=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some(e=>e.manipulator.selected)||this.events.emit("immediate-click",{...t,object:this.object}),t.stopPropagation()}),this._watchAndUpdateGrabState(e,!1)]));const o=e=>t=>{this.addHandles([t.events.on("focus-changed",({action:t})=>{"focus"===t?this._updateTranslateTooltip(e):this._resetTooltip()})])};this._moveManipulation.xyManipulation.forEachManipulator(o(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o(1)),this._moveManipulation.zManipulation.forEachManipulator(o(2)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=n.data.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline((a,o,s,r,l)=>{const{snappingStep:p,cancelSnapping:h}=_e({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new fe({editGeometryOperations:n,elevationInfo:e,pointer:l,excludeFeature:t.graphic,visualizer:new L}),updatingHandles:this._updatingHandles,useZ:!1});return r=r.next(e=>(this._onDragCancel(),e)).next(h),{steps:s=s.next(e=>this._trackNumDragging(e)).next(e=>{const t=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.manipulatorType&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e}).next(he(this.view,e,t.graphic??void 0)).next(...p).next(de()).next(e=>this._perObjectManipulatorDragAction(1,e)).next(e=>(this._updateTranslateTooltip(a,e),e)),cancel:r}},e,s,t.graphic),h(()=>t.visible,()=>this._updateMoveManipulationPosition(),u),t.on("committed",()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()}),h(()=>t.isDraped,e=>{this._updateMoveManipulationPosition();const t="align-move-manipulation";e?this.addHandles(this.view.elevationProvider.on("elevation-change",()=>this._updateMoveManipulationPosition()),t):this.removeHandles(t)},u)])}_createVisualElements(){const{object:e,view:t}=this,i=q({view:t,object:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._objectMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,1)}},onManipulatorsChanged:e=>this.events.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof se?i.visualElement:null);const a=this._outlineVisualElement;if(null!=a){const t=()=>{e.isDraped||this._updateMoveManipulationPosition()};this._manipulatorHandles.add(d(()=>a.events,"attachment-origin-changed",t,{onListenerAdd:t}))}this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=this.object.elevationInfo){const i=this.view,a=this._operations;if(e.part.vertices.length<=2||!a)return null;const n=a.data.spatialReference,s=this._settings.manipulators.edgeOffset,r=s.size/2,l=r+s.collisionPadding,p=r/l,h=p/2,d=p*Math.sqrt(3)/2,{height:u,offset:c}=s,m=this._edgeOffsetManipulatorMaterial;if(!this._edgeOffsetManipulatorGeometryInside){const e=re(m,d,h,h,u,c);this._edgeOffsetManipulatorGeometryInside=e}if(!this._edgeOffsetManipulatorGeometryOutside){const e=re(m,-d,h,h,u,-c);this._edgeOffsetManipulatorGeometryOutside=e}const g=[new k(this._edgeOffsetManipulatorGeometryInside.instantiate(),1),new k(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate(),1),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2)],f=new T({view:i,renderObjects:g,elevationInfo:"on-the-ground"!==t.mode||A(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:l,available:this.object.visible,collisionType:{type:"disc",direction:j(0,0,1)},collisionPriority:1,metadata:{deleting:!1},location:je(n)}),_=new T({view:i,worldSized:!0,worldOriented:!1,available:this.object.visible,collisionPriority:-10,cursor:this.enableMoveObject?"move":"default",metadata:{deleting:!1},location:je(n)}),v={manipulator:f,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:_,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(v,s.minSquaredEdgeLength);const M=()=>this._updateEdgeOffsetManipulator(v);M(),v.locationUpdateHandle=o([e.leftVertex,e.rightVertex].map(e=>{const t=this._getManipulatorInfoFromHandle(e);return t?.manipulator.events.on("location-update",M)}));const b=e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()};return this._manipulatorHandles.add([v.locationUpdateHandle,this._watchAndUpdateGrabState(f,!0),this._watchAndUpdateGrabState(_,!0),ue(f,this._createEdgeOffsetPipeline(v,t,a)),ue(_,this._createEdgePipeline(v,t,a)),_.events.on("immediate-click",b),f.events.on("immediate-click",b),f.events.on("focus-changed",()=>this._resetTooltip()),f.events.on("grab-changed",({screenPoint:e,action:t})=>{v.grabMapPoint="start"===t?K(e,this.view,this.object,v):null})],f),this._manipulatorInfos.push(v),this.manipulators.addMany([f,_]),this.events.emit("manipulators-changed"),v}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,a=e.edgeManipulator,n=()=>{e.visibilityHandle=p(e.visibilityHandle);const n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=n&&null!=r&&ee(n.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||l)&&(i.grabbable=!l,a.grabbable=!l,e.visibilityHandle=o([i.disableDisplay(),s(()=>{i.grabbable=!0,a.grabbable=this.enableMoveObject})]))};this._manipulatorHandles.add([i.events.on("focus-changed",n),a.events.on("focus-changed",n),s(()=>{p(e.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)})],i),n()}_updateEdgeOffsetManipulator(e){if(!this._operations)return;this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._operations.data,i=J(this.view,e.manipulator.elevationAlignedLocation,Q(t,e.handle,e.manipulator.elevationInfo)),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==a||null==n)return;const o=a.manipulator.renderLocation,s=n.manipulator.renderLocation,r=null!=i?$(i,o,s):v;e.manipulator.modelTransform=r,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=r;const l=M(b(we,o,s))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgePipeline(e,t,i){return(a,n,o,s)=>{if("touch"===s){this._createEdgeOffsetPipeline(e,t,i)(a,n,o)}else if(this.enableMoveObject){const e=this.object.graphic,s=i.data.spatialReference,{elevationAlignedLocation:r}=a;n.next(e=>this._trackNumDragging(e)).next(ce(this.view,r)).next(R(this.view,r,t,s,e)).next(me()).next(de()).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(e=>{"end"===e.action&&this._resetTooltip()}),o.next(()=>this._onDragCancel(!a.metadata.deleting))}}}_createEdgeOffsetPipeline(e,t,i){return(a,n,o)=>{const s=this._pendingEdgeOffsetInfo;if(s?.manipulatorInfo===e&&"drag"!==s.mode)return void o.execute({action:"cancel"});this._clearSelection();const{initializeStep:r,cleanup:l}=this._initializeEdgeOffset(e,t,i,o),p=this._applyEdgeOffsetStep(e);n.next(e=>this._trackNumDragging(e)).next(ce(this.view,a.elevationAlignedLocation)).next(r).next(z(this.view)).next(F(this.view,i.data.spatialReference)).next(de()).next(ye()).next(e=>this._pendingEdgeOffsetInfo?e:p(e)).next(e=>{"end"!==e.action||this._pendingEdgeOffsetInfo||l()}),o.next(()=>{this._exitEdgeOffsetInputMode(),a.metadata.deleting||(l(),this._onDragCancel())})}}_initializeEdgeOffset(e,t,i,a){const{view:n,object:s}=this,r=Q(i.data.coordinateHelper,e.handle,t),l=i.createUndoGroup(),h=J(n,e.manipulator.elevationAlignedLocation,r);let d;this._splitEdgesBeforeEdgeOffset(e,r),this._selectEdgeOffsetArrow(e,r);const u=()=>{this._cleanEdgeOffsetCollapsedEdges(e,i),d=p(d)},c=this.events.on("undo",u);return d=o([this._initializeEdgeOffsetVisualElement(e,s,t,i),l,c,this._connectEdgeOffsetTooltip(e,r,i,()=>{a.execute({action:"cancel"})})]),{initializeStep:e=>null==r||null==h?(u(),null):{...e,operation:r,plane:h},cleanup:u}}_initializeEdgeOffsetVisualElement(e,t,i,a){const n=()=>new H({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:a.data.spatialReference}),s=new se({view:this.view,isDraped:t.isDraped,geometry:n(),elevationInfo:i,width:this._settings.visualElements.lineObjects.outline.width,attached:!1,isDecoration:!0}),l=o([h(()=>({color:this._accentColor,draped:t.isDraped}),({color:e,draped:t})=>{s.color=e.toUnitRGBA(),s.isDraped=t},c),t.on("committed",()=>{s.geometry=n()}),r(s)]);return s.attached=!0,l}_applyEdgeOffsetStep(e){return t=>(this.destroyed||null==t.operation||!this._operations||(this._updateEventState(2),null==t.signedDistance?this._resetTooltip():((t.mapDeltaX||t.mapDeltaY||t.mapDeltaZ)&&(this._offsetEdge(e,t.operation,t.signedDistance),this.events.emit("reshape",{type:"reshape",object:this.object})),this._updateEdgeOffsetTooltip(t))),t)}_cleanEdgeOffsetCollapsedEdges(e,t){const i=e.handle.leftVertex.leftSegment?.leftVertex,a=e.handle.leftVertex,n=e.handle.rightVertex.rightSegment?.rightVertex,o=e.handle.rightVertex,s=t.data.coordinateHelper,r=this.view.pixelSizeAt(s.vectorToDehydratedPoint(a.pos),s.spatialReference),l=[];if(i&&s.distance(i.pos,a.pos)<He){const e=this._getManipulatorInfoFromHandle(a);null!=e&&l.push(e)}if(s.distance(a.pos,o.pos)<r||n&&s.distance(n.pos,o.pos)<He){const e=this._getManipulatorInfoFromHandle(o);null!=e&&l.push(e)}l.length&&this._removeVertices(l)}_enterInputModeDuringEdgeOffset(e){const t=this._findActiveEdgeOffsetManipulatorInfo();return!!t&&(!!Me(e,this.tooltip)&&(t.manipulator.dragging?(this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"drag"},!0):(this._clearSelection(),this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"hover"},this._connectEdgeOffsetTooltipOnHover(t),!0)))}_exitEdgeOffsetInputMode(){this.tooltip&&(this._pendingEdgeOffsetInfo=null,this._resetTooltip(),this.tooltip.exitInputMode())}_findActiveEdgeOffsetManipulatorInfo(){return this._manipulatorInfos.filter(Ie).find(({manipulator:e})=>e.hovering||e.grabbing||e.dragging)}_connectEdgeOffsetTooltipOnHover(e){const{_operations:t,object:i}=this;if(!t)return;const{elevationInfo:a}=i,n=Q(t.data.coordinateHelper,e.handle,a);this._selectEdgeOffsetArrow(e,n),this.addHandles([this._initializeEdgeOffsetVisualElement(e,i,a,t),this._connectEdgeOffsetTooltip(e,n,t,()=>{this.removeHandles(n),this._exitEdgeOffsetInputMode()})],n)}_splitEdgesBeforeEdgeOffset(e,t){if(t.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftSegment);null!=t&&this._splitEdgeManipulator(t,1)}if(t.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightSegment);null!=t&&this._splitEdgeManipulator(t,0)}}_selectEdgeOffsetArrow(e,t){const i=e.grabMapPoint??K(this.view.inputManager?.latestPointerInfo?.location,this.view,this.object,e);i&&t.selectArrowFromStartPoint(i)}_connectEdgeOffsetTooltip(e,t,i,a){const n=()=>this.tooltipInfos.edgeOffset.distance.actual,s=n=>{a(),queueMicrotask(()=>{this.view.focus();const a=i.createUndoGroup();this._tooltipCallbacks.onReshapeStart?.(),this._splitEdgesBeforeEdgeOffset(e,t),this._offsetEdge(e,t,te(n,e.manipulator.location,t,i)),this._tooltipCallbacks.onReshape?.(),this._tooltipCallbacks.onReshapeStop?.(),this._cleanEdgeOffsetCollapsedEdges(e,i),a.remove()})},r=()=>{const e=n();null!=e?s(e):a()};return o([m(()=>this.tooltip&&!this.tooltip.focused,()=>r(),g),this.tooltip.on("discard",a),this.tooltip.on("commit",e=>{"commit-and-exit"===e.type&&r()})])}_createVertexOrEdgeManipulator(e,t=this.object.elevationInfo,i=!1){const a=this.view,n=this._operations,s=this._settings;if(!n)return null;const r=n.data.type,l=n.data.spatialReference;if("line"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=Oe(s.manipulators.vertex);this._vertexManipulatorGeometry=le(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=le(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=Oe(s.manipulators.edge);this._edgeManipulatorGeometry=le(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=le(this._edgeManipulatorOutlineMaterial,t,16,16)}const h="point"===r||"mesh"===r?[]:[new k(this._vertexManipulatorGeometry.instantiate(),4|Ve),new k(this._vertexManipulatorOutlineGeometry.instantiate(),5|Ve),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|Ve),new k(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),8),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),9),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),10)];this.enableMidpoints&&h.push(new k(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),6|De),new k(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|De),new k(this._edgeManipulatorGeometry.instantiate(),5|De),new k(this._edgeManipulatorOutlineGeometry.instantiate(),5|De));const d=new T({view:a,renderObjects:h,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:this.object.visible,metadata:{deleting:!1},location:je(l)});d.selected=i,this._setTypeSpecificManipulatorSettings(d,e,t);const u="vertex"===e.type?{manipulator:d,handle:e,type:"vertex",selectedIndex:0}:{manipulator:d,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0};if(this._manipulatorInfos.push(u),this.manipulators.add(d),this._updateManipulatorPosition(u),"edge"===u.type){const e=[];for(const t of[u.handle.leftVertex,u.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",()=>this._updateManipulatorPosition(u)))}u.locationUpdateHandle=o(e),this._manipulatorHandles.add(u.locationUpdateHandle,d)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(d,!0),d);const c=ue(d,(e,i,o,s)=>{let r=null;const{snappingStep:h,cancelSnapping:d}=_e({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new fe({editGeometryOperations:n,elevationInfo:t,pointer:s,excludeFeature:this.object.graphic,visualizer:new L}),updatingHandles:this._updatingHandles,useZ:!1});o=o.next(t=>(this._onDragCancel(!e.metadata.deleting,()=>r=p(r)),t)).next(d);const{elevationAlignedLocation:c}=e,m=this.object.graphic??void 0;i.next(e=>this._trackNumDragging(e)).next(e=>{if("start"===e.action&&n&&(r=n.createUndoGroup()),"edge"===u.type){const t=this._splitEdgeManipulator(u);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:u,snapOrigin:u.handle.pos}}).next(ce(a,c)).next(R(a,c,t,l,m)).next(he(a,t,m)).next(...h).next(de()).next(e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(r=p(r)),this._resetTooltip()})});return this._manipulatorHandles.add([c,d.events.on("immediate-click",e=>this._manipulatorClickCallback(e,u)),d.events.on("select-changed",()=>{u.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition(),this._resetTooltip()}),d.events.on("focus-changed",()=>{this._resetTooltip()})],d),this.events.emit("manipulators-changed"),u}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&this.undo(),this.tool.snappingManager?.doneSnapping(),this._resetTooltip(),this._reshapeEventState){case 0:break;case 1:this.events.emit("move",{type:"move",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape",object:this.object})}t?.(),this.destroyed||this._updateEventState(0)}_setTypeSpecificManipulatorSettings(e,t,i){const a=this._settings;switch(t.type){case"vertex":{e.state=Ve,e.selectable=!0,e.cursor="move",e.collisionPriority=2;const{size:t,collisionPadding:n}=a.manipulators.vertex;e.radius=t/2+n,e.elevationInfo=i;const o=this._operations?.data.type;e.interactive=null!=o&&"point"!==o&&"mesh"!==o;break}case"line":{e.state=De,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1;const{size:t,collisionPadding:n}=a.manipulators.edge;e.radius=t/2+n,e.elevationInfo="on-the-ground"!==i.mode||A(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",i=>{this._onGrabStateChanged(e,t,i.action,i.pointerType)})}_onGrabStateChanged(e,t,i,a="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(0),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach(e=>{const{manipulator:t}=e,i=this._operations?.data.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=i&&"point"!==i&&"mesh"!==i,Ie(e)&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)}),this._objectMoveManipulation.forEachManipulator(e=>{e.interactive=e.grabbing||!this._numGrabbing}))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1);this._pendingEdgeOffsetInfo=null}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.events.emit("manipulators-changed"))}_removeManipulator(e){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),this.events.emit("manipulators-changed"),this._resetTooltip())}_getManipulatorInfoFromHandle(e){return this._manipulatorInfos.find(t=>t.handle===e)}_updateManipulatorPositions(e){for(const t of e)this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t))}_updateManipulatorPosition(e){const t=this._operations;if(null!=e&&t)if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,Se),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==a)return;const n=i.manipulator,o=a.manipulator;if("on-the-ground"===e.manipulator.elevationInfo?.mode){const i=n.location,a=o.location,s=.5,r=i.x+s*(a.x-i.x),l=i.y+s*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;e.manipulator.location=D(r,l,p,t.data.spatialReference)}else x(we,n.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=we}}_splitEdgeManipulator(e,t=.5){const i=this._operations,a=i.splitSegment(e.handle,t).createdVertex;e.locationUpdateHandle=p(e.locationUpdateHandle);const n=this.object.elevationInfo;let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(a)):(o=e,o.handle=a,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,n)),"line"===a.leftSegment?.type&&this._createVertexOrEdgeManipulator(a.leftSegment),"line"===a.rightSegment?.type&&this._createVertexOrEdgeManipulator(a.rightSegment),this._updateManipulatorPosition(o),this.enableEdgeOffset||this._resetTooltip(),this._updateSelection(e.manipulator);const s=this._updateEventState(2),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.parts.indexOf(a.part);return this.events.emit("vertex-add",{type:"vertex-add",object:this.object,vertices:[{coordinates:r,componentIndex:l,vertexIndex:a.index}],added:r}),s&&this._updateEventState(0),o}_updateMoveManipulationPosition(){const e=y(we,0,0,0);let t=0,i=!1,a=null,n=null;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.selected?(t++,O(e,e,r.manipulator.renderLocation),null==a||r.selectedIndex>a.selectedIndex?(n=a,a=r):(null==n||r.selectedIndex>n.selectedIndex)&&(n=r)):i=!0);const o=this.object,s=this._operations?.data.geometry;if(0===t){const e=o.visible&&this.enableMoveObject;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&B(this._operations,o.elevationInfo),this._moveManipulation.angle=Z(s),this._moveManipulation.radius=Y.radiusForSymbol(o.graphic?.symbol)}else{const e=o.visible;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&B(this._operations,this.object.elevationInfo),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=a){const e=a.handle.pos,t=null!=n?n.handle.pos:a.handle.leftSegment?.leftVertex?a.handle.leftSegment.leftVertex.pos:null,o=null==n&&a.handle.rightSegment?.rightVertex?a.handle.rightSegment.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=Ee(t,e):o&&(i=Ee(e,o))}this._moveManipulation.angle=i,this._moveManipulation.radius=X}0!==t&&i?(E(e,e,1/t),Se.spatialReference=this._operations.data.spatialReference,Se.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,Se),this._moveManipulation.elevationAlignedLocation=Se):null==this._outlineVisualElement||this.object.isDraped||null==this._outlineVisualElement.attachmentOrigin?P(this._moveManipulation,this.object):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=this._operations;if(i){for(const a of e){const e=a.handle.part;if("vertex"===a.type&&i.canRemoveVertex(e)){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftSegment)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightSegment));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdSegment;o&&"line"===o.type?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&e.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(e.segments[0]))}}if(t.length>0){const e=t.map(e=>{const t=i.data.parts.indexOf(e.part);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:e.index}}),a=this._updateEventState(2);if(this.destroyed)return;if(this.events.emit("vertex-remove",{type:"vertex-remove",object:this.object,removed:e.map(e=>e.coordinates),vertices:e}),this.destroyed)return;if(a&&(this._updateEventState(0),this.destroyed))return;this._updateMoveManipulationPosition()}}}_moveVertices(e,t,i=("start"===t.action?0:1)){const a=this._operations;if(a){e.length>0&&a.moveVertices(e.map(e=>e.handle),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);for(const t of e)this._updateManipulatorPosition(t)}}_offsetEdge(e,t,i){if(!this._operations)return;const a=t.clone();a.distance=i,this._operations.updateVertices([e.handle.leftVertex,e.handle.rightVertex],a),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,this.enableDeleteVertices&&e.button===pe.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===pe.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){null!=this._defaultTooltipInfo?this._resetTooltip():this._updateTranslateObjectTooltip(e,t)}_updateTranslateObjectTooltip(e,t){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=ne(e,t,this._tooltipsContext))}_updateEdgeOffsetTooltip(e){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=oe(this.object,e,this._tooltipsContext))}_resetTooltip(){const e=this.activeTooltipInfo;if(this._pendingEdgeOffsetInfo&&"reshape-edge-offset"===e?.type)return;let t=null;t=this._pendingEdgeOffsetInfo||null!=this._findActiveEdgeOffsetManipulatorInfo()?oe(this.object,null,this._tooltipsContext):this._defaultTooltipInfo,t!==e&&(null!=e&&null!=t&&"input"===this.tooltip.mode||(this.activeTooltipInfo=t))}get _defaultTooltipInfo(){const e=this._operations?.data.type;switch(e){case"polyline":case"polygon":return this._selectedVertexManipulatorInfo?this.tooltipInfos.selectedVertex:null;case"point":case"mesh":return this.tooltipInfos.movePoint;default:return null}}get _selectedVertexManipulatorInfo(){const e=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.length?e[0]:null}get _tooltipsContext(){const{tooltipInfos:e,activeTooltipInfo:t,automaticAreaMeasurementUtils:i,automaticLengthMeasurementUtils:a}=this;return{sketchOptions:this._sketchOptions,tooltipInfos:e,activeTooltipInfo:t,selectedVertexManipulatorInfo:this._selectedVertexManipulatorInfo,callbacks:this._tooltipCallbacks,automaticAreaMeasurementUtils:i,automaticLengthMeasurementUtils:a}}get test(){}};function ye(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:{...e,signedDistance:t.signedDistanceToPoint(i)}}}function Oe(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}function Ee(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function je(e){return new w({x:0,y:0,z:0,spatialReference:e})}function Ie(e){return"edge"===e.type&&"edgeManipulator"in e}e([f()],xe.prototype,"_numGrabbing",void 0),e([f()],xe.prototype,"_numDragging",void 0),e([f()],xe.prototype,"_pendingEdgeOffsetInfo",void 0),e([f()],xe.prototype,"_operations",null),e([f()],xe.prototype,"_segmentLabels",void 0),e([f({constructOnly:!0})],xe.prototype,"tool",void 0),e([f()],xe.prototype,"tooltip",void 0),e([f()],xe.prototype,"activeTooltipInfo",void 0),e([f({readOnly:!0})],xe.prototype,"updating",null),e([f()],xe.prototype,"manipulators",null),e([f()],xe.prototype,"view",null),e([f()],xe.prototype,"automaticAreaMeasurementUtils",null),e([f()],xe.prototype,"automaticLengthMeasurementUtils",null),e([f()],xe.prototype,"object",null),e([f()],xe.prototype,"enableZShape",null),e([f()],xe.prototype,"enableDeleteVertices",null),e([f()],xe.prototype,"enableZVertex",null),e([f()],xe.prototype,"autoHideManipulators",null),e([f()],xe.prototype,"enableMoveObject",null),e([f()],xe.prototype,"enableMidpoints",null),e([f()],xe.prototype,"enableEdgeOffset",null),e([f()],xe.prototype,"_sketchOptions",null),e([f()],xe.prototype,"_accentColor",null),e([f()],xe.prototype,"_tooltipsContext",null),xe=e([_("esri.views.3d.interactive.editingTools.reshape.ReshapeOperation")],xe);const Se=D(0,0,void 0,V.WGS84),we=I(),He=1e-6,Ve=16,De=32;export{xe as ReshapeOperation};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Logger.js";import{removeMaybe as s}from"../../../core/maybe.js";import{watch as i,syncAndInitial as r}from"../../../core/reactiveUtils.js";import{convertUnit as a}from"../../../core/units.js";import{property as n,subclass as o}from"../../../core/accessorSupport/decorators.js";import{fromValues as l}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{isCompatible as h}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as d,isWebMercator as u,equals as p}from"../../../geometry/support/spatialReferenceUtils.js";import{getHeightModelInfoFromVCS as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Logger.js";import{removeMaybe as s}from"../../../core/maybe.js";import{watch as i,syncAndInitial as r}from"../../../core/reactiveUtils.js";import{convertUnit as a}from"../../../core/units.js";import{property as n,subclass as o}from"../../../core/accessorSupport/decorators.js";import{fromValues as l}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{isCompatible as h}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as d,isWebMercator as u,equals as p}from"../../../geometry/support/spatialReferenceUtils.js";import{getHeightModelInfoFromVCS as m}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as c}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as f}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as y}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as _}from"./LayerView3D.js";import{addLayerViewToWasm as g,getLyr3DWasm as w,removeLayerViewFromWasm as b}from"./Lyr3DWasm.js";import{Obb as C}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as v,elementsPerSplatPage as M,packedGaussianSizeInU32 as S,splatPageSizeInU32WithoutHeader as x,gaussiansPerSplatPage as H,splatAtlasTextureWidth as U}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatFadeHelper as V}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianTile as j}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatRenderNode as A}from"../webgl-engine/lib/GaussianSplatRenderNode.js";import G from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as I,isInEffectiveScaleRange as L}from"../../support/layerViewUtils.js";const R=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D");let E=class extends(_(G)){constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(v),this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const{view:t}=e;this._memCache=t.resourceController.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._fadeHelper=new V(this),this._renderNode=new A({view:t,fadeHelper:this._fadeHelper})}initialize(){if(!this._canProjectWithoutEngine())throw I("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);const e=g(this).then(e=>{this._wasmLayerId=e,this.addHandles([i(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=i(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),r)});this.addHandles([i(()=>this.view.qualitySettings.fadeDuration,e=>{this._fadeHelper.onFadeDurationChanged(e),this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)})]),this.addResolvingPromise(e)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}get _wasm(){return w(this.view)}get usedMemory(){return this._usedMemory}get cachedMemory(){return this._cacheMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get data(){return this._renderNode.data}get visibleAtCurrentScale(){return L(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this._renderNode.data.isUpdating()||this._fadeHelper.isUpdating())}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const s=t.desc.prims[0],i=s.vertexCount,r=s.atrbs[0].view,a=s.atrbs[0].view.byteCount,n=s.atrbs[0].view.byteOffset;let o=null;if("U32"!==r.type)return R().warnOnce("unexpected meshData.data format"),{memUsageBytes:0,numGaussians:0};o=new Uint32Array(t.data.buffer,n,a/4);const h=this.extractHeader(o),d=Math.ceil(i/H),u=new Uint32Array(i),p=[];for(let l=0;l<d;l++){let e=this.data.textureAtlas.requestPage();if(null===e&&(this._freeInvisibleTiles(),e=this.data.textureAtlas.requestPage()),null===e)return R().warnOnce("ran out of gaussian splat memory"),{memUsageBytes:0,numGaussians:0};{p.push(e);const t=i-l*H,s=Math.min(t,H),r=l*H;for(let i=0;i<s;i++)u[i+r]=i+M*e;const a=l*x;this._pageBuffer.set(o.subarray(a,a+s*S)),this._pageBuffer.set(h.packedHeader,x);const n=e*M,d=n%U,m=Math.floor(n/U);this.data.textureAtlas.update(d,m,this._pageBuffer)}}const m=new Float64Array(3*i),c=new Float64Array(i),f=2.048,y=h.tileOrigin.x*f,_=h.tileOrigin.y*f,g=h.tileOrigin.z*f,w=h.invPosScale;let b=0,v=0;for(let l=0;l<i;l++){const e=l*S,{rawX:t,rawY:s,rawZ:i}=this._extractGaussianPosition(o,e),r=this._extractGaussianSphericalScale(o,e);m[b]=t*w+y,m[b+1]=s*w+_,m[b+2]=i*w+g,c[l]=r*r,v=Math.max(v,r),b+=3}let V=null;if(t.desc.obb){const e=t.desc.obb.quaternion;V=new C(t.desc.obb.center,t.desc.obb.halfSize,l(...e))}V||(R().warnOnce("encountered tile without a bounding box"),V=new C);const A=new j(e.handle,V,u,p,m,c,v);return this._memCache.put(`${A.handle}`,A),this._tileHandles.set(e.handle,A),this._cacheMemory+=A.usedMemory,{memUsageBytes:A.usedMemory,numGaussians:i}}_extractGaussianPosition(e,t){const s=e[t+1];return{rawX:16383&s,rawY:s>>>14&16383,rawZ:s>>>28&15|(1023&e[t+2])<<4}}_extractGaussianSphericalScale(e,t){const s=e[t+2],i=s>>>10&255,r=s>>>18&255,a=s>>>26&63|(3&e[t+3])<<6,n=Math.exp(i/16-10),o=Math.exp(r/16-10),l=Math.exp(a/16-10);return Math.max(n,o,l)}freeRenderable(e){const t=this._tileHandles.get(e);t&&(t.isVisible&&!this._fadeHelper.isTileFadingOut(t)?this._usedMemory-=t.usedMemory:this._cacheMemory-=t.usedMemory,t.pageIds.forEach(e=>this.data.textureAtlas.freePage(e)),this.freeObject(t),this._tileHandles.delete(e)),this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}setRenderableVisibility(e,t,s){for(let i=0;i<s;i++){if(!t[i])continue;const s=e[i],r=this._tileHandles.get(s);r&&(r.isVisible&&!this._fadeHelper.isTileFadingOut(r)||(r.isVisible=!0,this._fadeHelper.isTileFadingOut(r)||this._popTileFromCache(r),this._fadeHelper.fadeTile(r,0)))}for(let i=0;i<s;i++){if(t[i])continue;const s=e[i],r=this._tileHandles.get(s);r&&r.isVisible&&this._fadeHelper.fadeTile(r,1)}this.updateGaussians()}_popTileFromCache(e){this._usedMemory+=e.usedMemory,this._cacheMemory-=e.usedMemory,this._memCache.pop(`${e.handle}`)}moveTileToCache(e){this._usedMemory-=e.usedMemory,this._cacheMemory+=e.usedMemory,this._memCache.put(`${e.handle}`,e)}destroy(){b(this),this._suspendedHandle&&(this._suspendedHandle=s(this._suspendedHandle)),this._renderNode.destroy(),this._memCache.destroy()}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(d(this.view.renderSpatialReference)||u(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&p(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){const e=m(this.layer.esriCrsSpatialReference),t=this.view.heightModelInfo;return this._useEsriCrs=0===h(e,t,!1),this._useEsriCrs&&e&&(this._metersPerVCSUnit=a(1,"meters",e.heightUnit),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=f(e?.unit)/this._metersPerVCSUnit,s=e?.offset??0;this._wasm?.setLayerOffset(this,s*t)}else this._wasm?.setLayerOffset(this,c(e));else this._wasm?.setLayerOffset(this,0)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())t.isVisible&&e.push(t);this.data.updateGaussianVisibility(e),this.notifyChange("updating")}setMaximumGaussianSplatCount(e){this._wasm?.setMaximumGaussianSplatCount(e)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())e.isVisible||this._deleteTile(e)}extractHeader(e){const t=e.length-4,s=this.reinterpretU32AsFloat(e[t]),i=this.reinterpretU32AsFloat(e[t+1]),r=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:s,y:i,z:r},invPosScale:a}}_deleteTile(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;return this._tileHandles.forEach(s=>{s.isVisible?e++:t++}),new y(this.usedMemory,e,t,this.cachedMemory)}};e([n()],E.prototype,"layer",void 0),e([n({readOnly:!0})],E.prototype,"visibleAtCurrentScale",null),e([n()],E.prototype,"fullExtentInLocalViewSpatialReference",void 0),E=e([o("esri.views.3d.layers.GaussianSplatLayerView3D")],E);const O=E;export{O 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s,isSome as r}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import o from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../core/maybe.js";import l from"../../../core/PooledArray.js";import{ignoreAbortErrors as d,isAbortError as h,throwIfAborted as c,createResolver as u}from"../../../core/promiseUtils.js";import{initial as _,watch as g}from"../../../core/reactiveUtils.js";import{schedule as m}from"../../../core/scheduling.js";import{equals as f}from"../../../core/SetUtils.js";import{isArrayBuffer as p}from"../../../core/typedArrayUtil.js";import{property as y,subclass as b}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as v,invert as I}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as M,getTranslation as w}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as x,create as S}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as E}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{h as O,p as R,t as j,a as F,i as V,j as D,e as A,u as T}from"../../../chunks/vec32.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as N}from"../../../chunks/vec42.js";import{fromValues as P}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 U}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as G}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as B}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as q}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as W,create as $,toRect as K}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as J}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y,ensurePackedMat4f64 as X}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{Sphere as te}from"../../../geometry/support/sphere.js";import{newUByteArray as ie}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as se}from"../../../layers/LayerConstants.js";import re from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as oe}from"../../../layers/support/fieldUtils.js";import ne from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as le}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as de}from"../../../support/basemapUtils.js";import{getElevationOffset as he}from"../../../support/elevationInfoUtils.js";import{loadArcade as ce}from"../../../support/loadArcade.js";import ue from"../../../symbols/MeshSymbol3D.js";import _e from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as ge}from"./ContentGeometryLayerView.js";import me from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as fe}from"./I3SMeshViewPerformanceInfo.js";import{initialize as pe,setModificationsSync as ye,filterObbsForModificationsSync as be,interpretObbModificationResults as ve}from"./SceneLayerWorker.js";import{SceneLayerWorkerHandle as Ie,toWasmModification as Ce}from"./SceneLayerWorkerHandle.js";import{overrideColor as Me}from"./graphics/graphicUtils.js";import{areLabelsVisible as we}from"./graphics/Labeler.js";import xe from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Se}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Ee}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Oe,NodeCrossfadeMetaData as Re}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as je}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Fe}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ve,selectEncoding as De,defaultMaterial as Ae,createTexture as Te,configureMaterial as He}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as Ne}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Pe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as ke,checkSceneLayerValid as Le,checkSceneLayerCompatibleWithView as Ue,whenGraphicAttributes as Ge,computeVisibilityObb as Be,filterInPlace as qe,intersectBoundingRectWithMbs as ze,addWraparound as We,getSymbolInfo as $e,transparentEdgeMaterial as Ke,getClipRect as Qe}from"./i3s/I3SUtil.js";import{IDBCache as Je}from"./i3s/IDBCache.js";import{IDBMockCache as Ye}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as Xe}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as Ze}from"./i3s/SymbologyInfo.js";import{attributeLookup as et}from"./support/attributeUtils.js";import{normalizeHighlightTarget as tt,emptyHighlightHandle as it}from"./support/highlightUtils.js";import{makeScheduleFunction as st}from"./support/makeScheduleFunction.js";import{debugFlags as rt}from"../support/debugFlags.js";import{ElevationRange as ot}from"../support/ElevationRange.js";import{toBoundingRect as nt}from"../support/extentUtils.js";import{Obb as at,ensurePackedObbData as lt}from"../support/orientedBoundingBox.js";import{updatingProgress as dt}from"../support/updatingProperties.js";import{glLayout as ht}from"../support/buffer/glUtil.js";import{ObjectParameters as ct}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as ut,SourceParameters as _t,SourceGeometry as gt,GeometryParameters as mt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as ft}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as pt}from"../webgl-engine/core/shaderLibrary/output/Emissions.glsl.js";import{loadBasisTranscoder as yt}from"../webgl-engine/lib/BasisUtil.js";import{getHighlightName as bt}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as vt}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as It}from"../../../webscene/support/AlphaCutoff.js";const Ct=[1,1,1,1];class Mt extends Re{constructor(e,t,i,s,r,o,n,a,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0,this.cachedSymbologyStride=5}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}const wt=26,xt=104857600,St=t=>{const p=t;let T=class extends p{constructor(){super(...arguments),this._applySSAO=!0,this._shadeNormals=!0,this._updatingHandles=new k,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new vt,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 Oe(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerViewUid(){return this.uid}get layerId(){return 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>It}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 ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?63:37:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?he(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new Lt(0,0);const t=he(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new Lt(0,t);case"relative-to-ground":return new Lt(1,t);case"on-the-ground":return new Lt(2,0);default:return new Lt(0,0)}}get supportedTextureEncodings(){return Ve(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new ot;for(const i of e.values()){const e=i?.node.serviceMbsInIndexSR;e&&t.expandElevationRangeValues(e.center[2]-e.radius,e.center[2]+e.radius)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new Ye(this.view,e):new Je("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Ne({view:this.view,layer:this.i3slayer,memoryController:i}),this._workerHandle=new Ie(st(t)),this.addResolvingPromise(this._workerHandle.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(d)),Le(this.i3slayer),Ue(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new re({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection;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 n=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=n;const l=this._controller,h=this._nodeId2Meta,c=this._nodeId2MetaReloading,u=e=>{const t=l.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=h.get(i)||c.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Fe({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:u}),this._elevationProvider=new Xe({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),_),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),_),this._updatingHandles.add(()=>!this.suspended&&0!==this.elevationInfo.mode,(e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",({extent:e})=>this._ensureElevationTask().addExtent(e)),Bt):t&&this.removeHandles(Bt)},_),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e));const m=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add(()=>this.rendererTextureUsage,m),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),_),this._updatingHandles.add(()=>this.i3slayer.labelsVisible,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this.i3slayer.labelingInfo,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),_),this.addHandles([g(()=>rt.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&rt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||rt.I3S_TREE_SHOW_TILES||(this._treeDebugger=a(this._treeDebugger))},_),g(()=>rt.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),_)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>o.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));const{view:f}=this,{viewingMode:p,renderCoordsHelper:y}=f;this._planetRadiusInGlobalMode="local"===p?0:y.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=a(this._elevationTask),this.i3sOverrides=a(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.notifyObjectsChanged(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._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=a(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=a(this._labeler),this._treeDebugger=a(this._treeDebugger),this._controller=a(this._controller),this._highlights=a(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=a(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=a(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(!(we(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new me({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=pe().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()}),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=e=>o.getLogger(this).error("set-modifications-error","Error when setting modifications:",e),t=this.uid,i=this.i3slayer.spatialReference,s=i.isGeographic,r=Ce(this._layerClippingArea,this._modifications,i);this._workerHandle.setModifications(t,r,s).catch(e);try{ye({context:t,modifications:r,isGeodetic:s})}catch(a){e(a)}this._controller.modificationsChanged();const n=this.hasModifications?new l: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!=n&&n.push(e.node)}),this.notifyChange("elevationRange"),null!=n&&this._nodeId2MetaReloading.forEach(e=>n.push(e.node)),null!=n&&n.length>0&&(this.updateNodeModificationStatus(n),n.forAll(e=>{if(2!==e.imModificationImpact){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),!rt.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 _e({...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=>{h(e)||o.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")&&2&this.supportedTextureEncodings&&this.i3slayer.textureSetDefinitions?.some(e=>e.formats.some(e=>"basis"===e.format||"ktx2"===e.format))&&yt()}_getVertexBufferLayout(e,t){return ht(ut(this._getGeometryParameters({hasTexture:Dt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.i3slayer.objectIdField||se}_getGlobalIdField(){return this.i3slayer.globalIdField}_findGraphicNodeAndIndex(e){const t=et(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 n of t){const e=et(o,n.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=je(t,this._collection,s,Y(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;return B(r,o,0,r,n,0)?W(r):null}whenGraphicAttributes(e,t){return Ge(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 s?t.defer?(t.defer(async()=>(s.geometry=(await import("./i3s/meshUtils.js")).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),s)),null):s:null}_getCacheKey(e){return`${this._layerUrl}/v${wt}/${e}${this._cacheKeySuffix}`}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return zt;if(e===L(e))return Wt;return this.i3slayer.spatialReference.equals(e)?qt: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=De(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.globalTrafo=X(s.globalTrafo),s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=at.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then(i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Ht(s.transformedGeometry,s.textureData),s.textureData.every(Tt)&&this._indexedDbSizeCheck(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch(t=>o.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),c(t),s))))):Promise.resolve(null)}addNode(e,t,i){return At(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);const{obb:r,componentOffsets:n,featureIds:a,anchorIds:l,anchors:d,transformedGeometry:h}=s;e.hasModifications=h.hasModifications;const c=X(s.globalTrafo),u=O(Ut,r.center.x,r.center.y,r.center.z);R(u,u,c);const _=new at(u,[r.extents.x,r.extents.y,r.extents.z],E(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=_),t.geometryData.componentOffsets=n,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=l,t.geometryData.anchors=d;const g={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:h,globalTrafo:c,geometryObbData:_.data,byteSize:Ht(h,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,g)){const t=null!=g.textureData?g.textureData.map(e=>Tt(e)?e:null):null;this._idbCache.put(this._getCacheKey(e.id),{...g,textureData:t}).catch(t=>o.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,g,i)},i))):Promise.reject()}getElevationRange(e){const t=new ot,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e.radius,a=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=a.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=a.getServiceMbsInRenderSR(i),d&&(_=d.radius);if(_>=0&&n>=1*_)return null!=r?Qt(t,r,l):null!=d&&d.radius>=0&&Jt(t,d,l),!1;const g=Kt;if(g.minElevation=1/0,g.maxElevation=-1/0,(null!=r||null!=d)&&(null!=r?Qt(g,r,l):null!=d&&Jt(g,d,l),g.minElevation>=t.minElevation&&g.maxElevation<=t.maxElevation))return!1;const m=o.get(i.index);if(m){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(n>0*s.radius)return Qt(t,s,l),!1}const{objectHandle:e}=m,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(m?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Be(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,n=t.normalReferenceFrame??o??"none",a=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=Pe(a,l,n,d,c),_=q(d,h),g=q(h,c);if(null==_||null==g)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:a.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._controller.isMeshPyramid,normalReferenceFrame:n,indexToVertexProjector:_,vertexToRenderProjector:g};return this._workerHandle.invoke(m,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(0===this.elevationInfo.mode&&(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),0!==this.elevationInfo.mode&&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:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter(e=>null!=e&&0!==(e.usage&this.rendererTextureUsage)):[];!has("disable-feature:i3s-basis")&&a.some(e=>null!=e&&(2===e.encoding||1===e.encoding))&&await yt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:f,interleavedVertexData:p,positionData:y,hasColors:b}=n,{material:E,geometryParameters:O}=this._materialParameters(g,m),R=l||new Uint32Array([0,f?f.length:p.byteLength/m[0].stride]),V=new _t(m,O.shadeNormals,O.applySSAO,O.textureCoordinateType),D=new gt({data:p,count:p.byteLength/m[0].stride},{positions:Z(y.data),indices:ee(y.indices)},f,R,V),A=g.transformation?x(g.transformation):S(),T=X(t.globalTrafo);M(A,T,A);const N=w(H(),A),k=v(C(),A),L=this.view.renderSpatialReference,G=this.view.basemapTerrain.spatialReference,B=at.fromData(lt(t.geometryObbData)).center,q=[1,1,1];U(B,L,q,G)||o.getLogger(this).errorOnce("Unsupported coordinate system for IM overlay");const W=H();z(B,L,W,G);const $=C();I($,k);const K=H();j(K,F(K,B,N),$);const Q=W[0]-K[0]*q[0],J=W[1]-K[1]*q[1],Y=_.createObject(new ct(P(Q,J,q[0],q[1]),new ft(N,k),at.fromData(lt(t.geometryObbData)),D,!this._isIntegratedMesh)),te=2===O.textureCoordinateType,{textures:ie,texturePromise:se}=this._initMaterialAndTextures(Y,E,a,te,e);e.memory+=this._memEstimateGeometryAdded(Y),e.memory+=ie.reduce((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0),0);const re=!!E.hasParametersFromSource,oe="blend"!==E.alphaMode&&E.metallicRoughness.baseColorFactor[3]>=1,ne=new Mt(e,h,Y,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:re,isOpaque:oe},ie,c,u);s.meta=ne,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(19&e))||!!e.resources.texture,this._hasData=!0,this._hasColors||=b,this.notifyChange("hasTexturesOrVertexColors");const ae=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(ne),se]).then(([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(ne.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,ne),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(Y,!0),t?.updateObjectVisibility(ne.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),ne.attributeInfo=i.attributeInfo;const s=ne.cachedRendererVersion!==this._rendererVersion,r=ae!==this.slicePlaneEnabled;this._updateElevationOffsets(ne);const o=ne.elevationOffsets;this._updateComponentData(ne);const n=this._applyFiltersToNode(ne);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(ne),null!=this._labeler&&this._addMetaToLabeler(this._labeler,ne),this._visibleGeometryChanged(ne,0),this._highlights?.objectCreated(ne),this._updateMaterial(ne),this._setNewNodeOpacity(ne),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)){o.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&&kt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;const{view:t,elevationInfo:i}=this,s=this._controller.crsIndex,{groundView:r,groundSpatialReference:o,renderSpatialReference:n}=t,a=i.mode;if(null==n||null==o||0===a)return void(e.elevationOffsets=null);const l=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const d=Ut,h=Gt,c=2===a,u=this.view.renderCoordsHelper,_=e.featureIds.length,g=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const t=Y(3*_);e.cachedElevationAnchors=t;const{center:i}=e.node.serviceMbsInIndexSR;for(let r=0;r<_;r++){const a=3*r,c=e.anchorIds?.indexOf(r)??-1;e.anchors&&c>=0?(O(d,e.anchors[3*c],e.anchors[3*c+1],e.anchors[3*c+2]),V(d,d,i),z(d,s,d,o),t[a]=d[0],t[a+1]=d[1],t[a+2]=u.getAltitude(d)):(this._collection.getComponentAabb(e.objectHandle,r,h,!0),O(d,(h[0]+h[3])/2,(h[1]+h[4])/2,h[2]),j(d,d,l.rotationScale),V(d,d,l.position),t[a+2]=u.getAltitude(d),z(d,n,d,o),t[a]=d[0],t[a+1]=d[1])}return t})(),m=i.offset,f=e.elevationOffsets,p=(e,t)=>{const i=c?g[3*e+2]:0;f[e]=m+(t??0)-i};r.getElevations(g,_,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Se(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=0!==e.mode,s=!!t&&t!==e&&0!==t.mode;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,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return c(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ae(),s=t.some(({name:e})=>"uvRegion"===e),r=t.some(({name:e})=>"normalCompressed"===e),o=Dt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s,r){const o=this._stage.renderView,n=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,r.memory-=e},a=i.map(e=>Te(e,t,s,o,this._compressionTracker,n));this._stage.addTextures(a);let l=null;return this._collection.updateMaterial(e,e=>{l=He(e,t,a,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:a,texturePromise:l}}_getGeometryParameters(e){return new mt(this._hasVertexColors,e.hasTexture?e.hasRegions?2:1:0,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=u();s=new Pt(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=Q();this._renderClippingArea=nt(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=nt(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=ei(this._nodeId2Meta.values()),this._filteredIdCounts=ei(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=ei(this._nodeId2Meta.values(),2),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,Zt(this._featureIdCounts,e.featureIds,t),Zt(this._filteredIdCounts,e.filteredIds,t),Zt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,Zt(this._filteredIdCounts,t,-1),Zt(this._filteredIdCounts,e.filteredIds,1),Zt(this._weaklyRemovedIdCounts,i,-1),Zt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&o.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=ei(this._nodeId2Meta.values());n(this._featureIdCounts,t)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=ei(this._nodeId2Meta.values(),1);n(this._filteredIdCounts,i)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=ei(this._nodeId2Meta.values(),2);n(this._weaklyRemovedIdCounts,s)||o.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))}}f(e,this._mismatchShow)&&f(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;const t=Xt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_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,2))})}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={},n=this._createLayerGraphic(o);if(!n)return;const a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every(e=>e===a||null!=d?.[e])&&qe(e,l,e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?Ee(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}})}_boundingRectNodeTest(e,t){return G(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Vt,this.view.renderSpatialReference),ze(t,Vt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Et),K(Et,Ot),J(i,Ot)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(3===r)return;if(0===r)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Rt,i,t.objectHandle);qe(e,t.featureIds,e=>this._boundingRectFeatureTest(t,e,n))}_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 n=o.hasObject(i);if(s){if(n){if(this.nodeCrossfadingEnabled){kt(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 n&&(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=Yt(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=Xt(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=a(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,1),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=0===t)}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=We(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(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 ce()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:o.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&&o.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=i*e.cachedSymbologyStride;N(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,n=de(this.view,this.uid);o.setUidToObjectAndLayerId(t,t,this.layerId,r,this.layerPopupEnabledAndHasTemplate&&!n,e.node.resources.attributes,i,this.sublayerId),s.olidColor=o.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:r})}s.externalColorMixMode=15&t[r+4],s.castShadows=!!(16&t[r+4]),s.pickable=!!(32&t[r+4]),s.elevationOffset=e.elevationOffsets?.[i]??0,s.emissiveStrength=e.emissiveStrengths?.[i]??1,s.emissiveSource=e.emissiveSources?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ue))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=$e(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?oe(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,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=ie(e.featureIds.length*e.cachedSymbologyStride));const d=new Ze,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=1,g=Ke,m=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=Ee(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=ae(this._colorVariable,t,{color:Ft,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=le(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?Me(h,p,e.color,e.alpha,Ct,d.color):Me(h,p,null,null,Ct,d.color)}h??=N(d.color,1,1,1,1);const y=r?.material;if(d.colorMixMode=y?.colorMixMode??1,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=3),d.pickable&&=h[3]>=It,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||3===d.colorMixMode)?1:0;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[f]=g}else e.cachedEdgeMaterials[f]=Ke;e.cachedSymbology[m++]=Math.round(255*h[0]),e.cachedSymbology[m++]=Math.round(255*h[1]),e.cachedSymbology[m++]=Math.round(255*h[2]),e.cachedSymbology[m++]=Math.round(255*h[3]),e.cachedSymbology[m++]=d.colorMixMode|+d.castShadows<<4|+d.pickable<<5;const b=y?.emissive?.strength??pt;b===pt||e.emissiveStrengths||(e.emissiveStrengths=new Array(e.featureIds.length).fill(pt)),e.emissiveStrengths&&(e.emissiveStrengths[f]=b);const v=y?.emissive?.source||0;0===v||e.emissiveSources||(e.emissiveSources=new Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[f]=v)}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||kt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some(e=>e!==Ke),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map((t,o)=>e.featureIds[o]!==i[s]?Ke:(r=r||t!==Ke,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),kt(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,2)}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}_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)?0:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values())if(!(null==s||t&&s.node.serviceMbsInIndexSR&&1===t(s.node.serviceMbsInIndexSR)))switch(i){case 1:this._forAllFeaturesOfNode(s,e);break;case 0:this._forAllVisibleFeaturesOfNode(s,e);break;case 2:this._forAllQueryableFeaturesOfNode(s,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((i,s)=>t(i,s,e))}_forAllVisibleFeaturesOfNode(e,t){const i=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,s=>0===t(i[s],s,e))}_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(0===s)return;if(3===s)return this._forAllFeaturesOfNode(e,i);const r=e.featureIds,o=e.objectHandle,n=Qe(this._renderClippingArea,this._collection.getObjectTransform(o));for(let a=0;a<r.length;a++)this._boundingRectFeatureTest(e,a,n)&&i(r[a],a,e)}_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]=Ee(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){const s=tt(e);if(0===s.length)return it;const r=bt(t),o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return it;const n=this._ensureHighlights(),{set:a,handle:l}=n.acquireSet(r);return n.setFeatureIds(a,o),l}_featureIdsFromGraphics(e){const t=this.i3slayer.fieldsIndex,i=this._getObjectIdField();return e.map(e=>et(t,e.attributes,i))}_ensureHighlights(){return this._highlights??=new xe({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=a(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=m(()=>{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 ge(e))}else this.emit("visible-geometry-changed");this._visibleGeometryChangedSchedulerHandle=null})),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new fe(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;kt(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=Nt(e);if(s){const t={context:i,buffer:s.buffer};be(t);const r=new Float64Array(s.buffer);e.forAll((e,t)=>{const i=r[t],s=ve(i);e.imModificationImpact=s,0!==s&&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.readyToRun||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||0===this.elevationInfo.mode)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=H(),a=H(),l=(e,t)=>{V(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),V(e,e,D(a,a,t)),A(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)1!==t&&2!==t||r.events.remove(i),0!==t&&2!==t||r.events.add(i,s)}_logEdgeViewError(e,t){h(e)||o.getLogger(this).warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>xt?(o.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([y()],T.prototype,"_hasLoadedPBRTextures",void 0),e([y()],T.prototype,"_asyncModuleLoading",void 0),e([y()],T.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([y()],T.prototype,"view",void 0),e([y()],T.prototype,"i3slayer",void 0),e([y()],T.prototype,"_controller",void 0),e([y()],T.prototype,"_labeler",void 0),e([y()],T.prototype,"updating",void 0),e([y()],T.prototype,"suspended",void 0),e([y()],T.prototype,"contentVisible",null),e([y({readOnly:!0})],T.prototype,"legendEnabled",null),e([y(dt)],T.prototype,"updatingProgress",void 0),e([y()],T.prototype,"updatingProgressValue",null),e([y()],T.prototype,"hasTexturesOrVertexColors",null),e([y()],T.prototype,"rendererTextureUsage",null),e([y()],T.prototype,"elevationOffset",null),e([y()],T.prototype,"elevationInfo",null),e([y({type:Boolean})],T.prototype,"slicePlaneEnabled",void 0),e([y()],T.prototype,"supportedTextureEncodings",null),e([y({type:[ne]})],T.prototype,"_modifications",void 0),e([y({readOnly:!0})],T.prototype,"clientGeometry",null),e([y()],T.prototype,"elevationRange",null),e([y()],T.prototype,"fullExtent",null),e([y()],T.prototype,"_elevationTask",void 0),e([y({readOnly:!0})],T.prototype,"_usePBR",null),T=e([b("esri.views.3d.layers.I3SMeshView3D")],T),T},Et=$(),Ot=Q(),Rt=Q(),jt=new at,Ft=new t([0,0,0,0]),Vt=new te(0,0,0,0);function Dt(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 At(e){return"geometryData"in e}function Tt(e){return null!=e&&p(e.data)}function Ht(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&&p(s.data)&&(i+=s.data.byteLength);return i}function Nt(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=jt,e.serviceMbsInIndexSR?(t.center=e.serviceMbsInIndexSR.center,t.halfSize=[e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius]):t.invalidate());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 Pt{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function kt(e,t){e.forEach(e=>e.opacity=t)}class Lt{constructor(e,t){this.mode=e,this.offset=t}}const Ut=H(),Gt=$(),Bt="elevation-change",qt="",zt="@null",Wt="@ECEF",$t=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Kt=new ot;function Qt(e,t,i){let s=e.minElevation,r=e.maxElevation;const o=i;if(o>0){t.getCorners($t);for(const e of $t){const t=T(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners($t);for(const e of $t){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function Jt(e,t,i){const{center:s,radius:r}=t,o=i>0?T(s)-i:s[2];e.expandElevationRangeValues(o-r,o+r)}function Yt(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 Xt(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,n)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(n)})}}else e.featureIds.forEach((e,t)=>{r[s.length]===e&&s.push(t)});return s}function Zt(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)}}function ei(e,t=0){const i=new Map;for(const s of e){Zt(i,0===t?s?.featureIds:1===t?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}export{St as I3SMeshView3D};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s,isSome as r}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import o from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../core/maybe.js";import l from"../../../core/PooledArray.js";import{ignoreAbortErrors as d,isAbortError as h,throwIfAborted as c,createResolver as u}from"../../../core/promiseUtils.js";import{initial as _,watch as g}from"../../../core/reactiveUtils.js";import{schedule as m}from"../../../core/scheduling.js";import{equals as f}from"../../../core/SetUtils.js";import{isArrayBuffer as p}from"../../../core/typedArrayUtil.js";import{property as y,subclass as b}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as v,invert as I}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as M,getTranslation as w}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as x,create as S}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as E}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{h as O,p as R,t as j,a as F,i as V,j as D,e as A,u as T}from"../../../chunks/vec32.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as N}from"../../../chunks/vec42.js";import{fromValues as P}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 U}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as G}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as B}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as q}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as W,create as $,toRect as K}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as J}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y,ensurePackedMat4f64 as X}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{Sphere as te}from"../../../geometry/support/sphere.js";import{newUByteArray as ie}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as se}from"../../../layers/LayerConstants.js";import re from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as oe}from"../../../layers/support/fieldUtils.js";import ne from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as le}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as de}from"../../../support/basemapUtils.js";import{getElevationOffset as he}from"../../../support/elevationInfoUtils.js";import{loadArcade as ce}from"../../../support/loadArcade.js";import ue from"../../../symbols/MeshSymbol3D.js";import _e from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as ge}from"./ContentGeometryLayerView.js";import me from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as fe}from"./I3SMeshViewPerformanceInfo.js";import{initialize as pe,setModificationsSync as ye,filterObbsForModificationsSync as be,interpretObbModificationResults as ve}from"./SceneLayerWorker.js";import{SceneLayerWorkerHandle as Ie,toWasmModification as Ce}from"./SceneLayerWorkerHandle.js";import{overrideColor as Me}from"./graphics/graphicUtils.js";import{areLabelsVisible as we}from"./graphics/Labeler.js";import xe from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Se}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Ee}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Oe,NodeCrossfadeMetaData as Re}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as je}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Fe}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ve,selectEncoding as De,defaultMaterial as Ae,createTexture as Te,configureMaterial as He}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as Ne}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Pe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as ke,checkSceneLayerValid as Le,checkSceneLayerCompatibleWithView as Ue,whenGraphicAttributes as Ge,computeVisibilityObb as Be,filterInPlace as qe,intersectBoundingRectWithMbs as ze,addWraparound as We,getSymbolInfo as $e,transparentEdgeMaterial as Ke,getClipRect as Qe}from"./i3s/I3SUtil.js";import{IDBCache as Je}from"./i3s/IDBCache.js";import{IDBMockCache as Ye}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as Xe}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as Ze}from"./i3s/SymbologyInfo.js";import{attributeLookup as et}from"./support/attributeUtils.js";import{normalizeHighlightTarget as tt,emptyHighlightHandle as it}from"./support/highlightUtils.js";import{makeScheduleFunction as st}from"./support/makeScheduleFunction.js";import{debugFlags as rt}from"../support/debugFlags.js";import{ElevationRange as ot}from"../support/ElevationRange.js";import{toBoundingRect as nt}from"../support/extentUtils.js";import{Obb as at,ensurePackedObbData as lt}from"../support/orientedBoundingBox.js";import{updatingProgress as dt}from"../support/updatingProperties.js";import{glLayout as ht}from"../support/buffer/glUtil.js";import{ObjectParameters as ct}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as ut,SourceParameters as _t,SourceGeometry as gt,GeometryParameters as mt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as ft}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as pt}from"../webgl-engine/core/shaderLibrary/output/Emissions.glsl.js";import{loadBasisTranscoder as yt}from"../webgl-engine/lib/BasisUtil.js";import{getHighlightName as bt}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as vt}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as It}from"../../../webscene/support/AlphaCutoff.js";const Ct=[1,1,1,1];class Mt extends Re{constructor(e,t,i,s,r,o,n,a,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0,this.cachedSymbologyStride=5}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}const wt=26,xt=104857600,St=t=>{const p=t;let T=class extends p{constructor(){super(...arguments),this._applySSAO=!0,this._shadeNormals=!0,this._updatingHandles=new k,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new vt,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 Oe(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerViewUid(){return this.uid}get layerId(){return 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>It}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 ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?63:37:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?he(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new Lt(0,0);const t=he(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new Lt(0,t);case"relative-to-ground":return new Lt(1,t);case"on-the-ground":return new Lt(2,0);default:return new Lt(0,0)}}get supportedTextureEncodings(){return Ve(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new ot;for(const i of e.values()){const e=i?.node.serviceMbsInIndexSR;e&&t.expandElevationRangeValues(e.center[2]-e.radius,e.center[2]+e.radius)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new Ye(this.view,e):new Je("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Ne({view:this.view,layer:this.i3slayer,memoryController:i}),this._workerHandle=new Ie(st(t)),this.addResolvingPromise(this._workerHandle.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(d)),Le(this.i3slayer),Ue(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new re({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection;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 n=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=n;const l=this._controller,h=this._nodeId2Meta,c=this._nodeId2MetaReloading,u=e=>{const t=l.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=h.get(i)||c.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Fe({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:u}),this._elevationProvider=new Xe({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),_),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),_),this._updatingHandles.add(()=>!this.suspended&&0!==this.elevationInfo.mode,(e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",({extent:e})=>this._ensureElevationTask().addExtent(e)),Bt):t&&this.removeHandles(Bt)},_),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e));const m=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add(()=>this.rendererTextureUsage,m),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),_),this._updatingHandles.add(()=>this.i3slayer.labelsVisible,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this.i3slayer.labelingInfo,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),_),this.addHandles([g(()=>rt.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&rt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||rt.I3S_TREE_SHOW_TILES||(this._treeDebugger=a(this._treeDebugger))},_),g(()=>rt.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),_)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>o.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));const{view:f}=this,{viewingMode:p,renderCoordsHelper:y}=f;this._planetRadiusInGlobalMode="local"===p?0:y.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=a(this._elevationTask),this.i3sOverrides=a(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.notifyObjectsChanged(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._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=a(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=a(this._labeler),this._treeDebugger=a(this._treeDebugger),this._controller=a(this._controller),this._highlights=a(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=a(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=a(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(!(we(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new me({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=pe().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()}),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=e=>o.getLogger(this).error("set-modifications-error","Error when setting modifications:",e),t=this.uid,i=this.i3slayer.spatialReference,s=i.isGeographic,r=Ce(this._layerClippingArea,this._modifications,i);this._workerHandle.setModifications(t,r,s).catch(e);try{ye({context:t,modifications:r,isGeodetic:s})}catch(a){e(a)}this._controller.modificationsChanged();const n=this.hasModifications?new l: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!=n&&n.push(e.node)}),this.notifyChange("elevationRange"),null!=n&&this._nodeId2MetaReloading.forEach(e=>n.push(e.node)),null!=n&&n.length>0&&(this.updateNodeModificationStatus(n),n.forAll(e=>{if(2!==e.imModificationImpact){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),!rt.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 _e({...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=>{h(e)||o.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")&&2&this.supportedTextureEncodings&&this.i3slayer.textureSetDefinitions?.some(e=>e.formats.some(e=>"basis"===e.format||"ktx2"===e.format))&&yt()}_getVertexBufferLayout(e,t){return ht(ut(this._getGeometryParameters({hasTexture:Dt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.i3slayer.objectIdField||se}_getGlobalIdField(){return this.i3slayer.globalIdField}_findGraphicNodeAndIndex(e){const t=et(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 n of t){const e=et(o,n.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=je(t,this._collection,s,Y(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;return B(r,o,0,r,n,0)?W(r):null}whenGraphicAttributes(e,t){return Ge(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 s?t.defer?(t.defer(async()=>(s.geometry=(await import("./i3s/meshUtils.js")).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),s)),null):s:null}_getCacheKey(e){return`${this._layerUrl}/v${wt}/${e}${this._cacheKeySuffix}`}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return zt;if(e===L(e))return Wt;return this.i3slayer.spatialReference.equals(e)?qt: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=De(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.globalTrafo=X(s.globalTrafo),s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=at.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then(i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Ht(s.transformedGeometry,s.textureData),s.textureData.every(Tt)&&this._indexedDbSizeCheck(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch(t=>o.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),c(t),s))))):Promise.resolve(null)}addNode(e,t,i){return At(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);const{obb:r,componentOffsets:n,featureIds:a,anchorIds:l,anchors:d,transformedGeometry:h}=s;e.hasModifications=h.hasModifications;const c=X(s.globalTrafo),u=O(Ut,r.center.x,r.center.y,r.center.z);R(u,u,c);const _=new at(u,[r.extents.x,r.extents.y,r.extents.z],E(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=_),t.geometryData.componentOffsets=n,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=l,t.geometryData.anchors=d;const g={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:h,globalTrafo:c,geometryObbData:_.data,byteSize:Ht(h,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,g)){const t=null!=g.textureData?g.textureData.map(e=>Tt(e)?e:null):null;this._idbCache.put(this._getCacheKey(e.id),{...g,textureData:t}).catch(t=>o.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,g,i)},i))):Promise.reject()}getElevationRange(e){const t=new ot,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e.radius,a=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=a.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=a.calculateServiceMbsInRenderSR(i),d&&(_=d.radius);if(_>=0&&n>=1*_)return null!=r?Qt(t,r,l):null!=d&&d.radius>=0&&Jt(t,d,l),!1;const g=Kt;if(g.minElevation=1/0,g.maxElevation=-1/0,(null!=r||null!=d)&&(null!=r?Qt(g,r,l):null!=d&&Jt(g,d,l),g.minElevation>=t.minElevation&&g.maxElevation<=t.maxElevation))return!1;const m=o.get(i.index);if(m){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(n>0*s.radius)return Qt(t,s,l),!1}const{objectHandle:e}=m,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(m?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Be(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,n=t.normalReferenceFrame??o??"none",a=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=Pe(a,l,n,d,c),_=q(d,h),g=q(h,c);if(null==_||null==g)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:a.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._controller.isMeshPyramid,normalReferenceFrame:n,indexToVertexProjector:_,vertexToRenderProjector:g};return this._workerHandle.invoke(m,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(0===this.elevationInfo.mode&&(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),0!==this.elevationInfo.mode&&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:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter(e=>null!=e&&0!==(e.usage&this.rendererTextureUsage)):[];!has("disable-feature:i3s-basis")&&a.some(e=>null!=e&&(2===e.encoding||1===e.encoding))&&await yt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:f,interleavedVertexData:p,positionData:y,hasColors:b}=n,{material:E,geometryParameters:O}=this._materialParameters(g,m),R=l||new Uint32Array([0,f?f.length:p.byteLength/m[0].stride]),V=new _t(m,O.shadeNormals,O.applySSAO,O.textureCoordinateType),D=new gt({data:p,count:p.byteLength/m[0].stride},{positions:Z(y.data),indices:ee(y.indices)},f,R,V),A=g.transformation?x(g.transformation):S(),T=X(t.globalTrafo);M(A,T,A);const N=w(H(),A),k=v(C(),A),L=this.view.renderSpatialReference,G=this.view.basemapTerrain.spatialReference,B=at.fromData(lt(t.geometryObbData)).center,q=[1,1,1];U(B,L,q,G)||o.getLogger(this).errorOnce("Unsupported coordinate system for IM overlay");const W=H();z(B,L,W,G);const $=C();I($,k);const K=H();j(K,F(K,B,N),$);const Q=W[0]-K[0]*q[0],J=W[1]-K[1]*q[1],Y=_.createObject(new ct(P(Q,J,q[0],q[1]),new ft(N,k),at.fromData(lt(t.geometryObbData)),D,!this._isIntegratedMesh)),te=2===O.textureCoordinateType,{textures:ie,texturePromise:se}=this._initMaterialAndTextures(Y,E,a,te,e);e.memory+=this._memEstimateGeometryAdded(Y),e.memory+=ie.reduce((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0),0);const re=!!E.hasParametersFromSource,oe="blend"!==E.alphaMode&&E.metallicRoughness.baseColorFactor[3]>=1,ne=new Mt(e,h,Y,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:re,isOpaque:oe},ie,c,u);s.meta=ne,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(19&e))||!!e.resources.texture,this._hasData=!0,this._hasColors||=b,this.notifyChange("hasTexturesOrVertexColors");const ae=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(ne),se]).then(([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(ne.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,ne),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(Y,!0),t?.updateObjectVisibility(ne.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),ne.attributeInfo=i.attributeInfo;const s=ne.cachedRendererVersion!==this._rendererVersion,r=ae!==this.slicePlaneEnabled;this._updateElevationOffsets(ne);const o=ne.elevationOffsets;this._updateComponentData(ne);const n=this._applyFiltersToNode(ne);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(ne),null!=this._labeler&&this._addMetaToLabeler(this._labeler,ne),this._visibleGeometryChanged(ne,0),this._highlights?.objectCreated(ne),this._updateMaterial(ne),this._setNewNodeOpacity(ne),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)){o.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&&kt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;const{view:t,elevationInfo:i}=this,s=this._controller.crsIndex,{groundView:r,groundSpatialReference:o,renderSpatialReference:n}=t,a=i.mode;if(null==n||null==o||0===a)return void(e.elevationOffsets=null);const l=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const d=Ut,h=Gt,c=2===a,u=this.view.renderCoordsHelper,_=e.featureIds.length,g=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const t=Y(3*_);e.cachedElevationAnchors=t;const{center:i}=e.node.serviceMbsInIndexSR;for(let r=0;r<_;r++){const a=3*r,c=e.anchorIds?.indexOf(r)??-1;e.anchors&&c>=0?(O(d,e.anchors[3*c],e.anchors[3*c+1],e.anchors[3*c+2]),V(d,d,i),z(d,s,d,o),t[a]=d[0],t[a+1]=d[1],t[a+2]=u.getAltitude(d)):(this._collection.getComponentAabb(e.objectHandle,r,h,!0),O(d,(h[0]+h[3])/2,(h[1]+h[4])/2,h[2]),j(d,d,l.rotationScale),V(d,d,l.position),t[a+2]=u.getAltitude(d),z(d,n,d,o),t[a]=d[0],t[a+1]=d[1])}return t})(),m=i.offset,f=e.elevationOffsets,p=(e,t)=>{const i=c?g[3*e+2]:0;f[e]=m+(t??0)-i};r.getElevations(g,_,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Se(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=0!==e.mode,s=!!t&&t!==e&&0!==t.mode;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,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return c(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ae(),s=t.some(({name:e})=>"uvRegion"===e),r=t.some(({name:e})=>"normalCompressed"===e),o=Dt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s,r){const o=this._stage.renderView,n=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,r.memory-=e},a=i.map(e=>Te(e,t,s,o,this._compressionTracker,n));this._stage.addTextures(a);let l=null;return this._collection.updateMaterial(e,e=>{l=He(e,t,a,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:a,texturePromise:l}}_getGeometryParameters(e){return new mt(this._hasVertexColors,e.hasTexture?e.hasRegions?2:1:0,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=u();s=new Pt(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=Q();this._renderClippingArea=nt(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=nt(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=ei(this._nodeId2Meta.values()),this._filteredIdCounts=ei(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=ei(this._nodeId2Meta.values(),2),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,Zt(this._featureIdCounts,e.featureIds,t),Zt(this._filteredIdCounts,e.filteredIds,t),Zt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,Zt(this._filteredIdCounts,t,-1),Zt(this._filteredIdCounts,e.filteredIds,1),Zt(this._weaklyRemovedIdCounts,i,-1),Zt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&o.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=ei(this._nodeId2Meta.values());n(this._featureIdCounts,t)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=ei(this._nodeId2Meta.values(),1);n(this._filteredIdCounts,i)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=ei(this._nodeId2Meta.values(),2);n(this._weaklyRemovedIdCounts,s)||o.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))}}f(e,this._mismatchShow)&&f(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;const t=Xt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_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,2))})}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={},n=this._createLayerGraphic(o);if(!n)return;const a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every(e=>e===a||null!=d?.[e])&&qe(e,l,e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?Ee(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}})}_boundingRectNodeTest(e,t){return G(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Vt,this.view.renderSpatialReference),ze(t,Vt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Et),K(Et,Ot),J(i,Ot)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(3===r)return;if(0===r)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Rt,i,t.objectHandle);qe(e,t.featureIds,e=>this._boundingRectFeatureTest(t,e,n))}_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 n=o.hasObject(i);if(s){if(n){if(this.nodeCrossfadingEnabled){kt(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 n&&(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=Yt(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=Xt(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=a(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,1),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=0===t)}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=We(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(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 ce()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:o.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&&o.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=i*e.cachedSymbologyStride;N(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,n=de(this.view,this.uid);o.setUidToObjectAndLayerId(t,t,this.layerId,r,this.layerPopupEnabledAndHasTemplate&&!n,e.node.resources.attributes,i,this.sublayerId),s.olidColor=o.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:r})}s.externalColorMixMode=15&t[r+4],s.castShadows=!!(16&t[r+4]),s.pickable=!!(32&t[r+4]),s.elevationOffset=e.elevationOffsets?.[i]??0,s.emissiveStrength=e.emissiveStrengths?.[i]??1,s.emissiveSource=e.emissiveSources?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ue))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=$e(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?oe(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,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=ie(e.featureIds.length*e.cachedSymbologyStride));const d=new Ze,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=1,g=Ke,m=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=Ee(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=ae(this._colorVariable,t,{color:Ft,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=le(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?Me(h,p,e.color,e.alpha,Ct,d.color):Me(h,p,null,null,Ct,d.color)}h??=N(d.color,1,1,1,1);const y=r?.material;if(d.colorMixMode=y?.colorMixMode??1,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=3),d.pickable&&=h[3]>=It,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||3===d.colorMixMode)?1:0;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[f]=g}else e.cachedEdgeMaterials[f]=Ke;e.cachedSymbology[m++]=Math.round(255*h[0]),e.cachedSymbology[m++]=Math.round(255*h[1]),e.cachedSymbology[m++]=Math.round(255*h[2]),e.cachedSymbology[m++]=Math.round(255*h[3]),e.cachedSymbology[m++]=d.colorMixMode|+d.castShadows<<4|+d.pickable<<5;const b=y?.emissive?.strength??pt;b===pt||e.emissiveStrengths||(e.emissiveStrengths=new Array(e.featureIds.length).fill(pt)),e.emissiveStrengths&&(e.emissiveStrengths[f]=b);const v=y?.emissive?.source||0;0===v||e.emissiveSources||(e.emissiveSources=new Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[f]=v)}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||kt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some(e=>e!==Ke),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map((t,o)=>e.featureIds[o]!==i[s]?Ke:(r=r||t!==Ke,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),kt(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,2)}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}_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)?0:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values())if(!(null==s||t&&s.node.serviceMbsInIndexSR&&1===t(s.node.serviceMbsInIndexSR)))switch(i){case 1:this._forAllFeaturesOfNode(s,e);break;case 0:this._forAllVisibleFeaturesOfNode(s,e);break;case 2:this._forAllQueryableFeaturesOfNode(s,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((i,s)=>t(i,s,e))}_forAllVisibleFeaturesOfNode(e,t){const i=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,s=>0===t(i[s],s,e))}_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(0===s)return;if(3===s)return this._forAllFeaturesOfNode(e,i);const r=e.featureIds,o=e.objectHandle,n=Qe(this._renderClippingArea,this._collection.getObjectTransform(o));for(let a=0;a<r.length;a++)this._boundingRectFeatureTest(e,a,n)&&i(r[a],a,e)}_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]=Ee(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){const s=tt(e);if(0===s.length)return it;const r=bt(t),o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return it;const n=this._ensureHighlights(),{set:a,handle:l}=n.acquireSet(r);return n.setFeatureIds(a,o),l}_featureIdsFromGraphics(e){const t=this.i3slayer.fieldsIndex,i=this._getObjectIdField();return e.map(e=>et(t,e.attributes,i))}_ensureHighlights(){return this._highlights??=new xe({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=a(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=m(()=>{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 ge(e))}else this.emit("visible-geometry-changed");this._visibleGeometryChangedSchedulerHandle=null})),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new fe(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;kt(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=Nt(e);if(s){const t={context:i,buffer:s.buffer};be(t);const r=new Float64Array(s.buffer);e.forAll((e,t)=>{const i=r[t],s=ve(i);e.imModificationImpact=s,0!==s&&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.readyToRun||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||0===this.elevationInfo.mode)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=H(),a=H(),l=(e,t)=>{V(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),V(e,e,D(a,a,t)),A(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)1!==t&&2!==t||r.events.remove(i),0!==t&&2!==t||r.events.add(i,s)}_logEdgeViewError(e,t){h(e)||o.getLogger(this).warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>xt?(o.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([y()],T.prototype,"_hasLoadedPBRTextures",void 0),e([y()],T.prototype,"_asyncModuleLoading",void 0),e([y()],T.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([y()],T.prototype,"view",void 0),e([y()],T.prototype,"i3slayer",void 0),e([y()],T.prototype,"_controller",void 0),e([y()],T.prototype,"_labeler",void 0),e([y()],T.prototype,"updating",void 0),e([y()],T.prototype,"suspended",void 0),e([y()],T.prototype,"contentVisible",null),e([y({readOnly:!0})],T.prototype,"legendEnabled",null),e([y(dt)],T.prototype,"updatingProgress",void 0),e([y()],T.prototype,"updatingProgressValue",null),e([y()],T.prototype,"hasTexturesOrVertexColors",null),e([y()],T.prototype,"rendererTextureUsage",null),e([y()],T.prototype,"elevationOffset",null),e([y()],T.prototype,"elevationInfo",null),e([y({type:Boolean})],T.prototype,"slicePlaneEnabled",void 0),e([y()],T.prototype,"supportedTextureEncodings",null),e([y({type:[ne]})],T.prototype,"_modifications",void 0),e([y({readOnly:!0})],T.prototype,"clientGeometry",null),e([y()],T.prototype,"elevationRange",null),e([y()],T.prototype,"fullExtent",null),e([y()],T.prototype,"_elevationTask",void 0),e([y({readOnly:!0})],T.prototype,"_usePBR",null),T=e([b("esri.views.3d.layers.I3SMeshView3D")],T),T},Et=$(),Ot=Q(),Rt=Q(),jt=new at,Ft=new t([0,0,0,0]),Vt=new te(0,0,0,0);function Dt(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 At(e){return"geometryData"in e}function Tt(e){return null!=e&&p(e.data)}function Ht(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&&p(s.data)&&(i+=s.data.byteLength);return i}function Nt(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=jt,e.serviceMbsInIndexSR?(t.center=e.serviceMbsInIndexSR.center,t.halfSize=[e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius]):t.invalidate());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 Pt{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function kt(e,t){e.forEach(e=>e.opacity=t)}class Lt{constructor(e,t){this.mode=e,this.offset=t}}const Ut=H(),Gt=$(),Bt="elevation-change",qt="",zt="@null",Wt="@ECEF",$t=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Kt=new ot;function Qt(e,t,i){let s=e.minElevation,r=e.maxElevation;const o=i;if(o>0){t.getCorners($t);for(const e of $t){const t=T(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners($t);for(const e of $t){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function Jt(e,t,i){const{center:s,radius:r}=t,o=i>0?T(s)-i:s[2];e.expandElevationRangeValues(o-r,o+r)}function Yt(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 Xt(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,n)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(n)})}}else e.featureIds.forEach((e,t)=>{r[s.length]===e&&s.push(t)});return s}function Zt(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)}}function ei(e,t=0){const i=new Map;for(const s of e){Zt(i,0===t?s?.featureIds:1===t?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}export{St as I3SMeshView3D};
|