@arcgis/core 4.29.0-next.20231219 → 4.29.0-next.20231221
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/analysis/Analysis.js +1 -1
- package/applications/WebEditor/sketchUtils.js +1 -1
- package/assets/components/assets/icon/hexagon16.json +1 -0
- package/assets/components/assets/icon/hexagon24.json +1 -0
- package/assets/components/assets/icon/hexagon32.json +1 -0
- package/assets/components/assets/icon/octagon16.json +1 -0
- package/assets/components/assets/icon/octagon24.json +1 -0
- package/assets/components/assets/icon/octagon32.json +1 -0
- package/assets/esri/core/libs/libtess/libtess.wasm +0 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/00b340b4495bfabd4ca2.js +1 -0
- package/assets/esri/core/workers/chunks/{4301736368af52b94ee2.js → 02d6e2f0b1003534a077.js} +1 -1
- package/assets/esri/core/workers/chunks/050132142f4887c62724.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/0e315452f11b112523f0.js +1 -0
- package/assets/esri/core/workers/chunks/0f5a197f0a4b3a354bcd.js +1 -0
- package/assets/esri/core/workers/chunks/1187ba315883ff27e2d9.js +1 -0
- package/assets/esri/core/workers/chunks/1254a544d369d99ccf59.js +1 -0
- package/assets/esri/core/workers/chunks/138d138a5d33b2f5d8a4.js +1 -0
- package/assets/esri/core/workers/chunks/1a73dcbb49d17f16ed5a.js +1 -0
- package/assets/esri/core/workers/chunks/1c2b17d22f97d56f6212.js +1 -0
- package/assets/esri/core/workers/chunks/{0be38fd63e870341c660.js → 220fcc25578b2ef316da.js} +1 -1
- package/assets/esri/core/workers/chunks/251ceefdea4b345698a4.js +1 -0
- package/assets/esri/core/workers/chunks/28aafc7ea522663909b8.js +1 -0
- package/assets/esri/core/workers/chunks/30749bcd1a7b98a38386.js +1 -0
- package/assets/esri/core/workers/chunks/320a75ff760295d9af91.js +1 -0
- package/assets/esri/core/workers/chunks/{c9f8354d51f701cd69e5.js → 321dcff84c31c739ed93.js} +1 -1
- package/assets/esri/core/workers/chunks/36eb1e0471eb61a6bc38.js +1 -0
- package/assets/esri/core/workers/chunks/{57176c0968e07357126d.js → 3a429bb09b89e84021ab.js} +1 -1
- package/assets/esri/core/workers/chunks/444adb8a310024ec969c.js +1 -0
- package/assets/esri/core/workers/chunks/48aebd650b6eccde01f8.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/4f7459402b5910288ab1.js +1 -0
- package/assets/esri/core/workers/chunks/4fcd94fbf7c68996ad31.js +1 -0
- package/assets/esri/core/workers/chunks/573ad8aa1c2cfad61eb8.js +1 -0
- package/assets/esri/core/workers/chunks/5e12871a267742de6d22.js +1 -0
- package/assets/esri/core/workers/chunks/5f3104051f5267c58dda.js +2 -0
- package/assets/esri/core/workers/chunks/{76d0c4d6192449f22e51.js.LICENSE.txt → 5f3104051f5267c58dda.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{f350378a0d93dda39425.js → 7205c1680afee0cc0aac.js} +1 -1
- package/assets/esri/core/workers/chunks/77b3dff9fdcfe1222749.js +1 -0
- package/assets/esri/core/workers/chunks/77c29cfa3d245ff0afa0.js +1 -0
- package/assets/esri/core/workers/chunks/82dac92c1c611dea077f.js +1 -0
- package/assets/esri/core/workers/chunks/831283ac6653d7af90b6.js +1 -0
- package/assets/esri/core/workers/chunks/8485562b452686c6c3f2.js +1 -0
- package/assets/esri/core/workers/chunks/85a39b0f928f817a4b1b.js +1 -0
- package/assets/esri/core/workers/chunks/882fec2317740f6c118f.js +1 -0
- package/assets/esri/core/workers/chunks/8e1ac19a6188da157c0b.js +1 -0
- package/assets/esri/core/workers/chunks/8e2723dbc09400202aea.js +1 -0
- package/assets/esri/core/workers/chunks/{d3860693a40394723c99.js → 9249371cb2437e68a304.js} +1 -1
- package/assets/esri/core/workers/chunks/9528dfed701ad37ea551.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{419f4aaecc4231fdd171.js → 9dc0331885cb8150d9ca.js} +1 -1
- package/assets/esri/core/workers/chunks/9ebf8288046aa0fa51f1.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/a0b8164928a331ffc1b4.js +2 -0
- package/assets/esri/core/workers/chunks/{5c71a14417cdd11a1e8d.js.LICENSE.txt → a0b8164928a331ffc1b4.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/a6e3783cc10fb505473e.js +1 -0
- package/assets/esri/core/workers/chunks/a6fec91863abaa670301.js +2 -0
- package/assets/esri/core/workers/chunks/{359297c87764ae8db386.js.LICENSE.txt → a6fec91863abaa670301.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/a98cdf10ff7b2923abd5.js +1 -0
- package/assets/esri/core/workers/chunks/aa43b12a71957da2e678.js +1 -0
- package/assets/esri/core/workers/chunks/ac85f9d88f5583407d66.js +1 -0
- package/assets/esri/core/workers/chunks/{418988591e8068adefe2.js → b7c2244c27790ccaca92.js} +1 -1
- package/assets/esri/core/workers/chunks/da70e2c191e7d1d2df64.js +1 -0
- package/assets/esri/core/workers/chunks/dbded06d7a944dd97b01.js +1 -0
- package/assets/esri/core/workers/chunks/dcf857dc23b152fe74ff.js +1 -0
- package/assets/esri/core/workers/chunks/dcfc48bf5c27774fa05c.js +1 -0
- package/assets/esri/core/workers/chunks/dd368833c042127360ad.js +1 -0
- package/assets/esri/core/workers/chunks/e4049e498b3eaa9c8596.js +1 -0
- package/assets/esri/core/workers/chunks/e730a930d8a551552db5.js +1 -0
- package/assets/esri/core/workers/chunks/eb55835b8d3829f75e1e.js +1 -0
- package/assets/esri/core/workers/chunks/ef6fc6c92eae4f51e689.js +2 -0
- package/assets/esri/core/workers/chunks/{931063b2654ff763d15e.js.LICENSE.txt → ef6fc6c92eae4f51e689.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/f4124bf5b674811332bd.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/fd03cd19d0d4db699dca.js +1 -0
- package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
- package/assets/esri/themes/base/widgets/_Directions.scss +4 -0
- package/assets/esri/themes/base/widgets/_Grid.scss +8 -2
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/libtess-asm.js +1 -1
- package/chunks/libtess.js +1 -1
- package/chunks/vec32.js +1 -1
- package/chunks/vxlLayer.js +1 -1
- package/core/PooledArray.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/core/scheduling.js +1 -1
- package/core/sql.js +1 -1
- package/geometry/ellipsoidUtils.js +1 -1
- package/geometry/libtess.js +1 -1
- package/geometry/support/meshUtils/loadExternal.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/interfaces.d.ts +391 -49
- package/layers/BuildingSceneLayer.js +1 -1
- package/layers/GeoJSONLayer.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/MapImageLayer.js +1 -1
- package/layers/OGCFeatureLayer.js +1 -1
- package/layers/PointCloudLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/VoxelLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/sources/WFSSource.js +1 -1
- package/layers/graphics/sources/support/uploads.js +1 -1
- package/layers/mixins/SceneService.js +1 -1
- package/layers/ogc/wfsUtils.js +1 -1
- package/layers/support/I3SIndexInfo.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/associatedFeatureServiceUtils.js +1 -1
- package/layers/support/rasterDatasets/WCSRaster.js +1 -1
- package/layers/support/rasterFunctions/BandArithmeticFunction.js +1 -1
- package/layers/support/rasterFunctions/bandIndexUtils.js +1 -1
- package/package.json +2 -2
- package/portal/schemas/buildingSceneLayerItem.js +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/portal/schemas/integratedMeshLayerItem.js +1 -1
- package/portal/schemas/pointCloudLayerItem.js +1 -1
- package/portal/schemas/sceneLayerItem.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/SubtypeGroupLayerView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +5 -0
- package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +5 -0
- package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +5 -0
- package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +5 -0
- package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +5 -0
- package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +5 -0
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +5 -0
- package/views/2d/layers/features/layerAdapters/featureReductionUtils.js +5 -0
- package/views/2d/layers/features/layerAdapters/floorFilterUtils.js +5 -0
- package/views/2d/layers/features/support/NormalizedField.js +1 -1
- package/views/2d/layers/support/DebugOverlay.js +1 -1
- package/views/3d/analysis/AnalysisView3D.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesViewPerformanceInfo.js +5 -0
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/TiledLayerView3D.js +1 -1
- package/views/3d/layers/VoxelLayerView3D.js +1 -1
- package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
- package/views/3d/layers/i3s/I3SUtil.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
- package/views/3d/layers/i3s/PagedNodeIndex.js +1 -1
- package/views/3d/layers/support/DefinitionExpressionSceneLayerView.js +1 -1
- package/views/3d/layers/support/TemporalSceneLayerView.js +1 -1
- package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/RenderCoordsHelper.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/terrain/OverlayFramebufferObject.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/SphericalPatch.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/effects/RenderNodeCollection.js +1 -1
- package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
- package/views/3d/webgl-engine/lib/rendererUtils.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/draw/DrawGraphicTool.js +1 -1
- package/views/interactive/AnalysisToolBase.js +1 -1
- package/views/interactive/tooltip/Tooltip.js +1 -1
- package/views/interactive/tooltip/content/TooltipContent.js +1 -1
- package/views/layers/DimensionLayerView.js +1 -1
- package/views/webgl/Program.js +1 -1
- package/widgets/BasemapLayerList/BasemapLayerListVisibleElements.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +4 -0
- package/widgets/DirectionalPad.d.ts +4 -0
- package/widgets/Directions/css.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Column.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/LayerList/support/layerListUtils.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/TableList.js +1 -1
- package/widgets/support/AnchorElementViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/040e0122efe1cb716431.js +0 -1
- package/assets/esri/core/workers/chunks/04c89069761f7d6bf69d.js +0 -1
- package/assets/esri/core/workers/chunks/0c05900239e372f49f7e.js +0 -1
- package/assets/esri/core/workers/chunks/104e943cfffd093572a8.js +0 -1
- package/assets/esri/core/workers/chunks/1f5a4da5773ba48addfa.js +0 -1
- package/assets/esri/core/workers/chunks/24087961564e5b8cc20c.js +0 -1
- package/assets/esri/core/workers/chunks/26d8f6e0b9d67c75a781.js +0 -1
- package/assets/esri/core/workers/chunks/3441ae1ee2b11cf2c3f6.js +0 -1
- package/assets/esri/core/workers/chunks/359297c87764ae8db386.js +0 -2
- package/assets/esri/core/workers/chunks/37f71dac3208e74a76fc.js +0 -1
- package/assets/esri/core/workers/chunks/3913cf13681761afa596.js +0 -1
- package/assets/esri/core/workers/chunks/4a4dfe393c4c5e9435f9.js +0 -1
- package/assets/esri/core/workers/chunks/530306592924eb06d30c.js +0 -1
- package/assets/esri/core/workers/chunks/5558e8acc1bee29a0e9b.js +0 -1
- package/assets/esri/core/workers/chunks/587c81abcbe118ea89ae.js +0 -1
- package/assets/esri/core/workers/chunks/5c71a14417cdd11a1e8d.js +0 -2
- package/assets/esri/core/workers/chunks/5db76bdc4916d11cbcfe.js +0 -1
- package/assets/esri/core/workers/chunks/642e652bf21a7fa463c9.js +0 -1
- package/assets/esri/core/workers/chunks/649c3cbf6b3ec94cbdf1.js +0 -1
- package/assets/esri/core/workers/chunks/67e4bec7950f09ffe4a7.js +0 -1
- package/assets/esri/core/workers/chunks/68b2743411ef5e09862b.js +0 -1
- package/assets/esri/core/workers/chunks/76d0c4d6192449f22e51.js +0 -2
- package/assets/esri/core/workers/chunks/78123fa25903d376bd49.js +0 -1
- package/assets/esri/core/workers/chunks/7918a1c53ce9e7c95030.js +0 -1
- package/assets/esri/core/workers/chunks/80498a2a85e1aeadd569.js +0 -1
- package/assets/esri/core/workers/chunks/8407cf549c0c59a206f1.js +0 -1
- package/assets/esri/core/workers/chunks/89299923c92540455513.js +0 -1
- package/assets/esri/core/workers/chunks/8932cdbb7cfab9258d5a.js +0 -1
- package/assets/esri/core/workers/chunks/931063b2654ff763d15e.js +0 -2
- package/assets/esri/core/workers/chunks/969a22814dc765ac1061.js +0 -1
- package/assets/esri/core/workers/chunks/aa4d3276917421abaa12.js +0 -1
- package/assets/esri/core/workers/chunks/be924cb8ab2d40abea6c.js +0 -1
- package/assets/esri/core/workers/chunks/c6d1a6db8cfa0a7e3bd2.js +0 -1
- package/assets/esri/core/workers/chunks/c87e3d55ecdbbb584dfc.js +0 -1
- package/assets/esri/core/workers/chunks/cf9bf7d57341d00a92a6.js +0 -1
- package/assets/esri/core/workers/chunks/d72121b17640e302d6a9.js +0 -1
- package/assets/esri/core/workers/chunks/de01e106ca3daf6c2f49.js +0 -1
- package/assets/esri/core/workers/chunks/e3154ef5dbd851224452.js +0 -1
- package/assets/esri/core/workers/chunks/f0c62bb406bb93b1408a.js +0 -1
- package/assets/esri/core/workers/chunks/f4c4e0fe6be09fa49784.js +0 -1
- package/assets/esri/core/workers/chunks/f64a4349f895f92b6338.js +0 -1
- package/assets/esri/core/workers/chunks/f7a31ac1251c9c0ba713.js +0 -1
- package/assets/esri/core/workers/chunks/f842b3b50059aa70f1af.js +0 -1
- package/assets/esri/core/workers/chunks/fab270f3a45914f8df9e.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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as o}from"../../../core/maybe.js";import a from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{s as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as R,DrapeSourceType as f,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as D}from"./OverlayContent.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import{ColorFormat as S}from"../webgl-engine/core/FBOCache.js";import{ShaderOutput as C}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as P}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as j}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as E}from"../webgl-engine/effects/RenderPlugin.js";import{Camera as A}from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as M}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as W}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as F}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as L}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as q,defaultRenderOccludedMask as I}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as V}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as N}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as U}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as k}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as G}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as H}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as B}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as z}from"../webgl-engine/lighting/Lightsources.js";import{O as Y}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as X}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as J,noBudget as K}from"../../support/Scheduler.js";import{ClearBufferBit as Q,TextureSamplingMode as Z}from"../../webgl/enums.js";import{Texture as $}from"../../webgl/Texture.js";import{TextureDescriptor as ee}from"../../webgl/TextureDescriptor.js";let re=class extends E{get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materialRepository(){return this._materialRepository}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new Y,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new a,this._passParameters=new O,this._materialRepository=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new A,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[V.DRAPED_MATERIAL,e=>e!==C.Highlight||this.hasHighlights],[V.DRAPED_WATER,()=>!0]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextureRepository:t,stippleTextureRepository:s,markerTextureRepository:i}=r;this._shaderTechniqueRepository=new j({rctx:this._rctx,viewingMode:y.Local,stippleTextureRepository:s,markerTextureRepository:i,waterTextureRepository:t}),this._renderContext=new q(this._rctx,new N(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),h),n((()=>this.spatialReference),(e=>this._localOriginFactory=new F(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materialRepository=new M(r.textureRepository,this._shaderTechniqueRepository,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=V.DRAPED_MATERIAL,this._bindParameters.mainDepth=W(this._rctx),this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=H.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new z(g(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(J.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._bindParameters.mainDepth=i(this._bindParameters.mainDepth),this._shaderTechniqueRepository=o(this._shaderTechniqueRepository),this.disposeOverlays()}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMemoryForMaterial(e){return Array.from(this._renderers.values()).reduce(((r,t)=>r+t.getMemoryForMaterial(e)),0)}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,U)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===R.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===f.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===f.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===D.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(D.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(K,(e=>e.updatePolicy===B.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=oe;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==D.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?P.Disabled:this._renderTargets?.getTexture(D.WaterNormal)?P.EnabledWithWater:this._renderTargets?.getTexture(D.Color)?P.Enabled:P.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets)(r.content!==D.ColorNoRasterImage||this._needsColorWithoutRasterImage)&&(this._drawTarget(w.INNER,r,e),this._drawTarget(w.OUTER,r,e))}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return;const{alignPixelEnabled:o,contentPixelRatio:a}=t;this._screenToWorldRatio=a*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===C.Highlight&&!this.hasHighlights||n===C.Normal&&!this.hasWater||!s.hasSomeSizedView())return;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*a,this._renderContext.output=n,this._bindParameters.alignPixelEnabled=o,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=n===C.Normal?V.DRAPED_WATER:V.DRAPED_MATERIAL,r.content===D.Occluded&&(this._renderContext.renderOccludedMask=oe),!this.renders(r.content))return void(this._renderContext.renderOccludedMask=I);const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clearSafe(Q.COLOR_BUFFER_BIT));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==D.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,se[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();this._sortedRenderers.forAll((({drapeSource:t,renderer:o})=>{if(r.content===D.ColorNoRasterImage&&t.drapeSourceType===f.RasterImage)return;const{fullOpacity:a}=t,d=null!=a&&a<1&&n===C.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),o.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.colorTexture,this._overlayParameters.opacity=a,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniqueRepository.acquire(X);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),e===w.OUTER&&u.generateMipMap(),this._renderContext.renderOccludedMask=I}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(S.RGBA,e,r,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clearSafe(Q.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:o}of this._sortedRenderers)i=o.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),o=i>=0,a=s.renderGroup??(o?T.MapLayer:T.ViewLayer),n=r*a+(o?i:0);this._sortedRenderers.push(new te(s,t,n))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let a=0;a<e;a++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(a/10);i<2||o<2||10*i>e-20||10*o>e-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&i&&1&o?1&r^1&a?0:255:1&i^1&o?0:128)}const i=new ee(e);i.samplingMode=Z.NEAREST,this._passParameters.texture=new $(this._rctx,i,t);const o=new G;o.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire(k,o)}get test(){return{drapedRenderers:Array.from(this._renderers.values()),sortedDrapeSources:Array.from(this._sortedRenderers).map((({drapeSource:e})=>e)),getDrapeSourceRenderer:e=>this._renderers.get(e)}}};e([c()],re.prototype,"hasHighlights",void 0),e([c()],re.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c({autoDestroy:!0})],re.prototype,"_shaderTechniqueRepository",void 0),e([c({constructOnly:!0})],re.prototype,"view",void 0),e([c()],re.prototype,"worldToPCSRatio",void 0),e([c()],re.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],re.prototype,"updating",null),e([c()],re.prototype,"isEmpty",null),e([c({readOnly:!0})],re.prototype,"rendersOccludedDraped",null),re=e([u("esri.views.3d.terrain.OverlayRenderer")],re);class te{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const se=[[1,.5,.5],[.5,.5,1]],ie=-2,oe=L.OccludeAndTransparent;export{re as OverlayRenderer,ie as drapedZ,oe as overlayRenderOccludedFlag};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as o}from"../../../core/maybe.js";import a from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{s as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as R,DrapeSourceType as f,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as D}from"./OverlayContent.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import{ShaderOutput as S}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as C}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as P}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as O}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as E}from"../webgl-engine/effects/RenderPlugin.js";import{Camera as j}from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as A}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as M}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as W}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as F}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as L,defaultRenderOccludedMask as q}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as I}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as V}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as N}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as U}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as k}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as H}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as G}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as B}from"../webgl-engine/lighting/Lightsources.js";import{O as z}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as Y}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as X,noBudget as J}from"../../support/Scheduler.js";import{ClearBufferBit as K,TextureSamplingMode as Q}from"../../webgl/enums.js";import{Texture as Z}from"../../webgl/Texture.js";import{TextureDescriptor as $}from"../../webgl/TextureDescriptor.js";let ee=class extends E{get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materialRepository(){return this._materialRepository}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new z,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new a,this._passParameters=new P,this._materialRepository=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new j,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[I.DRAPED_MATERIAL,e=>e!==S.Highlight||this.hasHighlights],[I.DRAPED_WATER,()=>!0]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextureRepository:t,stippleTextureRepository:s,markerTextureRepository:i}=r;this._shaderTechniqueRepository=new O({rctx:this._rctx,viewingMode:y.Local,stippleTextureRepository:s,markerTextureRepository:i,waterTextureRepository:t}),this._renderContext=new L(this._rctx,new V(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),h),n((()=>this.spatialReference),(e=>this._localOriginFactory=new W(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materialRepository=new A(r.textureRepository,this._shaderTechniqueRepository,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=I.DRAPED_MATERIAL,this._bindParameters.mainDepth=M(this._rctx),this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=H.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new B(g(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(X.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._bindParameters.mainDepth=i(this._bindParameters.mainDepth),this._shaderTechniqueRepository=o(this._shaderTechniqueRepository),this.disposeOverlays()}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMemoryForMaterial(e){return Array.from(this._renderers.values()).reduce(((r,t)=>r+t.getMemoryForMaterial(e)),0)}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,N)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===R.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===f.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===f.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===D.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(D.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(J,(e=>e.updatePolicy===G.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=ie;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==D.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?C.Disabled:this._renderTargets?.getTexture(D.WaterNormal)?C.EnabledWithWater:this._renderTargets?.getTexture(D.Color)?C.Enabled:C.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets)(r.content!==D.ColorNoRasterImage||this._needsColorWithoutRasterImage)&&(this._drawTarget(w.INNER,r,e),this._drawTarget(w.OUTER,r,e))}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return;const{alignPixelEnabled:o,contentPixelRatio:a}=t;this._screenToWorldRatio=a*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===S.Highlight&&!this.hasHighlights||n===S.Normal&&!this.hasWater||!s.hasSomeSizedView())return;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*a,this._renderContext.output=n,this._bindParameters.alignPixelEnabled=o,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=n===S.Normal?I.DRAPED_WATER:I.DRAPED_MATERIAL,r.content===D.Occluded&&(this._renderContext.renderOccludedMask=ie),!this.renders(r.content))return void(this._renderContext.renderOccludedMask=q);const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clearSafe(K.COLOR_BUFFER_BIT));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==D.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,te[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();this._sortedRenderers.forAll((({drapeSource:t,renderer:o})=>{if(r.content===D.ColorNoRasterImage&&t.drapeSourceType===f.RasterImage)return;const{fullOpacity:a}=t,d=null!=a&&a<1&&n===S.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),o.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.colorTexture,this._overlayParameters.opacity=a,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniqueRepository.acquire(Y);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),e===w.OUTER&&u.generateMipMap(),this._renderContext.renderOccludedMask=q}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(e,r,"overlay tmp");return t.rctx.clearSafe(K.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:o}of this._sortedRenderers)i=o.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),o=i>=0,a=s.renderGroup??(o?T.MapLayer:T.ViewLayer),n=r*a+(o?i:0);this._sortedRenderers.push(new re(s,t,n))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let a=0;a<e;a++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(a/10);i<2||o<2||10*i>e-20||10*o>e-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&i&&1&o?1&r^1&a?0:255:1&i^1&o?0:128)}const i=new $(e);i.samplingMode=Q.NEAREST,this._passParameters.texture=new Z(this._rctx,i,t);const o=new k;o.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire(U,o)}get test(){return{drapedRenderers:Array.from(this._renderers.values()),sortedDrapeSources:Array.from(this._sortedRenderers).map((({drapeSource:e})=>e)),getDrapeSourceRenderer:e=>this._renderers.get(e)}}};e([c()],ee.prototype,"hasHighlights",void 0),e([c()],ee.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c({autoDestroy:!0})],ee.prototype,"_shaderTechniqueRepository",void 0),e([c({constructOnly:!0})],ee.prototype,"view",void 0),e([c()],ee.prototype,"worldToPCSRatio",void 0),e([c()],ee.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],ee.prototype,"updating",null),e([c()],ee.prototype,"isEmpty",null),e([c({readOnly:!0})],ee.prototype,"rendersOccludedDraped",null),ee=e([u("esri.views.3d.terrain.OverlayRenderer")],ee);class re{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const te=[[1,.5,.5],[.5,.5,1]],se=-2,ie=F.OccludeAndTransparent;export{ee as OverlayRenderer,se as drapedZ,ie 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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{k as i,q as s,G as o,f as a,n,j as l,x as g,D as d}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{NeighborIndex as y}from"./ITile.js";import{LayerClass as x}from"./LayerClass.js";import{PatchGeometry as _}from"./PatchGeometry.js";import{enableTerrainInternalChecks as v,internalAssert as E,neighborEdgeIndices as $,oppositeEdge as S,neighborCornerIndices as C,v32s as D,lij2s as T}from"./terrainUtils.js";import{TextureFader as b,ActivationTime as j}from"./TextureFader.js";import{isEdgeNeighbor as A}from"./Tile.js";import V from"./TileOverlayData.js";import{fallsWithinLayer as R}from"./tileUtils.js";import{VertexArrayObject as w}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as L}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as N}from"../../webgl/BufferObject.js";import{PixelFormat as P}from"../../webgl/enums.js";class F{constructor(){this.geometry=new _,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureRef=new b((()=>this.tile.surface.textureFadeDuration)),this.overlay=new V,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new p,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),v&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)E(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=$[e];if(!t)return E(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.isLoaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(E(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}E(!t.isLeaf);let a=i;return t.forAllSubtreeOnSide(S(o),(e=>e===r||(e.isLoaded?(a=Math.max(a,2**(e.level-s)),!0):(E(!e.isLeaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile($[a],i),l=H(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==H(e,d),m=o[a]!==g;s[a]=n,(h||m)&&(o[a]=g,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);E(t(c)),E(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(C[t],i);r.cornerPeerNeighbours[t]=o;const a=H(e,s[t]),n=H(e,s[(t+1)%4]),l=H(e,o);B[t]=l,B[(t+1)%4]=n,B[(t+2)%4]=e,B[(t+3)%4]=a,E(B.some((t=>t?.isLoaded||t===e)));const g=B.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);B.forEach(((e,t)=>{e&&e?.level>g&&(B[t]=null)})),E(B.some((t=>t?.isLoaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=B[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=d[s]!==r,a=!o&&h[s]!==i;(o||a)&&(d[s]=r,h[s]=i,this._markCornerDirty(t))}v&&E(Z.some((r=>d[4*t+r]?.isLoaded||d[4*t+r]===e)))}v&&E(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)B[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;v&&E(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{geometry:i}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),g=!l&&a,d=!g&&(0!==this.dirtyEdges||a),h=!d&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):g?t.updateEdgeElevationsAndResolutions():d||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r){const i=t?P.RGBA:P.RGB;return null==this._texture||this._texture.descriptor.width===e&&this._texture.descriptor.pixelFormat===i||this.releaseTexture(),null==this._texture&&(this._texture=r(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}get numVerticesPerSideChanged(){return 0!=(this._modifiedFlags&W)}get samplerDataChanged(){return 0!=(this._modifiedFlags&q)}get clippingAreaChanged(){return 0!=(this._modifiedFlags&z)}get wireframeChanged(){return 0!=(this._modifiedFlags&J)}get dirtyEdges(){return this._modifiedFlags>>K&15}get dirtyCorners(){return this._modifiedFlags>>Q&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>Y&15}_markCornerDirty(e){const t=1<<e<<Q;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Q|15<<K|15<<Y}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new w(e,L,{geometry:f(t.layout)},{geometry:N.createVertex(e,i.STATIC_DRAW,t.buffer)},N.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=j.Immediate){null!=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[x.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let g=0;g<r;g++){const r=t[g];if(null!=r.upsampleInfo){const t=r.upsampleInfo.tile,n=t.layerInfo[x.ELEVATION][g].data,l=n&&n.samplerData;e&&e[s]===l||(a=!0),i[s++]=l,o=Math.max(o,t.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(g,x.ELEVATION);if(R(this.tile,t.layer,!1)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!v)return;const e=this.tile;if(!e.isLoaded||!e.intersectsClippingArea||0===e.level)return void E(e?.isLoaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=$.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;E(0===this.dirtyCorners),E(0===this.dirtyEdges),E(0===this.dirtyEdgeResolutions),E(!this.numVerticesPerSideChanged),E(!this.samplerDataChanged),E(!this.clippingAreaChanged),E(!this.wireframeChanged);const x=C.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),_=this.geometryState;for(let t=0;t<4;++t){const r=_.cornerPeerNeighbours[t],i=x[t];E(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}$.forEach(((r,x)=>{if(f[x])return;const _=e.findNeighborTile(r,(e=>(e.level===p||e?.isLoaded)&&e?.intersectsClippingArea));if(!_){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void E(!t)}E(_.isLoaded||_.level===e.level),E(_===this.geometryState.edgePeerNeighbors[x]);const v=p-_.level;if(!_.isLoaded)return E(!_.isLeaf),void E(0===v);const $=_.renderData;E(A(e,_,r)),E(v>=0);const S=2**v;if(v<0)return void E(!1);const C=e.renderData,b=C.geometry,j=C.localOrigin,V=b.getEdgeCount(x),R=b.numVerticesPerSide-1,w=$.geometry;if(!w)return void E(!1);const L=$.localOrigin,N=this.geometryState.edgePeerNeighbors[x];if(N?.isLoaded){const e=N.renderData;E(C.geometryState.edgePeerNeighborSamplerVersions[x]===e.geometryState.samplerDataVersion),E(this.geometryState.edgePeerNeighborSamplerVersions[x]===e.geometryState.samplerDataVersion)}const P=(x+2)%4,F=w.getEdgeCount(P),B=V-1,H=F-1;E(B*S===H,`Tile[${e.lij}]:e${x},res=${B} edgeRes mismatch with Neighbor[${_.lij}]:e${P},res=${H} (expected:${B*S})`);const W=e.extent,q=r===y.NORTH||r===y.SOUTH,z=F-1,J=z>>v,K=V-1;if(J<1)return void E(1===K);E(J===K),E(t(J));const Q=w.numVerticesPerSide-1;E(v>0||J===Math.max(Q,R));const Y=e.getNeighborEdgeStartVertexIndex(x,_);E(0<=Y&&Y<S);const Z=Y*J;E(0<=Z&&Z<=z-J);let ee=0,te=Z;b.getEdgeVertexPosition(x,G,j,0),b.getEdgeVertexPosition(x,O,j,V-1);const re=i(G,O),ie=Math.max(X,1e-4*re);for(let t=0;t<=J;++t){b.getEdgeVertexPosition(x,G,j,ee),w.getEdgeVertexPosition(P,O,L,te);const i=t/J,f=q?W[0]+i*(W[2]-W[0]):r===y.WEST?W[0]:W[2],p=q?r===y.SOUTH?W[1]:W[3]:W[1]+i*(W[3]-W[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(G,O),r=o(G)-c.radius,i=o(O)-c.radius,u=t<ie;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${x}[${ee}/${V}] and [${_.lij}].edge${P}[${te}/${F}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,$.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${$.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(G),r=m(O);e.updateEdgeElevations(),_.updateEdgeElevations(),b.getEdgeVertexPosition(x,G,j,ee),w.getEdgeVertexPosition(P,O,L,te);const i=h();g(i,G,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${G} d=${o(i)} [${i}]`),g(i,O,r),o(i)>0&&console.warn(` XXX Neighbor[${_.lij}] edge out of date: ${r} vs ${O} d=${o(i)} [${i}]`)})();const n=b.getEdgeCount(x),l=w.getEdgeCount(F);E(u,`Mismatch in tile [${e.lij}].edge[${x}][${ee}/${n}] vs neighbor [${_.lij}].edge[${P}][${te}/${l}] ${D(G)} vs ${D(O)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}b.getEdgeNormal(x,I,ee),w.getEdgeNormal(P,M,te),n(U,I),n(k,M);const y=l(U,k),S=1-y<.01||!1||e===_;if(!S){const t=h();g(t,I,M);const r=()=>`Mismatch in tile edge normal ${T(e.lij)} (${ee}/${V-1}) edge ${x} vs neighbor ${T(_.lij)} (${te}/${F-1}) nedge ${P} :${D(I)} vs ${D(M)} dot = ${y} : ${D(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),_.updateEdgeElevations();const t=h(),r=h();b.getEdgeNormal(x,t,ee),w.getEdgeNormal(P,r,te),d(I,t)||console.warn("Missing update in tile normal: ",D(I)," => ",D(t)),d(M,r)||console.warn("Missing update in neighbor normal: ",D(M)," => ",D(r))}E(S,r())}}ee+=1,te+=1}}))}}const G=h(),O=h(),I=h(),M=h(),U=h(),k=h(),X=1,B=[null,null,null,null];function H(e,t){return t?.isLoaded||t===e?t:null}const W=1,q=2,z=4,J=8,K=4,Q=8,Y=12,Z=[0,1,2,3];export{j as ActivationTime,F as PatchRenderData,H as neighborTileIfLoadedOrSelf,Z as zeroToFour};
|
|
5
|
+
import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{k as i,q as s,G as o,f as a,n,j as l,x as g,D as d}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{NeighborIndex as y}from"./ITile.js";import{LayerClass as x}from"./LayerClass.js";import{PatchGeometry as _}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as v}from"./TerrainConst.js";import{enableTerrainInternalChecks as E,internalAssert as $,neighborEdgeIndices as S,oppositeEdge as C,neighborCornerIndices as D,v32s as T,lij2s as b}from"./terrainUtils.js";import{TextureFader as j,ActivationTime as A}from"./TextureFader.js";import{isEdgeNeighbor as V}from"./Tile.js";import R from"./TileOverlayData.js";import{fallsWithinLayer as w}from"./tileUtils.js";import{VertexArrayObject as L}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as N}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as P}from"../../webgl/BufferObject.js";import{PixelFormat as F}from"../../webgl/enums.js";class G{constructor(){this.geometry=new _,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureRef=new j((()=>this.tile.surface.textureFadeDuration)),this.overlay=new R,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new p,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),E&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)$(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=S[e];if(!t)return $(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.isLoaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if($(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}$(!t.isLeaf);let a=i;return t.forAllSubtreeOnSide(C(o),(e=>e===r||(e.isLoaded?(a=Math.max(a,2**(e.level-s)),!0):($(!e.isLeaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(S[a],i),l=W(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==W(e,d),m=o[a]!==g;E&&n&&($(e.level>=n.level),$(e.level-n.level<=v)),s[a]=n,(h||m)&&(o[a]=g,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);$(t(c)),$(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(D[t],i);r.cornerPeerNeighbours[t]=o;const a=W(e,s[t]),n=W(e,s[(t+1)%4]),l=W(e,o);H[t]=l,H[(t+1)%4]=n,H[(t+2)%4]=e,H[(t+3)%4]=a,$(H.some((t=>t?.isLoaded||t===e)));const g=H.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);H.forEach(((e,t)=>{e&&e?.level>g&&(H[t]=null)})),$(H.some((t=>t?.isLoaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=H[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=d[s]!==r,a=!o&&h[s]!==i;(o||a)&&(d[s]=r,h[s]=i,this._markCornerDirty(t))}E&&$(ee.some((r=>d[4*t+r]?.isLoaded||d[4*t+r]===e)))}E&&$(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)H[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;E&&$(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{geometry:i}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),g=!l&&a,d=!g&&(0!==this.dirtyEdges||a),h=!d&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):g?t.updateEdgeElevationsAndResolutions():d||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r){const i=t?F.RGBA:F.RGB;return null==this._texture||this._texture.descriptor.width===e&&this._texture.descriptor.pixelFormat===i||this.releaseTexture(),null==this._texture&&(this._texture=r(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}get numVerticesPerSideChanged(){return 0!=(this._modifiedFlags&q)}get samplerDataChanged(){return 0!=(this._modifiedFlags&z)}get clippingAreaChanged(){return 0!=(this._modifiedFlags&J)}get wireframeChanged(){return 0!=(this._modifiedFlags&K)}get dirtyEdges(){return this._modifiedFlags>>Q&15}get dirtyCorners(){return this._modifiedFlags>>Y&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>Z&15}_markCornerDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Q;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Y|15<<Q|15<<Z}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new L(e,N,{geometry:f(t.layout)},{geometry:P.createVertex(e,i.STATIC_DRAW,t.buffer)},P.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){null!=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[x.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let g=0;g<r;g++){const r=t[g];if(null!=r.upsampleInfo){const t=r.upsampleInfo.tile,n=t.layerInfo[x.ELEVATION][g].data,l=n&&n.samplerData;e&&e[s]===l||(a=!0),i[s++]=l,o=Math.max(o,t.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(g,x.ELEVATION);if(w(this.tile,t.layer,!1)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!E)return;const e=this.tile;if(!e.isLoaded||!e.intersectsClippingArea||0===e.level)return void $(e?.isLoaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=S.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;$(0===this.dirtyCorners),$(0===this.dirtyEdges),$(0===this.dirtyEdgeResolutions),$(!this.numVerticesPerSideChanged),$(!this.samplerDataChanged),$(!this.clippingAreaChanged),$(!this.wireframeChanged);const x=D.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),_=this.geometryState;for(let t=0;t<4;++t){const r=_.cornerPeerNeighbours[t],i=x[t];$(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}S.forEach(((r,x)=>{if(f[x])return;const _=e.findNeighborTile(r,(e=>(e.level===p||e?.isLoaded)&&e?.intersectsClippingArea));if(!_){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void $(!t)}$(_.isLoaded||_.level===e.level),$(_===this.geometryState.edgePeerNeighbors[x]);const v=p-_.level;if(!_.isLoaded)return $(!_.isLeaf),void $(0===v);const E=_.renderData;$(V(e,_,r)),$(v>=0);const S=2**v;if(v<0)return void $(!1);const C=e.renderData,D=C.geometry,j=C.localOrigin,A=D.getEdgeCount(x),R=D.numVerticesPerSide-1,w=E.geometry;if(!w)return void $(!1);const L=E.localOrigin,N=this.geometryState.edgePeerNeighbors[x];if(N?.isLoaded){const e=N.renderData;$(C.geometryState.edgePeerNeighborSamplerVersions[x]===e.geometryState.samplerDataVersion),$(this.geometryState.edgePeerNeighborSamplerVersions[x]===e.geometryState.samplerDataVersion)}const P=(x+2)%4,F=w.getEdgeCount(P),G=A-1,H=F-1;$(G*S===H,`Tile[${e.lij}]:e${x},res=${G} edgeRes mismatch with Neighbor[${_.lij}]:e${P},res=${H} (expected:${G*S})`);const W=e.extent,q=r===y.NORTH||r===y.SOUTH,z=F-1,J=z>>v,K=A-1;if(J<1)return void $(1===K);$(J===K),$(t(J));const Q=w.numVerticesPerSide-1;$(v>0||J===Math.max(Q,R));const Y=e.getNeighborEdgeStartVertexIndex(x,_);$(0<=Y&&Y<S);const Z=Y*J;$(0<=Z&&Z<=z-J);let ee=0,te=Z;D.getEdgeVertexPosition(x,O,j,0),D.getEdgeVertexPosition(x,I,j,A-1);const re=i(O,I),ie=Math.max(B,1e-4*re);for(let t=0;t<=J;++t){D.getEdgeVertexPosition(x,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=t/J,f=q?W[0]+i*(W[2]-W[0]):r===y.WEST?W[0]:W[2],p=q?r===y.SOUTH?W[1]:W[3]:W[1]+i*(W[3]-W[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(O,I),r=o(O)-c.radius,i=o(I)-c.radius,u=t<ie;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${x}[${ee}/${A}] and [${_.lij}].edge${P}[${te}/${F}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(O),r=m(I);e.updateEdgeElevations(),_.updateEdgeElevations(),D.getEdgeVertexPosition(x,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=h();g(i,O,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${O} d=${o(i)} [${i}]`),g(i,I,r),o(i)>0&&console.warn(` XXX Neighbor[${_.lij}] edge out of date: ${r} vs ${I} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(x),l=w.getEdgeCount(F);$(u,`Mismatch in tile [${e.lij}].edge[${x}][${ee}/${n}] vs neighbor [${_.lij}].edge[${P}][${te}/${l}] ${T(O)} vs ${T(I)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(x,M,ee),w.getEdgeNormal(P,U,te),n(k,M),n(X,U);const y=l(k,X),S=1-y<.01||!1||e===_;if(!S){const t=h();g(t,M,U);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${ee}/${A-1}) edge ${x} vs neighbor ${b(_.lij)} (${te}/${F-1}) nedge ${P} :${T(M)} vs ${T(U)} dot = ${y} : ${T(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),_.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(x,t,ee),w.getEdgeNormal(P,r,te),d(M,t)||console.warn("Missing update in tile normal: ",T(M)," => ",T(t)),d(U,r)||console.warn("Missing update in neighbor normal: ",T(U)," => ",T(r))}$(S,r())}}ee+=1,te+=1}}))}}const O=h(),I=h(),M=h(),U=h(),k=h(),X=h(),B=1,H=[null,null,null,null];function W(e,t){return t?.isLoaded||t===e?t:null}const q=1,z=2,J=4,K=8,Q=4,Y=8,Z=12,ee=[0,1,2,3];export{A as ActivationTime,G as PatchRenderData,W as neighborTileIfLoadedOrSelf,ee as zeroToFour};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{lerp as t}from"../../../core/mathUtils.js";import{n as e,s,g as i,i as o,G as n,b as r,j as l,q as a,x as h}from"../../../chunks/vec32.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as c}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{newDoubleArray as d}from"../../../geometry/support/DoubleArray.js";import{intersectsSphere as p,NumPlanes as f,PlaneIndex as m}from"../../../geometry/support/frustum.js";import{b as g,g as $}from"../../../chunks/sphere.js";import{PatchType as _}from"./interfaces.js";import{TileFrustumVisibility as x}from"./ITile.js";import{createSphericalGlobePatch as v,updateCornerSpherical as M,updateEdgesAndCornersSpherical as b,updateEdgeElevationsAndResolutionsSpherical as j}from"./PatchGeometryFactory.js";import{enableTerrainInternalChecks as S,internalAssert as T,almostEquals as E}from"./terrainUtils.js";import{Tile as
|
|
5
|
+
import{lerp as t}from"../../../core/mathUtils.js";import{n as e,s,g as i,i as o,G as n,b as r,j as l,q as a,x as h}from"../../../chunks/vec32.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as c}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{newDoubleArray as d}from"../../../geometry/support/DoubleArray.js";import{intersectsSphere as p,NumPlanes as f,PlaneIndex as m}from"../../../geometry/support/frustum.js";import{b as g,g as $}from"../../../chunks/sphere.js";import{PatchType as _}from"./interfaces.js";import{TileFrustumVisibility as x}from"./ITile.js";import{createSphericalGlobePatch as v,updateCornerSpherical as M,updateEdgesAndCornersSpherical as b,updateEdgeElevationsAndResolutionsSpherical as j}from"./PatchGeometryFactory.js";import{enableTerrainInternalChecks as S,internalAssert as T,almostEquals as E}from"./terrainUtils.js";import{Tile as I,CenterPosition as H}from"./Tile.js";import{compareTilesByLij as D}from"./tileUtils.js";class L extends I{constructor(t,e,s,i,o){super(),this._convexHull=new Array(24),this._boundingSphere=g(),this._baseUsedMemory=1816,this.init(t,e,s,i,o)}init(s,i,o,n,r){super.init(s,i,o,n,r);const l=this.ellipsoid.radius,a=this.extentInRadians[0],h=this.extentInRadians[1],u=this.extentInRadians[2],d=this.extentInRadians[3],p=t(h,d,.5),f=t(a,u,.5),m=0===s?0:Math.min(Math.abs(h),Math.abs(d));this._edgeLen=(u-a)*Math.cos(m)*l,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=l-Math.sqrt(l*l-this._edgeLen2/4),c(this.centerAtSeaLevel,f,p,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])s($(t[H.MIDDLE]),0,0,0),s(t[H.TOP],0,0,0),s(t[H.BOTTOM],0,0,0),t[H.MIDDLE][3]=this.ellipsoid.radius+this.elevationBounds[1];else{this._updateCenter();const e=t[H.MIDDLE],s=this.convexHull;let i=0;for(let t=0;t<8;++t)i=Math.max(i,R($(e),s,3*t));t[H.MIDDLE][3]=Math.sqrt(i)}}_calculateFrustumVisibilityStatus(t){if(!p(t,this._boundingSphere))return x.OUTSIDE;if(this.lij[0]<10)return x.INTERSECTS;const e=this.convexHull,s=this.surface.view.state.camera.near;let i=!0;for(let o=0;o<f;o++){const n=o===m.NEAR,r=t[o],l=r[0],a=r[1],h=r[2],u=r[3]-(n?s:0);let c=!1;for(let t=0;t<8;++t){const s=3*t;if(l*e[s]+a*e[s+1]+h*e[s+2]+u<0){if(c=!0,!i)break}else i=!1}if(!c)return x.OUTSIDE}return i?x.INSIDE:x.INTERSECTS}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){v(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere(),S&&this._checkBVs()}_updateBoundingSphere(){const t=this._boundingSphere,e=$(t),r=this.elevationBounds,l=this.ellipsoid.radius,a=r[1];if(0===this.level)s(e,0,0,0),t[3]=l+a;else{const s=this.extentInRadians,a=.5*(s[0]+s[2]),h=s[1],u=s[3];O(A,a,h,l),O(V,a,u,l),i(e,A,V);const c=.5*(r[0]+r[1]);o(e,e,(l+c)/n(e));const d=this.convexHull;let p=0;const f=(t,e)=>{const s=t[0]-d[3*e],i=t[1]-d[3*e+1],o=t[2]-d[3*e+2];return Math.sqrt(s*s+i*i+o*o)};for(let t=0;t<8;++t){const s=f(e,t);p=Math.max(p,s)}const m=p;t[3]=m+2}}_updateConvexHull(){const t=this.extentInRadians,s=this.ellipsoid.radius;if(0===this.level)return;const a=this.elevationBounds,c=this._getPatchType(),d=this.surface.isWebMercator,p=d&&c===_.HAS_NORTH_POLE,f=d&&c===_.HAS_SOUTH_POLE,m=f||p,g=Math.PI/2,$=t[0],x=t[2],v=f?-g:t[1],M=p?g:t[3],b=.5*($+x),j=a[0],S=s+(m?Math.min(0,j-1):j),I=(t,e,s)=>O(t,e,s,S),H=u(),D=u(),L=u(),y=u();I(H,$,v),I(D,$,M),I(L,x,M),I(y,x,v);const R=(t,e)=>{for(let s=0;s<3;++s)this._convexHull[3*e+s]=t[s]};R(H,0),R(D,1),R(L,2),R(y,3);const B=a[1],A=s+(m?Math.max(0,B+1):B),V=u(),C=u(),N=u();O(C,b,M,S),O(N,b,v,S),i(V,C,N),e(V,V);const U=u(),F=u(),k=(t,s)=>{h(F,t,s),e(F,F);const n=-l(t,U)/l(F,U);T(n>=0),o(F,F,n),i(t,t,F)};if(2**this.lij[0]>2*this.lij[1]){const t=N,s=u();r(s,P,t),e(s,s),r(U,t,s),e(U,U),T(E(l(U,t)/n(t),0)),k(H,D),k(y,L),R(H,0),R(y,3)}else if(2**this.lij[0]!==2*this.lij[1]){const t=C,s=u();r(s,P,t),e(s,s),r(U,s,t),e(U,U),k(D,H),k(L,y),R(D,1),R(L,2)}const q=(t,e)=>{const s=A/l(e,V);for(let i=0;i<3;++i)this._convexHull[3*t+i]=e[i]*s};q(4,H),q(5,D),q(6,L),q(7,y)}_getPatchType(){const t=this.lij[1],e=0===t,s=t===(1<<this.level)-1;return e?s?_.HAS_BOTH_POLES:_.HAS_NORTH_POLE:s?_.HAS_SOUTH_POLE:_.REGULAR}intersectsRay(t,e,s,i){const o=this._boundingSphere,n=o[3]+s,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],l=o[0]-t[0],a=o[1]-t[1],h=o[2]-t[2],u=(l*e[0]+a*e[1]+h*e[2])/r,c=e[0]*u-l,d=e[1]*u-a,p=e[2]*u-h;return c*c+d*d+p*p<n*n}getDefaultVerticesPerSide(){return this.level<y.length?y[this.level]+1:2}updateCornerElevations(){M(this.renderData),this._updateBoundingVolumes()}updateEdgeElevations(){b(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){j(this.renderData),this._updateBoundingVolumes()}_checkBVs(){if(!S)return;if(this.level<=2)return;const t=this._boundingSphere,s=t[3],o=$(t),c=u(),p=this.ellipsoid.radius,f=this.elevationBounds;f[1],f[0];const m=p+f[0],g=1,_=0,x=this._center[H.MIDDLE][3],v=this.convexHull,M=(t,e)=>{for(let s=0;s<3;++s)t[s]=v[3*e+s]};{const t=u(),s=u(),i=u(),o=u(),n=u(),a=(a,u,c,d)=>{M(s,a),M(i,u),M(o,c),h(s,s,i),h(o,o,i),r(t,s,o),e(t,t);const p=l(t,i);M(n,d);const f=l(t,n),m=Math.abs(f-p);T(E(m,0),`Non coplanar ${a},${u},${c},${d} diff = ${m}`)};a(0,1,2,3),a(4,5,6,7),a(0,1,4,5),a(1,2,5,6),a(2,3,6,7),a(3,0,7,4)}const b=d(24),j=(t,e,s)=>{const i=4*t;for(let o=0;o<3;++o)b[i+o]=e[o];b[i+3]=s},I=u(),L=u(),y=u(),R=u(),P=(t,s,i,o)=>{M(I,s),M(L,i),M(y,o),h(I,I,L),e(I,I),h(y,y,L),e(y,y),r(R,I,y),e(R,R);const n=l(R,L);j(t,R,n)};P(0,0,1,2),P(1,1,0,4),P(2,1,5,2),P(3,3,2,6),P(4,4,0,3),P(5,4,6,5);const A=1,V=(t,e,s,i)=>{const o=4*t;return b[o]*e+b[o+1]*s+b[o+2]*i-b[o+3]},C=(t,e,s,i)=>V(t,e,s,i)>=-A,N=(t,e)=>C(t,e[0],e[1],e[2]),U=2**this.lij[0]>2*this.lij[1],F=(t,e,i)=>Math.sqrt(B(t,e,i,o[0],o[1],o[2]))<s,k=t=>F(t[0],t[1],t[2]),q=(t,e)=>F(t[e],t[e+1],t[e+2]),w=this.extentInRadians,G=.5*(w[0]+w[2]),z=w[1],W=w[3],J=u(),K=u();O(J,G,W,m),O(K,G,z,m);const Q=U?"Upper":"Lower";let X=!0;for(let e=0;e<6;++e){for(let t=0;t<8;++t){const s=3*t,i=C(e,v[s],v[s+1],v[s+2]);X&&=i,T(i,`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}T(N(e,K),`Tile[${this.lij}] (${Q}) bottom mid outside of plane ${e}`),T(N(e,J),`Tile[${this.lij}] (${Q}) top mid outside of plane ${e}`)}T(X,"Not all convex hull points are inside convex hull polyhedron"),T(k(K),`Tile[${this.lij}] (${Q}) bottom mid outside of bounding sphere`),T(k(J),`Tile[${this.lij}] (${Q}) top mid outside of bounding sphere`);for(let e=0;e<8;++e){const t=q(v,3*e);T(t,`Tile[${this.lij}] Convex hull point ${e} outside of bounding sphere`)}for(let e=0;e<6;++e)for(let t=0;t<8;++t){const s=3*t;C(e,v[s],v[s+1],v[s+2])||console.error(`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}const{extentInRadians:Y}=this,Z=Math.max(Y[2]-Y[0],Y[3]-Y[1]),tt=Math.round(Z*p),{renderData:et}=this;if(!et)return;const{geometry:st,geometryState:it,localOrigin:ot}=et,nt=st.vertexAttributes?.position;if(!nt)return;const rt=u(),lt=st.numVerticesPerSide-2,{indices:at,indexCount:ht,edgeVerticesStartIndex:ut,poleVerticesStartIndex:ct}=st;if(!at)return;const dt=new Set;for(let e=0;e<ht;++e){const t=at[e];if(dt.has(t))continue;dt.add(t);const r=t<ct,l=t>=ut;let h=!1,u=-1;if(l){let e=ut;for(let s=0;s<4;++s){const i=it.edgeResolutions[s];if(t===e||t===e+i-1){h=!0;break}if(e+=i,t<e){u=s;break}}}const d=l?it.edgePeerNeighbors[u]:null,m=l&&d&&D(this,d)>0;nt.getVec(t,c),i(rt,c,ot);const $=n(rt)-p;let v=0,M=!1;const b=f[0]-$,j=$-f[1],S=b>g,T=j>g,E=S||T,I=()=>{const e=r?"internal":l&&!h?"edge":h?"corner":"pole";return`Tile[${this.lij}].vertex[${t}]:${e}`+(S?"(below)":T?"(above)":"")+(m?"(Neighbor)":"")},H=a(rt,o);if(H>=s+_){const t=H-s;E||(console.error(`${I()} is out of the bounding sphere by ${t.toFixed(0)} / ${s.toFixed(0)}[tol=${_}] h=${$.toFixed(0)} / [${f[0].toFixed(0)}..${f[1].toFixed(0)}] (${(t/s).toFixed(0)})`),M=!0)}for(let e=0;e<6;++e)if(!C(e,rt[0],rt[1],rt[2])){const i=V(e,rt[0],rt[1],rt[2]),o=t%lt,n=(t-o)/lt;0===e&&b||5===e&&j||(console.error(`${I()} (${o},${n})|${lt}] is out of the bounding trapezoid plane ${e} h=${Math.round($)} / [${Math.round(f[0])}..${Math.round(f[1])}] dist=${Math.round(i)} radii = ${Math.round(s)}/${Math.round(x)}} : maxL = ${tt}`),++v)}if(M||v>0)break}}get convexHull(){return this._convexHull}}const y=[128,64,64,32,16,8,8,4];function R(t,e,s){return B(t[0],t[1],t[2],e[s],e[s+1],e[s+2])}function B(t,e,s,i,o,n){const r=i-t,l=o-e,a=n-s;return r*r+l*l+a*a}const O=(t,e,s,i)=>{const o=Math.cos(e),n=Math.sin(e),r=Math.cos(s),l=Math.sin(s);t[0]=i*r*o,t[1]=i*r*n,t[2]=i*l},P=[0,0,1],A=u(),V=u();export{L as SphericalPatch};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/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/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{releaseMaybe as o,destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import u from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as _,createAbortError as m}from"../../../core/promiseUtils.js";import{watch as f,syncAndInitial as T,sync as y,initial as v}from"../../../core/reactiveUtils.js";import{property as E}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as w}from"../../../core/accessorSupport/decorators/subclass.js";import{multiply as L}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as S}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as b,c as C}from"../../../chunks/vec32.js";import{create as P}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as D}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as x}from"../../../geometry/ellipsoidUtils.js";import U from"../../../geometry/SpatialReference.js";import{projectPointToVector as j}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as M}from"../../../geometry/projection/projectVectorToVector.js";import{create as R,equals as A,intersection as I,empty as V,expand as B,intersectsSphere as k}from"../../../geometry/support/aaBoundingRect.js";import{create as O,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as G}from"../../../geometry/support/spatialReferenceUtils.js";import{c as q,g as F,b as W}from"../../../chunks/sphere.js";import{isRefreshableLayer as H}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as $}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as Q}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as z}from"../../../layers/support/layerUtils.js";import{acquireDecoder as X}from"../../../layers/support/LercDecoder.js";import{printAllocations as Y}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as K}from"../support/cameraUtils.js";import{debugFlags as J}from"../support/debugFlags.js";import{ElevationRange as Z}from"../support/ElevationRange.js";import{ElevationUpdateEvent as ee}from"../support/ElevationUpdateEvent.js";import{toBoundingRect as te}from"../support/extentUtils.js";import{ClientType as ie}from"../support/index.js";import{updatingProgress as re}from"../support/updatingProperties.js";import{ElevationBounds as se}from"./ElevationBounds.js";import{ElevationData as ae,sampleElevation as ne}from"./ElevationData.js";import{create as le}from"./ExtentHelper.js";import{LODSnapping as oe,TextureUpdate as he}from"./interfaces.js";import{LayerClass as de,LayerClasses as pe}from"./LayerClass.js";import{OverlayManager as ue}from"./OverlayManager.js";import{PlanarPatch as ce}from"./PlanarPatch.js";import{RenderOrder as ge}from"./RenderOrder.js";import{ScaleRangeQueries as _e}from"./ScaleRangeQueries.js";import{SphericalPatch as me}from"./SphericalPatch.js";import{SplitLimits as fe}from"./SplitLimits.js";import{maxRootTiles as Te,tooManyRootTilesAfterChangeError as ye,tooManyRootTilesForLayerError as ve,maxTileNeighborLevelDelta as Ee,maxMemoryLodBias as we,elevationNodataValue as Le}from"./TerrainConst.js";import{TerrainRenderer as Se,TransparencyMode as be}from"./TerrainRenderer.js";import Ce from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as Pe,neighborEdgeIndices as De,internalAssert as xe,oppositeEdge as Ue,isSurfaceLayerView as je,isGroupLayerView as Me,isMapTileLayerView as Re,isBlendableLayerView as Ae,isElevationLayerView as Ie,isVectorTileLayerView as Ve,useFetchTileForLayer as Be,isImageryTileLayerView as ke,isTileLayerView as Oe,releaseTileData as Ne,enableTerrainInternalChecks as Ge,neighborCornerIndices as qe,oppositeCorner as Fe,enableWaterproofnessTests as We,enableInternalTerrainChecks as He,enableTerrainWaterproofnessChecks as $e}from"./terrainUtils.js";import{Tile as Qe}from"./Tile.js";import{printAllocations as ze}from"./TilePerLayerInfo.js";import{TileUpdate as Xe}from"./TileUpdate.js";import{IteratorPreorder as Ye,IteratorPostorder as Ke,compareTilesByLij as Je,hasLoadableSiblings as Ze,sortTilesByPOI as et,sortTiles as tt}from"./tileUtils.js";import{TilingSchemeLogic as it}from"./TilingSchemeLogic.js";import{UpsampleInfo as rt}from"./UpsampleInfo.js";import{isCompositeBlendMode as st,blendModeFromString as at}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as nt}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as lt}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as ot}from"../../support/RenderState.js";import{ImmediateTask as ht,TaskPriority as dt,noBudget as pt}from"../../support/Scheduler.js";var ut;let ct=ut=class extends(a.EventedMixin(i)){constructor(e){super(e),this._scaleRangeQueries=new _e,this._iteratorPool=new p(Ye,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ke,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new Ce,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=P(),this._eyePosSurfaceSR=P(),this._splitLimits=new fe,this._frustum=O(),this._viewProjectionMatrix=S(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new D,this._frameTask=ht,this._allTiles=new u,this._upsampleInfoPool=new p(rt),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=R(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=U.WebMercator,this.visibleElevationBounds=new se(1/0,-1/0),this.rootTileElevationBounds=new se(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.overlayManager=new ue({...e,surface:this}),this._isGlobal=!e.view?.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?me:ce}initialize(){const e=this.view,t=e.resourceController;this._lercDecoder=X(t);const i=t.memoryController;this._tileCache=new d(((e,t)=>i.newCache(e,t)),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new $(i.newCache("elevation-query"));const r=this.overlayManager;this._renderer=new Se(r.renderer,e._stage,this._allTiles,x(e.spatialReference).radius,i),this.addHandles([f((()=>r.renderer.isEmpty),(()=>this._evaluateTransparency())),f((()=>this.renderer.visible),(e=>this.suspended=!e))],"overlayManager"),this.addHandles([f((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?he.UNFADED:he.IMMEDIATE)}),T),f((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?he.UNFADED:he.IMMEDIATE)),T),f((()=>this.backgroundColor),((e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))}),y),f((()=>this.snapLevel),(()=>this._viewChanged=!0),y),f((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),f((()=>J.TERRAIN_TILE_TREE_SHOW_TILES),(t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&J.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))})):t||(this._treeDebugger=h(this._treeDebugger))}),v)]);const{spatialReference:a}=e;this._extentHelper=le(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new it({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(ie.ELEVATION),this._mapDataRequester=t.createStreamDataRequester(ie.BASEMAP);const o=t.scheduler;this._frameTask=o.registerTask(dt.TERRAIN_SURFACE,this),this.addHandles([f((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),v),f((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),y),f((()=>this.extent),(()=>this._updateRootTiles()),v),e.on("resize",(()=>this._viewChangeUpdate())),f((()=>{const t=e.state;return[this._lodBias,this.lodSnapping,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),T),f((()=>e.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),v),f((()=>e.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?nt.Terrain:nt.Disabled),v),f((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),y)]),this.addHandles(e.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._lercDecoder=o(this._lercDecoder),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),Qe.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer=h(this._renderer),this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),Y(),ze()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===oe.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(t&&i){const r=e.state.contentCamera;let s=K(e,r.eye,r.viewForward,r.up).tilt;s>90&&(s=180-s);const a=2*(s/90)**2,n=t.levelAtScale(i)-a,l=Math.min(n+e.qualitySettings.tiledSurface.lodBias,this._splitLimits.maxLod||1/0);return l<=0?null:l}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?oe.ON:oe.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(null==t||null==e)return null;const i=R(),r=te(t,i,e)?i:null,s=this._get("extent");return A(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=I(this.groundExtent,this._userClippingExtent,R()),t=this._get("extent");return A(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=this._rootTiles}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===be.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get textureFadeDuration(){return this.view.qualitySettings.tiledSurface.textureFadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length)return null;if(0===s[0].layerInfo[de.ELEVATION].length)return null;const a=b(mt,e,t,i);if(!M(a,r,a,this._spatialReference))return n.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;return wt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[de.ELEVATION].length:0;if(r?.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,wt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!j(e,mt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(mt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;mt[0]>t[2]&&(i+=1),mt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}getSphereElevationBounds(e,t){q(e,ft);const i=F(ft);if(!M(i,t,i,this.tilingScheme?.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;const r=new Z,s=e=>{if(e&&k(e.extent,ft))if(e.isLeaf||e.rendered)r.union(e.elevationBounds[0],e.elevationBounds[1]);else for(const t of e.children)s(t)},a=this._rootTiles;if(null!=a)for(const n of a)s(n);return r}getRootElevationBounds(){return new Z(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!j(e,F(ft),this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;ft[3]=t;let i=null;const r=e=>{if(e&&k(e.extent,ft)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=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._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?be.Empty:be.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?be.Opaque:be.Semitransparent,s=i!==r;return s&&(this._renderer.transparency=r,this.view?._stage?.renderer.setParameters({terrainTransparency:this._renderer.transparency})),s}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;Pe(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??U.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&G(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,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._tileCache.pop(ut._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=Tt;let s=t.rootTilesInExtent(e,i,5*Te);if(null!=this._rootTiles){if(s.length>Te)return void n.getLogger(this).warn(ye);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,_t);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>_t(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>Te&&(n.getLogger(this).warn(ve),s=t.rootTilesInExtent(e,i,Te)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=R(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.isLoaded&&e.intersectsClippingArea));e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Je);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===Xe.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Xe.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=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.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Xe.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Ze(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();if(e.updateClippingStatus(a)&&e.resetPendingUpdate(Xe.GEOMETRY)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData){const t=e.elevationBounds;r=Math.min(t[0],r),s=Math.max(t[1],s)}}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new se(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach((({elevationBounds:i})=>{e=Math.min(e,i[0]),t=Math.max(t,i[1])}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new se(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,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?this._splitLimits.frustum=N(this._splitLimits.frustum??O(),t.frustum):this._splitLimits.frustum=null,N(this._frustum,e.frustum),L(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),C(this._eyePosRenderSR,t.eye),M(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor((e=>{this._pendingTilesToUpdate.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Xe.TEXTURE_FADING)?Xe.TEXTURE_FADING:!!e.resetPendingUpdate(Xe.TEXTURE_NOFADING)&&Xe.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=vt.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),vt.spatialReference=this.spatialReference,this.emit("elevation-change",vt),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),Ge&&this._checkTileInvariant()}_checkTileInvariant(){const e=new Map;this._allTiles.forAll((t=>e.set(t,new Set))),this._allTiles.forAll((t=>{if(Pe(t.rendered===t.isLeaf,` rendered ${t.rendered} != ${t.isLeaf} leaf`),!t.isLeaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce(((t,i)=>t+(e(i)?0:1)),0);if(Pe(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(Xe.MERGE)){Pe(!t.hasPendingUpdate(Xe.SPLIT),"Tile can be both split and merge at the same time");for(const e of t.children)Pe(e.isLeaf||e.hasPendingUpdate(Xe.MERGE),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=Ee;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${Ee} (edge[${i}])`),Pe(r,`tile level delta [${t.level}] vs [${e.level}] > ${Ee}`))}Pe(t.level-e.level<=Ee,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-Ee,s=e=>e.isLeaf||e.level===t.level,a=t.findNeighborTile(De[i],s);if(null!=a){if(t.isLeaf&&t.level>=Ee){let i=a;for(;t.level-i.level<Ee;)i=i.parent;if(!_t([r,t.lij[1]>>Ee,t.lij[2]>>Ee],i.lij)){const r=e.get(i);Pe(!r.has(t),"Cannot already have neighbor"),r.add(t)}}Pe(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),Pe(t.level-a.level<=Ee,`Tile level delta [${t.level}] vs [${a.level}] > ${Ee}`)}}})),this._allTiles.forAll((t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);Pe(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)}))}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new Lt(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll((e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0}));const a=this._viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=null!=n&&n.hasPendingUpdate(Xe.MERGE),o=l?Xe.MERGE:e.shouldSplit(r,s,i),h=o===Xe.SPLIT;e.isLeaf?St(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(Xe.SPLIT),e.isLeaf||e.setPendingUpdate(Xe.MERGE),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(Xe.MERGE),e.isLeaf&&e.setPendingUpdate(Xe.SPLIT)):(e.resetPendingUpdate(Xe.SPLIT)&&e.updateAgentSuspension(),o===Xe.ELEVATION&&e.updateAgents(de.ELEVATION),e.isLeaf||(e.setPendingUpdate(Xe.MERGE),e.resetPendingUpdate(Xe.SPLIT)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(et(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){xe(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea));if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.isLoaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Je);const r=t.length;for(let s=0;s<r;++s){const r=t[s];xe(r.isLoaded),xe(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=qe[e];i(r,l.cornerPeerNeighbours[e]?.findCorner(Fe(t),(e=>e.isLoaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Ue(De[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(xe(e.has(t)||Je(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,Ge&&We&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(Xe.MERGE)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(Xe.MERGE);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(Xe.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(Xe.SPLIT)){let t=!0;{const e=s.renderData.geometryState.edgePeerNeighbors;for(let i=0;i<4;++i){const r=e[i];if(null!=r){s.level-r.level===Ee&&(t=!1)}}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(Xe.SPLIT)}return e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Xe.GEOMETRY)&&(this._updateTileGeometryState(t),this._updateTileTexture(t,e),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done))),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(lt.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*we}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(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(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.renderer.visible=!1}_purgeDescendantTiles(e){if(!e.children[0])return;const t=e.children.slice();e.unsetChildren();for(let i=0;i<4;++i)this._purgeTile(t[i])}_purgeTile(e){e.isLeaf?Ct(e):this._purgeDescendantTiles(e),this._allTiles.removeUnordered(e),this._unloadTile(e),this._tileCache.put(ut._tileMemcacheKey,e)}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){Pe(e.isLeaf,"Tile that is already split should not be split again!"),Pe(e.rendered,"Tile marked to split is not rendered"),Ct(e);const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2],s=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));this._allTiles.pushArray(s),e.updateAgentSuspension(),Pe(e.rendered,"parent should be rendered"),this._unloadTile(e),s.forEach((e=>this._loadTile(e))),s.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),s.forEach((e=>St(e,e.hasPendingUpdate(Xe.SPLIT)))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){Et.spatialReference=this.spatialReference,Et.extent=e.extent,Et.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",Et)}_createTile(e,t,i,r){Pe(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(Xe.SPLIT),s}get _shortBatches(){return this.view.state.mode!==ot.IDLE}_mergeTile(e){Pe(!e.hasPendingUpdate(Xe.SPLIT),"_mergeTile sanity check"),Pe(!e.isLeaf,"Cannot merge a leaf"),e.isLeaf||(this._purgeDescendantTiles(e),Pe(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),St(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new ae(e.lij,e.extent,i);e.dataArrived(t,de.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()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=pt){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),je(e)||Me(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Me(e)){const i=this._layerClassFromLayerView(e),s=this._getLayerIdxByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(Re(t)&&!z(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ae(e)||Me(e))&&st(at[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Ie(e)?de.ELEVATION:de.MAP}_registerTiledLayerView(e){const t=[];if((Ae(e)||Me(e))&&t.push(f((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(he.UNFADED)}))),!Me(e)){const i=this._layerClassFromLayerView(e);t.push(f((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(f((()=>e.fullOpacity),(()=>this._updateTileTextures(he.UNFADED)))),t.push(f((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!je(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===de.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of pe){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,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,r);this._layerViews[r]=i,this._restartAllAgents(r),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===de.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(de.MAP),e===he.IMMEDIATE?this.renderer.updateTileTexture(t,Xe.TEXTURE_NOFADING):t.updateRenderData(de.MAP,e)})),this._evaluateTransparency()}_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=lt.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||Ve(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,c(r),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===de.ELEVATION?Ie(i)?this._requestElevationTileData(e,i,r):Promise.reject():Re(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(_(i))return;const s=this._layerIndexByUid[de.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):n.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",de.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,de.ELEVATION,t,i),this.requestUpdate())};if(Be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:Le,signal:i.signal}).then((e=>{if(!_(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);n.getLogger(this).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));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:Le},i.signal))).then((e=>{e?r(new Q(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ne(s),_(i)||(this._dataMissing(e,de.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),_(i)?Ne(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),l=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Ve(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,l)}if(ke(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,l);if(Oe(t)&&Be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(_(i))return n.getLogger(this).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void l(m());a(e)}),l);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);H(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,l)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(de.MAP,t.uid);null!=r?e.dataArrived(r,de.MAP,i):(Ne(i),n.getLogger(this).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);null!=s?e.dataMissing(s,t,r):n.getLogger(this).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}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(null==e||null==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=t[0],r=t[1]>>i,s=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 Pe(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{null!=e._rootTiles&&e._rootTiles.length>0&&(e._mergeTile(e._rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){yt.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&yt.push(e)}));const t=yt.toArray();return tt(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!We)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),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=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._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]}enableInternalChecks(e){He(e)}enableWaterproofnessChecks(e){$e(e)}};ct._tileMemcacheKey="TerrainTileMemcache",e([E()],ct.prototype,"_renderer",void 0),e([E({constructOnly:!0})],ct.prototype,"_scaleRangeQueries",void 0),e([E({constructOnly:!0})],ct.prototype,"view",void 0),e([E({constructOnly:!0})],ct.prototype,"overlayManager",void 0),e([E()],ct.prototype,"_hasPendingUpdates",void 0),e([E()],ct.prototype,"_asyncWorkItems",void 0),e([E()],ct.prototype,"_allTilesDirty",void 0),e([E()],ct.prototype,"_allTilesSorted",void 0),e([E()],ct.prototype,"_viewChanged",void 0),e([E()],ct.prototype,"_splitLimits",void 0),e([E({readOnly:!0})],ct.prototype,"_watchUpdatingTracking",void 0),e([E()],ct.prototype,"_frameTask",void 0),e([E({readOnly:!0})],ct.prototype,"snapLevel",null),e([E({readOnly:!0})],ct.prototype,"lodSnapping",null),e([E()],ct.prototype,"_userClippingExtent",null),e([E()],ct.prototype,"_rootTilesExtent",void 0),e([E({readOnly:!0})],ct.prototype,"extent",null),e([E({readOnly:!0})],ct.prototype,"groundExtent",null),e([E({readOnly:!0})],ct.prototype,"_tilingSchemeExtent",null),e([E({readOnly:!0})],ct.prototype,"updating",null),e([E({readOnly:!0})],ct.prototype,"running",null),e([E(re)],ct.prototype,"updatingProgress",void 0),e([E({readOnly:!0})],ct.prototype,"updatingProgressValue",null),e([E()],ct.prototype,"_maxNumUpdating",void 0),e([E()],ct.prototype,"baseOpacity",null),e([E()],ct.prototype,"hasCompositeBlendMode",void 0),e([E({readOnly:!0})],ct.prototype,"viewingMode",null),e([E()],ct.prototype,"maxTextureScale",void 0),e([E({readOnly:!0})],ct.prototype,"ready",null),e([E({value:ge.FRONT_TO_BACK})],ct.prototype,"renderOrder",null),e([E({readOnly:!0})],ct.prototype,"rootTiles",null),e([E()],ct.prototype,"_rootTiles",void 0),e([E({readOnly:!0})],ct.prototype,"spatialReference",null),e([E({type:t})],ct.prototype,"backgroundColor",null),e([E({value:!1})],ct.prototype,"slicePlaneEnabled",null),e([E({readOnly:!0})],ct.prototype,"tilingScheme",void 0),e([E({readOnly:!0})],ct.prototype,"tilingSchemeLocked",null),e([E({readOnly:!0})],ct.prototype,"tilingSchemeLogic",void 0),e([E()],ct.prototype,"wireframe",null),e([E({value:!1})],ct.prototype,"suspended",null),e([E()],ct.prototype,"textureFadeDuration",null),e([E()],ct.prototype,"visibleElevationBounds",void 0),e([E()],ct.prototype,"rootTileElevationBounds",void 0),e([E()],ct.prototype,"_layerViewsDirty",void 0),e([E()],ct.prototype,"renderPatchBorders",null),e([E()],ct.prototype,"visualizeNormals",null),e([E()],ct.prototype,"renderingDisabled",null),ct=ut=e([w("esri.views.3d.terrain.TerrainSurface")],ct);const gt=ct;function _t(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}const mt=P(),ft=W(),Tt=R(),yt=new u,vt=new ee("ground"),Et={spatialReference:null,extent:null,scale:0};function wt(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return ne(t,i,s)}return null}class Lt{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function St(e,t){!e.isLeaf||e.level<Ee||Dt(e,(e=>{t&&bt(e);const i=Pt(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=Pt(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}}))}function bt(e){if(e.hasPendingUpdate(Xe.SPLIT))return;let t=e.parent;for(;t&&t.resetPendingUpdate(Xe.MERGE);)t=t.parent;e.resetPendingUpdate(Xe.MERGE),e.isLeaf&&e.setPendingUpdate(Xe.SPLIT),e.level<Ee||Dt(e,(e=>{bt(e)}))}function Ct(e){e.level<Ee||Dt(e,(e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,Pt(t));)t=t.parent}}))}function Pt(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function Dt(e,t){if(e.level<Ee)return;const i=e.level-Ee,r=e.lij[1]>>Ee,s=e.lij[2]>>Ee,a=e=>e.isLeaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(De[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}export{gt 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/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{releaseMaybe as o,destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import u from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as _,createAbortError as m}from"../../../core/promiseUtils.js";import{watch as f,syncAndInitial as T,sync as y,initial as v}from"../../../core/reactiveUtils.js";import{property as E}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{multiply as L}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as b,c as P}from"../../../chunks/vec32.js";import{create as C}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as D}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as j}from"../../../geometry/ellipsoidUtils.js";import x from"../../../geometry/SpatialReference.js";import{createEmptyProjectorCache as M,getProjector as U}from"../../../geometry/projection/projectors.js";import{projectPointToVector as R}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as A}from"../../../geometry/projection/projectVectorToVector.js";import{create as I,equals as B,intersection as V,empty as k,expand as O,intersectsSphere as N}from"../../../geometry/support/aaBoundingRect.js";import{create as G,copy as q}from"../../../geometry/support/frustum.js";import{isPlateCarree as F}from"../../../geometry/support/spatialReferenceUtils.js";import{c as W,g as H,b as $}from"../../../chunks/sphere.js";import{isRefreshableLayer as Q}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as z}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as X}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as Y}from"../../../layers/support/layerUtils.js";import{acquireDecoder as K}from"../../../layers/support/LercDecoder.js";import{printAllocations as J}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as Z}from"../support/cameraUtils.js";import{debugFlags as ee}from"../support/debugFlags.js";import{ElevationRange as te}from"../support/ElevationRange.js";import{ElevationUpdateEvent as ie}from"../support/ElevationUpdateEvent.js";import{toBoundingRect as re}from"../support/extentUtils.js";import{ClientType as se}from"../support/index.js";import{updatingProgress as ae}from"../support/updatingProperties.js";import{ElevationBounds as ne}from"./ElevationBounds.js";import{ElevationData as le,sampleElevation as oe}from"./ElevationData.js";import{create as he}from"./ExtentHelper.js";import{LODSnapping as de,TextureUpdate as pe}from"./interfaces.js";import{LayerClass as ue,LayerClasses as ce}from"./LayerClass.js";import{OverlayManager as ge}from"./OverlayManager.js";import{PlanarPatch as _e}from"./PlanarPatch.js";import{RenderOrder as me}from"./RenderOrder.js";import{ScaleRangeQueries as fe}from"./ScaleRangeQueries.js";import{SphericalPatch as Te}from"./SphericalPatch.js";import{SplitLimits as ye}from"./SplitLimits.js";import{maxRootTiles as ve,tooManyRootTilesAfterChangeError as Ee,tooManyRootTilesForLayerError as Se,maxTileNeighborLevelDelta as Le,maxMemoryLodBias as we,elevationNodataValue as be}from"./TerrainConst.js";import{TerrainRenderer as Pe,TransparencyMode as Ce}from"./TerrainRenderer.js";import De from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as je,neighborEdgeIndices as xe,internalAssert as Me,oppositeEdge as Ue,isSurfaceLayerView as Re,isGroupLayerView as Ae,isMapTileLayerView as Ie,isBlendableLayerView as Be,isElevationLayerView as Ve,isVectorTileLayerView as ke,useFetchTileForLayer as Oe,isImageryTileLayerView as Ne,isTileLayerView as Ge,releaseTileData as qe,enableTerrainInternalChecks as Fe,neighborCornerIndices as We,oppositeCorner as He,enableWaterproofnessTests as $e,enableInternalTerrainChecks as Qe,enableTerrainWaterproofnessChecks as ze}from"./terrainUtils.js";import{Tile as Xe}from"./Tile.js";import{printAllocations as Ye}from"./TilePerLayerInfo.js";import{TileUpdate as Ke}from"./TileUpdate.js";import{IteratorPreorder as Je,IteratorPostorder as Ze,compareTilesByLij as et,hasLoadableSiblings as tt,sortTilesByPOI as it,sortTiles as rt}from"./tileUtils.js";import{TilingSchemeLogic as st}from"./TilingSchemeLogic.js";import{UpsampleInfo as at}from"./UpsampleInfo.js";import{isCompositeBlendMode as nt,blendModeFromString as lt}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as ot}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as ht}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as dt}from"../../support/RenderState.js";import{ImmediateTask as pt,TaskPriority as ut,noBudget as ct}from"../../support/Scheduler.js";var gt;let _t=gt=class extends(a.EventedMixin(i)){constructor(e){super(e),this._scaleRangeQueries=new fe,this._iteratorPool=new p(Je,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ze,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new De,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=C(),this._eyePosSurfaceSR=C(),this._splitLimits=new ye,this._frustum=G(),this._viewProjectionMatrix=w(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new D,this._frameTask=pt,this._allTiles=new u,this._upsampleInfoPool=new p(at),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=I(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=x.WebMercator,this.visibleElevationBounds=new ne(1/0,-1/0),this.rootTileElevationBounds=new ne(1/0,-1/0),this._sebProjectorMap=new Map,this._sebProjectorCache=M(),this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.overlayManager=new ge({...e,surface:this}),this._isGlobal=!e.view?.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?Te:_e}initialize(){const e=this.view,t=e.resourceController;this._lercDecoder=K(t);const i=t.memoryController;this._tileCache=new d(((e,t)=>i.newCache(e,t)),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new z(i.newCache("elevation-query"));const r=this.overlayManager;this._renderer=new Pe(r.renderer,e._stage,this._allTiles,j(e.spatialReference).radius,i),this.addHandles([f((()=>r.renderer.isEmpty),(()=>this._evaluateTransparency())),f((()=>this.renderer.visible),(e=>this.suspended=!e))],"overlayManager"),this.addHandles([f((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?pe.UNFADED:pe.IMMEDIATE)}),T),f((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?pe.UNFADED:pe.IMMEDIATE)),T),f((()=>this.backgroundColor),((e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))}),y),f((()=>this.snapLevel),(()=>this._viewChanged=!0),y),f((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),f((()=>ee.TERRAIN_TILE_TREE_SHOW_TILES),(t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&ee.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))})):t||(this._treeDebugger=h(this._treeDebugger))}),v)]);const{spatialReference:a}=e;this._extentHelper=he(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new st({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(se.ELEVATION),this._mapDataRequester=t.createStreamDataRequester(se.BASEMAP);const o=t.scheduler;this._frameTask=o.registerTask(ut.TERRAIN_SURFACE,this),this.addHandles([f((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),v),f((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),y),f((()=>this.extent),(()=>this._updateRootTiles()),v),e.on("resize",(()=>this._viewChangeUpdate())),f((()=>{const t=e.state;return[this._lodBias,this.lodSnapping,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),T),f((()=>e.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),v),f((()=>e.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?ot.Terrain:ot.Disabled),v),f((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),y)]),this.addHandles(e.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._lercDecoder=o(this._lercDecoder),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),Xe.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer=h(this._renderer),this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),J(),Ye()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===de.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(t&&i){const r=e.state.contentCamera;let s=Z(e,r.eye,r.viewForward,r.up).tilt;s>90&&(s=180-s);const a=2*(s/90)**2,n=t.levelAtScale(i)-a,l=Math.min(n+e.qualitySettings.tiledSurface.lodBias,this._splitLimits.maxLod||1/0);return l<=0?null:l}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?de.ON:de.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(null==t||null==e)return null;const i=I(),r=re(t,i,e)?i:null,s=this._get("extent");return B(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,I()),t=this._get("extent");return B(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=this._rootTiles}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===Ce.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get textureFadeDuration(){return this.view.qualitySettings.tiledSurface.textureFadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length)return null;if(0===s[0].layerInfo[ue.ELEVATION].length)return null;const a=b(Tt,e,t,i);if(!A(a,r,a,this._spatialReference))return n.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;return wt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[ue.ELEVATION].length:0;if(r?.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,wt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!R(e,Tt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(Tt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;Tt[0]>t[2]&&(i+=1),Tt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureSEBProject(e){const t=this._sebProjectorMap.get(e);if(t)return t;const i=U(e,this._tilingSchemeSpatialReference,this._sebProjectorCache)??null;return this._sebProjectorMap.set(e,i),i}getSphereElevationBounds(e,t){const i=this._ensureSEBProject(t);if(null==i)return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;W(e,yt);const r=H(yt);i(r,0,r,0);const s=new te,a=e=>{if(e&&N(e.extent,yt))if(e.isLeaf||e.rendered)s.union(e.elevationBounds[0],e.elevationBounds[1]);else for(const t of e.children)a(t)},l=this._rootTiles;if(null!=l)for(const n of l)a(n);return s}getRootElevationBounds(){return new te(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!R(e,H(yt),this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;yt[3]=t;let i=null;const r=e=>{if(e&&N(e.extent,yt)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=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._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?Ce.Empty:Ce.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?Ce.Opaque:Ce.Semitransparent,s=i!==r;return s&&(this._renderer.transparency=r,this.view?._stage?.renderer.setParameters({terrainTransparency:this._renderer.transparency})),s}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;je(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??x.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&F(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._sebProjectorMap.clear(),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._tileCache.pop(gt._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=vt;let s=t.rootTilesInExtent(e,i,5*ve);if(null!=this._rootTiles){if(s.length>ve)return void n.getLogger(this).warn(Ee);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,ft);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>ft(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>ve&&(n.getLogger(this).warn(Se),s=t.rootTilesInExtent(e,i,ve)),this._setRootTiles(s.map((e=>this._newRootTile(e))));B(i,this._rootTilesExtent)||(this._rootTilesExtent=I(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.isLoaded&&e.intersectsClippingArea));e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(et);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===Ke.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Ke.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=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.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ke.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=tt(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();if(e.updateClippingStatus(a)&&e.resetPendingUpdate(Ke.GEOMETRY)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData){const t=e.elevationBounds;r=Math.min(t[0],r),s=Math.max(t[1],s)}}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new ne(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach((({elevationBounds:i})=>{e=Math.min(e,i[0]),t=Math.max(t,i[1])}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new ne(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,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?this._splitLimits.frustum=q(this._splitLimits.frustum??G(),t.frustum):this._splitLimits.frustum=null,q(this._frustum,e.frustum),L(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),P(this._eyePosRenderSR,t.eye),A(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor((e=>{this._pendingTilesToUpdate.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ke.TEXTURE_FADING)?Ke.TEXTURE_FADING:!!e.resetPendingUpdate(Ke.TEXTURE_NOFADING)&&Ke.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=St.extent;k(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>O(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),St.spatialReference=this.spatialReference,this.emit("elevation-change",St),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),Fe&&this._checkTileInvariant()}_checkTileInvariant(){const e=new Map;this._allTiles.forAll((t=>e.set(t,new Set))),this._allTiles.forAll((t=>{if(je(t.rendered===t.isLeaf,` rendered ${t.rendered} != ${t.isLeaf} leaf`),!t.isLeaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce(((t,i)=>t+(e(i)?0:1)),0);if(je(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(Ke.MERGE)){je(!t.hasPendingUpdate(Ke.SPLIT),"Tile can be both split and merge at the same time");for(const e of t.children)je(e.isLeaf||e.hasPendingUpdate(Ke.MERGE),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=Le;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${Le} (edge[${i}])`),je(r,`tile level delta [${t.level}] vs [${e.level}] > ${Le}`))}je(t.level-e.level<=Le,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-Le,s=e=>e.isLeaf||e.level===t.level,a=t.findNeighborTile(xe[i],s);if(null!=a){if(t.isLeaf&&t.level>=Le){let i=a;for(;t.level-i.level<Le;)i=i.parent;if(!ft([r,t.lij[1]>>Le,t.lij[2]>>Le],i.lij)){const r=e.get(i);je(!r.has(t),"Cannot already have neighbor"),r.add(t)}}je(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),je(t.level-a.level<=Le,`Tile level delta [${t.level}] vs [${a.level}] > ${Le}`)}}})),this._allTiles.forAll((t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);je(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)}))}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new bt(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll((e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0}));const a=this._viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=null!=n&&n.hasPendingUpdate(Ke.MERGE),o=l?Ke.MERGE:e.shouldSplit(r,s,i),h=o===Ke.SPLIT;e.isLeaf?Pt(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(Ke.SPLIT),e.isLeaf||e.setPendingUpdate(Ke.MERGE),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(Ke.MERGE),e.isLeaf&&e.setPendingUpdate(Ke.SPLIT)):(e.resetPendingUpdate(Ke.SPLIT)&&e.updateAgentSuspension(),o===Ke.ELEVATION&&e.updateAgents(ue.ELEVATION),e.isLeaf||(e.setPendingUpdate(Ke.MERGE),e.resetPendingUpdate(Ke.SPLIT)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(it(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Me(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea));if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.isLoaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(et);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Me(r.isLoaded),Me(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=We[e];i(r,l.cornerPeerNeighbours[e]?.findCorner(He(t),(e=>e.isLoaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Ue(xe[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(Me(e.has(t)||et(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,Fe&&$e&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(Ke.MERGE)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(Ke.MERGE);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(Ke.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(Ke.SPLIT)){let t=!0;const i=s.level;if(i>=Le){const e=e=>e.isLeaf||i-e.level<Le;for(let r=0;r<4;++r){const a=s.findNeighborTile(xe[r],e);null!=a&&i-a.level===Le&&(t=!1,Fe&&(Me(a.isLeaf),Me(a.hasPendingUpdate(Ke.SPLIT))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(Ke.SPLIT)}return e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Ke.GEOMETRY)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done))),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(ht.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*we}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(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(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.renderer.visible=!1}_purgeDescendantTiles(e){if(!e.children[0])return;const t=e.children.slice();e.unsetChildren();for(let i=0;i<4;++i)this._purgeTile(t[i])}_purgeTile(e){e.isLeaf?Dt(e):this._purgeDescendantTiles(e),this._allTiles.removeUnordered(e),this._unloadTile(e),this._tileCache.put(gt._tileMemcacheKey,e)}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){je(e.isLeaf,"Tile that is already split should not be split again!"),je(e.rendered,"Tile marked to split is not rendered"),Dt(e);const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2],s=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));this._allTiles.pushArray(s),e.updateAgentSuspension(),je(e.rendered,"parent should be rendered"),this._unloadTile(e),s.forEach((e=>this._loadTile(e))),s.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),s.forEach((e=>Pt(e,e.hasPendingUpdate(Ke.SPLIT)))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){Lt.spatialReference=this.spatialReference,Lt.extent=e.extent,Lt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",Lt)}_createTile(e,t,i,r){je(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(Ke.SPLIT),s}get _shortBatches(){return this.view.state.mode!==dt.IDLE}_mergeTile(e){je(!e.hasPendingUpdate(Ke.SPLIT),"_mergeTile sanity check"),je(!e.isLeaf,"Cannot merge a leaf"),e.isLeaf||(this._purgeDescendantTiles(e),je(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),Pt(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new le(e.lij,e.extent,i);e.dataArrived(t,ue.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()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=ct){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),Re(e)||Ae(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Ae(e)){const i=this._layerClassFromLayerView(e),s=this._getLayerIdxByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(Ie(t)&&!Y(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Be(e)||Ae(e))&&nt(lt[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Ve(e)?ue.ELEVATION:ue.MAP}_registerTiledLayerView(e){const t=[];if((Be(e)||Ae(e))&&t.push(f((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(pe.UNFADED)}))),!Ae(e)){const i=this._layerClassFromLayerView(e);t.push(f((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(f((()=>e.fullOpacity),(()=>this._updateTileTextures(pe.UNFADED)))),t.push(f((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!Re(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===ue.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ce){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,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,r);this._layerViews[r]=i,this._restartAllAgents(r),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===ue.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(ue.MAP),e===pe.IMMEDIATE?this.renderer.updateTileTexture(t,Ke.TEXTURE_NOFADING):t.updateRenderData(ue.MAP,e)})),this._evaluateTransparency()}_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=ht.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||ke(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,c(r),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===ue.ELEVATION?Ve(i)?this._requestElevationTileData(e,i,r):Promise.reject():Ie(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(_(i))return;const s=this._layerIndexByUid[ue.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):n.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",ue.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,ue.ELEVATION,t,i),this.requestUpdate())};if(Oe(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:be,signal:i.signal}).then((e=>{if(!_(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);n.getLogger(this).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));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:be},i.signal))).then((e=>{e?r(new X(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,qe(s),_(i)||(this._dataMissing(e,ue.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),_(i)?qe(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),l=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(ke(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,l)}if(Ne(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,l);if(Ge(t)&&Oe(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(_(i))return n.getLogger(this).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void l(m());a(e)}),l);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);Q(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,l)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(ue.MAP,t.uid);null!=r?e.dataArrived(r,ue.MAP,i):(qe(i),n.getLogger(this).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);null!=s?e.dataMissing(s,t,r):n.getLogger(this).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}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(null==e||null==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=t[0],r=t[1]>>i,s=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 je(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{null!=e._rootTiles&&e._rootTiles.length>0&&(e._mergeTile(e._rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){Et.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&Et.push(e)}));const t=Et.toArray();return rt(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!$e)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),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=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._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]}enableInternalChecks(e){Qe(e)}enableWaterproofnessChecks(e){ze(e)}};_t._tileMemcacheKey="TerrainTileMemcache",e([E()],_t.prototype,"_renderer",void 0),e([E({constructOnly:!0})],_t.prototype,"_scaleRangeQueries",void 0),e([E({constructOnly:!0})],_t.prototype,"view",void 0),e([E({constructOnly:!0})],_t.prototype,"overlayManager",void 0),e([E()],_t.prototype,"_hasPendingUpdates",void 0),e([E()],_t.prototype,"_asyncWorkItems",void 0),e([E()],_t.prototype,"_allTilesDirty",void 0),e([E()],_t.prototype,"_allTilesSorted",void 0),e([E()],_t.prototype,"_viewChanged",void 0),e([E()],_t.prototype,"_splitLimits",void 0),e([E({readOnly:!0})],_t.prototype,"_watchUpdatingTracking",void 0),e([E()],_t.prototype,"_frameTask",void 0),e([E({readOnly:!0})],_t.prototype,"snapLevel",null),e([E({readOnly:!0})],_t.prototype,"lodSnapping",null),e([E()],_t.prototype,"_userClippingExtent",null),e([E()],_t.prototype,"_rootTilesExtent",void 0),e([E({readOnly:!0})],_t.prototype,"extent",null),e([E({readOnly:!0})],_t.prototype,"groundExtent",null),e([E({readOnly:!0})],_t.prototype,"_tilingSchemeExtent",null),e([E({readOnly:!0})],_t.prototype,"updating",null),e([E({readOnly:!0})],_t.prototype,"running",null),e([E(ae)],_t.prototype,"updatingProgress",void 0),e([E({readOnly:!0})],_t.prototype,"updatingProgressValue",null),e([E()],_t.prototype,"_maxNumUpdating",void 0),e([E()],_t.prototype,"baseOpacity",null),e([E()],_t.prototype,"hasCompositeBlendMode",void 0),e([E({readOnly:!0})],_t.prototype,"viewingMode",null),e([E()],_t.prototype,"maxTextureScale",void 0),e([E({readOnly:!0})],_t.prototype,"ready",null),e([E({value:me.FRONT_TO_BACK})],_t.prototype,"renderOrder",null),e([E({readOnly:!0})],_t.prototype,"rootTiles",null),e([E()],_t.prototype,"_rootTiles",void 0),e([E({readOnly:!0})],_t.prototype,"spatialReference",null),e([E({type:t})],_t.prototype,"backgroundColor",null),e([E({value:!1})],_t.prototype,"slicePlaneEnabled",null),e([E({readOnly:!0})],_t.prototype,"tilingScheme",void 0),e([E({readOnly:!0})],_t.prototype,"tilingSchemeLocked",null),e([E({readOnly:!0})],_t.prototype,"tilingSchemeLogic",void 0),e([E()],_t.prototype,"wireframe",null),e([E({value:!1})],_t.prototype,"suspended",null),e([E()],_t.prototype,"textureFadeDuration",null),e([E()],_t.prototype,"visibleElevationBounds",void 0),e([E()],_t.prototype,"rootTileElevationBounds",void 0),e([E()],_t.prototype,"_layerViewsDirty",void 0),e([E()],_t.prototype,"renderPatchBorders",null),e([E()],_t.prototype,"visualizeNormals",null),e([E()],_t.prototype,"renderingDisabled",null),_t=gt=e([S("esri.views.3d.terrain.TerrainSurface")],_t);const mt=_t;function ft(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}const Tt=C(),yt=$(),vt=I(),Et=new u,St=new ie("ground"),Lt={spatialReference:null,extent:null,scale:0};function wt(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return oe(t,i,s)}return null}class bt{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function Pt(e,t){!e.isLeaf||e.level<Le||xt(e,(e=>{t&&Ct(e);const i=jt(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=jt(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}}))}function Ct(e){if(e.hasPendingUpdate(Ke.SPLIT))return;let t=e.parent;for(;t&&t.resetPendingUpdate(Ke.MERGE);)t=t.parent;e.resetPendingUpdate(Ke.MERGE),e.isLeaf&&e.setPendingUpdate(Ke.SPLIT),e.level<Le||xt(e,(e=>{Ct(e)}))}function Dt(e){e.level<Le||xt(e,(e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,jt(t));)t=t.parent}}))}function jt(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function xt(e,t){if(e.level<Le)return;const i=e.level-Le,r=e.lij[1]>>Le,s=e.lij[2]>>Le,a=e=>e.isLeaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(xe[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}export{mt as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import t from"../../../../../core/PooledArray.js";import{isArray as o}from"../../../../../core/typedArrayUtil.js";import{invert as r,transpose as n}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{a as s,x as a,t as l}from"../../../../../chunks/vec32.js";import{clone as m,create as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{compactIndices as f}from"../../../../../geometry/support/Indices.js";import{b as p}from"../../../../../chunks/vec3.js";import{c as h}from"../../../../../chunks/vec33.js";import{ViewingMode as u}from"../../../../ViewingMode.js";import{ColorMixModeEnum as d,encodeSymbolColor as g}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as b}from"../../../support/orientedBoundingBox.js";import{glLayout as y}from"../../../support/buffer/glUtil.js";import{newLayout as C}from"../../../support/buffer/InterleavedLayout.js";import j from"./ComponentData.js";import{ComponentObject as v}from"./ComponentObject.js";import _ from"./IntersectionGeometry.js";import{Renderable as w}from"./Renderable.js";import{RenderGeometry as M}from"./RenderGeometry.js";import{RenderSubmitSystem as x}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as O}from"./SourceGeometry.js";import{UniformComponentParameters as A}from"./UniformComponentParameters.js";import{ComponentParametersVarying as D,ComponentParametersUniform as S,ComponentParameterSummary as I,ComponentMaterial as P}from"./Material/ComponentMaterial.js";import{attributeLocations as U}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as E}from"./Material/shader/ComponentData.glsl.js";import{getVisibility as R,updateVisibilityWithCount as B}from"../../lib/ComponentUtils.js";import{assert as T}from"../../lib/Util.js";import{VertexAttribute as L}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as V}from"../../lib/verticalOffsetUtils.js";import{EdgeInputBufferLayout as G}from"../../lib/edgeRendering/bufferLayouts.js";import{extractComponentsEdgeLocationsLayout as k}from"../../lib/edgeRendering/edgeProcessing.js";import{BufferManager as N}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as q}from"../../../../webgl/BufferObject.js";import{Usage as H,PrimitiveType as W}from"../../../../webgl/enums.js";import{VertexArrayObject as X}from"../../../../webgl/VertexArrayObject.js";const Y=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class z{constructor(e,o){this._renderManager=e,this._viewingMode=o,this._visible=new t,this._hidden=new t,this._renderSubmit=new x(this),this._renderManager.register(this._renderSubmit),this._hasObjectAndLayerId=has("enable-feature:objectAndLayerId-rendering"),this._componentBufferManager=new N(e.rctx,2+(this._hasObjectAndLayerId?1:0))}destroy(){T(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._hidden.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.clear()}createObject(e){const t=new v;t.toMapSpace=e.toMapSpace,t.transform=e.transform,t.obb=e.obb.clone(),t.components=new j(this._componentBufferManager,f(e.geometry.componentOffsets)),t.renderable=this._createRenderable(e,t.components),t.intersectionGeometry=new _(e.geometry.positionData,t.components);return(t.visible?this._visible:this._hidden).push(t),t}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(t?(this._hidden.removeUnordered(o),this._visible.push(o)):(this._visible.removeUnordered(o),this._hidden.push(o)),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=s(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.components.visibility.reset(t),o.components.visibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.components.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.components.visibility.componentCount();return{visible:o,invisible:t.components.count-o}}setComponentData(e,t){const o=e,r=o.renderable.material,n=o.components,i=n.materialDataBuffer,s=n.materialDataIndices,a=new A,l=i.textureBuffer,m=new Uint8Array(4),c=new Uint32Array(m.buffer);let f=0,p=0,h=0,u=n.verticalOffsets,y=1/0,C=-1/0,j=!1,v=!1,_=0;for(let b=0;b<n.count;b++){t(b,a),f+=+(a.externalColor[3]<1),p+=+(a.externalColorMixMode===d.Replace&&1===a.externalColor[3]),h+=+a.castShadows,g(a.externalColor,a.externalColorMixMode,m),m[2]=254&m[2]|+a.castShadows,l.setData(s[b],0,m[0],m[1],m[2],m[3]),j||=b>0&&_!==c[0],_=c[0],v||=0!==a.elevationOffset,v&&null==u&&(u=new Array(b).fill(0)),null!=u&&(u[b]=a.elevationOffset),y=Math.min(y,a.elevationOffset),C=Math.max(C,a.elevationOffset),E(a.elevationOffset,m),l.setData(s[b],1,m[0],m[1],m[2],m[3]);const e=a.objectAndLayerIdColor;null!=e&&l.setData(s[b],2,e[0],e[1],e[2],e[3]),a.pickable!==R(n.pickability,b)&&(n.pickability=B(n.pickability,n.count,b,a.pickable))}n.verticalOffsets=v?u:null,o.offsetObb=v?b(o.obb,y,C,this._viewingMode,o.offsetObb??o.obb.clone()):null,j||v||this._hasObjectAndLayerId?(r.componentParameters=new D,r.componentParameters.castShadows=J(h,n.count),r.componentParameters.transparent=J(f,n.count),r.componentParameters.opaqueOverride=J(p,n.count),r.componentParameters.texture=l,l.updateTexture()):(r.componentParameters=new S,r.componentParameters.castShadows=a.castShadows?I.All:I.None,r.componentParameters.externalColor=a.externalColor,r.componentParameters.externalColorMixMode=a.externalColorMixMode),this._notifyDirty()}getComponentAabb(e,t,o,r=!1){e.intersectionGeometry.getComponentAabb(t,o);const n=e,i=n.components.verticalOffsets;if(r||null==i)return o;const s=i[t];if(this._viewingMode===u.Local||0===s)return o[2]+=s,o[5]+=s,o;const a=V(s);return a.localOrigin=n.transform.position,a.applyToAabb(o)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}intersect(e,t,o,i,s,m){const
|
|
5
|
+
import has from"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import t from"../../../../../core/PooledArray.js";import{isArray as o}from"../../../../../core/typedArrayUtil.js";import{invert as r,transpose as n}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{a as s,x as a,t as l}from"../../../../../chunks/vec32.js";import{clone as m,create as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{compactIndices as f}from"../../../../../geometry/support/Indices.js";import{b as p}from"../../../../../chunks/vec3.js";import{c as h}from"../../../../../chunks/vec33.js";import{ViewingMode as u}from"../../../../ViewingMode.js";import{ColorMixModeEnum as d,encodeSymbolColor as g}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as b}from"../../../support/orientedBoundingBox.js";import{glLayout as y}from"../../../support/buffer/glUtil.js";import{newLayout as C}from"../../../support/buffer/InterleavedLayout.js";import j from"./ComponentData.js";import{ComponentObject as v}from"./ComponentObject.js";import _ from"./IntersectionGeometry.js";import{Renderable as w}from"./Renderable.js";import{RenderGeometry as M}from"./RenderGeometry.js";import{RenderSubmitSystem as x}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as O}from"./SourceGeometry.js";import{UniformComponentParameters as A}from"./UniformComponentParameters.js";import{ComponentParametersVarying as D,ComponentParametersUniform as S,ComponentParameterSummary as I,ComponentMaterial as P}from"./Material/ComponentMaterial.js";import{attributeLocations as U}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as E}from"./Material/shader/ComponentData.glsl.js";import{getVisibility as R,updateVisibilityWithCount as B}from"../../lib/ComponentUtils.js";import{assert as T}from"../../lib/Util.js";import{VertexAttribute as L}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as V}from"../../lib/verticalOffsetUtils.js";import{EdgeInputBufferLayout as G}from"../../lib/edgeRendering/bufferLayouts.js";import{extractComponentsEdgeLocationsLayout as k}from"../../lib/edgeRendering/edgeProcessing.js";import{BufferManager as N}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as q}from"../../../../webgl/BufferObject.js";import{Usage as H,PrimitiveType as W}from"../../../../webgl/enums.js";import{VertexArrayObject as X}from"../../../../webgl/VertexArrayObject.js";const Y=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class z{constructor(e,o){this._renderManager=e,this._viewingMode=o,this._visible=new t,this._hidden=new t,this._renderSubmit=new x(this),this._renderManager.register(this._renderSubmit),this._hasObjectAndLayerId=has("enable-feature:objectAndLayerId-rendering"),this._componentBufferManager=new N(e.rctx,2+(this._hasObjectAndLayerId?1:0))}destroy(){T(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._hidden.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.clear()}createObject(e){const t=new v;t.toMapSpace=e.toMapSpace,t.transform=e.transform,t.obb=e.obb.clone(),t.components=new j(this._componentBufferManager,f(e.geometry.componentOffsets)),t.renderable=this._createRenderable(e,t.components),t.intersectionGeometry=new _(e.geometry.positionData,t.components);return(t.visible?this._visible:this._hidden).push(t),t}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(t?(this._hidden.removeUnordered(o),this._visible.push(o)):(this._visible.removeUnordered(o),this._hidden.push(o)),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=s(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.components.visibility.reset(t),o.components.visibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.components.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.components.visibility.componentCount();return{visible:o,invisible:t.components.count-o}}setComponentData(e,t){const o=e,r=o.renderable.material,n=o.components,i=n.materialDataBuffer,s=n.materialDataIndices,a=new A,l=i.textureBuffer,m=new Uint8Array(4),c=new Uint32Array(m.buffer);let f=0,p=0,h=0,u=n.verticalOffsets,y=1/0,C=-1/0,j=!1,v=!1,_=0;for(let b=0;b<n.count;b++){t(b,a),f+=+(a.externalColor[3]<1),p+=+(a.externalColorMixMode===d.Replace&&1===a.externalColor[3]),h+=+a.castShadows,g(a.externalColor,a.externalColorMixMode,m),m[2]=254&m[2]|+a.castShadows,l.setData(s[b],0,m[0],m[1],m[2],m[3]),j||=b>0&&_!==c[0],_=c[0],v||=0!==a.elevationOffset,v&&null==u&&(u=new Array(b).fill(0)),null!=u&&(u[b]=a.elevationOffset),y=Math.min(y,a.elevationOffset),C=Math.max(C,a.elevationOffset),E(a.elevationOffset,m),l.setData(s[b],1,m[0],m[1],m[2],m[3]);const e=a.objectAndLayerIdColor;null!=e&&l.setData(s[b],2,e[0],e[1],e[2],e[3]),a.pickable!==R(n.pickability,b)&&(n.pickability=B(n.pickability,n.count,b,a.pickable))}n.verticalOffsets=v?u:null,o.offsetObb=v?b(o.obb,y,C,this._viewingMode,o.offsetObb??o.obb.clone()):null,j||v||this._hasObjectAndLayerId?(r.componentParameters=new D,r.componentParameters.castShadows=J(h,n.count),r.componentParameters.transparent=J(f,n.count),r.componentParameters.opaqueOverride=J(p,n.count),r.componentParameters.texture=l,l.updateTexture()):(r.componentParameters=new S,r.componentParameters.castShadows=a.castShadows?I.All:I.None,r.componentParameters.externalColor=a.externalColor,r.componentParameters.externalColorMixMode=a.externalColorMixMode),this._notifyDirty()}getComponentAabb(e,t,o,r=!1){e.intersectionGeometry.getComponentAabb(t,o);const n=e,i=n.components.verticalOffsets;if(r||null==i)return o;const s=i[t];if(this._viewingMode===u.Local||0===s)return o[2]+=s,o[5]+=s,o;const a=V(s);return a.localOrigin=n.transform.position,a.applyToAabb(o)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}intersect(e,t,o,i,s,m,c){const f=e;null!=s&&(s.localOrigin=f.transform.position);const p=r(K,f.transform.rotationScale);a(Q,t,f.transform.position),a(Z,o,f.transform.position),l(Q,Q,p),l(Z,Z,p);const h=n(K,p);return f.intersectionGeometry.intersect(Q,Z,i,h,s,f.components.verticalOffsets,m,c)}addEdges(e,t,o,r){const n=e,{indices:i,positions:s}=n.intersectionGeometry,a=n.components.offsets;return t.addComponentObject(n,s,i,a,o,r)}async extractEdgeInformation(e,t,o){const r=e,n=r.components.visibility;if(n.allInvisible())return{buffer:k.createBuffer(0),origin:[0,0,0]};const{indices:i,positions:s}=r.intersectionGeometry,a=r.components.offsets,l=G.createBuffer(s.length/3);h(l.position.typedBuffer,s,l.position.typedBufferStride,3),p(l.position,l.position,r.transform.rotationScale),this._setComponentIndices(l.componentIndex,i,a);const c=l.count,f=this._computeVisibilityIndices(i,n,a,c);return{origin:m(r.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:f,indicesLength:f.length,skipDeduplicate:!0,data:l,writerSettings:{reducedPrecision:!1,variants:0}},o)}}_setComponentIndices(e,t,o){let r=0;for(let n=0;n<o.length-1;n++){const i=o[n],s=o[n+1];for(let o=i;o<s;o++){const n=t?t[o]:o;e.set(n,r)}r++}}_computeVisibilityIndices(e,t,r,n){if(e&&t.allVisible())return e;let i=0;t.forEachComponentRange(((e,t)=>(i+=r[t]-r[e],!0)));const s=o(e)?new Array(i):2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(i):new Uint32Array(i);let a=0;return t.forEachComponentRange(((t,o)=>{const n=r[t],i=r[o];for(let r=n;r<i;r++)s[a++]=e?e[r]:r;return!0})),s}addComponentHighlight(e,t){const o=e.components;null==o.highlightCounts&&(o.highlightCounts=new Uint32Array(o.count+1));0===o.highlightCounts[t]++&&(o.highlightsDirty(),this._notifyDirty()),o.highlightCounts[o.count]++}removeComponentHighlight(e,t){const o=e.components;if(null==o.highlightCounts)return void Y().warn("Removing non-existing highlight.");const r=o.highlightCounts[t],n=o.highlightCounts[o.count];if(0!==r){if(r>1)return o.highlightCounts[t]=r-1,void(o.highlightCounts[o.count]=n-1);o.highlightCounts[t]=0,o.highlightsDirty(),this._notifyDirty(),1===n?o.highlightCounts=null:o.highlightCounts[o.count]=n-1}else Y().warn("Removing non-existing highlight.")}clearHighlights(e){const t=e.components;null!=t.highlightCounts&&(t.highlightCounts=null,t.highlightsDirty(),this._notifyDirty())}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const o=this._renderManager.rctx,r=e.geometry,n=r.vertices.layoutParameters,i=q.createVertex(o,H.STATIC_DRAW,r.vertices.data),s=r.indices?q.createIndex(o,H.STATIC_DRAW,r.indices):null,a=y(O(n)),l=new Uint16Array(r.vertices.count);for(let u=0;u<t.count;u++){const e=t.offsets[u],o=t.offsets[u+1],n=t.materialDataIndices[u];if(null!=r.indices)for(let t=e;t<o;t++){l[r.indices[t]]=n}else for(let t=e;t<o;t++)l[t]=n}const m=q.createVertex(o,H.STATIC_DRAW,l.buffer),c=new P(e.transform,e.toMapSpace),f=new X(o,U,{data:a,componentIndices:F},{data:i,componentIndices:m},s),p=new M(f,W.TRIANGLES,n,null!=s),h={cameraDepthSquared:.5,gpuMemoryEstimate:i.usedMemory+m.usedMemory+(null!=s?s.usedMemory:0)};return new w(c,p,h)}_notifyDirty(){this._renderManager.notifyDirty()}}const F=y(C().u16(L.COMPONENTINDEX));function J(e,t){return e===t?I.All:0===e?I.None:I.Some}const K=i(),Q=c(),Z=c();export{z as ComponentObjectCollection};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{t}from"../../../../../chunks/vec32.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n}from"../../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as s}from"../../../../../geometry/support/FloatArray.js";import{compactIndices as i,getContinuousIndexArray as e}from"../../../../../geometry/support/Indices.js";import{componentMinimalSizeForIntersectionData as r,ComponentIntersectionData as p}from"./ComponentIntersectionData.js";import{Vertices as c}from"../../lib/Attribute.js";import{getVisibility as m}from"../../lib/ComponentUtils.js";import{computeInvDir as a,intersectAabbInvDir as h,intersectTriangles as l}from"../../materials/internal/MaterialUtil.js";class _{constructor(t,o){this._components=o,this._indices=t.indices?i(t.indices):e(t.positions.length/3),this._positions=t.positions,this._componentIntersectionData=new Array(o.count)}destroy(){this._positions=null,this._indices=null,this._componentIntersectionData.length=0,this._perComponentAabbs=null}getComponentAabb(t,o){this._perComponentAabbs||(this._perComponentAabbs=this._computePerComponentAabbs());for(let n=0;n<6;n++)o[n]=this._perComponentAabbs[6*t+n];return o}getComponentPositions(t,o){o.indices=this._indices,o.data=this._positions,o.stride=3,o.startIndex=this._components.offsets[t],o.endIndex=this._components.offsets[t+1]}intersect(o,n,s,i,e,_,b){const
|
|
5
|
+
import{t}from"../../../../../chunks/vec32.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n}from"../../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as s}from"../../../../../geometry/support/FloatArray.js";import{compactIndices as i,getContinuousIndexArray as e}from"../../../../../geometry/support/Indices.js";import{componentMinimalSizeForIntersectionData as r,ComponentIntersectionData as p}from"./ComponentIntersectionData.js";import{Vertices as c}from"../../lib/Attribute.js";import{getVisibility as m}from"../../lib/ComponentUtils.js";import{computeInvDir as a,intersectAabbInvDir as h,intersectTriangles as l}from"../../materials/internal/MaterialUtil.js";class _{constructor(t,o){this._components=o,this._indices=t.indices?i(t.indices):e(t.positions.length/3),this._positions=t.positions,this._componentIntersectionData=new Array(o.count)}destroy(){this._positions=null,this._indices=null,this._componentIntersectionData.length=0,this._perComponentAabbs=null}getComponentAabb(t,o){this._perComponentAabbs||(this._perComponentAabbs=this._computePerComponentAabbs());for(let n=0;n<6;n++)o[n]=this._perComponentAabbs[6*t+n];return o}getComponentPositions(t,o){o.indices=this._indices,o.data=this._positions,o.stride=3,o.startIndex=this._components.offsets[t],o.endIndex=this._components.offsets[t+1]}intersect(o,n,s,i,e,_,b,d){const g=new c(this._positions,3),A=this._indices,C=this._components.offsets,y=a(o,n,f),j=o[2],I=n[2];this._components.visibility.forEachComponent((c=>{if(!m(this._components.pickability,c))return!0;const a=this.getComponentAabb(c,u);if(null!=_){const t=_[c];null==e||d?(o[2]=j-t,n[2]=I-t):e.componentOffset=t}if(null==e||d||e.applyToAabb(a),!h(a,o,y,s))return!0;const f=C[c]/3,x=C[c+1]/3,M=(o,n,s)=>b(c,o,t(n,n,i),s);return(null==e||d)&&x-f>r?(null==this._componentIntersectionData[c]&&(this._componentIntersectionData[c]=new p(this._indices,f,x,g)),this._componentIntersectionData[c].intersectRay({r0:o,r1:n},M)):l(o,n,f,x,A,g,void 0,e,M),!0}))}_computePerComponentAabbs(){const t=this._components.count,o=s(6*t),n=this._indices,i=this._positions,e=this._components.offsets;let r=0;for(let s=0;s<t;s++){const t=e[s],p=e[s+1];let c=1/0,m=1/0,a=1/0,h=-1/0,l=-1/0,_=-1/0;for(let o=t;o<p;o++){const t=3*n[o],s=i[t],e=i[t+1],r=i[t+2];c=Math.min(c,s),m=Math.min(m,e),a=Math.min(a,r),h=Math.max(h,s),l=Math.max(l,e),_=Math.max(_,r)}o[r++]=c,o[r++]=m,o[r++]=a,o[r++]=h,o[r++]=l,o[r++]=_}return o}get positions(){return this._positions}get indices(){return this._indices}}const f=o(),u=n();export{_ as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{releaseMaybe as e}from"../../../../core/maybe.js";import{FBOPool as t}from"./FBOPool.js";import{PixelFormat as r,SizedPixelFormat as h,TextureWrapMode as s,PixelType as a,TextureSamplingMode as o,RenderbufferFormat as i,ColorAttachment as c,DepthStencilAttachment as n}from"../../../webgl/enums.js";import{FramebufferObject as l}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as d}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as u}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as _}from"../../../webgl/Texture.js";import{TextureDescriptor as p}from"../../../webgl/TextureDescriptor.js";class m{constructor(e){this.rctx=e,this._acquired=new Set,this._cache=new t(e.newCache,"FBOCache"),this._depthCache=new t(e.newCache,"DepthAttachmentCache"),this._colorCache=new t(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback&&this.debugCallback()}frameEnd(){const e=this.debugCallback;e&&this._acquired.forEach((t=>t.type===T.FBO&&e(t.name,t.fbo)))}get usedMemory(){return Array.from(this._acquired.values()).reduce(((e,t)=>e+("colorTexture"in t?t.colorTexture?.usedMemory??0:t.usedMemory)),this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e}acquire(e,t,r,h){const s=
|
|
5
|
+
import{releaseMaybe as e}from"../../../../core/maybe.js";import{FBOPool as t}from"./FBOPool.js";import{PixelFormat as r,SizedPixelFormat as h,TextureWrapMode as s,PixelType as a,TextureSamplingMode as o,RenderbufferFormat as i,ColorAttachment as c,DepthStencilAttachment as n}from"../../../webgl/enums.js";import{FramebufferObject as l}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as d}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as u}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as _}from"../../../webgl/Texture.js";import{TextureDescriptor as p}from"../../../webgl/TextureDescriptor.js";class m{constructor(e){this.rctx=e,this._acquired=new Set,this._cache=new t(e.newCache,"FBOCache"),this._depthCache=new t(e.newCache,"DepthAttachmentCache"),this._colorCache=new t(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback&&this.debugCallback()}frameEnd(){const e=this.debugCallback;e&&this._acquired.forEach((t=>t.type===T.FBO&&e(t.name,t.fbo)))}get usedMemory(){return Array.from(this._acquired.values()).reduce(((e,t)=>e+("colorTexture"in t?t.colorTexture?.usedMemory??0:t.usedMemory)),this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e}acquire(e,t,r,h=C.RGBA){const s=D(h,e,t);let a=this._cache.pop(s);return a?a.retain():a=new E(s,r,new l(this.rctx,{...G[h],width:e,height:t}),(e=>(a.releaseDepth(),a.depth=this._acquireDepth(e,a.fbo.width,a.fbo.height,`${a.name} depth`),a.fbo.attachDepthStencil(a.depth.attachment),a)),((r,h)=>{const s=this._acquireColor(r,e,t,`${a.name} color ${h}`);return a.colors??=new Map,a.colors.set(h,s),a.fbo.attachColorTexture(s.attachment,h),a})),a.name=r,a.release=()=>{a.dereference((()=>{this.debugCallback&&this.debugCallback(a.name,a.fbo),this._acquired.delete(a),a.releaseDepth(),a.colors?.forEach(((e,t)=>a.releaseColor(t))),this._cache.put(a),a.release=()=>console.log(`Double FBO release in ${(new Error).stack}`)}))},this.rctx.unbindTexture(a.fbo.colorTexture),this.rctx.bindFramebuffer(a.fbo),this._trackHandle(a)}acquireDepth(e,t,r,h){return this._acquireDepth(e,t,r,h)}_acquireDepth(e,t,r,h){const s=D(e,t,r),a=this._depthCache.pop(s);if(a)return a.name=h,this._trackHandle(a);const o=e===P.DEPTH_STENCIL_TEXTURE?new R(s,new _(this.rctx,{...B[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._depthCache.put(o)})):new R(s,new d(this.rctx,{...B[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._depthCache.put(o)}));return o.name=h,this._trackHandle(o)}_acquireColor(e,t,r,h){const s=D(e,t,r),a=this._colorCache.pop(s);if(a)return a.name=h,this._trackHandle(a);const o=new b(s,new _(this.rctx,{...G[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._colorCache.put(o)}));return o.name=h,this._trackHandle(o)}_trackHandle(e){return this._acquired.add(e),e}}var T,C;!function(e){e[e.FBO=0]="FBO",e[e.DEPTH=1]="DEPTH",e[e.COLOR=2]="COLOR"}(T||(T={}));class E{constructor(e,t,r,h,s){this.key=e,this.name=t,this.fbo=r,this.acquireDepth=h,this.acquireColor=s,this.type=T.FBO,this._refCount=1,this.release=()=>{},this.incarnation=0}dispose(){this.fbo.dispose()}retain(){++this._refCount}dereference(e){--this._refCount,0===this._refCount&&e()}releaseDepth(){this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),this.depth=e(this.depth)}detachDepth(){const e=this.depth;return this.depth=void 0,this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),e}attachDepth(e){return this.releaseDepth(),e&&(this.fbo.attachDepthStencil(e.attachment),this.depth=e),this}releaseColor(t){this.fbo.detachColorTexture(t);const r=this.colors?.get(t);this.colors?.delete(t),e(r)}get colorTexture(){return this.fbo?.colorTexture}getColorTexture(e=c.COLOR_ATTACHMENT0){return this.fbo?.getColorTexture(e)}getTexture(e=c.COLOR_ATTACHMENT0){return e===n?this.fbo?.depthStencilTexture:this.fbo?.getColorTexture(e)}get usedMemory(){return this.fbo.usedMemory}}class f{constructor(e,t,r){this.key=e,this.attachment=t,this.release=r,this.incarnation=0,this.name=""}dispose(){this.attachment.dispose()}get usedMemory(){return this.attachment.usedMemory}}class R extends f{constructor(){super(...arguments),this.type=T.DEPTH}}class b extends f{constructor(e,t,r){super(e,t,r),this.attachment=t,this.release=r,this.type=T.COLOR}}function D(e,t,r){return`${e}x${t}x${r}`}!function(e){e[e.RED=0]="RED",e[e.RG=1]="RG",e[e.RGBA4=2]="RGBA4",e[e.RGBA=3]="RGBA",e[e.RGBA_MIPMAP=4]="RGBA_MIPMAP",e[e.R16F=5]="R16F",e[e.RGBA16F=6]="RGBA16F"}(C||(C={}));const w=new p;w.pixelFormat=r.RED,w.internalFormat=h.R8,w.wrapMode=s.CLAMP_TO_EDGE;const A=new p;A.pixelFormat=r.RG,A.internalFormat=h.RG8,A.wrapMode=s.CLAMP_TO_EDGE;const M=new p;M.internalFormat=h.RGBA4,M.dataType=a.UNSIGNED_SHORT_4_4_4_4,M.wrapMode=s.CLAMP_TO_EDGE;const F=new p;F.wrapMode=s.CLAMP_TO_EDGE;const x=new p;x.wrapMode=s.CLAMP_TO_EDGE,x.samplingMode=o.LINEAR_MIPMAP_LINEAR,x.hasMipmap=!0,x.maxAnisotropy=8;const g=new p;g.pixelFormat=r.RED,g.dataType=a.HALF_FLOAT,g.internalFormat=h.R16F,g.samplingMode=o.NEAREST;const O=new p;O.dataType=a.HALF_FLOAT,O.internalFormat=h.RGBA16F,O.samplingMode=o.NEAREST;const G={[C.RED]:w,[C.RG]:A,[C.RGBA4]:M,[C.RGBA]:F,[C.RGBA_MIPMAP]:x,[C.R16F]:g,[C.RGBA16F]:O};var P;!function(e){e[e.DEPTH_STENCIL_TEXTURE=0]="DEPTH_STENCIL_TEXTURE",e[e.DEPTH16_BUFFER=1]="DEPTH16_BUFFER"}(P||(P={}));const y=new p;y.pixelFormat=r.DEPTH_STENCIL,y.dataType=a.UNSIGNED_INT_24_8,y.samplingMode=o.NEAREST,y.wrapMode=s.CLAMP_TO_EDGE;const B={[P.DEPTH_STENCIL_TEXTURE]:y,[P.DEPTH16_BUFFER]:new u(i.DEPTH_COMPONENT16,4)};export{C as ColorFormat,P as DepthFormat,m as FBOCache};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Collection.js";class
|
|
5
|
+
import e from"../../../../core/Collection.js";class s{constructor(){this._nodes=new e}add(e){this._nodes.push(e)}remove(e){const s=this._nodes.indexOf(e);this._nodes.removeAt(s)?.destroy()}produces(e){return this._nodes.some((s=>s.produces.includes(e)))}consumes(e){return this._nodes.some((s=>s.consumes.required.includes(e)))}render(e,s){if(!e.composite)return;let r,o=e.composite;return this._nodes.filter((e=>e.produces.includes(s))).forEach((n=>{const t=new Array;for(const s of n.consumes.required)switch(s){case"composite-color":t.push(o);break;case"linear-depth":if(!e.linearDepth)return;t.push(e.linearDepth);break;case"normals":if(!e.normals)return;t.push(e.normals);break;case"highlight":if(!e.highlight)return;t.push(e.highlight)}o=n.render(t,s),r?.release(),r=o})),r}}export{s as RenderNodeCollection};
|