@arcgis/core 4.28.0-next.20230818 → 4.28.0-next.20230821

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.
Files changed (200) hide show
  1. package/arcade/functions/centroid.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/003744a45b07865f1be9.js +1 -0
  4. package/assets/esri/core/workers/chunks/034accc7cab6c88a3b31.js +1 -0
  5. package/assets/esri/core/workers/chunks/05ab09713d599687afa3.js +1 -0
  6. package/assets/esri/core/workers/chunks/{3724f23b6f5ac8ec2568.js → 12b8fe0374fa9ab4ca09.js} +1 -1
  7. package/assets/esri/core/workers/chunks/16d1a72014074e87ecb9.js +1 -0
  8. package/assets/esri/core/workers/chunks/{e4b6565c16430b28ad93.js → 19857e5420cdf23c5f2e.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{1a804dea42c0fb5e5c07.js → 1bab408eaffd2c18976d.js} +1 -1
  10. package/assets/esri/core/workers/chunks/201365f53509e3f78e17.js +1 -0
  11. package/assets/esri/core/workers/chunks/{2031451b82ff70fb201a.js → 2f48f4a9a0a056ac5e1c.js} +1 -1
  12. package/assets/esri/core/workers/chunks/318b51fdee09c1fd750f.js +1 -0
  13. package/assets/esri/core/workers/chunks/{5b799dc155adeb728c74.js → 3361e3e8385f8de8820c.js} +1 -1
  14. package/assets/esri/core/workers/chunks/3ce1870c28ab6ac3648e.js +1 -0
  15. package/assets/esri/core/workers/chunks/41929e4531787389804b.js +1 -0
  16. package/assets/esri/core/workers/chunks/{55ac725127c5ea9fb942.js → 4e39252f40bc57be9d12.js} +1 -1
  17. package/assets/esri/core/workers/chunks/4e496b03ce24b1206f86.js +1 -0
  18. package/assets/esri/core/workers/chunks/{ee5f17c1790dc07f9d9e.js → 50455c84131b634ca6b4.js} +1 -1
  19. package/assets/esri/core/workers/chunks/54513578f735d274a20e.js +1 -0
  20. package/assets/esri/core/workers/chunks/{d46f8ef92e79d12384c9.js → 587437526ea77f764986.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{ab720e2f0a35138564b2.js → 5ffabd1a90c5b08109aa.js} +1 -1
  22. package/assets/esri/core/workers/chunks/6108d72faf48a592c8ba.js +1 -0
  23. package/assets/esri/core/workers/chunks/6479439afae01f9bb5e6.js +1 -0
  24. package/assets/esri/core/workers/chunks/69306dfc89e877539223.js +1 -0
  25. package/assets/esri/core/workers/chunks/6db4a6f9d25691830829.js +1 -0
  26. package/assets/esri/core/workers/chunks/{61393fd3376ea599a447.js → 76e27cece1559ae815df.js} +1 -1
  27. package/assets/esri/core/workers/chunks/81526909c0fa11639038.js +1 -0
  28. package/assets/esri/core/workers/chunks/873111ddf4813cdd4903.js +1 -0
  29. package/assets/esri/core/workers/chunks/8d4f1170394a8be15da9.js +1 -0
  30. package/assets/esri/core/workers/chunks/8d8bdfda09c24e363f78.js +1 -0
  31. package/assets/esri/core/workers/chunks/9b54b5bdb6367c36f6e9.js +1 -0
  32. package/assets/esri/core/workers/chunks/b2752e038c5fa3c21e49.js +1 -0
  33. package/assets/esri/core/workers/chunks/{dd3b7cfc6f78552249a4.js → b78dc6cbe14e5817b4d9.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{e31d0c7363cbceeb5ac9.js → c35b850fbfcb28133235.js} +1 -1
  35. package/assets/esri/core/workers/chunks/c83e1be4ee64320cf2fe.js +1 -0
  36. package/assets/esri/core/workers/chunks/c88869d2a647c22dc3e6.js +1 -0
  37. package/assets/esri/core/workers/chunks/cb0a5bc6deaa98026bb5.js +1 -0
  38. package/assets/esri/core/workers/chunks/{767467738aeabec14abd.js → d0c4367a197b193e95d4.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{f113141e254505116b82.js → d1cc2c050423595e54e0.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{7f34945036495ad7c3f8.js → d2a8bf2d090b94cb294b.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{08af7f7f1950a59a8e47.js → d6c96a20e9640b433719.js} +4 -4
  42. package/assets/esri/core/workers/chunks/da5453e67d00ff546640.js +1 -0
  43. package/assets/esri/core/workers/chunks/daa79c14150c12d8bc3d.js +1 -0
  44. package/assets/esri/core/workers/chunks/ef03b78659c72de93076.js +1 -0
  45. package/assets/esri/core/workers/chunks/{c3cace5b25b5170228ba.js → f2fe89b6ac6bf6817e71.js} +1 -1
  46. package/assets/esri/core/workers/chunks/f3554627664a419e00fa.js +1 -0
  47. package/assets/esri/themes/base/_core.scss +2 -0
  48. package/assets/esri/themes/base/widgets/_DirectionalPad.scss +76 -0
  49. package/assets/esri/themes/base/widgets/_Editor.scss +65 -4
  50. package/assets/esri/themes/base/widgets/_UtilityNetworkAssociations.scss +97 -39
  51. package/assets/esri/themes/dark/main.css +1 -1
  52. package/assets/esri/themes/light/main.css +1 -1
  53. package/assets/esri/themes/light/view.css +1 -1
  54. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad.json +1 -0
  55. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_en.json +1 -0
  56. package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
  57. package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
  58. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-caps/butt.png +0 -0
  59. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-caps/round.png +0 -0
  60. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-caps/square.png +0 -0
  61. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/dash-dot.png +0 -0
  62. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/dash.png +0 -0
  63. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/dot.png +0 -0
  64. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/long-dash-dot-dot.png +0 -0
  65. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/long-dash-dot.png +0 -0
  66. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/long-dash.png +0 -0
  67. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dash-dot-dot.png +0 -0
  68. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dash-dot.png +0 -0
  69. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dash.png +0 -0
  70. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dot.png +0 -0
  71. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/solid.png +0 -0
  72. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations.json +1 -1
  73. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_en.json +1 -1
  74. package/chunks/HighlightBlur.glsl.js +3 -3
  75. package/chunks/HighlightDownsample.glsl.js +24 -6
  76. package/chunks/SSAO.glsl.js +2 -2
  77. package/core/timeUtils.js +1 -1
  78. package/interfaces.d.ts +182 -2
  79. package/intl/date.js +1 -1
  80. package/layers/FeatureLayer.js +1 -1
  81. package/layers/ImageryLayer.js +1 -1
  82. package/layers/ImageryTileLayer.js +1 -1
  83. package/layers/StreamLayer.js +1 -1
  84. package/layers/SubtypeGroupLayer.js +1 -1
  85. package/layers/VoxelWasmPerSceneView.js +1 -1
  86. package/layers/graphics/sources/support/uploads.js +1 -1
  87. package/layers/mixins/ArcGISImageService.js +1 -1
  88. package/layers/mixins/ImageryTileMixin.js +1 -1
  89. package/layers/save/featureLayerUtils.js +1 -1
  90. package/layers/save/imageryUtils.js +1 -1
  91. package/layers/save/streamLayerUtils.js +1 -1
  92. package/libs/maquette-advanced-projector/utils.js +1 -1
  93. package/package.json +1 -1
  94. package/popup/support/FieldInfoFormat.js +1 -1
  95. package/portal/PortalItem.js +1 -1
  96. package/support/revision.js +1 -1
  97. package/views/2d/navigation/MapViewNavigation.js +1 -1
  98. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  99. package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
  100. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  101. package/views/3d/support/LaserLineRenderer.js +1 -1
  102. package/views/3d/terrain/OverlayRenderer.js +1 -1
  103. package/views/3d/terrain/TerrainRenderer.js +1 -1
  104. package/views/3d/terrain/TerrainSurface.js +1 -1
  105. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  106. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  107. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  108. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  109. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  110. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  111. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  112. package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
  113. package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
  114. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  115. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  116. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  117. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  118. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  119. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  120. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  121. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  122. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  123. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  124. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  125. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  126. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  127. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  128. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  129. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  130. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  131. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  132. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  133. package/views/3d/webgl-engine/shaders/HighlightDownsample.glsl.js +1 -1
  134. package/views/draw/DrawGraphicTool.js +1 -1
  135. package/views/draw/DrawOperation.js +1 -1
  136. package/views/interactive/sketch/constraints.js +1 -1
  137. package/views/interactive/sketch/normalizedPoint.js +1 -1
  138. package/views/interactive/snapping/SnappingManager.js +1 -1
  139. package/views/interactive/snapping/candidates/IntersectionSnappingCandidate.js +1 -1
  140. package/views/interactive/tooltip/TooltipEditableField.js +1 -1
  141. package/views/interactive/tooltip/TooltipEditableFieldAngle.js +1 -1
  142. package/views/interactive/tooltip/constraintUtils.js +5 -0
  143. package/views/support/angularMeasurementUtils.js +1 -1
  144. package/widgets/Compass/CompassViewModel.js +1 -1
  145. package/widgets/Compass/utils.js +5 -0
  146. package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +4 -0
  147. package/widgets/DirectionalPad/DirectionalPadViewModel.js +5 -0
  148. package/widgets/DirectionalPad/VisibleElements.js +5 -0
  149. package/widgets/DirectionalPad/constants.js +5 -0
  150. package/widgets/DirectionalPad/css.js +5 -0
  151. package/widgets/DirectionalPad/utils.js +5 -0
  152. package/widgets/DirectionalPad.d.ts +4 -0
  153. package/widgets/DirectionalPad.js +5 -0
  154. package/widgets/Editor/EditorViewModel.js +1 -1
  155. package/widgets/Editor/Upload.js +1 -1
  156. package/widgets/Editor/components/CreateFeaturesPanelContent.js +1 -1
  157. package/widgets/Editor/components/UploadDetails.js +1 -1
  158. package/widgets/Editor/modelUploadUtils.js +1 -1
  159. package/widgets/Editor.js +1 -1
  160. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  161. package/widgets/ElevationProfile.js +1 -1
  162. package/widgets/Feature/FeatureViewModel.js +1 -1
  163. package/widgets/Feature/support/featureUtils.js +1 -1
  164. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  165. package/widgets/FeatureForm/FieldInput.js +1 -1
  166. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  167. package/widgets/FeatureForm/InputBase.js +1 -1
  168. package/widgets/FeatureForm.js +1 -1
  169. package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsLineSymbolPicker.js +5 -0
  170. package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
  171. package/widgets/UtilityNetworkAssociations/VisibleElements.js +5 -0
  172. package/widgets/UtilityNetworkAssociations/VisibleElementsSettingsPane.js +5 -0
  173. package/widgets/UtilityNetworkAssociations.js +1 -1
  174. package/assets/esri/core/workers/chunks/11abbbf97093b55e2417.js +0 -1
  175. package/assets/esri/core/workers/chunks/1b2a081f2c3b97ba7e00.js +0 -1
  176. package/assets/esri/core/workers/chunks/235f333177ed7ea21e01.js +0 -1
  177. package/assets/esri/core/workers/chunks/3725dd14c2da0f47198f.js +0 -1
  178. package/assets/esri/core/workers/chunks/39467e1da18924cfb9b6.js +0 -1
  179. package/assets/esri/core/workers/chunks/42595c4870c673ed451c.js +0 -1
  180. package/assets/esri/core/workers/chunks/481cdd2a4bc40c6fef66.js +0 -1
  181. package/assets/esri/core/workers/chunks/54893132e70c515ea7e3.js +0 -1
  182. package/assets/esri/core/workers/chunks/6509a4198972b323d9b6.js +0 -1
  183. package/assets/esri/core/workers/chunks/68598d2806d4aa3d8acc.js +0 -1
  184. package/assets/esri/core/workers/chunks/718d2e8ea61f3b7b70c5.js +0 -1
  185. package/assets/esri/core/workers/chunks/7bce4b5eec630ef57f1e.js +0 -1
  186. package/assets/esri/core/workers/chunks/81df7304f97d1fc3ba16.js +0 -1
  187. package/assets/esri/core/workers/chunks/8706dc9f852df9b2095d.js +0 -1
  188. package/assets/esri/core/workers/chunks/8ef26aac0fe7feb8c324.js +0 -1
  189. package/assets/esri/core/workers/chunks/91e61da22f258d9e86c5.js +0 -1
  190. package/assets/esri/core/workers/chunks/9f039bf79b34d8fd75ae.js +0 -1
  191. package/assets/esri/core/workers/chunks/a1f3352301472e4b8956.js +0 -1
  192. package/assets/esri/core/workers/chunks/a20fd9e7db37b3c3b041.js +0 -1
  193. package/assets/esri/core/workers/chunks/aa83dce42d64034a0a13.js +0 -1
  194. package/assets/esri/core/workers/chunks/c8c8471b59700914ee9d.js +0 -1
  195. package/assets/esri/core/workers/chunks/cdcf0a5e05283d37b3ac.js +0 -1
  196. package/assets/esri/core/workers/chunks/d4f9106bf2ea5d66d96a.js +0 -1
  197. package/assets/esri/core/workers/chunks/e6bfbc4347fa13db4df2.js +0 -1
  198. package/assets/esri/core/workers/chunks/f1d5487f2d828fb142ba.js +0 -1
  199. package/assets/esri/core/workers/chunks/f97f165d05439e668e05.js +0 -1
  200. package/assets/esri/core/workers/chunks/fe973d8155c22d73a4f9.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.28/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 _,isAborted as g,createAbortError as m}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as f,initial as v}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as E}from"../../../core/accessorSupport/decorators/subclass.js";import{m as S}from"../../../chunks/mat4.js";import{c as L}from"../../../chunks/mat4f64.js";import{i as D}from"../../../chunks/vec3.js";import{c as P}from"../../../chunks/vec3f64.js";import{c as x}from"../../../chunks/vec4f64.js";import{UpdatingHandles as U}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b}from"../../../geometry/ellipsoidUtils.js";import R from"../../../geometry/SpatialReference.js";import{projectPointToVector as C}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as M}from"../../../geometry/projection/projectVectorToVector.js";import{create as j,equals as A,intersection as I,empty as V,expand as B,intersectsSphere as O}from"../../../geometry/support/aaBoundingRect.js";import{create as k,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as q}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as F}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as G}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as W}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as H}from"../../../layers/support/layerUtils.js";import{acquireDecoder as Q}from"../../../layers/support/LercDecoder.js";import{printAllocations as z}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as X}from"../support/cameraUtils.js";import{debugFlags as Y}from"../support/debugFlags.js";import{toBoundingRect as $}from"../support/extentUtils.js";import{ClientType as K}from"../support/index.js";import{updatingProgress as J}from"../support/updatingProperties.js";import{ElevationBounds as Z}from"./ElevationBounds.js";import{ElevationData as ee,sampleElevation as te}from"./ElevationData.js";import{create as ie}from"./ExtentHelper.js";import{LODSnapping as re,TextureUpdate as se}from"./interfaces.js";import{LayerClass as ae,LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as he}from"./RenderOrder.js";import{ScaleRangeQueries as de}from"./ScaleRangeQueries.js";import{SphericalPatch as pe}from"./SphericalPatch.js";import{SplitLimits as ue}from"./SplitLimits.js";import{MAX_ROOT_TILES as ce,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as _e,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ge,MAX_MEMORY_LOD_BIAS as me,ELEVATION_NODATA_VALUE as Te}from"./TerrainConst.js";import{TerrainRenderer as ye,TransparencyMode as fe}from"./TerrainRenderer.js";import ve from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as we,internalAssert as Ee,oppositeEdge as Se,isSurfaceLayerView as Le,isGroupLayerView as De,isMapTileLayerView as Pe,isBlendableLayerView as xe,isElevationLayerView as Ue,isVectorTileLayerView as be,useFetchTileForLayer as Re,isImageryTileLayerView as Ce,isTileLayerView as Me,releaseTileData as je,neighborCornerIndices as Ae,oppositeCorner as Ie,neighborEdgeIndices as Ve,ENABLE_TERRAIN_INTERNAL_CHECKS as Be,ENABLE_WATERPROOFNESS_TESTS as Oe,enableTerrainInternalChecks as ke,enableTerrainWaterproofnessChecks as Ne}from"./terrainUtils.js";import{Tile as qe}from"./Tile.js";import{printAllocations as Fe}from"./TilePerLayerInfo.js";import{TileUpdate as Ge}from"./TileUpdate.js";import{IteratorPreorder as We,IteratorPostorder as He,compareTilesByLij as Qe,hasLoadableSiblings as ze,sortTilesByPOI as Xe,sortTiles as Ye}from"./tileUtils.js";import{TilingSchemeLogic as $e}from"./TilingSchemeLogic.js";import{UpsampleInfo as Ke}from"./UpsampleInfo.js";import{isCompositeBlendMode as Je,blendModeFromString as Ze}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as et}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as tt}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as it}from"../../support/RenderState.js";import{ImmediateTask as rt,TaskPriority as st,noBudget as at}from"../../support/Scheduler.js";let nt=class extends(a.EventedMixin(i)){constructor(e){super(e),this._scaleRangeQueries=new de,this._iteratorPool=new p(We,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new He,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new ve,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=P(),this._eyePosSurfaceSR=P(),this._splitLimits=new ue,this._frustum=k(),this._viewProjectionMatrix=L(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new U,this._frameTask=rt,this._allTiles=new u,this._upsampleInfoPool=new p(Ke),this._rootTilesExtent=j(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=R.WebMercator,this.visibleElevationBounds=new Z(1/0,-1/0),this.rootTileElevationBounds=new Z(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._isWebMercatorOnPlateeCarree=!1,this.overlayManager=new le({...e,surface:this}),this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=Q(this.view.resourceController),this._tilePool=this.view.state.isLocal?new p(oe):new p(pe);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new G(e.newCache("elevation-query")),this._tileTextureCache=new d(((t,i)=>e.newCache(t,i)),"TileTexture"),this._renderer=new ye({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:b(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles,_cache:this._tileTextureCache}),this.addHandles([T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e))),T((()=>this.overlayManager.renderer.isEmpty),(()=>this._evaluateTransparency())),T((()=>this.renderer.visible),(e=>{this.suspended=!e}))],"overlayManager"),this.addHandles([T((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?se.UNFADED:se.IMMEDIATE)}),y),T((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?se.UNFADED:se.IMMEDIATE)),y),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.snapLevel),(()=>this._viewChanged=!0),f),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),T((()=>Y.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&Y.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=h(this._treeDebugger))}),v)]);const{spatialReference:t}=this.view;this._extentHelper=ie(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:t});const i=new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),r=new $e({layers:i,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:t});this._set("tilingSchemeLogic",r),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(K.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(K.BASEMAP);const a=this.view.resourceController.scheduler;this._frameTask=a.registerTask(st.TERRAIN_SURFACE,this),this.addHandles([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),v),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),f),T((()=>this.extent),(()=>this._updateRootTiles()),v),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),v),T((()=>this.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?et.Terrain:et.Disabled),v),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),f)]),this.addHandles(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}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._tilePool=h(this._tilePool),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._tileTextureCache=h(this._tileTextureCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),z(),Fe()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===re.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(t&&i){const r=e.state.contentCamera;let s=X(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?re.ON:re.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const i=j(),r=$(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,j()),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===fe.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(null==s||!s.length)return null;if(0===s[0].layerInfo[ae.ELEVATION].length)return null;const a=pt;if(a[0]=e,a[1]=t,a[2]=i,!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 Tt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[ae.ELEVATION].length:0;if(null!=r&&r.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,Tt(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(!C(e,pt,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(pt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;pt[0]>t[2]&&(i+=1),pt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}getSphereElevationBounds(e,t){if(pt[0]=e[0],pt[1]=e[1],pt[2]=e[2],pt[3]=e[3],!M(pt,t,pt,this.tilingScheme?.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let i=1/0,r=-1/0;const s=e=>{if(e&&O(e.extent,pt))if(e.isLeaf||e.rendered)i=Math.min(i,e.elevationBounds[0]),r=Math.max(r,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{min:i,max:r}}getRootElevationBounds(){return{min:this.rootTileElevationBounds.min,max:this.rootTileElevationBounds.max}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!C(e,pt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;pt[3]=t;let i=null;const r=e=>{if(e&&O(e.extent,pt)){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?fe.Empty:fe.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?fe.Opaque:fe.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;we(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??R.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateeCarree=this._isWebMercator&&q(this.view?.renderSpatialReference),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles())}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return ct[0]=e,ct[1]=t,ct[2]=i,s.init(ct,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=ut;let s=t.rootTilesInExtent(e,i,5*ce);if(null!=this._rootTiles){if(s.length>ce)return void n.getLogger(this).warn(_e);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,ot);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>ot(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>ce&&(n.getLogger(this).warn(ge),s=t.rootTilesInExtent(e,i,ce)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=j(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(Qe);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)===Ge.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Ge.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(Ge.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();e.updateClippingStatus(a)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e),e.setPendingUpdate(Ge.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBounds[0],r),s=Math.max(e.elevationBounds[1],s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._batchUpdatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new Z(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 Z(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?(null==this._splitLimits.frustum&&(this._splitLimits.frustum=k()),N(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,N(this._frustum,e.frustum),S(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),D(this._eyePosRenderSR,t.eye),M(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(ht(e)?this._loadChildren(e):dt(e)&&this._loadParent(e))}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForGeometryUpdate(e){const t=this._pendingTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ge.TEXTURE_FADING)?Ge.TEXTURE_FADING:!!e.resetPendingUpdate(Ge.TEXTURE_NOFADING)&&Ge.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){const e=gt.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),gt.spatialReference=this.spatialReference,this.emit("elevation-change",gt)}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._batchUpdatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue")}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();t.reset(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;for(;!t.done;){const e=t.next(),a=e.shouldSplit(r,s,i);if(a!==Ge.SPLIT){if(e.resetPendingUpdate(Ge.SPLIT)&&e.updateAgentSuspension(),a===Ge.ELEVATION&&e.updateAgents(ae.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ge.MERGE),e.resetPendingUpdate(Ge.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);const i=this._viewProjectionMatrix;for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(i);t.remove()}}else e.resetPendingUpdate(Ge.MERGE),e.isLeaf&&(e.setPendingUpdate(Ge.SPLIT),t.skipSubtree()),e.rendered&&e.setPendingUpdate(Ge.RENDERDATA)}t.remove(),this.requestUpdate(),(this.shortBatches||!this.oneBatchPerFrameTask)&&this._batchUpdatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Xe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Ee(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForGeometryUpdate(e))}_batchUpdatePendingTileGeometries(){const e=this._pendingTilesToUpdate;if(0===e.size)return;const t=Array.from(this._pendingTilesToUpdate.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea)),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(Qe);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Ee(r.isLoaded),Ee(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData.cornerPeerNeighbors,o=e=>{const t=Ae[e];i(r,l[e]?.findCorner(Ie(t),(e=>e.isLoaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.neighborData.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Se(Ve[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(Ee(e.has(t)||Qe(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),Be&&Oe&&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.resetPendingUpdate(Ge.MERGE)){if(!t)return s.setPendingUpdate(Ge.MERGE),e.done;for(;n.parent?.resetPendingUpdate(Ge.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else s.resetPendingUpdate(Ge.SPLIT)&&(this._splitTile(s),a=!0,e.madeProgress());return!e.done&&n===s&&s.resetPendingUpdate(Ge.RENDERDATA)&&(this._updateRenderData(s),e.madeProgress()),e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Ge.GEOMETRY)&&(this._updateTileGeometryState(t),this._updateTileTexture(t,e),this.shortBatches&&this._batchUpdatePendingTileGeometries(),e.madeProgress()),e.done))),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(tt.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*me}_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!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i])||t;return e.unsetChildren(),t}_purgeTile(e){const t=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),this._tilePool.release(e),t}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){we(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ge.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){mt.spatialReference=this.spatialReference,mt.extent=e.extent,mt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",mt)}_createTile(e,t,i,r){we(!!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(Ge.SPLIT),s}get shortBatches(){return this.view.state.mode!==it.IDLE}_mergeTile(e){we(!e.hasPendingUpdate(Ge.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(we(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this.shortBatches&&this._batchUpdatePendingTileGeometries()),this._allTilesDirty=!0,++this._performanceInfo.numMerged}_loadChildren(e){we(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForGeometryUpdate(e),this._emitTileScaleChange(e,e.level+1),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._markTileToUpdate(t),this._emitTileScaleChange(t,t.level),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_unloadChildren(e){const t=e.children;if(t[0])for(let i=0;i<4;++i){const e=t[i];this._unloadChildren(e),this._unloadTile(e)}}_loadTile(e){e.load(),e.setPendingUpdate(Ge.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new ee(e.lij,e.extent,i);e.dataArrived(t,ae.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=at){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),Le(s)||De(s))if(this._basemapLayerViewHandles.has(s.uid)&&!De(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);null!=i&&((i<r||null==r)&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.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(Pe(t)&&!H(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((xe(e)||De(e))&&Je(Ze[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Ue(e)?ae.ELEVATION:ae.MAP}_registerTiledLayerView(e){const t=[];if((xe(e)||De(e))&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(se.UNFADED)}))),!De(e)){const i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(se.UNFADED)))),t.push(T((()=>"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||!Le(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===ae.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ne){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===ae.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(ae.MAP),e===se.IMMEDIATE?this.renderer.updateTileTexture(t,Ge.TEXTURE_NOFADING):t.updateRenderData(ae.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=tt.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||be(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),_(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===ae.ELEVATION?Ue(i)?this._requestElevationTileData(e,i,r):Promise.reject():Pe(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(g(i))return;const s=this._layerIndexByUid[ae.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",ae.ELEVATION,e.lij.toString())},s=i=>{_(i)||(this._dataMissing(e,ae.ELEVATION,t,i),this.requestUpdate())};if(Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:Te,signal:i.signal}).then((e=>{if(!g(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:Te},i.signal))).then((e=>{e?r(new W(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,je(s),g(i)||(this._dataMissing(e,ae.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),g(i)?je(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),l=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(be(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,l)}if(Ce(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,l);if(Me(t)&&Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(g(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]);F(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(ae.MAP,t.uid);null!=r?e.dataArrived(r,ae.MAP,i):(je(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=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this._rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return we(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(){_t.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&_t.push(e)}));const t=_t.toArray();return Ye(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!Oe)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 isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateeCarree(){return this._isWebMercatorOnPlateeCarree}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(null!=this.spatialReference&&this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){ke(e)}enableWaterproofnessChecks(e){Ne(e)}};e([w()],nt.prototype,"_renderer",void 0),e([w({constructOnly:!0})],nt.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],nt.prototype,"view",void 0),e([w({constructOnly:!0})],nt.prototype,"overlayManager",void 0),e([w()],nt.prototype,"_hasPendingUpdates",void 0),e([w()],nt.prototype,"_asyncWorkItems",void 0),e([w()],nt.prototype,"_allTilesDirty",void 0),e([w()],nt.prototype,"_allTilesSorted",void 0),e([w()],nt.prototype,"_viewChanged",void 0),e([w()],nt.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],nt.prototype,"_watchUpdatingTracking",void 0),e([w()],nt.prototype,"_frameTask",void 0),e([w({readOnly:!0})],nt.prototype,"snapLevel",null),e([w({readOnly:!0})],nt.prototype,"lodSnapping",null),e([w()],nt.prototype,"_userClippingExtent",null),e([w()],nt.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],nt.prototype,"extent",null),e([w({readOnly:!0})],nt.prototype,"groundExtent",null),e([w({readOnly:!0})],nt.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],nt.prototype,"updating",null),e([w({readOnly:!0})],nt.prototype,"running",null),e([w(J)],nt.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],nt.prototype,"updatingProgressValue",null),e([w()],nt.prototype,"_maxNumUpdating",void 0),e([w()],nt.prototype,"baseOpacity",null),e([w()],nt.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],nt.prototype,"viewingMode",null),e([w()],nt.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],nt.prototype,"ready",null),e([w({value:he.FRONT_TO_BACK})],nt.prototype,"renderOrder",null),e([w({readOnly:!0})],nt.prototype,"rootTiles",null),e([w()],nt.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],nt.prototype,"spatialReference",null),e([w({type:t})],nt.prototype,"backgroundColor",null),e([w({value:!1})],nt.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],nt.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],nt.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],nt.prototype,"tilingSchemeLogic",void 0),e([w()],nt.prototype,"wireframe",null),e([w({value:!1})],nt.prototype,"suspended",null),e([w()],nt.prototype,"textureFadeDuration",null),e([w()],nt.prototype,"visibleElevationBounds",void 0),e([w()],nt.prototype,"rootTileElevationBounds",void 0),e([w()],nt.prototype,"_layerViewsDirty",void 0),e([w()],nt.prototype,"renderPatchBorders",null),e([w()],nt.prototype,"visualizeNormals",null),e([w()],nt.prototype,"renderingDisabled",null),nt=e([E("esri.views.3d.terrain.TerrainSurface")],nt);const lt=nt;function ot(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ht(e){const t=e.children;if(!t[0])return!1;for(const i of t)if(i.shouldLoad)return!0;for(const i of t)if(ht(i))return!0;return!1}function dt(e){return e.isLeaf&&(e.parent?.shouldLoad??!1)}const pt=x(),ut=j(),ct=[0,0,0],_t=new u,gt={spatialReference:null,extent:j(),context:"ground"},mt={spatialReference:null,extent:null,scale:0};function Tt(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 te(t,i,s)}return null}export{lt 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 _,isAborted as g,createAbortError as m}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as f,initial as v}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as E}from"../../../core/accessorSupport/decorators/subclass.js";import{m as S}from"../../../chunks/mat4.js";import{c as L}from"../../../chunks/mat4f64.js";import{i as D}from"../../../chunks/vec3.js";import{c as P}from"../../../chunks/vec3f64.js";import{c as x}from"../../../chunks/vec4f64.js";import{UpdatingHandles as U}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b}from"../../../geometry/ellipsoidUtils.js";import R from"../../../geometry/SpatialReference.js";import{projectPointToVector as C}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as M}from"../../../geometry/projection/projectVectorToVector.js";import{create as j,equals as A,intersection as I,empty as V,expand as B,intersectsSphere as O}from"../../../geometry/support/aaBoundingRect.js";import{create as k,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as q}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as F}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as G}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as W}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as H}from"../../../layers/support/layerUtils.js";import{acquireDecoder as Q}from"../../../layers/support/LercDecoder.js";import{printAllocations as z}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as X}from"../support/cameraUtils.js";import{debugFlags as Y}from"../support/debugFlags.js";import{toBoundingRect as $}from"../support/extentUtils.js";import{ClientType as K}from"../support/index.js";import{updatingProgress as J}from"../support/updatingProperties.js";import{ElevationBounds as Z}from"./ElevationBounds.js";import{ElevationData as ee,sampleElevation as te}from"./ElevationData.js";import{create as ie}from"./ExtentHelper.js";import{LODSnapping as re,TextureUpdate as se}from"./interfaces.js";import{LayerClass as ae,LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as he}from"./RenderOrder.js";import{ScaleRangeQueries as de}from"./ScaleRangeQueries.js";import{SphericalPatch as pe}from"./SphericalPatch.js";import{SplitLimits as ue}from"./SplitLimits.js";import{MAX_ROOT_TILES as ce,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as _e,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ge,MAX_MEMORY_LOD_BIAS as me,ELEVATION_NODATA_VALUE as Te}from"./TerrainConst.js";import{TerrainRenderer as ye,TransparencyMode as fe}from"./TerrainRenderer.js";import ve from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as we,internalAssert as Ee,oppositeEdge as Se,isSurfaceLayerView as Le,isGroupLayerView as De,isMapTileLayerView as Pe,isBlendableLayerView as xe,isElevationLayerView as Ue,isVectorTileLayerView as be,useFetchTileForLayer as Re,isImageryTileLayerView as Ce,isTileLayerView as Me,releaseTileData as je,neighborCornerIndices as Ae,oppositeCorner as Ie,neighborEdgeIndices as Ve,ENABLE_TERRAIN_INTERNAL_CHECKS as Be,ENABLE_WATERPROOFNESS_TESTS as Oe,enableTerrainInternalChecks as ke,enableTerrainWaterproofnessChecks as Ne}from"./terrainUtils.js";import{Tile as qe}from"./Tile.js";import{printAllocations as Fe}from"./TilePerLayerInfo.js";import{TileUpdate as Ge}from"./TileUpdate.js";import{IteratorPreorder as We,IteratorPostorder as He,compareTilesByLij as Qe,hasLoadableSiblings as ze,sortTilesByPOI as Xe,sortTiles as Ye}from"./tileUtils.js";import{TilingSchemeLogic as $e}from"./TilingSchemeLogic.js";import{UpsampleInfo as Ke}from"./UpsampleInfo.js";import{isCompositeBlendMode as Je,blendModeFromString as Ze}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as et}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as tt}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as it}from"../../support/RenderState.js";import{ImmediateTask as rt,TaskPriority as st,noBudget as at}from"../../support/Scheduler.js";let nt=class extends(a.EventedMixin(i)){constructor(e){super(e),this._scaleRangeQueries=new de,this._iteratorPool=new p(We,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new He,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new ve,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=P(),this._eyePosSurfaceSR=P(),this._splitLimits=new ue,this._frustum=k(),this._viewProjectionMatrix=L(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new U,this._frameTask=rt,this._allTiles=new u,this._upsampleInfoPool=new p(Ke),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=j(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=R.WebMercator,this.visibleElevationBounds=new Z(1/0,-1/0),this.rootTileElevationBounds=new Z(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._isWebMercatorOnPlateeCarree=!1,this.overlayManager=new le({...e,surface:this}),this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=Q(this.view.resourceController),this._tilePool=this.view.state.isLocal?new p(oe):new p(pe);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new G(e.newCache("elevation-query")),this._tileTextureCache=new d(((t,i)=>e.newCache(t,i)),"TileTexture"),this._renderer=new ye({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:b(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles,_cache:this._tileTextureCache}),this.addHandles([T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e))),T((()=>this.overlayManager.renderer.isEmpty),(()=>this._evaluateTransparency())),T((()=>this.renderer.visible),(e=>{this.suspended=!e}))],"overlayManager"),this.addHandles([T((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?se.UNFADED:se.IMMEDIATE)}),y),T((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?se.UNFADED:se.IMMEDIATE)),y),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.snapLevel),(()=>this._viewChanged=!0),f),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),T((()=>Y.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&Y.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=h(this._treeDebugger))}),v)]);const{spatialReference:t}=this.view;this._extentHelper=ie(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:t});const i=new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),r=new $e({layers:i,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:t});this._set("tilingSchemeLogic",r),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(K.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(K.BASEMAP);const a=this.view.resourceController.scheduler;this._frameTask=a.registerTask(st.TERRAIN_SURFACE,this),this.addHandles([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),v),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),f),T((()=>this.extent),(()=>this._updateRootTiles()),v),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),v),T((()=>this.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?et.Terrain:et.Disabled),v),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),f)]),this.addHandles(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}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._tilePool=h(this._tilePool),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._tileTextureCache=h(this._tileTextureCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),z(),Fe()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===re.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(t&&i){const r=e.state.contentCamera;let s=X(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?re.ON:re.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const i=j(),r=$(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,j()),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===fe.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(null==s||!s.length)return null;if(0===s[0].layerInfo[ae.ELEVATION].length)return null;const a=pt;if(a[0]=e,a[1]=t,a[2]=i,!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 Tt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[ae.ELEVATION].length:0;if(null!=r&&r.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,Tt(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(!C(e,pt,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(pt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;pt[0]>t[2]&&(i+=1),pt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}getSphereElevationBounds(e,t){if(pt[0]=e[0],pt[1]=e[1],pt[2]=e[2],pt[3]=e[3],!M(pt,t,pt,this.tilingScheme?.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let i=1/0,r=-1/0;const s=e=>{if(e&&O(e.extent,pt))if(e.isLeaf||e.rendered)i=Math.min(i,e.elevationBounds[0]),r=Math.max(r,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{min:i,max:r}}getRootElevationBounds(){return{min:this.rootTileElevationBounds.min,max:this.rootTileElevationBounds.max}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!C(e,pt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;pt[3]=t;let i=null;const r=e=>{if(e&&O(e.extent,pt)){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?fe.Empty:fe.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?fe.Opaque:fe.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;we(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??R.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateeCarree=this._isWebMercator&&q(this.view?.renderSpatialReference),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles())}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return ct[0]=e,ct[1]=t,ct[2]=i,s.init(ct,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=ut;let s=t.rootTilesInExtent(e,i,5*ce);if(null!=this._rootTiles){if(s.length>ce)return void n.getLogger(this).warn(_e);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,ot);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>ot(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>ce&&(n.getLogger(this).warn(ge),s=t.rootTilesInExtent(e,i,ce)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=j(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(Qe);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)===Ge.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Ge.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(Ge.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();e.updateClippingStatus(a)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e),e.setPendingUpdate(Ge.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBounds[0],r),s=Math.max(e.elevationBounds[1],s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._batchUpdatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new Z(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 Z(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?(null==this._splitLimits.frustum&&(this._splitLimits.frustum=k()),N(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,N(this._frustum,e.frustum),S(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),D(this._eyePosRenderSR,t.eye),M(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(ht(e)?this._loadChildren(e):dt(e)&&this._loadParent(e))}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForGeometryUpdate(e){const t=this._pendingTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ge.TEXTURE_FADING)?Ge.TEXTURE_FADING:!!e.resetPendingUpdate(Ge.TEXTURE_NOFADING)&&Ge.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=gt.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),gt.spatialReference=this.spatialReference,this.emit("elevation-change",gt),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._batchUpdatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue")}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();t.reset(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;for(;!t.done;){const e=t.next(),a=e.shouldSplit(r,s,i);if(a!==Ge.SPLIT){if(e.resetPendingUpdate(Ge.SPLIT)&&e.updateAgentSuspension(),a===Ge.ELEVATION&&e.updateAgents(ae.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ge.MERGE),e.resetPendingUpdate(Ge.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);const i=this._viewProjectionMatrix;for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(i);t.remove()}}else e.resetPendingUpdate(Ge.MERGE),e.isLeaf&&(e.setPendingUpdate(Ge.SPLIT),t.skipSubtree()),e.rendered&&e.setPendingUpdate(Ge.RENDERDATA)}t.remove(),this.requestUpdate(),(this.shortBatches||!this.oneBatchPerFrameTask)&&this._batchUpdatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Xe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Ee(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForGeometryUpdate(e))}_batchUpdatePendingTileGeometries(){const e=this._pendingTilesToUpdate;if(0===e.size)return;const t=Array.from(this._pendingTilesToUpdate.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea)),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(Qe);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Ee(r.isLoaded),Ee(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData.cornerPeerNeighbors,o=e=>{const t=Ae[e];i(r,l[e]?.findCorner(Ie(t),(e=>e.isLoaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.neighborData.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Se(Ve[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(Ee(e.has(t)||Qe(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,Be&&Oe&&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.resetPendingUpdate(Ge.MERGE)){if(!t)return s.setPendingUpdate(Ge.MERGE),e.done;for(;n.parent?.resetPendingUpdate(Ge.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else s.resetPendingUpdate(Ge.SPLIT)&&(this._splitTile(s),a=!0,e.madeProgress());return!e.done&&n===s&&s.resetPendingUpdate(Ge.RENDERDATA)&&(this._updateRenderData(s),e.madeProgress()),e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Ge.GEOMETRY)&&(this._updateTileGeometryState(t),this._updateTileTexture(t,e),this.shortBatches&&this._batchUpdatePendingTileGeometries(),e.madeProgress()),e.done))),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(tt.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*me}_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!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i])||t;return e.unsetChildren(),t}_purgeTile(e){const t=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),this._tilePool.release(e),t}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){we(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ge.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){mt.spatialReference=this.spatialReference,mt.extent=e.extent,mt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",mt)}_createTile(e,t,i,r){we(!!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(Ge.SPLIT),s}get shortBatches(){return this.view.state.mode!==it.IDLE}_mergeTile(e){we(!e.hasPendingUpdate(Ge.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(we(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this.shortBatches&&this._batchUpdatePendingTileGeometries()),this._allTilesDirty=!0,++this._performanceInfo.numMerged}_loadChildren(e){we(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForGeometryUpdate(e),this._emitTileScaleChange(e,e.level+1),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._markTileToUpdate(t),this._emitTileScaleChange(t,t.level),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_unloadChildren(e){const t=e.children;if(t[0])for(let i=0;i<4;++i){const e=t[i];this._unloadChildren(e),this._unloadTile(e)}}_loadTile(e){e.load(),e.setPendingUpdate(Ge.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new ee(e.lij,e.extent,i);e.dataArrived(t,ae.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=at){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),Le(s)||De(s))if(this._basemapLayerViewHandles.has(s.uid)&&!De(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);null!=i&&((i<r||null==r)&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.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(Pe(t)&&!H(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((xe(e)||De(e))&&Je(Ze[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Ue(e)?ae.ELEVATION:ae.MAP}_registerTiledLayerView(e){const t=[];if((xe(e)||De(e))&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(se.UNFADED)}))),!De(e)){const i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(se.UNFADED)))),t.push(T((()=>"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||!Le(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===ae.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ne){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===ae.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(ae.MAP),e===se.IMMEDIATE?this.renderer.updateTileTexture(t,Ge.TEXTURE_NOFADING):t.updateRenderData(ae.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=tt.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||be(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),_(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===ae.ELEVATION?Ue(i)?this._requestElevationTileData(e,i,r):Promise.reject():Pe(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(g(i))return;const s=this._layerIndexByUid[ae.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",ae.ELEVATION,e.lij.toString())},s=i=>{_(i)||(this._dataMissing(e,ae.ELEVATION,t,i),this.requestUpdate())};if(Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:Te,signal:i.signal}).then((e=>{if(!g(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:Te},i.signal))).then((e=>{e?r(new W(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,je(s),g(i)||(this._dataMissing(e,ae.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),g(i)?je(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),l=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(be(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,l)}if(Ce(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,l);if(Me(t)&&Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(g(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]);F(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(ae.MAP,t.uid);null!=r?e.dataArrived(r,ae.MAP,i):(je(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=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this._rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return we(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(){_t.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&_t.push(e)}));const t=_t.toArray();return Ye(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!Oe)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 isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateeCarree(){return this._isWebMercatorOnPlateeCarree}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(null!=this.spatialReference&&this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){ke(e)}enableWaterproofnessChecks(e){Ne(e)}};e([w()],nt.prototype,"_renderer",void 0),e([w({constructOnly:!0})],nt.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],nt.prototype,"view",void 0),e([w({constructOnly:!0})],nt.prototype,"overlayManager",void 0),e([w()],nt.prototype,"_hasPendingUpdates",void 0),e([w()],nt.prototype,"_asyncWorkItems",void 0),e([w()],nt.prototype,"_allTilesDirty",void 0),e([w()],nt.prototype,"_allTilesSorted",void 0),e([w()],nt.prototype,"_viewChanged",void 0),e([w()],nt.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],nt.prototype,"_watchUpdatingTracking",void 0),e([w()],nt.prototype,"_frameTask",void 0),e([w({readOnly:!0})],nt.prototype,"snapLevel",null),e([w({readOnly:!0})],nt.prototype,"lodSnapping",null),e([w()],nt.prototype,"_userClippingExtent",null),e([w()],nt.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],nt.prototype,"extent",null),e([w({readOnly:!0})],nt.prototype,"groundExtent",null),e([w({readOnly:!0})],nt.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],nt.prototype,"updating",null),e([w({readOnly:!0})],nt.prototype,"running",null),e([w(J)],nt.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],nt.prototype,"updatingProgressValue",null),e([w()],nt.prototype,"_maxNumUpdating",void 0),e([w()],nt.prototype,"baseOpacity",null),e([w()],nt.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],nt.prototype,"viewingMode",null),e([w()],nt.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],nt.prototype,"ready",null),e([w({value:he.FRONT_TO_BACK})],nt.prototype,"renderOrder",null),e([w({readOnly:!0})],nt.prototype,"rootTiles",null),e([w()],nt.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],nt.prototype,"spatialReference",null),e([w({type:t})],nt.prototype,"backgroundColor",null),e([w({value:!1})],nt.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],nt.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],nt.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],nt.prototype,"tilingSchemeLogic",void 0),e([w()],nt.prototype,"wireframe",null),e([w({value:!1})],nt.prototype,"suspended",null),e([w()],nt.prototype,"textureFadeDuration",null),e([w()],nt.prototype,"visibleElevationBounds",void 0),e([w()],nt.prototype,"rootTileElevationBounds",void 0),e([w()],nt.prototype,"_layerViewsDirty",void 0),e([w()],nt.prototype,"renderPatchBorders",null),e([w()],nt.prototype,"visualizeNormals",null),e([w()],nt.prototype,"renderingDisabled",null),nt=e([E("esri.views.3d.terrain.TerrainSurface")],nt);const lt=nt;function ot(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ht(e){const t=e.children;if(!t[0])return!1;for(const i of t)if(i.shouldLoad)return!0;for(const i of t)if(ht(i))return!0;return!1}function dt(e){return e.isLeaf&&(e.parent?.shouldLoad??!1)}const pt=x(),ut=j(),ct=[0,0,0],_t=new u,gt={spatialReference:null,extent:j(),context:"ground"},mt={spatialReference:null,extent:null,scale:0};function Tt(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 te(t,i,s)}return null}export{lt 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as s}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/Logger.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/Error.js";import{subclass as e}from"../../../../../core/accessorSupport/decorators/subclass.js";import{f as t,t as r,e as a}from"../../../../../chunks/mat3.js";import{c as i}from"../../../../../chunks/mat3f64.js";import{c as h}from"../../../../../chunks/mat4.js";import{s as o,i as n}from"../../../../../chunks/vec3.js";import{c as m}from"../../../../../chunks/vec3f64.js";import{MaterialPassParameters as l,ShadowMapPassParameters as c,HighlightPassParameters as p,RenderPassIdentifier as u}from"./AllRenderPasses.js";import{RenderPass as d,RenderPassSorting as _}from"./RenderPass.js";import{ShaderOutput as g}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as P}from"../util/TwoVectorPosition.js";import{SyncPreparesRenderPlugin as w}from"../../effects/RenderPlugin.js";import{DepthRange as f,union as R}from"../../lib/depthRange.js";import{RenderSlot as A}from"../../lib/RenderSlot.js";let T=class extends w{get renderSlots(){return[A.OPAQUE_MATERIAL,A.TRANSPARENT_MATERIAL,A.INTEGRATED_MESH]}constructor(){super({}),this._passes=null,this._materialPassParameters=new l,this._shadowPassParameters=new c,this._highlightPassParameters=new p,this._systems=new Set}initializeRenderContext(s){this._context=s;const e=s.renderContext.rctx,t=s.techniqueRepository;this._passes={materialOpaque:new d(e,t),materialTransparent:new d(e,t,_.BackToFront),materialIntegratedMesh:new d(e,t),shadowMap:new d(e,t),highlight:new d(e,t),highlightIntegratedMesh:new d(e,t),highlightShadowMap:new d(e,t),defaultShadowMap:new d(e,t)}}get rctx(){return this._context.renderContext.rctx}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.clear()}register(s){this._systems.add(s)}canRender(s,e){return 0!==this._systems.size&&null!==this._passes&&(e===g.Highlight?this._passes.highlight.count>0||this._passes.highlightIntegratedMesh.count>0:e===g.ShadowHighlight?this._passes.highlight.count>0:s!==A.TRANSPARENT_MATERIAL||this._passes.materialTransparent.count>0)}prepareRender(s){if(0!==this._systems.size&&null!==this._passes){for(const s of Object.values(this._passes))s.prepareSubmit();this._systems.forEach((e=>e.submit(this._passes,s.bindParameters)));for(const s of Object.values(this._passes))s.finishSubmit();this._context.techniqueRepository.frameUpdate()}}prepareTechniques(s){return 0===this._systems.size?null:(this._configure(s),this._materialPassParameters.output=s.output,this._invoke(s,((e,t)=>e.prepare(t,s.bindParameters))))}render(s,e){this._invoke(s,((t,r)=>t.dispatch(r,s.bindParameters,e)))}_invoke(s,e){if(null===this._passes)return null;switch(s.bindParameters.slot){case A.OPAQUE_MATERIAL:switch(s.output){case g.Color:case g.Depth:case g.Normal:case g.ObjectAndLayerIdColor:return e(this._passes.materialOpaque,this._materialPassParameters);case g.Highlight:return e(this._passes.highlight,this._highlightPassParameters);case g.Shadow:return e(this._passes.shadowMap,this._shadowPassParameters);case g.ShadowHighlight:return e(this._passes.highlightShadowMap,this._shadowPassParameters);case g.ShadowExcludeHighlight:return e(this._passes.defaultShadowMap,this._shadowPassParameters)}break;case A.TRANSPARENT_MATERIAL:switch(s.output){case g.Color:case g.Alpha:case g.Depth:case g.Normal:case g.ObjectAndLayerIdColor:return e(this._passes.materialTransparent,this._materialPassParameters)}break;case A.INTEGRATED_MESH:switch(s.output){case g.Color:case g.Depth:case g.Normal:case g.ObjectAndLayerIdColor:return e(this._passes.materialIntegratedMesh,this._materialPassParameters);case g.Highlight:return e(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}}return null}notifyDirty(){this._context.requestRender()}queryDepthRange(s){const e=new f;return this._systems.forEach((t=>R(e,t.queryShadowCasterDepthRange(s)))),e}_configure(s){const e=s.output===g.Shadow||s.output===g.ShadowHighlight||s.output===g.ShadowExcludeHighlight?this._shadowPassParameters:s.output===g.Highlight?this._highlightPassParameters:this._materialPassParameters;this._updateParameters(s,e)}_updateParameters(s,e){const i=s.bindParameters.camera,m=i.viewInverseTransposeMatrix;o(S,m[3],m[7],m[11]),E.set(S),n(e.transformWorldFromViewTH,E.high),n(e.transformWorldFromViewTL,E.low),n(e.slicePlaneLocalOrigin,S),t(e.transformViewFromCameraRelativeRS,i.viewMatrix),h(e.transformProjFromView,i.projectionMatrix),e.identifier===u.Material&&(this._materialPassParameters.transparent=s.bindParameters.slot===A.TRANSPARENT_MATERIAL,this._materialPassParameters.integratedMesh=s.bindParameters.slot===A.INTEGRATED_MESH,r(j,e.transformViewFromCameraRelativeRS),a(e.transformNormalViewFromGlobal,j))}};T=s([e("esri.views.3d.webgl-engine.core.renderPasses.RenderPassManager")],T);const S=m(),j=i(),E=new P;export{T as RenderPassManager};
5
+ import{_ as s}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/Logger.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/Error.js";import{subclass as e}from"../../../../../core/accessorSupport/decorators/subclass.js";import{f as t,t as r,e as a}from"../../../../../chunks/mat3.js";import{c as i}from"../../../../../chunks/mat3f64.js";import{c as h}from"../../../../../chunks/mat4.js";import{s as o,i as n}from"../../../../../chunks/vec3.js";import{c as m}from"../../../../../chunks/vec3f64.js";import{MaterialPassParameters as l,ShadowMapPassParameters as c,HighlightPassParameters as p,RenderPassIdentifier as u}from"./AllRenderPasses.js";import{RenderPass as d,RenderPassSorting as _}from"./RenderPass.js";import{ShaderOutput as g}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as P}from"../util/TwoVectorPosition.js";import{SyncPreparesRenderPlugin as w}from"../../effects/RenderPlugin.js";import{DepthRange as f,union as R}from"../../lib/depthRange.js";import{RenderSlot as A}from"../../lib/RenderSlot.js";let T=class extends w{get renderSlots(){return[A.OPAQUE_MATERIAL,A.TRANSPARENT_MATERIAL,A.INTEGRATED_MESH]}constructor(){super({}),this._passes=null,this._materialPassParameters=new l,this._shadowPassParameters=new c,this._highlightPassParameters=new p,this._systems=new Set}initializeRenderContext(s){this._context=s;const e=s.renderContext.rctx,t=s.techniqueRepository;this._passes={materialOpaque:new d(e,t),materialTransparent:new d(e,t,_.BackToFront),materialIntegratedMesh:new d(e,t),shadowMap:new d(e,t),highlight:new d(e,t),highlightIntegratedMesh:new d(e,t),highlightShadowMap:new d(e,t),defaultShadowMap:new d(e,t)}}get rctx(){return this._context.renderContext.rctx}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.clear()}register(s){this._systems.add(s)}produces(s,e){return 0!==this._systems.size&&null!==this._passes&&(e===g.Highlight?this._passes.highlight.count>0||this._passes.highlightIntegratedMesh.count>0:e===g.ShadowHighlight?this._passes.highlight.count>0:s!==A.TRANSPARENT_MATERIAL||this._passes.materialTransparent.count>0)}prepareRender(s){if(0!==this._systems.size&&null!==this._passes){for(const s of Object.values(this._passes))s.prepareSubmit();this._systems.forEach((e=>e.submit(this._passes,s.bindParameters)));for(const s of Object.values(this._passes))s.finishSubmit();this._context.techniqueRepository.frameUpdate()}}prepareTechniques(s){return 0===this._systems.size?null:(this._configure(s),this._materialPassParameters.output=s.output,this._invoke(s,((e,t)=>e.prepare(t,s.bindParameters))))}render(s,e){this._invoke(s,((t,r)=>t.dispatch(r,s.bindParameters,e)))}_invoke(s,e){if(null===this._passes)return null;switch(s.bindParameters.slot){case A.OPAQUE_MATERIAL:switch(s.output){case g.Color:case g.Depth:case g.Normal:case g.ObjectAndLayerIdColor:return e(this._passes.materialOpaque,this._materialPassParameters);case g.Highlight:return e(this._passes.highlight,this._highlightPassParameters);case g.Shadow:return e(this._passes.shadowMap,this._shadowPassParameters);case g.ShadowHighlight:return e(this._passes.highlightShadowMap,this._shadowPassParameters);case g.ShadowExcludeHighlight:return e(this._passes.defaultShadowMap,this._shadowPassParameters)}break;case A.TRANSPARENT_MATERIAL:switch(s.output){case g.Color:case g.Alpha:case g.Depth:case g.Normal:case g.ObjectAndLayerIdColor:return e(this._passes.materialTransparent,this._materialPassParameters)}break;case A.INTEGRATED_MESH:switch(s.output){case g.Color:case g.Depth:case g.Normal:case g.ObjectAndLayerIdColor:return e(this._passes.materialIntegratedMesh,this._materialPassParameters);case g.Highlight:return e(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}}return null}notifyDirty(){this._context.requestRender()}queryDepthRange(s){const e=new f;return this._systems.forEach((t=>R(e,t.queryShadowCasterDepthRange(s)))),e}_configure(s){const e=s.output===g.Shadow||s.output===g.ShadowHighlight||s.output===g.ShadowExcludeHighlight?this._shadowPassParameters:s.output===g.Highlight?this._highlightPassParameters:this._materialPassParameters;this._updateParameters(s,e)}_updateParameters(s,e){const i=s.bindParameters.camera,m=i.viewInverseTransposeMatrix;o(S,m[3],m[7],m[11]),E.set(S),n(e.transformWorldFromViewTH,E.high),n(e.transformWorldFromViewTL,E.low),n(e.slicePlaneLocalOrigin,S),t(e.transformViewFromCameraRelativeRS,i.viewMatrix),h(e.transformProjFromView,i.projectionMatrix),e.identifier===u.Material&&(this._materialPassParameters.transparent=s.bindParameters.slot===A.TRANSPARENT_MATERIAL,this._materialPassParameters.integratedMesh=s.bindParameters.slot===A.INTEGRATED_MESH,r(j,e.transformViewFromCameraRelativeRS),a(e.transformNormalViewFromGlobal,j))}};T=s([e("esri.views.3d.webgl-engine.core.renderPasses.RenderPassManager")],T);const S=m(),j=i(),E=new P;export{T as RenderPassManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Accessor.js";class s extends e{requires(e){return!1}get usedMemory(){return 0}get isDecoration(){return!1}get running(){return!1}}class r extends s{}class t extends s{}class n extends s{}class c extends s{}class o extends s{}export{o as ASyncPreparesRenderPlugin,c as AsyncRenderPlugin,t as SyncPrepareRenderPlugin,n as SyncPreparesRenderPlugin,r as SyncRenderPlugin};
5
+ import e from"../../../../core/Accessor.js";class s extends e{consumes(e){return!1}get usedMemory(){return 0}get isDecoration(){return!1}get running(){return!1}}class r extends s{}class t extends s{}class n extends s{}class c extends s{}class o extends s{}export{o as ASyncPreparesRenderPlugin,c as AsyncRenderPlugin,t as SyncPrepareRenderPlugin,n as SyncPreparesRenderPlugin,r as SyncRenderPlugin};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/PooledArray.js";import{isPromiseLike as n,createAbortError as s}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{ShaderOutput as l}from"../core/shaderLibrary/ShaderOutput.js";import{Decorations as a}from"../lib/basicInterfaces.js";import{DepthRange as u,union as d}from"../lib/depthRange.js";import{RenderOccludedFlag as c}from"../lib/Material.js";import{RenderSlot as p}from"../lib/RenderSlot.js";let h=class extends r{constructor(e){super({}),this._context=e,this._renderPlugins=new t,this._slots=new Array;for(let r=0;r<p.MAX_SLOTS;++r)this._slots[r]=[]}normalizeCtorArgs(){return{}}add(e,r){const t=()=>{if(r?.aborted)throw e.uninitializeRenderContext(),s();this._renderPlugins.push(e);for(const r of e.renderSlots)this._slots[r].push(e);this._context.requestRender(),this.notifyChange("updating")},o=e.initializeRenderContext(this._context,r);if(n(o))return o.then(t);t()}remove(e){if(null!=this._renderPlugins.removeUnordered(e)){for(let r=0;r<this._slots.length;++r)this._slots[r]=this._slots[r].filter((r=>r!==e));e.uninitializeRenderContext(),this._context.requestRender(),this.notifyChange("updating")}}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this._context.renderContext)}))}updateAnimation(e){let r=!1;return this._renderPlugins.forAll((t=>{t.updateAnimation&&(r=t.updateAnimation(e)||r)})),r}renderFeatureChanged(){this._renderPlugins.forAll((e=>{e.renderFeatureChanged&&e.renderFeatureChanged()}))}prepareSlots(e){for(const r of e)this._context.renderContext.bindParameters.slot=r,this._slots[r].filter((e=>{e.canRender(r,l.Color)&&(m(e)&&e.prepareTechnique(this._context.renderContext),g(e)&&e.prepareTechniques(this._context.renderContext))}))}prepare(e){this._context.renderContext.bindParameters.slot=e;const r=this._slots[e],t=new Map;return r.forEach((r=>{if(r.canRender(e,l.Color)&&(!r.isDecoration||this._context.renderContext.bindParameters.decorations!==a.OFF))if(m(r)){const e=r.prepareTechnique(this._context.renderContext);null!=e&&t.set(r,e)}else if(g(r)){const e=r.prepareTechniques(this._context.renderContext);null!=e&&t.set(r,e)}else t.set(r,null)})),t}render(e,r=null,t=null){let n;return e.forEach(((e,s)=>{n=s.render(this._context.renderContext,e,r,t)})),n}queryDepthRange(e){const r=new u;return this._renderPlugins.forAll((t=>{const n=t.queryDepthRange&&t.queryDepthRange(e);d(r,n)})),r}get updating(){return this._renderPlugins.some((e=>e.running))}canRender(e,r=l.Color){return this._slots[e].some((t=>t.canRender(e,r)))}requires(e){return this._renderPlugins.some((r=>r.requires(e)))}get hasDecorations(){return this._renderPlugins.some((e=>e.isDecoration))}get renderOccludedFlags(){return this._renderPlugins.reduce(((e,r)=>e|r.renderOccludedFlags),c.None)}get usedMemory(){return this._renderPlugins.reduce(((e,r)=>e+(r.usedMemory??0)),0)}};function m(e){return"prepareTechnique"in e}function g(e){return"prepareTechniques"in e}e([o({readOnly:!0})],h.prototype,"updating",null),h=e([i("esri.views.3d.webgl-engine.lib.RenderPluginManager")],h);export{h as RenderPluginManager};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/PooledArray.js";import{isPromiseLike as n,createAbortError as s}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{ShaderOutput as l}from"../core/shaderLibrary/ShaderOutput.js";import{Decorations as u}from"../lib/basicInterfaces.js";import{DepthRange as d,union as a}from"../lib/depthRange.js";import{RenderOccludedFlag as c}from"../lib/Material.js";import{RenderSlot as p}from"../lib/RenderSlot.js";let h=class extends r{constructor(e){super({}),this._context=e,this._renderPlugins=new t,this._slots=new Array;for(let r=0;r<p.MAX_SLOTS;++r)this._slots[r]=[]}normalizeCtorArgs(){return{}}add(e,r){const t=()=>{if(r?.aborted)throw e.uninitializeRenderContext(),s();this._renderPlugins.push(e);for(const r of e.renderSlots)this._slots[r].push(e);this._context.requestRender(),this.notifyChange("updating")},o=e.initializeRenderContext(this._context,r);if(n(o))return o.then(t);t()}remove(e){if(null!=this._renderPlugins.removeUnordered(e)){for(let r=0;r<this._slots.length;++r)this._slots[r]=this._slots[r].filter((r=>r!==e));e.uninitializeRenderContext(),this._context.requestRender(),this.notifyChange("updating")}}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this._context.renderContext)}))}updateAnimation(e){let r=!1;return this._renderPlugins.forAll((t=>{t.updateAnimation&&(r=t.updateAnimation(e)||r)})),r}renderFeatureChanged(){this._renderPlugins.forAll((e=>{e.renderFeatureChanged&&e.renderFeatureChanged()}))}prepareSlots(e){for(const r of e)this._context.renderContext.bindParameters.slot=r,this._slots[r].filter((e=>{e.produces(r,l.Color)&&(m(e)&&e.prepareTechnique(this._context.renderContext),g(e)&&e.prepareTechniques(this._context.renderContext))}))}prepare(e){this._context.renderContext.bindParameters.slot=e;const r=this._slots[e],t=new Map;return r.forEach((r=>{if(r.produces(e,l.Color)&&(!r.isDecoration||this._context.renderContext.bindParameters.decorations!==u.OFF))if(m(r)){const e=r.prepareTechnique(this._context.renderContext);null!=e&&t.set(r,e)}else if(g(r)){const e=r.prepareTechniques(this._context.renderContext);null!=e&&t.set(r,e)}else t.set(r,null)})),t}render(e,r=null,t=null){let n;return e.forEach(((e,s)=>{n=s.render(this._context.renderContext,e,r,t)})),n}queryDepthRange(e){const r=new d;return this._renderPlugins.forAll((t=>{const n=t.queryDepthRange&&t.queryDepthRange(e);a(r,n)})),r}get updating(){return this._renderPlugins.some((e=>e.running))}produces(e,r=l.Color){return this._slots[e].some((t=>t.produces(e,r)))}consumes(e){return this._renderPlugins.some((r=>r.consumes(e)))}get hasDecorations(){return this._renderPlugins.some((e=>e.isDecoration))}get renderOccludedFlags(){return this._renderPlugins.reduce(((e,r)=>e|r.renderOccludedFlags),c.None)}get usedMemory(){return this._renderPlugins.reduce(((e,r)=>e+(r.usedMemory??0)),0)}};function m(e){return"prepareTechnique"in e}function g(e){return"prepareTechniques"in e}e([o({readOnly:!0})],h.prototype,"updating",null),h=e([i("esri.views.3d.webgl-engine.lib.RenderPluginManager")],h);export{h as RenderPluginManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import{releaseMaybe as r,disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as s,syncAndInitial as o}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{s as l}from"../../../../../chunks/vec2.js";import{ColorFormat as n}from"../../core/FBOCache.js";import{ShaderOutput as c}from"../../core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as u}from"../RenderPlugin.js";import{HighlightApplyTechnique as p}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as m}from"./HighlightBlurTechnique.js";import{defaultColor as _,defaultHaloOpacity as d,defaultFillOpacity as g}from"./HighlightDefaults.js";import{HighlightDownsampleTechnique as b}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as f}from"./HighlightPassParameters.js";import{Default3D as w}from"../../lib/DefaultVertexAttributeLocations.js";import{Pos2Tex as T}from"../../lib/DefaultVertexBufferLayouts.js";import{RenderSlot as x}from"../../lib/RenderSlot.js";import{VertexArrayObject as q}from"../../lib/VertexArrayObject.js";import{H as v}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as P}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as y}from"../../../../webgl/BufferObject.js";import{ClearBufferBit as j,Usage as C}from"../../../../webgl/enums.js";import{vertexCount as O}from"../../../../webgl/Util.js";const R=32,D=Math.ceil(Math.log2(R));let H=class extends u{constructor(e){super(e),this.renderSlots=[x.HIGHLIGHT],this._context=null,this._passParameters=new f,this._downsampleDrawParameters=new P,this._blurDrawParameters=new v,this._grid={coverage:null,vao:null,verticalCellCount:0,horizontalCellCount:0,viewportWidth:0,viewportHeight:0}}canRender(){return!0}requires(e){return e===c.Highlight}initializeRenderContext(e){this._context=e,null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(m)),null==this._downsampleTechnique&&(this._downsampleTechnique=this._context.techniqueRepository.acquire(b)),null==this._applyTechnique&&(this._applyTechnique=this._context.techniqueRepository.acquire(p)),this.addHandles([s((()=>this.view.highlightOptions.color),(e=>{this._passParameters.color=t(e??_),this.view.highlightOptions.haloColor||(this._passParameters.haloColor=this._passParameters.color),this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloColor),(e=>{this._passParameters.haloColor=null!=e?t(e):this._passParameters.color,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloOpacity),(e=>{this._passParameters.haloOpacity=e??d,this._passParameters.haloOpacityOccluded=.25*this._passParameters.haloOpacity,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.fillOpacity),(e=>{this._passParameters.fillOpacity=e??g,this._passParameters.fillOpacityOccluded=.25*this._passParameters.fillOpacity,this._context.requestRender()}),o)])}uninitializeRenderContext(){this._context=null}dispose(){this._blurTechnique=r(this._blurTechnique),this._downsampleTechnique=r(this._downsampleTechnique),this._applyTechnique=r(this._applyTechnique),this._grid.coverage=r(this._grid.coverage),this._grid.vao=i(this._grid.vao)}render(e,t,r,i){const s=r?.highlightTexture;if(!this._context||!s)return;if(!(this._blurTechnique.compiled&&this._downsampleTechnique.compiled&&this._applyTechnique.compiled))return void this._context.requestRender();const o=e.bindParameters.camera,a=o.fullWidth,h=o.fullHeight,c=o.pixelRatio,u=Math.ceil(a/c),p=Math.ceil(h/c),m=this._context.fbos.rctx,_=this._context.fbos;this._gridUpdateResources(s),this._gridComputeCoverage(s,e.bindParameters),this._passParameters.highlightTexture=s,this._passParameters.coverageTexture=this._grid.coverage?.colorTexture;const d=m.bindTechnique(this._blurTechnique,this._passParameters,e.bindParameters),g=this._grid.vao;m.bindVAO(g);const b=_.acquire(n.RGBA4,u,p);m.bindFramebuffer(b.fbo),m.setViewport(0,0,u,p),m.setClearColor(0,0,0,0),m.clear(j.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=s,l(this._blurDrawParameters.blurSize,1/u,0),d.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),m.drawArrays(this._blurTechnique.primitiveType,0,O(g,"geometry"));const f=_.acquire(n.RGBA4,u,p);m.bindFramebuffer(f.fbo),m.clear(j.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=b.colorTexture,l(this._blurDrawParameters.blurSize,0,1/p),d.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),m.drawArrays(this._blurTechnique.primitiveType,0,O(g,"geometry")),m.bindFramebuffer(i),m.setViewport4fv(o.fullViewport),this._passParameters.blurTexture=f.colorTexture,m.bindTechnique(this._applyTechnique,this._passParameters,e.bindParameters),m.drawArrays(this._applyTechnique.primitiveType,0,O(g,"geometry")),f.release(),b.release()}_gridUpdateResources(e){if(!this._context)return;const t=this._context.fbos.rctx,r=this._grid,s=Math.ceil(e.descriptor.height/R),o=Math.ceil(e.descriptor.width/R);if(!r.vao||r.verticalCellCount!==s||r.horizontalCellCount!==o){r.verticalCellCount=s,r.horizontalCellCount=o;const e=s+1,a=o+1,h=1/s,l=1/o,n=6,c=4,u=new Float32Array(n*c*e*a);let p=0;for(let t=0;t<e;t++)for(let e=0;e<a;e++)u[p]=(e-.5)*l*2-1,u[p+1]=(t-.5)*h*2-1,u[p+2]=e*l,u[p+3]=t*h,u[p+4]=(e+.5)*l*2-1,u[p+5]=(t-.5)*h*2-1,u[p+6]=e*l,u[p+7]=t*h,u[p+8]=(e-.5)*l*2-1,u[p+9]=(t+.5)*h*2-1,u[p+10]=e*l,u[p+11]=t*h,u[p+12]=(e-.5)*l*2-1,u[p+13]=(t+.5)*h*2-1,u[p+14]=e*l,u[p+15]=t*h,u[p+16]=(e+.5)*l*2-1,u[p+17]=(t-.5)*h*2-1,u[p+18]=e*l,u[p+19]=t*h,u[p+20]=(e+.5)*l*2-1,u[p+21]=(t+.5)*h*2-1,u[p+22]=e*l,u[p+23]=t*h,p+=n*c;r.vao=i(r.vao),r.vao=new q(t,w,{geometry:T},{geometry:y.createVertex(t,C.STATIC_DRAW,u)})}}_gridComputeCoverage(e,t){if(!this._context)return;const r=this._context.fbos.rctx,i=this._grid;i.coverage?.release();const s=r.bindTechnique(this._downsampleTechnique,this._passParameters,t);let o;for(let a=0;a<D;++a){const i=e.descriptor,a=this._context.fbos.acquire(n.RG,Math.ceil(i.width/2),Math.ceil(i.height/2));r.bindFramebuffer(a.fbo);const{width:h,height:c}=a.colorTexture.descriptor;l(this._downsampleDrawParameters.invFramebufferDim,1/h,1/c),this._downsampleDrawParameters.inputTexture=e,s.bindDraw(this._downsampleDrawParameters,t,this._passParameters),r.setViewport(0,0,h,c),r.screen.draw(),o?.release(),o=a,e=a.colorTexture}i.coverage=o}get test(){return{coverage:this._grid.coverage}}};e([a()],H.prototype,"_context",void 0),e([a()],H.prototype,"view",void 0),H=e([h("esri.views.3d.webgl-engine.lib.Highlight")],H);export{H as Highlight};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import{releaseMaybe as r,disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as s,syncAndInitial as o}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{s as l}from"../../../../../chunks/vec2.js";import{ColorFormat as n}from"../../core/FBOCache.js";import{ShaderOutput as c}from"../../core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as p}from"../RenderPlugin.js";import{HighlightApplyTechnique as u}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as m}from"./HighlightBlurTechnique.js";import{defaultColor as _,defaultHaloOpacity as d,defaultFillOpacity as g}from"./HighlightDefaults.js";import{HighlightDownsampleTechnique as b}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as f}from"./HighlightPassParameters.js";import{Default3D as w}from"../../lib/DefaultVertexAttributeLocations.js";import{Pos2Tex as T}from"../../lib/DefaultVertexBufferLayouts.js";import{RenderSlot as q}from"../../lib/RenderSlot.js";import{VertexArrayObject as v}from"../../lib/VertexArrayObject.js";import{H as x}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as y,G as P}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as j}from"../../../../webgl/BufferObject.js";import{ClearBufferBit as C,Usage as O}from"../../../../webgl/enums.js";import{vertexCount as R}from"../../../../webgl/Util.js";let D=class extends p{constructor(e){super(e),this.renderSlots=[q.HIGHLIGHT],this._context=null,this._passParameters=new f,this._downsampleDrawParameters=new y,this._blurDrawParameters=new x,this._grid={coverage:null,vao:null,verticalCellCount:0,horizontalCellCount:0,viewportWidth:0,viewportHeight:0}}produces(){return!0}consumes(e){return e===c.Highlight}initializeRenderContext(e){this._context=e,null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(m)),null==this._downsampleTechnique&&(this._downsampleTechnique=this._context.techniqueRepository.acquire(b)),null==this._applyTechnique&&(this._applyTechnique=this._context.techniqueRepository.acquire(u)),this.addHandles([s((()=>this.view.highlightOptions.color),(e=>{this._passParameters.color=t(e??_),this.view.highlightOptions.haloColor||(this._passParameters.haloColor=this._passParameters.color),this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloColor),(e=>{this._passParameters.haloColor=null!=e?t(e):this._passParameters.color,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloOpacity),(e=>{this._passParameters.haloOpacity=e??d,this._passParameters.haloOpacityOccluded=.25*this._passParameters.haloOpacity,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.fillOpacity),(e=>{this._passParameters.fillOpacity=e??g,this._passParameters.fillOpacityOccluded=.25*this._passParameters.fillOpacity,this._context.requestRender()}),o)])}uninitializeRenderContext(){this._context=null}dispose(){this._blurTechnique=r(this._blurTechnique),this._downsampleTechnique=r(this._downsampleTechnique),this._applyTechnique=r(this._applyTechnique),this._grid.coverage=r(this._grid.coverage),this._grid.vao=i(this._grid.vao)}render(e,t,r,i){const s=r?.highlightTexture;if(!this._context||!s)return;if(!(this._blurTechnique.compiled&&this._downsampleTechnique.compiled&&this._applyTechnique.compiled))return void this._context.requestRender();const o=e.bindParameters.camera,a=o.fullWidth,h=o.fullHeight,c=o.pixelRatio,p=Math.ceil(a/c),u=Math.ceil(h/c),m=this._context.fbos.rctx,_=this._context.fbos;this._gridUpdateResources(s),this._gridComputeCoverage(s,e.bindParameters),this._passParameters.highlightTexture=s,this._passParameters.coverageTexture=this._grid.coverage?.colorTexture;const d=m.bindTechnique(this._blurTechnique,this._passParameters,e.bindParameters),g=this._grid.vao;m.bindVAO(g);const b=_.acquire(n.RGBA4,p,u);m.bindFramebuffer(b.fbo),m.setViewport(0,0,p,u),m.setClearColor(0,0,0,0),m.clear(C.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=s,l(this._blurDrawParameters.blurSize,1/p,0),d.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),m.drawArrays(this._blurTechnique.primitiveType,0,R(g,"geometry"));const f=_.acquire(n.RGBA4,p,u);m.bindFramebuffer(f.fbo),m.clear(C.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=b.colorTexture,l(this._blurDrawParameters.blurSize,0,1/u),d.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),m.drawArrays(this._blurTechnique.primitiveType,0,R(g,"geometry")),m.bindFramebuffer(i),m.setViewport4fv(o.fullViewport),this._passParameters.blurTexture=f.colorTexture,m.bindTechnique(this._applyTechnique,this._passParameters,e.bindParameters),m.drawArrays(this._applyTechnique.primitiveType,0,R(g,"geometry")),f.release(),b.release()}_gridUpdateResources(e){if(!this._context)return;const t=this._context.fbos.rctx,r=this._grid,s=Math.ceil(e.descriptor.height/P),o=Math.ceil(e.descriptor.width/P);if(!r.vao||r.verticalCellCount!==s||r.horizontalCellCount!==o){r.verticalCellCount=s,r.horizontalCellCount=o;const e=s+1,a=o+1,h=1/s,l=1/o,n=6,c=4,p=new Float32Array(n*c*e*a);let u=0;for(let t=0;t<e;t++)for(let e=0;e<a;e++)p[u]=(e-.5)*l*2-1,p[u+1]=(t-.5)*h*2-1,p[u+2]=e*l,p[u+3]=t*h,p[u+4]=(e+.5)*l*2-1,p[u+5]=(t-.5)*h*2-1,p[u+6]=e*l,p[u+7]=t*h,p[u+8]=(e-.5)*l*2-1,p[u+9]=(t+.5)*h*2-1,p[u+10]=e*l,p[u+11]=t*h,p[u+12]=(e-.5)*l*2-1,p[u+13]=(t+.5)*h*2-1,p[u+14]=e*l,p[u+15]=t*h,p[u+16]=(e+.5)*l*2-1,p[u+17]=(t-.5)*h*2-1,p[u+18]=e*l,p[u+19]=t*h,p[u+20]=(e+.5)*l*2-1,p[u+21]=(t+.5)*h*2-1,p[u+22]=e*l,p[u+23]=t*h,u+=n*c;r.vao=i(r.vao),r.vao=new v(t,w,{geometry:T},{geometry:j.createVertex(t,O.STATIC_DRAW,p)})}}_gridComputeCoverage(e,t){if(!this._context)return;const r=this._context.fbos.rctx,i=this._grid,s=r.bindTechnique(this._downsampleTechnique,this._passParameters,t),o=e.descriptor;i.coverage?.release(),i.coverage=this._context.fbos.acquire(n.RG,Math.ceil(o.width/P),Math.ceil(o.height/P)),r.bindFramebuffer(i.coverage.fbo),this._downsampleDrawParameters.input=e,s.bindDraw(this._downsampleDrawParameters,t,this._passParameters);const{width:a,height:h}=o;r.setViewport(0,0,a,h),r.screen.draw()}get test(){return{coverage:this._grid.coverage}}};e([a()],D.prototype,"_context",void 0),e([a()],D.prototype,"view",void 0),D=e([h("esri.views.3d.webgl-engine.lib.Highlight")],D);export{D as Highlight};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as e}from"../../../../../core/colorUtils.js";import{smoothstep as i,clamp as s}from"../../../../../core/mathUtils.js";import{watch as r,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{n as c,s as n,d as p}from"../../../../../chunks/vec3.js";import{c as d}from"../../../../../chunks/vec3f64.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{ShaderOutput as l}from"../../core/shaderLibrary/ShaderOutput.js";import{ReadShadowMapDrawParameters as u}from"../../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{SyncRenderPlugin as _}from"../RenderPlugin.js";import{defaultShadowOpacity as w,defaultShadowDifference as g,defaultShadowColor as f}from"./HighlightDefaults.js";import{ShadowHighlightPassParameters as y,ShadowHighlightTechnique as O}from"./ShadowHighlightTechnique.js";import{RenderSlot as x}from"../../lib/RenderSlot.js";const b=.001953125,P=4e4,j=5e4;let v=class extends _{constructor(t){super(t),this.renderSlots=[x.SHADOW_HIGHLIGHT],this._maxOpacity=1,this._passParameters=new y,this._drawParameters=new u,this._shadowDifference=.2,this._context=null}canRender(t){return t===x.SHADOW_HIGHLIGHT&&this._isVisible}requires(t){return t===l.Highlight}initializeRenderContext(t){this._context=t,this.addHandles([r((()=>this.view.highlightOptions.shadowOpacity),(t=>{this._passParameters.shadowOpacity=t??w,this._updateOccludedShadowOpacity(),this._updateMaxOpacity()}),a),r((()=>this.view.highlightOptions.shadowDifference),(t=>{this._shadowDifference=t??g,this._updateOccludedShadowOpacity(),this._updateMaxOpacity()}),a),r((()=>this.view.highlightOptions.shadowColor),(t=>{this._passParameters.shadowColor=e(t??f),this._updateMaxOpacity()}),a)])}_updateOccludedShadowOpacity(){this._passParameters.occludedShadowOpacity=this._passParameters.shadowOpacity*(1-this._shadowDifference)}_updateMaxOpacity(){const t=Math.max(this._passParameters.shadowOpacity,this._passParameters.occludedShadowOpacity);this._maxOpacity=t*this._passParameters.shadowColor[3]}uninitializeRenderContext(){this._context=null}enable(){this._context&&null==this._technique&&(this._technique=this._context.techniqueRepository.acquire(O))}render(t,e,i,s){if(!(this._context&&i&&i.highlightTexture&&this._isVisible))return;if(!this._technique?.compiled)return void this._context.requestRender();const r=t.bindParameters;if(!r.shadowMap.enabled||!r.linearDepth)return;const a=t.rctx,o=this._technique;this._passParameters.highlight=i.highlightTexture,this._drawParameters.origin=r.camera.center,a.bindFramebuffer(s),a.bindTechnique(o,this._passParameters,r).bindDraw(this._drawParameters,r,this._passParameters),a.screen.draw()}updateParameters(t,e){this._passParameters.opacityElevation=1-i(P,j,t.relativeElevation);const r=this.viewingMode===m.Global?c(S,t.center):n(S,0,0,1),a=p(r,e);this._passParameters.dayNightTerminator=i(0,1,s(30*a,0,1)),this._isVisible&&this.enable()}get _isVisible(){const{opacityElevation:t,dayNightTerminator:e}=this._passParameters;return this._maxOpacity*t*e>=b}};t([o()],v.prototype,"_context",void 0),t([o()],v.prototype,"view",void 0),t([o()],v.prototype,"viewingMode",void 0),v=t([h("esri.views.3d.webgl-engine.lib.ShadowHighlight")],v);const S=d();export{v as ShadowHighlight};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as e}from"../../../../../core/colorUtils.js";import{smoothstep as s,clamp as i}from"../../../../../core/mathUtils.js";import{watch as r,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{n as c,s as n,d as p}from"../../../../../chunks/vec3.js";import{c as d}from"../../../../../chunks/vec3f64.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{ShaderOutput as l}from"../../core/shaderLibrary/ShaderOutput.js";import{ReadShadowMapDrawParameters as u}from"../../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{SyncRenderPlugin as _}from"../RenderPlugin.js";import{defaultShadowOpacity as w,defaultShadowDifference as g,defaultShadowColor as f}from"./HighlightDefaults.js";import{ShadowHighlightPassParameters as y,ShadowHighlightTechnique as O}from"./ShadowHighlightTechnique.js";import{RenderSlot as x}from"../../lib/RenderSlot.js";const b=.001953125,P=4e4,j=5e4;let v=class extends _{constructor(t){super(t),this.renderSlots=[x.SHADOW_HIGHLIGHT],this._maxOpacity=1,this._passParameters=new y,this._drawParameters=new u,this._shadowDifference=.2,this._context=null}produces(t){return t===x.SHADOW_HIGHLIGHT&&this._isVisible}consumes(t){return t===l.Highlight}initializeRenderContext(t){this._context=t,this.addHandles([r((()=>this.view.highlightOptions.shadowOpacity),(t=>{this._passParameters.shadowOpacity=t??w,this._updateOccludedShadowOpacity(),this._updateMaxOpacity()}),a),r((()=>this.view.highlightOptions.shadowDifference),(t=>{this._shadowDifference=t??g,this._updateOccludedShadowOpacity(),this._updateMaxOpacity()}),a),r((()=>this.view.highlightOptions.shadowColor),(t=>{this._passParameters.shadowColor=e(t??f),this._updateMaxOpacity()}),a)])}_updateOccludedShadowOpacity(){this._passParameters.occludedShadowOpacity=this._passParameters.shadowOpacity*(1-this._shadowDifference)}_updateMaxOpacity(){const t=Math.max(this._passParameters.shadowOpacity,this._passParameters.occludedShadowOpacity);this._maxOpacity=t*this._passParameters.shadowColor[3]}uninitializeRenderContext(){this._context=null}enable(){this._context&&null==this._technique&&(this._technique=this._context.techniqueRepository.acquire(O))}render(t,e,s,i){if(!(this._context&&s&&s.highlightTexture&&this._isVisible))return;if(!this._technique?.compiled)return void this._context.requestRender();const r=t.bindParameters;if(!r.shadowMap.enabled||!r.linearDepth)return;const a=t.rctx,o=this._technique;this._passParameters.highlight=s.highlightTexture,this._drawParameters.origin=r.camera.center,a.bindFramebuffer(i),a.bindTechnique(o,this._passParameters,r).bindDraw(this._drawParameters,r,this._passParameters),a.screen.draw()}updateParameters(t,e){this._passParameters.opacityElevation=1-s(P,j,t.relativeElevation);const r=this.viewingMode===m.Global?c(S,t.center):n(S,0,0,1),a=p(r,e);this._passParameters.dayNightTerminator=s(0,1,i(30*a,0,1)),this._isVisible&&this.enable()}get _isVisible(){const{opacityElevation:t,dayNightTerminator:e}=this._passParameters;return this._maxOpacity*t*e>=b}};t([o()],v.prototype,"_context",void 0),t([o()],v.prototype,"view",void 0),t([o()],v.prototype,"viewingMode",void 0),v=t([h("esri.views.3d.webgl-engine.lib.ShadowHighlight")],v);const S=d();export{v as ShadowHighlight};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as t,abortMaybe as r}from"../../../../../core/maybe.js";import{isAbortError as s,throwIfAborted as i,isAborted as o}from"../../../../../core/promiseUtils.js";import{watch as a,syncAndInitial as n}from"../../../../../core/reactiveUtils.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as u}from"../../../../../support/requestImageUtils.js";import{ColorFormat as c}from"../../core/FBOCache.js";import{SyncRenderPlugin as d}from"../RenderPlugin.js";import{SMAABlendWeightsTechnique as _}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as m}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as p}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as b}from"./SMAAPassParameters.js";import{RenderFeature as T}from"../../lib/RenderFeature.js";import{RenderSlot as x}from"../../lib/RenderSlot.js";import{PixelFormat as f,TextureSamplingMode as q,ClearBufferBit as g,TextureWrapMode as C}from"../../../../webgl/enums.js";import{Texture as j}from"../../../../webgl/Texture.js";import{TextureDescriptor as A}from"../../../../webgl/TextureDescriptor.js";let R=class extends d{constructor(e){super(e),this.renderSlots=[x.ANTIALIASING],this._context=null,this._areaTexture=null,this._searchTexture=null,this._isEnabled=!1,this._smaaParameters=new b}canRender(){return this._isEnabled&&null!=this._context}get updating(){return null!=this._abortController}initializeRenderContext(e){this._context=e,this.addHandles([a((()=>this.view.qualitySettings.antialiasingEnabled),(e=>e||this._context?.isFeatureEnabled(T.Antialiasing)?this.enable():this.disable()),n)])}renderFeatureChanged(){this.view.qualitySettings.antialiasingEnabled||this._context?.isFeatureEnabled(T.Antialiasing)?this.enable():this.disable()}uninitializeRenderContext(){this.disable(),this._context=null}enable(){if(this._isEnabled||!this._context||this._abortController)return;if(null==this._edgeTechnique&&(this._edgeTechnique=this._context.techniqueRepository.acquire(p)),null==this._blendTechnique&&(this._blendTechnique=this._context.techniqueRepository.acquire(_)),null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(m)),this._areaTexture&&this._searchTexture)return void(this._isEnabled=!0);this._abortController=new AbortController;const e=this._abortController.signal;import("./SMAAData.js").then((t=>this._loadTextures(this._context,t,e))).then((()=>{this._context?.requestRender(),this._abortController=null})).catch((e=>{s(e)||this._disposeTextures()}))}_loadTextures(e,t,r){return i(r),e?Promise.all([u(t.areaTexture).then((t=>E(e.fbos.rctx,q.LINEAR,f.RGB,t))),u(t.searchTexure).then((t=>E(e.fbos.rctx,q.NEAREST,f.LUMINANCE,t)))]).then((([e,t])=>{o(r)?(e.dispose(),t.dispose(),i(r)):(this._areaTexture=e,this._searchTexture=t,this._isEnabled=!0)})):Promise.reject()}_disposeTextures(){this._areaTexture=t(this._areaTexture),this._searchTexture=t(this._searchTexture)}disable(){this._abortController=r(this._abortController),this._isEnabled=!1}destroy(){this.disable(),this._disposeTextures()}render(e,t,r,s){if(!(this._isEnabled&&this._context&&r&&r.compositeTexture))return;if(!(this._edgeTechnique?.compiled&&this._blendTechnique?.compiled&&this._blurTechnique?.compiled))return void this._context.requestRender();const i=r.compositeTexture,o=i.descriptor.width,a=i.descriptor.height,n=this._context.fbos,h=e.rctx;h.setViewport(0,0,o,a);const l=n.acquire(c.RG,o,a);h.bindFramebuffer(l.fbo),h.setClearColor(0,0,0,1),h.clear(g.COLOR_BUFFER_BIT),this._smaaParameters.color=i,h.bindTechnique(this._edgeTechnique,this._smaaParameters),h.screen.draw();const u=n.acquire(c.RGBA,o,a);h.bindFramebuffer(u.fbo),h.setClearColor(0,0,1,1),h.clear(g.COLOR_BUFFER_BIT),this._smaaParameters.inputTexture=l.colorTexture,this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,h.bindTechnique(this._blendTechnique,this._smaaParameters),h.screen.draw(),h.bindFramebuffer(s),l.release(),h.setClearColor(0,1,0,1),h.clear(g.COLOR_BUFFER_BIT),this._smaaParameters.inputTexture=u.colorTexture,h.bindTechnique(this._blurTechnique,this._smaaParameters),h.screen.draw(),u.release()}};function E(e,t,r,s){const i=new A;return i.pixelFormat=r,i.wrapMode=C.CLAMP_TO_EDGE,i.width=s.width,i.height=s.height,i.samplingMode=t,new j(e,i,s)}e([h()],R.prototype,"view",void 0),e([h()],R.prototype,"_context",void 0),e([h()],R.prototype,"_abortController",void 0),e([h({readOnly:!0})],R.prototype,"updating",null),R=e([l("esri.views.3d.webgl-engine.lib.SMAA")],R);export{R as SMAA};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as t,abortMaybe as r}from"../../../../../core/maybe.js";import{isAbortError as s,throwIfAborted as i,isAborted as o}from"../../../../../core/promiseUtils.js";import{watch as a,syncAndInitial as n}from"../../../../../core/reactiveUtils.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as u}from"../../../../../support/requestImageUtils.js";import{ColorFormat as c}from"../../core/FBOCache.js";import{SyncRenderPlugin as d}from"../RenderPlugin.js";import{SMAABlendWeightsTechnique as _}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as m}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as p}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as b}from"./SMAAPassParameters.js";import{RenderFeature as T}from"../../lib/RenderFeature.js";import{RenderSlot as x}from"../../lib/RenderSlot.js";import{PixelFormat as f,TextureSamplingMode as q,ClearBufferBit as g,TextureWrapMode as C}from"../../../../webgl/enums.js";import{Texture as j}from"../../../../webgl/Texture.js";import{TextureDescriptor as A}from"../../../../webgl/TextureDescriptor.js";let E=class extends d{constructor(e){super(e),this.renderSlots=[x.ANTIALIASING],this._context=null,this._areaTexture=null,this._searchTexture=null,this._isEnabled=!1,this._smaaParameters=new b}produces(){return this._isEnabled&&null!=this._context}get updating(){return null!=this._abortController}initializeRenderContext(e){this._context=e,this.addHandles([a((()=>this.view.qualitySettings.antialiasingEnabled),(e=>e||this._context?.isFeatureEnabled(T.Antialiasing)?this.enable():this.disable()),n)])}renderFeatureChanged(){this.view.qualitySettings.antialiasingEnabled||this._context?.isFeatureEnabled(T.Antialiasing)?this.enable():this.disable()}uninitializeRenderContext(){this.disable(),this._context=null}enable(){if(this._isEnabled||!this._context||this._abortController)return;if(null==this._edgeTechnique&&(this._edgeTechnique=this._context.techniqueRepository.acquire(p)),null==this._blendTechnique&&(this._blendTechnique=this._context.techniqueRepository.acquire(_)),null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(m)),this._areaTexture&&this._searchTexture)return void(this._isEnabled=!0);this._abortController=new AbortController;const e=this._abortController.signal;import("./SMAAData.js").then((t=>this._loadTextures(this._context,t,e))).then((()=>{this._context?.requestRender(),this._abortController=null})).catch((e=>{s(e)||this._disposeTextures()}))}_loadTextures(e,t,r){return i(r),e?Promise.all([u(t.areaTexture).then((t=>R(e.fbos.rctx,q.LINEAR,f.RGB,t))),u(t.searchTexure).then((t=>R(e.fbos.rctx,q.NEAREST,f.LUMINANCE,t)))]).then((([e,t])=>{o(r)?(e.dispose(),t.dispose(),i(r)):(this._areaTexture=e,this._searchTexture=t,this._isEnabled=!0)})):Promise.reject()}_disposeTextures(){this._areaTexture=t(this._areaTexture),this._searchTexture=t(this._searchTexture)}disable(){this._abortController=r(this._abortController),this._isEnabled=!1}destroy(){this.disable(),this._disposeTextures()}render(e,t,r,s){if(!(this._isEnabled&&this._context&&r&&r.compositeTexture))return;if(!(this._edgeTechnique?.compiled&&this._blendTechnique?.compiled&&this._blurTechnique?.compiled))return void this._context.requestRender();const i=r.compositeTexture,o=i.descriptor.width,a=i.descriptor.height,n=this._context.fbos,h=e.rctx;h.setViewport(0,0,o,a);const l=n.acquire(c.RG,o,a);h.bindFramebuffer(l.fbo),h.setClearColor(0,0,0,1),h.clear(g.COLOR_BUFFER_BIT),this._smaaParameters.color=i,h.bindTechnique(this._edgeTechnique,this._smaaParameters),h.screen.draw();const u=n.acquire(c.RGBA,o,a);h.bindFramebuffer(u.fbo),h.setClearColor(0,0,1,1),h.clear(g.COLOR_BUFFER_BIT),this._smaaParameters.inputTexture=l.colorTexture,this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,h.bindTechnique(this._blendTechnique,this._smaaParameters),h.screen.draw(),h.bindFramebuffer(s),l.release(),h.setClearColor(0,1,0,1),h.clear(g.COLOR_BUFFER_BIT),this._smaaParameters.inputTexture=u.colorTexture,h.bindTechnique(this._blurTechnique,this._smaaParameters),h.screen.draw(),u.release()}};function R(e,t,r,s){const i=new A;return i.pixelFormat=r,i.wrapMode=C.CLAMP_TO_EDGE,i.width=s.width,i.height=s.height,i.samplingMode=t,new j(e,i,s)}e([h()],E.prototype,"view",void 0),e([h()],E.prototype,"_context",void 0),e([h()],E.prototype,"_abortController",void 0),e([h({readOnly:!0})],E.prototype,"updating",null),E=e([l("esri.views.3d.webgl-engine.lib.SMAA")],E);export{E as SMAA};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{watch as r,syncAndInitial as s}from"../../../../../core/reactiveUtils.js";import{Milliseconds as i}from"../../../../../core/time.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{s as n}from"../../../../../chunks/vec2.js";import{ColorFormat as m}from"../../core/FBOCache.js";import{ShaderOutput as l}from"../../core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as c}from"../RenderPlugin.js";import{SSAOBlurTechnique as h}from"./SSAOBlurTechnique.js";import{noiseData as u}from"./SSAONoiseData.js";import{SSAOPassParameters as p,BlurDrawParameters as _}from"./SSAOParameters.js";import{SSAOTechnique as d}from"./SSAOTechnique.js";import{RenderFeature as b}from"../../lib/RenderFeature.js";import{RenderSlot as T}from"../../lib/RenderSlot.js";import{g as f}from"../../../../../chunks/SSAO.glsl.js";import{TextureWrapMode as x,PixelFormat as w,ClearBufferBit as S}from"../../../../webgl/enums.js";import{Texture as P}from"../../../../webgl/Texture.js";import{TextureDescriptor as q}from"../../../../webgl/TextureDescriptor.js";const j=2;let R=class extends c{constructor(e){super(e),this.renderSlots=[T.SSAO],this._context=null,this._passParameters=new p,this._drawParameters=new _}canRender(){return null!=this._enableTime&&null!=this._context}requires(e){return this.canRender()&&(e===l.Depth||e===l.Normal)}initializeRenderContext(e){this._context=e,this.addHandles([r((()=>this.view.qualitySettings.ambientOcclusion||this._context?.isFeatureEnabled(b.SSAO)),(e=>e?this._enable():this._disable()),s)])}uninitializeRenderContext(){this._disable(),this._context=null}_disable(){this._passParameters.noiseTexture=t(this._passParameters.noiseTexture),this._enableTime=null}destroy(){this._disable()}_enable(){if(null!=this._enableTime||!this._context)return;const e=Uint8Array.from(atob(u),(e=>e.charCodeAt(0))),t=new q;t.wrapMode=x.CLAMP_TO_EDGE,t.pixelFormat=w.RGB,t.wrapMode=x.REPEAT,t.hasMipmap=!0,t.width=32,t.height=32,this._passParameters.noiseTexture=new P(this._context.renderContext.rctx,t,e),null==this._ssaoTechnique&&(this._ssaoTechnique=this._context.techniqueRepository.acquire(d)),null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(h)),this._enableTime=i(0),this._context?.requestRender()}render(e,t,r,s){const i=e.bindParameters,o=i.linearDepth?.colorTexture;if(null==this._enableTime||null==this._context||null==o||!r?.normalTexture)return;if(!this._ssaoTechnique.compiled||!this._blurTechnique.compiled)return this._enableTime=e.time,void this._context.requestRender();0===this._enableTime&&(this._enableTime=e.time);const a=e.rctx,l=i.camera,c=this.view.qualitySettings.fadeDuration,h=c>0?Math.min(c,e.time-this._enableTime)/c:1;this._passParameters.normalTexture=r.normalTexture,this._passParameters.depthTexture=o,this._passParameters.projScale=1/l.computeRenderPixelSizeAtDist(1),this._passParameters.intensity=4*y/f(l)**6*h;const u=l.fullViewport[2],p=l.fullViewport[3],_=u/j,d=p/j,b=this._context.fbos,T=b.acquire(m.RED,u,p);a.bindFramebuffer(T.fbo),a.setViewport(0,0,u,p);a.bindTechnique(this._ssaoTechnique,this._passParameters,i).bindDraw(this._drawParameters,i,this._passParameters),a.screen.draw();const x=a.bindTechnique(this._blurTechnique,this._passParameters,i);a.setViewport(0,0,_,d);const w=b.acquire(m.RED,_,d);a.bindFramebuffer(w.fbo),this._drawParameters.colorTexture=T.colorTexture,n(this._drawParameters.blurSize,0,j/p),x.bindDraw(this._drawParameters,i,this._passParameters),a.setViewport(0,0,_,d),a.screen.draw(),T.release();const P=b.acquire(m.RED,_,d);return a.bindFramebuffer(P.fbo),a.setViewport(0,0,u,p),a.setClearColor(1,1,1,0),a.clear(S.COLOR_BUFFER_BIT),a.setViewport(0,0,_,d),this._drawParameters.colorTexture=w.colorTexture,n(this._drawParameters.blurSize,j/u,0),x.bindDraw(this._drawParameters,i,this._passParameters),a.screen.draw(),a.setViewport4fv(l.fullViewport),w.release(),h<1&&this._context.requestRender(),P}};e([o({constructOnly:!0})],R.prototype,"view",void 0),e([o()],R.prototype,"_context",void 0),R=e([a("esri.views.3d.webgl-engine.lib.SSAO")],R);const y=.5;export{R as SSAO,j as blurSizePixels};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{watch as r,syncAndInitial as s}from"../../../../../core/reactiveUtils.js";import{Milliseconds as i}from"../../../../../core/time.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{s as n}from"../../../../../chunks/vec2.js";import{ColorFormat as m}from"../../core/FBOCache.js";import{ShaderOutput as c}from"../../core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as l}from"../RenderPlugin.js";import{SSAOBlurTechnique as u}from"./SSAOBlurTechnique.js";import{noiseData as h}from"./SSAONoiseData.js";import{SSAOPassParameters as p,BlurDrawParameters as _}from"./SSAOParameters.js";import{SSAOTechnique as d}from"./SSAOTechnique.js";import{RenderFeature as b}from"../../lib/RenderFeature.js";import{RenderSlot as T}from"../../lib/RenderSlot.js";import{g as f}from"../../../../../chunks/SSAO.glsl.js";import{TextureWrapMode as x,PixelFormat as w,ClearBufferBit as S}from"../../../../webgl/enums.js";import{Texture as P}from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";const q=2;let R=class extends l{constructor(e){super(e),this.renderSlots=[T.SSAO],this._context=null,this._passParameters=new p,this._drawParameters=new _}produces(){return null!=this._enableTime&&null!=this._context}consumes(e){return this.produces()&&(e===c.Depth||e===c.Normal)}initializeRenderContext(e){this._context=e,this.addHandles([r((()=>this.view.qualitySettings.ambientOcclusion||this._context?.isFeatureEnabled(b.SSAO)),(e=>e?this._enable():this._disable()),s)])}uninitializeRenderContext(){this._disable(),this._context=null}_disable(){this._passParameters.noiseTexture=t(this._passParameters.noiseTexture),this._enableTime=null}destroy(){this._disable()}_enable(){if(null!=this._enableTime||!this._context)return;const e=Uint8Array.from(atob(h),(e=>e.charCodeAt(0))),t=new j;t.wrapMode=x.CLAMP_TO_EDGE,t.pixelFormat=w.RGB,t.wrapMode=x.REPEAT,t.hasMipmap=!0,t.width=32,t.height=32,this._passParameters.noiseTexture=new P(this._context.renderContext.rctx,t,e),null==this._ssaoTechnique&&(this._ssaoTechnique=this._context.techniqueRepository.acquire(d)),null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(u)),this._enableTime=i(0),this._context?.requestRender()}render(e,t,r,s){const i=e.bindParameters,o=i.linearDepth?.colorTexture;if(null==this._enableTime||null==this._context||null==o||!r?.normalTexture)return;if(!this._ssaoTechnique.compiled||!this._blurTechnique.compiled)return this._enableTime=e.time,void this._context.requestRender();0===this._enableTime&&(this._enableTime=e.time);const a=e.rctx,c=i.camera,l=this.view.qualitySettings.fadeDuration,u=l>0?Math.min(l,e.time-this._enableTime)/l:1;this._passParameters.normalTexture=r.normalTexture,this._passParameters.depthTexture=o,this._passParameters.projScale=1/c.computeRenderPixelSizeAtDist(1),this._passParameters.intensity=4*y/f(c)**6*u;const h=c.fullViewport[2],p=c.fullViewport[3],_=h/q,d=p/q,b=this._context.fbos,T=b.acquire(m.RED,h,p);a.bindFramebuffer(T.fbo),a.setViewport(0,0,h,p);a.bindTechnique(this._ssaoTechnique,this._passParameters,i).bindDraw(this._drawParameters,i,this._passParameters),a.screen.draw();const x=a.bindTechnique(this._blurTechnique,this._passParameters,i);a.setViewport(0,0,_,d);const w=b.acquire(m.RED,_,d);a.bindFramebuffer(w.fbo),this._drawParameters.colorTexture=T.colorTexture,n(this._drawParameters.blurSize,0,q/p),x.bindDraw(this._drawParameters,i,this._passParameters),a.setViewport(0,0,_,d),a.screen.draw(),T.release();const P=b.acquire(m.RED,_,d);return a.bindFramebuffer(P.fbo),a.setViewport(0,0,h,p),a.setClearColor(1,1,1,0),a.clear(S.COLOR_BUFFER_BIT),a.setViewport(0,0,_,d),this._drawParameters.colorTexture=w.colorTexture,n(this._drawParameters.blurSize,q/h,0),x.bindDraw(this._drawParameters,i,this._passParameters),a.screen.draw(),a.setViewport4fv(c.fullViewport),w.release(),u<1&&this._context.requestRender(),P}};e([o({constructOnly:!0})],R.prototype,"view",void 0),e([o()],R.prototype,"_context",void 0),R=e([a("esri.views.3d.webgl-engine.lib.SSAO")],R);const y=.5;export{R as SSAO,q as blurSizePixels};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Logger.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import{NestedMap as r}from"../../../../core/NestedMap.js";import{assert as i}from"./Util.js";class s{constructor(e,t,i,s){this._textureRepository=e,this._techniqueRepository=t,this.materialChanged=i,this.requestRender=s,this._id2glMaterialRef=new r}dispose(){this._textureRepository.destroy()}acquire(e,t,r){if(this._ownMaterial(e),!e.canRender(t,r))return null;let i=this._id2glMaterialRef.get(r,e.id);if(null==i){const t=e.createGLMaterial({material:e,techniqueRep:this._techniqueRepository,textureRep:this._textureRepository,output:r});i=new o(t),this._id2glMaterialRef.set(r,e.id,i)}return i.ref(),i.glMaterial}release(e,r){const i=this._id2glMaterialRef.get(r,e.id);null!=i&&(i.unref(),i.referenced||(t(i.glMaterial),this._id2glMaterialRef.delete(r,e.id)))}_ownMaterial(t){null!=t.repository&&t.repository!==this&&e.getLogger("esri.views.3d.webgl-engine.lib.GLMaterialRepository").error("Material is already owned by a different material repository"),t.repository=this}}class o{constructor(e){this.glMaterial=e,this._refCnt=0}ref(){++this._refCnt}unref(){--this._refCnt,i(this._refCnt>=0)}get referenced(){return this._refCnt>0}}export{s as GLMaterialRepository};
5
+ import e from"../../../../core/Logger.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import{NestedMap as r}from"../../../../core/NestedMap.js";import{assert as i}from"./Util.js";class s{constructor(e,t,i,s){this._textureRepository=e,this._techniqueRepository=t,this.materialChanged=i,this.requestRender=s,this._id2glMaterialRef=new r}dispose(){this._textureRepository.destroy()}acquire(e,t,r){if(this._ownMaterial(e),!e.produces(t,r))return null;let i=this._id2glMaterialRef.get(r,e.id);if(null==i){const t=e.createGLMaterial({material:e,techniqueRep:this._techniqueRepository,textureRep:this._textureRepository,output:r});i=new o(t),this._id2glMaterialRef.set(r,e.id,i)}return i.ref(),i.glMaterial}release(e,r){const i=this._id2glMaterialRef.get(r,e.id);null!=i&&(i.unref(),i.referenced||(t(i.glMaterial),this._id2glMaterialRef.delete(r,e.id)))}_ownMaterial(t){null!=t.repository&&t.repository!==this&&e.getLogger("esri.views.3d.webgl-engine.lib.GLMaterialRepository").error("Material is already owned by a different material repository"),t.repository=this}}class o{constructor(e){this.glMaterial=e,this._refCnt=0}ref(){++this._refCnt}unref(){--this._refCnt,i(this._refCnt>=0)}get referenced(){return this._refCnt>0}}export{s as GLMaterialRepository};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{ResourceState as s}from"./basicInterfaces.js";class t{constructor(s,t){this._material=s,this._repository=t,this._map=new Map}dispose(){this._map.forEach(((s,t)=>{null!=s&&this._repository.release(this._material,t)}))}load(t,e,r){if(!this._material.canRender(e,r))return null;this._map.has(r)||this._map.set(r,this._repository.acquire(this._material,e,r));const i=this._map.get(r);if(null!=i){if(i.ensureResources(t)===s.LOADED)return i;this._repository.requestRender()}return null}}export{t as GLMaterials};
5
+ import{ResourceState as s}from"./basicInterfaces.js";class t{constructor(s,t){this._material=s,this._repository=t,this._map=new Map}dispose(){this._map.forEach(((s,t)=>{null!=s&&this._repository.release(this._material,t)}))}load(t,r,e){if(!this._material.produces(r,e))return null;this._map.has(e)||this._map.set(e,this._repository.acquire(this._material,r,e));const i=this._map.get(e);if(null!=i){if(i.ensureResources(t)===s.LOADED)return i;this._repository.requestRender()}return null}}export{t as GLMaterials};