@arcgis/core 4.24.0-next.20220427 → 4.24.0-next.20220430
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/WebMap.js +1 -1
- package/analysis/LineOfSightAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{3a43a2918b44781aaf85.js → 055a0ebf22a82f859474.js} +1 -1
- package/assets/esri/core/workers/chunks/{3273b6be43eeb49ee842.js → 0b12ff7b2ed2838afbb8.js} +1 -1
- package/assets/esri/core/workers/chunks/0e25548573baf855e394.js +1 -0
- package/assets/esri/core/workers/chunks/0edd4c3ca6e7d749d0e5.js +1 -0
- package/assets/esri/core/workers/chunks/133f971e72a1a6277ac4.js +1 -0
- package/assets/esri/core/workers/chunks/{c388ac33496f004d56f3.js → 135a90ae61f3b3cae91b.js} +1 -1
- package/assets/esri/core/workers/chunks/{54f9b1ab9d472bf4baca.js → 1facbda248863cf72cbd.js} +1 -1
- package/assets/esri/core/workers/chunks/1fb2d7abe6c8efa84695.js +1 -0
- package/assets/esri/core/workers/chunks/2133499e642193f6738f.js +1 -0
- package/assets/esri/core/workers/chunks/{dee63bfc108b4e5893a3.js → 2cf3934b3ecabdf207c8.js} +1 -1
- package/assets/esri/core/workers/chunks/{3c572629f46e5093223c.js → 30333a95dc0a44e23fb5.js} +1 -1
- package/assets/esri/core/workers/chunks/{7afe89eafab00afb31f2.js → 30837d93116f0337972f.js} +1 -1
- package/assets/esri/core/workers/chunks/31df729c17470245288c.js +2 -0
- package/assets/esri/core/workers/chunks/{c0bf663240df7be68131.js.LICENSE.txt → 31df729c17470245288c.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/4130ea1f5a9f197168d7.js +1 -0
- package/assets/esri/core/workers/chunks/{417ee7a88575cb8f9aaf.js → 492b65fe99641f5740f0.js} +1 -1
- package/assets/esri/core/workers/chunks/4cdd29e1f3a1c7a39af7.js +1 -0
- package/assets/esri/core/workers/chunks/{9a0073d43b7dbaeba736.js → 541e644fc77dbe527124.js} +1 -1
- package/assets/esri/core/workers/chunks/{5a61a12b2492c6eae592.js → 59e341b2db44351bf557.js} +1 -1
- package/assets/esri/core/workers/chunks/{73630d52768e3d932f30.js → 5a10b58533b4116115ac.js} +1 -1
- package/assets/esri/core/workers/chunks/5fd787f63362defc984f.js +1 -0
- package/assets/esri/core/workers/chunks/682a8f15f352de76df69.js +1 -0
- package/assets/esri/core/workers/chunks/6a06635089761ee3e6d4.js +972 -0
- package/assets/esri/core/workers/chunks/{ab0c0c29d54f2ed954d6.js → 86b31ae136f931d7884a.js} +1 -1
- package/assets/esri/core/workers/chunks/{dc193247a1980360ec4f.js → 8e98ff9404a802352037.js} +1 -1
- package/assets/esri/core/workers/chunks/{863cfe35ee640bac103f.js → 94e51fe1c539df6257c2.js} +1 -1
- package/assets/esri/core/workers/chunks/{cbe7e6283a427a618d4b.js → 9519a02b9b8db88a3150.js} +1 -1
- package/assets/esri/core/workers/chunks/9f3a094aa4b47e4eb046.js +1 -0
- package/assets/esri/core/workers/chunks/{50d256bc3b213c8a1b09.js → a0ebf25c9c9a7f839b93.js} +1 -1
- package/assets/esri/core/workers/chunks/{d8a992dee594a6a64fde.js → a25f0a195f9217665530.js} +1 -1
- package/assets/esri/core/workers/chunks/a59ee7d2b98c85f27dd2.js +1 -0
- package/assets/esri/core/workers/chunks/{92ef9b0c61640e0ecbb4.js → a5dbab94697757c87c49.js} +1 -1
- package/assets/esri/core/workers/chunks/{147d3ee9aa81d7b2b7fa.js → a6406a248b7b2ed65f35.js} +1 -1
- package/assets/esri/core/workers/chunks/{ebdf61eb364ac0856f40.js → acbd0f4d72d1f5d8e4e8.js} +1 -1
- package/assets/esri/core/workers/chunks/acc97a210f36bff2d1b0.js +1 -0
- package/assets/esri/core/workers/chunks/ad68fe924456d6d7d4f0.js +1 -0
- package/assets/esri/core/workers/chunks/b06c949fc7d08e376a5f.js +1 -0
- package/assets/esri/core/workers/chunks/b4405e9fe6c0cf7250d3.js +1 -0
- package/assets/esri/core/workers/chunks/b97a34d2e7cceef1ac41.js +1 -0
- package/assets/esri/core/workers/chunks/bc08fe3b03767bd694c5.js +1 -0
- package/assets/esri/core/workers/chunks/c9b09099488d0e719dfb.js +1 -0
- package/assets/esri/core/workers/chunks/{4a05d0dfa73ff570e1fa.js → d15e6662d90718411d62.js} +1 -1
- package/assets/esri/core/workers/chunks/{b74b9dceabbf7b1aec39.js → d16aac3461af9cee0c29.js} +1 -1
- package/assets/esri/core/workers/chunks/{bb678bc2e2fc48112e07.js → d60dd3e1028f714f2258.js} +1 -1
- package/assets/esri/core/workers/chunks/{31c1ae0532dd991da63d.js → d6c150c243ca1f6108f9.js} +1 -1
- package/assets/esri/core/workers/chunks/{cab6decfcb3f596a3837.js → d8c59b1d73650c060dfb.js} +1 -1
- package/assets/esri/core/workers/chunks/{d24339b37cc9316e6d99.js → dcb6e1b33402d7fa455b.js} +1 -1
- package/assets/esri/core/workers/chunks/{a8da24116180d708cf81.js → df653bca2b14dffc82d1.js} +1 -1
- package/assets/esri/core/workers/chunks/{a3db91d04fe1fca0fe4f.js → e06461703e6f1acfcfdc.js} +1 -1
- package/assets/esri/core/workers/chunks/{423e199c2f695e913c0e.js → e3e1d87b8532bf84a18d.js} +1 -1
- package/assets/esri/core/workers/chunks/e7744b7e0c16bba93151.js +1 -0
- package/assets/esri/core/workers/chunks/ea50effc5c39870dc871.js +1 -0
- package/assets/esri/core/workers/chunks/fc4fd9db056579e09bfe.js +1 -0
- package/assets/esri/core/workers/chunks/fc9b5f40c5179a8c90de.js +1 -0
- package/assets/esri/core/workers/chunks/fd35b69872ac9393924f.js +1 -0
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ar.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_bg.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_bs.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ca.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_cs.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_da.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_de.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_el.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_es.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_et.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_fi.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_fr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_he.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_hr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_hu.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_id.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_it.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ja.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ko.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_lt.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_lv.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_nb.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_nl.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pl.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pt-BR.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pt-PT.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ro.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ru.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sk.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sl.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sv.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_th.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_tr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_uk.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_vi.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-CN.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-HK.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-TW.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_ar.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_bg.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_bs.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_ca.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_cs.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_da.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_de.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_el.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_es.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_et.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_fi.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_fr.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_he.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_hr.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_hu.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_id.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_it.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_ja.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_ko.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_lt.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_lv.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_nb.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_nl.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_pl.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_pt-BR.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_pt-PT.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_ro.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_ru.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_sk.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_sl.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_sr.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_sv.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_th.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_tr.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_uk.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_vi.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_zh-CN.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_zh-HK.json +1 -1
- package/assets/esri/widgets/Weather/t9n/Weather_zh-TW.json +1 -1
- package/chunks/ColorMaterial.glsl.js +4 -4
- package/chunks/LineMarker.glsl.js +12 -12
- package/chunks/Pattern.glsl.js +17 -17
- package/chunks/RibbonLine.glsl.js +34 -34
- package/chunks/ShadedColorMaterial.glsl.js +11 -11
- package/chunks/index.js +1 -1
- package/chunks/sphere.js +1 -1
- package/config.js +1 -1
- package/core/workers/RemoteClient.js +1 -1
- package/core/workers/WorkerHandle.js +1 -1
- package/geometry/support/sphere.js +1 -1
- package/interfaces.d.ts +74 -20
- package/layers/mixins/PortalLayer.js +1 -1
- package/layers/support/LercDecoder.js +1 -1
- package/package.json +2 -2
- package/request.js +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/previewSymbol2D.js +1 -1
- package/views/2d/engine/brushes.js +1 -1
- package/views/2d/engine/vectorTiles/TileParser.js +1 -1
- package/views/2d/engine/webgl/GraphicDisplayList.js +1 -1
- package/views/2d/engine/webgl/Painter.js +1 -1
- package/views/2d/engine/webgl/WGLRendererInfo.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushDotDensity.js +5 -0
- package/views/2d/engine/webgl/brushes/WGLBrushHeatmap.js +5 -0
- package/views/2d/engine/webgl/brushes/WGLGeometryBrush.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrushFill.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrushLabel.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrushLine.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrushMarker.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrushText.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/engine/webgl/techniques/Technique.js +5 -0
- package/views/2d/engine/webgl/techniques/dotDensity/TechniqueDotDensity.js +5 -0
- package/views/2d/engine/webgl/techniques/heatmap/TechniqueHeatmap.js +5 -0
- package/views/2d/engine/webgl/techniques/utils.js +5 -0
- package/views/2d/layers/features/schemaUtils.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/GraphicsReader.js +1 -1
- package/views/2d/layers/features/tileRenderers/support/WGLFeatureView.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/analysisTools/lineOfSight/LineOfSightTool.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/DirectLineMeasurement3DView.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
- package/views/3d/layers/I3SPointsWorkerHandle.js +1 -1
- package/views/3d/layers/PointCloudWorkerHandle.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/i3s/I3SElevationProvider.js +1 -1
- package/views/3d/layers/i3s/I3SNode.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/PBFDecoder.js +1 -1
- package/views/3d/support/geometryUtils/sphere.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/tileUtils.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IndexRange/ComponentRangeRunLengthEncoded.js +1 -1
- package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeProcessingWorker.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeWorkerHandle.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
- package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/LineSnapper.js +1 -1
- package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
- package/views/interactive/snapping/SnappingManager.js +1 -1
- package/views/interactive/snapping/candidates/EdgeSnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/FeatureSnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/IntersectionSnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/LineSnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/ParallelLineSnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/RightAngleSnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/RightAngleTriangleSnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/SnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/VertexSnappingCandidate.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/SceneLayerSnappingSource.js +5 -0
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/featureSources/queryEngineUtils.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +5 -0
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorkerHandle.js +5 -0
- package/views/interactive/snapping/hints/IntersectionSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/ParallelSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/PointSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/RightAngleSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/SnappingHint.js +1 -1
- package/views/interactive/snapping/snappingUtils.js +1 -1
- package/views/support/colorUtils.js +1 -1
- package/webmap/Bookmark.js +1 -1
- package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.js +1 -1
- package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +2 -2
- package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Slice/SliceViewModel.js +1 -1
- package/widgets/support/AnalysisViewModel.js +1 -1
- package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/2266d6388444ac5d50b3.js +0 -1
- package/assets/esri/core/workers/chunks/3f6b17c9d2629ed396da.js +0 -1
- package/assets/esri/core/workers/chunks/404f1d7bce014c7e6965.js +0 -1
- package/assets/esri/core/workers/chunks/4e4994665549435f51ee.js +0 -1
- package/assets/esri/core/workers/chunks/503226c5c612feab4115.js +0 -1
- package/assets/esri/core/workers/chunks/528033aa0d663b4d41bf.js +0 -1
- package/assets/esri/core/workers/chunks/54af957c5330933805a3.js +0 -1
- package/assets/esri/core/workers/chunks/6ef8de3aa9a8d9c22161.js +0 -1
- package/assets/esri/core/workers/chunks/72d8b2ad36f0d0a40a0d.js +0 -1
- package/assets/esri/core/workers/chunks/756befc4aa3354e1db1d.js +0 -972
- package/assets/esri/core/workers/chunks/8a4e2831e8fdde530b21.js +0 -1
- package/assets/esri/core/workers/chunks/9b9821772b6cbe189fe0.js +0 -1
- package/assets/esri/core/workers/chunks/9c4d41f20c1a94147344.js +0 -1
- package/assets/esri/core/workers/chunks/9cfd66ee9e6328b3693a.js +0 -1
- package/assets/esri/core/workers/chunks/b548bf032c8af34fe155.js +0 -1
- package/assets/esri/core/workers/chunks/bbcae04235830debd814.js +0 -1
- package/assets/esri/core/workers/chunks/bc6f5927f07c5993b998.js +0 -1
- package/assets/esri/core/workers/chunks/c0bf663240df7be68131.js +0 -2
- package/assets/esri/core/workers/chunks/cd9668acbe3babd2b188.js +0 -1
- package/assets/esri/core/workers/chunks/d53c7a9ede56be749f2b.js +0 -1
- package/assets/esri/core/workers/chunks/e07930ab66f89d215666.js +0 -1
- package/assets/esri/core/workers/chunks/f72de828ede4d0c5e9d7.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{create as r}from"../../../../geometry/support/ray.js";import{
|
|
5
|
+
import{create as r}from"../../../../geometry/support/ray.js";import{h as o}from"../../../../chunks/sphere.js";import{fromScreenAtEye as t}from"./ray.js";function s(r,s,p,e){const n=t(s,p,m);return o(r,n,e)}const m=r();export{s as intersectScreen};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{Cyclical as r,cyclicalPI as s}from"../../../core/Cyclical.js";import i from"../../../core/Handles.js";import a from"../../../core/has.js";import{clamp as n,deg2rad as o}from"../../../core/mathUtils.js";import{isSome as l,isNone as h,unwrap as c}from"../../../core/maybe.js";import{watch as d,sync as u}from"../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../core/scheduling.js";import{Milliseconds as _}from"../../../core/time.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import{h as g}from"../../../chunks/vec2.js";import{a as f,b as v,x as R,c as T,i as O}from"../../../chunks/vec3.js";import{c as w}from"../../../chunks/vec3f64.js";import{t as D,b as x,a as S}from"../../../chunks/vec4.js";import{c as E,f as P}from"../../../chunks/vec4f64.js";import{projectVectorToVector as U}from"../../../geometry/projection.js";import{getReferenceEllipsoid as M}from"../../../geometry/projectionEllipsoid.js";import{create as C,width as j,copy as I,center as N,intersection as b,height as A,contains as G,intersects as H,offset as L}from"../../../geometry/support/aaBoundingRect.js";import{create as V,wrap as k}from"../../../geometry/support/ray.js";import{h as B,j as F}from"../../../chunks/sphere.js";import{angleAroundAxis as q}from"../../../geometry/support/vector.js";import{y2lat as W}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as z}from"../state/utils/viewUtils.js";import Y from"../support/debugFlags.js";import{PointGraphics as X}from"../support/debugUtils.js";import{OverlayIndex as K}from"./interfaces.js";import{computeOverlayResolution as Z}from"./Overlay.js";import{OverlayRenderer as J}from"./OverlayRenderer.js";import{RenderRequestType as Q,ValidationState as $}from"../webgl-engine/lib/basicInterfaces.js";import{newIntersector as ee}from"../webgl-engine/lib/Intersector.js";import{fromValues as te}from"../webgl-engine/lib/LocalOriginFactory.js";import{SortedRenderGeometryRenderer as re}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{removeLoadedShaderModules as se}from"../webgl-engine/parts/requireUtils.js";import{TaskPriority as ie}from"../../support/Scheduler.js";const ae=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let ne,oe=class extends t{constructor(e){super(e),this._handles=new i,this._spatialReference=null,this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._hasUnusedRenderTargets=!1,this._longitudeCyclical=null,this._latestOriginId=0,this._maxResolution=a("esri-mobile")?2048:4096,this._animationTimeLast=0}get running(){return this._placementDirty&&(this._drapeSources.size>0||this.view.graphics.length>0||Y.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.surface.ready}get _isSpherical(){return this.view.state.isGlobal}get _worldToPCSRatio(){return l(this._spatialReference)&&this._spatialReference.isGeographic&&!this.view.state.isLocal?M(this._spatialReference).metersPerDegree:1}get view(){return this.surface.view}get updating(){return this.running||this.renderer.updating||this._contentUpdated}get hasHighlights(){return this.renderer.hasHighlights}get rendersOccluded(){return this.renderer.rendersOccluded}initialize(){const e=this.view;this.renderer=new J({view:e,worldToPCSRatio:this._worldToPCSRatio,spatialReference:this._spatialReference}),this._groundIntersector=ee(this.view.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this._handles.add([this.renderer.events.on("has-highlights",(()=>{this._setDrawTexturesDirty(),this.notifyChange("hasHighlights")})),this.renderer.events.on("has-water",(t=>{var r;return null==(r=e._stage)?void 0:r.renderView.setRenderParameters({hasOverlayWater:t})})),this.renderer.events.on("renders-occluded",(()=>{this._setDrawTexturesDirty(),this.notifyChange("rendersOccluded")})),this.renderer.events.on("content-changed",(()=>this._setDrawTexturesDirty())),this.renderer.events.on("textures-disposed",(()=>this.updateOverlayResult())),d((()=>{var t,r,s;return[null==(t=e.pointsOfInterest)?void 0:t.renderPointOfView,null==(r=e.pointsOfInterest)||null==(s=r.centerOnSurfaceFrequent)?void 0:s.location]}),(()=>this.setPlacementDirty())),d((()=>{var t;return null==(t=e.state)?void 0:t.pixelRatio}),(()=>this.setPlacementDirty()),u),this.surface.on("elevation-change",(()=>this.setPlacementDirty())),e.on("resize",(()=>this.setPlacementDirty())),p({preRender:e=>{this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.hasOverlays&&(this._dispatchAnimationUpdate(e),this._drawOverlayTextures(this.renderer.overlays,Q.UPDATE)),this._hasUnusedRenderTargets&&this._collectUnusedRenderTargetMemory()}}),e.resourceController.scheduler.registerTask(ie.OVERLAY,this),e._stage.renderView.events.on("force-camera-for-screenshot",(e=>{this._updateOverlays(e,Q.BACKGROUND),this.renderer.hasOverlays&&this._drawOverlayTextures(this.renderer.overlays,Q.BACKGROUND,e)}))])}destroy(){this.renderer.dispose(),this._handles&&(this._handles.destroy(),this._handles=null),l(ne)&&(ne.hide(),ne=null)}get hasOverlays(){return this.renderer.hasOverlays}setSpatialReference(e){this._spatialReference=e,this.renderer.spatialReference=e,this._longitudeCyclical=null;const t=this.view.renderSpatialReference;l(e)&&l(t)?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this._longitudeCyclical=e.isWebMercator?new r(-20037508.342787,20037508.342787):new r(-180,180),this.renderer.longitudeCyclical=this._longitudeCyclical),this.renderer&&(this.renderer.worldToPCSRatio=this._worldToPCSRatio)):this.renderer.disposeOverlays()}get gpuMemoryUsage(){return this.renderer.gpuMemoryUsage}registerDrapeSource(e,t,r){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const s=this.renderer.createDrapeSourceRenderer(e,t,r);return this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("running"),s}registerGeometryDrapeSource(e){return this.registerDrapeSource(e,re)}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&l(e.setDrapingExtent)&&l(this._spatialReference)&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("running"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}updateOverlayResult(){var e;null==(e=this.view._stage)||e.renderView.setRenderParameters({overlays:this.renderer.overlays})}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this._setDrawTexturesDirty()}setPlacementDirty(){this._placementDirty=!0}runTask(){this._updateOverlays(this.view.state.camera,Q.UPDATE)}_updateOverlays(e,t){if(!this._spatialReference)return;const r=Z(e.fullWidth,e.fullHeight,this._maxResolution);this._computeOverlayExtents(e,r,de);const s=j(de.inner)/j(de.outer);this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const i=this._updateOverlay(K.INNER,de.inner,r,1*de.pixelRatioAdjustment,de.mapUnitsPerPixel),a=this._updateOverlay(K.OUTER,de.outer,r,s*de.pixelRatioAdjustment,de.mapUnitsPerPixel);i!==me.EXTENT&&a!==me.EXTENT||(this._drapeSources.forEach((e=>this._updateDrapeSourceExtent(e))),this.surface.updateTileOverlayParams(t)),i===me.NONE&&a===me.NONE||this._setDrawTexturesDirty(),this._placementDirty=!1}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return me.NONE;const a=this.renderer.overlays[e],n=a.mapUnitsPerPixel;if(a.mapUnitsPerPixel=i,a.pixelRatio=s,le(t,a.extent)&&r===a.resolution)return n===i?me.NONE:me.RERENDER_ONLY;I(a.extent,t),a.resolution=r;const o=N(a.extent);return a.renderLocalOrigin=te(o[0],o[1],0,"OV_"+this._latestOriginId++),me.EXTENT}setTileParameters(e){const t=e.renderData.overlay;if(this.renderer.overlays.length>0){const r=this.renderer.overlays[K.INNER],s=this.renderer.overlays[K.OUTER],i=b(e.extent,this.surface.extent,ue);this._rectInsideRect(r.extent,i)||this._rectanglesOverlap(i,r.extent)||this._rectanglesOverlap(i,s.extent)?(this._setTileOverlayData(i,K.INNER,t),this._setTileOverlayData(i,K.OUTER,t)):(this._clearTileOverlayData(K.INNER,t),this._clearTileOverlayData(K.OUTER,t))}else this._clearTileOverlayData(K.INNER,t),this._clearTileOverlayData(K.OUTER,t)}overlayPixelSizeInMapUnits(e){if(0===this.renderer.overlays.length)return 0;const t=this.renderer.overlays[K.INNER],r=this.renderer.overlays[K.OUTER],s=this._pointIsInExtent(e,t.extent)?t:r;return(s.extent[2]-s.extent[0])/s.resolution}_setTileOverlayData(e,t,r){if(0===this.renderer.overlays.length)return;const s=this.renderer.overlays[t].extent,i=j(s),a=A(s);let n=e[0];if(this._longitudeCyclical){n=this._longitudeCyclical.minimalMonotonic(s[0],n);const t=this._longitudeCyclical.minimalMonotonic(s[0],e[2]);n>t&&(n=t-(e[2]-e[0]))}r.setScale(t,j(e)/i,A(e)/a),r.setOffset(t,(n-s[0])/i,(e[1]-s[1])/a)}_clearTileOverlayData(e,t){t.setScale(e,-1,-1),t.setOffset(e,-1,-1)}async reloadShaders(){se(),await this.renderer.reloadShaders(),this._setDrawTexturesDirty(),this.runTask()}_dispatchAnimationUpdate(e){const t=_(e.time-this._animationTimeLast);(t>=this.surface.view._stage.renderView.animationTimestep||l(this.forcedAnimationTime)||this._drawTexturesDirty||this._drawTexturesAnimateDirty)&&(this.renderer.updateAnimation({dt:t,forcedTime:this.forcedAnimationTime,camera:this.view.state.camera})&&(this._drawTexturesAnimateDirty=!0),this._animationTimeLast=e.time)}_setDrawTexturesDirty(){this.renderer.hasOverlays?(this._contentUpdated=!0,this._drawTexturesDirty=!0):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s){const i=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,_e,t,r);if(h(i))return!1;const a=i.origin,n=f(ce,i.origin,i.direction);return this._groundIntersector.reset(a,n,e),this._groundIntersector.intersect([],null),this.view.basemapTerrain.intersect(this._groundIntersector,null,a,n),this._groundIntersector.results.min.getIntersectionPoint(s)}_findHorizonBasedPointOfInterest(e,t){let r=.5;const i=.55,a=this.view.renderCoordsHelper.getAltitude(e.eye),o=this.view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=n(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:a+l,e.aboveGround?a-l:1/0),c=e.aboveGround;if("global"===this.view.viewingMode){const t=ce;B(F(M(this.view.spatialReference).radius+h),k(e.eye,e.viewForward),t),v(t,t,e.eye);const a=s.normalize(q(e.viewForward,t,e.viewRight))/e.fovY+.5,n=a<=0||a>=1?.5:i;r=c?n*a:a+n*(1-a)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),s=Math.tan(t),a=P(0,s,1,0),o=D(a,a,e.projectionMatrix)[1],l=n(.5+.5*o,0,1);r=1===l||0===l?.5:c?l*i:1-(1-l)*i}return!!this._intersectGroundFromView(e,.5,r,t)&&R(t,e.eye)<o.distance*o.distance}_computeOverlayExtents(e,t,r){const s=this.view.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,i=w();this._findHorizonBasedPointOfInterest(e,i)||T(i,s);const a=Math.max(.1,O(e.eye,i)),n=z(this.view.renderCoordsHelper,s,e.eye),d=Math.PI/2-Math.abs(n-Math.PI/2);Y.OVERLAY_SHOW_CENTER?(h(ne)&&(ne=new X(this.view.graphics,"red")),ne.show(i,this._renderSR)):l(ne)&&ne.hide(),this._overlaySREqualsRenderSR||U(i,this._renderSR,i,this._spatialReference);const u=this.surface.extent,p=!this._isSpherical&&l(this._spatialReference)&&this._spatialReference.isGeographic,_=p&&l(this._spatialReference)?1/M(this._spatialReference).metersPerDegree:1,m=e.perRenderPixelRatio*a*_;r.mapUnitsPerPixel=m/this._worldToPCSRatio;let y=t*m/2,f=!1,v=p?90:1/0;this._isSpherical&&l(u)&&l(this._spatialReference)&&(this._spatialReference.isWebMercator?(y/=Math.cos(W(i[1])),v=u[3]):(f=!0,y/=M(this._spatialReference).metersPerDegree,v=90),y>=v&&(y=v,i[1]=0,this._spatialReference.isWebMercator&&(i[0]=0)));let R=1;f&&(R=1/Math.max(.2,Math.cos(Math.abs(o(i[1])))),y*R>180&&(R=180/y),r.mapUnitsPerPixel*=R);const D=Math.log(2)/12;y=Math.exp(Math.round(Math.log(y)/D)*D);const E=y*R,P=32,C=.5*t/(P*E),N=.5*t/(P*y);i[0]=Math.round(i[0]*C)/C,i[1]=Math.round(i[1]*N)/N;const A=r.inner;A[0]=i[0]-E,A[1]=i[1]-y,A[2]=i[0]+E,A[3]=i[1]+y,this._isSpherical&&this._shiftExtentToFitBounds(A,1/0,v);const H=r.outer;if(6*E>j(u))I(H,c(u));else if(d<=.25*Math.PI)H[0]=A[0]-E,H[1]=A[1]-y,H[2]=A[2]+E,H[3]=A[3]+y;else{U(e.eye,this._renderSR,ce,this._spatialReference),g(he,i,ce);let t=-Math.atan2(he[1],he[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));x(he,ae[r],2*y),he[0]*=R,he[2]*=R,S(H,A,he)}if(this._isSpherical)H[0]=this._longitudeCyclical.clamp(H[0]),H[2]=this._longitudeCyclical.clamp(H[2]),H[1]=Math.max(H[1],-v),H[3]=Math.min(H[3],v);else{const e=b(A,u,ue),t=b(H,u,pe);G(e,t)&&(H[2]=H[0],H[3]=H[1])}const L=Math.abs(A[2]-A[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,L),r.pixelRatioAdjustment=r.mapUnitsPerPixel/L}_drawOverlayTextures(e,t,r=this.view.state.camera){if(0===e.length||!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return;const s=this._drawTexturesDirty;this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1;const i=this._drawOverlay(e[K.INNER],r),a=this._drawOverlay(e[K.OUTER],r);i!==$.CHANGED&&a!==$.CHANGED||this.surface.updateTileOverlayParams(Q.UPDATE),this._collectUnusedRenderTargetMemory(),this.updateOverlayResult(),s?(this.surface.requestRender(t),t===Q.UPDATE&&this.surface.requestUpdate()):this.surface.requestRender(Q.BACKGROUND)}_drawOverlay(e,t){return this._longitudeCyclical?e.setupGeometryViewsCyclical(this._longitudeCyclical):e.setupGeometryViewsDirect(),e.draw(this.renderer,t.pixelRatio)}_collectUnusedRenderTargetMemory(){if(this._hasUnusedRenderTargets=!1,this.renderer.hasOverlays){const e=performance.now();this._hasUnusedRenderTargets=this.renderer.collectUnusedRenderTargetMemory(e)}}_rectanglesOverlap(e,t){return!h(e)&&(this._longitudeCyclical?(this._longitudeCyclical.contains(t[0],t[2],e[0])||this._longitudeCyclical.contains(t[0],t[2],e[2])||this._longitudeCyclical.contains(e[0],e[2],t[0]))&&!(e[1]>t[3]||e[3]<t[1]):H(e,t))}_rectInsideRect(e,t){return!h(t)&&(this._longitudeCyclical?this._longitudeCyclical.contains(e[0],e[2],t[0])&&this._longitudeCyclical.contains(e[0],e[2],t[2])&&t[1]>e[1]&&t[3]<e[3]:G(e,t))}_pointIsInExtent(e,t){if(this._longitudeCyclical)return this._longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),L(e,s,i)}get test(){return{renderer:this.renderer,update:()=>this.runTask()}}};function le(e,t){const r=1e-5,s=Y.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([m()],oe.prototype,"_spatialReference",void 0),e([m({readOnly:!0})],oe.prototype,"running",null),e([m()],oe.prototype,"_placementDirty",void 0),e([m()],oe.prototype,"_contentUpdated",void 0),e([m()],oe.prototype,"_isSpherical",null),e([m()],oe.prototype,"_worldToPCSRatio",null),e([m()],oe.prototype,"renderer",void 0),e([m({constructOnly:!0})],oe.prototype,"surface",void 0),e([m({readOnly:!0,aliasOf:"surface.suspended"})],oe.prototype,"suspended",void 0),e([m({readOnly:!0})],oe.prototype,"updating",null),e([m({type:Boolean})],oe.prototype,"hasHighlights",null),e([m({type:Boolean})],oe.prototype,"rendersOccluded",null),oe=e([y("esri.views.3d.terrain.OverlayManager")],oe);const he=E(),ce=w(),de={inner:C(),outer:C(),mapUnitsPerPixel:0,pixelRatioAdjustment:1},ue=C(),pe=C(),_e=V();var me;!function(e){e[e.NONE=0]="NONE",e[e.EXTENT=1]="EXTENT",e[e.RERENDER_ONLY=2]="RERENDER_ONLY"}(me||(me={}));export{oe as OverlayManager};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{Cyclical as r,cyclicalPI as s}from"../../../core/Cyclical.js";import i from"../../../core/Handles.js";import a from"../../../core/has.js";import{clamp as n,deg2rad as o}from"../../../core/mathUtils.js";import{isSome as l,isNone as h,unwrap as c}from"../../../core/maybe.js";import{watch as d,sync as u}from"../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../core/scheduling.js";import{Milliseconds as _}from"../../../core/time.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import{h as g}from"../../../chunks/vec2.js";import{a as f,b as v,x as R,c as T,i as O}from"../../../chunks/vec3.js";import{c as w}from"../../../chunks/vec3f64.js";import{t as D,b as x,a as S}from"../../../chunks/vec4.js";import{c as E,f as P}from"../../../chunks/vec4f64.js";import{projectVectorToVector as U}from"../../../geometry/projection.js";import{getReferenceEllipsoid as M}from"../../../geometry/projectionEllipsoid.js";import{create as C,width as j,copy as I,center as N,intersection as b,height as A,contains as G,intersects as H,offset as L}from"../../../geometry/support/aaBoundingRect.js";import{create as k,wrap as V}from"../../../geometry/support/ray.js";import{j as B,k as F,t as q}from"../../../chunks/sphere.js";import{angleAroundAxis as W}from"../../../geometry/support/vector.js";import{y2lat as z}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as Y}from"../state/utils/viewUtils.js";import X from"../support/debugFlags.js";import{PointGraphics as K}from"../support/debugUtils.js";import{OverlayIndex as Z}from"./interfaces.js";import{computeOverlayResolution as J}from"./Overlay.js";import{OverlayRenderer as Q}from"./OverlayRenderer.js";import{RenderRequestType as $,ValidationState as ee}from"../webgl-engine/lib/basicInterfaces.js";import{newIntersector as te}from"../webgl-engine/lib/Intersector.js";import{fromValues as re}from"../webgl-engine/lib/LocalOriginFactory.js";import{SortedRenderGeometryRenderer as se}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{removeLoadedShaderModules as ie}from"../webgl-engine/parts/requireUtils.js";import{TaskPriority as ae}from"../../support/Scheduler.js";const ne=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let oe,le=class extends t{constructor(e){super(e),this._handles=new i,this._spatialReference=null,this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._hasUnusedRenderTargets=!1,this._longitudeCyclical=null,this._latestOriginId=0,this._maxResolution=a("esri-mobile")?2048:4096,this._animationTimeLast=0}get running(){return this._placementDirty&&(this._drapeSources.size>0||this.view.graphics.length>0||X.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.surface.ready}get _isSpherical(){return this.view.state.isGlobal}get _worldToPCSRatio(){return l(this._spatialReference)&&this._spatialReference.isGeographic&&!this.view.state.isLocal?M(this._spatialReference).metersPerDegree:1}get view(){return this.surface.view}get updating(){return this.running||this.renderer.updating||this._contentUpdated}get hasHighlights(){return this.renderer.hasHighlights}get rendersOccluded(){return this.renderer.rendersOccluded}initialize(){const e=this.view;this.renderer=new Q({view:e,worldToPCSRatio:this._worldToPCSRatio,spatialReference:this._spatialReference}),this._groundIntersector=te(this.view.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this._handles.add([this.renderer.events.on("has-highlights",(()=>{this._setDrawTexturesDirty(),this.notifyChange("hasHighlights")})),this.renderer.events.on("has-water",(t=>{var r;return null==(r=e._stage)?void 0:r.renderView.setRenderParameters({hasOverlayWater:t})})),this.renderer.events.on("renders-occluded",(()=>{this._setDrawTexturesDirty(),this.notifyChange("rendersOccluded")})),this.renderer.events.on("content-changed",(()=>this._setDrawTexturesDirty())),this.renderer.events.on("textures-disposed",(()=>this.updateOverlayResult())),d((()=>{var t,r,s;return[null==(t=e.pointsOfInterest)?void 0:t.renderPointOfView,null==(r=e.pointsOfInterest)||null==(s=r.centerOnSurfaceFrequent)?void 0:s.location]}),(()=>this.setPlacementDirty())),d((()=>{var t;return null==(t=e.state)?void 0:t.pixelRatio}),(()=>this.setPlacementDirty()),u),this.surface.on("elevation-change",(()=>this.setPlacementDirty())),e.on("resize",(()=>this.setPlacementDirty())),p({preRender:e=>{this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.hasOverlays&&(this._dispatchAnimationUpdate(e),this._drawOverlayTextures(this.renderer.overlays,$.UPDATE)),this._hasUnusedRenderTargets&&this._collectUnusedRenderTargetMemory()}}),e.resourceController.scheduler.registerTask(ae.OVERLAY,this),e._stage.renderView.events.on("force-camera-for-screenshot",(e=>{this._updateOverlays(e,$.BACKGROUND),this.renderer.hasOverlays&&this._drawOverlayTextures(this.renderer.overlays,$.BACKGROUND,e)}))])}destroy(){this.renderer.dispose(),this._handles&&(this._handles.destroy(),this._handles=null),l(oe)&&(oe.hide(),oe=null)}get hasOverlays(){return this.renderer.hasOverlays}setSpatialReference(e){this._spatialReference=e,this.renderer.spatialReference=e,this._longitudeCyclical=null;const t=this.view.renderSpatialReference;l(e)&&l(t)?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this._longitudeCyclical=e.isWebMercator?new r(-20037508.342787,20037508.342787):new r(-180,180),this.renderer.longitudeCyclical=this._longitudeCyclical),this.renderer&&(this.renderer.worldToPCSRatio=this._worldToPCSRatio)):this.renderer.disposeOverlays()}get gpuMemoryUsage(){return this.renderer.gpuMemoryUsage}registerDrapeSource(e,t,r){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const s=this.renderer.createDrapeSourceRenderer(e,t,r);return this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("running"),s}registerGeometryDrapeSource(e){return this.registerDrapeSource(e,se)}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&l(e.setDrapingExtent)&&l(this._spatialReference)&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("running"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}updateOverlayResult(){var e;null==(e=this.view._stage)||e.renderView.setRenderParameters({overlays:this.renderer.overlays})}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this._setDrawTexturesDirty()}setPlacementDirty(){this._placementDirty=!0}runTask(){this._updateOverlays(this.view.state.camera,$.UPDATE)}_updateOverlays(e,t){if(!this._spatialReference)return;const r=J(e.fullWidth,e.fullHeight,this._maxResolution);this._computeOverlayExtents(e,r,ue);const s=j(ue.inner)/j(ue.outer);this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const i=this._updateOverlay(Z.INNER,ue.inner,r,1*ue.pixelRatioAdjustment,ue.mapUnitsPerPixel),a=this._updateOverlay(Z.OUTER,ue.outer,r,s*ue.pixelRatioAdjustment,ue.mapUnitsPerPixel);i!==ye.EXTENT&&a!==ye.EXTENT||(this._drapeSources.forEach((e=>this._updateDrapeSourceExtent(e))),this.surface.updateTileOverlayParams(t)),i===ye.NONE&&a===ye.NONE||this._setDrawTexturesDirty(),this._placementDirty=!1}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return ye.NONE;const a=this.renderer.overlays[e],n=a.mapUnitsPerPixel;if(a.mapUnitsPerPixel=i,a.pixelRatio=s,he(t,a.extent)&&r===a.resolution)return n===i?ye.NONE:ye.RERENDER_ONLY;I(a.extent,t),a.resolution=r;const o=N(a.extent);return a.renderLocalOrigin=re(o[0],o[1],0,"OV_"+this._latestOriginId++),ye.EXTENT}setTileParameters(e){const t=e.renderData.overlay;if(this.renderer.overlays.length>0){const r=this.renderer.overlays[Z.INNER],s=this.renderer.overlays[Z.OUTER],i=b(e.extent,this.surface.extent,pe);this._rectInsideRect(r.extent,i)||this._rectanglesOverlap(i,r.extent)||this._rectanglesOverlap(i,s.extent)?(this._setTileOverlayData(i,Z.INNER,t),this._setTileOverlayData(i,Z.OUTER,t)):(this._clearTileOverlayData(Z.INNER,t),this._clearTileOverlayData(Z.OUTER,t))}else this._clearTileOverlayData(Z.INNER,t),this._clearTileOverlayData(Z.OUTER,t)}overlayPixelSizeInMapUnits(e){if(0===this.renderer.overlays.length)return 0;const t=this.renderer.overlays[Z.INNER],r=this.renderer.overlays[Z.OUTER],s=this._pointIsInExtent(e,t.extent)?t:r;return(s.extent[2]-s.extent[0])/s.resolution}_setTileOverlayData(e,t,r){if(0===this.renderer.overlays.length)return;const s=this.renderer.overlays[t].extent,i=j(s),a=A(s);let n=e[0];if(this._longitudeCyclical){n=this._longitudeCyclical.minimalMonotonic(s[0],n);const t=this._longitudeCyclical.minimalMonotonic(s[0],e[2]);n>t&&(n=t-(e[2]-e[0]))}r.setScale(t,j(e)/i,A(e)/a),r.setOffset(t,(n-s[0])/i,(e[1]-s[1])/a)}_clearTileOverlayData(e,t){t.setScale(e,-1,-1),t.setOffset(e,-1,-1)}async reloadShaders(){ie(),await this.renderer.reloadShaders(),this._setDrawTexturesDirty(),this.runTask()}_dispatchAnimationUpdate(e){const t=_(e.time-this._animationTimeLast);(t>=this.surface.view._stage.renderView.animationTimestep||l(this.forcedAnimationTime)||this._drawTexturesDirty||this._drawTexturesAnimateDirty)&&(this.renderer.updateAnimation({dt:t,forcedTime:this.forcedAnimationTime,camera:this.view.state.camera})&&(this._drawTexturesAnimateDirty=!0),this._animationTimeLast=e.time)}_setDrawTexturesDirty(){this.renderer.hasOverlays?(this._contentUpdated=!0,this._drawTexturesDirty=!0):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s){const i=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,me,t,r);if(h(i))return!1;const a=i.origin,n=f(de,i.origin,i.direction);return this._groundIntersector.reset(a,n,e),this._groundIntersector.intersect([],null),this.view.basemapTerrain.intersect(this._groundIntersector,null,a,n),this._groundIntersector.results.min.getIntersectionPoint(s)}_findHorizonBasedPointOfInterest(e,t){let r=.5;const i=.55,a=this.view.renderCoordsHelper.getAltitude(e.eye),o=this.view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=n(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:a+l,e.aboveGround?a-l:1/0),c=e.aboveGround;if("global"===this.view.viewingMode){const t=de;B(F(q,M(this.view.spatialReference).radius+h),V(e.eye,e.viewForward),t),v(t,t,e.eye);const a=s.normalize(W(e.viewForward,t,e.viewRight))/e.fovY+.5,n=a<=0||a>=1?.5:i;r=c?n*a:a+n*(1-a)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),s=Math.tan(t),a=P(0,s,1,0),o=D(a,a,e.projectionMatrix)[1],l=n(.5+.5*o,0,1);r=1===l||0===l?.5:c?l*i:1-(1-l)*i}return!!this._intersectGroundFromView(e,.5,r,t)&&R(t,e.eye)<o.distance*o.distance}_computeOverlayExtents(e,t,r){const s=this.view.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,i=w();this._findHorizonBasedPointOfInterest(e,i)||T(i,s);const a=Math.max(.1,O(e.eye,i)),n=Y(this.view.renderCoordsHelper,s,e.eye),d=Math.PI/2-Math.abs(n-Math.PI/2);X.OVERLAY_SHOW_CENTER?(h(oe)&&(oe=new K(this.view.graphics,"red")),oe.show(i,this._renderSR)):l(oe)&&oe.hide(),this._overlaySREqualsRenderSR||U(i,this._renderSR,i,this._spatialReference);const u=this.surface.extent,p=!this._isSpherical&&l(this._spatialReference)&&this._spatialReference.isGeographic,_=p&&l(this._spatialReference)?1/M(this._spatialReference).metersPerDegree:1,m=e.perRenderPixelRatio*a*_;r.mapUnitsPerPixel=m/this._worldToPCSRatio;let y=t*m/2,f=!1,v=p?90:1/0;this._isSpherical&&l(u)&&l(this._spatialReference)&&(this._spatialReference.isWebMercator?(y/=Math.cos(z(i[1])),v=u[3]):(f=!0,y/=M(this._spatialReference).metersPerDegree,v=90),y>=v&&(y=v,i[1]=0,this._spatialReference.isWebMercator&&(i[0]=0)));let R=1;f&&(R=1/Math.max(.2,Math.cos(Math.abs(o(i[1])))),y*R>180&&(R=180/y),r.mapUnitsPerPixel*=R);const D=Math.log(2)/12;y=Math.exp(Math.round(Math.log(y)/D)*D);const E=y*R,P=32,C=.5*t/(P*E),N=.5*t/(P*y);i[0]=Math.round(i[0]*C)/C,i[1]=Math.round(i[1]*N)/N;const A=r.inner;A[0]=i[0]-E,A[1]=i[1]-y,A[2]=i[0]+E,A[3]=i[1]+y,this._isSpherical&&this._shiftExtentToFitBounds(A,1/0,v);const H=r.outer;if(6*E>j(u))I(H,c(u));else if(d<=.25*Math.PI)H[0]=A[0]-E,H[1]=A[1]-y,H[2]=A[2]+E,H[3]=A[3]+y;else{U(e.eye,this._renderSR,de,this._spatialReference),g(ce,i,de);let t=-Math.atan2(ce[1],ce[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));x(ce,ne[r],2*y),ce[0]*=R,ce[2]*=R,S(H,A,ce)}if(this._isSpherical)H[0]=this._longitudeCyclical.clamp(H[0]),H[2]=this._longitudeCyclical.clamp(H[2]),H[1]=Math.max(H[1],-v),H[3]=Math.min(H[3],v);else{const e=b(A,u,pe),t=b(H,u,_e);G(e,t)&&(H[2]=H[0],H[3]=H[1])}const L=Math.abs(A[2]-A[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,L),r.pixelRatioAdjustment=r.mapUnitsPerPixel/L}_drawOverlayTextures(e,t,r=this.view.state.camera){if(0===e.length||!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return;const s=this._drawTexturesDirty;this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1;const i=this._drawOverlay(e[Z.INNER],r),a=this._drawOverlay(e[Z.OUTER],r);i!==ee.CHANGED&&a!==ee.CHANGED||this.surface.updateTileOverlayParams($.UPDATE),this._collectUnusedRenderTargetMemory(),this.updateOverlayResult(),s?(this.surface.requestRender(t),t===$.UPDATE&&this.surface.requestUpdate()):this.surface.requestRender($.BACKGROUND)}_drawOverlay(e,t){return this._longitudeCyclical?e.setupGeometryViewsCyclical(this._longitudeCyclical):e.setupGeometryViewsDirect(),e.draw(this.renderer,t.pixelRatio)}_collectUnusedRenderTargetMemory(){if(this._hasUnusedRenderTargets=!1,this.renderer.hasOverlays){const e=performance.now();this._hasUnusedRenderTargets=this.renderer.collectUnusedRenderTargetMemory(e)}}_rectanglesOverlap(e,t){return!h(e)&&(this._longitudeCyclical?(this._longitudeCyclical.contains(t[0],t[2],e[0])||this._longitudeCyclical.contains(t[0],t[2],e[2])||this._longitudeCyclical.contains(e[0],e[2],t[0]))&&!(e[1]>t[3]||e[3]<t[1]):H(e,t))}_rectInsideRect(e,t){return!h(t)&&(this._longitudeCyclical?this._longitudeCyclical.contains(e[0],e[2],t[0])&&this._longitudeCyclical.contains(e[0],e[2],t[2])&&t[1]>e[1]&&t[3]<e[3]:G(e,t))}_pointIsInExtent(e,t){if(this._longitudeCyclical)return this._longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),L(e,s,i)}get test(){return{renderer:this.renderer,update:()=>this.runTask()}}};function he(e,t){const r=1e-5,s=X.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([m()],le.prototype,"_spatialReference",void 0),e([m({readOnly:!0})],le.prototype,"running",null),e([m()],le.prototype,"_placementDirty",void 0),e([m()],le.prototype,"_contentUpdated",void 0),e([m()],le.prototype,"_isSpherical",null),e([m()],le.prototype,"_worldToPCSRatio",null),e([m()],le.prototype,"renderer",void 0),e([m({constructOnly:!0})],le.prototype,"surface",void 0),e([m({readOnly:!0,aliasOf:"surface.suspended"})],le.prototype,"suspended",void 0),e([m({readOnly:!0})],le.prototype,"updating",null),e([m({type:Boolean})],le.prototype,"hasHighlights",null),e([m({type:Boolean})],le.prototype,"rendersOccluded",null),le=e([y("esri.views.3d.terrain.OverlayManager")],le);const ce=E(),de=w(),ue={inner:C(),outer:C(),mapUnitsPerPixel:0,pixelRatioAdjustment:1},pe=C(),_e=C(),me=k();var ye;!function(e){e[e.NONE=0]="NONE",e[e.EXTENT=1]="EXTENT",e[e.RERENDER_ONLY=2]="RERENDER_ONLY"}(ye||(ye={}));export{le as OverlayManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/Evented.js";import s from"../../../core/Handles.js";import{someMap as i}from"../../../core/MapUtils.js";import{releaseMaybe as o,disposeMaybe as a,isSome as n,isNone as d,unwrapOr as h}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{watch as l,syncAndInitial as u,on as p}from"../../../core/reactiveUtils.js";import{someSet as _}from"../../../core/SetUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{q as R,f as y}from"../../../chunks/mat4.js";import{f as T}from"../../../chunks/vec3f64.js";import{ViewingMode as f}from"../../ViewingMode.js";import{DrapeTargetType as b,DrapeSourceType as S}from"../layers/interfaces.js";import v from"../support/debugFlags.js";import{OverlayIndex as w,RenderTargetType as x}from"./interfaces.js";import{Overlay as O}from"./Overlay.js";import{OverlayFramebufferObject as D}from"./OverlayFramebufferObject.js";import{OverlayRenderTarget as j}from"./OverlayRenderTarget.js";import{ShaderTechniqueRepository as E}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{autoDispose as A,AutoDisposableMixin as P}from"../webgl-engine/lib/AutoDisposable.js";import{TransparencyPassType as C,UpdatePolicy as F}from"../webgl-engine/lib/basicInterfaces.js";import{Camera as M}from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as q}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as I,createQuadVAO as U}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as W}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as L}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as V}from"../webgl-engine/lib/RenderContext.js";import{RenderPass as H}from"../webgl-engine/lib/RenderPass.js";import{RenderSlot as B}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as N}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as k}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{SSAOHelper as G}from"../webgl-engine/lib/SSAOHelper.js";import{TextureTechnique as z}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as Y}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as X}from"../webgl-engine/lighting/Lightsources.js";import{StippleTextureRepository as Q}from"../webgl-engine/materials/StippleTextureRepository.js";import{AlphaMode as J,CompositingFunction as K}from"../webgl-engine/shaders/CompositingTechniqueConfiguration.js";import{ImmediateTask as Z,TaskPriority as $,noBudget as ee}from"../../support/Scheduler.js";import{ClearBufferBit as re,PrimitiveType as te,TextureType as se,PixelFormat as ie,PixelType as oe,TextureSamplingMode as ae}from"../../webgl/enums.js";import{Texture as ne}from"../../webgl/Texture.js";import{vertexCount as de}from"../../webgl/Util.js";let he=class extends(P(r)){constructor(e){super(e),this._overlays=null,this._overlayRenderTarget=null,this._hasHighlights=!1,this._rendersOccluded=!1,this._hasWater=!1,this._handles=new s,this._frameTask=Z,this._drapeSourceRenderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedDrapeSourceRenderers=new c,this._rctx=null,this._materialRepository=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.worldToPCSRatio=1,this.events=new t,this.longitudeCyclical=null}get _bindParameters(){return this._renderContext.bindParameters}get rctx(){return this._rctx}get materialRepository(){return this._materialRepository}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initialize(){const e=this.view._stage.renderView;this._rctx=e.renderingContext;const r=e.waterTextureRepository;this._stippleTextureRepository=new Q(e.renderingContext),this._shaderTechniqueRepository=new E({rctx:this._rctx,viewingMode:f.Local,stippleTextureRepository:this._stippleTextureRepository,waterTextureRepository:r}),this._renderContext=new V(this._rctx,new N(this._rctx,this.view.state.viewingMode),new G(this._shaderTechniqueRepository,this._rctx,(()=>{}))),this._handles.add([l((()=>r.updating),(()=>this.events.emit("content-changed")),u),l((()=>this.spatialReference),(e=>this._localOriginFactory=new W(e)),u),p((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materialRepository=new q(e.textureRepository,this._shaderTechniqueRepository,(e=>{(e.renderOccluded&ge)>0!==this._rendersOccluded&&this._updateRendersOccluded(),this.events.emit("content-changed"),this.notifyChange("updating")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=B.DRAPED_MATERIAL,this._bindParameters.highlightDepthTexture=I(this._rctx),this._bindParameters.camera=pe,this._bindParameters.transparencyPassType=C.NONE,this._bindParameters.lighting.groundLightingFactor=1,this._bindParameters.lighting.globalFactor=0,this._bindParameters.lighting.set([new X(T(1,1,1))]),this._frameTask=this.view.resourceController.scheduler.registerTask($.STAGE,this),this._handles.add(this._frameTask)}dispose(){this._handles.destroy(),this._drapeSourceRenderers.forEach((e=>e.destroy())),this._drapeSourceRenderers.clear(),this._debugTextureTechnique=o(this._debugTextureTechnique),this._debugPatternTexture=a(this._debugPatternTexture),this._bindParameters.highlightDepthTexture=a(this._bindParameters.highlightDepthTexture),this._shaderTechniqueRepository=a(this._shaderTechniqueRepository),this._temporaryFBO=a(this._temporaryFBO),this._quadVAO=a(this._quadVAO),this.disposeOverlays()}get updating(){return this._sortedDrapeSourceRenderersDirty||this._frameTask.updating||i(this._drapeSourceRenderers,(e=>e.updating))}get hasOverlays(){return n(this._overlays)&&n(this._overlayRenderTarget)}get gpuMemoryUsage(){return n(this._overlayRenderTarget)?this._overlayRenderTarget.gpuMemoryUsage:0}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,k)}createDrapeSourceRenderer(e,r,t){const s=this._drapeSourceRenderers.get(e);n(s)&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._drapeSourceRenderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this._handles.add(l((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(d(e))return;const r=this._drapeSourceRenderers.get(e);d(r)||(this._sortedDrapeSourceRenderersDirty=!0,this._drapeSourceRenderers.delete(e),this._handles.remove(e),r.destroy())}collectUnusedRenderTargetMemory(e){let r=!1;if(n(this._overlayRenderTarget))for(const t of this._overlayRenderTarget.renderTargets){const s=this.overlays[0].validTargets[t.type]||!this.overlays[1].validTargets[t.type];r=this._overlayRenderTarget.validateUsageForTarget(s,t,e)||r}return r}get overlays(){return h(this._overlays,[])}ensureDrapeTargets(e){n(this._overlays)&&this._overlays.forEach((r=>{r.hasTargetWithoutRasterImage=_(e,(e=>e.drapeTargetType===b.WithoutRasterImage))}))}ensureDrapeSources(e){n(this._overlays)&&this._overlays.forEach((r=>{r.hasDrapedFeatureSource=_(e,(e=>e.drapeSourceType===S.Features)),r.hasDrapedRasterSource=_(e,(e=>e.drapeSourceType===S.RasterImage))}))}ensureOverlays(e,r){d(this._overlays)&&(this._overlayRenderTarget=new j(this._rctx),this._overlays=[new O(w.INNER,this._overlayRenderTarget),new O(w.OUTER,this._overlayRenderTarget)]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r)}disposeOverlays(){this._overlays=null,this._overlayRenderTarget=a(this._overlayRenderTarget),this.events.emit("textures-disposed")}get running(){return this.updating}runTask(e,r=(()=>!0)){this._frameTask.processQueue(e),e.done||this._processDrapeSources(e,r)}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._drapeSourceRenderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._updateSortedDrapeSourceRenderers(),t&&(n(this._overlays)&&0===this._drapeSourceRenderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.events.emit("content-changed"),this._updateHasHighlights(),this._updateRendersOccluded(),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(ee,(e=>e.updatePolicy===F.SYNC))}isEmpty(){let e=!0;for(const r of this._drapeSourceRenderers.values())if(e=e&&r.isEmpty,!e)break;return e&&!v.OVERLAY_DRAW_DEBUG_TEXTURE}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccluded(){return this._rendersOccluded}updateAnimation(e){let r=!1;return this._drapeSourceRenderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawTarget(e,r,t){const s=e.canvasGeometries;if(0===s.numViews)return!1;this._screenToWorldRatio=t*e.mapUnitsPerPixel;const i=r.renderPass;if(this.isEmpty()||i===H.MATERIAL_HIGHLIGHT&&!this.hasHighlights||i===H.MATERIAL_NORMAL&&!this.hasWater||!e.hasSomeSizedView())return!1;const o=r.fbo;if(!o.isValid())return!1;const a=2*e.resolution,d=e.resolution;o.resize(a,d);const h=this._rctx;pe.pixelRatio=e.pixelRatio*t,this._renderContext.pass=i,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=i===H.MATERIAL_NORMAL?B.DRAPED_WATER:B.DRAPED_MATERIAL,e.applyViewport(this._rctx),o.bind(h),e.index===w.INNER&&(h.setClearColor(0,0,0,0),h.clearSafe(re.COLOR_BUFFER_BIT));const c=r.type===x.ColorNoRasterImage?ce.ExcludeRasterImage:r.type===x.Occluded?ce.OccludedOnly:ce.Normal;if(c===ce.OccludedOnly&&(this._renderContext.renderOccludedMask=ge),v.OVERLAY_DRAW_DEBUG_TEXTURE&&c!==ce.OccludedOnly)for(let n=0;n<s.numViews;n++)this._setViewParameters(s.extents[n],e,pe),this._drawDebugTexture(e.resolution,ue[e.index]);return this._drapeSourceRenderers.size>0&&this._sortedDrapeSourceRenderers.forAll((({drapeSource:r,renderer:t})=>{if(c===ce.ExcludeRasterImage&&r.drapeSourceType===S.RasterImage)return;const{fullOpacity:l}=r,u=n(l)&&l<1&&i===H.MATERIAL;u&&(this.bindTemporaryFramebuffer(this._rctx,a,d),h.clearSafe(re.COLOR_BUFFER_BIT));for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],e,pe),t.render(this._renderContext,this._bindParameters);u&&n(this._temporaryFBO)&&(o.bind(h),this.view._stage.renderView.compositingHelper.composite(this._renderContext.bindParameters,this._temporaryFBO.getTexture(),J.PremultipliedAlpha,l,K.OverlayWithTransparency,e.index))})),h.bindFramebuffer(null),o.generateMipMap(),this._renderContext.resetRenderOccludedMask(),!0}bindTemporaryFramebuffer(e,r,t){d(this._temporaryFBO)&&(this._temporaryFBO=new D(e,!1)),this._temporaryFBO.resize(r,t),this._temporaryFBO.bind(e)}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}intersect(e,r,t,s){let i=0;for(const a of this._drapeSourceRenderers.values()){var o;i=null!=(o=null==a.intersect?void 0:a.intersect(e,r,t,s,i))?o:i}}_updateSortedDrapeSourceRenderers(){if(!this._sortedDrapeSourceRenderersDirty)return;if(this._sortedDrapeSourceRenderersDirty=!1,this._sortedDrapeSourceRenderers.clear(),0===this._drapeSourceRenderers.size)return;const e=this.view.map.allLayers;this._drapeSourceRenderers.forEach(((r,t)=>{const s=e.indexOf(t.layer);this._sortedDrapeSourceRenderers.push(new le(t,r,s<0?1/0:s))})),this._sortedDrapeSourceRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r,t){t.viewport[0]=t.viewport[1]=0,t.viewport[2]=t.viewport[3]=r.resolution,R(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),y(t.viewMatrix,[-e[0],-e[1],0]),this._bindParameters.camera=t}_updateHasWater(){const e=i(this._drapeSourceRenderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_updateHasHighlights(){const e=i(this._drapeSourceRenderers,(e=>e.hasHighlights));e!==this._hasHighlights&&(this._hasHighlights=e,this.events.emit("has-highlights",e))}_updateRendersOccluded(){const e=i(this._drapeSourceRenderers,(e=>e.rendersOccluded));e!==this._rendersOccluded&&(this._rendersOccluded=e,this.events.emit("renders-occluded",e))}_drawDebugTexture(e,r){this._ensureDebugPatternResources(e,e);const t=this._rctx,s=t.bindTechnique(this._debugTextureTechnique);s.setUniform4f("uColor",r[0],r[1],r[2],1),s.bindTexture("tex",this._debugPatternTexture),t.bindVAO(this._quadVAO),t.drawArrays(te.TRIANGLE_STRIP,0,de(this._quadVAO,"geometry"))}_ensureDebugPatternResources(e,r){if(this._debugPatternTexture)return;const t=new Uint8Array(e*r*4);let s=0;for(let o=0;o<r;o++)for(let i=0;i<e;i++){const a=Math.floor(i/10),n=Math.floor(o/10);a<2||n<2||10*a>e-20||10*n>r-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&a&&1&n?1&i^1&o?0:255:1&a^1&n?0:128)}this._debugPatternTexture=new ne(this._rctx,{target:se.TEXTURE_2D,pixelFormat:ie.RGBA,dataType:oe.UNSIGNED_BYTE,samplingMode:ae.NEAREST,width:e,height:r},t);const i=new Y;i.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire(z,i),this._quadVAO=U(this._rctx)}get test(){return{drapeSourceRenderers:this._drapeSourceRenderers,getDrapeSourceRenderer:e=>this._drapeSourceRenderers.get(e)}}};var ce;e([g()],he.prototype,"_frameTask",void 0),e([g()],he.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([A()],he.prototype,"_shaderTechniqueRepository",void 0),e([A()],he.prototype,"_stippleTextureRepository",void 0),e([g({constructOnly:!0})],he.prototype,"view",void 0),e([g()],he.prototype,"worldToPCSRatio",void 0),e([g()],he.prototype,"spatialReference",void 0),e([g({type:Boolean,readOnly:!0})],he.prototype,"updating",null),he=e([m("esri.views.3d.terrain.OverlayRenderer")],he),function(e){e[e.Normal=0]="Normal",e[e.OccludedOnly=1]="OccludedOnly",e[e.ExcludeRasterImage=2]="ExcludeRasterImage"}(ce||(ce={}));class le{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const ue=[[1,.5,.5],[.5,.5,1]],pe=new M;pe.near=1,pe.far=1e4,pe.relativeElevation=null;const _e=-2,ge=L.OccludeAndTransparent;export{_e as DRAPED_Z,ce as DrawPassOption,he as OverlayRenderer,ge as overlayRenderOccludedFlag};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/Evented.js";import s from"../../../core/Handles.js";import{someMap as i}from"../../../core/MapUtils.js";import{releaseMaybe as o,disposeMaybe as a,isSome as n,isNone as d,unwrapOr as h}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{watch as l,syncAndInitial as u,on as p}from"../../../core/reactiveUtils.js";import{someSet as _}from"../../../core/SetUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{q as y,f as R}from"../../../chunks/mat4.js";import{f as T}from"../../../chunks/vec3f64.js";import{ViewingMode as f}from"../../ViewingMode.js";import{DrapeTargetType as b,DrapeSourceType as S}from"../layers/interfaces.js";import v from"../support/debugFlags.js";import{OverlayIndex as w,RenderTargetType as x}from"./interfaces.js";import{Overlay as O}from"./Overlay.js";import{OverlayFramebufferObject as D}from"./OverlayFramebufferObject.js";import{OverlayRenderTarget as j}from"./OverlayRenderTarget.js";import{ShaderTechniqueRepository as E}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{autoDispose as A,AutoDisposableMixin as P}from"../webgl-engine/lib/AutoDisposable.js";import{TransparencyPassType as C,UpdatePolicy as F}from"../webgl-engine/lib/basicInterfaces.js";import{Camera as M}from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as q}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as I,createQuadVAO as U}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as W}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as L}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as V}from"../webgl-engine/lib/RenderContext.js";import{RenderPass as H}from"../webgl-engine/lib/RenderPass.js";import{RenderSlot as B}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as N}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as k}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{SSAOHelper as G}from"../webgl-engine/lib/SSAOHelper.js";import{TextureTechnique as z}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as Y}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as X}from"../webgl-engine/lighting/Lightsources.js";import{StippleTextureRepository as Q}from"../webgl-engine/materials/StippleTextureRepository.js";import{AlphaMode as J,CompositingFunction as K}from"../webgl-engine/shaders/CompositingTechniqueConfiguration.js";import{ImmediateTask as Z,TaskPriority as $,noBudget as ee}from"../../support/Scheduler.js";import{ClearBufferBit as re,PrimitiveType as te,TextureType as se,PixelFormat as ie,PixelType as oe,TextureSamplingMode as ae}from"../../webgl/enums.js";import{Texture as ne}from"../../webgl/Texture.js";import{vertexCount as de}from"../../webgl/Util.js";let he=class extends(P(r)){constructor(e){super(e),this._overlays=null,this._overlayRenderTarget=null,this._hasHighlights=!1,this._rendersOccluded=!1,this._hasWater=!1,this._handles=new s,this._frameTask=Z,this._drapeSourceRenderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedDrapeSourceRenderers=new c,this._rctx=null,this._materialRepository=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.worldToPCSRatio=1,this.events=new t,this.longitudeCyclical=null}get _bindParameters(){return this._renderContext.bindParameters}get rctx(){return this._rctx}get materialRepository(){return this._materialRepository}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initialize(){const e=this.view._stage.renderView;this._rctx=e.renderingContext;const r=e.waterTextureRepository;this._stippleTextureRepository=new Q(e.renderingContext),this._shaderTechniqueRepository=new E({rctx:this._rctx,viewingMode:f.Local,stippleTextureRepository:this._stippleTextureRepository,waterTextureRepository:r}),this._renderContext=new V(this._rctx,new N(this._rctx,this.view.state.viewingMode),new G(this._shaderTechniqueRepository,this._rctx,(()=>{}))),this._handles.add([l((()=>r.updating),(()=>this.events.emit("content-changed")),u),l((()=>this.spatialReference),(e=>this._localOriginFactory=new W(e)),u),p((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materialRepository=new q(e.textureRepository,this._shaderTechniqueRepository,(e=>{(e.renderOccluded&ge)>0!==this._rendersOccluded&&this._updateRendersOccluded(),this.events.emit("content-changed"),this.notifyChange("updating")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=B.DRAPED_MATERIAL,this._bindParameters.highlightDepthTexture=I(this._rctx),this._bindParameters.camera=pe,this._bindParameters.transparencyPassType=C.NONE,this._bindParameters.lighting.groundLightingFactor=1,this._bindParameters.lighting.globalFactor=0,this._bindParameters.lighting.set([new X(T(1,1,1))]),this._frameTask=this.view.resourceController.scheduler.registerTask($.STAGE,this),this._handles.add(this._frameTask)}dispose(){this._handles.destroy(),this._drapeSourceRenderers.forEach((e=>e.destroy())),this._drapeSourceRenderers.clear(),this._debugTextureTechnique=o(this._debugTextureTechnique),this._debugPatternTexture=a(this._debugPatternTexture),this._bindParameters.highlightDepthTexture=a(this._bindParameters.highlightDepthTexture),this._shaderTechniqueRepository=a(this._shaderTechniqueRepository),this._temporaryFBO=a(this._temporaryFBO),this._quadVAO=a(this._quadVAO),this.disposeOverlays()}get updating(){return this._sortedDrapeSourceRenderersDirty||this._frameTask.updating||i(this._drapeSourceRenderers,(e=>e.updating))}get hasOverlays(){return n(this._overlays)&&n(this._overlayRenderTarget)}get gpuMemoryUsage(){return n(this._overlayRenderTarget)?this._overlayRenderTarget.gpuMemoryUsage:0}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,k)}createDrapeSourceRenderer(e,r,t){const s=this._drapeSourceRenderers.get(e);n(s)&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._drapeSourceRenderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this._handles.add(l((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(d(e))return;const r=this._drapeSourceRenderers.get(e);d(r)||(this._sortedDrapeSourceRenderersDirty=!0,this._drapeSourceRenderers.delete(e),this._handles.remove(e),r.destroy())}collectUnusedRenderTargetMemory(e){let r=!1;if(n(this._overlayRenderTarget))for(const t of this._overlayRenderTarget.renderTargets){const s=this.overlays[0].validTargets[t.type]||!this.overlays[1].validTargets[t.type];r=this._overlayRenderTarget.validateUsageForTarget(s,t,e)||r}return r}get overlays(){return h(this._overlays,[])}ensureDrapeTargets(e){n(this._overlays)&&this._overlays.forEach((r=>{r.hasTargetWithoutRasterImage=_(e,(e=>e.drapeTargetType===b.WithoutRasterImage))}))}ensureDrapeSources(e){n(this._overlays)&&this._overlays.forEach((r=>{r.hasDrapedFeatureSource=_(e,(e=>e.drapeSourceType===S.Features)),r.hasDrapedRasterSource=_(e,(e=>e.drapeSourceType===S.RasterImage))}))}ensureOverlays(e,r){d(this._overlays)&&(this._overlayRenderTarget=new j(this._rctx),this._overlays=[new O(w.INNER,this._overlayRenderTarget),new O(w.OUTER,this._overlayRenderTarget)]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r)}disposeOverlays(){this._overlays=null,this._overlayRenderTarget=a(this._overlayRenderTarget),this.events.emit("textures-disposed")}get running(){return this.updating}runTask(e,r=(()=>!0)){this._frameTask.processQueue(e),e.done||this._processDrapeSources(e,r)}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._drapeSourceRenderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._updateSortedDrapeSourceRenderers(),t&&(n(this._overlays)&&0===this._drapeSourceRenderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.events.emit("content-changed"),this._updateHasHighlights(),this._updateRendersOccluded(),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(ee,(e=>e.updatePolicy===F.SYNC))}isEmpty(){let e=!0;for(const r of this._drapeSourceRenderers.values())if(e=e&&r.isEmpty,!e)break;return e&&!v.OVERLAY_DRAW_DEBUG_TEXTURE}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccluded(){return this._rendersOccluded}updateAnimation(e){let r=!1;return this._drapeSourceRenderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawTarget(e,r,t){const s=e.canvasGeometries;if(0===s.numViews)return!1;this._screenToWorldRatio=t*e.mapUnitsPerPixel;const i=r.renderPass;if(this.isEmpty()||i===H.MATERIAL_HIGHLIGHT&&!this.hasHighlights||i===H.MATERIAL_NORMAL&&!this.hasWater||!e.hasSomeSizedView())return!1;const o=r.fbo;if(!o.isValid())return!1;const a=2*e.resolution,d=e.resolution;o.resize(a,d);const h=this._rctx;pe.pixelRatio=e.pixelRatio*t,this._renderContext.pass=i,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=i===H.MATERIAL_NORMAL?B.DRAPED_WATER:B.DRAPED_MATERIAL,e.applyViewport(this._rctx),o.bind(h),e.index===w.INNER&&(h.setClearColor(0,0,0,0),h.clearSafe(re.COLOR_BUFFER_BIT));const c=r.type===x.ColorNoRasterImage?ce.ExcludeRasterImage:r.type===x.Occluded?ce.OccludedOnly:ce.Normal;if(c===ce.OccludedOnly&&(this._renderContext.renderOccludedMask=ge),v.OVERLAY_DRAW_DEBUG_TEXTURE&&c!==ce.OccludedOnly)for(let n=0;n<s.numViews;n++)this._setViewParameters(s.extents[n],e,pe),this._drawDebugTexture(e.resolution,ue[e.index]);return this._drapeSourceRenderers.size>0&&this._sortedDrapeSourceRenderers.forAll((({drapeSource:r,renderer:t})=>{if(c===ce.ExcludeRasterImage&&r.drapeSourceType===S.RasterImage)return;const{fullOpacity:l}=r,u=n(l)&&l<1&&i===H.MATERIAL;u&&(this.bindTemporaryFramebuffer(this._rctx,a,d),h.clearSafe(re.COLOR_BUFFER_BIT));for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],e,pe),t.render(this._renderContext,this._bindParameters);u&&n(this._temporaryFBO)&&(o.bind(h),this.view._stage.renderView.compositingHelper.composite(this._renderContext.bindParameters,this._temporaryFBO.getTexture(),J.PremultipliedAlpha,l,K.OverlayWithTransparency,e.index))})),h.bindFramebuffer(null),o.generateMipMap(),this._renderContext.resetRenderOccludedMask(),!0}bindTemporaryFramebuffer(e,r,t){d(this._temporaryFBO)&&(this._temporaryFBO=new D(e,!1)),this._temporaryFBO.resize(r,t),this._temporaryFBO.bind(e)}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){let i=0;for(const a of this._drapeSourceRenderers.values()){var o;i=null!=(o=null==a.intersect?void 0:a.intersect(e,r,t,s,i))?o:i}}_updateSortedDrapeSourceRenderers(){if(!this._sortedDrapeSourceRenderersDirty)return;if(this._sortedDrapeSourceRenderersDirty=!1,this._sortedDrapeSourceRenderers.clear(),0===this._drapeSourceRenderers.size)return;const e=this.view.map.allLayers;this._drapeSourceRenderers.forEach(((r,t)=>{const s=e.indexOf(t.layer);this._sortedDrapeSourceRenderers.push(new le(t,r,s<0?1/0:s))})),this._sortedDrapeSourceRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r,t){t.viewport[0]=t.viewport[1]=0,t.viewport[2]=t.viewport[3]=r.resolution,y(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),R(t.viewMatrix,[-e[0],-e[1],0]),this._bindParameters.camera=t}_updateHasWater(){const e=i(this._drapeSourceRenderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_updateHasHighlights(){const e=i(this._drapeSourceRenderers,(e=>e.hasHighlights));e!==this._hasHighlights&&(this._hasHighlights=e,this.events.emit("has-highlights",e))}_updateRendersOccluded(){const e=i(this._drapeSourceRenderers,(e=>e.rendersOccluded));e!==this._rendersOccluded&&(this._rendersOccluded=e,this.events.emit("renders-occluded",e))}_drawDebugTexture(e,r){this._ensureDebugPatternResources(e,e);const t=this._rctx,s=t.bindTechnique(this._debugTextureTechnique);s.setUniform4f("uColor",r[0],r[1],r[2],1),s.bindTexture("tex",this._debugPatternTexture),t.bindVAO(this._quadVAO),t.drawArrays(te.TRIANGLE_STRIP,0,de(this._quadVAO,"geometry"))}_ensureDebugPatternResources(e,r){if(this._debugPatternTexture)return;const t=new Uint8Array(e*r*4);let s=0;for(let o=0;o<r;o++)for(let i=0;i<e;i++){const a=Math.floor(i/10),n=Math.floor(o/10);a<2||n<2||10*a>e-20||10*n>r-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&a&&1&n?1&i^1&o?0:255:1&a^1&n?0:128)}this._debugPatternTexture=new ne(this._rctx,{target:se.TEXTURE_2D,pixelFormat:ie.RGBA,dataType:oe.UNSIGNED_BYTE,samplingMode:ae.NEAREST,width:e,height:r},t);const i=new Y;i.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire(z,i),this._quadVAO=U(this._rctx)}get test(){return{drapeSourceRenderers:this._drapeSourceRenderers,getDrapeSourceRenderer:e=>this._drapeSourceRenderers.get(e)}}};var ce;e([g()],he.prototype,"_frameTask",void 0),e([g()],he.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([A()],he.prototype,"_shaderTechniqueRepository",void 0),e([A()],he.prototype,"_stippleTextureRepository",void 0),e([g({constructOnly:!0})],he.prototype,"view",void 0),e([g()],he.prototype,"worldToPCSRatio",void 0),e([g()],he.prototype,"spatialReference",void 0),e([g({type:Boolean,readOnly:!0})],he.prototype,"updating",null),he=e([m("esri.views.3d.terrain.OverlayRenderer")],he),function(e){e[e.Normal=0]="Normal",e[e.OccludedOnly=1]="OccludedOnly",e[e.ExcludeRasterImage=2]="ExcludeRasterImage"}(ce||(ce={}));class le{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const ue=[[1,.5,.5],[.5,.5,1]],pe=new M;pe.near=1,pe.far=1e4,pe.relativeElevation=null;const _e=-2,ge=L.OccludeAndTransparent;export{_e as DRAPED_Z,ce as DrawPassOption,he as OverlayRenderer,ge as overlayRenderOccludedFlag};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{equals as e}from"../../../core/arrayUtils.js";import{lerp as t}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,mapOr as o}from"../../../core/maybe.js";import{empty as s}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as n}from"../../../geometry/support/aaBoundingRect.js";import"../../../geometry/support/Ellipsoid.js";import{glLayout as a}from"../support/buffer/glUtil.js";import{sampleElevationOr0 as l}from"./ElevationData.js";import{GeometryState as u,neighborEdgeIndices as h,oppositeEdge as m,eps as d,neighborCornerIndices as c,oppositeCorner as g}from"./GeometryState.js";import"./interfaces.js";import{LayerClass as f}from"./LayerClass.js";import{PatchGeometry as p,releaseGeometry as y}from"./PatchGeometry.js";import{internalAssert as x}from"./terrainUtils.js";import{TextureFader as v,ActivationTime as _}from"./TextureFader.js";export{ActivationTime}from"./TextureFader.js";import"./Tile.js";import D from"./TileOverlayData.js";import{fallsWithinLayer as S}from"./tileUtils.js";import{Default3D as b}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{BufferObject as G}from"../../webgl/BufferObject.js";import{VertexArrayObject as T}from"../../webgl/VertexArrayObject.js";class L{constructor(){this.geometryInfo=new p,this.intersectionData=null,this.geometryState=null,this._textureRef=new v((()=>this.tile.surface.textureFadeDuration)),this.overlay=new D,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1}init(e){this.tile=e,this.clear();const t=this.geometryInfo;t.indices=null,t.vertexAttributes=null,s(t.boundingBox),t.numSurfaceIndices=0,t.indexCount=0,t.numVerticesPerSide=0,this.intersectionData=null,this.geometryState=new u,this.localOrigin=null,this.overlay.clear()}clear(){const e=this.
|
|
5
|
+
import{equals as e}from"../../../core/arrayUtils.js";import{lerp as t}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,mapOr as o}from"../../../core/maybe.js";import{empty as s}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as n}from"../../../geometry/support/aaBoundingRect.js";import"../../../geometry/support/Ellipsoid.js";import{glLayout as a}from"../support/buffer/glUtil.js";import{sampleElevationOr0 as l}from"./ElevationData.js";import{GeometryState as u,neighborEdgeIndices as h,oppositeEdge as m,eps as d,neighborCornerIndices as c,oppositeCorner as g}from"./GeometryState.js";import"./interfaces.js";import{LayerClass as f}from"./LayerClass.js";import{PatchGeometry as p,releaseGeometry as y}from"./PatchGeometry.js";import{internalAssert as x}from"./terrainUtils.js";import{TextureFader as v,ActivationTime as _}from"./TextureFader.js";export{ActivationTime}from"./TextureFader.js";import"./Tile.js";import D from"./TileOverlayData.js";import{fallsWithinLayer as S}from"./tileUtils.js";import{Default3D as b}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{BufferObject as G}from"../../webgl/BufferObject.js";import{VertexArrayObject as T}from"../../webgl/VertexArrayObject.js";class L{constructor(){this.geometryInfo=new p,this.intersectionData=null,this.geometryState=null,this._textureRef=new v((()=>this.tile.surface.textureFadeDuration)),this.overlay=new D,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1}init(e){this.tile=e,this.clear();const t=this.geometryInfo;t.indices=null,t.vertexAttributes=null,s(t.boundingBox),t.numSurfaceIndices=0,t.indexCount=0,t.numVerticesPerSide=0,this.intersectionData=null,this.geometryState=new u,this.localOrigin=null,this.overlay.clear()}clear(){const e=this._releaseGeometry();return this.releaseTexture(),this._textureRef.clear(),e}updateGeometryIfChanged(e,t){const r=this.updateGeometryStateAndPrepareForGeometryGeneration(t);this._hasGeometry=!0;return this.updateNeighborDataAndGeometryIfNeeded(r,e)}updateNeighborDataAndGeometryIfNeeded(e=!1,t=this.vao.context){const r=this._updateNeighborData(),i=e||this._geometryStateChangedSinceLastUpdate||r;return i&&(this._updateGeometry(t),this._geometryStateChangedSinceLastUpdate=!1),i}_calculateEdgeResolution(e,t){const o=this.tile,s=this.geometryState.numVerticesPerSide-1;if(!o.surface.isGlobal){const t=o.surface.extent;if(r(t)&&(0===e&&o.extent[3]>t[3]||1===e&&o.extent[2]>t[2]||2===e&&o.extent[1]<t[1]||3===e&&o.extent[0]<t[0]))return s}const n=o.level,a=h[e],l=t||o.findNeighborTile(a,(e=>e.isLoaded||e.level===n));var u;if(!l||l.isLeaf&&!l.isLoaded)return x(i(null==(u=o.surface)?void 0:u.rootTiles)||o.surface.updatingRootTiles||!o.shouldHaveNeighbor(a)),s;if(l.isLoaded){const t=l,r=t.renderData.geometryState,i=n-t.level;if(0===i){const e=r.numVerticesPerSide-1;return Math.max(e,s)}const o=2**i,a=r.neighborData.edgeResolutions[(e+2)%4]/o;return Math.max(1,a)}x(!l.isLeaf);let d=s;return l.forAllSubtreeOnSide(m(a),(e=>e===o||(e.isLoaded?(d=Math.max(d,2**(e.level-n)),!0):(x(!e.isLeaf),!1)))),d}_updateNeighborData(){const e=this.tile,r=t=>t.isLoaded||t.level===e.level,i=e=>e.isLoaded,o=[null,null,null,null],s=[null,null,null,null];(()=>{for(let t=0;t<4;++t){const i=e.findNeighborTile(h[t],r);o[t]=i,s[t]=null!=i&&i.isLoaded?i:null}})();const n=[null,null,null,null];(()=>{for(let t=0;t<4;++t)n[t]=e.findNeighborTile(c[t],i)})();const a=this.geometryState.neighborData;let u=!1;(()=>{for(let t=0;t<4;++t){const r=a.edgeResolutions[t],i=o[t],s=this._calculateEdgeResolution(t,i);a.edgeResolutions[t]=s,r!==s&&(u=!0,i&&i!==e&&!i.isLoaded&&i.level===e.level&&(a.modifiedEdgeResolutions[t]=!0))}})();(()=>{const r=[null,null,null,null],i=(i,o)=>{let s=1/0;for(let t=0;t<4;++t){const o=c[t],n=i[t];if(n){const i=n.findCorner(g(o),(t=>(null==t?void 0:t.isLoaded)||t===e));r[t]=i,s=Math.min(s,i.level)}else r[t]=null}for(let m=0;m<4;++m){const i=r[(m+3)%4],s=r[m];if(i&&i.level<e.level&&i===s){const r=i,s=1==(1&m),n=(e.getNeighborEdgeStartVertexIndex(m,r)+(0===o||1===o&&!s||3===o&&s?1:0))/2**(e.level-r.level),a=s?0===o||1===o?r.extent[0]:r.extent[2]:t(r.extent[0],r.extent[2],n),u=s?t(r.extent[1],r.extent[3],n):0===o||3===o?r.extent[1]:r.extent[3];return l(a,u,r.renderData.geometryState.samplerData)}}let n=0,a=0;for(let e=0;e<4;++e){const t=r[e];if(t&&t.level===s){var u,h;const r=0===e||1===e,i=0===e||3===e,o=t.extent;a+=l(o[r?0:2],o[i?1:3],null==(u=t.renderData)||null==(h=u.geometryState)?void 0:h.samplerData),n++}}return n?a/n:0},o=this.geometryState.neighborData.cornerElevations,a=(e,t)=>{const r=i(t,e);return o[e]!==r&&(o[e]=r,!0)};for(let t=0;t<4;++t){const r=n[t],i=s[t],o=[r,s[(t+1)%4],e,i],l=o.map(((e,r)=>o[(r+4-t)%4])),h=a(t,l);u||(u=h)}})();return(()=>{const t=(t,r)=>{if(null==t||!t.isLoaded||t.lij[0]>e.lij[0])return null;const i=t.renderData.geometryState;return{neighborSamplerData:i.samplerData,neighborEdgeOverlapResolution:i.neighborData.edgeResolutions[r+2],version:i.samplerDataVersion,neighborVerticesPerSide:i.numVerticesPerSide,neighborTile:t}},r=a.edges;for(let o=0;o<4;++o){var i;const n=s[o];n&&(x(null==n?void 0:n.isLoaded),x((null==n?void 0:n.lij[0])<=e.lij[0]));const a=r[o],l=null==a?void 0:a.version,h=t(n,o),m=null!=(i=null==h?void 0:h.version)?i:null,d=null!=a!=(null!=h),c=a&&h&&l!==m,g=a&&h&&(null==a?void 0:a.neighborTile)!==(null==h?void 0:h.neighborTile),f=d||c||g;u||(u=f),!f&&l||(r[o]=h)}})(),u}updateEdgeAfterResolutionChange(e){var t,r;const i=this._calculateEdgeResolution(e),o=this.geometryState.neighborData.edgeResolutions,s=o[e];x((null!=(t=null==(r=this.geometryState.neighborData.edges[e])?void 0:r.neighborTile.level)?t:0)<=this.tile.level),i!==s&&(o[e]=i,this._updateGeometry(this.vao.context))}_updateGeometry(e){this._releaseGeometry(),this._createGeometry(e)}releaseGeometry(){return this._releaseGeometry()}get hasGeometry(){return this._hasGeometry}ensureTexture(e,t){return r(this._texture)&&this._texture.descriptor.width!==e&&this.releaseTexture(),i(this._texture)&&(this._texture=t(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){r(this._texture)&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}updateGeometryStateAndPrepareForGeometryGeneration(t){const r=this._getElevationInfo(),i=r.samplerData?this.tile.getElevationBasedVerticesPerSide(r.maxTileLevel):this.tile.getDefaultVerticesPerRowOnLevel(),o=Math.max(i,5);let s=this.tile.clippingArea;this.tile.intersectsClippingArea&&!this.tile.isWithinClippingArea||(s=null);const n=this.geometryState;let a=!1;return n.numVerticesPerSide!==o&&(n.numVerticesPerSide=o,n.samplerDataVersion++,a=!0),r.changed&&(n.samplerData=r.samplerData,n.samplerDataVersion++,a=!0),e(n.clippingArea,s)||(n.clippingArea=s,a=!0),n.wireframe!==t&&(n.wireframe=t,a=!0),this._geometryStateChangedSinceLastUpdate||(this._geometryStateChangedSinceLastUpdate=a),this._hasGeometry=!0,a}_createGeometry(e){this.tile.createGeometry(this.geometryState,this.localOrigin);const t=this.geometryInfo.vertexAttributes,r=this.geometryInfo.indices,i=e.gl;this._vao=new T(e,b,{geometry:a(t.layout)},{geometry:G.createVertex(e,i.STATIC_DRAW,t.buffer)},G.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}_releaseGeometry(){return this._hasGeometry=!1,!!this._vao&&(this._vao.dispose(),this._vao=null,y(this.geometryInfo),!0)}get vao(){return this._vao}setTextureReference(e,t=_.Immediate){r(e)&&e.texture!==this._texture&&this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[f.ELEVATION],i=t.length;let o=new Array(i),s=0,n=0,a=!1;for(let l=0;l<i;l++){const i=t[l];if(r(i.upsampleInfo)){const t=i.upsampleInfo.tile,r=t.layerInfo[f.ELEVATION][l].data,u=r&&r.samplerData;e&&e[s]===u||(a=!0),o[s++]=u,n=Math.max(n,t.lij[0])}else if(i.data){const t=this.tile.surface.layerViewByIndex(l,f.ELEVATION);if(S(this.tile,t.layer,!1)){const t=i.data;e&&e[s]===t.samplerData||(a=!0),o[s++]=t.samplerData,n=this.tile.level}}}return r(e)&&e.length!==s&&(a=!0),s>0?o.length=s:o=null,{changed:a,samplerData:o,maxTileLevel:n}}get estimatedGeometryMemoryUsage(){const e=o(this.intersectionData,0,(e=>e.estimatedMemoryUsage));return this.geometryInfo.indices.byteLength+this.geometryInfo.vertexAttributes.byteLength+e}get textureDescriptor(){return r(this._texture)?this._texture.descriptor:null}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){}}function j(e,t){return t[0]>=e[0]-d&&t[2]<=e[2]+d&&t[1]>=e[1]-d&&t[3]<=e[3]+d}function I(e,t,i){if(r(i))for(const r of i)if(r){const i=r.x0,o=r.width,s=i+(o-1)/r.dx,n=r.y1,a=n-(o-1)/r.dy;if(e>=i-d&&e<=s+d&&a-d<=t&&t<=n+d)return!0}return!1}function R(e,t){for(const r of t)if(r){const t=r.x0,i=r.width,o=t+(i-1)/r.dx,s=r.y1,a=s-(i-1)/r.dy;if(j(n(t,a,o,s),e))return!0}return!1}export{L as PatchRenderData,I as isElevationSampleIn,R as isExtentInSampler};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as u,isSome as p}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as y,syncAndInitial as T,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{aliasOf as S}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as L}from"../../../core/accessorSupport/decorators/property.js";import{subclass as E}from"../../../core/accessorSupport/decorators/subclass.js";import{m as x}from"../../../chunks/mat4.js";import{c as D}from"../../../chunks/mat4f64.js";import{c as P}from"../../../chunks/vec3.js";import{c as b}from"../../../chunks/vec3f64.js";import{c as R}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as C}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as j,projectPointToVector as U}from"../../../geometry/projection.js";import{getReferenceEllipsoid as A}from"../../../geometry/projectionEllipsoid.js";import{create as M,equals as I,intersection as V,empty as k,expand as O,intersectsSphere as N}from"../../../geometry/support/aaBoundingRect.js";import{create as q,copy as B}from"../../../geometry/support/frustum.js";import{isRefreshableLayer as G}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as W}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as F}from"../../../layers/support/layerUtils.js";import{acquireDecoder as H}from"../../../layers/support/LercDecoder.js";import{printAllocations as Q}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as X,scaleToZoom as z}from"../support/cameraUtils.js";import Y from"../support/debugFlags.js";import{toBoundingRect as $}from"../support/extentUtils.js";import{ClientType as K}from"../support/index.js";import{updatingProgress as J}from"../support/updatingProperties.js";import{ElevationBounds as Z}from"./ElevationBounds.js";import{sampleElevation as ee,ElevationData as te}from"./ElevationData.js";import{create as ie}from"./ExtentHelper.js";import{LODSnapping as re,TextureUpdate as se}from"./interfaces.js";import{LayerClass as ae,LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as he}from"./RenderOrder.js";import{SphericalPatch as de}from"./SphericalPatch.js";import{DEFAULT_TILE_BACKGROUND as ue,MAX_ROOT_TILES as pe,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as ce,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as _e,MAX_MEMORY_LOD_BIAS as ge,ELEVATION_NODATA_VALUE as me}from"./TerrainConst.js";import fe from"./TerrainRenderer.js";import ye from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as Te,isSurfaceLayerView as ve,isMapTileLayerView as we,isElevationLayerView as Se,isVectorTileLayerView as Le,useFetchTileForLayer as Ee,isImageryTileLayerView as xe,isTileLayerView as De,releaseTileData as Pe,ENABLE_WATERPROOFNESS_TESTS as be}from"./terrainUtils.js";import{SplitLimits as Re,Tile as Ce}from"./Tile.js";import{printAllocations as je}from"./TilePerLayerInfo.js";import{TileUpdate as Ue}from"./TileUpdate.js";import{IteratorPreorder as Ae,IteratorPostorder as Me,hasLoadableSiblings as Ie,sortTilesByPOI as Ve,sortTiles as ke}from"./tileUtils.js";import{TilingSchemeLogic as Oe}from"./TilingSchemeLogic.js";import{UpsampleInfo as Ne}from"./UpsampleInfo.js";import{RenderRequestType as qe}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as Be,TaskPriority as Ge,noBudget as We}from"../../support/Scheduler.js";const Fe=l.getLogger("esri.views.3d.terrain.TerrainSurface"),He=.25;let Qe=class extends(a.EventedMixin(i)){constructor(e){var t,i;super(e),this._elevationBounds=new Z,this._iteratorPool=new c(Ae,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Me,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visible=!1,this._usedMemory=Ke,this._performanceInfo=new ye,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=b(),this._eyePosSurfaceSR=b(),this._splitLimits=new Re,this._snapLevel=1/0,this._frustum=q(),this._viewProjectionMatrix=D(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new C,this._frameTask=Be,this._allTiles=new _,this._upsampleInfoPool=new c(Ne),this._rootTilesExtent=M(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundImage=ue,this.backgroundColor=null,this._updatingRootTiles=!1,this._layerViewsDirty=!1,this._isGlobal=!(null!=(t=e.view)&&null!=(i=t.state)&&i.isLocal)}initialize(){this._lercDecoder=H(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(oe):new c(de);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new W(e.newCache("elevation-query")),this._set("overlayManager",new le({surface:this})),this._handles.add([y((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),y((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new fe({overlayRenderer:this.overlayManager.renderer,ellipsoidRadius:A(this.view.spatialReference).radius,stage:this.view._stage,allTiles:this._allTiles}),this._handles.add([y((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),T),y((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),y((()=>this._background),(()=>{this._handleLayerViewChanges(),this._renderer.setTileBackground(this._background)}),T),y((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),y((()=>Y.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&Y.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=ie(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>{var e,t,i;return null==(e=this.view)||null==(t=e.defaultsFromMap)||null==(i=t.mapCollections)?void 0:i.map((({layers:e})=>e))},getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new Oe({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(K.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(K.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(Ge.TERRAIN_SURFACE,this),this._handles.add([y((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),y((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),y((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),y((()=>{var e,t;const i=this.view,r=i.state;return[this.lodBias,this.lodSnapping,null==(e=i.resourceController)||null==(t=e.memoryController)?void 0:t.memoryFactor,r.camera,r.contentCamera,r.fixedContentCamera]}),(()=>this._viewChangeUpdate()),T),y((()=>{var e,t;return null==(e=this.view.qualitySettings)||null==(t=e.tiledSurface)?void 0:t.textureFadeDuration}),(e=>this._renderer.textureFadingEnabled=e>0),w),y((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Ce.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),Q(),je()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){var e,t;const i=null==(e=this.view.pointsOfInterest)||null==(t=e.contentCameraOnSurface)?void 0:t.scale;if(i){const e=this.view.state.contentCamera;let t=X(this.view,e.eye,e.viewForward,e.up).tilt;t>90&&(t=180-t);const r=2*(t/90)**2,s=z(this.view,i)-r;Math.abs(this._snapLevel-s)>He&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?re.ON:re.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(u(t)||u(e))return null;const i=M(),r=$(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,M()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return p(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){var e;return null==(e=this.tilingSchemeLogic)?void 0:e.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._renderer.updating||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return p(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get spatialReference(){var e,t;return null!=(e=null==(t=this.tilingScheme)?void 0:t.spatialReference)?e:null}get _background(){return null!=this.backgroundColor?this.backgroundColor:this.backgroundImage}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){var e,t;const i=!this.renderingDisabled&&!this.opaque;null==(e=this.view)||null==(t=e._stage)||t.renderView.setRenderParameters({transparentTerrain:i})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}set visible(e){e!==this._visible&&(this._visible=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,Je);return u(s)?null:ee(Je[0],Je[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=Je){var a;const n=this.rootTiles;if(u(n)||!n.length)return null;if(0===n[0].layerInfo[ae.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!j(s,r,s,null==(a=this.tilingScheme)?void 0:a.spatialReference))return Fe.error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let l of n){if(!l.containsPoint(s))continue;for(;l&&!l.rendered&&!l.isLeaf;){let e=0;s[0]>.5*(l.extent[0]+l.extent[2])&&(e+=1),s[1]<.5*(l.extent[1]+l.extent[3])&&(e+=2),l=l.children[e]}const e=l.renderData;return(e?e.geometryState.samplerData:null)?l:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!U(e,Je,this.spatialReference))return Fe.error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(p(t))for(let e of t)if(e.containsPoint(Je)){for(;null!=e.children[0];){let t=0;Je[0]>e.children[0].extent[2]&&(t+=1),Je[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!U(e,Je,this.spatialReference))return Fe.error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Je[3]=t;let i=null;const r=e=>{if(e&&N(e.extent,Je))if(null!=e.children[0])for(const t of e.children)r(t);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}},s=this.rootTiles;if(p(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this.lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1,this._renderer.isTransparent=this._allTransparentSurfaceLayers();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?se.UNFADED:se.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(Te(!!e,"tiling scheme cannot be reset to undefined"),this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return et[0]=e,et[1]=t,et[2]=i,s.init(et,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=Ze;let s=t.rootTilesInExtent(e,i,5*pe);if(p(this.rootTiles)){if(s.length>pe)return void Fe.warn(ce);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,ze);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>ze(t,e.lij)))>-1)||(this._purgeTile(e,!0),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>pe&&(Fe.warn(_e),s=t.rootTilesInExtent(e,i,pe)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=M(i)),this.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._allTiles.forEach((e=>{e.isLoaded&&this._prepareToLoadTile(e)})),this._allTiles.forAll((e=>{e.isLoaded&&(this._updateTileGeometry(e),e.updateNeighborsAfterGeometryChange())})),this._updatingRootTiles=!1,this.checkAllTileWaterproofness()}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ue.SPLIT&&t.setPendingUpdate(Ue.SPLIT),this._loadTile(t),t.checkGeometryWaterproofness(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),p(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ue.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(u(e))return;const t=Ie(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.view.state.fixedContentCamera,a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(Ue.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Ue.RENDERDATA);const t=e.computeVisibility();s||t?(e.updateScreenDepth(n),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))):l.skipSubtree()}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this.lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(u(this._splitLimits.frustum)&&(this._splitLimits.frustum=q()),B(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,B(this._frustum,e.frustum),x(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),P(this._eyePosRenderSR,t.eye),j(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(Ye(e)?(this._loadChildren(e),this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness()))):$e(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),e.updateNeighborsAfterGeometryChange(),this._elevationUpdate(e),this._usedMemory=Ke}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ue.TEXTURE_FADING)?Ue.TEXTURE_FADING:!!e.resetPendingUpdate(Ue.TEXTURE_NOFADING)&&Ue.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=Ke,t.madeProgress())}_elevationUpdate(e){it.spatialReference=this.spatialReference,it.tile=e,it.extent=e.extent,this.emit("elevation-change",it)}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done&&this.requestUpdate(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next();if(e.loadable){const i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i===Ue.SPLIT){e.resetPendingUpdate(Ue.MERGE),e.isLeaf&&(e.setPendingUpdate(Ue.SPLIT),t.skipSubtree());continue}e.resetPendingUpdate(Ue.SPLIT)&&e.updateAgentSuspension(),i===Ue.VSPLITMERGE&&e.updateAgents(ae.ELEVATION)}if(t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ue.MERGE),e.resetPendingUpdate(Ue.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.loadable&&e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Ve(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=0;for(;!e.done;){let r=!1;i=0;const s=!this._allTiles.some((s=>{if(i+=s.usedMemory,s.resetPendingUpdate(Ue.MERGE)){if(!t)return s.setPendingUpdate(Ue.MERGE),e.done;this._mergeTile(s),r=!0,e.madeProgress()}else s.resetPendingUpdate(Ue.SPLIT)&&(this._splitTile(s),r=!0,e.madeProgress());return!e.done&&s.resetPendingUpdate(Ue.RENDERDATA)&&(this._updateRenderData(s),e.madeProgress()),e.done}));if(r&&(this._allTilesSorted=!1,this._allTilesDirty=!0),s){if(this._usedMemory=i,!r)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}0===i&&(this._allTilesDirty=!0),this._sortTiles(e)}_updateElevation(e){return this._allTiles.some((t=>(t.resetPendingUpdate(Ue.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(qe.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ge}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this.lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){p(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e,!1))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i],!1)||t;return e.unsetChildren(),t}_purgeTile(e,t){const i=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),t&&e.updateNeighborsAfterGeometryChange(),this._tilePool.release(e),i}_unloadTile(e){e.unload(this._renderer)}_splitTile(e){Te(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ue.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){rt.spatialReference=this.spatialReference,rt.extent=e.extent,rt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",rt)}_createTile(e,t,i,r){Te(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.loadable&&(s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ue.SPLIT&&s.setPendingUpdate(Ue.SPLIT)),s}_mergeTile(e){Te(!e.hasPendingUpdate(Ue.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(Te(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),e.updateNeighborsAfterGeometryChange(),this._checkTileAndNeighborsWaterproofness(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_checkTileAndNeighborsWaterproofness(e){e.checkGeometryWaterproofness(),this._checkTileNeighborsWaterproofness(e)}_checkTileNeighborsWaterproofness(e){be&&e.forallNeighbors((e=>!!e.isLoaded&&(e.checkGeometryWaterproofness(),!0)))}_loadChildren(e){this._checkTileAndNeighborsWaterproofness(e),Te(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._prepareToLoadTile(e))),t.forEach((e=>this._loadTilePrepared(e))),e.updateNeighborsAfterGeometryChange(e.level+1),t.forEach((e=>e.updateNeighborsWithChangedEdgeResolution())),t.forEach((e=>e.checkGeometryWaterproofness())),this._checkTileNeighborsWaterproofness(e)}_loadParent(e){this._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),t.updateNeighborsAfterGeometryChange(),this._checkTileAndNeighborsWaterproofness(t)}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_postLoadTile(e){e.setPendingUpdate(Ue.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_loadTile(e){e.load(this._renderer),this._postLoadTile(e)}_loadTilePrepared(e){e.loadPrepared(this._renderer),this._postLoadTile(e)}_prepareToLoadTile(e){e.prepareToLoad(this._renderer)}_elevationDataArrived(e,t,i){const r=new te(e.lij,e.extent,i);e.dataArrived(t,ae.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=We){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),ve(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._layerIndexByUid[e].get(s.uid);i<r&&(t=!0),r=i}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allTransparentSurfaceLayers(),e.madeProgress()}_allTransparentSurfaceLayers(){var e,t;let i=0===(null==(e=this.view.map)||null==(t=e.ground)?void 0:t.opacity);for(const r of this.view.allLayerViews.items)if(we(r)&&!F(r.layer)&&0!==r.fullOpacity)return i=!1,i;return i}_layerClassFromLayerView(e){return Se(e)?ae.ELEVATION:ae.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(y((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(y((()=>e.fullOpacity),(()=>this._updateTileTextures(se.UNFADED)))),t.push(y((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._layerIndexByUid[i].get(e.uid);null!=t&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;const r=k();e.forEach((e=>{const s=e.layer;if(!s||e.suspended||!ve(e))return;const a=e.fullExtent;if(!a)return void Fe.warn("Terrain: Map or elevation layer does not have fullExtent: "+s.id);O(r,a,r);const n=this._layerClassFromLayerView(e);if(n===ae.MAP){const t=e.displayLevelRange;t.maxLevel!==1/0&&(null===i||t.maxLevel>i)&&(i=t.maxLevel)}t[n].push(e)}));for(const s of ne){const e=this._layerViews[s],i=t[s];i.reverse();const r=i.length;let a=e.length!==r;const n=new Array(r),l=new Array(e.length);this._layerIndexByUid[s].clear();for(let t=0;t<r;t++){const r=i[t].uid;this._layerIndexByUid[s].set(r,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(l,n,s);this._layerViews[s]=i,this._restartAllAgents(s),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===ae.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(ae.MAP),e===se.IMMEDIATE?this.renderer.updateTileTexture(t,Ue.TEXTURE_NOFADING):t.updateRenderData(ae.MAP,e)})),this._renderer.isTransparent=this._allTransparentSurfaceLayers()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=qe.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Le(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===ae.ELEVATION?Se(i)?this._requestElevationTileData(e,i,r):Promise.reject():we(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(--this._asyncWorkItems,m(i))return;const s=this._layerIndexByUid[ae.ELEVATION].get(t.uid);null!=s?(this._usedMemory=Ke,this.requestUpdate(),this._elevationDataArrived(e,s,r)):Fe.warn("TerrainSurface: received data from unknown layer %d %s",ae.ELEVATION,e.lij.toString())},s=i=>{--this._asyncWorkItems,g(i)||(this._dataMissing(e,ae.ELEVATION,t,i),this.requestUpdate())};if(Ee(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:me,signal:i.signal}).then((e=>{if(m(i))return Fe.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void s(f());this._frameTask.schedule((()=>r(e)),i.signal,s)}),s);const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:me},i.signal))).then((e=>{r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue})}),s)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Pe(s),m(i)||(this._dataMissing(e,ae.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Pe(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Le(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(xe(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(De(t)&&Ee(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return Fe.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let l=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);G(t.layer)&&t.layer.refreshTimestamp&&(l+=`${l.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const o=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(l,o,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._layerIndexByUid[ae.MAP].get(t.uid);null!=r?e.dataArrived(r,ae.MAP,i):(Pe(i),Fe.warn("TerrainSurface: received data from unknown layer"))}_dataMissing(e,t,i,r){const s=this._layerIndexByUid[t].get(i.uid);null!=s?e.dataMissing(s,t,r):Fe.warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(this._usedMemory===Ke&&(this._usedMemory=0,this._allTiles.forAll((e=>this._usedMemory+=e.usedMemory))),this._usedMemory):0}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._layerIndexByUid[i].get(e.uid);return this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(u(e)||u(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return Te(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{p(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){tt.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&tt.push(e)}));const t=tt.toArray();return ke(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTileWaterproofness(){if(!be)return;const e=this.rootTiles;if(u(e))return;const t=e=>{var t,i,r,s;return null!=(t=(null==e||null==(i=e.renderData)||null==(r=i.geometryInfo)||null==(s=r.indices)?void 0:s.length)>0)&&t},i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{var s,a,n;if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),null==(s=e.renderData)||!s.geometryInfo||(null!=(a=null==(n=e.renderData.geometryInfo.indices)?void 0:n.length)?a:0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{var t,i;const r=null==(t=null==(i=e.parent)?void 0:i.visible)||t,a=e.visible;e.computeVisibility();const n=e.visible;if(a!==n&&r&&console.error(" Tile[",e.lij,"] has out of date visibility: ",a," instead of ",n),!e.isLeaf)for(const l of e.children)s(l)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}};e([L()],Qe.prototype,"_renderer",void 0),e([L()],Qe.prototype,"_hasPendingUpdates",void 0),e([L()],Qe.prototype,"_asyncWorkItems",void 0),e([L()],Qe.prototype,"_allTilesDirty",void 0),e([L()],Qe.prototype,"_allTilesSorted",void 0),e([L()],Qe.prototype,"_viewChanged",void 0),e([L({readOnly:!0})],Qe.prototype,"_watchUpdatingTracking",void 0),e([L()],Qe.prototype,"_frameTask",void 0),e([L({readOnly:!0})],Qe.prototype,"snapLevel",null),e([L({readOnly:!0})],Qe.prototype,"lodSnapping",null),e([L({constructOnly:!0})],Qe.prototype,"view",void 0),e([L()],Qe.prototype,"_userClippingExtent",null),e([L()],Qe.prototype,"_rootTilesExtent",void 0),e([L({readOnly:!0})],Qe.prototype,"extent",null),e([L({readOnly:!0})],Qe.prototype,"groundExtent",null),e([L({readOnly:!0})],Qe.prototype,"_tilingSchemeExtent",null),e([L({readOnly:!0})],Qe.prototype,"updating",null),e([L(J)],Qe.prototype,"updatingProgress",void 0),e([L({readOnly:!0})],Qe.prototype,"updatingProgressValue",null),e([L()],Qe.prototype,"_maxNumUpdating",void 0),e([L({aliasOf:"view.map.ground.opacity"})],Qe.prototype,"baseOpacity",void 0),e([L({readOnly:!0})],Qe.prototype,"overlayManager",void 0),e([L({readOnly:!0})],Qe.prototype,"viewingMode",null),e([L()],Qe.prototype,"maxTextureScale",void 0),e([L({readOnly:!0})],Qe.prototype,"ready",null),e([L({value:he.FRONT_TO_BACK})],Qe.prototype,"renderOrder",null),e([L({readOnly:!0})],Qe.prototype,"rootTiles",void 0),e([L({readOnly:!0})],Qe.prototype,"spatialReference",null),e([L()],Qe.prototype,"backgroundImage",void 0),e([L({type:t,aliasOf:"view.map.ground.surfaceColor"})],Qe.prototype,"backgroundColor",void 0),e([L()],Qe.prototype,"_background",null),e([L({value:!1})],Qe.prototype,"slicePlaneEnabled",null),e([L({readOnly:!0})],Qe.prototype,"tilingScheme",void 0),e([L({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Qe.prototype,"tilingSchemeLocked",void 0),e([L({readOnly:!0})],Qe.prototype,"tilingSchemeLogic",void 0),e([L({value:!0})],Qe.prototype,"velvetOverground",null),e([S("_renderer.wireframe")],Qe.prototype,"wireframe",void 0),e([L({value:!1})],Qe.prototype,"suspended",null),e([L({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Qe.prototype,"textureFadeDuration",void 0),e([L()],Qe.prototype,"_layerViewsDirty",void 0),e([S("_renderer.renderPatchBorders")],Qe.prototype,"renderPatchBorders",void 0),e([S("_renderer.renderingDisabled")],Qe.prototype,"renderingDisabled",void 0),Qe=e([E("esri.views.3d.terrain.TerrainSurface")],Qe);const Xe=Qe;function ze(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Ye(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>Ye(e))))}function $e(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const Ke=-1,Je=R(),Ze=M(),et=[0,0,0],tt=new _,it={spatialReference:null,tile:null,extent:null,context:"ground"},rt={spatialReference:null,extent:null,scale:0};export{Xe as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as T}from"../../../core/promiseUtils.js";import{watch as f,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{aliasOf as S}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as L}from"../../../core/accessorSupport/decorators/property.js";import{subclass as E}from"../../../core/accessorSupport/decorators/subclass.js";import{m as b}from"../../../chunks/mat4.js";import{c as x}from"../../../chunks/mat4f64.js";import{c as D}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as P}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as R}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as C,projectPointToVector as j}from"../../../geometry/projection.js";import{getReferenceEllipsoid as A}from"../../../geometry/projectionEllipsoid.js";import{create as M,equals as I,intersection as V,empty as k,expand as O,intersectsSphere as N}from"../../../geometry/support/aaBoundingRect.js";import{create as q,copy as B}from"../../../geometry/support/frustum.js";import{isRefreshableLayer as G}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as W}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as F}from"../../../layers/support/layerUtils.js";import{acquireDecoder as H}from"../../../layers/support/LercDecoder.js";import{printAllocations as Q}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as X,scaleToZoom as z}from"../support/cameraUtils.js";import Y from"../support/debugFlags.js";import{toBoundingRect as $}from"../support/extentUtils.js";import{ClientType as K}from"../support/index.js";import{updatingProgress as J}from"../support/updatingProperties.js";import{ElevationBounds as Z}from"./ElevationBounds.js";import{sampleElevation as ee,ElevationData as te}from"./ElevationData.js";import{create as ie}from"./ExtentHelper.js";import{LODSnapping as re,TextureUpdate as se}from"./interfaces.js";import{LayerClass as ae,LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as he}from"./RenderOrder.js";import{SphericalPatch as de}from"./SphericalPatch.js";import{DEFAULT_TILE_BACKGROUND as pe,MAX_ROOT_TILES as ue,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as ce,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as _e,MAX_MEMORY_LOD_BIAS as ge,ELEVATION_NODATA_VALUE as me}from"./TerrainConst.js";import Te from"./TerrainRenderer.js";import fe from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as ye,internalAssert as ve,isSurfaceLayerView as we,isMapTileLayerView as Se,isElevationLayerView as Le,isVectorTileLayerView as Ee,useFetchTileForLayer as be,isImageryTileLayerView as xe,isTileLayerView as De,releaseTileData as Ue,ENABLE_WATERPROOFNESS_TESTS as Pe}from"./terrainUtils.js";import{SplitLimits as Re,Tile as Ce}from"./Tile.js";import{printAllocations as je}from"./TilePerLayerInfo.js";import{TileUpdate as Ae}from"./TileUpdate.js";import{IteratorPreorder as Me,IteratorPostorder as Ie,hasLoadableSiblings as Ve,sortTilesByPOI as ke,sortTiles as Oe}from"./tileUtils.js";import{TilingSchemeLogic as Ne}from"./TilingSchemeLogic.js";import{UpsampleInfo as qe}from"./UpsampleInfo.js";import{RenderRequestType as Be}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as Ge,TaskPriority as We,noBudget as Fe}from"../../support/Scheduler.js";const He=l.getLogger("esri.views.3d.terrain.TerrainSurface"),Qe=.25;let Xe=class extends(a.EventedMixin(i)){constructor(e){var t,i;super(e),this._elevationBounds=new Z,this._iteratorPool=new c(Me,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ie,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visible=!1,this._usedMemory=Je,this._performanceInfo=new fe,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new Re,this._snapLevel=1/0,this._frustum=q(),this._viewProjectionMatrix=x(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new R,this._frameTask=Ge,this._allTiles=new _,this._upsampleInfoPool=new c(qe),this._rootTilesExtent=M(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundImage=pe,this.backgroundColor=null,this._updatingRootTiles=!1,this.deferTileNeighborUpdate=!1,this.neighborTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this._isGlobal=!(null!=(t=e.view)&&null!=(i=t.state)&&i.isLocal)}initialize(){this._lercDecoder=H(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(oe):new c(de);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new W(e.newCache("elevation-query")),this._set("overlayManager",new le({surface:this})),this._handles.add([f((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),f((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new Te({overlayRenderer:this.overlayManager.renderer,ellipsoidRadius:A(this.view.spatialReference).radius,stage:this.view._stage,allTiles:this._allTiles}),this._handles.add([f((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),f((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),f((()=>this._background),(()=>{this._handleLayerViewChanges(),this._renderer.setTileBackground(this._background)}),y),f((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),f((()=>Y.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&Y.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=ie(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>{var e,t,i;return null==(e=this.view)||null==(t=e.defaultsFromMap)||null==(i=t.mapCollections)?void 0:i.map((({layers:e})=>e))},getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new Ne({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(K.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(K.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(We.TERRAIN_SURFACE,this),this._handles.add([f((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),f((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),f((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),f((()=>{var e,t;const i=this.view,r=i.state;return[this.lodBias,this.lodSnapping,null==(e=i.resourceController)||null==(t=e.memoryController)?void 0:t.memoryFactor,r.camera,r.contentCamera,r.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),f((()=>{var e,t;return null==(e=this.view.qualitySettings)||null==(t=e.tiledSurface)?void 0:t.textureFadeDuration}),(e=>this._renderer.textureFadingEnabled=e>0),w),f((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Ce.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),Q(),je()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){var e,t;const i=null==(e=this.view.pointsOfInterest)||null==(t=e.contentCameraOnSurface)?void 0:t.scale;if(i){const e=this.view.state.contentCamera;let t=X(this.view,e.eye,e.viewForward,e.up).tilt;t>90&&(t=180-t);const r=2*(t/90)**2,s=z(this.view,i)-r;Math.abs(this._snapLevel-s)>Qe&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?re.ON:re.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=M(),r=$(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,M()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){var e;return null==(e=this.tilingSchemeLogic)?void 0:e.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._renderer.updating||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get spatialReference(){var e,t;return null!=(e=null==(t=this.tilingScheme)?void 0:t.spatialReference)?e:null}get _background(){return null!=this.backgroundColor?this.backgroundColor:this.backgroundImage}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){var e,t;const i=!this.renderingDisabled&&!this.opaque;null==(e=this.view)||null==(t=e._stage)||t.renderView.setRenderParameters({transparentTerrain:i})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}set visible(e){e!==this._visible&&(this._visible=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,Ze);return p(s)?null:ee(Ze[0],Ze[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=Ze){var a;const n=this.rootTiles;if(p(n)||!n.length)return null;if(0===n[0].layerInfo[ae.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!C(s,r,s,null==(a=this.tilingScheme)?void 0:a.spatialReference))return He.error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let l of n){if(!l.containsPoint(s))continue;for(;l&&!l.rendered&&!l.isLeaf;){let e=0;s[0]>.5*(l.extent[0]+l.extent[2])&&(e+=1),s[1]<.5*(l.extent[1]+l.extent[3])&&(e+=2),l=l.children[e]}const e=l.renderData;return(e?e.geometryState.samplerData:null)?l:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!j(e,Ze,this.spatialReference))return He.error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(u(t))for(let e of t)if(e.containsPoint(Ze)){for(;null!=e.children[0];){let t=0;Ze[0]>e.children[0].extent[2]&&(t+=1),Ze[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!j(e,Ze,this.spatialReference))return He.error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Ze[3]=t;let i=null;const r=e=>{if(e&&N(e.extent,Ze))if(null!=e.children[0])for(const t of e.children)r(t);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}},s=this.rootTiles;if(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this.lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1,this._renderer.isTransparent=this._allTransparentSurfaceLayers();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?se.UNFADED:se.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(ye(!!e,"tiling scheme cannot be reset to undefined"),this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return tt[0]=e,tt[1]=t,tt[2]=i,s.init(tt,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=et;let s=t.rootTilesInExtent(e,i,5*ue);if(u(this.rootTiles)){if(s.length>ue)return void He.warn(ce);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Ye);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Ye(t,e.lij)))>-1)||(this._purgeTile(e,!0),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>ue&&(He.warn(_e),s=t.rootTilesInExtent(e,i,ue)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=M(i)),this.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._allTiles.forEach((e=>{e.isLoaded&&this._prepareToLoadTile(e)})),this._allTiles.forAll((e=>{e.isLoaded&&(this._updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e))})),this._updatingRootTiles=!1,this.checkAllTileWaterproofness()}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ae.SPLIT&&t.setPendingUpdate(Ae.SPLIT),this._loadTile(t),t.checkGeometryWaterproofness(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ae.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(p(e))return;const t=Ve(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.extent,a=this._viewProjectionMatrix;this.setTileTreeDirty();const n=this._iteratorPool.acquire();for(n.reset(e);!n.done;){const e=n.next();e.updateClippingStatus(s)&&e.resetPendingUpdate(Ae.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Ae.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(a),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))}n.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this.lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=q()),B(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,B(this._frustum,e.frustum),b(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),D(this._eyePosRenderSR,t.eye),C(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&($e(e)?(this._loadChildren(e),this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness()))):Ke(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e),this._elevationUpdate(e),this._usedMemory=Je,this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e)}_updateTileNeighborsAfterGeometryChange(e,t){if(this.deferTileNeighborUpdate){const t=this.neighborTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}else e.updateNeighborsAfterGeometryChange(t)}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ae.TEXTURE_FADING)?Ae.TEXTURE_FADING:!!e.resetPendingUpdate(Ae.TEXTURE_NOFADING)&&Ae.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=Je,t.madeProgress())}_elevationUpdate(e){rt.spatialReference=this.spatialReference,rt.tile=e,rt.extent=e.extent,this.emit("elevation-change",rt)}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done&&this.requestUpdate(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next(),i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i!==Ae.SPLIT){if(e.resetPendingUpdate(Ae.SPLIT)&&e.updateAgentSuspension(),i===Ae.VSPLITMERGE&&e.updateAgents(ae.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ae.MERGE),e.resetPendingUpdate(Ae.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}else e.resetPendingUpdate(Ae.MERGE),e.isLeaf&&(e.setPendingUpdate(Ae.SPLIT),t.skipSubtree())}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(ke(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_prepareBatchTileGeometryUpdate(){ve(0===this.neighborTilesToUpdate.size),this.deferTileNeighborUpdate=!0}_batchUpdateUpdatedTileNeighbors(){this.deferTileNeighborUpdate=!1;const e=this.neighborTilesToUpdate;(()=>{const t=()=>{for(const t of e)t.updateNeighborsWithChangedEdgeResolution()};(()=>{for(const t of e)t.updateNeighborDataAndGeometryIfNeeded()})(),t(),e.clear()})()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=0;this._prepareBatchTileGeometryUpdate();let r=!1;for(;!e.done;){let s=!1;i=0;const a=!this._allTiles.some((a=>{if(r)i+=a.usedMemory;else if(!a.loadable)return e.done;if(a.resetPendingUpdate(Ae.MERGE)){if(!t)return a.setPendingUpdate(Ae.MERGE),e.done;this._mergeTile(a),s=!0,e.madeProgress()}else a.resetPendingUpdate(Ae.SPLIT)&&(this._splitTile(a),s=!0,e.madeProgress());return!e.done&&a.resetPendingUpdate(Ae.RENDERDATA)&&(this._updateRenderData(a),e.madeProgress()),e.done}));if(s&&(this._allTilesSorted=!1,this._allTilesDirty=!0),a){if(!r){r=!0;continue}if(this._usedMemory=i,!s)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}0===i&&(this._allTilesDirty=!0),this._batchUpdateUpdatedTileNeighbors(),this._sortTiles(e)}_updateElevation(e){return this._prepareBatchTileGeometryUpdate(),this._allTiles.some((t=>(t.resetPendingUpdate(Ae.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),this._batchUpdateUpdatedTileNeighbors(),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Be.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ge}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this.lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){u(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e,!1))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i],!1)||t;return e.unsetChildren(),t}_purgeTile(e,t){const i=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),t&&this._updateTileNeighborsAfterGeometryChange(e),this._tilePool.release(e),i}_unloadTile(e){this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e),e.unload(this._renderer)}_splitTile(e){ye(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ae.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){st.spatialReference=this.spatialReference,st.extent=e.extent,st.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",st)}_createTile(e,t,i,r){ye(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ae.SPLIT&&s.setPendingUpdate(Ae.SPLIT),s}_mergeTile(e){ye(!e.hasPendingUpdate(Ae.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(ye(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._updateTileNeighborsAfterGeometryChange(e),this._checkTileAndNeighborsWaterproofness(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_checkTileAndNeighborsWaterproofness(e){e.checkGeometryWaterproofness(),this._checkTileNeighborsWaterproofness(e)}_checkTileNeighborsWaterproofness(e){Pe&&e.forallNeighbors((e=>!!e.isLoaded&&(e.checkGeometryWaterproofness(),!0)))}_loadChildren(e){this._checkTileAndNeighborsWaterproofness(e),ye(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._prepareToLoadTile(e))),t.forEach((e=>this._loadTilePrepared(e))),this._updateTileNeighborsAfterGeometryChange(e,e.level+1),this.deferTileNeighborUpdate||t.forEach((e=>e.updateNeighborsWithChangedEdgeResolution())),t.forEach((e=>e.checkGeometryWaterproofness())),this._checkTileNeighborsWaterproofness(e)}_loadParent(e){this._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._updateTileNeighborsAfterGeometryChange(t),this._checkTileAndNeighborsWaterproofness(t)}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_postLoadTile(e){e.setPendingUpdate(Ae.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_loadTile(e){e.load(this._renderer),this._postLoadTile(e)}_loadTilePrepared(e){e.loadPrepared(this._renderer),this._postLoadTile(e)}_prepareToLoadTile(e){e.prepareToLoad(this._renderer)}_elevationDataArrived(e,t,i){const r=new te(e.lij,e.extent,i);e.dataArrived(t,ae.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=Fe){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),we(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._layerIndexByUid[e].get(s.uid);i<r&&(t=!0),r=i}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allTransparentSurfaceLayers(),e.madeProgress()}_allTransparentSurfaceLayers(){var e,t;let i=0===(null==(e=this.view.map)||null==(t=e.ground)?void 0:t.opacity);for(const r of this.view.allLayerViews.items)if(Se(r)&&!F(r.layer)&&0!==r.fullOpacity)return i=!1,i;return i}_layerClassFromLayerView(e){return Le(e)?ae.ELEVATION:ae.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(f((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(f((()=>e.fullOpacity),(()=>this._updateTileTextures(se.UNFADED)))),t.push(f((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._layerIndexByUid[i].get(e.uid);null!=t&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;const r=k();e.forEach((e=>{const s=e.layer;if(!s||e.suspended||!we(e))return;const a=e.fullExtent;if(!a)return void He.warn("Terrain: Map or elevation layer does not have fullExtent: "+s.id);O(r,a,r);const n=this._layerClassFromLayerView(e);if(n===ae.MAP){const t=e.displayLevelRange;t.maxLevel!==1/0&&(null===i||t.maxLevel>i)&&(i=t.maxLevel)}t[n].push(e)}));for(const s of ne){const e=this._layerViews[s],i=t[s];i.reverse();const r=i.length;let a=e.length!==r;const n=new Array(r),l=new Array(e.length);this._layerIndexByUid[s].clear();for(let t=0;t<r;t++){const r=i[t].uid;this._layerIndexByUid[s].set(r,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(l,n,s);this._layerViews[s]=i,this._restartAllAgents(s),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===ae.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(ae.MAP),e===se.IMMEDIATE?this.renderer.updateTileTexture(t,Ae.TEXTURE_NOFADING):t.updateRenderData(ae.MAP,e)})),this._renderer.isTransparent=this._allTransparentSurfaceLayers()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=Be.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Ee(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===ae.ELEVATION?Le(i)?this._requestElevationTileData(e,i,r):Promise.reject():Se(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(--this._asyncWorkItems,m(i))return;const s=this._layerIndexByUid[ae.ELEVATION].get(t.uid);null!=s?(this._usedMemory=Je,this.requestUpdate(),this._elevationDataArrived(e,s,r)):He.warn("TerrainSurface: received data from unknown layer %d %s",ae.ELEVATION,e.lij.toString())},s=i=>{--this._asyncWorkItems,g(i)||(this._dataMissing(e,ae.ELEVATION,t,i),this.requestUpdate())};if(be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:me,signal:i.signal}).then((e=>{if(m(i))return He.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void s(T());this._frameTask.schedule((()=>r(e)),i.signal,s)}),s);const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:me},i.signal))).then((e=>{r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue})}),s)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ue(s),m(i)||(this._dataMissing(e,ae.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Ue(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Ee(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(xe(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(De(t)&&be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return He.warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(T());a(e)}),n);let l=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);G(t.layer)&&t.layer.refreshTimestamp&&(l+=`${l.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const o=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(l,o,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._layerIndexByUid[ae.MAP].get(t.uid);null!=r?e.dataArrived(r,ae.MAP,i):(Ue(i),He.warn("TerrainSurface: received data from unknown layer"))}_dataMissing(e,t,i,r){const s=this._layerIndexByUid[t].get(i.uid);null!=s?e.dataMissing(s,t,r):He.warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(this._usedMemory===Je&&(this._usedMemory=0,this._allTiles.forAll((e=>this._usedMemory+=e.usedMemory))),this._usedMemory):0}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._layerIndexByUid[i].get(e.uid);return this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return ye(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){it.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&it.push(e)}));const t=it.toArray();return Oe(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTileWaterproofness(){if(!Pe)return;const e=this.rootTiles;if(p(e))return;const t=e=>{var t,i,r,s;return null!=(t=(null==e||null==(i=e.renderData)||null==(r=i.geometryInfo)||null==(s=r.indices)?void 0:s.length)>0)&&t},i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{var s,a,n;if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),null==(s=e.renderData)||!s.geometryInfo||(null!=(a=null==(n=e.renderData.geometryInfo.indices)?void 0:n.length)?a:0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{var t,i;const r=null==(t=null==(i=e.parent)?void 0:i.visible)||t,a=e.visible;e.computeVisibility();const n=e.visible;if(a!==n&&r&&console.error(" Tile[",e.lij,"] has out of date visibility: ",a," instead of ",n),!e.isLeaf)for(const l of e.children)s(l)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}};e([L()],Xe.prototype,"_renderer",void 0),e([L()],Xe.prototype,"_hasPendingUpdates",void 0),e([L()],Xe.prototype,"_asyncWorkItems",void 0),e([L()],Xe.prototype,"_allTilesDirty",void 0),e([L()],Xe.prototype,"_allTilesSorted",void 0),e([L()],Xe.prototype,"_viewChanged",void 0),e([L({readOnly:!0})],Xe.prototype,"_watchUpdatingTracking",void 0),e([L()],Xe.prototype,"_frameTask",void 0),e([L({readOnly:!0})],Xe.prototype,"snapLevel",null),e([L({readOnly:!0})],Xe.prototype,"lodSnapping",null),e([L({constructOnly:!0})],Xe.prototype,"view",void 0),e([L()],Xe.prototype,"_userClippingExtent",null),e([L()],Xe.prototype,"_rootTilesExtent",void 0),e([L({readOnly:!0})],Xe.prototype,"extent",null),e([L({readOnly:!0})],Xe.prototype,"groundExtent",null),e([L({readOnly:!0})],Xe.prototype,"_tilingSchemeExtent",null),e([L({readOnly:!0})],Xe.prototype,"updating",null),e([L(J)],Xe.prototype,"updatingProgress",void 0),e([L({readOnly:!0})],Xe.prototype,"updatingProgressValue",null),e([L()],Xe.prototype,"_maxNumUpdating",void 0),e([L({aliasOf:"view.map.ground.opacity"})],Xe.prototype,"baseOpacity",void 0),e([L({readOnly:!0})],Xe.prototype,"overlayManager",void 0),e([L({readOnly:!0})],Xe.prototype,"viewingMode",null),e([L()],Xe.prototype,"maxTextureScale",void 0),e([L({readOnly:!0})],Xe.prototype,"ready",null),e([L({value:he.FRONT_TO_BACK})],Xe.prototype,"renderOrder",null),e([L({readOnly:!0})],Xe.prototype,"rootTiles",void 0),e([L({readOnly:!0})],Xe.prototype,"spatialReference",null),e([L()],Xe.prototype,"backgroundImage",void 0),e([L({type:t,aliasOf:"view.map.ground.surfaceColor"})],Xe.prototype,"backgroundColor",void 0),e([L()],Xe.prototype,"_background",null),e([L({value:!1})],Xe.prototype,"slicePlaneEnabled",null),e([L({readOnly:!0})],Xe.prototype,"tilingScheme",void 0),e([L({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Xe.prototype,"tilingSchemeLocked",void 0),e([L({readOnly:!0})],Xe.prototype,"tilingSchemeLogic",void 0),e([L({value:!0})],Xe.prototype,"velvetOverground",null),e([S("_renderer.wireframe")],Xe.prototype,"wireframe",void 0),e([L({value:!1})],Xe.prototype,"suspended",null),e([L({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Xe.prototype,"textureFadeDuration",void 0),e([L()],Xe.prototype,"_layerViewsDirty",void 0),e([S("_renderer.renderPatchBorders")],Xe.prototype,"renderPatchBorders",void 0),e([S("_renderer.renderingDisabled")],Xe.prototype,"renderingDisabled",void 0),Xe=e([E("esri.views.3d.terrain.TerrainSurface")],Xe);const ze=Xe;function Ye(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function $e(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>$e(e))))}function Ke(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const Je=-1,Ze=P(),et=M(),tt=[0,0,0],it=new _,rt={spatialReference:null,tile:null,extent:null,context:"ground"},st={spatialReference:null,extent:null,scale:0};export{ze as default};
|
package/views/3d/terrain/Tile.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clamp as e}from"../../../core/mathUtils.js";import{isSome as t,abortMaybe as i,isNone as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{c as r,b as a}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{b as l,p as h,e as d,g as u,a as c,l as g}from"../../../chunks/vec3.js";import{c as f,u as p}from"../../../chunks/vec3f64.js";import{E as _}from"../../../chunks/common.js";import{getReferenceEllipsoid as m}from"../../../geometry/projectionEllipsoid.js";import{create as T,equals as E}from"../../../geometry/support/aaBoundingRect.js";import{c as A}from"../../../chunks/sphere.js";import{VectorTile as y}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as v}from"../support/StreamDataLoader.js";import{ElevationBounds as S}from"./ElevationBounds.js";import{ElevationTileAgent as L}from"./ElevationTileAgent.js";import{NeighborIndex as M,LODSnapping as N,TextureUpdate as I}from"./interfaces.js";import{LayerClass as O,LayerClasses as D}from"./LayerClass.js";import{MapTileAgent as b}from"./MapTileAgent.js";import{RasterTile as U}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as x,getElevationDesiredResolutionLevel as R}from"./TerrainConst.js";import{weakAssert as j,getLayerWithExtentRange as C,internalAssert as H,ENABLE_WATERPROOFNESS_TESTS as W}from"./terrainUtils.js";import{TILE_AGENT_DONE as P}from"./TileAgent.js";import{TilePerLayerInfo as B}from"./TilePerLayerInfo.js";import G from"./TileTexture.js";import{TileUpdate as V}from"./TileUpdate.js";import{fallsWithinLayer as w}from"./tileUtils.js";import{getGpuMemoryUsage as q}from"../../webgl/Util.js";const F=f(),k=f(),X=f(),z=.1;class J{constructor(){this.fovX=0,this.fovY=0,this.relativeWidthLimit=0,this.relativeHeightLimit=0,this.maxLod=0,this.angledSplitBias=0,this.aboveGround=!0}}class Y{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=T(),this._elevationBounds=o(),this.layerInfo=[[],[]],this.extentInRadians=T(),this.centerAtSeaLevel=f(),this._center=[f(),A(),f()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=te,this._mapTileMemory=0,this._mapDataRefCount=0,this._screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0}static prune(){K.prune(0),Z.prune(0),B.prune()}get usedMemory(){return this._usedMemory===te&&this._updateMemoryUsed(),this._usedMemory+(this.isCached?0:this.mapTileMemory)}get cachedMemory(){return this.isCached?this.mapTileMemory:0}get mapTileMemory(){this._usedMemory===te&&this._updateMemoryUsed();let e=this._mapTileMemory;for(const{data:t}of this.layerInfo[O.MAP])t instanceof y&&(e+=t.memoryUsage);return e}get isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[ie.MIDDLE][3]}get screenDepth(){return this._screenDepth}get visible(){return this._dirty&&this.computeVisibility(),this._visible}computeVisibility(){this._dirty=!1;const e=this._intersectsClippingArea&&this._isVisible(this.surface.frustum);return e!==this._visible&&(this._visible=e,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setNeedsRender(),this.updateAgentSuspension()),this._visible}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setNeedsRender()),e}get shouldLoad(){if(!this.loadable)return!1;if(this._surface.lodSnapping===N.ON){const e=this.level-this._surface.snapLevel;if(0===e)return!0;if(1===e)return!1}return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=m(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[ie.MIDDLE][3]=0,this.vlevel=e?e[0]:0,t&&t.elevationBounds?r(this._elevationBounds,t.elevationBounds):a(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this._screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of D){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=B.acquire(this._surface.upsampleInfoPool),s===O.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,x)}release(){j(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of D){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null,this._surface=null,this._usedMemory=te}refMapData(){++this._mapDataRefCount,this.isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this.isCached){const e=this.cachedMemory;e>0&&(this._surface.upsampleMapCache.put(this.key,this,e),this.setMemoryDirty())}}setMemoryDirty(){this._usedMemory=te}get cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_updateMemoryUsed(){this._usedMemory=0,this._mapTileMemory=0;const e=this.cpuImageMemorySize;for(const{data:t}of this.layerInfo[O.MAP])t instanceof G?this._mapTileMemory+=q(t.texture):t instanceof HTMLImageElement||t instanceof v?this._mapTileMemory+=e:t instanceof U&&(this._mapTileMemory+=t.memoryUsage);for(const t of this.layerInfo[O.ELEVATION])this._usedMemory+=t.data?e:0;this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemory+=q(this.renderData.textureDescriptor)),this.isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this.cachedMemory)}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];if(!i||!i.data)return 0;if(e!==O.MAP||this.isCached){if(e===O.ELEVATION)return this.cpuImageMemorySize}else{const e=i.data;if(e instanceof G)return q(e.texture);if(e instanceof HTMLImageElement||e instanceof v)return this.cpuImageMemorySize;if(e instanceof y||e instanceof U)return e.memoryUsage}return 0}updateScreenDepth(e){const t=this._center[ie.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this._screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,i,s){if(t(e.frustum)&&(!this._intersectsClippingArea||!this._isVisible(e.frustum)))return V.NONE;const n=this.level;l(F,this._center[ie.MIDDLE],i);let r=h(F),a=ie.MIDDLE;l(k,this._center[ie.TOP],i);const o=h(k);o<r&&(r=o,a=ie.TOP),l(k,this._center[ie.BOTTOM],i);const f=h(k);if(f<r&&(r=f,a=ie.BOTTOM),this._edgeLen2>r&&n<e.maxLod)return V.SPLIT;const p=Math.sqrt(r),_=e.fovX*p*2,m=this._edgeLen/_,T=()=>{const t=n+Math.ceil(-Math.log2(e.relativeWidthLimit/m));return t!==this.vlevel?(this.vlevel=t,V.VSPLITMERGE):V.NONE_HIT_MAXLOD};if(s===N.ON){if(1===this._surface.snapLevel-n)return n>=e.maxLod?T():V.SPLIT}const E=d(this.up,F),A=this._elevationBounds[1]-this._elevationBounds[0],y=A/this.edgeLen;if(e.aboveGround&&E>0&&y<.001){if(E/p-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-y>0)return V.NONE}if(m<e.relativeWidthLimit)return this.vlevel!==this.level?(this.vlevel=this.level,V.VSPLITMERGE):V.NONE;if(n>=e.maxLod)return T();if(n>6){l(k,this._center[a],i),u(X,this.up,E),l(X,X,k);const t=h(X);if(t>this.radius*this.radius){u(X,X,this.radius/Math.sqrt(t)),c(X,X,this._center[a]),l(X,i,X);const s=Math.min(1,(Math.abs(d(X,this.up))+.5*A+this._curvatureHeight)/g(X)),n=z/e.angledSplitBias,r=e.fovY*p*2;if(s*(this._edgeLen/r)<n*e.relativeHeightLimit)return V.NONE}}return V.SPLIT}setChildren(e,t,i,s){j(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){var e,t;return null!=(e=null==(t=this.renderData)?void 0:t.hasGeometry)&&e}prepareToLoad(e){this.refMapData();for(const t of D)this._createOrUpdateAgents(0,t);e.updateTileGeometryState(this)}load(e){this.prepareToLoad(e),this.loadPrepared(e)}loadPrepared(e){e.loadTile(this)}unload(e){e.unloadTile(this);for(const t of D){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==P&&(Q(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(V.GEOMETRY),this.resetPendingUpdate(V.TEXTURE_NOFADING),this.resetPendingUpdate(V.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[O.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==P&&(Q(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(E(e,this._clippingArea))return!1;const i=this._intersectsClippingArea,s=this._isWithinClippingArea;t(e)?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const n=s&&this._isWithinClippingArea,r=!(s||i||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||n||r||this.setPendingUpdate(V.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of D){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==P&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(V.SPLIT)||e!==O.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===V.SPLIT||e===V.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated)return console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),s.dataArrived(this),!0;if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;if(this.isLeaf)return null;const t=this._children[0].findByLij(e)||this._children[1].findByLij(e)||this._children[2].findByLij(e)||this._children[3].findByLij(e);return t||null}distanceToSquared(e){return h(l(X,this._center[ie.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);j(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this._updateMemoryUsed())}dataArrived(e,t,i){const s=this.layerInfo[t][e];s.data=i,s.dataInvalidated=!1,s.waitingAgents.forAll((e=>e.dataArrived(this))),s.waitingAgents.clear(),this._updateMemoryUsed()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this._updateMemoryUsed()}updateRenderData(e,t){switch(e){case O.MAP:return this._updateTexture(t);case O.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===I.FADING?V.TEXTURE_NOFADING:V.TEXTURE_FADING),this.setPendingUpdate(e===I.FADING?V.TEXTURE_FADING:V.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(V.GEOMETRY);for(const e of this.layerInfo[O.ELEVATION])e.pendingUpdates|=V.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds;a(e,Number.MAX_VALUE,-Number.MAX_VALUE);const i=this.layerInfo[O.ELEVATION];let s=!0;for(const n of i)t(n.elevationBounds)&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(s=!1));s&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),this.updateRadiusAndCenter(),this._surface.setTileTreeDirty()}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]);u(X,this.up,t),c(this._center[ie.MIDDLE],this.centerAtSeaLevel,X),u(X,this.up,e[0]),c(this._center[ie.TOP],this.centerAtSeaLevel,X),u(X,this.up,e[1]),c(this._center[ie.BOTTOM],this.centerAtSeaLevel,X)}findElevationBoundsForLayer(e,i){const n=this.layerInfo[O.ELEVATION][e];if(t(n.elevationBounds)&&n.elevationBounds.level>=i)return;const r=this._surface.layerViewByIndex(e,O.ELEVATION),a=C(r);if(!w(this,a,!1))return;const o=ee;let l=!1;if(n.data){const e=n.data;o.min=e.bounds[0],o.max=e.bounds[1],o.hasNoDataValues=e.hasNoDataValues,o.level=this.level,l=!0}else{let t,i,s=0;for(let n=this._parent;n&&(!i||s<R(this.level))&&(s=this.vlevel-n.level,t=i||t,i=n.layerInfo[O.ELEVATION][e].data,!(!i&&t&&s>=R(this.level)));n=n.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],o),o.min!==1/0&&(o.level=i.level,l=!0))}l&&(s(n.elevationBounds)&&(n.elevationBounds=new S),n.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==P&&(Q(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:B.acquire(this._surface.upsampleInfoPool)}this._updateMemoryUsed()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,I.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===P&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of D){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==P&&(i.loadingAgent.setSuspension(t),i.loadingAgent===P&&this.updateRenderData(e,I.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==P&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=P,!i.data&&s(i.upsampleInfo)&&this._createOrUpdateAgents(e+1,t)}_createOrUpdateAgents(e,t){const i=this._isSuspended(t),s=this.layerInfo[t];for(let n=e;n<s.length;++n){const e=s[n];let r=!1;const a=this._surface.layerViewByIndex(n,t),o=C(a);if(e.loadingAgent?w(this,o,!1)?(e.loadingAgent!==P&&e.loadingAgent.setSuspension(i),e.loadingAgent!==P&&(r=e.loadingAgent.update())):e.dispose():w(this,o,!1)&&(e.loadingAgent=$(this,n,t,i),r=e.loadingAgent.startLoading(),r?e.loadingAgent===P&&this.setPendingUpdate(V.GEOMETRY):(Q(e.loadingAgent),e.loadingAgent=P)),e.loadingAgent===P&&this.updateRenderData(t,I.FADING),r&&a.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationBasedVerticesPerSide(t){const i=this.vlevel-this.level,s=Math.max(this.level-t,R(this.level)-i);return e(1+(this.maxTesselation>>s),2,this.maxTesselation+1)}get test(){return{cachedMemory:this.cachedMemory}}_findLIJ(e,i){if(!e)return null;const s=this.surface.rootTiles;if(t(s))for(const t of s)if(se(t,e)){let s=t,n=e[0]-s.level-1;for(;n>=0&&!s.isLeaf&&!i(s);){const t=e[1]>>n&1,i=e[2]>>n&1;s=s.children[2*t+i],n--}return i(s)?s:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?ne(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===M.NORTH_EAST?1:e===M.NORTH_WEST?0:e===M.SOUTH_WEST?2:3;let s=this;for(;!(s.isLeaf||t&&t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){var i;return null==(i=this.findNeighborTile(e,(e=>t(e)||e.level===this.level)))?void 0:i.findCorner(de(e),t)}forAllSubtreeOnSide(e,t){const i=e===M.NORTH?[0,1]:e===M.NORTH_EAST?[1]:e===M.EAST?[1,3]:e===M.SOUTH_EAST?[3]:e===M.SOUTH?[2,3]:e===M.SOUTH_WEST?[2]:e===M.WEST?[0,2]:[0],s=e=>{t(e)||e.isLeaf||i.forEach((t=>s(e.children[t])))};s(this)}forallNeighbors(e){Ee.forEach((t=>this.findNeighborCornerTileExact(t,e))),Te.forEach((t=>{var i;return null==(i=this.findNeighborTile(t,(t=>t.level===this.level||e(t))))?void 0:i.forAllSubtreeOnSide(ue(t),e)}))}getNeighborEdgeStartVertexIndex(e,t){const i=null!=t?t:this.findNeighborTile(Te[e],(e=>e.isLoaded));if(!i||!this.isLoaded||!i.isLoaded)return 0;const s=this.level-i.level;if(0===s)return 0;const n=2**s,r=1==(1&e),a=r?0:1,o=i.lij[a+1]*n,l=this.lij[a+1]-o;return r?n-1-l:l}_updateNeighborsWithChangedEdgeResolution(){for(let e=0;e<4;++e)if(this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]){const t=Te[e],i=this.findNeighborTile(t,(e=>e.isLoaded||e.level===this.level));if(!i)continue;if(!i.isLoaded){H(!i.isLeaf);const s=(e+2)%4,n=ue(t);i.forAllSubtreeOnSide(n,(e=>e.isLoaded?(e.updateEdgeAfterResolutionChange(s),!0):(H(!e.isLeaf),!1)))}this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]=!1}}updateNeighborDataAndGeometryIfNeeded(){this.isLoaded&&this.renderData.updateNeighborDataAndGeometryIfNeeded()}updateNeighborsAfterGeometryChange(e=this.level){this._forEachLoadedNeighbor((e=>this._updateNeighbor(e))),Te.forEach((t=>{const i=this.findNeighborTile(t,(t=>t.isLoaded&&t.level<e));null==i||i.updateNeighborsWithChangedEdgeResolution()}))}updateNeighborsWithChangedEdgeResolution(){this.isLoaded&&this._updateNeighborsWithChangedEdgeResolution()}updateEdgeAfterResolutionChange(e){this.renderData.updateEdgeAfterResolutionChange(e)}_forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;Te.forEach(((t,s)=>{var n,r;const a=this.findNeighborTile(t,i);null!=a&&a!==this&&a.forAllSubtreeOnSide(ue(t),(t=>!!t.isLoaded&&(e(t),!0)));const o=null==(n=this.renderData)||null==(r=n.geometryState)?void 0:r.neighborData;o&&(o.modifiedEdgeResolutions[s]=!1)})),Ee.forEach((t=>{var s;const n=null==(s=this.findNeighborTile(t,i))?void 0:s.findCorner(de(t),(e=>e.isLoaded));H(!n||oe(this,n,t)),null!=n&&n.isLoaded&&e(n)}))}_updateNeighbor(e){null!=e&&e.isLoaded&&e.updateNeighborDataAndGeometryIfNeeded()}getNeighborLIJ(e,t){const i=me(t)?-1:_e(t)?1:0,s=fe(t)?-1:pe(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){return this.extent[1]+_>=this.surface.extent[1]}compareLIJs(e){const t=this.lij,i=t[0],s=e[0];if(i===s)return[t,e];const n=i-s;if(n<0){const i=2**-n;return[[s,t[1]*i,t[2]*i],e]}{const s=2**n;return[t,[i,e[1]*s,e[2]*s]]}}checkGeometryWaterproofness(){W&&(H(this.isLoaded),this.renderData.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(me(e)&&t[3]+s>=i[3])return!1;if(_e(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&fe(e)&&t[0]-s<=i[0])&&!(!n&&pe(e)&&t[2]+s>=i[2])}}function $(e,t,i,s){const n=i===O.ELEVATION?Z.acquire():K.acquire();return n.init(e,t,i,s),n}function Q(e){e.dispose(),e instanceof L?Z.release(e):e instanceof b&&K.release(e)}const K=new n(b),Z=new n(L),ee=new S,te=-1;var ie;function se(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=t[1]>>n,a=t[2]>>n;return r===e.lij[1]&&a===e.lij[2]}function ne(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function re(e,t,i){return Math.abs(e-t)<=i}function ae(e,t,i){if(!e||!t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===M.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===M.WEST)return!0}const s=1e-6*(e.extent[2]-e.extent[0]);switch(i){case M.NORTH:return re(e.extent[3],t.extent[1],s);case M.SOUTH:return re(e.extent[1],t.extent[3],s);case M.EAST:return re(e.extent[2],t.extent[0],s)||re(e.extent[2],-t.extent[0],s);case M.WEST:return re(e.extent[0],t.extent[2],s)||re(e.extent[0],-t.extent[2],s)}}function oe(e,t,i){return!(!e||!t||t===e)&&(e.level>=t.level?le(e,t,i):le(t,e,de(i)))}function le(e,t,i){H(e.level>=t.level);const s=ce(i),n=ge(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),d=re(o[0],l[0],h)||e.surface.isGlobal&&re(o[0],-l[0],h),u=re(o[1],l[1],h);if(d&&u)return!0;if(e.level===t.level)return!1;if(!d&&!u)return!1;return d?he([a[1],a[3]],[r[1],r[3]],h):he([a[0],a[2]],[r[0],r[2]],h)}function he(e,t,i=_){return e[0]-i<=t[0]&&t[0]<=t[1]&&t[1]<=e[1]+i}function de(e){return e===M.NORTH_EAST?M.SOUTH_WEST:e===M.NORTH_WEST?M.SOUTH_EAST:e===M.SOUTH_WEST?M.NORTH_EAST:M.NORTH_WEST}function ue(e){return e===M.NORTH?M.SOUTH:e===M.EAST?M.WEST:e===M.SOUTH?M.NORTH:M.EAST}function ce(e){return e===M.NORTH_WEST||e===M.SOUTH_WEST}function ge(e){return e===M.NORTH_WEST||e===M.NORTH_EAST}function fe(e){return e===M.NORTH_WEST||e===M.WEST||e===M.SOUTH_WEST}function pe(e){return e===M.NORTH_EAST||e===M.EAST||e===M.SOUTH_EAST}function _e(e){return e===M.SOUTH_EAST||e===M.SOUTH||e===M.SOUTH_WEST}function me(e){return e===M.NORTH_EAST||e===M.NORTH||e===M.NORTH_WEST}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(ie||(ie={}));const Te=[M.NORTH,M.EAST,M.SOUTH,M.WEST],Ee=[M.NORTH_EAST,M.SOUTH_EAST,M.SOUTH_WEST,M.NORTH_WEST];export{ie as CenterPosition,J as SplitLimits,Y as Tile,re as almostEquals,oe as isCornerNeighbor,pe as isEast,ae as isEdgeNeighbor,me as isNorth,ge as isNorthCorner,_e as isSouth,fe as isWest,ce as isWestCorner,Ee as neighborCornerIndices,Te as neighborEdgeIndices,de as oppositeCorner,ue as oppositeEdge};
|
|
5
|
+
import{clamp as e}from"../../../core/mathUtils.js";import{isSome as t,abortMaybe as i,isNone as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{c as r,b as a}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{b as l,p as h,e as d,g as u,a as c,l as g}from"../../../chunks/vec3.js";import{c as f,u as p}from"../../../chunks/vec3f64.js";import{E as m}from"../../../chunks/common.js";import{getReferenceEllipsoid as _}from"../../../geometry/projectionEllipsoid.js";import{create as T,equals as E}from"../../../geometry/support/aaBoundingRect.js";import{c as A}from"../../../chunks/sphere.js";import{VectorTile as y}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as v}from"../support/StreamDataLoader.js";import{ElevationBounds as S}from"./ElevationBounds.js";import{ElevationTileAgent as L}from"./ElevationTileAgent.js";import{NeighborIndex as M,LODSnapping as N,TextureUpdate as I}from"./interfaces.js";import{LayerClass as O,LayerClasses as D}from"./LayerClass.js";import{MapTileAgent as b}from"./MapTileAgent.js";import{RasterTile as U}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as x,getElevationDesiredResolutionLevel as R}from"./TerrainConst.js";import{weakAssert as j,getLayerWithExtentRange as C,internalAssert as H,ENABLE_WATERPROOFNESS_TESTS as W}from"./terrainUtils.js";import{TILE_AGENT_DONE as P}from"./TileAgent.js";import{TilePerLayerInfo as B}from"./TilePerLayerInfo.js";import G from"./TileTexture.js";import{TileUpdate as V}from"./TileUpdate.js";import{fallsWithinLayer as w}from"./tileUtils.js";import{getGpuMemoryUsage as q}from"../../webgl/Util.js";const F=f(),k=f(),X=f(),z=.1;class J{constructor(){this.fovX=0,this.fovY=0,this.relativeWidthLimit=0,this.relativeHeightLimit=0,this.maxLod=0,this.angledSplitBias=0,this.aboveGround=!0}}class Y{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=T(),this._elevationBounds=o(),this.layerInfo=[[],[]],this.extentInRadians=T(),this.centerAtSeaLevel=f(),this._center=[f(),A(),f()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=te,this._mapTileMemory=0,this._mapDataRefCount=0,this._screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0}static prune(){K.prune(0),Z.prune(0),B.prune()}get usedMemory(){return this._usedMemory===te&&this._updateMemoryUsed(),this._usedMemory+(this.isCached?0:this.mapTileMemory)}get cachedMemory(){return this.isCached?this.mapTileMemory:0}get mapTileMemory(){this._usedMemory===te&&this._updateMemoryUsed();let e=this._mapTileMemory;for(const{data:t}of this.layerInfo[O.MAP])t instanceof y&&(e+=t.memoryUsage);return e}get isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[ie.MIDDLE][3]}get screenDepth(){return this._screenDepth}get visible(){return this._dirty&&this.computeVisibility(),this._visible}computeVisibility(){this._dirty=!1;const e=this._intersectsClippingArea&&this._isVisible(this.surface.frustum);return e!==this._visible&&(this._visible=e,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setNeedsRender(),this.updateAgentSuspension()),this._visible}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setNeedsRender()),e}get shouldLoad(){if(this._surface.lodSnapping===N.ON){const e=this.level-this._surface.snapLevel;if(0===e)return!0;if(1===e)return!1}return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=_(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[ie.MIDDLE][3]=0,this.vlevel=e?e[0]:0,t&&t.elevationBounds?r(this._elevationBounds,t.elevationBounds):a(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this._screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of D){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=B.acquire(this._surface.upsampleInfoPool),s===O.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,x)}release(){j(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of D){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null,this._surface=null,this._usedMemory=te}refMapData(){++this._mapDataRefCount,this.isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this.isCached){const e=this.cachedMemory;e>0&&(this._surface.upsampleMapCache.put(this.key,this,e),this.setMemoryDirty())}}setMemoryDirty(){this._usedMemory=te}get cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_updateMemoryUsed(){this._usedMemory=0,this._mapTileMemory=0;const e=this.cpuImageMemorySize;for(const{data:t}of this.layerInfo[O.MAP])t instanceof G?this._mapTileMemory+=q(t.texture):t instanceof HTMLImageElement||t instanceof v?this._mapTileMemory+=e:t instanceof U&&(this._mapTileMemory+=t.memoryUsage);for(const t of this.layerInfo[O.ELEVATION])this._usedMemory+=t.data?e:0;this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemory+=q(this.renderData.textureDescriptor)),this.isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this.cachedMemory)}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];if(!i||!i.data)return 0;if(e!==O.MAP||this.isCached){if(e===O.ELEVATION)return this.cpuImageMemorySize}else{const e=i.data;if(e instanceof G)return q(e.texture);if(e instanceof HTMLImageElement||e instanceof v)return this.cpuImageMemorySize;if(e instanceof y||e instanceof U)return e.memoryUsage}return 0}updateScreenDepth(e){const t=this._center[ie.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this._screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,i,s){if(t(e.frustum)&&(!this._intersectsClippingArea||!this._isVisible(e.frustum)))return V.NONE;const n=this.level;l(F,this._center[ie.MIDDLE],i);let r=h(F),a=ie.MIDDLE;l(k,this._center[ie.TOP],i);const o=h(k);o<r&&(r=o,a=ie.TOP),l(k,this._center[ie.BOTTOM],i);const f=h(k);if(f<r&&(r=f,a=ie.BOTTOM),this._edgeLen2>r&&n<e.maxLod)return V.SPLIT;const p=Math.sqrt(r),m=e.fovX*p*2,_=this._edgeLen/m,T=()=>{const t=n+Math.ceil(-Math.log2(e.relativeWidthLimit/_));return t!==this.vlevel?(this.vlevel=t,V.VSPLITMERGE):V.NONE_HIT_MAXLOD};if(s===N.ON){if(1===this._surface.snapLevel-n)return n>=e.maxLod?T():V.SPLIT}const E=d(this.up,F),A=this._elevationBounds[1]-this._elevationBounds[0],y=A/this.edgeLen;if(e.aboveGround&&E>0&&y<.001){if(E/p-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-y>0)return V.NONE}if(_<e.relativeWidthLimit)return this.vlevel!==this.level?(this.vlevel=this.level,V.VSPLITMERGE):V.NONE;if(n>=e.maxLod)return T();if(n>6){l(k,this._center[a],i),u(X,this.up,E),l(X,X,k);const t=h(X);if(t>this.radius*this.radius){u(X,X,this.radius/Math.sqrt(t)),c(X,X,this._center[a]),l(X,i,X);const s=Math.min(1,(Math.abs(d(X,this.up))+.5*A+this._curvatureHeight)/g(X)),n=z/e.angledSplitBias,r=e.fovY*p*2;if(s*(this._edgeLen/r)<n*e.relativeHeightLimit)return V.NONE}}return V.SPLIT}setChildren(e,t,i,s){j(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){var e,t;return null!=(e=null==(t=this.renderData)?void 0:t.hasGeometry)&&e}prepareToLoad(e){this.refMapData();for(const t of D)this._createOrUpdateAgents(0,t);e.updateTileGeometryState(this)}load(e){this.prepareToLoad(e),this.loadPrepared(e)}loadPrepared(e){e.loadTile(this)}unload(e){e.unloadTile(this);for(const t of D){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==P&&(Q(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(V.GEOMETRY),this.resetPendingUpdate(V.TEXTURE_NOFADING),this.resetPendingUpdate(V.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[O.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==P&&(Q(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(E(e,this._clippingArea))return!1;const i=this._intersectsClippingArea,s=this._isWithinClippingArea;t(e)?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const n=s&&this._isWithinClippingArea,r=!(s||i||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||n||r||this.setPendingUpdate(V.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of D){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==P&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(V.SPLIT)||e!==O.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===V.SPLIT||e===V.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated)return console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),s.dataArrived(this),!0;if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;if(this.isLeaf)return null;const t=this._children[0].findByLij(e)||this._children[1].findByLij(e)||this._children[2].findByLij(e)||this._children[3].findByLij(e);return t||null}distanceToSquared(e){return h(l(X,this._center[ie.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);j(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this._updateMemoryUsed())}dataArrived(e,t,i){const s=this.layerInfo[t][e];s.data=i,s.dataInvalidated=!1,s.waitingAgents.forAll((e=>e.dataArrived(this))),s.waitingAgents.clear(),this._updateMemoryUsed()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this._updateMemoryUsed()}updateRenderData(e,t){switch(e){case O.MAP:return this._updateTexture(t);case O.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===I.FADING?V.TEXTURE_NOFADING:V.TEXTURE_FADING),this.setPendingUpdate(e===I.FADING?V.TEXTURE_FADING:V.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(V.GEOMETRY);for(const e of this.layerInfo[O.ELEVATION])e.pendingUpdates|=V.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds;a(e,Number.MAX_VALUE,-Number.MAX_VALUE);const i=this.layerInfo[O.ELEVATION];let s=!0;for(const n of i)t(n.elevationBounds)&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(s=!1));s&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),this.updateRadiusAndCenter(),this._surface.setTileTreeDirty()}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]);u(X,this.up,t),c(this._center[ie.MIDDLE],this.centerAtSeaLevel,X),u(X,this.up,e[0]),c(this._center[ie.TOP],this.centerAtSeaLevel,X),u(X,this.up,e[1]),c(this._center[ie.BOTTOM],this.centerAtSeaLevel,X)}findElevationBoundsForLayer(e,i){const n=this.layerInfo[O.ELEVATION][e];if(t(n.elevationBounds)&&n.elevationBounds.level>=i)return;const r=this._surface.layerViewByIndex(e,O.ELEVATION),a=C(r);if(!w(this,a,!1))return;const o=ee;let l=!1;if(n.data){const e=n.data;o.min=e.bounds[0],o.max=e.bounds[1],o.hasNoDataValues=e.hasNoDataValues,o.level=this.level,l=!0}else{let t,i,s=0;for(let n=this._parent;n&&(!i||s<R(this.level))&&(s=this.vlevel-n.level,t=i||t,i=n.layerInfo[O.ELEVATION][e].data,!(!i&&t&&s>=R(this.level)));n=n.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],o),o.min!==1/0&&(o.level=i.level,l=!0))}l&&(s(n.elevationBounds)&&(n.elevationBounds=new S),n.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==P&&(Q(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:B.acquire(this._surface.upsampleInfoPool)}this._updateMemoryUsed()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,I.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===P&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of D){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==P&&(i.loadingAgent.setSuspension(t),i.loadingAgent===P&&this.updateRenderData(e,I.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==P&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=P,!i.data&&s(i.upsampleInfo)&&this._createOrUpdateAgents(e+1,t)}_createOrUpdateAgents(e,t){const i=this._isSuspended(t),s=this.layerInfo[t];for(let n=e;n<s.length;++n){const e=s[n];let r=!1;const a=this._surface.layerViewByIndex(n,t),o=C(a);if(e.loadingAgent?w(this,o,!1)?(e.loadingAgent!==P&&e.loadingAgent.setSuspension(i),e.loadingAgent!==P&&(r=e.loadingAgent.update())):e.dispose():w(this,o,!1)&&(e.loadingAgent=$(this,n,t,i),r=e.loadingAgent.startLoading(),r?e.loadingAgent===P&&this.setPendingUpdate(V.GEOMETRY):(Q(e.loadingAgent),e.loadingAgent=P)),e.loadingAgent===P&&this.updateRenderData(t,I.FADING),r&&a.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationBasedVerticesPerSide(t){const i=this.vlevel-this.level,s=Math.max(this.level-t,R(this.level)-i);return e(1+(this.maxTesselation>>s),2,this.maxTesselation+1)}get test(){return{cachedMemory:this.cachedMemory}}_findLIJ(e,i){if(!e)return null;const s=this.surface.rootTiles;if(t(s))for(const t of s)if(se(t,e)){let s=t,n=e[0]-s.level-1;for(;n>=0&&!s.isLeaf&&!i(s);){const t=e[1]>>n&1,i=e[2]>>n&1;s=s.children[2*t+i],n--}return i(s)?s:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?ne(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===M.NORTH_EAST?1:e===M.NORTH_WEST?0:e===M.SOUTH_WEST?2:3;let s=this;for(;!(s.isLeaf||t&&t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){var i;return null==(i=this.findNeighborTile(e,(e=>t(e)||e.level===this.level)))?void 0:i.findCorner(de(e),t)}forAllSubtreeOnSide(e,t){const i=e===M.NORTH?[0,1]:e===M.NORTH_EAST?[1]:e===M.EAST?[1,3]:e===M.SOUTH_EAST?[3]:e===M.SOUTH?[2,3]:e===M.SOUTH_WEST?[2]:e===M.WEST?[0,2]:[0],s=e=>{t(e)||e.isLeaf||i.forEach((t=>s(e.children[t])))};s(this)}forallNeighbors(e){Ee.forEach((t=>this.findNeighborCornerTileExact(t,e))),Te.forEach((t=>{var i;return null==(i=this.findNeighborTile(t,(t=>t.level===this.level||e(t))))?void 0:i.forAllSubtreeOnSide(ue(t),e)}))}getNeighborEdgeStartVertexIndex(e,t){const i=null!=t?t:this.findNeighborTile(Te[e],(e=>e.isLoaded));if(!i||!this.isLoaded||!i.isLoaded)return 0;const s=this.level-i.level;if(0===s)return 0;const n=2**s,r=1==(1&e),a=r?0:1,o=i.lij[a+1]*n,l=this.lij[a+1]-o;return r?n-1-l:l}_updateNeighborsWithChangedEdgeResolution(){for(let e=0;e<4;++e)if(this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]){const t=Te[e],i=this.findNeighborTile(t,(e=>e.isLoaded||e.level===this.level));if(!i)continue;if(!i.isLoaded){H(!i.isLeaf);const s=(e+2)%4,n=ue(t);i.forAllSubtreeOnSide(n,(e=>e.isLoaded?(e.updateEdgeAfterResolutionChange(s),!0):(H(!e.isLeaf),!1)))}this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]=!1}}updateNeighborDataAndGeometryIfNeeded(){this.isLoaded&&this.renderData.updateNeighborDataAndGeometryIfNeeded()}updateNeighborsAfterGeometryChange(e=this.level){this.forEachLoadedNeighbor((e=>this._updateNeighbor(e))),Te.forEach((t=>{const i=this.findNeighborTile(t,(t=>t.isLoaded&&t.level<e));null==i||i.updateNeighborsWithChangedEdgeResolution()}))}updateNeighborsWithChangedEdgeResolution(){this.isLoaded&&this._updateNeighborsWithChangedEdgeResolution()}updateEdgeAfterResolutionChange(e){this.renderData.updateEdgeAfterResolutionChange(e)}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;Te.forEach(((t,s)=>{var n,r;const a=this.findNeighborTile(t,i);null!=a&&a!==this&&a.forAllSubtreeOnSide(ue(t),(t=>!!t.isLoaded&&(e(t),!0)));const o=null==(n=this.renderData)||null==(r=n.geometryState)?void 0:r.neighborData;o&&(o.modifiedEdgeResolutions[s]=!1)})),Ee.forEach((t=>{var s;const n=null==(s=this.findNeighborTile(t,i))?void 0:s.findCorner(de(t),(e=>e.isLoaded));H(!n||oe(this,n,t)),null!=n&&n.isLoaded&&e(n)}))}_updateNeighbor(e){null!=e&&e.isLoaded&&e.updateNeighborDataAndGeometryIfNeeded()}getNeighborLIJ(e,t){const i=_e(t)?-1:me(t)?1:0,s=fe(t)?-1:pe(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){return this.extent[1]+m>=this.surface.extent[1]}compareLIJs(e){const t=this.lij,i=t[0],s=e[0];if(i===s)return[t,e];const n=i-s;if(n<0){const i=2**-n;return[[s,t[1]*i,t[2]*i],e]}{const s=2**n;return[t,[i,e[1]*s,e[2]*s]]}}checkGeometryWaterproofness(){W&&(H(this.isLoaded),this.renderData.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(_e(e)&&t[3]+s>=i[3])return!1;if(me(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&fe(e)&&t[0]-s<=i[0])&&!(!n&&pe(e)&&t[2]+s>=i[2])}}function $(e,t,i,s){const n=i===O.ELEVATION?Z.acquire():K.acquire();return n.init(e,t,i,s),n}function Q(e){e.dispose(),e instanceof L?Z.release(e):e instanceof b&&K.release(e)}const K=new n(b),Z=new n(L),ee=new S,te=-1;var ie;function se(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=t[1]>>n,a=t[2]>>n;return r===e.lij[1]&&a===e.lij[2]}function ne(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function re(e,t,i){return Math.abs(e-t)<=i}function ae(e,t,i){if(!e||!t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===M.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===M.WEST)return!0}const s=1e-6*(e.extent[2]-e.extent[0]);switch(i){case M.NORTH:return re(e.extent[3],t.extent[1],s);case M.SOUTH:return re(e.extent[1],t.extent[3],s);case M.EAST:return re(e.extent[2],t.extent[0],s)||re(e.extent[2],-t.extent[0],s);case M.WEST:return re(e.extent[0],t.extent[2],s)||re(e.extent[0],-t.extent[2],s)}}function oe(e,t,i){return!(!e||!t||t===e)&&(e.level>=t.level?le(e,t,i):le(t,e,de(i)))}function le(e,t,i){H(e.level>=t.level);const s=ce(i),n=ge(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),d=re(o[0],l[0],h)||e.surface.isGlobal&&re(o[0],-l[0],h),u=re(o[1],l[1],h);if(d&&u)return!0;if(e.level===t.level)return!1;if(!d&&!u)return!1;return d?he([a[1],a[3]],[r[1],r[3]],h):he([a[0],a[2]],[r[0],r[2]],h)}function he(e,t,i=m){return e[0]-i<=t[0]&&t[0]<=t[1]&&t[1]<=e[1]+i}function de(e){return e===M.NORTH_EAST?M.SOUTH_WEST:e===M.NORTH_WEST?M.SOUTH_EAST:e===M.SOUTH_WEST?M.NORTH_EAST:M.NORTH_WEST}function ue(e){return e===M.NORTH?M.SOUTH:e===M.EAST?M.WEST:e===M.SOUTH?M.NORTH:M.EAST}function ce(e){return e===M.NORTH_WEST||e===M.SOUTH_WEST}function ge(e){return e===M.NORTH_WEST||e===M.NORTH_EAST}function fe(e){return e===M.NORTH_WEST||e===M.WEST||e===M.SOUTH_WEST}function pe(e){return e===M.NORTH_EAST||e===M.EAST||e===M.SOUTH_EAST}function me(e){return e===M.SOUTH_EAST||e===M.SOUTH||e===M.SOUTH_WEST}function _e(e){return e===M.NORTH_EAST||e===M.NORTH||e===M.NORTH_WEST}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(ie||(ie={}));const Te=[M.NORTH,M.EAST,M.SOUTH,M.WEST],Ee=[M.NORTH_EAST,M.SOUTH_EAST,M.SOUTH_WEST,M.NORTH_WEST];export{ie as CenterPosition,J as SplitLimits,Y as Tile,re as almostEquals,oe as isCornerNeighbor,pe as isEast,ae as isEdgeNeighbor,_e as isNorth,ge as isNorthCorner,me as isSouth,fe as isWest,ce as isWestCorner,Ee as neighborCornerIndices,Te as neighborEdgeIndices,de as oppositeCorner,ue as oppositeEdge};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as t,isNone as e}from"../../../core/maybe.js";import n from"../../../core/PooledArray.js";class r{constructor(){this._queue=new n,this._last=null,this.remove=()=>{}}get done(){return 0===this._queue.length&&(!this._last||this._last.isLeaf)}resetOne(t){this._queue.clear(),this._queue.push(t),this._last=null}reset(e=null){this._queue.clear(),t(e)&&this._queue.pushArray(e),this._last=null}skipSubtree(){this._last=null}next(){return this._last&&!this._last.isLeaf&&this._queue.pushArray(this._last.children),this._last=this._queue.pop(),this._last}}class
|
|
5
|
+
import{isSome as t,isNone as e}from"../../../core/maybe.js";import n from"../../../core/PooledArray.js";class r{constructor(){this._queue=new n,this._last=null,this.remove=()=>{}}get done(){return 0===this._queue.length&&(!this._last||this._last.isLeaf)}resetOne(t){this._queue.clear(),this._queue.push(t),this._last=null}reset(e=null){this._queue.clear(),t(e)&&this._queue.pushArray(e),this._last=null}skipSubtree(){this._last=null}next(){return this._last&&!this._last.isLeaf&&this._queue.pushArray(this._last.children),this._last=this._queue.pop(),this._last}}class i{constructor(){this.q=new n}get done(){return 0===this.q.length}reset(t){if(this.q.clear(),!e(t)){this.q.pushArray(t);for(let t=0;t<this.q.length;++t){const e=this.q.data[t];e.isLeaf||this.q.pushArray(e.children)}}}next(){return this.q.pop()}}function s(t,e){if(Array.isArray(t))for(let n=0;n<t.length;n++)l(t[n],e);else l(t,e)}function l(t,e){if(e(t),!t.isLeaf)for(const n of t.children)l(n,e)}function u(t,n,r){if(e(n)||e(n.fullExtent))return!1;const i=n.fullExtent,s=t.extent;if(r){if(s[0]<i.xmin||s[1]<i.ymin||s[2]>i.xmax||s[3]>i.ymax)return!1}else if(i.xmin>s[2]||i.ymin>s[3]||i.xmax<s[0]||i.ymax<s[1])return!1;const l=t.surface.tilingScheme.levels[t.level].scale;return!(n.minScale>0&&l>1.00000001*n.minScale)&&!(n.maxScale>0&&l<.99999999*n.maxScale)}function o(t,e){return t.lij[0]-e.lij[0]||t.lij[1]-e.lij[1]||t.lij[2]-e.lij[2]}function a(t,e){e.sort(((e,n)=>h(e,n,t)))}function h(t,e,n){const r=t.screenDepth,i=e.screenDepth;return r<i?-n:r>i?n:o(t,e)}function c(t,e){const n=new Map;t.forAll((t=>n.set(t.lij,t.distanceToSquared(e)))),t.sort(((t,e)=>n.get(t.lij)-n.get(e.lij)||o(t,e)))}function f(t,e,n){let r=1,i=0,s=0;for(;t!==e;)if(r*=.5,i*=.5,s*=.5,1&t.lij[2]&&(i+=.5),0==(1&t.lij[1])&&(s+=.5),null==(t=t.parent))throw new Error("tile was not a descendant of upsampleTile");n.init(e,i,s,r)}function m(t){for(let e=0;e<t.length;e++){const n=t[e],r=n.parent;if(r)for(let t=0;t<4;t++){const e=r.children[t];if(e&&e!==n)return!0}}return!1}function p(t,e){if(!t||!e||t[0]===e[0])return!1;const n=t[0]<e[0],r=n?t:e,i=n?e:t,s=1<<i[0]-r[0];return Math.floor(i[1]/s)===r[1]&&Math.floor(i[2]/s)===r[2]}export{i as IteratorPostorder,r as IteratorPreorder,h as compareTiles,f as computeUpsampleInfo,u as fallsWithinLayer,m as hasLoadableSiblings,a as sortTiles,c as sortTilesByPOI,p as tilesAreRelated,s as traverseTilesPreorder};
|