@arcgis/core 6.0.0-next.54 → 6.0.0-next.55
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/WebScene.js +2 -2
- package/applications/Components/OrientedImageryViewer/shared/constants.js +1 -1
- package/applications/SceneViewer/sceneViewerUtils.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/arcadeRuntime.js +1 -1
- package/arcade/featureset/support/sqlUtils.js +1 -1
- package/arcade/validation/arcadeValidator.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0329fa3aa3403f1c243b.js +1 -0
- package/assets/esri/core/workers/chunks/{6602310c3fcd91fb6a2f.js → 07c8ac092e4b9e8d5b3c.js} +1 -1
- package/assets/esri/core/workers/chunks/0a97b1974367382cfdf5.js +1 -0
- package/assets/esri/core/workers/chunks/{db0a7671ab5cbe8afd72.js → 123661019bb69c53f2d3.js} +1 -1
- package/assets/esri/core/workers/chunks/{d14732a57c8e63948c60.js → 14259910f44c08fd5bbd.js} +1 -1
- package/assets/esri/core/workers/chunks/{1b41ba050cde068d2860.js → 193a73a2c7f4f8482c21.js} +1 -1
- package/assets/esri/core/workers/chunks/20acb6f3ed5140b6c6c6.js +1 -0
- package/assets/esri/core/workers/chunks/{e507dfc4788295d9c244.js → 249a687ce1b6d0815242.js} +1 -1
- package/assets/esri/core/workers/chunks/{afb4dfb89fbc8a342cc5.js → 3354f1fa90f8ce4c8fde.js} +1 -1
- package/assets/esri/core/workers/chunks/{9b458b0d1627f22fdd93.js → 3b11e4d2e69b7aea1d65.js} +1 -1
- package/assets/esri/core/workers/chunks/41694ee8990e799da225.js +1 -0
- package/assets/esri/core/workers/chunks/{e592f2483db71230e8e5.js → 4401b3f8ebb658abe789.js} +1 -1
- package/assets/esri/core/workers/chunks/{12add2003631fa314f25.js → 5060be52a380fc4920f8.js} +1 -1
- package/assets/esri/core/workers/chunks/{2aa6be0b047a1b25a520.js → 53bbb9aa6e4e4a0a8121.js} +1 -1
- package/assets/esri/core/workers/chunks/{4707aedcc1b3bdf5e987.js → 5c34d49a6c9cc34b7626.js} +1 -1
- package/assets/esri/core/workers/chunks/69a09c6acb5ae03c67f6.js +1 -0
- package/assets/esri/core/workers/chunks/7b156905d168bf973518.js +1 -0
- package/assets/esri/core/workers/chunks/{e83806797979138fd22a.js → 844c593754b2692257f4.js} +1 -1
- package/assets/esri/core/workers/chunks/{2d3e977f3b75474d7ebc.js → 846248697c398468d8e6.js} +1 -1
- package/assets/esri/core/workers/chunks/{f7e33d37dd11fb08f3f8.js → 97107e64407fa6825620.js} +1 -1
- package/assets/esri/core/workers/chunks/{032733b863426c5bde00.js → 9e508f930086d2ef5f22.js} +3 -3
- package/assets/esri/core/workers/chunks/{5118c7269b706089c88e.js → a05a2c2aaf0c288f9681.js} +1 -1
- package/assets/esri/core/workers/chunks/{817bf487df056da1e6ec.js → a116dd204921e7464944.js} +1 -1
- package/assets/esri/core/workers/chunks/{944f17e9c9f681b971fb.js → a12e2a345005189c64be.js} +1 -1
- package/assets/esri/core/workers/chunks/{15b3386ad92a0b4149b8.js → a24dc5350af001db417a.js} +1 -1
- package/assets/esri/core/workers/chunks/{10967a36c77c5188690d.js → a66d6298236d59a615db.js} +1 -1
- package/assets/esri/core/workers/chunks/{255f5b45c4d32f97f86c.js → ac0861014b3d2f1a1de2.js} +1 -1
- package/assets/esri/core/workers/chunks/ace210d313ce53f3ae10.js +1 -0
- package/assets/esri/core/workers/chunks/ae48ee283cfa5b3c14b0.js +1 -0
- package/assets/esri/core/workers/chunks/bbd8fcb0bbba7bde3d9b.js +1 -0
- package/assets/esri/core/workers/chunks/{ac8d38016e4bee37a77c.js → be0b8bb4f09aae6ff5de.js} +1 -1
- package/assets/esri/core/workers/chunks/d0659f1b0495734be4b3.js +1 -0
- package/assets/esri/core/workers/chunks/{b9a2b05ede02c305e865.js → d8ffb1502def5c85740b.js} +1 -1
- package/assets/esri/core/workers/chunks/{7dfe1e78d2e66de6be22.js → d9ef244019954d5a8a27.js} +1 -1
- package/assets/esri/core/workers/chunks/{95403bb27a4ea0a4b7b1.js → ddbfa664e69612295785.js} +1 -1
- package/assets/esri/core/workers/chunks/{c6d82397044e403a1f61.js → e61082f56c08abe54b3a.js} +1 -1
- package/assets/esri/core/workers/chunks/{55d28d3f5b8ced061e39.js → eaf73ce60f39a48ddd2a.js} +1 -1
- package/assets/esri/core/workers/chunks/ed2f2a5da830d058e339.js +1 -0
- package/assets/esri/core/workers/chunks/{944cb751c85d3a127f49.js → f52d081bbde5c95265cf.js} +1 -1
- package/assets/esri/core/workers/chunks/{1de9be7b65109c207bd5.js → fbd5f3b81cd9f061824d.js} +1 -1
- package/assets/esri/layers/raster/formats/blosc-wasm.wasm +0 -0
- package/assets/esri/libs/librust-parquet/pkg/parquet_bg.wasm +0 -0
- package/basemapGallery/support/basemapCompatibilityUtils.js +1 -1
- package/chunks/CypherParser.js +1 -1
- package/chunks/GeodeticDistanceCalculator-zRp89-dW.js +1 -1
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/UnitFactory.js +1 -1
- package/chunks/blosc-wasm.js +2 -0
- package/chunks/cameraUtilsSpherical.js +1 -1
- package/chunks/parquet.js +1 -1
- package/chunks/text.js +1 -1
- package/config.js +1 -1
- package/core/sql/SqlInterval.js +1 -1
- package/core/urlUtils.js +1 -1
- package/geometry/geometryEngine.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/support/Ellipsoid.js +1 -1
- package/geometry/support/curves/ellipticArc7Utils.js +1 -1
- package/geometry/support/geodesicConstants.js +1 -1
- package/geometry/support/meshUtils/primitives.js +1 -1
- package/kernel.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/effects/parser.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/parquet.js +1 -1
- package/layers/raster/datasets/ZarrRaster.js +1 -1
- package/layers/raster/datasets/wcsCoverageParser.js +1 -1
- package/layers/raster/formats/RasterCodec.js +1 -1
- package/layers/raster/formats/blosc.js +2 -0
- package/layers/support/BuildingFilter.js +1 -1
- package/layers/support/IntegratedMeshSemantics.js +1 -1
- package/layers/support/fieldUtils.d.ts +23 -87
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/layersMapping.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/legend/ActiveLayerInfo.js +1 -1
- package/libs/ajv/ajv.bundle-wrapper.js +1 -1
- package/package.json +4 -4
- package/renderers/types.d.ts +1 -1
- package/rest/knowledgeGraphService.js +1 -1
- package/rest/query/operations/pbfFeatureServiceParser.js +1 -1
- package/smartMapping/statistics/support/attributeDensity.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/support/tests/serviceMockDependencies.js +1 -1
- package/symbols/cim/CIMEffects.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
- package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
- package/symbols/cim/rasterizingUtils.js +1 -1
- package/views/2d/PaddedViewState.js +1 -1
- package/views/2d/engine/vectorTiles/buckets/FillBucket.js +1 -1
- package/views/2d/engine/vectorTiles/constants.js +1 -1
- package/views/2d/engine/vectorTiles/style/geoJSONVectorTileUtils.js +1 -1
- package/views/2d/engine/webgl/effects/HighlightEffect.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/segmentUtils.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/constants.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
- package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
- package/views/2d/layers/ParquetLayerView2D.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
- package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightItemManipulatedObject3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedObserverManipulatedObject3D.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSnappingController.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementVisualization.js +1 -1
- package/views/3d/animation/pointToPoint/Camera.js +1 -1
- package/views/3d/camera/constraintUtils.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/environment/EnvironmentView.js +1 -1
- package/views/3d/focusAreaUtils.js +1 -1
- package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
- package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/config.js +1 -1
- package/views/3d/interactive/editingTools/media/MediaElementControllerControlPoints.js +1 -1
- package/views/3d/interactive/editingTools/media/MediaElementControllerShape.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateMeshAdapter.js +1 -1
- package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/TiledLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolFactory.js +1 -1
- package/views/3d/layers/graphics/LabelInfo.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.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/I3SMeshViewFilter.js +1 -1
- package/views/3d/layers/i3s/I3SNode.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3DContext.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
- package/views/3d/layers/support/Tiles3DLayerViewRegistration.js +1 -1
- package/views/3d/layers/support/selectTiles3DSpatialReference.js +1 -1
- package/views/3d/layers/support/uvUtils.js +1 -1
- package/views/3d/state/Constraints.js +1 -1
- package/views/3d/state/ConstraintsManager.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
- package/views/3d/state/controllers/PointToPointAnimationController.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/state/utils/OffsetCorrectionController.js +1 -1
- package/views/3d/state/utils/groundNavigationUtils.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/FrustumExtentIntersection.js +1 -1
- package/views/3d/support/RenderCoordsHelper.js +1 -1
- package/views/3d/support/SweptSphereVolume.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/elevationUpdateExtentUtils.js +1 -1
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/engineContent/marker.js +1 -1
- package/views/3d/support/hitTest.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
- package/views/3d/support/pointsOfInterest/SurfaceGeometryUpdates.js +1 -1
- package/views/3d/support/sunUtils.js +1 -1
- package/views/3d/terrain/ExtentHelper.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TilingSchemeLogic.js +1 -1
- package/views/3d/terrain/terrainUtils.js +1 -1
- package/views/3d/webgl/RenderCamera.js +1 -1
- package/views/3d/webgl-engine/Stage.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentGeometryBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/atmosphere/MarsAtmosphere.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
- package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/Intersector.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/strokes.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PolygonOffset.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/MapView.d.ts +1 -0
- package/views/SceneView.js +1 -1
- package/views/View2D.js +1 -1
- package/views/ViewingMode.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileChartBoundsUtils.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
- package/views/draw/DrawAction.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/SegmentDrawAction.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/helpMessageUtils.js +1 -1
- package/views/draw/support/managers/EditSessionManager.js +1 -1
- package/views/interactive/dragEventPipeline.js +1 -1
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
- package/views/interactive/editGeometry/operations/AddOrUpdatePart.js +1 -1
- package/views/layers/support/editableLayerViews.js +1 -1
- package/views/overlay/TextOverlayItem.js +1 -1
- package/views/support/DefaultsFromMap.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/views/support/spatialReferenceSupport.js +1 -1
- package/views/webgl/ShaderTranspiler.js +2 -2
- package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
- package/widgets/BasemapGallery/support/basemapCompatibilityUtils.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Legend/styles/card/ColorRamp.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Measurement.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageMeasurementWidget.js +1 -1
- package/widgets/Search/support/layerSearchUtils.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
- package/widgets/UtilityNetworkAssociations.js +1 -1
- package/widgets/Weather/WeatherViewModel.js +1 -1
- package/widgets/Weather/css.js +1 -1
- package/widgets/Weather.js +1 -1
- package/assets/esri/core/workers/chunks/021bd07b9a3e70598840.js +0 -1
- package/assets/esri/core/workers/chunks/170e68624b71ac96de4a.js +0 -1
- package/assets/esri/core/workers/chunks/8a820e303941b351de81.js +0 -1
- package/assets/esri/core/workers/chunks/90d567e920b6982b402d.js +0 -1
- package/assets/esri/core/workers/chunks/97cdcedfe853280f6258.js +0 -1
- package/assets/esri/core/workers/chunks/9ebc6026934400fc1e1f.js +0 -1
- package/assets/esri/core/workers/chunks/b4a325dcf50e276751d7.js +0 -1
- package/assets/esri/core/workers/chunks/be5857b0d1b00faf430b.js +0 -1
- package/assets/esri/core/workers/chunks/cd9100a7c8309dfa7569.js +0 -1
- package/assets/esri/core/workers/chunks/e58f51618251f74aaafd.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../../../core/Error.js";import{ONES as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{normalFromMat4 as n}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{exactEquals as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{assertIsSome as a}from"../../../../core/maybe.js";import{MinPriority as o}from"../../../../core/MemCache.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{generateUUID as c}from"../../../../core/uuid.js";import{projectBoundingSphere as l}from"../../../../geometry/projection/projectBoundingSphere.js";import{ensurePackedArray as u}from"../../../../geometry/support/DoubleArray.js";import{isRelativeVertexSpace as d}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{Sphere as f}from"../../../../geometry/support/sphere.js";import{CachedMeshData as p}from"./CachedMeshData.js";import{convertMeshMaterialToPBRMaterial as m}from"./I3SClientMaterialUtil.js";class h{constructor(e,t,n,r,i,a){this.id=e,this.version=t,this.mbs=n,this.oid=r,this.componentNodeIds=i,this.unloadedMesh=a,this.type=`mesh`}}class g{constructor(e,t,n){this.id=e,this.meshNodeInfo=t,this.componentIndex=n,this.type=`mesh-component`,this.textureData=new Map}get mbs(){return this.meshNodeInfo.mbs}}class _{constructor(e,t,n,r){this._uid=e,this._worker=r,this._id2Meta=new Map,this._oid2Meta=new Map,this._indexSR=t.indexSR,this._vertexSR=t.vertexSR,this._renderSR=t.renderSR,this._memCache=n.newCache(`sl-client-mesh-data-${this._uid}`)}get uid(){return this._uid}get worker(){return this._worker}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){let n=`mesh${t}`,r=e.extent,i=r.spatialReference,a=this._indexSR,o=y(r,e.origin);l(o,i,o,a);let s=C(e);return new h(n,s,o,t,[],e)}addMeshNode(t,n){if(this.getMeshNodeIndex(n.oid)!=null)throw new e(`scenelayer`,`I3SClientNodeLoader: client side mesh for feature oid=${n.oid} already exists`);n.nodeIndex=t,this._id2Meta.set(n.id,n),this._oid2Meta.set(n.oid,n)}getMeshNodeIndex(e){let t=this._oid2Meta.get(e);return t==null||t.type!==`mesh`?null:t.nodeIndex}getMeshNodeInfo(e){let t=this._oid2Meta.values();for(let n of t)if(n.type===`mesh`&&n.id===e)return n;return null}removeNode(e){let t=this._id2Meta.get(e);t!=null&&(this._id2Meta.delete(e),t.type===`mesh`&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(t){let n=this._id2Meta.get(t);if(n==null)throw new e(`scenelayer`,`I3SClientNodeLoader::loadNodeJSON unable to find node ${t}`);switch(n.type){case`mesh`:return this._loadMeshNodeJSON(n);case`mesh-component`:return v(n);default:throw new e(`scenelayer`,`I3SClientNodeLoader::loadNodeJSON unable to handle node ${t}`)}}async _loadMeshNodeJSON(e){let t=e.id,n=(await this._getMeshData(e)).loadedMesh;if(n.components==null||n.components.length===0)return{id:t,mbs:e.mbs.toVec4()};let r=[],i=n.components;for(let n=0;n<i.length;++n){let i=`${t}-component${n}`,a=new g(i,e,n);this._id2Meta.set(a.id,a),e.componentNodeIds.push(i),r.push({id:a.id,mbs:a.mbs.toVec4()})}return{id:t,mbs:e.mbs.toVec4(),children:r}}updateNodeIndex(e,t,n){let r=this._id2Meta.get(e);r?.type===`mesh`&&(r.nodeIndex=n)}async loadNodeData(t,n){let r=this._id2Meta.get(t);if(r==null||r.type!==`mesh-component`)throw new e(`scenelayer`,`Failed to load client node data for node ${t} (unexpected node info)`);let i=r.meshNodeInfo,o=await this._getMeshData(i),c=o.loadedMesh,l=i.oid;if(c.components==null)throw new e(`scenelayer`,`Failed to load client node data for node ${t} (unexpected null reference)`);let d=c.components[r.componentIndex],{material:f,requiredTextures:p,textureData:h}=await m(d.material);if(h!=null)for(let e of h)e!=null&&r.textureData.set(e.id,e);let{vertexSpace:g,origin:_,transform:v}=c,y=[_.x,_.y,_.z??0];o.projectionPromise||=(a(this._worker,`SceneLayerWorker is needed to project mesh`),this._worker.project({positions:c.vertexAttributes.position,localMatrix:v?.localMatrix,vertexSpace:g.toJSON(),origin:y,inSpatialReference:c.spatialReference.toJSON(),outSpatialReference:this._vertexSR.toJSON()},n));let{projected:S,original:C,projectedOrigin:w}=await o.projectionPromise,T=u(w);c.vertexAttributes.position=C;let{transformed:E,original:D}=await b(d,o,this._worker,n);c.vertexAttributes.normal=D,s(n);let{geometryBuffer:O,geometryDescriptor:k}=x(S,d.faces,E,c.vertexAttributes.uv,c.vertexAttributes.color,l);return{geometryData:{featureDataPosition:T,featureIds:[],geometries:[{params:{material:f},type:`ArrayBufferView`}]},attributeDataInfo:{attributeData:{},loadedAttributes:[]},geometryBuffer:O,geometryDescriptor:k,requiredTextures:p,textureData:h,normalReferenceFrame:this._vertexSR.isGeographic?`east-north-up`:`vertex-reference-frame`}}async loadAttributes(e,t){let n=e.numFeatures,r={};for(let{field:{name:e}}of t)r[e]=Array(n);return r}async loadTextures(e,t){let n=e.id,r=this._id2Meta.get(n);if(r==null||r.type!==`mesh-component`)throw Error(`Failed to load textures for node ${e.id} (unexpected node info)`);return Array.from(t,e=>r.textureData.get(e.id)||null)}async _getMeshData(e){let t=e.version;return this._memCache.get(t)??(e.loadMeshPromise??=(async()=>{let n=e.unloadedMesh.clone();await n.load();let r=new p(n);return this._memCache.put(t,r,o),e.loadMeshPromise=null,r})(),e.loadMeshPromise)}}async function v(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs.toVec4(),isEmpty:!1}}function y(e,t){let{spatialReference:n}=e,r=[1,-1],i=[e.width*.5,e.height*.5,e.hasZ?(e.zmax-e.zmin)*.5:0],a=n.isGeographic?n.metersPerUnit:1,o=e.center,s=0;if(e.hasZ)for(let e=0;e<2;++e)for(let n=0;n<2;++n)for(let c=0;c<2;++c){let l=(o.x+r[e]*i[0]-t.x)*a,u=(o.y+r[n]*i[1]-t.y)*a,d=o.z+r[c]*i[2]-t.z;s=Math.max(l*l+u*u+d*d,s)}else for(let e=0;e<2;++e)for(let n=0;n<2;++n){let c=(o.x+r[e]*i[0]-t.x)*a,l=(o.y+r[n]*i[1]-t.y)*a;s=Math.max(c*c+l*l,s)}return new f(t.x,t.y,t.z??0,Math.sqrt(s))}async function b(e,o,s,c){let{transform:l,vertexAttributes:u}=o.loadedMesh,d=e.shading===`source`?u.normal:null;if(d==null||l==null||l.rotationAngle===0&&i(l.scale,t))return{transformed:d,original:u.normal};if(!o.normalsTransformPromise){a(s,`SceneLayerWorker is needed to transform mesh normals`);let e=r();n(e,l.localMatrix),o.normalsTransformPromise=s.transformNormals({normalMatrix:e,normals:d},c)}return o.normalsTransformPromise}function x(e,t,n,r,i,a){let o=(t?.length??0)/3,s=o*3,c=w+w,l=c;c+=s*3*T;let u=n!=null,d=c;u&&(c+=s*3*T);let f=r!=null,p=c;f&&(c+=s*2*T);let m=i!=null,h=c;m&&(c+=s*4*E);let g=c;c
|
|
2
|
+
import e from"../../../../core/Error.js";import{ONES as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{normalFromMat4 as n}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{exactEquals as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{assertIsSome as a}from"../../../../core/maybe.js";import{MinPriority as o}from"../../../../core/MemCache.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{generateUUID as c}from"../../../../core/uuid.js";import{projectBoundingSphere as l}from"../../../../geometry/projection/projectBoundingSphere.js";import{ensurePackedArray as u}from"../../../../geometry/support/DoubleArray.js";import{isRelativeVertexSpace as d}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{Sphere as f}from"../../../../geometry/support/sphere.js";import{CachedMeshData as p}from"./CachedMeshData.js";import{convertMeshMaterialToPBRMaterial as m}from"./I3SClientMaterialUtil.js";class h{constructor(e,t,n,r,i,a){this.id=e,this.version=t,this.mbs=n,this.oid=r,this.componentNodeIds=i,this.unloadedMesh=a,this.type=`mesh`}}class g{constructor(e,t,n){this.id=e,this.meshNodeInfo=t,this.componentIndex=n,this.type=`mesh-component`,this.textureData=new Map}get mbs(){return this.meshNodeInfo.mbs}}class _{constructor(e,t,n,r){this._uid=e,this._worker=r,this._id2Meta=new Map,this._oid2Meta=new Map,this._indexSR=t.indexSR,this._vertexSR=t.vertexSR,this._renderSR=t.renderSR,this._memCache=n.newCache(`sl-client-mesh-data-${this._uid}`)}get uid(){return this._uid}get worker(){return this._worker}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){let n=`mesh${t}`,r=e.extent,i=r.spatialReference,a=this._indexSR,o=y(r,e.origin);l(o,i,o,a);let s=C(e);return new h(n,s,o,t,[],e)}addMeshNode(t,n){if(this.getMeshNodeIndex(n.oid)!=null)throw new e(`scenelayer`,`I3SClientNodeLoader: client side mesh for feature oid=${n.oid} already exists`);n.nodeIndex=t,this._id2Meta.set(n.id,n),this._oid2Meta.set(n.oid,n)}getMeshNodeIndex(e){let t=this._oid2Meta.get(e);return t==null||t.type!==`mesh`?null:t.nodeIndex}getMeshNodeInfo(e){let t=this._oid2Meta.values();for(let n of t)if(n.type===`mesh`&&n.id===e)return n;return null}removeNode(e){let t=this._id2Meta.get(e);t!=null&&(this._id2Meta.delete(e),t.type===`mesh`&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(t){let n=this._id2Meta.get(t);if(n==null)throw new e(`scenelayer`,`I3SClientNodeLoader::loadNodeJSON unable to find node ${t}`);switch(n.type){case`mesh`:return this._loadMeshNodeJSON(n);case`mesh-component`:return v(n);default:throw new e(`scenelayer`,`I3SClientNodeLoader::loadNodeJSON unable to handle node ${t}`)}}async _loadMeshNodeJSON(e){let t=e.id,n=(await this._getMeshData(e)).loadedMesh;if(n.components==null||n.components.length===0)return{id:t,mbs:e.mbs.toVec4()};let r=[],i=n.components;for(let n=0;n<i.length;++n){let i=`${t}-component${n}`,a=new g(i,e,n);this._id2Meta.set(a.id,a),e.componentNodeIds.push(i),r.push({id:a.id,mbs:a.mbs.toVec4()})}return{id:t,mbs:e.mbs.toVec4(),children:r}}updateNodeIndex(e,t,n){let r=this._id2Meta.get(e);r?.type===`mesh`&&(r.nodeIndex=n)}async loadNodeData(t,n){let r=this._id2Meta.get(t);if(r==null||r.type!==`mesh-component`)throw new e(`scenelayer`,`Failed to load client node data for node ${t} (unexpected node info)`);let i=r.meshNodeInfo,o=await this._getMeshData(i),c=o.loadedMesh,l=i.oid;if(c.components==null)throw new e(`scenelayer`,`Failed to load client node data for node ${t} (unexpected null reference)`);let d=c.components[r.componentIndex],{material:f,requiredTextures:p,textureData:h}=await m(d.material);if(h!=null)for(let e of h)e!=null&&r.textureData.set(e.id,e);let{vertexSpace:g,origin:_,transform:v}=c,y=[_.x,_.y,_.z??0];o.projectionPromise||=(a(this._worker,`SceneLayerWorker is needed to project mesh`),this._worker.project({positions:c.vertexAttributes.position,localMatrix:v?.localMatrix,vertexSpace:g.toJSON(),origin:y,inSpatialReference:c.spatialReference.toJSON(),outSpatialReference:this._vertexSR.toJSON()},n));let{projected:S,original:C,projectedOrigin:w}=await o.projectionPromise,T=u(w);c.vertexAttributes.position=C;let{transformed:E,original:D}=await b(d,o,this._worker,n);c.vertexAttributes.normal=D,s(n);let{geometryBuffer:O,geometryDescriptor:k}=x(S,d.faces,E,c.vertexAttributes.uv,c.vertexAttributes.color,l);return{geometryData:{featureDataPosition:T,featureIds:[],geometries:[{params:{material:f},type:`ArrayBufferView`}]},attributeDataInfo:{attributeData:{},loadedAttributes:[]},geometryBuffer:O,geometryDescriptor:k,requiredTextures:p,textureData:h,normalReferenceFrame:this._vertexSR.isGeographic?`east-north-up`:`vertex-reference-frame`}}async loadAttributes(e,t){let n=e.numFeatures,r={};for(let{field:{name:e}}of t)r[e]=Array(n);return r}async loadTextures(e,t){let n=e.id,r=this._id2Meta.get(n);if(r==null||r.type!==`mesh-component`)throw Error(`Failed to load textures for node ${e.id} (unexpected node info)`);return Array.from(t,e=>r.textureData.get(e.id)||null)}async _getMeshData(e){let t=e.version;return this._memCache.get(t)??(e.loadMeshPromise??=(async()=>{let n=e.unloadedMesh.clone();await n.load();let r=new p(n);return this._memCache.put(t,r,o),e.loadMeshPromise=null,r})(),e.loadMeshPromise)}}async function v(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs.toVec4(),isEmpty:!1}}function y(e,t){let{spatialReference:n}=e,r=[1,-1],i=[e.width*.5,e.height*.5,e.hasZ?(e.zmax-e.zmin)*.5:0],a=n.isGeographic?n.metersPerUnit:1,o=e.center,s=0;if(e.hasZ)for(let e=0;e<2;++e)for(let n=0;n<2;++n)for(let c=0;c<2;++c){let l=(o.x+r[e]*i[0]-t.x)*a,u=(o.y+r[n]*i[1]-t.y)*a,d=o.z+r[c]*i[2]-t.z;s=Math.max(l*l+u*u+d*d,s)}else for(let e=0;e<2;++e)for(let n=0;n<2;++n){let c=(o.x+r[e]*i[0]-t.x)*a,l=(o.y+r[n]*i[1]-t.y)*a;s=Math.max(c*c+l*l,s)}return new f(t.x,t.y,t.z??0,Math.sqrt(s))}async function b(e,o,s,c){let{transform:l,vertexAttributes:u}=o.loadedMesh,d=e.shading===`source`?u.normal:null;if(d==null||l==null||l.rotationAngle===0&&i(l.scale,t))return{transformed:d,original:u.normal};if(!o.normalsTransformPromise){a(s,`SceneLayerWorker is needed to transform mesh normals`);let e=r();n(e,l.localMatrix),o.normalsTransformPromise=s.transformNormals({normalMatrix:e,normals:d},c)}return o.normalsTransformPromise}function x(e,t,n,r,i,a){let o=(t?.length??0)/3,s=o*3,c=w+w,l=c;c+=s*3*T;let u=n!=null,d=c;u&&(c+=s*3*T);let f=r!=null,p=c;f&&(c+=s*2*T);let m=i!=null,h=c;m&&(c+=s*4*E);let g=c;c+=+D;let _=c;c+=2*w;let v=new ArrayBuffer(c),y=new Uint8Array(v);S(y,0,s),S(y,w,1);let b=new Float32Array(v,l),x=n==null?null:new Float32Array(v,d),C=r==null?null:new Float32Array(v,p),O=i==null?null:new Uint8Array(v,h);for(let a=0;a<o;++a){let o=a*3;for(let s=0;s<3;++s){let c=t[o+s],l=c*3,u=a*9+s*3;if(b[u]=e[l],b[u+1]=e[l+1],b[u+2]=e[l+2],x&&(x[u]=n[l],x[u+1]=n[l+1],x[u+2]=n[l+2]),C){let e=c*2,t=a*6+s*2;C[t]=r[e],C[t+1]=r[e+1]}if(O){let e=c*4,t=a*12+s*4;O[t]=i[e],O[t+1]=i[e+1],O[t+2]=i[e+2],O[t+3]=i[e+3]}}}return S(y,g,a),S(y,g+w,a/2**32),S(y,_,0),S(y,_+w,o-1),{geometryBuffer:v,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:m,normal:u,uv0:f,uvRegion:!1,featureIndex:!0}}}function S(e,t,n){e[t]=255&n,e[t+1]=255&n>>8,e[t+2]=255&n>>16,e[t+3]=255&n>>24}function C(e){let t=e.metadata.displaySource?.source;if(t?.type!==`service`)return c();let n=t.assets.reduce((e,t)=>e+t.makeHash(),``),r=JSON.stringify(e.transform?.toJSON()??``),i=d(e.vertexSpace)?JSON.stringify(e.vertexSpace.origin):``,a=JSON.stringify(e.spatialReference);return n+r+i+a}const w=4,T=4,E=1,D=8;export{g as ClientMeshComponentNodeInfo,h as ClientMeshNodeInfo,_ as I3SClientNodeLoader,y as createSphereFromExtent,T as sizeOfFloat32,w as sizeOfInt32,D as sizeOfUInt64,E as sizeOfUInt8,b as transformNormals};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import has from"../../../../core/has.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import t from"../../../../core/PooledArray.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as r}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as i}from"../../../../geometry/support/sphere.js";import{ElevationRange as a}from"../../support/ElevationRange.js";import{Obb as o}from"../../support/orientedBoundingBox.js";import{NodeBoundingData as s,Node as c,NodeTraversalState as l}from"./I3SNode.js";import{addWraparound as u}from"./I3SUtil.js";import{ValidatedNode as d}from"./ValidatedNode.js";class f{constructor(e,t,n,r,i){this.childOffset=e,this.childCount=t,this.visibilityCache=n,this._boundingData=r,this.node=i,this.parentIndex=-1,this.useAsHole=0,this.filterImpact=2,this.traversalState=null}get nodeBoundingData(){return this._boundingData}destroy(){this._boundingData=null,this.node=null,this.traversalState=null}invalidateBounds(){this.node?.invalidateServiceBVsInRenderSR(),this.nodeBoundingData?.invalidateServiceBVsInRenderSR()}}class p{constructor(e=[],t=[]){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(let e of this._nodeDescriptors)e.destroy();this._nodeDescriptors.length=0,this._children.length=0}get nodes(){return this._nodeDescriptors}addNode(e){return this._nodeDescriptors.push(e),this._nodeDescriptors.length-1}setNodes(e,t){this._nodeDescriptors=e,this._children=t}get children(){return this._children}}class m{get _useNodePages(){return this._pageSize>0}constructor(e,n,r,i,a,o,c,l,u,d,f,m,h,_,y,b,x){if(this.viewingMode=e,this._layer=n,this._groundNavigationCheckDistance=i,this._requester=o,this._clientNodeLoader=c,this._viewportQueries=l,this._logger=u,this.holeFilling=d,this._isLoaded=f,this._isReloading=m,this._shouldLoadNode=h,this._enable=_,this._needsUpdate=y,this._computeVisibilityObb=b,this._computeNodeFiltering=x,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=0,this._lodConversion=e=>e,this._isEditable=!1,this.urlPrefix=``,this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=1/0,this._version=v(0),this._visibilityCacheVersion=v(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._progressiveLoadPenaltyWeight=10,this._missingPagesAndNodes=new Set,this._prioritizedMissingNodeAndPageIds=[],this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=[],this._updates=new g(this._missingPagesAndNodes),this._imModificationUncategorized=new t({deallocator:null}),this.ignoreServiceObb=!1,this.isGroundNavigationMode=!1,this._pageQueue=[],this._newPages=[],this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=n.associatedLayer?.infoFor3D!=null,this.isGroundNavigationMode=r,n.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${n.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,a.type===`page`){let e=a.rootPage;switch(this.urlPrefix=a.urlPrefix,this._pageSize=a.pageSize,a.lodMetric){case`maxScreenThreshold`:this._lodMetric=1;break;case`maxScreenThresholdSQ`:this._lodMetric=1,this._lodConversion=k}if(this._isEditable){this._rootIndex=-1;let t=C(a.rootIndex,a.pageSize),n=e.nodes[t],r={nodes:[{index:this._rootIndex,children:[a.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(S(this._rootIndex,this._pageSize),r),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=a.rootIndex;this._addPage(S(a.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if(a.type===`node`){this.urlPrefix=a.urlPrefix;let e=new p;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new p;let e={id:`-1`,version:null,mbs:a.rootNode.mbs,obb:a.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:`root`,href:`../root`,mbs:a.rootNode.mbs,obb:a.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new s(e.id),-1);let t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new s(a.rootNode.id),-1);let t=this._validateNode(a.rootNode.id,a.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){let n=new s(e,t),r=this._makeClientRefNode(n,-1);return this._linkChildToParentNode(-1,r),this.requestUpdate(),r}removeClientNodeFromIndex(e,t,n){this._destroyClientRefNode(e,t,n),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e)){this._logger.error(`Requested load page [${e}] already loaded`);return}if(this._loadingPages.has(e)){this._logger.error(`Requested load page [${e}] already loading`);return}this._loadingPages.add(e);let t=this.urlPrefix+e;this._requester.request(t,`json`).then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(t=>{this._loadingPages.delete(e),n(t)||(this._failedPages.add(e),this._logger.error(`#loadPage()`,this._layer,`Error when loading page ${e}`,t))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){let{pageIndex:t,page:n}=this._pageQueue.shift();this._addPage(t,n),this._loadingPages.delete(t),e.madeProgress(),this._needsNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this._needsNodeElevationRange)for(;this._newPages.length>0&&!e.done;)this._nodePages.get(this._newPages.shift())?.nodes.forEach(e=>{let t=e.parentIndex;for(;t!=null&&t!==this._rootIndex;){let e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}_addPage(e,t){if(this._nodePages.has(e)){this._logger.error(`Page[${e}] reloaded`);return}let n=[],r=[],a=t.nodes.map((t,a)=>{let s=n.length,l=t.children?t.children.length:0;r.push(this._rootIndex);for(let e=0;e<l;e++)n.push(t.children[e]);let u=`${t.index}`,d=o.fromJSON(t.obb),p=new i(d.getCenter(N),d.radius),m=t.mesh?.attribute,h=t.mesh?.geometry,g=t.mesh?.material,v={hasSharedResource:!1,isEmpty:h==null,attributes:m?.resource==null?void 0:`${m.resource}`,geometry:h?.resource==null?void 0:`${h.resource}`,texture:g?.resource==null?void 0:`${g.resource}`,geometryDefinition:h?h.definition:-1,materialDefinition:g?g.definition:-1},y=new c(u,w(a,e,this._pageSize),p,l,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),h?.featureCount??null,d);return y.visibilityObbInRenderSR=this._computeVisibilityObb(y),y.vertexCount=h?h.vertexCount:0,new f(s,l,_(this._visibilityCacheVersion),null,y)}),s=new p(a,n);e===-1?this._clientNodePage=s:this._nodePages.set(e,s)}_updateParentsAndLevel(){let e=[],t=(t,n,r)=>{let i=this._getPage(t);if(i!=null){let a=C(t,this._pageSize),o=i.nodes[a];o.parentIndex=n??-1;let s=o.node;s!=null&&(s.level=r,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){let n=e.pop(),r=this.getNode(n);if(r!=null)for(let e=0;e<r.childCount;e++)t(this.getChildIndex(r.index,e),n,r.level+1),this._maxLevel=Math.max(this._maxLevel,r.level+1)}}_getPage(e){let t=S(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){let t=this._getPage(e);return t==null?null:(t.lastTraversed=this._frameNumber,t.nodes[C(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);let n=this.getParent(t),r=n==null?0:n.level+1;this._maxLevel=Math.max(this._maxLevel,e.children?r+1:r);let{lodMetric:i,maxError:a}=E(e.lodSelection),s=this._getNodeDescriptor(t);if(s.node!=null)return this._logger.error(`Loaded node[${t}] already in descriptor`),s.node;let l=new c(e.id,t,e.mbs,s.childCount,r,e.resources,e.version,i,a,e.numFeatures,e.obb?o.fromJSON(e.obb):null);s.node=l,l.visibilityObbInRenderSR=this._computeVisibilityObb(l);let u=s.nodeBoundingData;return u!=null&&(u.serviceMbsInIndexSR??=e.mbs,l.shareServiceBVsInRenderSRWith(u),u.visibilityObbInRenderSR=l.visibilityObbInRenderSR),l}_makeRefNode(e,t){let n=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(n==null)return-1;let r=n.nodes.length,i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_makeClientRefNode(e,t){let n=this._clientNodePage;if(n==null)return-1;if(t>=0)throw Error(`I3SIndex::client side nodes can not be made children of service side nodes.`);let r=-(n.nodes.length+1),i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_linkChildToParentNode(e,t){let n=this._clientNodePage;if(n==null||e>=0)return;let r=C(e,this._pageSize),i=C(t,this._pageSize),a=n.nodes[r],o=a.childOffset;n.children.splice(a.childOffset+a.childCount,0,t),a.childCount+=1,a.node!=null&&(a.node.childCount+=1);for(let e of n.nodes)e.childOffset>o&&(e.childOffset+=1);let s=n.nodes[i];s.parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,n){let r=this._clientNodePage;if(r==null)return;let i=this._getParentIndex(e);if(i==null)return;let a=new Set,o=new Map,s=e=>{let n=C(e,this._pageSize),i=r.nodes[n];if(i.childCount>0)for(let e=i.childOffset;e<i.childOffset+i.childCount;++e)s(r.children[e]);let o=i.node?.id??i.nodeBoundingData?.id;if(o==null)throw Error(`Node has no id`);t(o,e),a.add(i)};s(e);let c=r.nodes,l=r.children,u=r.nodes.map(()=>-1),d=[],f=[];for(let e=0;e<c.length;++e){let t=c[e];if(a.has(t))continue;let r=d.length,i=w(e,-1,this._pageSize),s=w(r,-1,this._pageSize);if(t.node&&(t.node.index=s),u[e]=s,d.push(t),i!==s){let e=t.node?.id??t.nodeBoundingData?.id;if(e==null)throw Error(`Node has no id`);n(e,i,s),o.set(i,s)}}for(let e=0;e<d.length;++e){let t=w(e,-1,this._pageSize),n=d[e],r=f.length;for(let e=n.childOffset;e<n.childOffset+n.childCount;++e){let n=l[e];if(n>=0)f.push(n);else{let e=C(n,this._pageSize),r=c[e];if(a.has(r))continue;let i=u[e];f.push(i),r.parentIndex=t}}n.childOffset=r,n.childCount=f.length-r,n.node&&(n.node.childCount=n.childCount)}r.setNodes(d,f),this._updateParentBoundingInformation(u[C(i,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null,n=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,o=this._getNodeDescriptor(t);if(o==null)return;for(let i=0;i<o.childCount;i++){let o=this.getChildIndex(t,i),s=this._getNodeDescriptor(o),c=s==null?null:s.nodeBoundingData||s.node;if(c?.serviceMbsInIndexSR!=null&&c.serviceMbsInIndexSR.radius>0){if(e==null)e=A.copyFrom(c.serviceMbsInIndexSR);else{let t=j;r(c.serviceMbsInIndexSR,n,t,a);let i=M;r(e,n,i,a),r(t.union(i),a,e,n)}}}let s=t=>{t!=null&&(t.serviceObbInIndexSR=null,e==null?t.serviceMbsInIndexSR?.invalidate():(t.serviceMbsInIndexSR??=new i,t.serviceMbsInIndexSR.copyFrom(e)),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};s(o.nodeBoundingData),s(o.node),this.invalidateNodeVisibilityCacheInternal(o),t=this._getParentIndex(t)}while(t!=null)}populateChildren(e,t){let n=this._getNodeDescriptor(e),r=this._getPage(e);n.childOffset=r.children.length,n.childCount=t.length;for(let n=0;n<t.length;n++){let i=this._makeRefNode(t[n],e);r.children.push(i)}}getNode(e){let t=this._getNodeDescriptor(e);return t==null?null:t.node}getIndexById(e){let t;return this._forAllNodes((n,r)=>{(n.node!=null&&n.node.id===e||n.nodeBoundingData!=null&&n.nodeBoundingData.id===e)&&(t=r)}),t}getNodeById(e){let t=this.getIndexById(e);return t!=null&&t>=0?this.getNode(t):null}getChildIndex(e,t){let n=this._getPage(e);if(n==null)return-1;let r=n.nodes[C(e,this._pageSize)];return n.children[r.childOffset+t]}_getParentIndex(e){let t=this._getPage(e);return t!=null&&e!==this._rootIndex?t.nodes[C(e,this._pageSize)]?.parentIndex:null}getParent(e){let t=this._getParentIndex(e);return t==null?null:this.getNode(t)}isLeaf(e){let t=this._getNodeDescriptor(e);return t!=null&&t.childCount===0}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{e.node!=null&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=v(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){let t=this._getNodeDescriptor(e);t!=null&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=_(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){let t=this._getNodeDescriptor(e);t!=null&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){let t=this._getNodeDescriptor(e);t!=null&&(this._needsNodeElevationRange?(t.node==null?t.nodeBoundingData:t.node)?.invalidateElevationRange():this.invalidateBoundingVolumeCache(e))}invalidateGeometryVisibility(e){let t=this._getNodeDescriptor(e)?.node;t&&(t.geometryObbInRenderSR=null,t.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){this.rootNode!=null&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeValid(e){if(!this._needsNodeElevationRange)return!0;let t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){let n=this._getNodeDescriptor(e);if(!n)return!1;let r=n?.node??n?.nodeBoundingData;if(!r)return!1;if(r.elevationRangeValid)return t?.expandElevationRange(r),!0;let i=new a,o=!1;for(let t=0;t<n.childCount;t++){let n=this.getChildIndex(e,t),r=this._updateElevationRange(n,i);o||=!r}if(n.childCount===0||o){let e=!n.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(r,e,i)}(i.minElevation===1/0||i.maxElevation===-1/0)&&i.expandElevationRangeValues(0,0);let{minElevation:s,maxElevation:c}=r;return s===i.minElevation&&c===i.maxElevation?(t?.expandElevationRange(r),!0):(n.node?.setElevationRange(i),n.nodeBoundingData?.setElevationRange(i),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(r),!0)}isNodeVisible(e){let t=this._getNodeDescriptor(e);if(t==null)return!0;let n=t.nodeBoundingData;if(n!=null&&!n.serviceMbsInIndexSR)return!0;if(this._isElevationRangeValid(t)&&b(t.visibilityCache,this._visibilityCacheVersion))return x(t.visibilityCache);let r=t.node,i=this._viewportQueries;if(r){let e=i.ensureElevationAgnosticBoundingVolume(r),n=i.isElevationAgnosticBoundingVolumeVisible(e,this.isGroundNavigationMode?this._groundNavigationCheckDistance:0),a=n;if(this._needsNodeElevationRange&&n){let t=i.getNodeObbInRenderSRIndependentOfElevationOffset(r);t!=null&&(a=i.isObbVisibleIndependentOfElevation(e,t))}if(!a)return t.visibilityCache=y(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(r!=null||n!=null)&&t.filterImpact===2){let e=r==null?n==null?null:n.serviceMbsInIndexSR:r.serviceMbsInIndexSR;t.filterImpact=e==null?0:this._computeNodeFiltering(e)}let a=r!=null&&t.filterImpact===1,o=(r==null||r.imModificationImpact!==2)&&!a;if(o){let t=r&&(!n||r.visibilityObbInRenderSR)?r:n??null;t!=null&&(this._needsNodeElevationRange&&this._updateElevationRange(e),o=i.isNodeVisible(t,this.isGroundNavigationMode))}return t.visibilityCache=y(o,this._visibilityCacheVersion),o}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;let t=this._getNodeDescriptor(e);return t?.node?.geometryObbInRenderSR!=null&&(!this.layerHasModifications||t.node.imModificationImpact!==4)?this._viewportQueries.isGeometryVisible(t.node,this.isGroundNavigationMode):!0}_traverseCoverage(e,t,n,r,i){let a=this._getPage(e);if(a==null||t.childCount===0)return;let o=t.childOffset+t.childCount,s=[];for(let e=t.childOffset;e<o;++e){let t=a.children[e],n=this._getNodeDescriptor(t);n?.node!=null&&this.isGeometryVisible(t)&&s.push(n)}r/=s.length;for(let e of s){let t=e.node.index;this._isLoaded(t)||this._isReloading(t)?(i.delta=Math.max(i.delta,n),i.coverage+=r):this._traverseCoverage(t,e,n+1,r,i)}}useNodeAsHole(e){if(this.holeFilling===`off`)return!1;let t=this._getNodeDescriptor(e);if(t==null)return!1;if(this.holeFilling===`always`)return!0;if(b(t.useAsHole,this._version))return x(t.useAsHole);let n={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,n);let r=n.delta*n.coverage<=.5;return t.useAsHole=y(r,this._version),r}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.destroy(),this._nodePages.clear(),this._clientNodePage=null,this._layer=null,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._imModificationUncategorized.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=v(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{e!=null&&(e.imModificationImpact=4,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))}),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes(e=>{if(e!=null){e.filterImpact=2;let t=e.node;t!=null&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,n){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let r=!0,i=new D,a=new O,o=this._imModificationUncategorized;o.clear();let s=new Set,c=0;this.traverseVisible((s,l,u)=>{let d=e=>{this._shouldLoadNode(e)&&e.childCount&&(r=!1)};if(!l){let e=S(s,this._pageSize),t=this._getNodeLoadPriority(s);t===1/0&&(t=this._getNodeLoadPriority(u)),h.set(e,Math.max(t,h.get(e)||0)),!this._loadingPages.has(e)&&!this._failedPages.has(e)&&(this._missingPagesAndNodes.add(e),++c),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t);return}let{node:f,childCount:p}=l;if(this._updateNodeFeatureEstimate(f,a),!f){let e=this._getNodeLoadPriority(s);!this._loadingNodes.has(s)&&!this._failedNodes.has(s)&&(this._missingPagesAndNodes.add(s),h.set(s,e)),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e);return}let m=this._getPage(s);if(!this._useNodePages&&this._missingPagesAndNodes.size===0)for(let e=0;e<p;e++){let t=m.children[l.childOffset+e],n=this._getNodeDescriptor(t);n!=null&&!n.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(h.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(f.failed||f.resources.isEmpty){d(f);return}if(this._isLoaded(s)){if(i.known+=f.memory,++i.knownNodes,d(f),this._shouldLoadNode(f)||(i.unremoved+=f.memory),this._needsUpdate(f)){let e=this._getNodeLoadPriority(s);h.set(s,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(s)}return}if(f.memory&&(i.known+=f.memory,++i.knownNodes),!this._shouldLoadNode(f)){this._isReloading(s)&&this._updates.remove.push(s);return}if(d(f),f.memory?(i.missing+=f.memory,i.known+=f.memory,++i.knownNodes):++i.missingNodes,e.includes(f.index)){this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(s)),this._updates.cancel=this._updates.cancel.filter(e=>e!==f.index);return}if(!t.done&&this._enable(f)){t.madeProgress();return}let g=this._getNodeLoadPriority(s);h.set(s,g),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,g),this._updates.add.push(s),this.layerHasModifications&&n&&f!=null&&f.imModificationImpact===4&&o.push(s)},s),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(s,c),this._handleModifications(n,o),this._updateUnloadedMemoryEstimate(i),this._featureEstimate.estimate=this._computeFeatureEstimate(a),this._featureEstimate.leavesReached=r,this._updates.add.filterInPlace(e=>h.get(e)>=this._maxUnloadedPrio).sort((e,t)=>h.get(e)-h.get(t)),this._updates.update.sort((e,t)=>h.get(e)-h.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,h.clear()}_updateUnloadedMemoryEstimate(e){this._unloadedMemoryEstimate=e.missing-e.unremoved,e.knownNodes>3&&e.missingNodes>0&&(this._unloadedMemoryEstimate+=e.known/e.knownNodes*e.missingNodes),this._unloadedMemoryEstimate=Math.max(0,this._unloadedMemoryEstimate)*.8}resetUpdateState(e){this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=-1/0,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),h.clear()}_prioritizeMissingNodesAndPages(){let e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),e.length>0&&(this._maxUnloadedPrio=h.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&this._updates.add.length!==0&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{let t=this._getNodeDescriptor(e),n=t?.node==null||t.node.imModificationImpact!==2;return n||this.invalidateNodeVisibilityCache(e),n}))}checkFeatureTarget(e,t){let n=this._viewportQueries.updateScreenSpaceErrorBias(t),r=t,i=t,a=n,o=10;for(;o--;){let n=new O;if(this._updateFeatureEstimate(r,n),this._computeFeatureEstimate(n)<=e){if(r>=t||n.missingNodes>0||o===0)break;a=r,r=(r+i)*.5}else i=r,r=(r+a)*.5}return this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(n),Math.min(t,r)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;let n=e.size,r=this._nodePages,i=r.size+this._loadingPages.size+t;if(i>P&&i>n){let t=[];for(let[n,i]of r)i.numNodesWithLoadedChildren===0&&!e.has(n)&&t.push([i.lastTraversed,n]);t.sort((e,t)=>e[0]-t[0]).some(e=>{let t=e[1];return this._deleteNodePage(t),r.size<=P})}}_updateFeatureEstimate(e,t){this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,n)=>this._updateNodeFeatureEstimate(n?.node,t))}_updateNodeFeatureEstimate(e,t){e!=null&&!e.failed&&this._shouldLoadNode(e)&&(e.numFeatures==null?++t.missingNodes:(t.numFeatures+=e.numFeatures,++t.knownNodes))}_computeFeatureEstimate(e){let t=e.numFeatures;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.numFeatures/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._prioritizedMissingNodeAndPageIds,this._missingPagesAndNodes)}prefetch(){let e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(e.length===0||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){let n=e[e.length-1];e.length--,t.delete(n),this._useNodePages&&n>=0?this._loadPage(n):this._loadNode(n)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.size>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(e==null)return null;let t=e.index,n=this._getNodeDescriptor(t);if(!n)return null;let r=n?.traversalState;if(r&&b(r.version,this._version))return r;let i=this._viewportQueries.getLodLevel(e),a=this._viewportQueries.hasLOD(e),o=!0;if(a){let e=this._getParentIndex(t);if(e!=null){let t=this._getNodeDescriptor(e)?.traversalState;o=!!t&&i>t.lodLevel}else o=i>0}else o=e.childCount===0;return r?(r.lodLevel=i,r.isChosen=o,r.version=y(!0,this._version),r):(r=new l(a,o,i,y(!0,this._version)),n.traversalState=r,r)}_loadNode(e){if(this._loadingNodes.has(e)){this._logger.error(`Node[${e}] already loading`);return}this._loadingNodes.add(e);let t=this._getNodeDescriptor(e);if(t.node){this._logger.error(`Node[${e}] already in descriptor`);return}let r=t.nodeBoundingData;if(r==null){this._failedNodes.add(e);return}let i=r.id,a=this.urlPrefix+i,o=()=>{this._loadingNodes.delete(e),this._missingPagesAndNodes.size===0&&this._loadingNodes.size===0&&this.requestUpdate()};(e>=0?this._requester.request(a,`json`):this._clientNodeLoader.loadNodeJSON(i)).then(t=>{o();let n=this._validateNode(i,t);if(n==null)return;n.obb&&this.invalidateNodeVisibilityCache(e);let r=this._addNode(n,e);this.nodeTraversalState(r)}).catch(t=>{o(),n(t)||(this._logger.error(`#loadNode()`,this._layer,`Error loading node: `+a),this._failedNodes.add(e))})}_validateNode(e,t){if(typeof t!=`object`||!t||t.id!==e)return this._logger.error(`#validateNode()`,this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error(`#validateNode()`,this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&t.sharedResource.href!==`./shared`&&t.sharedResource.href!==`./shared/`&&this._logger.warn(`#validateNode()`,this._layer,`Invalid shared resource href on node "${e}"`);let n=t.geometryData;n!=null&&!(Array.isArray(n)&&n.length===0)&&!(Array.isArray(n)&&n.length===1&&n[0].href===`./geometries/0`)&&this._logger.warn(`#validateNode()`,this._layer,`Invalid geometry data on node "${e}"`);let r=t.attributeData,a=this._layer.attributeStorageInfo;r!=null&&(!Array.isArray(r)||r.some((e,t)=>e.href!==`./attributes/${a?.[t]?.key??`f_${t}`}/0`))&&this._logger.warn(`#validateNode()`,this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn(`#validateNode()`,this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);let c=t.hasOwnProperty(`obb`)&&!this.ignoreServiceObb?t.obb:void 0,l=t.featureData?.length===1&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,u=Array.isArray(t.children)?t.children.map(t=>{if(t==null)return null;let n=t=>this._logger.error(`#validateNode()`,this._layer,`Invalid node reference on node ${e}: ${t}`);if(typeof t.id==`number`)n(`id ${t.id} is a number instead of a string.`);else if(typeof t.id!=`string`||!Array.isArray(t.mbs))return n(`Missing or invalid id.`),null;if(!Array.isArray(t.mbs))return n(`Invalid bounding volume on reference ${t.id}.`),null;let r=new s(`${t.id}`,new i(t.mbs));return r.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty(`obb`)&&t.obb?o.fromJSON(t.obb):null,r.visibilityObbInRenderSR=this._computeVisibilityObb(r),r}).filter(e=>e!=null):null,f=t.featureData?.length??!1,p=t.isEmpty===!0;return new d(e,new i(t.mbs),c,typeof t.version==`string`?t.version:null,{isEmpty:!f&&p,hasSharedResource:t.sharedResource!=null,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:t.geometryData==null?void 0:e},u,Array.isArray(t.lodSelection)?t.lodSelection:null,l)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{e.node!=null&&(e.node.failed=!1)})}_getNodeLoadPriority(e){let t=this._getNodeDescriptor(e),n=this._getParentIndex(e);if(t==null||n==null&&t.node==null)return n==null?1/0:this._getNodeLoadPriority(n);let r=0;t.node&&n!=null&&(r=this._getNodeDescriptor(n).traversalState?.lodLevel??0);let i=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+r)+r*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+i}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;t!=null;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){let n=this._getNodeDescriptor(this._rootIndex);n==null?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,null,n,e,t)}_traverseVisible(e,t,n,r,i){let a=S(e,this._pageSize);if(i&&i.add(a),n.node&&n.childCount===0){this.isGeometryVisible(e)&&r(e,n,t);return}if(!this.isNodeVisible(e)||(r(e,n,t),n.node==null))return;let o=this.nodeTraversalState(n.node);if(o?.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;let s=this._getPageFromPageIndex(a);for(let t=0;t<n.childCount;t++){let a=s.children[n.childOffset+t],o=this._getNodeDescriptor(a);if(o)this._traverseVisible(a,e,o,r,i);else{if(i){let e=S(a,this._pageSize);i.add(e)}r(a,null,e)}}}traverse(e,t){for(let n of this.traverseValues(e,t));}*traverseValues(e,t){t(e)&&(yield e,yield*this._traverseDescendantValues(e,t))}*_traverseDescendantValues(e,t){let n=e.index,r=this._pageSize,i=S(n,r),a=this._getPageFromPageIndex(i);if(a==null)return;let o=this._frameNumber,s=this._nodePages,c=C(n,r),l=a.nodes[c],u=l.childCount;if(a.lastTraversed=o,u===0)return;let d=[],f=[],p=0;{let{childOffset:e,childCount:t}=l,{children:n}=a;f.length=2**Math.ceil(Math.log2(p+t));for(let r=e;r<e+t;++r){let e=n[r];e>=0?(f[p]=e,++p):d.push(e)}}if(d.length>0){let e=this._clientNodePage;if(e){let n=e.children,r=0;for(;r<d.length;){let i=d[r];++r;let a=-i-1,o=e.nodes[a],s=o.node;if(!s||!t(s))continue;yield s;let{childCount:c}=o;if(c===0)continue;let{childOffset:l}=o,u=l+c;for(let e=l;e<u;++e)d.push(n[e])}}}if(p>0){let e=0;if(r>0){let n=i*r,c=a,l=c.nodes;for(;e<p;){let i=f[e];++e;let a;if(n<=i&&i<n+r)a=c;else{let e=i/r|0,t=s.get(e);if(t===void 0)continue;a=t,a.lastTraversed=o,c=a,l=c.nodes,n=r*e}let u=i-n,d=l[u],m=d?.node;if(m==null||t(m)===!1||(yield m,d.node==null))continue;let{childCount:h}=d;if(h===0)continue;let g=p+h;for(f.length<g&&(f.length=2**Math.ceil(Math.log2(p+h)));f.length<p+h;)f.length+=f.length;let _=a.children,{childOffset:v}=d,y=v+h;for(let e=v;e<y;++e)f[p]=_[e],++p}}else{let n=s.get(0);if(n)for(;e<p;){let r=f[e++],i=n.nodes[r],a=i.node;if(!a||!t(a))continue;yield a;let{childCount:o}=i;if(o===0)continue;f.length=Math.max(f.length,2**Math.ceil(Math.log2(p+o)));let s=n.children,{childOffset:c}=i,l=c+o;for(let e=c;e<l;++e)f[p]=s[e],++p}}}}traverseDescendants(e,t){for(let n of this._traverseDescendantValues(e,t));}updateChildrenLoaded(e,t){let n=this.getNode(e);for(;n!=null;){let e=n.childrenLoaded,r=e+t;n.childrenLoaded=r;let i=e===0?1:r===0?-1:0,a=n.index;if(i!==0){let e=this._getPage(a);e.numNodesWithLoadedChildren+=i}n=this.getParent(a)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this._needsNodeElevationRange=t&&!!e&&(e.mode===`relative-to-ground`||e.mode===`relative-to-scene`||e.mode===`on-the-ground`),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_forAllNodes(e){if(this._clientNodePage!=null){let t=this._clientNodePage;for(let n=0;n<t.nodes.length;n++)e(t.nodes[n],-(n+1))}for(let[t,n]of this._nodePages){let r=t*this._pageSize;for(let t=0;t<n.nodes.length;t++)e(n.nodes[t],r+t)}}clearCaches(){if(this._useNodePages){let e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(S(e,this._pageSize)));for(let[n,r]of e)if(r.numNodesWithLoadedChildren===0&&!t.has(n))this._deleteNodePage(n);else for(let e of r.nodes)e.traversalState=null}}_deleteNodePage(e){if(!this._nodePages.has(e)){this._logger.error(`Destroying non-existent page ${e}`);return}let t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const h=new Map;class g{constructor(e){this.missing=e,this.update=new t({deallocator:null}),this.add=new t({deallocator:null}),this.remove=new t({deallocator:null}),this.cancel=[]}destroy(){this.update.prune(),this.add.prune(),this.remove.prune(),this.cancel.length=0}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function _(e){return u(e,-2)}function v(e){return u(e,2)}function y(e,t){return t+ +!!e}function b(e,t){return(e&-2)===t}function x(e){return(e&1)==1}function S(e,t){return e<0?-1:t>0?e/t|0:0}function C(e,t){return e<0?-e-1:t===0?e:e%t}function w(e,t,n){return t===-1?-(e+1):n===0?e:t*n+e}const T=[[`maxScreenThreshold`,1],[`screenSpaceRelative`,2],[`removedFeatureDiameter`,3],[`distanceRangeFromDefaultCamera`,4]];function E(e){if(e){for(let t=0;t<e.length;t++)for(let n of T)if(n[0]===e[t].metricType)return{lodMetric:n[1],maxError:e[t].maxError}}return{lodMetric:0,maxError:0}}class D{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class O{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function k(e){return Math.sqrt(4/Math.PI*e)}const A=new i,j=new i,M=new i,N=e(),P=has(`esri-mobile`)?100:300;export{m as I3SIndex,E as selectErrorMetric};
|
|
2
|
+
import has from"../../../../core/has.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import t from"../../../../core/PooledArray.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as r}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as i}from"../../../../geometry/support/sphere.js";import{ElevationRange as a}from"../../support/ElevationRange.js";import{Obb as o}from"../../support/orientedBoundingBox.js";import{NodeBoundingData as s,Node as c,NodeTraversalState as l}from"./I3SNode.js";import{addWraparound as u}from"./I3SUtil.js";import{ValidatedNode as d}from"./ValidatedNode.js";class f{constructor(e,t,n,r,i){this.childOffset=e,this.childCount=t,this.visibilityCache=n,this._boundingData=r,this.node=i,this.parentIndex=-1,this.useAsHole=0,this.filterImpact=2,this.traversalState=null}get nodeBoundingData(){return this._boundingData}destroy(){this._boundingData=null,this.node=null,this.traversalState=null}invalidateBounds(){this.node?.invalidateServiceBVsInRenderSR(),this.nodeBoundingData?.invalidateServiceBVsInRenderSR()}}class p{constructor(e=[],t=[]){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(let e of this._nodeDescriptors)e.destroy();this._nodeDescriptors.length=0,this._children.length=0}get nodes(){return this._nodeDescriptors}addNode(e){return this._nodeDescriptors.push(e),this._nodeDescriptors.length-1}setNodes(e,t){this._nodeDescriptors=e,this._children=t}get children(){return this._children}}class m{get _useNodePages(){return this._pageSize>0}constructor(e,n,r,i,a,o,c,l,u,d,f,m,h,_,y,b){if(this._layer=e,this._groundNavigationCheckDistance=r,this._requester=a,this._clientNodeLoader=o,this._viewportQueries=c,this._logger=l,this.holeFilling=u,this._isLoaded=d,this._isReloading=f,this._shouldLoadNode=m,this._enable=h,this._needsUpdate=_,this._computeVisibilityObb=y,this._computeNodeFiltering=b,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=0,this._lodConversion=e=>e,this._isEditable=!1,this.urlPrefix=``,this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=1/0,this._version=v(0),this._visibilityCacheVersion=v(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._progressiveLoadPenaltyWeight=10,this._missingPagesAndNodes=new Set,this._prioritizedMissingNodeAndPageIds=[],this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=[],this._updates=new g(this._missingPagesAndNodes),this._imModificationUncategorized=new t({deallocator:null}),this.ignoreServiceObb=!1,this.isGroundNavigationMode=!1,this._pageQueue=[],this._newPages=[],this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=e.associatedLayer?.infoFor3D!=null,this.isGroundNavigationMode=n,e.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${e.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,i.type===`page`){let e=i.rootPage;switch(this.urlPrefix=i.urlPrefix,this._pageSize=i.pageSize,i.lodMetric){case`maxScreenThreshold`:this._lodMetric=1;break;case`maxScreenThresholdSQ`:this._lodMetric=1,this._lodConversion=k}if(this._isEditable){this._rootIndex=-1;let t=C(i.rootIndex,i.pageSize),n=e.nodes[t],r={nodes:[{index:this._rootIndex,children:[i.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(S(this._rootIndex,this._pageSize),r),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=i.rootIndex;this._addPage(S(i.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if(i.type===`node`){this.urlPrefix=i.urlPrefix;let e=new p;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new p;let e={id:`-1`,version:null,mbs:i.rootNode.mbs,obb:i.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:`root`,href:`../root`,mbs:i.rootNode.mbs,obb:i.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new s(e.id),-1);let t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new s(i.rootNode.id),-1);let t=this._validateNode(i.rootNode.id,i.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){let n=new s(e,t),r=this._makeClientRefNode(n,-1);return this._linkChildToParentNode(-1,r),this.requestUpdate(),r}removeClientNodeFromIndex(e,t,n){this._destroyClientRefNode(e,t,n),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e)){this._logger.error(`Requested load page [${e}] already loaded`);return}if(this._loadingPages.has(e)){this._logger.error(`Requested load page [${e}] already loading`);return}this._loadingPages.add(e);let t=this.urlPrefix+e;this._requester.request(t,`json`).then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(t=>{this._loadingPages.delete(e),n(t)||(this._failedPages.add(e),this._logger.error(`#loadPage()`,this._layer,`Error when loading page ${e}`,t))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){let{pageIndex:t,page:n}=this._pageQueue.shift();this._addPage(t,n),this._loadingPages.delete(t),e.madeProgress(),this._needsNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this._needsNodeElevationRange)for(;this._newPages.length>0&&!e.done;)this._nodePages.get(this._newPages.shift())?.nodes.forEach(e=>{let t=e.parentIndex;for(;t!=null&&t!==this._rootIndex;){let e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}_addPage(e,t){if(this._nodePages.has(e)){this._logger.error(`Page[${e}] reloaded`);return}let n=[],r=[],a=t.nodes.map((t,a)=>{let s=n.length,l=t.children?t.children.length:0;r.push(this._rootIndex);for(let e=0;e<l;e++)n.push(t.children[e]);let u=`${t.index}`,d=o.fromJSON(t.obb),p=new i(d.getCenter(N),d.radius),m=t.mesh?.attribute,h=t.mesh?.geometry,g=t.mesh?.material,v={hasSharedResource:!1,isEmpty:h==null,attributes:m?.resource==null?void 0:`${m.resource}`,geometry:h?.resource==null?void 0:`${h.resource}`,texture:g?.resource==null?void 0:`${g.resource}`,geometryDefinition:h?h.definition:-1,materialDefinition:g?g.definition:-1},y=new c(u,w(a,e,this._pageSize),p,l,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),h?.featureCount??null,d);return y.visibilityObbInRenderSR=this._computeVisibilityObb(y),y.vertexCount=h?h.vertexCount:0,new f(s,l,_(this._visibilityCacheVersion),null,y)}),s=new p(a,n);e===-1?this._clientNodePage=s:this._nodePages.set(e,s)}_updateParentsAndLevel(){let e=[],t=(t,n,r)=>{let i=this._getPage(t);if(i!=null){let a=C(t,this._pageSize),o=i.nodes[a];o.parentIndex=n??-1;let s=o.node;s!=null&&(s.level=r,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){let n=e.pop(),r=this.getNode(n);if(r!=null)for(let e=0;e<r.childCount;e++)t(this.getChildIndex(r.index,e),n,r.level+1),this._maxLevel=Math.max(this._maxLevel,r.level+1)}}_getPage(e){let t=S(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){let t=this._getPage(e);return t==null?null:(t.lastTraversed=this._frameNumber,t.nodes[C(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);let n=this.getParent(t),r=n==null?0:n.level+1;this._maxLevel=Math.max(this._maxLevel,e.children?r+1:r);let{lodMetric:i,maxError:a}=E(e.lodSelection),s=this._getNodeDescriptor(t);if(s.node!=null)return this._logger.error(`Loaded node[${t}] already in descriptor`),s.node;let l=new c(e.id,t,e.mbs,s.childCount,r,e.resources,e.version,i,a,e.numFeatures,e.obb?o.fromJSON(e.obb):null);s.node=l,l.visibilityObbInRenderSR=this._computeVisibilityObb(l);let u=s.nodeBoundingData;return u!=null&&(u.serviceMbsInIndexSR??=e.mbs,l.shareServiceBVsInRenderSRWith(u),u.visibilityObbInRenderSR=l.visibilityObbInRenderSR),l}_makeRefNode(e,t){let n=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(n==null)return-1;let r=n.nodes.length,i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_makeClientRefNode(e,t){let n=this._clientNodePage;if(n==null)return-1;if(t>=0)throw Error(`I3SIndex::client side nodes can not be made children of service side nodes.`);let r=-(n.nodes.length+1),i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_linkChildToParentNode(e,t){let n=this._clientNodePage;if(n==null||e>=0)return;let r=C(e,this._pageSize),i=C(t,this._pageSize),a=n.nodes[r],o=a.childOffset;n.children.splice(a.childOffset+a.childCount,0,t),a.childCount+=1,a.node!=null&&(a.node.childCount+=1);for(let e of n.nodes)e.childOffset>o&&(e.childOffset+=1);let s=n.nodes[i];s.parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,n){let r=this._clientNodePage;if(r==null)return;let i=this._getParentIndex(e);if(i==null)return;let a=new Set,o=new Map,s=e=>{let n=C(e,this._pageSize),i=r.nodes[n];if(i.childCount>0)for(let e=i.childOffset;e<i.childOffset+i.childCount;++e)s(r.children[e]);let o=i.node?.id??i.nodeBoundingData?.id;if(o==null)throw Error(`Node has no id`);t(o,e),a.add(i)};s(e);let c=r.nodes,l=r.children,u=r.nodes.map(()=>-1),d=[],f=[];for(let e=0;e<c.length;++e){let t=c[e];if(a.has(t))continue;let r=d.length,i=w(e,-1,this._pageSize),s=w(r,-1,this._pageSize);if(t.node&&(t.node.index=s),u[e]=s,d.push(t),i!==s){let e=t.node?.id??t.nodeBoundingData?.id;if(e==null)throw Error(`Node has no id`);n(e,i,s),o.set(i,s)}}for(let e=0;e<d.length;++e){let t=w(e,-1,this._pageSize),n=d[e],r=f.length;for(let e=n.childOffset;e<n.childOffset+n.childCount;++e){let n=l[e];if(n>=0)f.push(n);else{let e=C(n,this._pageSize),r=c[e];if(a.has(r))continue;let i=u[e];f.push(i),r.parentIndex=t}}n.childOffset=r,n.childCount=f.length-r,n.node&&(n.node.childCount=n.childCount)}r.setNodes(d,f),this._updateParentBoundingInformation(u[C(i,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null,n=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,o=this._getNodeDescriptor(t);if(o==null)return;for(let i=0;i<o.childCount;i++){let o=this.getChildIndex(t,i),s=this._getNodeDescriptor(o),c=s==null?null:s.nodeBoundingData||s.node;if(c?.serviceMbsInIndexSR!=null&&c.serviceMbsInIndexSR.radius>0){if(e==null)e=A.copyFrom(c.serviceMbsInIndexSR);else{let t=j;r(c.serviceMbsInIndexSR,n,t,a);let i=M;r(e,n,i,a),r(t.union(i),a,e,n)}}}let s=t=>{t!=null&&(t.serviceObbInIndexSR=null,e==null?t.serviceMbsInIndexSR?.invalidate():(t.serviceMbsInIndexSR??=new i,t.serviceMbsInIndexSR.copyFrom(e)),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};s(o.nodeBoundingData),s(o.node),this.invalidateNodeVisibilityCacheInternal(o),t=this._getParentIndex(t)}while(t!=null)}populateChildren(e,t){let n=this._getNodeDescriptor(e),r=this._getPage(e);n.childOffset=r.children.length,n.childCount=t.length;for(let n=0;n<t.length;n++){let i=this._makeRefNode(t[n],e);r.children.push(i)}}getNode(e){let t=this._getNodeDescriptor(e);return t==null?null:t.node}getIndexById(e){let t;return this._forAllNodes((n,r)=>{(n.node!=null&&n.node.id===e||n.nodeBoundingData!=null&&n.nodeBoundingData.id===e)&&(t=r)}),t}getNodeById(e){let t=this.getIndexById(e);return t!=null&&t>=0?this.getNode(t):null}getChildIndex(e,t){let n=this._getPage(e);if(n==null)return-1;let r=n.nodes[C(e,this._pageSize)];return n.children[r.childOffset+t]}_getParentIndex(e){let t=this._getPage(e);return t!=null&&e!==this._rootIndex?t.nodes[C(e,this._pageSize)]?.parentIndex:null}getParent(e){let t=this._getParentIndex(e);return t==null?null:this.getNode(t)}isLeaf(e){let t=this._getNodeDescriptor(e);return t!=null&&t.childCount===0}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{e.node!=null&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=v(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){let t=this._getNodeDescriptor(e);t!=null&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=_(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){let t=this._getNodeDescriptor(e);t!=null&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){let t=this._getNodeDescriptor(e);t!=null&&(this._needsNodeElevationRange?(t.node==null?t.nodeBoundingData:t.node)?.invalidateElevationRange():this.invalidateBoundingVolumeCache(e))}invalidateGeometryVisibility(e){let t=this._getNodeDescriptor(e)?.node;t&&(t.geometryObbInRenderSR=null,t.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){this.rootNode!=null&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeValid(e){if(!this._needsNodeElevationRange)return!0;let t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){let n=this._getNodeDescriptor(e);if(!n)return!1;let r=n?.node??n?.nodeBoundingData;if(!r)return!1;if(r.elevationRangeValid)return t?.expandElevationRange(r),!0;let i=new a,o=!1;for(let t=0;t<n.childCount;t++){let n=this.getChildIndex(e,t),r=this._updateElevationRange(n,i);o||=!r}if(n.childCount===0||o){let e=!n.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(r,e,i)}(i.minElevation===1/0||i.maxElevation===-1/0)&&i.expandElevationRangeValues(0,0);let{minElevation:s,maxElevation:c}=r;return s===i.minElevation&&c===i.maxElevation?(t?.expandElevationRange(r),!0):(n.node?.setElevationRange(i),n.nodeBoundingData?.setElevationRange(i),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(r),!0)}isNodeVisible(e){let t=this._getNodeDescriptor(e);if(t==null)return!0;let n=t.nodeBoundingData;if(n!=null&&!n.serviceMbsInIndexSR)return!0;if(this._isElevationRangeValid(t)&&b(t.visibilityCache,this._visibilityCacheVersion))return x(t.visibilityCache);let r=t.node,i=this._viewportQueries;if(r){let e=i.ensureElevationAgnosticBoundingVolume(r),n=i.isElevationAgnosticBoundingVolumeVisible(e,this.isGroundNavigationMode?this._groundNavigationCheckDistance:0),a=n;if(this._needsNodeElevationRange&&n){let t=i.getNodeObbInRenderSRIndependentOfElevationOffset(r);t!=null&&(a=i.isObbVisibleIndependentOfElevation(e,t))}if(!a)return t.visibilityCache=y(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(r!=null||n!=null)&&t.filterImpact===2){let e=r==null?n==null?null:n.serviceMbsInIndexSR:r.serviceMbsInIndexSR;t.filterImpact=e==null?0:this._computeNodeFiltering(e)}let a=r!=null&&t.filterImpact===1,o=(r==null||r.imModificationImpact!==2)&&!a;if(o){let t=r&&(!n||r.visibilityObbInRenderSR)?r:n??null;t!=null&&(this._needsNodeElevationRange&&this._updateElevationRange(e),o=i.isNodeVisible(t,this.isGroundNavigationMode))}return t.visibilityCache=y(o,this._visibilityCacheVersion),o}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;let t=this._getNodeDescriptor(e);return t?.node?.geometryObbInRenderSR!=null&&(!this.layerHasModifications||t.node.imModificationImpact!==4)?this._viewportQueries.isGeometryVisible(t.node,this.isGroundNavigationMode):!0}_traverseCoverage(e,t,n,r,i){let a=this._getPage(e);if(a==null||t.childCount===0)return;let o=t.childOffset+t.childCount,s=[];for(let e=t.childOffset;e<o;++e){let t=a.children[e],n=this._getNodeDescriptor(t);n?.node!=null&&this.isGeometryVisible(t)&&s.push(n)}r/=s.length;for(let e of s){let t=e.node.index;this._isLoaded(t)||this._isReloading(t)?(i.delta=Math.max(i.delta,n),i.coverage+=r):this._traverseCoverage(t,e,n+1,r,i)}}useNodeAsHole(e){if(this.holeFilling===`off`)return!1;let t=this._getNodeDescriptor(e);if(t==null)return!1;if(this.holeFilling===`always`)return!0;if(b(t.useAsHole,this._version))return x(t.useAsHole);let n={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,n);let r=n.delta*n.coverage<=.5;return t.useAsHole=y(r,this._version),r}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.destroy(),this._nodePages.clear(),this._clientNodePage=null,this._layer=null,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._imModificationUncategorized.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=v(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{e!=null&&(e.imModificationImpact=4,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))}),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes(e=>{if(e!=null){e.filterImpact=2;let t=e.node;t!=null&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,n){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let r=!0,i=new D,a=new O,o=this._imModificationUncategorized;o.clear();let s=new Set,c=0;this.traverseVisible((s,l,u)=>{let d=e=>{this._shouldLoadNode(e)&&e.childCount&&(r=!1)};if(!l){let e=S(s,this._pageSize),t=this._getNodeLoadPriority(s);t===1/0&&(t=this._getNodeLoadPriority(u)),h.set(e,Math.max(t,h.get(e)||0)),!this._loadingPages.has(e)&&!this._failedPages.has(e)&&(this._missingPagesAndNodes.add(e),++c),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t);return}let{node:f,childCount:p}=l;if(this._updateNodeFeatureEstimate(f,a),!f){let e=this._getNodeLoadPriority(s);!this._loadingNodes.has(s)&&!this._failedNodes.has(s)&&(this._missingPagesAndNodes.add(s),h.set(s,e)),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e);return}let m=this._getPage(s);if(!this._useNodePages&&this._missingPagesAndNodes.size===0)for(let e=0;e<p;e++){let t=m.children[l.childOffset+e],n=this._getNodeDescriptor(t);n!=null&&!n.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(h.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(f.failed||f.resources.isEmpty){d(f);return}if(this._isLoaded(s)){if(i.known+=f.memory,++i.knownNodes,d(f),this._shouldLoadNode(f)||(i.unremoved+=f.memory),this._needsUpdate(f)){let e=this._getNodeLoadPriority(s);h.set(s,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(s)}return}if(f.memory&&(i.known+=f.memory,++i.knownNodes),!this._shouldLoadNode(f)){this._isReloading(s)&&this._updates.remove.push(s);return}if(d(f),f.memory?(i.missing+=f.memory,i.known+=f.memory,++i.knownNodes):++i.missingNodes,e.includes(f.index)){this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(s)),this._updates.cancel=this._updates.cancel.filter(e=>e!==f.index);return}if(!t.done&&this._enable(f)){t.madeProgress();return}let g=this._getNodeLoadPriority(s);h.set(s,g),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,g),this._updates.add.push(s),this.layerHasModifications&&n&&f!=null&&f.imModificationImpact===4&&o.push(s)},s),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(s,c),this._handleModifications(n,o),this._updateUnloadedMemoryEstimate(i),this._featureEstimate.estimate=this._computeFeatureEstimate(a),this._featureEstimate.leavesReached=r,this._updates.add.filterInPlace(e=>h.get(e)>=this._maxUnloadedPrio).sort((e,t)=>h.get(e)-h.get(t)),this._updates.update.sort((e,t)=>h.get(e)-h.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,h.clear()}_updateUnloadedMemoryEstimate(e){this._unloadedMemoryEstimate=e.missing-e.unremoved,e.knownNodes>3&&e.missingNodes>0&&(this._unloadedMemoryEstimate+=e.known/e.knownNodes*e.missingNodes),this._unloadedMemoryEstimate=Math.max(0,this._unloadedMemoryEstimate)*.8}resetUpdateState(e){this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=-1/0,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),h.clear()}_prioritizeMissingNodesAndPages(){let e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),e.length>0&&(this._maxUnloadedPrio=h.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&this._updates.add.length!==0&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{let t=this._getNodeDescriptor(e),n=t?.node==null||t.node.imModificationImpact!==2;return n||this.invalidateNodeVisibilityCache(e),n}))}checkFeatureTarget(e,t){let n=this._viewportQueries.updateScreenSpaceErrorBias(t),r=t,i=t,a=n,o=10;for(;o--;){let n=new O;if(this._updateFeatureEstimate(r,n),this._computeFeatureEstimate(n)<=e){if(r>=t||n.missingNodes>0||o===0)break;a=r,r=(r+i)*.5}else i=r,r=(r+a)*.5}return this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(n),Math.min(t,r)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;let n=e.size,r=this._nodePages,i=r.size+this._loadingPages.size+t;if(i>P&&i>n){let t=[];for(let[n,i]of r)i.numNodesWithLoadedChildren===0&&!e.has(n)&&t.push([i.lastTraversed,n]);t.sort((e,t)=>e[0]-t[0]).some(e=>{let t=e[1];return this._deleteNodePage(t),r.size<=P})}}_updateFeatureEstimate(e,t){this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,n)=>this._updateNodeFeatureEstimate(n?.node,t))}_updateNodeFeatureEstimate(e,t){e!=null&&!e.failed&&this._shouldLoadNode(e)&&(e.numFeatures==null?++t.missingNodes:(t.numFeatures+=e.numFeatures,++t.knownNodes))}_computeFeatureEstimate(e){let t=e.numFeatures;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.numFeatures/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._prioritizedMissingNodeAndPageIds,this._missingPagesAndNodes)}prefetch(){let e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(e.length===0||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){let n=e[e.length-1];e.length--,t.delete(n),this._useNodePages&&n>=0?this._loadPage(n):this._loadNode(n)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.size>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(e==null)return null;let t=e.index,n=this._getNodeDescriptor(t);if(!n)return null;let r=n?.traversalState;if(r&&b(r.version,this._version))return r;let i=this._viewportQueries.getLodLevel(e),a=this._viewportQueries.hasLOD(e),o=!0;if(a){let e=this._getParentIndex(t);if(e!=null){let t=this._getNodeDescriptor(e)?.traversalState;o=!!t&&i>t.lodLevel}else o=i>0}else o=e.childCount===0;return r?(r.lodLevel=i,r.isChosen=o,r.version=y(!0,this._version),r):(r=new l(a,o,i,y(!0,this._version)),n.traversalState=r,r)}_loadNode(e){if(this._loadingNodes.has(e)){this._logger.error(`Node[${e}] already loading`);return}this._loadingNodes.add(e);let t=this._getNodeDescriptor(e);if(t.node){this._logger.error(`Node[${e}] already in descriptor`);return}let r=t.nodeBoundingData;if(r==null){this._failedNodes.add(e);return}let i=r.id,a=this.urlPrefix+i,o=()=>{this._loadingNodes.delete(e),this._missingPagesAndNodes.size===0&&this._loadingNodes.size===0&&this.requestUpdate()};(e>=0?this._requester.request(a,`json`):this._clientNodeLoader.loadNodeJSON(i)).then(t=>{o();let n=this._validateNode(i,t);if(n==null)return;n.obb&&this.invalidateNodeVisibilityCache(e);let r=this._addNode(n,e);this.nodeTraversalState(r)}).catch(t=>{o(),n(t)||(this._logger.error(`#loadNode()`,this._layer,`Error loading node: `+a),this._failedNodes.add(e))})}_validateNode(e,t){if(typeof t!=`object`||!t||t.id!==e)return this._logger.error(`#validateNode()`,this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error(`#validateNode()`,this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&t.sharedResource.href!==`./shared`&&t.sharedResource.href!==`./shared/`&&this._logger.warn(`#validateNode()`,this._layer,`Invalid shared resource href on node "${e}"`);let n=t.geometryData;n!=null&&!(Array.isArray(n)&&n.length===0)&&!(Array.isArray(n)&&n.length===1&&n[0].href===`./geometries/0`)&&this._logger.warn(`#validateNode()`,this._layer,`Invalid geometry data on node "${e}"`);let r=t.attributeData,a=this._layer.attributeStorageInfo;r!=null&&(!Array.isArray(r)||r.some((e,t)=>e.href!==`./attributes/${a?.[t]?.key??`f_${t}`}/0`))&&this._logger.warn(`#validateNode()`,this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn(`#validateNode()`,this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);let c=t.hasOwnProperty(`obb`)&&!this.ignoreServiceObb?t.obb:void 0,l=t.featureData?.length===1&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,u=Array.isArray(t.children)?t.children.map(t=>{if(t==null)return null;let n=t=>this._logger.error(`#validateNode()`,this._layer,`Invalid node reference on node ${e}: ${t}`);if(typeof t.id==`number`)n(`id ${t.id} is a number instead of a string.`);else if(typeof t.id!=`string`||!Array.isArray(t.mbs))return n(`Missing or invalid id.`),null;if(!Array.isArray(t.mbs))return n(`Invalid bounding volume on reference ${t.id}.`),null;let r=new s(`${t.id}`,new i(t.mbs));return r.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty(`obb`)&&t.obb?o.fromJSON(t.obb):null,r.visibilityObbInRenderSR=this._computeVisibilityObb(r),r}).filter(e=>e!=null):null,f=t.featureData?.length??!1,p=t.isEmpty===!0;return new d(e,new i(t.mbs),c,typeof t.version==`string`?t.version:null,{isEmpty:!f&&p,hasSharedResource:t.sharedResource!=null,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:t.geometryData==null?void 0:e},u,Array.isArray(t.lodSelection)?t.lodSelection:null,l)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{e.node!=null&&(e.node.failed=!1)})}_getNodeLoadPriority(e){let t=this._getNodeDescriptor(e),n=this._getParentIndex(e);if(t==null||n==null&&t.node==null)return n==null?1/0:this._getNodeLoadPriority(n);let r=0;t.node&&n!=null&&(r=this._getNodeDescriptor(n).traversalState?.lodLevel??0);let i=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+r)+r*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+i}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;t!=null;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){let n=this._getNodeDescriptor(this._rootIndex);n==null?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,null,n,e,t)}_traverseVisible(e,t,n,r,i){let a=S(e,this._pageSize);if(i&&i.add(a),n.node&&n.childCount===0){this.isGeometryVisible(e)&&r(e,n,t);return}if(!this.isNodeVisible(e)||(r(e,n,t),n.node==null))return;let o=this.nodeTraversalState(n.node);if(o?.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;let s=this._getPageFromPageIndex(a);for(let t=0;t<n.childCount;t++){let a=s.children[n.childOffset+t],o=this._getNodeDescriptor(a);if(o)this._traverseVisible(a,e,o,r,i);else{if(i){let e=S(a,this._pageSize);i.add(e)}r(a,null,e)}}}traverse(e,t){for(let n of this.traverseValues(e,t));}*traverseValues(e,t){t(e)&&(yield e,yield*this._traverseDescendantValues(e,t))}*_traverseDescendantValues(e,t){let n=e.index,r=this._pageSize,i=S(n,r),a=this._getPageFromPageIndex(i);if(a==null)return;let o=this._frameNumber,s=this._nodePages,c=C(n,r),l=a.nodes[c],u=l.childCount;if(a.lastTraversed=o,u===0)return;let d=[],f=[],p=0;{let{childOffset:e,childCount:t}=l,{children:n}=a;f.length=2**Math.ceil(Math.log2(p+t));for(let r=e;r<e+t;++r){let e=n[r];e>=0?(f[p]=e,++p):d.push(e)}}if(d.length>0){let e=this._clientNodePage;if(e){let n=e.children,r=0;for(;r<d.length;){let i=d[r];++r;let a=-i-1,o=e.nodes[a],s=o.node;if(!s||!t(s))continue;yield s;let{childCount:c}=o;if(c===0)continue;let{childOffset:l}=o,u=l+c;for(let e=l;e<u;++e)d.push(n[e])}}}if(p>0){let e=0;if(r>0){let n=i*r,c=a,l=c.nodes;for(;e<p;){let i=f[e];++e;let a;if(n<=i&&i<n+r)a=c;else{let e=i/r|0,t=s.get(e);if(t===void 0)continue;a=t,a.lastTraversed=o,c=a,l=c.nodes,n=r*e}let u=i-n,d=l[u],m=d?.node;if(m==null||t(m)===!1||(yield m,d.node==null))continue;let{childCount:h}=d;if(h===0)continue;let g=p+h;for(f.length<g&&(f.length=2**Math.ceil(Math.log2(p+h)));f.length<p+h;)f.length+=f.length;let _=a.children,{childOffset:v}=d,y=v+h;for(let e=v;e<y;++e)f[p]=_[e],++p}}else{let n=s.get(0);if(n)for(;e<p;){let r=f[e++],i=n.nodes[r],a=i.node;if(!a||!t(a))continue;yield a;let{childCount:o}=i;if(o===0)continue;f.length=Math.max(f.length,2**Math.ceil(Math.log2(p+o)));let s=n.children,{childOffset:c}=i,l=c+o;for(let e=c;e<l;++e)f[p]=s[e],++p}}}}traverseDescendants(e,t){for(let n of this._traverseDescendantValues(e,t));}updateChildrenLoaded(e,t){let n=this.getNode(e);for(;n!=null;){let e=n.childrenLoaded,r=e+t;n.childrenLoaded=r;let i=e===0?1:r===0?-1:0,a=n.index;if(i!==0){let e=this._getPage(a);e.numNodesWithLoadedChildren+=i}n=this.getParent(a)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this._needsNodeElevationRange=t&&!!e&&(e.mode===`relative-to-ground`||e.mode===`relative-to-scene`||e.mode===`on-the-ground`),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_forAllNodes(e){if(this._clientNodePage!=null){let t=this._clientNodePage;for(let n=0;n<t.nodes.length;n++)e(t.nodes[n],-(n+1))}for(let[t,n]of this._nodePages){let r=t*this._pageSize;for(let t=0;t<n.nodes.length;t++)e(n.nodes[t],r+t)}}clearCaches(){if(this._useNodePages){let e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(S(e,this._pageSize)));for(let[n,r]of e)if(r.numNodesWithLoadedChildren===0&&!t.has(n))this._deleteNodePage(n);else for(let e of r.nodes)e.traversalState=null}}_deleteNodePage(e){if(!this._nodePages.has(e)){this._logger.error(`Destroying non-existent page ${e}`);return}let t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const h=new Map;class g{constructor(e){this.missing=e,this.update=new t({deallocator:null}),this.add=new t({deallocator:null}),this.remove=new t({deallocator:null}),this.cancel=[]}destroy(){this.update.prune(),this.add.prune(),this.remove.prune(),this.cancel.length=0}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function _(e){return u(e,-2)}function v(e){return u(e,2)}function y(e,t){return t+ +!!e}function b(e,t){return(e&-2)===t}function x(e){return(e&1)==1}function S(e,t){return e<0?-1:t>0?e/t|0:0}function C(e,t){return e<0?-e-1:t===0?e:e%t}function w(e,t,n){return t===-1?-(e+1):n===0?e:t*n+e}const T=[[`maxScreenThreshold`,1],[`screenSpaceRelative`,2],[`removedFeatureDiameter`,3],[`distanceRangeFromDefaultCamera`,4]];function E(e){if(e){for(let t=0;t<e.length;t++)for(let n of T)if(n[0]===e[t].metricType)return{lodMetric:n[1],maxError:e[t].maxError}}return{lodMetric:0,maxError:0}}class D{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class O{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function k(e){return Math.sqrt(4/Math.PI*e)}const A=new i,j=new i,M=new i,N=e(),P=has(`esri-mobile`)?100:300;export{m as I3SIndex,E as selectErrorMetric};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{intersectsSphere as e}from"../../../../geometry/support/frustumPlanes.js";import{IntersectorResultRay as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as r}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{I3sTarget as i}from"./Intersector.js";class a{constructor(e,t){this.node=e,this.objectHandle=t}}class o{get isGround(){return this.integratedMeshSemantics.shouldIntersectAsGround}constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.integratedMeshSemantics=e.integratedMeshSemantics}updateElevationAlignState(e,t){this._needVerticalOffset=e&&t
|
|
2
|
+
import{intersectsSphere as e}from"../../../../geometry/support/frustumPlanes.js";import{IntersectorResultRay as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as r}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{I3sTarget as i}from"./Intersector.js";class a{constructor(e,t){this.node=e,this.objectHandle=t}}class o{get isGround(){return this.integratedMeshSemantics.shouldIntersectAsGround}constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.integratedMeshSemantics=e.integratedMeshSemantics}updateElevationAlignState(e,t){this._needVerticalOffset=e&&t}intersectRay(e,a,o,c,l,u){let d=e.options.store===2,f=e.ray.direction,p=e=>e,m=e=>e,h=r(e.verticalOffset??(this._needVerticalOffset?0:null));e.verticalOffset!=null&&h!=null&&(p=e=>h.applyToMbs(e),m=e=>h.applyToObb(e));let{results:g,tolerance:_}=e,v=new n(_,u,e.options.normalRequired),y=e=>{if(e.childrenLoaded===0)return!1;let t=e.serviceObbInRenderSR?.isValid?e.serviceObbInRenderSR:null;return!(t&&!m(t).intersectRay(o,f,_))};for(let{node:n,objectHandle:r}of this._traverseNodeHierarchy(y)){let l=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null,{serviceMbsInRenderSRElevationAdjusted:u}=n;r&&(l||!u.isValid||s(p(u),o,f,_))&&(n.geometryObbInRenderSR==null||m(n.geometryObbInRenderSR).intersectRay(o,f,_))&&this._collection.intersectRay(r,o,c,h,v,(r,s,l,u,f)=>{if(s<0||a!=null&&!a(o,c,s))return;let p=e=>{let t=new i(this.layerViewUid,this.sublayerId,n.index,f,u);e.set(this.type,t,r,s,l)};if(this.isGround&&(g.ground.renderDistance==null||s<g.ground.renderDistance)&&p(g.ground),!e.options.isFiltered&&((g.min.renderDistance==null||s<g.min.renderDistance)&&p(g.min),(g.max.renderDistance==null||r>g.max.renderDistance)&&p(g.max),d)){let n=new t(e.ray);p(n),e.results.all.push(n)}})}}*intersectScreenPolygon(t,n){if(t.camera==null)return;let a=r(this._needVerticalOffset?0:null),o=t=>{if(t.childrenLoaded===0)return!1;let r=t.serviceObbInRenderSR?.isValid?t.serviceObbInRenderSR:null;if(r!=null){if(!r.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))return!1}else{let r=t.serviceMbsInRenderSRElevationAdjusted;if(r.isValid&&!e(n.broadPhaseFrustum,r))return!1}return!0};for(let{node:e,objectHandle:r}of this._traverseNodeHierarchy(o))r!=null&&r.visible&&(e.geometryObbInRenderSR==null||e.geometryObbInRenderSR.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))&&(yield*this._collection.intersectScreenPolygon(r,t,n,a,(n,r,a,o)=>{t.polygonResults.add(this.type,new i(this.layerViewUid,this.sublayerId,e.index,n,o),r)}))}}function s(e,t,n,r=0){let i=e.radius+r,a=t[0]-e.center[0],o=t[1]-e.center[1],s=t[2]-e.center[2],[c,l,u]=n,d=c*c+l*l+u*u,f=c*a+l*o+u*s,p=a*a+o*o+s*s-i*i;return f*f-d*p>=0}export{o as I3SIntersectionHandler,a as TraversedIntersectionNode};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{indexOf as i,PositionHint as a}from"../../../../core/arrayUtils.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../../core/Logger.js";import{clamp as l}from"../../../../core/mathUtils.js";import{unwrapUpdating as u,updating as d,isUpdating as f}from"../../../../core/maybeUpdating.js";import{whenOnce as p}from"../../../../core/reactiveUtils.js";import m from"../../../../core/sql/WhereClause.js";import{getUnitString as h,lengthUnits as g}from"../../../../core/units.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import{projectBoundingSphere as v}from"../../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as y}from"../../../../geometry/projection/projectVectorToVector.js";import{create as b}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as x,expandWithNestedArray as S,expand as C}from"../../../../geometry/support/aaBoundingRect.js";import{doubleArrayFrom as w}from"../../../../geometry/support/DoubleArray.js";import{earth as T}from"../../../../geometry/support/Ellipsoid.js";import{isWGS84 as E,isWebMercator as D}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as O}from"../../../../geometry/support/sphere.js";import k from"../../../../layers/support/FeatureFilter.js";import{objectIdFilter as A,filterInPlace as j}from"./I3SUtil.js";let M=class extends t{constructor(e){super(e)}initialize(){p(()=>this.viewFilter?.geometry||this.layerFilter).then(()=>Promise.all([this._loadOperator(import(`../../../../geometry/operators/json/geodesicBufferOperator.js`)),this._loadOperator(import(`../../../../geometry/operators/json/bufferOperator.js`)),this._loadOperator(import(`../../../../geometry/operators/json/intersectsOperator.js`)),this._loadOperator(import(`../../../../geometry/operators/json/containsOperator.js`)),this._loadOperator(import(`../../../../geometry/operators/json/disjointOperator.js`))]).then(async e=>{this.destroyed||(this._geometryOperators=e)}))}_loadOperator(e){return this.loadAsyncModule(e).then(e=>`load`in e&&typeof e.load==`function`?e.load().then(()=>e):e)}get sortedObjectIds(){return this.viewFilter?.objectIds==null?null:w(this.viewFilter.objectIds).sort()}get parsedWhereClause(){let e=this.viewFilter?.where;if(e==null||!e)return null;try{return m.create(e,{fieldsIndex:this.layerFieldsIndex})}catch(e){c.getLogger(this).error(`Failed to parse filter where clause: ${e}`)}return null}addFilters(e,t,n,r){let i=this.sortedObjectIds;i!=null&&e.push(e=>A(i,!0,e)),this.addSqlFilter(e,this.parsedWhereClause),this.addTimeFilter(e,this.viewFilter?.timeExtent);let a=this._geometryOperators;if(!a)return;let o=()=>c.getLogger(this),s=u(this._layerMaskGeometries);if(s&&this.layerFilter){let i=this.layerFilter.spatialRelationship;e.push((e,c)=>R(o,a,e,c,r,t,n,s,i))}let l=u(this._viewMaskGeometries);if(l&&this.viewFilter){let i=this.viewFilter.spatialRelationship;e.push((e,s)=>R(o,a,e,s,r,t,n,l,i))}}isMBSGeometryVisible(e,t,n){let r=this._geometryOperators;if(!r)return!0;let i=u(this._layerMaskGeometries);if(i&&this.layerFilter){let a=this.layerFilter.spatialRelationship,o=i[0].spatialReference||t;return v(e,n,z,o)?L(r,z,i,o,a):(c.getLogger(this).warnOnce(`SceneLayer.mask geometry is using unsupported SpatialReference, skipping geometry filter for MBS`),!0)}let a=u(this._viewMaskGeometries);if(a&&this.viewFilter){let i=this.viewFilter.spatialRelationship,o=a[0].spatialReference||t;return v(e,n,z,o)?L(r,z,a,o,i):(c.getLogger(this).warnOnce(`SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter for MBS`),!0)}return!0}get parsedGeometry(){let e=u(this._viewMaskGeometries),t=u(this._layerMaskGeometries);return e==null||t==null?e??t:t.concat(e)}get _layerMaskGeometries(){let e=this.layerFilter;return e==null?null:this._geometryOperators==null?d:e.spatialRelationship===`disjoint`?e.geometries.map(e=>({type:`polygon`,rings:e.rings,spatialReference:e.spatialReference,cache:{}})):[e.geometries.reduce((e,t)=>(e.rings=[...e.rings,...t.rings],e),{type:`polygon`,rings:[],spatialReference:e.geometries[0].spatialReference,cache:{}})]}get _viewMaskGeometries(){let e=this.viewFilter?.geometry;if(!this.viewFilter||!e)return null;if(!this._geometryOperators)return d;let{distance:t,units:n}=this.viewFilter,r=this.viewFilter.spatialRelationship,i=e.type===`mesh`?e.extent:e;if(t==null||t===0)return I(this._geometryOperators,i,r);try{let e=F(n,i.spatialReference),a=this._geometryOperators[0].geodesicBufferExecute(i.toJSON(),t,{unit:e});return I(this._geometryOperators,a,r)}catch{c.getLogger(this).error(`Filter by geodesic buffer (distance) unsupported, failed execute with input geometry (${JSON.stringify(i.toJSON())}).`)}return null}get updating(){return f(this._layerMaskGeometries)||f(this._viewMaskGeometries)}static checkSupport(e){return e==null?!1:P(e.spatialRelationship)?!0:(c.getLogger(this.prototype).warn(`Filters with spatialRelationship other than ${N.join(`, `)} are not supported for mesh scene layers`),!1)}};e([n()],M.prototype,`layerFilter`,void 0),e([n({type:k})],M.prototype,`viewFilter`,void 0),e([n()],M.prototype,`layerFieldsIndex`,void 0),e([n()],M.prototype,`loadAsyncModule`,void 0),e([n()],M.prototype,`addSqlFilter`,void 0),e([n()],M.prototype,`addTimeFilter`,void 0),e([n({readOnly:!0})],M.prototype,`sortedObjectIds`,null),e([n({readOnly:!0})],M.prototype,`parsedWhereClause`,null),e([n({readOnly:!0})],M.prototype,`parsedGeometry`,null),e([n({readOnly:!0})],M.prototype,`_layerMaskGeometries`,null),e([n({readOnly:!0})],M.prototype,`_viewMaskGeometries`,null),e([n()],M.prototype,`updating`,null),e([n()],M.prototype,`_geometryOperators`,void 0),M=e([r(`esri.views.3d.layers.i3s.I3SMeshViewFilter`)],M);const N=(e=>e)([`contains`,`intersects`,`disjoint`]);function P(e){return e!=null&&N.includes(e)}function F(e,t){let n=e??h(t);return g.includes(n)?n:void 0}function I(e,t,n){if(t==null)return null;if(n===`disjoint`&&`rings`in t){let n=t.spatialReference,r=t.rings.map(e=>{let t=x(1/0,1/0,-1/0,-1/0);return S(t,e),new B({rings:[e],spatialReference:n},t)});r.sort((e,t)=>e.aabr[0]-t.aabr[0]);let o=new Set,s=new a;for(let t=0;t<r.length;++t){let{polygon:n,aabr:a}=r[t],c=a[0];o.forEach(t=>{if(c>=t.aabr[2]){o.delete(t);return}if(a[1]>t.aabr[3]||a[3]<t.aabr[1]||!e[2].intersectsExecute(n,t.polygon))return;n.rings=n.rings.concat(t.polygon.rings),C(a,t.aabr,a),o.delete(t);let l=i(r,t,r.length,s);r.splice(l,1)}),o.add(r[t])}return r.map(({polygon:e})=>e)}return[`toJSON`in t?t.toJSON():t]}function L(e,t,n,r,i){if(t.radius>=(t.center[2]+_(r).radius)*.5)return!0;let a=H(e,t,r);return!a||n.every(t=>U(e,t,a,i)!==1)}function R(e,t,n,r,i,a,o,s,c){let l=s[0].spatialReference||a.spatialReference;if(!v(r.node.serviceMbsInIndexSR,o,z,l)){e().warnOnce(`SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter`);return}let u=H(t,z,l);if(!u)return;let d=V(c,a,l,i,r.objectHandle),f=c===`intersects`,p=null;for(let e of s){if(n.length===0)return;switch(U(t,e,u,c)){case 1:f&&(r.weaklyRemovedIds=r.weaklyRemovedIds?.concat(n)??n.slice()),n.length=0;return;case 0:continue}j(n,r.featureIds,n=>K(t,e,n,d)?!0:(f&&(p||=[],p.push(r.featureIds[n])),!1))}p&&(r.weaklyRemovedIds=r.weaklyRemovedIds?.concat(p)??p)}const z=new O;class B{constructor(e,t){this.aabr=t,this.polygon={rings:e.rings,spatialReference:e.spatialReference}}}function V(e,t,n,r,i){let a=t.renderSpatialReference,o=new Map,s={rings:[[[0,0,0],[0,0,0],[0,0,0],[0,0,0]]],spatialReference:n};s.rings[0][3]=s.rings[0][0];let c={indices:null,data:null,stride:0,startIndex:0,endIndex:0},l,u;switch(e){case`intersects`:l=(e,t,n)=>e[2].intersectsExecute(t,n)?0:2,u=W;break;case`contains`:l=(e,t,n)=>e[3].containsExecute(t,n)?2:1,u=W;break;default:l=(e,t,n)=>e[4].disjointExecute(t,n)?2:1,u=G}return{collection:r,object:i,type:e,maskSR:n,renderSR:a,aabbCache:o,triangle:s,positions:c,triangleTest:l,geometryTest:u}}function H(e,t,n){let r={x:t.center[0],y:t.center[1],spatialReference:n},i=!E(n)&&!D(n),a=Number.isNaN(t.radius)?0:l(t.radius,0,T.radius*2);return i?e[1].bufferExecute(r,a):e[0].geodesicBufferExecute(r,a)}function U(e,t,n,r){if(!n)return 0;switch(r){case`intersects`:case`contains`:return W(e,t,n);case`disjoint`:return G(e,t,n)}}function W(e,t,n){return e[2].intersectsExecute(t,n)?e[3].containsExecute(t,n)?0:2:1}function G(e,t,n){return e[2].intersectsExecute(t,n)?e[3].containsExecute(t,n)?1:2:0}function K(e,t,n,r){let{collection:i,object:a,renderSR:c,maskSR:l,geometryTest:u,aabbCache:d}=r,f=d.get(n);if(!f){let e=i.getObjectTransform(a);i.getComponentAabb(a,n,q);let t=[s(q[0],q[1],0),s(q[0],q[4],0),s(q[3],q[4],0),s(q[3],q[1],0)];for(let n=0;n<4;++n)e.applyVec3(t[n],t[n]),y(t[n],c,t[n],l);f={rings:[t],spatialReference:l},f.rings[0][4]=f.rings[0][0],d.set(n,f)}switch(u(e,t,f)){case 1:return!1;case 0:return!0}let{triangle:p,triangleTest:m,positions:h}=r,g=p.rings[0][0],_=p.rings[0][1],v=p.rings[0][2],b=i.getObjectTransform(a);i.getComponentPositions(a,n,h);let{indices:x,data:S,stride:C,startIndex:w,endIndex:T}=h;for(let n=w;n<T;n+=3){let r=C*x[n],i=C*x[n+1],a=C*x[n+2];switch(o(g,S[r],S[r+1],S[r+2]),o(_,S[i],S[i+1],S[i+2]),o(v,S[a],S[a+1],S[a+2]),b.applyVec3(g,g),b.applyVec3(_,_),b.applyVec3(v,v),y(g,c,g,l),y(_,c,_,l),y(v,c,v,l),m(e,t,p)){case 1:return!1;case 0:return!0}}
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{indexOf as i,PositionHint as a}from"../../../../core/arrayUtils.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../../core/Logger.js";import{clamp as l}from"../../../../core/mathUtils.js";import{unwrapUpdating as u,updating as d,isUpdating as f}from"../../../../core/maybeUpdating.js";import{whenOnce as p}from"../../../../core/reactiveUtils.js";import m from"../../../../core/sql/WhereClause.js";import{getUnitString as h,lengthUnits as g}from"../../../../core/units.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import{projectBoundingSphere as v}from"../../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as y}from"../../../../geometry/projection/projectVectorToVector.js";import{create as b}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as x,expandWithNestedArray as S,expand as C}from"../../../../geometry/support/aaBoundingRect.js";import{doubleArrayFrom as w}from"../../../../geometry/support/DoubleArray.js";import{earth as T}from"../../../../geometry/support/Ellipsoid.js";import{isWGS84 as E,isWebMercator as D}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as O}from"../../../../geometry/support/sphere.js";import k from"../../../../layers/support/FeatureFilter.js";import{objectIdFilter as A,filterInPlace as j}from"./I3SUtil.js";let M=class extends t{constructor(e){super(e)}initialize(){p(()=>this.viewFilter?.geometry||this.layerFilter).then(()=>Promise.all([this._loadOperator(import(`../../../../geometry/operators/json/geodesicBufferOperator.js`)),this._loadOperator(import(`../../../../geometry/operators/json/bufferOperator.js`)),this._loadOperator(import(`../../../../geometry/operators/json/intersectsOperator.js`)),this._loadOperator(import(`../../../../geometry/operators/json/containsOperator.js`)),this._loadOperator(import(`../../../../geometry/operators/json/disjointOperator.js`))]).then(async e=>{this.destroyed||(this._geometryOperators=e)}))}_loadOperator(e){return this.loadAsyncModule(e).then(e=>`load`in e&&typeof e.load==`function`?e.load().then(()=>e):e)}get sortedObjectIds(){return this.viewFilter?.objectIds==null?null:w(this.viewFilter.objectIds).sort()}get parsedWhereClause(){let e=this.viewFilter?.where;if(e==null||!e)return null;try{return m.create(e,{fieldsIndex:this.layerFieldsIndex})}catch(e){c.getLogger(this).error(`Failed to parse filter where clause: ${e}`)}return null}addFilters(e,t,n,r){let i=this.sortedObjectIds;i!=null&&e.push(e=>A(i,!0,e)),this.addSqlFilter(e,this.parsedWhereClause),this.addTimeFilter(e,this.viewFilter?.timeExtent);let a=this._geometryOperators;if(!a)return;let o=()=>c.getLogger(this),s=u(this._layerMaskGeometries);if(s&&this.layerFilter){let i=this.layerFilter.spatialRelationship;e.push((e,c)=>R(o,a,e,c,r,t,n,s,i))}let l=u(this._viewMaskGeometries);if(l&&this.viewFilter){let i=this.viewFilter.spatialRelationship;e.push((e,s)=>R(o,a,e,s,r,t,n,l,i))}}isMBSGeometryVisible(e,t,n){let r=this._geometryOperators;if(!r)return!0;let i=u(this._layerMaskGeometries);if(i&&this.layerFilter){let a=this.layerFilter.spatialRelationship,o=i[0].spatialReference||t;return v(e,n,z,o)?L(r,z,i,o,a):(c.getLogger(this).warnOnce(`SceneLayer.mask geometry is using unsupported SpatialReference, skipping geometry filter for MBS`),!0)}let a=u(this._viewMaskGeometries);if(a&&this.viewFilter){let i=this.viewFilter.spatialRelationship,o=a[0].spatialReference||t;return v(e,n,z,o)?L(r,z,a,o,i):(c.getLogger(this).warnOnce(`SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter for MBS`),!0)}return!0}get parsedGeometry(){let e=u(this._viewMaskGeometries),t=u(this._layerMaskGeometries);return e==null||t==null?e??t:t.concat(e)}get _layerMaskGeometries(){let e=this.layerFilter;return e==null?null:this._geometryOperators==null?d:e.spatialRelationship===`disjoint`?e.geometries.map(e=>({type:`polygon`,rings:e.rings,spatialReference:e.spatialReference,cache:{}})):[e.geometries.reduce((e,t)=>(e.rings=[...e.rings,...t.rings],e),{type:`polygon`,rings:[],spatialReference:e.geometries[0].spatialReference,cache:{}})]}get _viewMaskGeometries(){let e=this.viewFilter?.geometry;if(!this.viewFilter||!e)return null;if(!this._geometryOperators)return d;let{distance:t,units:n}=this.viewFilter,r=this.viewFilter.spatialRelationship,i=e.type===`mesh`?e.extent:e;if(t==null||t===0)return I(this._geometryOperators,i,r);try{let e=F(n,i.spatialReference),a=this._geometryOperators[0].geodesicBufferExecute(i.toJSON(),t,{unit:e});return I(this._geometryOperators,a,r)}catch{c.getLogger(this).error(`Filter by geodesic buffer (distance) unsupported, failed execute with input geometry (${JSON.stringify(i.toJSON())}).`)}return null}get updating(){return f(this._layerMaskGeometries)||f(this._viewMaskGeometries)}static checkSupport(e){return e==null?!1:P(e.spatialRelationship)?!0:(c.getLogger(this.prototype).warn(`Filters with spatialRelationship other than ${N.join(`, `)} are not supported for mesh scene layers`),!1)}};e([n()],M.prototype,`layerFilter`,void 0),e([n({type:k})],M.prototype,`viewFilter`,void 0),e([n()],M.prototype,`layerFieldsIndex`,void 0),e([n()],M.prototype,`loadAsyncModule`,void 0),e([n()],M.prototype,`addSqlFilter`,void 0),e([n()],M.prototype,`addTimeFilter`,void 0),e([n({readOnly:!0})],M.prototype,`sortedObjectIds`,null),e([n({readOnly:!0})],M.prototype,`parsedWhereClause`,null),e([n({readOnly:!0})],M.prototype,`parsedGeometry`,null),e([n({readOnly:!0})],M.prototype,`_layerMaskGeometries`,null),e([n({readOnly:!0})],M.prototype,`_viewMaskGeometries`,null),e([n()],M.prototype,`updating`,null),e([n()],M.prototype,`_geometryOperators`,void 0),M=e([r(`esri.views.3d.layers.i3s.I3SMeshViewFilter`)],M);const N=(e=>e)([`contains`,`intersects`,`disjoint`]);function P(e){return e!=null&&N.includes(e)}function F(e,t){let n=e??h(t);return g.includes(n)?n:void 0}function I(e,t,n){if(t==null)return null;if(n===`disjoint`&&`rings`in t){let n=t.spatialReference,r=t.rings.map(e=>{let t=x(1/0,1/0,-1/0,-1/0);return S(t,e),new B({rings:[e],spatialReference:n},t)});r.sort((e,t)=>e.aabr[0]-t.aabr[0]);let o=new Set,s=new a;for(let t=0;t<r.length;++t){let{polygon:n,aabr:a}=r[t],c=a[0];o.forEach(t=>{if(c>=t.aabr[2]){o.delete(t);return}if(a[1]>t.aabr[3]||a[3]<t.aabr[1]||!e[2].intersectsExecute(n,t.polygon))return;n.rings=n.rings.concat(t.polygon.rings),C(a,t.aabr,a),o.delete(t);let l=i(r,t,r.length,s);r.splice(l,1)}),o.add(r[t])}return r.map(({polygon:e})=>e)}return[`toJSON`in t?t.toJSON():t]}function L(e,t,n,r,i){if(t.radius>=(t.center[2]+_(r).radius)*.5)return!0;let a=H(e,t,r);return!a||n.every(t=>U(e,t,a,i)!==1)}function R(e,t,n,r,i,a,o,s,c){let l=s[0].spatialReference||a.spatialReference;if(!v(r.node.serviceMbsInIndexSR,o,z,l)){e().warnOnce(`SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter`);return}let u=H(t,z,l);if(!u)return;let d=V(c,a,l,i,r.objectHandle),f=c===`intersects`,p=null;for(let e of s){if(n.length===0)return;switch(U(t,e,u,c)){case 1:f&&(r.weaklyRemovedIds=r.weaklyRemovedIds?.concat(n)??n.slice()),n.length=0;return;case 0:continue}j(n,r.featureIds,n=>K(t,e,n,d)?!0:(f&&(p||=[],p.push(r.featureIds[n])),!1))}p&&(r.weaklyRemovedIds=r.weaklyRemovedIds?.concat(p)??p)}const z=new O;class B{constructor(e,t){this.aabr=t,this.polygon={rings:e.rings,spatialReference:e.spatialReference}}}function V(e,t,n,r,i){let a=t.renderSpatialReference,o=new Map,s={rings:[[[0,0,0],[0,0,0],[0,0,0],[0,0,0]]],spatialReference:n};s.rings[0][3]=s.rings[0][0];let c={indices:null,data:null,stride:0,startIndex:0,endIndex:0},l,u;switch(e){case`intersects`:l=(e,t,n)=>e[2].intersectsExecute(t,n)?0:2,u=W;break;case`contains`:l=(e,t,n)=>e[3].containsExecute(t,n)?2:1,u=W;break;default:l=(e,t,n)=>e[4].disjointExecute(t,n)?2:1,u=G}return{collection:r,object:i,type:e,maskSR:n,renderSR:a,aabbCache:o,triangle:s,positions:c,triangleTest:l,geometryTest:u}}function H(e,t,n){let r={x:t.center[0],y:t.center[1],spatialReference:n},i=!E(n)&&!D(n),a=Number.isNaN(t.radius)?0:l(t.radius,0,T.radius*2);return i?e[1].bufferExecute(r,a):e[0].geodesicBufferExecute(r,a)}function U(e,t,n,r){if(!n)return 0;switch(r){case`intersects`:case`contains`:return W(e,t,n);case`disjoint`:return G(e,t,n)}}function W(e,t,n){return e[2].intersectsExecute(t,n)?e[3].containsExecute(t,n)?0:2:1}function G(e,t,n){return e[2].intersectsExecute(t,n)?e[3].containsExecute(t,n)?1:2:0}function K(e,t,n,r){let{collection:i,object:a,renderSR:c,maskSR:l,geometryTest:u,aabbCache:d}=r,f=d.get(n);if(!f){let e=i.getObjectTransform(a);i.getComponentAabb(a,n,q);let t=[s(q[0],q[1],0),s(q[0],q[4],0),s(q[3],q[4],0),s(q[3],q[1],0)];for(let n=0;n<4;++n)e.applyVec3(t[n],t[n]),y(t[n],c,t[n],l);f={rings:[t],spatialReference:l},f.rings[0][4]=f.rings[0][0],d.set(n,f)}switch(u(e,t,f)){case 1:return!1;case 0:return!0}let{triangle:p,triangleTest:m,positions:h}=r,g=p.rings[0][0],_=p.rings[0][1],v=p.rings[0][2],b=i.getObjectTransform(a);i.getComponentPositions(a,n,h);let{indices:x,data:S,stride:C,startIndex:w,endIndex:T}=h;for(let n=w;n<T;n+=3){let r=C*x[n],i=C*x[n+1],a=C*x[n+2];switch(o(g,S[r],S[r+1],S[r+2]),o(_,S[i],S[i+1],S[i+2]),o(v,S[a],S[a+1],S[a+2]),b.applyVec3(g,g),b.applyVec3(_,_),b.applyVec3(v,v),y(g,c,g,l),y(_,c,_,l),y(v,c,v,l),m(e,t,p)){case 1:return!1;case 0:return!0}}return r.type!==`intersects`}const q=b();export{M as I3SMeshViewFilter};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as t}from"../../../../geometry/support/aaBoundingRect.js";import{Sphere as n}from"../../../../geometry/support/sphere.js";import{sphereIntersectsInfiniteRadialConeConservative as r,sphereIntersectsInfiniteVerticalCylinderConservative as i,finiteVerticalCylinderIntersectsFrustumConservative as a}from"../../support/ElevationAgnosticVisibility.js";import{ElevationRange as o}from"../../support/ElevationRange.js";class s extends o{constructor(e,t){super(NaN,NaN),this.id=e,this.serviceMbsInIndexSR=t,this._serviceMbsInRenderSRElevationAdjusted=new n(0,0,0,-1),this._serviceMbsInRenderSR=new n(0,0,0,-1),this._serviceMbsElevationUpdateExtent=null,this._mbsConeInRenderSR=null}get serviceMbsInRenderSRElevationAdjusted(){return this._serviceMbsInRenderSRElevationAdjusted}updateServiceMbsInRenderSRElevationAdjusted(e){return this._serviceMbsInRenderSRElevationAdjusted.copyFrom(e),this._serviceMbsInRenderSRElevationAdjusted}get serviceMbsInRenderSR(){return this._serviceMbsInRenderSR}updateServiceMbsInRenderSR(e){return this._serviceMbsInRenderSR.copyFrom(e),this._serviceMbsElevationUpdateExtent!=null&&t(this._serviceMbsElevationUpdateExtent),this._serviceMbsInRenderSR}get serviceMbsElevationUpdateExtent(){return this._serviceMbsElevationUpdateExtent??=t()}get mbsConeInRenderSR(){return this._mbsConeInRenderSR}updateMbsConeInRenderSR(e){return this._mbsConeInRenderSR=e.clone(),this._mbsConeInRenderSR}invalidateServiceBVsInRenderSR(){this._serviceMbsInRenderSRElevationAdjusted.invalidate(),this._serviceMbsInRenderSR.invalidate(),this._serviceMbsElevationUpdateExtent!=null&&t(this._serviceMbsElevationUpdateExtent),this._mbsConeInRenderSR=null,this.serviceObbInRenderSR?.invalidate()}shareServiceBVsInRenderSRWith(e){this.serviceObbInRenderSR=e.serviceObbInRenderSR,this._serviceMbsInRenderSRElevationAdjusted=e._serviceMbsInRenderSRElevationAdjusted,this._serviceMbsInRenderSR=e._serviceMbsInRenderSR,this._serviceMbsElevationUpdateExtent=e._serviceMbsElevationUpdateExtent??=t(),this._mbsConeInRenderSR=e._mbsConeInRenderSR}}class c extends s{constructor(e,t,n,r,i,a,o,s,c,l,d){super(e,n),this.index=t,this.childCount=r,this.level=i,this.resources=a,this.version=o,this.lodMetric=s,this.maxError=c,this.numFeatures=l,this.failed=!1,this.cacheState=0,this.vertexCount=0,this.memory=0,this.childrenLoaded=0,this.hasModifications=!1,this.imModificationImpact=4,this.elevationAgnosticBoundingVolume=new u,this.serviceObbInIndexSR=d}invalidateServiceBVsInRenderSR(){super.invalidateServiceBVsInRenderSR(),this.elevationAgnosticBoundingVolume.invalidate()}}class l{constructor(e,t,n,r){this.nodeHasLOD=e,this.isChosen=t,this.lodLevel=n,this.version=r}}class u{constructor(){this._data=[0,0,0,u.invalidRadius]}static{this.invalidRadius=-2}invalidate(){this._data[3]=u.invalidRadius}get valid(){return this._data[3]!==u.invalidRadius}get radius(){return this._data[3]}getAxis(e){return e[0]=this._data[0],e[1]=this._data[1],e[2]=this._data[2],e}set(e,t){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2],this._data[3]=t}intersectsFrustumConservative(e,t,n){if(!this.valid)return!0;let o=this.getAxis(d),{center:s,radius:c}=e.boundingSphere,l=c+n;return t
|
|
2
|
+
import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as t}from"../../../../geometry/support/aaBoundingRect.js";import{Sphere as n}from"../../../../geometry/support/sphere.js";import{sphereIntersectsInfiniteRadialConeConservative as r,sphereIntersectsInfiniteVerticalCylinderConservative as i,finiteVerticalCylinderIntersectsFrustumConservative as a}from"../../support/ElevationAgnosticVisibility.js";import{ElevationRange as o}from"../../support/ElevationRange.js";class s extends o{constructor(e,t){super(NaN,NaN),this.id=e,this.serviceMbsInIndexSR=t,this._serviceMbsInRenderSRElevationAdjusted=new n(0,0,0,-1),this._serviceMbsInRenderSR=new n(0,0,0,-1),this._serviceMbsElevationUpdateExtent=null,this._mbsConeInRenderSR=null}get serviceMbsInRenderSRElevationAdjusted(){return this._serviceMbsInRenderSRElevationAdjusted}updateServiceMbsInRenderSRElevationAdjusted(e){return this._serviceMbsInRenderSRElevationAdjusted.copyFrom(e),this._serviceMbsInRenderSRElevationAdjusted}get serviceMbsInRenderSR(){return this._serviceMbsInRenderSR}updateServiceMbsInRenderSR(e){return this._serviceMbsInRenderSR.copyFrom(e),this._serviceMbsElevationUpdateExtent!=null&&t(this._serviceMbsElevationUpdateExtent),this._serviceMbsInRenderSR}get serviceMbsElevationUpdateExtent(){return this._serviceMbsElevationUpdateExtent??=t()}get mbsConeInRenderSR(){return this._mbsConeInRenderSR}updateMbsConeInRenderSR(e){return this._mbsConeInRenderSR=e.clone(),this._mbsConeInRenderSR}invalidateServiceBVsInRenderSR(){this._serviceMbsInRenderSRElevationAdjusted.invalidate(),this._serviceMbsInRenderSR.invalidate(),this._serviceMbsElevationUpdateExtent!=null&&t(this._serviceMbsElevationUpdateExtent),this._mbsConeInRenderSR=null,this.serviceObbInRenderSR?.invalidate()}shareServiceBVsInRenderSRWith(e){this.serviceObbInRenderSR=e.serviceObbInRenderSR,this._serviceMbsInRenderSRElevationAdjusted=e._serviceMbsInRenderSRElevationAdjusted,this._serviceMbsInRenderSR=e._serviceMbsInRenderSR,this._serviceMbsElevationUpdateExtent=e._serviceMbsElevationUpdateExtent??=t(),this._mbsConeInRenderSR=e._mbsConeInRenderSR}}class c extends s{constructor(e,t,n,r,i,a,o,s,c,l,d){super(e,n),this.index=t,this.childCount=r,this.level=i,this.resources=a,this.version=o,this.lodMetric=s,this.maxError=c,this.numFeatures=l,this.failed=!1,this.cacheState=0,this.vertexCount=0,this.memory=0,this.childrenLoaded=0,this.hasModifications=!1,this.imModificationImpact=4,this.elevationAgnosticBoundingVolume=new u,this.serviceObbInIndexSR=d}invalidateServiceBVsInRenderSR(){super.invalidateServiceBVsInRenderSR(),this.elevationAgnosticBoundingVolume.invalidate()}}class l{constructor(e,t,n,r){this.nodeHasLOD=e,this.isChosen=t,this.lodLevel=n,this.version=r}}class u{constructor(){this._data=[0,0,0,u.invalidRadius]}static{this.invalidRadius=-2}invalidate(){this._data[3]=u.invalidRadius}get valid(){return this._data[3]!==u.invalidRadius}get radius(){return this._data[3]}getAxis(e){return e[0]=this._data[0],e[1]=this._data[1],e[2]=this._data[2],e}set(e,t){this._data[0]=e[0],this._data[1]=e[1],this._data[2]=e[2],this._data[3]=t}intersectsFrustumConservative(e,t,n){if(!this.valid)return!0;let o=this.getAxis(d),{center:s,radius:c}=e.boundingSphere,l=c+n;return t?this.radius>f||r(o,this.radius,s,l):i(o,this.radius,s,l)&&a(o,this.radius,s[2]-l,s[2]+l,e.planes)}}const d=e(),f=.9;export{u as ElevationAgnosticBoundingVolume,c as Node,s as NodeBoundingData,l as NodeTraversalState};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{createTask as a,resultOrAbort as o}from"../../../../core/asyncUtils.js";import s from"../../../../core/Collection.js";import{makeHandle as c}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import l from"../../../../core/Logger.js";import{abortMaybe as u,destroyMaybe as d}from"../../../../core/maybe.js";import{estimateNumberMemory as f,estimateStringMemory as p}from"../../../../core/memoryEstimations.js";import{whenOrAbort as m,throwIfAborted as h}from"../../../../core/promiseUtils.js";import g from"../../../../core/ReactiveSet.js";import{watch as _,sync as v}from"../../../../core/reactiveUtils.js";import{equals as y}from"../../../../geometry/support/spatialReferenceUtils.js";import{formatNumber as b}from"../../../../intl/number.js";import{getMaximumQuerySize as x,queryAllJSON as S}from"../../../../layers/support/featureQueryAll.js";let C=class extends t{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=D,this._definitionExpressionDirty=!0,this._interactiveEditingSessions=new s,this.geometryOverrides=new s,this._clientGeometryCache=new Map,this._attributeChangedObjectIds=new g,this._geometryChangedObjectIds=new g,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._applyGeometryOverridesTask=null,this._featureIdLocks=new Map}initialize(){this._memCache=new T(this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`)),this.addHandles(_(()=>this.layer.definitionExpression,async()=>{this._definitionExpressionDirty=!0,this._pendingFetchChangedObjectIds||(this._applyGeometryOverridesTask=u(this._applyGeometryOverridesTask),this._applyGeometryOverridesTask=a(e=>this._queryAndAddGeometryOverrides(e)),await this._applyGeometryOverridesTask.promise.catch(()=>{}))},v)),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally(()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null}).catch(()=>{})}destroy(){this._set(`layer`,null),this._memCache=d(this._memCache),this._pendingFetchAbortController=u(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._featureIdLocks.clear()}get is3DOFL(){return this._associatedLayer?.infoFor3D!=null}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort((e,t)=>e-t):[]}get _associatedLayer(){return this.layer==null?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get updating(){return this.is3DOFL?!!(this._pendingFetchChangedObjectIds||this._applyGeometryOverridesTask&&!this._applyGeometryOverridesTask.finished):!1}get isEmpty(){return this._pendingFetchChangedObjectIds==null&&this._attributeChangedObjectIds.size===0&&this._geometryChangedObjectIds.size===0}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);let t=this._interactiveEditingSessions,n=new w(e,()=>{t.remove(n)});return t.unshift(n),n}async applyAttributeOverrides(e,t,n,r=[]){if(this._pendingFetchChangedObjectIds&&await m(this._pendingFetchChangedObjectIds,n),t==null)return;let{attributeData:i,loadedAttributes:a}=t;if(a==null||i==null||this._attributeChangedObjectIds.size===0)return;let o=new Set;for(let e of a)o.add(e.index);for(let t of r)o.has(t.index)||(a.push(t),i[t.name]=Array(e.length));let s=await this._lockFeatureIds(e);try{let t={attributeData:i,loadedAttributes:a},{objectIds:r,fieldNames:o}=this._getOverridesFromCache(e,t,this._attributeChangedObjectIds);if(r.length===0||o.length===0)return;let s=await this._queryAttributeOverridesFromAssociatedLayer(r,o,n);if(s==null)return;this._processOverridesFromAssociatedLayer(e,s,o,t)}finally{s.remove()}}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);let n=this._clientGeometryCache.get(e);if(n!=null&&(this.geometryOverrides.remove(n),this._clientGeometryCache.delete(e)),t!=null){let n={oid:e,mesh:t};this.geometryOverrides.add(n),this._clientGeometryCache.set(e,n)}}updateAttributeValue(e,t,n){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,n)}featureAdded(e){this.is3DOFL&&this._geometryChangedObjectIds.add(e),this._attributeChangedObjectIds.add(e)}_cacheAttributeValue(e,t,n){this._memCache.put(e,t,n)}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:n},r){let i=[];for(let e of t)i[e.index]=n[e.name];let a=new Set,o=new Set;for(let n=0;n<e.length;n++){let s=e[n];if(r.has(s))for(let e of t){let t=this._attributeFromCache(s,e.index);t===void 0?(a.add(s),o.add(e.name)):i[e.index][n]=t}}return{objectIds:Array.from(a),fieldNames:Array.from(o)}}_attributeFromCache(e,t){let n=this._fromInteractiveEditingSession(e,t);return n===void 0?this._memCache.get(e,t):n}_fromInteractiveEditingSession(e,t){if(this._interactiveEditingSessions!=null)for(let n of this._interactiveEditingSessions){if(n.objectId!==e)continue;let r=n.getAttribute(t);if(r!==void 0)return r}}async _queryAttributeOverridesFromAssociatedLayer(e,t,n){if(e.length===0)return null;this._logWarningIfMaximumObjectsExceeded();let{associatedLayer:r}=this.layer;if(r==null)return null;let i=r.createQuery(),{objectIdField:a}=r,o=[a,...t];i.where=this.layer.definitionExpression||`1=1`,i.returnGeometry=!1,i.outFields=o,r.capabilities.query.supportsCacheHint&&(i.cacheHint=!0);let s=await this._executeBatchQuery(r,e,i,n),c=[];for(let e of s)if(e.ok)for(let t of e.value.features)c.push(t);return c}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(e.length===0||!this.is3DOFL)return null;let n=this.layer.associatedLayer,r=n.infoFor3D,{spatialReference:i}=n;if(this.view){let{state:{viewingMode:e},spatialReference:t}=this.view,n=e===1,r=i.isGeographic;if(n&&!r)return l.getLogger(this).warn(`unsupported-pcs-edits-in-global-view`,this.layer.title,O(i,t,this.view.viewingMode,0)),null;if(!n&&r)return l.getLogger(this).warn(`unsupported-gcs-edits-in-local-view`,this.layer.title,O(i,t,this.view.viewingMode,0)),null;if(!(y(i,t)||n&&t.isWebMercator&&i.isWGS84))return l.getLogger(this).warn(`unsupported-mismatched-spatial-reference-edits`,this.layer.title,O(i,t,this.view.viewingMode,1)),null}this._logWarningIfMaximumObjectsExceeded();let{objectIdField:a,globalIdField:o}=n,s=[a,...o==null?[]:[o]],c=n.createQuery();c.where=this.layer.definitionExpression||`1=1`,c.returnGeometry=!0,c.outFields=s,c.returnZ=n.hasZ,c.returnM=n.hasM,n.capabilities.query.supportsCacheHint&&(c.cacheHint=!0);let{assetMapFromAssetMapsJSON:u,extractMesh:d}=await import(`../../../../rest/support/meshFeatureSet.js`),f=await this._executeBatchQuery(n,e,c,t),p=[];for(let e of f){if(!e.ok)continue;let{assetMaps:t,features:n,globalIdFieldName:a}=e.value;if(t==null)continue;let o=u(r,t);for(let e of n){let t=d(e,a,i,r,o),n=e;t==null?n.geometry=null:(n.geometry=t,p.push(n))}}return p}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${b(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`,t=this.layer.portalItem;t?.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,l.getLogger(this).warn(`#queryOverrides()`,this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,n,r){if(t.length===0)return[];let a=x(e);t=[...t].sort((e,t)=>e-t);let s=i(t,a).map(t=>{let i=n.clone();return i.objectIds=t,o(S(e,i,{signal:r}))});return Promise.all(s)}_processOverridesFromAssociatedLayer(e,t,n,{loadedAttributes:r,attributeData:i}){let a=this._associatedLayer;if(a==null)return;let o=a.objectIdField,s=n.map(t=>(t in i||(i[t]=Array(e.length)),i[t])),c=new Map(r.map(e=>[e.name,e.index])),l=n.map(e=>c.get(e)),u=new Map(Array.from(e,(e,t)=>[e,t]));for(let e of t){let t=e.attributes[o];for(let r=0;r<n.length;r++){let i=l[r],a=u.get(t),o=e.attributes[n[r]];s[r][a]=o,this._cacheAttributeValue(t,i,o)}}}async _fetchChangedObjectIds(e){let t=this.layer;await t.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();let{associatedLayer:n}=t;if(n==null||(await n.load({signal:e}),!n.capabilities?.operations?.supportsChangeTracking))return;let r=this._getFetchChangedObjectIdsServerGen();if(r==null)return;let i=await this.extractChanges.fetch(n,{serverGen:r,returnGeometryChanges:this.is3DOFL,signal:e});if(h(e),i!=null)for(this._setChangedObjectIds(i);this._definitionExpressionDirty;)await this._queryAndAddGeometryOverrides(e)}_setChangedObjectIds(e){let{attributeChangedObjectIds:t,geometryChangedObjectIds:n}=e,r=Math.min(this._maximumNumberOfEditOVerrides,t.length);r<t.length&&(this._warnMaximumChangedObjectsExceeded=!0);let i=t.sort((e,t)=>e-t);for(let e=0;e<r;++e){let t=i[e];this._attributeChangedObjectIds.add(t)}for(let e of n)this._geometryChangedObjectIds.add(e)}async _queryAndAddGeometryOverrides(e){this._definitionExpressionDirty=!1;let{associatedLayer:t}=this.layer;if(t!=null&&t.capabilities?.operations?.supportsChangeTracking&&this.is3DOFL&&this._geometryChangedObjectIds.size>0){let n=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(n!=null)for(let e of n)e.geometry!=null&&this.updateGeometry(e.attributes[t.objectIdField],e.geometry)}}_getFetchChangedObjectIdsServerGen(){let e=this.layer;if(e.serviceUpdateTimeStamp?.lastUpdate!=null)return e.serviceUpdateTimeStamp.lastUpdate;let t=e.associatedLayer;return t?.serverGens?.minServerGen==null?null:t.serverGens.minServerGen}async _lockFeatureIds(e){let t=this._featureIdLocks,n=!0;for(;n;){let r=[];for(let n of e){let e=t.get(n);e&&r.push(e)}r.length===0?n=!1:await Promise.all(r)}let r=Promise.withResolvers(),i=r.promise;for(let n of e)t.set(n,i);return c(()=>{for(let n of e)t.delete(n);r.resolve()})}get test(){}};e([n({constructOnly:!0})],C.prototype,`view`,void 0),e([n({constructOnly:!0})],C.prototype,`layer`,void 0),e([n({constructOnly:!0})],C.prototype,`extractChanges`,void 0),e([n({readOnly:!0})],C.prototype,`is3DOFL`,null),e([n()],C.prototype,`_interactiveEditingSessions`,void 0),e([n({readOnly:!0})],C.prototype,`sortedGeometryChangedObjectIds`,null),e([n({readOnly:!0})],C.prototype,`geometryOverrides`,void 0),e([n()],C.prototype,`_clientGeometryCache`,void 0),e([n()],C.prototype,`_associatedLayer`,null),e([n({constructOnly:!0})],C.prototype,`memoryController`,void 0),e([n()],C.prototype,`_attributeChangedObjectIds`,void 0),e([n()],C.prototype,`_geometryChangedObjectIds`,void 0),e([n()],C.prototype,`hasGeometryChanges`,null),e([n()],C.prototype,`_pendingFetchChangedObjectIds`,void 0),e([n()],C.prototype,`_pendingFetchAbortController`,void 0),e([n()],C.prototype,`_applyGeometryOverridesTask`,void 0),e([n()],C.prototype,`updating`,null),e([n()],C.prototype,`isEmpty`,null),C=e([r(`esri.views.3d.layers.i3s.I3SOverrides`)],C);class w{constructor(e,t){this.objectId=e,this._remove=t,this._updates=new Map,this._isActive=!0}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}remove(){this.isActive&&(this._isActive=!1,this._remove())}get isActive(){return this._isActive}}class T{constructor(e){this._cache=e}destroy(){this._cache.destroy()}put(e,t,n){this._cache.put(this._getKey(e,t),new E(n))}get(e,t){return this._cache.get(this._getKey(e,t))?.value}_getKey(e,t){return`${e}-${t}`}}class E{constructor(e){this.value=e,this.usedMemory=typeof e==`string`?p(e):f}}const D=5e4;function O(e,t,n,r){return`Displaying the edits of a SceneLayer with a${r===0?e.isGeographic?` geographic `:` projected `:` `}spatial reference (wkid:${e.wkid}) in ${n} viewing mode${r===1?` with spatial reference (wkid:${t.wkid}) `:` `}is not supported. No geometry edits will be displayed for this layer.\nPlease consider re-caching the scene service or changing the ${r===0?`viewing mode`:`view spatial reference`} to display edits.`}export{C as I3SOverrides};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{createTask as a,resultOrAbort as o}from"../../../../core/asyncUtils.js";import s from"../../../../core/Collection.js";import{makeHandle as c}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import l from"../../../../core/Logger.js";import{abortMaybe as u,destroyMaybe as d}from"../../../../core/maybe.js";import{estimateNumberMemory as f,estimateStringMemory as p}from"../../../../core/memoryEstimations.js";import{whenOrAbort as m,throwIfAborted as h}from"../../../../core/promiseUtils.js";import g from"../../../../core/ReactiveSet.js";import{watch as _,sync as v}from"../../../../core/reactiveUtils.js";import{equals as y}from"../../../../geometry/support/spatialReferenceUtils.js";import{formatNumber as b}from"../../../../intl/number.js";import{getMaximumQuerySize as x,queryAllJSON as S}from"../../../../layers/support/featureQueryAll.js";let C=class extends t{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=D,this._definitionExpressionDirty=!0,this._interactiveEditingSessions=new s,this.geometryOverrides=new s,this._clientGeometryCache=new Map,this._attributeChangedObjectIds=new g,this._geometryChangedObjectIds=new g,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._applyGeometryOverridesTask=null,this._featureIdLocks=new Map}initialize(){this._memCache=new T(this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`)),this.addHandles(_(()=>this.layer.definitionExpression,async()=>{this._definitionExpressionDirty=!0,this._pendingFetchChangedObjectIds||(this._applyGeometryOverridesTask=u(this._applyGeometryOverridesTask),this._applyGeometryOverridesTask=a(e=>this._queryAndAddGeometryOverrides(e)),await this._applyGeometryOverridesTask.promise.catch(()=>{}))},v)),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally(()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null}).catch(()=>{})}destroy(){this._set(`layer`,null),this._memCache=d(this._memCache),this._pendingFetchAbortController=u(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._featureIdLocks.clear()}get is3DOFL(){return this._associatedLayer?.infoFor3D!=null}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort((e,t)=>e-t):[]}get _associatedLayer(){return this.layer==null?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get updating(){return this.is3DOFL?!!(this._pendingFetchChangedObjectIds||this._applyGeometryOverridesTask&&!this._applyGeometryOverridesTask.finished):!1}get isEmpty(){return this._pendingFetchChangedObjectIds==null&&this._attributeChangedObjectIds.size===0&&this._geometryChangedObjectIds.size===0}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);let t=this._interactiveEditingSessions,n=new w(e,()=>{t.remove(n)});return t.unshift(n),n}async applyAttributeOverrides(e,t,n,r=[]){if(this._pendingFetchChangedObjectIds&&await m(this._pendingFetchChangedObjectIds,n),t==null)return;let{attributeData:i,loadedAttributes:a}=t;if(a==null||i==null||this._attributeChangedObjectIds.size===0)return;let o=new Set;for(let e of a)o.add(e.index);for(let t of r)o.has(t.index)||(a.push(t),i[t.name]=Array(e.length));let s=await this._lockFeatureIds(e);try{let t={attributeData:i,loadedAttributes:a},{objectIds:r,fieldNames:o}=this._getOverridesFromCache(e,t,this._attributeChangedObjectIds);if(r.length===0||o.length===0)return;let s=await this._queryAttributeOverridesFromAssociatedLayer(r,o,n);if(s==null)return;this._processOverridesFromAssociatedLayer(e,s,o,t)}finally{s.remove()}}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);let n=this._clientGeometryCache.get(e);if(n!=null&&(this.geometryOverrides.remove(n),this._clientGeometryCache.delete(e)),t!=null){let n={oid:e,mesh:t};this.geometryOverrides.add(n),this._clientGeometryCache.set(e,n)}}updateAttributeValue(e,t,n){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,n)}featureAdded(e){this.is3DOFL&&this._geometryChangedObjectIds.add(e),this._attributeChangedObjectIds.add(e)}_cacheAttributeValue(e,t,n){this._memCache.put(e,t,n)}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:n},r){let i=[];for(let e of t)i[e.index]=n[e.name];let a=new Set,o=new Set;for(let n=0;n<e.length;n++){let s=e[n];if(r.has(s))for(let e of t){let t=this._attributeFromCache(s,e.index);t===void 0?(a.add(s),o.add(e.name)):i[e.index][n]=t}}return{objectIds:Array.from(a),fieldNames:Array.from(o)}}_attributeFromCache(e,t){let n=this._fromInteractiveEditingSession(e,t);return n===void 0?this._memCache.get(e,t):n}_fromInteractiveEditingSession(e,t){if(this._interactiveEditingSessions!=null)for(let n of this._interactiveEditingSessions){if(n.objectId!==e)continue;let r=n.getAttribute(t);if(r!==void 0)return r}}async _queryAttributeOverridesFromAssociatedLayer(e,t,n){if(e.length===0)return null;this._logWarningIfMaximumObjectsExceeded();let{associatedLayer:r}=this.layer;if(r==null)return null;let i=r.createQuery(),{objectIdField:a}=r,o=[a,...t];i.where=this.layer.definitionExpression||`1=1`,i.returnGeometry=!1,i.outFields=o,r.capabilities.query.supportsCacheHint&&(i.cacheHint=!0);let s=await this._executeBatchQuery(r,e,i,n),c=[];for(let e of s)if(e.ok)for(let t of e.value.features)c.push(t);return c}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(e.length===0||!this.is3DOFL)return null;let n=this.layer.associatedLayer,r=n.infoFor3D,{spatialReference:i}=n;if(this.view){let{state:{isGlobal:e},spatialReference:t}=this.view,n=i.isGeographic;if(e&&!n)return l.getLogger(this).warn(`unsupported-pcs-edits-in-global-view`,this.layer.title,O(i,t,this.view.viewingMode,0)),null;if(!e&&n)return l.getLogger(this).warn(`unsupported-gcs-edits-in-local-view`,this.layer.title,O(i,t,this.view.viewingMode,0)),null;if(!(y(i,t)||e&&t.isWebMercator&&i.isWGS84))return l.getLogger(this).warn(`unsupported-mismatched-spatial-reference-edits`,this.layer.title,O(i,t,this.view.viewingMode,1)),null}this._logWarningIfMaximumObjectsExceeded();let{objectIdField:a,globalIdField:o}=n,s=[a,...o==null?[]:[o]],c=n.createQuery();c.where=this.layer.definitionExpression||`1=1`,c.returnGeometry=!0,c.outFields=s,c.returnZ=n.hasZ,c.returnM=n.hasM,n.capabilities.query.supportsCacheHint&&(c.cacheHint=!0);let{assetMapFromAssetMapsJSON:u,extractMesh:d}=await import(`../../../../rest/support/meshFeatureSet.js`),f=await this._executeBatchQuery(n,e,c,t),p=[];for(let e of f){if(!e.ok)continue;let{assetMaps:t,features:n,globalIdFieldName:a}=e.value;if(t==null)continue;let o=u(r,t);for(let e of n){let t=d(e,a,i,r,o),n=e;t==null?n.geometry=null:(n.geometry=t,p.push(n))}}return p}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${b(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`,t=this.layer.portalItem;t?.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,l.getLogger(this).warn(`#queryOverrides()`,this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,n,r){if(t.length===0)return[];let a=x(e);t=[...t].sort((e,t)=>e-t);let s=i(t,a).map(t=>{let i=n.clone();return i.objectIds=t,o(S(e,i,{signal:r}))});return Promise.all(s)}_processOverridesFromAssociatedLayer(e,t,n,{loadedAttributes:r,attributeData:i}){let a=this._associatedLayer;if(a==null)return;let o=a.objectIdField,s=n.map(t=>(t in i||(i[t]=Array(e.length)),i[t])),c=new Map(r.map(e=>[e.name,e.index])),l=n.map(e=>c.get(e)),u=new Map(Array.from(e,(e,t)=>[e,t]));for(let e of t){let t=e.attributes[o];for(let r=0;r<n.length;r++){let i=l[r],a=u.get(t),o=e.attributes[n[r]];s[r][a]=o,this._cacheAttributeValue(t,i,o)}}}async _fetchChangedObjectIds(e){let t=this.layer;await t.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();let{associatedLayer:n}=t;if(n==null||(await n.load({signal:e}),!n.capabilities?.operations?.supportsChangeTracking))return;let r=this._getFetchChangedObjectIdsServerGen();if(r==null)return;let i=await this.extractChanges.fetch(n,{serverGen:r,returnGeometryChanges:this.is3DOFL,signal:e});if(h(e),i!=null)for(this._setChangedObjectIds(i);this._definitionExpressionDirty;)await this._queryAndAddGeometryOverrides(e)}_setChangedObjectIds(e){let{attributeChangedObjectIds:t,geometryChangedObjectIds:n}=e,r=Math.min(this._maximumNumberOfEditOVerrides,t.length);r<t.length&&(this._warnMaximumChangedObjectsExceeded=!0);let i=t.sort((e,t)=>e-t);for(let e=0;e<r;++e){let t=i[e];this._attributeChangedObjectIds.add(t)}for(let e of n)this._geometryChangedObjectIds.add(e)}async _queryAndAddGeometryOverrides(e){this._definitionExpressionDirty=!1;let{associatedLayer:t}=this.layer;if(t!=null&&t.capabilities?.operations?.supportsChangeTracking&&this.is3DOFL&&this._geometryChangedObjectIds.size>0){let n=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(n!=null)for(let e of n)e.geometry!=null&&this.updateGeometry(e.attributes[t.objectIdField],e.geometry)}}_getFetchChangedObjectIdsServerGen(){let e=this.layer;if(e.serviceUpdateTimeStamp?.lastUpdate!=null)return e.serviceUpdateTimeStamp.lastUpdate;let t=e.associatedLayer;return t?.serverGens?.minServerGen==null?null:t.serverGens.minServerGen}async _lockFeatureIds(e){let t=this._featureIdLocks,n=!0;for(;n;){let r=[];for(let n of e){let e=t.get(n);e&&r.push(e)}r.length===0?n=!1:await Promise.all(r)}let r=Promise.withResolvers(),i=r.promise;for(let n of e)t.set(n,i);return c(()=>{for(let n of e)t.delete(n);r.resolve()})}get test(){}};e([n({constructOnly:!0})],C.prototype,`view`,void 0),e([n({constructOnly:!0})],C.prototype,`layer`,void 0),e([n({constructOnly:!0})],C.prototype,`extractChanges`,void 0),e([n({readOnly:!0})],C.prototype,`is3DOFL`,null),e([n()],C.prototype,`_interactiveEditingSessions`,void 0),e([n({readOnly:!0})],C.prototype,`sortedGeometryChangedObjectIds`,null),e([n({readOnly:!0})],C.prototype,`geometryOverrides`,void 0),e([n()],C.prototype,`_clientGeometryCache`,void 0),e([n()],C.prototype,`_associatedLayer`,null),e([n({constructOnly:!0})],C.prototype,`memoryController`,void 0),e([n()],C.prototype,`_attributeChangedObjectIds`,void 0),e([n()],C.prototype,`_geometryChangedObjectIds`,void 0),e([n()],C.prototype,`hasGeometryChanges`,null),e([n()],C.prototype,`_pendingFetchChangedObjectIds`,void 0),e([n()],C.prototype,`_pendingFetchAbortController`,void 0),e([n()],C.prototype,`_applyGeometryOverridesTask`,void 0),e([n()],C.prototype,`updating`,null),e([n()],C.prototype,`isEmpty`,null),C=e([r(`esri.views.3d.layers.i3s.I3SOverrides`)],C);class w{constructor(e,t){this.objectId=e,this._remove=t,this._updates=new Map,this._isActive=!0}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}remove(){this.isActive&&(this._isActive=!1,this._remove())}get isActive(){return this._isActive}}class T{constructor(e){this._cache=e}destroy(){this._cache.destroy()}put(e,t,n){this._cache.put(this._getKey(e,t),new E(n))}get(e,t){return this._cache.get(this._getKey(e,t))?.value}_getKey(e,t){return`${e}-${t}`}}class E{constructor(e){this.value=e,this.usedMemory=typeof e==`string`?p(e):f}}const D=5e4;function O(e,t,n,r){return`Displaying the edits of a SceneLayer with a${r===0?e.isGeographic?` geographic `:` projected `:` `}spatial reference (wkid:${e.wkid}) in ${n} viewing mode${r===1?` with spatial reference (wkid:${t.wkid}) `:` `}is not supported. No geometry edits will be displayed for this layer.\nPlease consider re-caching the scene service or changing the ${r===0?`viewing mode`:`view spatial reference`} to display edits.`}export{C as I3SOverrides};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import"../../../../core/has.js";import{normalize as e,add as t,scale as n,length as r,set as i,equals as a,subtract as o,dot as s,len as c,sqrDist as l,copy as u,sub as d,scaleAndAdd as f,distance as p,squaredLength as m,squaredDistance as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import v from"../../../../geometry/Point.js";import{projectBoundingRect as y}from"../../../../geometry/projection/projectBoundingRect.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as ee}from"../../../../geometry/projection/projectors.js";import te from"../../../../geometry/SpatialReference.js";import{getSphericalPCPF as x}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{create as ne,fromValues as S}from"../../../../geometry/support/aaBoundingRect.js";import{create as C,fromPoints as re,distance2 as ie}from"../../../../geometry/support/lineSegment.js";import{signedDistance as w,getNormal as T}from"../../../../geometry/support/plane.js";import{isPlateCarree as E,webMercatorValid as D}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as O}from"../../../../geometry/support/sphere.js";import{Frustum as ae}from"../../state/Frustum.js";import{groundNavigationConstants as oe}from"../../state/utils/groundNavigationUtils.js";import"../../support/elevationUpdateExtentUtils.js";import{Obb as k,computeOffsetObb as se}from"../../support/orientedBoundingBox.js";import{SweptSphereCylindricalVolume as ce,SphereGlobal as le,SweptSphereConicalVolume as ue}from"../../support/SweptSphereVolume.js";import{evaluateElevationAlignmentAtPoint as de}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as fe}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as pe,extractExpressionInfo as me}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as A}from"./I3SUtil.js";import{sphereToGeographicExtent as j,intersectsGeographicExtent as M}from"../../support/sphereExtentUtils.js";const N=1e5;class P{get _frustumPlanes(){return this._frustum.planes}constructor(e,t,n,r,i,a,o,s,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=i,this._elevationProvider=a,this._viewingMode=o,this._options=c,this._viewDirection=g(),this._useFrustumCulling=!1,this._poi=g(),this._cameraPOIDirection=g(),this._elevationContext=null,this._checkBelowSegmentEnd=g(),this.minCenterDistance=1/0,this.maxCenterDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this._frustum=new ae(t),this.updateCamera(n,r);let l=this._renderCoordsHelper.spatialReference;this._renderSR=l,this._renderSRSphericalPCPF=x(l),this._isGlobalMode=this._viewingMode===1,this.elevationIntersectionSpatialReference=this._isGlobalMode?this._indexSR.isWebMercator?this._indexSR:this._elevationProvider.spatialReference:l,this.updateElevationInfo(s),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(l.isWebMercator||E(l)),this._indexSREllipsoidRadius=_(this._indexSR).radius,this._indexSRSphericalPCPF=x(e),this._projectorIndexSRToIndexSRSphericalPCPF=ee(this._indexSR,this._indexSRSphericalPCPF),this._groundNavigationCheckDistance=oe.i3sNodeDownwardCheckDistanceInMeters/this._renderCoordsHelper.unitInMeters}updateElevationInfo(e){e==null?this._elevationContext=null:(this._elevationContext=fe.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(pe(me(e,!1))))}updateCamera(r,i){this._useFrustumCulling=i,e(this._viewDirection,r.viewForward),i&&this._frustum.update(r),this._halfScreenPixelSizePerDistance=r.screenPixelSizePerDistance/2,this._camPos=r.eye,this._updateCameraPOIDirection(),this.minCenterDistance=1/0,this.maxCenterDistance=0,t(this._checkBelowSegmentEnd,this._camPos,n(this._checkBelowSegmentEnd,this._renderCoordsHelper.worldUpAtPosition(this._camPos,this._checkBelowSegmentEnd),-this._groundNavigationCheckDistance))}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){let t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,n){if(this._elevationContext==null)return;let r=e.serviceMbsInIndexSR;if(!r)return;let i=this._elevationContext.mode===`relative-to-scene`?`scene`:`ground`,a=this._elevationProvider;if(a.getSphereElevationRange){let e=a.getSphereElevationRange(r,this._indexSR,i);if(e){n.expandElevationRange(e);return}}let[o,s,c]=r.center,l=a.getElevation(o,s,c,this._indexSR,i);l&&n.expandElevationRangeValues(l,l);let u=t?null:a.getRootElevationRange?.();u&&n.expandElevationRange(u)}calculateServiceMbsInRenderSR(e){let{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e;if(!n?.isValid)return t;let r=G;return b(n,this._indexSR,r,this._renderSR),e.updateServiceMbsInRenderSR(r)}intersectsElevationUpdate(e,t){if(this._isGlobalMode&&this._indexSR.isWebMercator){let n=t.serviceMbsInIndexSR;if(!n?.isValid)return!0;let[r,i]=D,a=i-r,o=e[2]-e[0]>=a,s=o?0:Math.round((n.center[0]-(e[0]+e[2])/2)/a)*a;return S(o?-1/0:e[0]+s,e[1],o?1/0:e[2]+s,e[3],K),A(K,n)!==0}let n=this.calculateServiceMbsInRenderSR(t);if(!n.isValid)return!0;if(!this._isGlobalMode)return A(e,n)!==0;let r=t.serviceMbsElevationUpdateExtent;return r[0]>r[2]&&(j(n,r),this.elevationIntersectionSpatialReference.isWebMercator&&Number.isFinite(r[0])&&(r[1]=Math.max(-90,r[1]),r[3]=Math.min(90,r[3]),y(r,te.WGS84,r,this.elevationIntersectionSpatialReference)||S(-1/0,-1/0,1/0,1/0,r))),M(e,r,this.elevationIntersectionSpatialReference)}_evaluateElevationAlignmentInIndexSR(e,t){return V.x=e[0],V.y=e[1],V.z=e[2],V.spatialReference=this._indexSR,de(V,this._elevationProvider,t,this._renderCoordsHelper)}calculateServiceMbsInRenderSRElevationAdjusted(e){let{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e,r=this.calculateServiceMbsInRenderSR(e);if(!r.isValid||!n?.isValid)return t;let i=G;i.copyFrom(r);let{_elevationContext:a}=this;if(a){let{minElevation:t}=e,{_renderCoordsHelper:r}=this,o=n.center,s=0;if(Number.isFinite(t)){let n=0,c=0,{maxElevation:l}=e,u=o[2];switch(a.mode){case`relative-to-ground`:case`relative-to-scene`:n=a.geometryZWithOffset(u,r)+t-u,c=l-t;break;case`on-the-ground`:n=t-u,c=l-t}s=n+.5*c,i.radius+=.5*c}else i.radius<N&&(s=this._evaluateElevationAlignmentInIndexSR(o,a)-o[2]);s&&ye(i,s,this._viewingMode)}return e.updateServiceMbsInRenderSRElevationAdjusted(i)}_isGlobalMbsContainingPlanetCenter(e){return this._viewingMode===1&&r(e.center)<=e.radius}calculateMbsConeInRenderSR(e){let{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;let{minElevation:n,maxElevation:r}=e;if(!Number.isFinite(n)||!(n<r))return null;let i=this.calculateServiceMbsInRenderSR(e);if(!i.isValid)return null;let a=this._elevationContext;if(a?.mode===`relative-to-ground`||a?.mode===`relative-to-scene`){let t=e.serviceMbsInIndexSR;if(!t?.isValid)return null;let i=t.center[2],o=a.geometryZWithOffset(i,this._renderCoordsHelper);if(this._viewingMode===2)n+=o,r+=o;else{let e=o-i;n+=e,r+=e}}let o=this._renderCoordsHelper.referenceEllipsoid.radius,s=this._viewingMode===2?new ce(i,n,r):this._isGlobalMbsContainingPlanetCenter(i)?new le(i,o+n,o+r):new ue(i,o+n,o+r);return e.updateMbsConeInRenderSR(s)}getAndUpdateVisibilityObbInRenderSR(e){{let t=e.visibilityObbInRenderSR;if(t)return t}let t=this._indexSREllipsoidRadius*.01,{serviceMbsInIndexSR:n,serviceObbInIndexSR:r}=e;if(r==null||!n||!r.isValid||this._isECEFOBBInLocalMode&&(r.halfSizeX>t||r.halfSizeY>t||r.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(t==null)t=new k,e.serviceObbInRenderSR=t;else if(t.isValid)return t;let a=n.radius,o=0,s=0,c=r.centerZ,l=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){let{minElevation:t,maxElevation:n}=e;switch(u.mode){case`relative-to-ground`:case`relative-to-scene`:o=u.geometryZWithOffset(c,l)+t-c,s=n-t;break;case`on-the-ground`:o=t-c,s=n-t}}else if(u&&a<N){let e=i(B,r.centerX,r.centerY,c);o=this._evaluateElevationAlignmentInIndexSR(e,u)-c}let d=s>0,f=d?z:t;return r.transform(f,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&se(f,0,s,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{let t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}let t=e.serviceObbInIndexSR;return t?this._viewingMode===2&&Math.max(t.halfSizeX,t.halfSizeY,t.halfSizeZ)>.2*this._indexSREllipsoidRadius?null:(t.transform(z,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),z):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(this._viewingMode===1?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){a(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(o(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){let n=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),r=t.elevationAgnosticBoundingVolume,i=-1,a;if(n){let t=B;n.getCenter(t),e(t,t),a=t,n.getCorners(H);for(let n of H){e(n,n);let a=s(n,t);if(a<=0){r.invalidate();return}let o=Math.sqrt(Math.max(0,1-a*a));i=Math.max(i,o)}}else{let n=t.serviceMbsInRenderSR;if(!n.isValid){r.invalidate();return}let{center:o,radius:s}=n,l=c(o);if(l<s){r.invalidate();return}i=s/l,a=e(W,o)}r.set(a,i+we)}_updateElevationAgnosticBoundingVolumeLocal(e){let t=e.elevationAgnosticBoundingVolume,n=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(n){let e=n.getCenter(B);e[2]=0;let r=0;n.getCorners(H);for(let t of H){t[2]=0;let n=l(e,t);r=Math.max(r,n)}t.set(e,Math.sqrt(r))}else{let n=e.serviceMbsInRenderSR;if(n.isValid){let e=u(B,n.center);e[2]=0,t.set(e,n.radius)}}}isNodeVisible(e,t=!1){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling||t&&this.isNodeCloseBelowCamera(e))return!0;let n=this.getAndUpdateVisibilityObbInRenderSR(e);return n?n.intersectsFrustumConservativeApproximation(this._frustumPlanes):this._frustum.intersectsSphere(this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isNodeCloseBelowCamera(e){let t=this.getAndUpdateVisibilityObbInRenderSR(e);if(t?.isValid)return t.intersectSegment(this._camPos,this._checkBelowSegmentEnd);let n=this.calculateServiceMbsInRenderSRElevationAdjusted(e);if(!n.isValid)return!0;let r=re(this._camPos,this._checkBelowSegmentEnd,ge);return ie(r,n.center)<=n.radius**2}isElevationAgnosticBoundingVolumeVisible(e,t){return!this._useFrustumCulling||!e.valid?!0:e.intersectsFrustumConservative(this._frustum,this._viewingMode,1+t)?this._viewingMode!==1||this._isConeVisibleInFrustum(e):!1}_isConeVisibleInFrustum(t){let r=t.radius;if(r>Se)return!0;let i=this._frustumPlanes,{center:a,radius:o}=this._frustum.boundingSphere,c=t.getAxis(W),l=s(c,a),u=o+1,p=l-u,m=l+u;if(p<=0)return!0;let h=n(I,c,p),g=n(L,c,m),_=r/Math.sqrt(1-r*r);for(let t of i){let r=T(t),i=e(R,r),a=s(i,c);if(Math.abs(1-a)<Ce)continue;let o=_e;n(o,c,a),d(o,o,i),e(o,o);let l=ve;if(f(l,h,o,p*_),!(w(t,l)<=0)&&(f(l,g,o,m*_),!(w(t,l)<=0)))return!1}return!0}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling||!e.valid)return!0;let{center:r,radius:i}=this._frustum.boundingSphere,a=i+1,o=this._frustumPlanes,c=H;if(t.getCorners(c),this._viewingMode===1){let t=e.getAxis(W),i=s(t,r),l=i-a,u=i+a;if(l<=0)return!0;for(let e of o){let r=!0;for(let i of c){let a=s(i,t),o=U;if(n(o,i,l/a),w(e,o)<=0){r=!1;break}let c=U;if(n(c,i,u/a),w(e,c)<=0){r=!1;break}}if(r)return!1}}else{let e=r[2]-a,t=r[2]+a;for(let n of o){let r=!0,i=T(n),a=i[0],o=i[1],s=i[2],l=n[3];for(let n of c){let i=a*n[0]+o*n[1]+l;if(i+s*e<=0||i+s*t<=0){r=!1;break}}if(r)return!1}}return!0}isGeometryVisible(e,t){if(!this._useFrustumCulling)return!0;let n=e.geometryObbInRenderSR;return!n?.isValid||n.intersectsFrustumConservativeApproximation(this._frustumPlanes)||t&&n.intersectSegment(this._camPos,this._checkBelowSegmentEnd)}_isMBSinClippingArea(e){return this._clippingArea==null||A(this._clippingArea,e)!==0}_screenSpaceDiameterMbs(e,t){let n=this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e);return n<0?be:t/n/this._halfScreenPixelSizePerDistance}calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e){let t=this.calculateMbsConeInRenderSR(e);if(t==null)return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e);let n=t.calculateSurfaceDistanceFromPoint(this._camPos),r=t.calculateCenterDistanceFromPoint(this._camPos);return this._updateMinMaxDistanceToCenter(r),n}calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=p(t.center,this._camPos);return this._updateMinMaxDistanceToCenter(n),n}_calculateAngleDependentLoDForSphere(e,t){let n=d(he,e,this._camPos),i=r(e),a=r(n);if(i===0||a===0)return 1;let o=(Math.abs(s(e,n))/i+t)/a;return Math.min(1,o)}calcAngleDependentLoD(e){let t=this.calculateMbsConeInRenderSR(e);if(t==null){let{center:t,radius:n}=this.calculateServiceMbsInRenderSRElevationAdjusted(e);return this._calculateAngleDependentLoDForSphere(t,n)}let{center:i,radius:a}=this.calculateServiceMbsInRenderSR(e);if(this._viewingMode===2)u(q,i),q[2]=t.lowerCenterHeight,u(J,i),J[2]=t.upperCenterHeight;else{let e=r(i);if(e===0)return 1;n(q,i,t.lowerCenterHeight/e),n(J,i,t.upperCenterHeight/e)}let o=this._calculateAngleDependentLoDForSphere(q,a),c=this._calculateAngleDependentLoDForSphere(J,a);if(this._viewingMode===2)u(Y,i),Y[2]=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,this._camPos[2]));else{let e=r(i);if(e===0)return Math.max(o,c);let a=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,s(this._camPos,i)/e));n(Y,i,a/e)}return Math.max(o,c,this._calculateAngleDependentLoDForSphere(Y,a))}hasLOD(e){return e.lodMetric!==0}_getDistanceToSurfaceGlobeMode(e,i){let a=r(i.center),c=r(e)-a;n(q,e,s(e,i.center)/m(e));let l=h(i.center,q),u=i.radius;if(l<=u*u)return Math.abs(c);let d=n(q,i.center,1/a),f=u*u/(2*a),g=n(J,d,a-f),_=o(Y,e,g),v=o(Y,_,n(X,d,s(d,_))),y=t(Y,g,n(Y,v,u/r(v))),b=p(e,y);if(c>=Z){let t=o(J,e,y),n=s(t,d)/r(t);n<Q&&(n=$),b/=n}return b}_getDistanceToSurface(e,t){return this._isGlobalMode?this._getDistanceToSurfaceGlobeMode(e,t):F(e,t)}_applyGlobalFlatAngleCorrectionToConeDistance(e,t){t.calculateClosestCenterToPoint(this._camPos,X);let n=r(X);if(n===0||r(this._camPos)-n<Z)return e;let i=o(Y,this._camPos,X),a=r(i);if(a===0)return e;let c=s(i,X)/(a*n);return e/(c<Q?$:c)}calculateScreenSpaceRelativeSphere(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=this._getDistanceToSurface(this._camPos,t),r=n+t.radius;return this._updateMinMaxDistanceToCenter(r),2*n*this._halfScreenPixelSizePerDistance}calculateScreenSpaceRelativeCone(e){let t=e.calculateCenterDistanceFromPoint(this._camPos);this._updateMinMaxDistanceToCenter(t);let n=e.calculateSurfaceDistanceFromPoint(this._camPos);return 2*(this._isGlobalMode?this._applyGlobalFlatAngleCorrectionToConeDistance(n,e):n)*this._halfScreenPixelSizePerDistance}_updateMinMaxDistanceToCenter(e){e>0?(this.minCenterDistance=Math.min(this.minCenterDistance,e),this.maxCenterDistance=Math.max(this.maxCenterDistance,e)):(this.minCenterDistance=0,this.maxCenterDistance=Math.max(this.maxCenterDistance,-e))}getLodLevel(e){if(e.lodMetric===0)return 0;if(e.childCount===0)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){let t=this._progressiveLoadFactor*this._screenspaceErrorBias,n=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,n)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let n=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(n*=this.calcAngleDependentLoD(e)),n<e.maxError}case 2:{let n=this.calculateMbsConeInRenderSR(e),r=n?this.calculateScreenSpaceRelativeCone(n):this.calculateScreenSpaceRelativeSphere(e);return e.maxError*t<=r}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<xe;case 4:return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(e==null)return 0;let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=t.center,r=s(n,this._cameraPOIDirection),i=r*r,a=m(n)-i;return Math.sqrt(a)-t.radius}distCameraToPOI(){return p(this._camPos,this._poi)}}function F(e,t){let n=e[0]-t.center[0],r=e[1]-t.center[1],i=e[2]-t.center[2],a=n*n+r*r,o=t.radius;if(a<=o*o)return Math.abs(i);let s=Math.sqrt(a)-o;return Math.sqrt(i*i+s*s)}const I=g(),L=g(),R=g(),z=new k,B=g(),V=new v,H=[g(),g(),g(),g(),g(),g(),g(),g()],he=g(),ge=C(),_e=g(),ve=g(),U=g(),W=g(),G=new O,K=ne(),q=g(),J=g(),Y=g(),X=g();function ye(e,t,i){if(i===2)e.center[2]+=t;else{let i=r(e.center);if(i===0){e.radius+=Math.abs(t);return}n(e.center,e.center,1+t/i)}}const be=.5*Number.MAX_VALUE,xe=10,Z=2e5,Q=.08,$=1e-4,Se=.9,Ce=.01,we=.001;export{P as default};
|
|
2
|
+
import"../../../../core/has.js";import{normalize as e,add as t,scale as n,length as r,set as i,equals as a,subtract as o,dot as s,len as c,sqrDist as l,copy as u,sub as d,scaleAndAdd as f,distance as p,squaredLength as m,squaredDistance as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import v from"../../../../geometry/Point.js";import{projectBoundingRect as y}from"../../../../geometry/projection/projectBoundingRect.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as ee}from"../../../../geometry/projection/projectors.js";import te from"../../../../geometry/SpatialReference.js";import{getSphericalPCPF as x}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{create as ne,fromValues as S}from"../../../../geometry/support/aaBoundingRect.js";import{create as C,fromPoints as re,distance2 as ie}from"../../../../geometry/support/lineSegment.js";import{signedDistance as w,getNormal as T}from"../../../../geometry/support/plane.js";import{isPlateCarree as E,webMercatorValid as D}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as O}from"../../../../geometry/support/sphere.js";import{Frustum as ae}from"../../state/Frustum.js";import{groundNavigationConstants as oe}from"../../state/utils/groundNavigationUtils.js";import"../../support/elevationUpdateExtentUtils.js";import{Obb as k,computeOffsetObb as se}from"../../support/orientedBoundingBox.js";import{SphereGlobal as ce,SweptSphereConicalVolume as le,SweptSphereCylindricalVolume as ue}from"../../support/SweptSphereVolume.js";import{evaluateElevationAlignmentAtPoint as de}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as fe}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as pe,extractExpressionInfo as me}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as A}from"./I3SUtil.js";import{sphereToGeographicExtent as j,intersectsGeographicExtent as M}from"../../support/sphereExtentUtils.js";const N=1e5;class P{get _frustumPlanes(){return this._frustum.planes}constructor(e,t,n,r,i,a,o,s,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=i,this._elevationProvider=a,this._isGlobal=o,this._options=c,this._viewDirection=g(),this._useFrustumCulling=!1,this._poi=g(),this._cameraPOIDirection=g(),this._elevationContext=null,this._checkBelowSegmentEnd=g(),this.minCenterDistance=1/0,this.maxCenterDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this._frustum=new ae(t),this.updateCamera(n,r);let l=this._renderCoordsHelper.spatialReference;this._renderSR=l,this._renderSRSphericalPCPF=x(l),this.elevationIntersectionSpatialReference=this._isGlobal?this._indexSR.isWebMercator?this._indexSR:this._elevationProvider.spatialReference:l,this.updateElevationInfo(s),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(l.isWebMercator||E(l)),this._indexSREllipsoidRadius=_(this._indexSR).radius,this._indexSRSphericalPCPF=x(e),this._projectorIndexSRToIndexSRSphericalPCPF=ee(this._indexSR,this._indexSRSphericalPCPF),this._groundNavigationCheckDistance=oe.i3sNodeDownwardCheckDistanceInMeters/this._renderCoordsHelper.unitInMeters}updateElevationInfo(e){e==null?this._elevationContext=null:(this._elevationContext=fe.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(pe(me(e,!1))))}updateCamera(r,i){this._useFrustumCulling=i,e(this._viewDirection,r.viewForward),i&&this._frustum.update(r),this._halfScreenPixelSizePerDistance=r.screenPixelSizePerDistance/2,this._camPos=r.eye,this._updateCameraPOIDirection(),this.minCenterDistance=1/0,this.maxCenterDistance=0,t(this._checkBelowSegmentEnd,this._camPos,n(this._checkBelowSegmentEnd,this._renderCoordsHelper.worldUpAtPosition(this._camPos,this._checkBelowSegmentEnd),-this._groundNavigationCheckDistance))}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){let t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,n){if(this._elevationContext==null)return;let r=e.serviceMbsInIndexSR;if(!r)return;let i=this._elevationContext.mode===`relative-to-scene`?`scene`:`ground`,a=this._elevationProvider;if(a.getSphereElevationRange){let e=a.getSphereElevationRange(r,this._indexSR,i);if(e){n.expandElevationRange(e);return}}let[o,s,c]=r.center,l=a.getElevation(o,s,c,this._indexSR,i);l&&n.expandElevationRangeValues(l,l);let u=t?null:a.getRootElevationRange?.();u&&n.expandElevationRange(u)}calculateServiceMbsInRenderSR(e){let{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e;if(!n?.isValid)return t;let r=G;return b(n,this._indexSR,r,this._renderSR),e.updateServiceMbsInRenderSR(r)}intersectsElevationUpdate(e,t){if(this._isGlobal&&this._indexSR.isWebMercator){let n=t.serviceMbsInIndexSR;if(!n?.isValid)return!0;let[r,i]=D,a=i-r,o=e[2]-e[0]>=a,s=o?0:Math.round((n.center[0]-(e[0]+e[2])/2)/a)*a;return S(o?-1/0:e[0]+s,e[1],o?1/0:e[2]+s,e[3],K),A(K,n)!==0}let n=this.calculateServiceMbsInRenderSR(t);if(!n.isValid)return!0;if(!this._isGlobal)return A(e,n)!==0;let r=t.serviceMbsElevationUpdateExtent;return r[0]>r[2]&&(j(n,r),this.elevationIntersectionSpatialReference.isWebMercator&&Number.isFinite(r[0])&&(r[1]=Math.max(-90,r[1]),r[3]=Math.min(90,r[3]),y(r,te.WGS84,r,this.elevationIntersectionSpatialReference)||S(-1/0,-1/0,1/0,1/0,r))),M(e,r,this.elevationIntersectionSpatialReference)}_evaluateElevationAlignmentInIndexSR(e,t){return V.x=e[0],V.y=e[1],V.z=e[2],V.spatialReference=this._indexSR,de(V,this._elevationProvider,t,this._renderCoordsHelper)}calculateServiceMbsInRenderSRElevationAdjusted(e){let{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e,r=this.calculateServiceMbsInRenderSR(e);if(!r.isValid||!n?.isValid)return t;let i=G;i.copyFrom(r);let{_elevationContext:a}=this;if(a){let{minElevation:t}=e,{_renderCoordsHelper:r}=this,o=n.center,s=0;if(Number.isFinite(t)){let n=0,c=0,{maxElevation:l}=e,u=o[2];switch(a.mode){case`relative-to-ground`:case`relative-to-scene`:n=a.geometryZWithOffset(u,r)+t-u,c=l-t;break;case`on-the-ground`:n=t-u,c=l-t}s=n+.5*c,i.radius+=.5*c}else i.radius<N&&(s=this._evaluateElevationAlignmentInIndexSR(o,a)-o[2]);s&&ye(i,s,this._isGlobal)}return e.updateServiceMbsInRenderSRElevationAdjusted(i)}_isGlobalMbsContainingPlanetCenter(e){return this._isGlobal&&r(e.center)<=e.radius}calculateMbsConeInRenderSR(e){let{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;let{minElevation:n,maxElevation:r}=e;if(!Number.isFinite(n)||!(n<r))return null;let i=this.calculateServiceMbsInRenderSR(e);if(!i.isValid)return null;let a=this._elevationContext;if(a?.mode===`relative-to-ground`||a?.mode===`relative-to-scene`){let t=e.serviceMbsInIndexSR;if(!t?.isValid)return null;let i=t.center[2],o=a.geometryZWithOffset(i,this._renderCoordsHelper);if(this._isGlobal){let e=o-i;n+=e,r+=e}else n+=o,r+=o}let o=this._renderCoordsHelper.referenceEllipsoid.radius,s=this._isGlobal?this._isGlobalMbsContainingPlanetCenter(i)?new ce(i,o+n,o+r):new le(i,o+n,o+r):new ue(i,n,r);return e.updateMbsConeInRenderSR(s)}getAndUpdateVisibilityObbInRenderSR(e){{let t=e.visibilityObbInRenderSR;if(t)return t}let t=this._indexSREllipsoidRadius*.01,{serviceMbsInIndexSR:n,serviceObbInIndexSR:r}=e;if(r==null||!n||!r.isValid||this._isECEFOBBInLocalMode&&(r.halfSizeX>t||r.halfSizeY>t||r.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(t==null)t=new k,e.serviceObbInRenderSR=t;else if(t.isValid)return t;let a=n.radius,o=0,s=0,c=r.centerZ,l=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){let{minElevation:t,maxElevation:n}=e;switch(u.mode){case`relative-to-ground`:case`relative-to-scene`:o=u.geometryZWithOffset(c,l)+t-c,s=n-t;break;case`on-the-ground`:o=t-c,s=n-t}}else if(u&&a<N){let e=i(B,r.centerX,r.centerY,c);o=this._evaluateElevationAlignmentInIndexSR(e,u)-c}let d=s>0,f=d?z:t;return r.transform(f,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&se(f,0,s,this._isGlobal,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{let t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}let t=e.serviceObbInIndexSR;return t?!this._isGlobal&&Math.max(t.halfSizeX,t.halfSizeY,t.halfSizeZ)>.2*this._indexSREllipsoidRadius?null:(t.transform(z,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),z):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(this._isGlobal?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){a(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(o(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){let n=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),r=t.elevationAgnosticBoundingVolume,i=-1,a;if(n){let t=B;n.getCenter(t),e(t,t),a=t,n.getCorners(H);for(let n of H){e(n,n);let a=s(n,t);if(a<=0){r.invalidate();return}let o=Math.sqrt(Math.max(0,1-a*a));i=Math.max(i,o)}}else{let n=t.serviceMbsInRenderSR;if(!n.isValid){r.invalidate();return}let{center:o,radius:s}=n,l=c(o);if(l<s){r.invalidate();return}i=s/l,a=e(W,o)}r.set(a,i+we)}_updateElevationAgnosticBoundingVolumeLocal(e){let t=e.elevationAgnosticBoundingVolume,n=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(n){let e=n.getCenter(B);e[2]=0;let r=0;n.getCorners(H);for(let t of H){t[2]=0;let n=l(e,t);r=Math.max(r,n)}t.set(e,Math.sqrt(r))}else{let n=e.serviceMbsInRenderSR;if(n.isValid){let e=u(B,n.center);e[2]=0,t.set(e,n.radius)}}}isNodeVisible(e,t=!1){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling||t&&this.isNodeCloseBelowCamera(e))return!0;let n=this.getAndUpdateVisibilityObbInRenderSR(e);return n?n.intersectsFrustumConservativeApproximation(this._frustumPlanes):this._frustum.intersectsSphere(this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isNodeCloseBelowCamera(e){let t=this.getAndUpdateVisibilityObbInRenderSR(e);if(t?.isValid)return t.intersectSegment(this._camPos,this._checkBelowSegmentEnd);let n=this.calculateServiceMbsInRenderSRElevationAdjusted(e);if(!n.isValid)return!0;let r=re(this._camPos,this._checkBelowSegmentEnd,ge);return ie(r,n.center)<=n.radius**2}isElevationAgnosticBoundingVolumeVisible(e,t){return!this._useFrustumCulling||!e.valid?!0:e.intersectsFrustumConservative(this._frustum,this._isGlobal,1+t)?!this._isGlobal||this._isConeVisibleInFrustum(e):!1}_isConeVisibleInFrustum(t){let r=t.radius;if(r>Se)return!0;let i=this._frustumPlanes,{center:a,radius:o}=this._frustum.boundingSphere,c=t.getAxis(W),l=s(c,a),u=o+1,p=l-u,m=l+u;if(p<=0)return!0;let h=n(I,c,p),g=n(L,c,m),_=r/Math.sqrt(1-r*r);for(let t of i){let r=T(t),i=e(R,r),a=s(i,c);if(Math.abs(1-a)<Ce)continue;let o=_e;n(o,c,a),d(o,o,i),e(o,o);let l=ve;if(f(l,h,o,p*_),!(w(t,l)<=0)&&(f(l,g,o,m*_),!(w(t,l)<=0)))return!1}return!0}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling||!e.valid)return!0;let{center:r,radius:i}=this._frustum.boundingSphere,a=i+1,o=this._frustumPlanes,c=H;if(t.getCorners(c),this._isGlobal){let t=e.getAxis(W),i=s(t,r),l=i-a,u=i+a;if(l<=0)return!0;for(let e of o){let r=!0;for(let i of c){let a=s(i,t),o=U;if(n(o,i,l/a),w(e,o)<=0){r=!1;break}let c=U;if(n(c,i,u/a),w(e,c)<=0){r=!1;break}}if(r)return!1}}else{let e=r[2]-a,t=r[2]+a;for(let n of o){let r=!0,i=T(n),a=i[0],o=i[1],s=i[2],l=n[3];for(let n of c){let i=a*n[0]+o*n[1]+l;if(i+s*e<=0||i+s*t<=0){r=!1;break}}if(r)return!1}}return!0}isGeometryVisible(e,t){if(!this._useFrustumCulling)return!0;let n=e.geometryObbInRenderSR;return!n?.isValid||n.intersectsFrustumConservativeApproximation(this._frustumPlanes)||t&&n.intersectSegment(this._camPos,this._checkBelowSegmentEnd)}_isMBSinClippingArea(e){return this._clippingArea==null||A(this._clippingArea,e)!==0}_screenSpaceDiameterMbs(e,t){let n=this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e);return n<0?be:t/n/this._halfScreenPixelSizePerDistance}calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e){let t=this.calculateMbsConeInRenderSR(e);if(t==null)return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e);let n=t.calculateSurfaceDistanceFromPoint(this._camPos),r=t.calculateCenterDistanceFromPoint(this._camPos);return this._updateMinMaxDistanceToCenter(r),n}calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=p(t.center,this._camPos);return this._updateMinMaxDistanceToCenter(n),n}_calculateAngleDependentLoDForSphere(e,t){let n=d(he,e,this._camPos),i=r(e),a=r(n);if(i===0||a===0)return 1;let o=(Math.abs(s(e,n))/i+t)/a;return Math.min(1,o)}calcAngleDependentLoD(e){let t=this.calculateMbsConeInRenderSR(e);if(t==null){let{center:t,radius:n}=this.calculateServiceMbsInRenderSRElevationAdjusted(e);return this._calculateAngleDependentLoDForSphere(t,n)}let{center:i,radius:a}=this.calculateServiceMbsInRenderSR(e);if(this._isGlobal){let e=r(i);if(e===0)return 1;n(q,i,t.lowerCenterHeight/e),n(J,i,t.upperCenterHeight/e)}else u(q,i),q[2]=t.lowerCenterHeight,u(J,i),J[2]=t.upperCenterHeight;let o=this._calculateAngleDependentLoDForSphere(q,a),c=this._calculateAngleDependentLoDForSphere(J,a);if(this._isGlobal){let e=r(i);if(e===0)return Math.max(o,c);let a=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,s(this._camPos,i)/e));n(Y,i,a/e)}else u(Y,i),Y[2]=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,this._camPos[2]));return Math.max(o,c,this._calculateAngleDependentLoDForSphere(Y,a))}hasLOD(e){return e.lodMetric!==0}_getDistanceToSurfaceGlobeMode(e,i){let a=r(i.center),c=r(e)-a;n(q,e,s(e,i.center)/m(e));let l=h(i.center,q),u=i.radius;if(l<=u*u)return Math.abs(c);let d=n(q,i.center,1/a),f=u*u/(2*a),g=n(J,d,a-f),_=o(Y,e,g),v=o(Y,_,n(X,d,s(d,_))),y=t(Y,g,n(Y,v,u/r(v))),b=p(e,y);if(c>=Z){let t=o(J,e,y),n=s(t,d)/r(t);n<Q&&(n=$),b/=n}return b}_getDistanceToSurface(e,t){return this._isGlobal?this._getDistanceToSurfaceGlobeMode(e,t):F(e,t)}_applyGlobalFlatAngleCorrectionToConeDistance(e,t){t.calculateClosestCenterToPoint(this._camPos,X);let n=r(X);if(n===0||r(this._camPos)-n<Z)return e;let i=o(Y,this._camPos,X),a=r(i);if(a===0)return e;let c=s(i,X)/(a*n);return e/(c<Q?$:c)}calculateScreenSpaceRelativeSphere(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=this._getDistanceToSurface(this._camPos,t),r=n+t.radius;return this._updateMinMaxDistanceToCenter(r),2*n*this._halfScreenPixelSizePerDistance}calculateScreenSpaceRelativeCone(e){let t=e.calculateCenterDistanceFromPoint(this._camPos);this._updateMinMaxDistanceToCenter(t);let n=e.calculateSurfaceDistanceFromPoint(this._camPos);return 2*(this._isGlobal?this._applyGlobalFlatAngleCorrectionToConeDistance(n,e):n)*this._halfScreenPixelSizePerDistance}_updateMinMaxDistanceToCenter(e){e>0?(this.minCenterDistance=Math.min(this.minCenterDistance,e),this.maxCenterDistance=Math.max(this.maxCenterDistance,e)):(this.minCenterDistance=0,this.maxCenterDistance=Math.max(this.maxCenterDistance,-e))}getLodLevel(e){if(e.lodMetric===0)return 0;if(e.childCount===0)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){let t=this._progressiveLoadFactor*this._screenspaceErrorBias,n=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,n)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let n=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(n*=this.calcAngleDependentLoD(e)),n<e.maxError}case 2:{let n=this.calculateMbsConeInRenderSR(e),r=n?this.calculateScreenSpaceRelativeCone(n):this.calculateScreenSpaceRelativeSphere(e);return e.maxError*t<=r}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<xe;case 4:return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(e==null)return 0;let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=t.center,r=s(n,this._cameraPOIDirection),i=r*r,a=m(n)-i;return Math.sqrt(a)-t.radius}distCameraToPOI(){return p(this._camPos,this._poi)}}function F(e,t){let n=e[0]-t.center[0],r=e[1]-t.center[1],i=e[2]-t.center[2],a=n*n+r*r,o=t.radius;if(a<=o*o)return Math.abs(i);let s=Math.sqrt(a)-o;return Math.sqrt(i*i+s*s)}const I=g(),L=g(),R=g(),z=new k,B=g(),V=new v,H=[g(),g(),g(),g(),g(),g(),g(),g()],he=g(),ge=C(),_e=g(),ve=g(),U=g(),W=g(),G=new O,K=ne(),q=g(),J=g(),Y=g(),X=g();function ye(e,t,i){if(i){let i=r(e.center);if(i===0){e.radius+=Math.abs(t);return}n(e.center,e.center,1+t/i)}else e.center[2]+=t}const be=.5*Number.MAX_VALUE,xe=10,Z=2e5,Q=.08,$=1e-4,Se=.9,Ce=.01,we=.001;export{P as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{EventedAccessor as r}from"../../../../core/Evented.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as a,transformQuatValues as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../../core/Logger.js";import{projectBoundingRect as l}from"../../../../geometry/projection/projectBoundingRect.js";import{projectBoundingSphere as u}from"../../../../geometry/projection/projectBoundingSphere.js";import{canProjectWithoutEngine as d}from"../../../../geometry/projectionUtils.js";import{create as f,allFinite as p,fromExtent as m}from"../../../../geometry/support/aaBoundingRect.js";import{getInfo as h}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as g}from"../../../../geometry/support/sphere.js";import{ElevationRange as _}from"../../support/ElevationRange.js";import{ElevationUpdateEvent as v}from"../../support/ElevationUpdateEvent.js";import{ProjectedElevationUpdateExtent as y,calculateElevationUpdateExtents as b,fullWorldElevationUpdateExtent as x,planetCenterProximityToleranceMeters as S}from"../../support/elevationUpdateExtentUtils.js";import{Intersector as C}from"../../webgl-engine/lib/Intersector.js";let w=class extends r{constructor(e){super(e),this._renderCoordsHelper=e.view.renderCoordsHelper,this._renderSR=this._renderCoordsHelper.spatialReference,this._layerElevationSource=e.layerElevationSource,this._projectedExtent=new y(this._renderCoordsHelper)}initialize(){this._intersector=new C(this.view.state.
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{EventedAccessor as r}from"../../../../core/Evented.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as a,transformQuatValues as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../../core/Logger.js";import{projectBoundingRect as l}from"../../../../geometry/projection/projectBoundingRect.js";import{projectBoundingSphere as u}from"../../../../geometry/projection/projectBoundingSphere.js";import{canProjectWithoutEngine as d}from"../../../../geometry/projectionUtils.js";import{create as f,allFinite as p,fromExtent as m}from"../../../../geometry/support/aaBoundingRect.js";import{getInfo as h}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as g}from"../../../../geometry/support/sphere.js";import{ElevationRange as _}from"../../support/ElevationRange.js";import{ElevationUpdateEvent as v}from"../../support/ElevationUpdateEvent.js";import{ProjectedElevationUpdateExtent as y,calculateElevationUpdateExtents as b,fullWorldElevationUpdateExtent as x,planetCenterProximityToleranceMeters as S}from"../../support/elevationUpdateExtentUtils.js";import{Intersector as C}from"../../webgl-engine/lib/Intersector.js";let w=class extends r{constructor(e){super(e),this._renderCoordsHelper=e.view.renderCoordsHelper,this._renderSR=this._renderCoordsHelper.spatialReference,this._layerElevationSource=e.layerElevationSource,this._projectedExtent=new y(this._renderCoordsHelper)}initialize(){this._intersector=new C(this.view.state.isGlobal),this._intersector.options.store=0,this._intersector.options.normalRequired=!1}get spatialReference(){return this.view?.elevationProvider?.spatialReference}getElevation(e,t,n,r){let i=this._renderCoordsHelper,o=a(E,e,t,n);if(!i.toRenderCoords(o,r,o))return c.getLogger(this).error(`could not project point to compute elevation`),null;let{layerElevationSource:s,_intersector:l,intersectionHandler:u}=this,d=s.elevationRange;if(d==null||d.isEmpty)return null;let f=d.minElevation,p=d.maxElevation,m=Math.max(1,(p-f)/2),h=i.setAltitude(k,p+m,o),g=i.setAltitude(A,f-m,o);return l.reset(h,g,this.view.state.camera),u.intersectRay(l,null,h,g,null,!0),l.results.min.getIntersectionPoint(o)?i.getAltitude(o):null}getElevations(e,t,n){let{groundSpatialReference:r}=this.view;for(let i=0;i<t;++i){let t=i*3,a=e[t],o=e[t+1],s=this.getElevation(a,o,0,r);n(i,s)}}getSphereElevationRange(e,t){return u(e,t,T,this._renderSR),this._layerElevationSource.getElevationRange(T)}getRootElevationRange(){let e=this.layerElevationSource.fullExtent;return e?.hasZ?new _(e.zmin,e.zmax):null}notifyObjectsChanged(e){this._notifyObjectsChanged(e.length,t=>{for(let n of e)if(!t(n))break})}notifyObjectsChangedFunctional(e,t){this._notifyObjectsChanged(e,t)}notifyObjectChanged(e){this._notifyObjectsChanged(1,t=>{t(e)})}_notifyObjectsChanged(e,t){if(e===0)return;let n=this.spatialReference;if(n==null)return;if(!d(this._renderSR,n)){this._emitFullExtentElevationChange(n);return}let r=new Float64Array(4*e),i=!1,a=0;t(e=>this._computeObjectExtent(e,r,a,n)?(a++,!0):(i=!0,!1)),i?this._emitFullExtentElevationChange(n):this._emitElevationChangeEvents(r,n)}_computeObjectExtent(e,t,n,r){if(this.view.state.isGlobal&&P(e))return!1;let i=this._projectedExtent;return E[0]=e.centerX,E[1]=e.centerY,E[2]=e.centerZ,i.reset(E,e.radius,r),!this._expandExtent(e,i,r)||!p(i.extent)?!1:(t.set(i.extent,4*n),!0)}_emitElevationChangeEvents(e,t){for(let n of b(e,t))this._emitElevationChangeEvent(n,t)}_emitFullExtentElevationChange(e){let t=f(),n=this._layerElevationSource.fullExtent;if(n!=null&&l(m(n,M),n.spatialReference,t,e)&&p(t)){this._emitElevationChangeEvent(t,e);return}let r=h(e);r!=null&&this._emitElevationChangeEvent(x(e,r),e)}_emitElevationChangeEvent(e,t){let n=new v(t,e,this.intersectionHandler.isGround?`ground`:`scene`);this.emit(`elevation-change`,n)}_expandExtent(e,t,n){e.getCorners(O);for(let e=0;e<8;++e){let r=O[e];if(t.addRenderPoint(r,n)==null)return!1}for(let e=0;e<D.length;e+=2)if(!t.addRenderEdge(O[D[e]],O[D[e+1]],n))return!1;return!0}};e([t({constructOnly:!0})],w.prototype,`layerElevationSource`,void 0),e([t({constructOnly:!0})],w.prototype,`intersectionHandler`,void 0),e([t({constructOnly:!0})],w.prototype,`view`,void 0),e([t()],w.prototype,`spatialReference`,null),w=e([n(`esri.views.3d.layers.i3s.LayerElevationProvider`)],w);const T=new g,E=s(),D=[0,1,2,3,4,5,6,7,0,2,1,3,4,6,5,7,0,4,1,5,2,6,3,7],O=Array.from({length:8},()=>s()),k=s(),A=s(),j=i(),M=f(),N=s();function P(e){N[0]=-e.centerX,N[1]=-e.centerY,N[2]=-e.centerZ,e.getQuaternion(j),o(N,N,-j[0],-j[1],-j[2],j[3]);let t=Math.max(Math.abs(N[0])-e.halfSizeX,0),n=Math.max(Math.abs(N[1])-e.halfSizeY,0),r=Math.max(Math.abs(N[2])-e.halfSizeZ,0);return t*t+n*n+r*r<=S*S}export{w as LayerElevationProvider};
|