@arcgis/core 4.25.0-next.20220705 → 4.25.0-next.20220708

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 (336) hide show
  1. package/TimeExtent.js +1 -1
  2. package/arcade/arcadeCompiler.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/0703495557b0df6878c5.js +1 -0
  5. package/assets/esri/core/workers/chunks/1570676351a313f1841b.js +1 -0
  6. package/assets/esri/core/workers/chunks/{695f90305478f5024fa7.js → 1ecbf642debc2207b762.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{30dbdf2aa1bc8e61cad4.js → 268e7b46202fc1decf9f.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{47d78b4f7117554acecf.js → 357a27203f5d8fa152de.js} +1 -1
  9. package/assets/esri/core/workers/chunks/35dfba25a9077ab5dbaf.js +982 -0
  10. package/assets/esri/core/workers/chunks/377354a81e402edf3077.js +1 -0
  11. package/assets/esri/core/workers/chunks/3a42d96ea3b59d33bfe8.js +1 -0
  12. package/assets/esri/core/workers/chunks/3a61e4ab83183f5526a7.js +1 -0
  13. package/assets/esri/core/workers/chunks/{3790f0362b6f27ee798b.js → 3ee5e8d00cd3bc47a9fa.js} +1 -1
  14. package/assets/esri/core/workers/chunks/425d1fabc713a598139c.js +1 -0
  15. package/assets/esri/core/workers/chunks/425e16862feccb467191.js +1 -0
  16. package/assets/esri/core/workers/chunks/{bbe51b49fe7093e47306.js → 48c8ac9a22190c2b890c.js} +1 -1
  17. package/assets/esri/core/workers/chunks/4a364bc073fdc7c1b563.js +1 -0
  18. package/assets/esri/core/workers/chunks/4ca6ada7a4ccde5b5a24.js +1 -0
  19. package/assets/esri/core/workers/chunks/{905130ff0118962c8140.js → 61b71b8e028eda10ccab.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{b34cffd5c45d3a8134bc.js → 69f57ad2227e59b323e8.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{290899b47a52f8b28a9c.js → 791220164501a791b2cd.js} +1 -1
  22. package/assets/esri/core/workers/chunks/792b4b0a43b4bbbc14ab.js +1 -0
  23. package/assets/esri/core/workers/chunks/7b32b8e8ebe48ae0dae2.js +1 -0
  24. package/assets/esri/core/workers/chunks/7f00125b02bb7211de43.js +1 -0
  25. package/assets/esri/core/workers/chunks/81074accfce5f109f909.js +1 -0
  26. package/assets/esri/core/workers/chunks/{594d7fdb80ad9cdedb85.js → 823e25dbc70e71257b6e.js} +1 -1
  27. package/assets/esri/core/workers/chunks/92e43e05265dfc8173a0.js +1 -0
  28. package/assets/esri/core/workers/chunks/{40fa9b28ca882a70813a.js → 92f7415c2e40e320addc.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{9520b32d5d53ea9cd0d3.js → 9341e9e1fe0f6800aa44.js} +1 -1
  30. package/assets/esri/core/workers/chunks/95451d6405729a9f50c7.js +1 -0
  31. package/assets/esri/core/workers/chunks/{910a2ffb4328f8ee7a0d.js → 95cb9cd08941c28ebd85.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{97f32af5893c86f6444c.js → 9b9a40b84640f00a1dcb.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{77c6ba5ea85915d9078c.js → ac07c732aca6e67232f8.js} +1 -1
  34. package/assets/esri/core/workers/chunks/ae8e87da97411cff3783.js +1 -0
  35. package/assets/esri/core/workers/chunks/{65161a874595b0a34aa1.js → b312dd3027492007d75e.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{83c9da68d6dbc77f60e5.js → beead2b06c994b4e61af.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{5e20fd8b7c9497f2da1f.js → bfb08d3e2208c6178af9.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{04e5486f0d8d4c6bd8a2.js → c3236a7058e64ea3b939.js} +1 -1
  39. package/assets/esri/core/workers/chunks/c4e9c71be6299c60c539.js +1 -0
  40. package/assets/esri/core/workers/chunks/c705f907ce60a646d9aa.js +1 -0
  41. package/assets/esri/core/workers/chunks/ce6abfafa0171b9c8d81.js +1 -0
  42. package/assets/esri/core/workers/chunks/{08a5c5a33a7c7c6852e5.js → d00b0f8236f1526099d4.js} +1 -1
  43. package/assets/esri/core/workers/chunks/d13951412a57e1af6208.js +1 -0
  44. package/assets/esri/core/workers/chunks/ecaf8f030026e41e1d1a.js +1 -0
  45. package/assets/esri/core/workers/chunks/f328a6cd4b7d8c653fc7.js +1 -0
  46. package/assets/esri/core/workers/chunks/f6a6178d4df029ff010d.js +1 -0
  47. package/assets/esri/core/workers/chunks/fde2301c6cd97a3cfb86.js +1 -0
  48. package/assets/esri/core/workers/chunks/fe84bcdfd9028b5e7ef6.js +1 -0
  49. package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +4 -0
  50. package/assets/esri/themes/base/widgets/_LayerList.scss +4 -0
  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/chunks/CheckerBoard.glsl.js +2 -2
  55. package/chunks/ColorMaterial.glsl.js +9 -9
  56. package/chunks/ComponentShader.glsl.js +33 -33
  57. package/chunks/DefaultMaterial.glsl.js +35 -35
  58. package/chunks/HUDMaterial.glsl.js +11 -11
  59. package/chunks/ImageMaterial.glsl.js +5 -5
  60. package/chunks/LineMarker.glsl.js +17 -17
  61. package/chunks/NativeLine.glsl.js +3 -3
  62. package/chunks/Path.glsl.js +28 -28
  63. package/chunks/Pattern.glsl.js +9 -9
  64. package/chunks/PointRenderer.glsl.js +1 -1
  65. package/chunks/RealisticTree.glsl.js +4 -4
  66. package/chunks/RibbonLine.glsl.js +1 -1
  67. package/chunks/ShadedColorMaterial.glsl.js +1 -1
  68. package/chunks/SimpleAtmosphere.glsl.js +1 -1
  69. package/chunks/Terrain.glsl.js +92 -92
  70. package/chunks/WaterSurface.glsl.js +22 -22
  71. package/chunks/common.js +1 -1
  72. package/chunks/mat2.js +1 -1
  73. package/chunks/mat2d.js +1 -1
  74. package/chunks/mat3.js +1 -1
  75. package/chunks/mat4.js +1 -1
  76. package/chunks/quat.js +1 -1
  77. package/chunks/quat2.js +1 -1
  78. package/chunks/vec2.js +1 -1
  79. package/chunks/vec3.js +1 -1
  80. package/chunks/vec4.js +1 -1
  81. package/core/Message.js +1 -1
  82. package/core/accessorSupport/tracking.js +1 -1
  83. package/core/libs/gl-matrix-2/math/common.js +1 -1
  84. package/core/libs/gl-matrix-2/math/vec2.js +1 -1
  85. package/core/pbf.js +1 -1
  86. package/core/quantity.js +0 -1
  87. package/core/sql/WhereClause.js +1 -1
  88. package/core/urlUtils.js +1 -1
  89. package/geometry/support/scaleUtils.js +1 -1
  90. package/identity/IdentityForm.js +1 -1
  91. package/identity/IdentityModal.js +1 -1
  92. package/identity/OAuthCredential.js +1 -1
  93. package/interfaces.d.ts +3347 -190
  94. package/intl/date.js +1 -1
  95. package/intl/duration.js +1 -1
  96. package/intl/messages.js +1 -1
  97. package/intl/substitute.js +1 -1
  98. package/kernel.js +1 -1
  99. package/layers/ImageryTileLayer.js +1 -1
  100. package/layers/VoxelWasmPerSceneView.js +1 -1
  101. package/layers/mixins/ArcGISImageService.js +1 -1
  102. package/layers/mixins/ImageryTileMixin.js +1 -1
  103. package/layers/support/ControlPointsGeoreference.d.ts +4 -0
  104. package/layers/support/ControlPointsGeoreference.js +5 -0
  105. package/layers/support/CornersGeoreference.js +1 -1
  106. package/layers/support/ElevationSamplerData.js +5 -0
  107. package/layers/support/ElevationTile.js +1 -1
  108. package/layers/support/ExportImageServiceParameters.js +1 -1
  109. package/layers/support/MediaElementBase.js +1 -1
  110. package/layers/support/imageryRendererUtils.js +1 -1
  111. package/layers/support/rasterDatasets/TIFFRaster.js +1 -1
  112. package/package.json +1 -1
  113. package/renderers/support/RasterSymbolizer.js +1 -1
  114. package/request.js +1 -1
  115. package/rest/route/utils.js +1 -1
  116. package/rest/serviceArea.js +1 -1
  117. package/rest/support/ServiceAreaParameters.js +1 -1
  118. package/rest/support/ServiceAreaSolveResult.js +1 -1
  119. package/smartMapping/raster/renderers/classBreaks.js +1 -1
  120. package/smartMapping/raster/renderers/uniqueValue.js +1 -1
  121. package/support/apiKeyUtils.js +1 -1
  122. package/support/requestUtils.js +1 -1
  123. package/support/revision.js +1 -1
  124. package/views/2d/layers/MapNotesLayerView2D.js +1 -1
  125. package/views/2d/navigation/actions/Pinch.js +1 -1
  126. package/views/2d/tiling/TileCache.js +1 -1
  127. package/views/2d/viewpointUtils.js +1 -1
  128. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  129. package/views/3d/environment/CloudsCompositionTechnique.js +1 -1
  130. package/views/3d/environment/CloudsTechnique.js +1 -1
  131. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  132. package/views/3d/environment/FogTechnique.js +1 -1
  133. package/views/3d/environment/NoiseTextureAtlasTechnique.js +1 -1
  134. package/views/3d/environment/Precipitation.js +1 -1
  135. package/views/3d/environment/PrecipitationTechnique.js +1 -1
  136. package/views/3d/environment/SimpleAtmosphereTechnique.js +1 -1
  137. package/views/3d/environment/SimpleAtmosphereTechniqueConfiguration.js +1 -1
  138. package/views/3d/environment/StarsTechnique.js +1 -1
  139. package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
  140. package/views/3d/interactive/Manipulator3D.js +1 -1
  141. package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
  142. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  143. package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
  144. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  145. package/views/3d/layers/ImageryLayerView3D.js +1 -1
  146. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  147. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  148. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  149. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  150. package/views/3d/layers/support/FeatureVisibilityFilter.js +5 -0
  151. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  152. package/views/3d/state/ViewStateManager.js +1 -1
  153. package/views/3d/support/LaserlinePathData.js +1 -1
  154. package/views/3d/support/ResourceController.js +1 -1
  155. package/views/3d/terrain/BlendLayersTechnique.js +1 -1
  156. package/views/3d/terrain/ElevationData.js +1 -1
  157. package/views/3d/terrain/GeometryState.js +1 -1
  158. package/views/3d/terrain/OverlayRenderTarget.js +1 -1
  159. package/views/3d/terrain/OverlayRenderer.js +1 -1
  160. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  161. package/views/3d/terrain/PatchRenderData.js +1 -1
  162. package/views/3d/terrain/RasterColorizerTechnique.js +1 -1
  163. package/views/3d/terrain/TerrainConst.js +1 -1
  164. package/views/3d/terrain/TerrainRenderer.js +1 -1
  165. package/views/3d/terrain/TerrainSurface.js +1 -1
  166. package/views/3d/terrain/Tile.js +1 -1
  167. package/views/3d/terrain/tileUtils.js +1 -1
  168. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  169. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  170. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  171. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  172. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
  173. package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
  174. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  175. package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +2 -2
  176. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +5 -0
  177. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutputConfiguration.js +5 -0
  178. package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +4 -4
  179. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +11 -11
  180. package/views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js +1 -1
  181. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +55 -55
  182. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js +3 -3
  183. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Terrain.glsl.js +1 -1
  184. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js +1 -1
  185. package/views/3d/webgl-engine/lib/BlendWeightsTechnique.js +1 -1
  186. package/views/3d/webgl-engine/lib/BlurTechnique.js +1 -1
  187. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  188. package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +1 -1
  189. package/views/3d/webgl-engine/lib/EdgeDetectTechnique.js +1 -1
  190. package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
  191. package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
  192. package/views/3d/webgl-engine/lib/Material.js +1 -1
  193. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  194. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  195. package/views/3d/webgl-engine/lib/RenderContext.js +1 -1
  196. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  197. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  198. package/views/3d/webgl-engine/lib/SSAOTechnique.js +1 -1
  199. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  200. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  201. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  202. package/views/3d/webgl-engine/lib/TextureTechnique.js +1 -1
  203. package/views/3d/webgl-engine/lib/TransparencyPassType.js +5 -0
  204. package/views/3d/webgl-engine/lib/basicInterfaces.js +1 -1
  205. package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderTechnique.js +1 -1
  206. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  207. package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
  208. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  209. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  210. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  211. package/views/3d/webgl-engine/materials/DefaultTechniqueConfiguration.js +1 -1
  212. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  213. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  214. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  215. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  216. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  217. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  218. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  219. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  220. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  221. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  222. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  223. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  224. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  225. package/views/3d/webgl-engine/materials/WaterGLMaterial.js +1 -1
  226. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  227. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  228. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  229. package/views/3d/webgl-engine/shaders/CheckerBoard.glsl.js +1 -1
  230. package/views/3d/webgl-engine/shaders/CheckerBoardTechnique.js +1 -1
  231. package/views/3d/webgl-engine/shaders/CheckerBoardTechniqueConfiguration.js +1 -1
  232. package/views/3d/webgl-engine/shaders/ColorMaterial.glsl.js +1 -1
  233. package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
  234. package/views/3d/webgl-engine/shaders/ColorMaterialTechniqueConfiguration.js +1 -1
  235. package/views/3d/webgl-engine/shaders/CompositingTechnique.js +1 -1
  236. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  237. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  238. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  239. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  240. package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
  241. package/views/3d/webgl-engine/shaders/HUDMaterialTechniqueConfiguration.js +1 -1
  242. package/views/3d/webgl-engine/shaders/HeatmapDensityTechnique.js +1 -1
  243. package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +1 -1
  244. package/views/3d/webgl-engine/shaders/HighlightApplyTechnique.js +1 -1
  245. package/views/3d/webgl-engine/shaders/HighlightBlurTechnique.js +1 -1
  246. package/views/3d/webgl-engine/shaders/HighlightDownsampleTechnique.js +1 -1
  247. package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
  248. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  249. package/views/3d/webgl-engine/shaders/LaserlinePathTechnique.js +1 -1
  250. package/views/3d/webgl-engine/shaders/LaserlineTechnique.js +1 -1
  251. package/views/3d/webgl-engine/shaders/LineCalloutTechnique.js +1 -1
  252. package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
  253. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  254. package/views/3d/webgl-engine/shaders/LineMarkerTechniqueConfiguration.js +1 -1
  255. package/views/3d/webgl-engine/shaders/MeasurementArrowTechnique.js +1 -1
  256. package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +1 -1
  257. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  258. package/views/3d/webgl-engine/shaders/NativeLineTechniqueConfiguration.js +1 -1
  259. package/views/3d/webgl-engine/shaders/Path.glsl.js +1 -1
  260. package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
  261. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  262. package/views/3d/webgl-engine/shaders/PointRenderer.glsl.js +1 -1
  263. package/views/3d/webgl-engine/shaders/PointRendererTechnique.js +1 -1
  264. package/views/3d/webgl-engine/shaders/PointRendererTechniqueConfiguration.js +1 -1
  265. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  266. package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
  267. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  268. package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
  269. package/views/3d/webgl-engine/shaders/ShadedColorMaterial.glsl.js +1 -1
  270. package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechnique.js +1 -1
  271. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  272. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
  273. package/views/3d/webgl-engine/shaders/ShadowHighlightTechnique.js +1 -1
  274. package/views/3d/webgl-engine/shaders/SlicePlaneMaterialTechnique.js +1 -1
  275. package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
  276. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  277. package/views/3d/webgl-engine/shaders/WaterSurface.glsl.js +1 -1
  278. package/views/SceneView.js +1 -1
  279. package/views/draw/support/Reshape.js +1 -1
  280. package/views/interactive/GraphicManipulator.js +1 -1
  281. package/views/interactive/SegmentLabels.js +1 -1
  282. package/views/interactive/coordinateHelper.js +1 -1
  283. package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
  284. package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
  285. package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
  286. package/views/interactive/snapping/SnappingConstraint.js +1 -1
  287. package/views/interactive/snapping/SnappingManager.js +1 -1
  288. package/views/interactive/snapping/candidates/ParallelLineSnappingCandidate.js +1 -1
  289. package/views/interactive/snapping/candidates/RightAngleTriangleSnappingCandidate.js +1 -1
  290. package/views/interactive/snapping/snappingUtils.js +1 -1
  291. package/views/interactive/support/viewUtils.js +1 -1
  292. package/views/layers/ImageryTileLayerView.js +1 -1
  293. package/views/support/geometry2dUtils.js +1 -1
  294. package/webscene/Slide.js +1 -1
  295. package/widgets/BasemapLayerList.js +1 -1
  296. package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
  297. package/widgets/ElevationProfile.js +1 -1
  298. package/widgets/LayerList/ListItemPanel.js +1 -1
  299. package/widgets/LayerList.js +1 -1
  300. package/widgets/Widget.js +1 -1
  301. package/widgets/Zoom/ZoomConditions3D.js +1 -1
  302. package/widgets/Zoom/ZoomViewModel.js +1 -1
  303. package/widgets/Zoom.js +1 -1
  304. package/widgets/support/widgetUtils.js +1 -1
  305. package/assets/esri/core/workers/chunks/06a7f58260225f52f8e6.js +0 -1
  306. package/assets/esri/core/workers/chunks/0e00741d35cdbf48e72d.js +0 -1
  307. package/assets/esri/core/workers/chunks/1ebb29ceabc81509646c.js +0 -1
  308. package/assets/esri/core/workers/chunks/24f7a3df08c3a2d3795c.js +0 -1
  309. package/assets/esri/core/workers/chunks/39a754713a48d46618bd.js +0 -1
  310. package/assets/esri/core/workers/chunks/462163f31fa134b7b216.js +0 -1
  311. package/assets/esri/core/workers/chunks/4bfcb7350ca492767a45.js +0 -1
  312. package/assets/esri/core/workers/chunks/5470cb0c3f670957c22c.js +0 -1
  313. package/assets/esri/core/workers/chunks/6889d698a2c796ed1ce6.js +0 -1
  314. package/assets/esri/core/workers/chunks/869310ef4c98542bf9df.js +0 -1
  315. package/assets/esri/core/workers/chunks/8ebaad46e2fe8925e3b0.js +0 -1
  316. package/assets/esri/core/workers/chunks/98c519ac806cc55bc19b.js +0 -1
  317. package/assets/esri/core/workers/chunks/9d07969fbea13aa5b03c.js +0 -1
  318. package/assets/esri/core/workers/chunks/9e6ce879ec0da884b9b8.js +0 -1
  319. package/assets/esri/core/workers/chunks/abd1bd74ba571e39ab5a.js +0 -1
  320. package/assets/esri/core/workers/chunks/b26ea76e3f41b45756e0.js +0 -1
  321. package/assets/esri/core/workers/chunks/c2286d97539066c8549a.js +0 -1
  322. package/assets/esri/core/workers/chunks/c495a66978d67c7e17f3.js +0 -1
  323. package/assets/esri/core/workers/chunks/c7fa92daca3f6e91734e.js +0 -987
  324. package/assets/esri/core/workers/chunks/c9e890b4be9d01c13efe.js +0 -1
  325. package/assets/esri/core/workers/chunks/dda5ea7f8d35e257815c.js +0 -1
  326. package/assets/esri/core/workers/chunks/e153e89c8a15c2f036ef.js +0 -1
  327. package/assets/esri/core/workers/chunks/e201ffcca7321771ee20.js +0 -1
  328. package/assets/esri/core/workers/chunks/e5b5b93e707173a4c883.js +0 -1
  329. package/assets/esri/core/workers/chunks/f7d1f75b6aa3ef566d74.js +0 -1
  330. package/assets/esri/core/workers/chunks/fde9e9683335fa6c8236.js +0 -1
  331. package/core/queryUtils.js +0 -5
  332. package/views/3d/layers/graphics/Graphics3DFilterVisibility.js +0 -5
  333. package/views/3d/layers/support/HeatmapFilterVisibility.js +0 -5
  334. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutputOptions.js +0 -5
  335. package/views/3d/webgl-engine/core/shaderLibrary/util/HeaderComment.glsl.js +0 -10
  336. package/views/3d/webgl-engine/lib/RenderPass.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import o from"../../../core/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{aliasOf as L}from"../../../core/accessorSupport/decorators/aliasOf.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import{subclass as b}from"../../../core/accessorSupport/decorators/subclass.js";import{m as E}from"../../../chunks/mat4.js";import{c as D}from"../../../chunks/mat4f64.js";import{c as U}from"../../../chunks/vec3.js";import{c as x}from"../../../chunks/vec3f64.js";import{c as C}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as P}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as R,projectPointToVector as M}from"../../../geometry/projection.js";import{getReferenceEllipsoid as j}from"../../../geometry/projectionEllipsoid.js";import{create as A,equals as I,intersection as V,intersectsSphere as O}from"../../../geometry/support/aaBoundingRect.js";import{create as N,copy as k}from"../../../geometry/support/frustum.js";import{isPlateCarree as B}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as q}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as G}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{acquireDecoder as F}from"../../../layers/support/LercDecoder.js";import{printAllocations as H}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as Q,scaleToZoom as X}from"../support/cameraUtils.js";import z from"../support/debugFlags.js";import{toBoundingRect as Y}from"../support/extentUtils.js";import{ClientType as $}from"../support/index.js";import{updatingProgress as K}from"../support/updatingProperties.js";import{ElevationBounds as J}from"./ElevationBounds.js";import{sampleElevation as Z,ElevationData as ee}from"./ElevationData.js";import{create as te}from"./ExtentHelper.js";import{LODSnapping as ie,TextureUpdate as re}from"./interfaces.js";import{LayerClass as se,LayerClasses as ae}from"./LayerClass.js";import{OverlayManager as ne}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{MAX_ROOT_TILES as de,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as pe,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ue,MAX_MEMORY_LOD_BIAS as ce,ELEVATION_NODATA_VALUE as _e}from"./TerrainConst.js";import ge from"./TerrainRenderer.js";import me from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as fe,internalAssert as Te,isSurfaceLayerView as ye,isMapTileLayerView as ve,isBlendableLayerView as we,isGroupLayer as Le,isElevationLayerView as Se,isVectorTileLayerView as be,useFetchTileForLayer as Ee,isImageryTileLayerView as De,isTileLayerView as Ue,releaseTileData as xe,ENABLE_WATERPROOFNESS_TESTS as Ce,enableTerrainInternalChecks as Pe,enableTerrainWaterproofnessChecks as Re}from"./terrainUtils.js";import{SplitLimits as Me,Tile as je}from"./Tile.js";import{printAllocations as Ae}from"./TilePerLayerInfo.js";import{TileUpdate as Ie}from"./TileUpdate.js";import{IteratorPreorder as Ve,IteratorPostorder as Oe,hasLoadableSiblings as Ne,sortTilesByPOI as ke,sortTiles as Be}from"./tileUtils.js";import{TilingSchemeLogic as qe}from"./TilingSchemeLogic.js";import{UpsampleInfo as Ge}from"./UpsampleInfo.js";import{isCompositeBlendMode as We,blendModeFromString as Fe}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as He}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as Qe,TaskPriority as Xe,noBudget as ze}from"../../support/Scheduler.js";const Ye=.25;let $e=class extends(a.EventedMixin(i)){constructor(e){super(e),this._elevationBounds=new J,this._iteratorPool=new c(Ve,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Oe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new me,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=x(),this._eyePosSurfaceSR=x(),this._splitLimits=new Me,this._snapLevel=1/0,this._frustum=N(),this._viewProjectionMatrix=D(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new P,this._frameTask=Qe,this._allTiles=new _,this._upsampleInfoPool=new c(Ge),this._rootTilesExtent=A(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundColor=null,this._updatingRootTiles=!1,this.deferTileNeighborUpdate=!1,this.neighborTilesToUpdate=new Set,this.enableBatchTileGeometryUpdates=!0,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=F(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(oe):new c(he);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new G(e.newCache("elevation-query")),this._set("overlayManager",new ne({surface:this})),this._handles.add([T((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new ge({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:j(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles}),this._handles.add([T((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),T((()=>this.hasCompositeBlendMode),(()=>{this._updateBaseOpacity(this.baseOpacity)}),y),T((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),T((()=>z.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&z.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=te(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new qe({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester($.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester($.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(Xe.TERRAIN_SURFACE,this),this._handles.add([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),T((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),w),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),je.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),H(),Ae()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){const e=this.view.pointsOfInterest?.contentCameraOnSurface?.scale;if(e){const t=this.view.state.contentCamera;let i=Q(this.view,t.eye,t.viewForward,t.up).tilt;i>90&&(i=180-i);const r=2*(i/90)**2,s=X(this.view,e)-r;Math.abs(this._snapLevel-s)>Ye&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ie.ON:ie.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=A(),r=Y(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,A()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get spatialReference(){return this.tilingScheme?.spatialReference??null}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){const e=!this.renderingDisabled&&!this.opaque;this.view?._stage?.renderView.setRenderParameters({transparentTerrain:e})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,tt);return p(s)?null:Z(tt[0],tt[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=tt){const a=this.rootTiles;if(p(a)||!a.length)return null;if(0===a[0].layerInfo[se.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!R(s,r,s,this.tilingScheme?.spatialReference))return o.getLogger(this.declaredClass).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let n of a){if(!n.containsPoint(s))continue;for(;n&&!n.rendered&&!n.isLeaf;){let e=0;s[0]>.5*(n.extent[0]+n.extent[2])&&(e+=1),s[1]<.5*(n.extent[1]+n.extent[3])&&(e+=2),n=n.children[e]}const e=n.renderData;return(e?e.geometryState.samplerData:null)?n:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!M(e,tt,this.spatialReference))return o.getLogger(this.declaredClass).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(u(t))for(let e of t)if(e?.containsPoint(tt)){for(;!e.isLeaf&&!e.rendered;){let t=0;tt[0]>e.children[0].extent[2]&&(t+=1),tt[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereElevationBounds(e,t,i,r,s){if(tt[0]=e,tt[1]=t,tt[2]=i,tt[3]=r,!R(tt,s,tt,this.tilingScheme?.spatialReference))return o.getLogger(this.declaredClass).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const l=e=>{if(e&&O(e.extent,tt))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)l(t)},h=this.rootTiles;if(u(h))for(const o of h)l(o);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!M(e,tt,this.spatialReference))return o.getLogger(this.declaredClass).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;tt[3]=t;let i=null;const r=e=>{if(e&&O(e.extent,tt))if(e.isLeaf||e.rendered){const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}else for(const t of e.children)r(t)},s=this.rootTiles;if(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1&&!this.hasCompositeBlendMode,this._renderer.isTransparent=this._allSurfaceLayersTransparent();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?re.UNFADED:re.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(fe(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return rt[0]=e,rt[1]=t,rt[2]=i,s.init(rt,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=it;let s=t.rootTilesInExtent(e,i,5*de);if(u(this.rootTiles)){if(s.length>de)return void o.getLogger(this.declaredClass).warn(pe);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Je);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Je(t,e.lij)))>-1)||(this._purgeTile(e,!0),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>de&&(o.getLogger(this.declaredClass).warn(ue),s=t.rootTilesInExtent(e,i,de)),this._setRootTiles(s.map((e=>this._newRootTile(e))));I(i,this._rootTilesExtent)||(this._rootTilesExtent=A(i)),this._visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._allTiles.forEach((e=>{e.isLoaded&&this._prepareToLoadTile(e)})),this._allTiles.forAll((e=>{e.isLoaded&&(this._updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e))})),this._updatingRootTiles=!1,this.checkAllTileWaterproofness()}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ie.SPLIT&&t.setPendingUpdate(Ie.SPLIT),this._loadTile(t),this.deferTileNeighborUpdate||t.checkGeometryWaterproofness(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ie.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(p(e))return;const t=Ne(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.extent,a=this._viewProjectionMatrix;this.setTileTreeDirty();const n=this._iteratorPool.acquire();for(n.reset(e);!n.done;){const e=n.next();e.updateClippingStatus(s)&&e.resetPendingUpdate(Ie.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Ie.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(a),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))}n.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=N()),k(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,k(this._frustum,e.frustum),E(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),U(this._eyePosRenderSR,t.eye),R(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(Ze(e)?(this._loadChildren(e),this.deferTileNeighborUpdate||(this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness())))):et(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e),this._elevationUpdate(e),this._usedMemory=null,this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e)}_updateTileNeighborsAfterGeometryChange(e,t){if(this.deferTileNeighborUpdate){const t=this.neighborTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}else e.updateNeighborsAfterGeometryChange(t)}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ie.TEXTURE_FADING)?Ie.TEXTURE_FADING:!!e.resetPendingUpdate(Ie.TEXTURE_NOFADING)&&Ie.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_elevationUpdate(e){at.spatialReference=this.spatialReference,at.tile=e,at.extent=e.extent,this.emit("elevation-change",at)}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done?this.requestUpdate():this._usedMemory=this._recalculateUsedMemory(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next(),i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i!==Ie.SPLIT){if(e.resetPendingUpdate(Ie.SPLIT)&&e.updateAgentSuspension(),i===Ie.VSPLITMERGE&&e.updateAgents(se.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ie.MERGE),e.resetPendingUpdate(Ie.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}else e.resetPendingUpdate(Ie.MERGE),e.isLeaf&&(e.setPendingUpdate(Ie.SPLIT),t.skipSubtree())}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(ke(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_prepareBatchTileGeometryUpdate(){Te(0===this.neighborTilesToUpdate.size),this.enableBatchTileGeometryUpdates&&(this.deferTileNeighborUpdate=!0)}_batchUpdateUpdatedTileNeighbors(){if(this.enableBatchTileGeometryUpdates){this.deferTileNeighborUpdate=!1;const e=this.neighborTilesToUpdate;(()=>{const t=()=>{for(const t of e)t.updateNeighborsWithChangedEdgeResolution()};(()=>{for(const t of e)t.updateNeighborDataAndGeometryIfNeeded()})(),t(),e.clear()})()}}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate(),this._prepareBatchTileGeometryUpdate();let i=!1,r=!1;for(;!e.done;){r=!0;let s=!1;const a=!this._allTiles.some((r=>{if(!i&&!r.loadable)return e.done;let a=r;if(r.resetPendingUpdate(Ie.MERGE)){if(!t)return r.setPendingUpdate(Ie.MERGE),e.done;for(;a.parent?.resetPendingUpdate(Ie.MERGE);)a=a.parent;this._mergeTile(a),s=!0,e.madeProgress()}else r.resetPendingUpdate(Ie.SPLIT)&&(this._splitTile(r),s=!0,e.madeProgress());return!e.done&&a===r&&r.resetPendingUpdate(Ie.RENDERDATA)&&(this._updateRenderData(r),e.madeProgress()),e.done}));if(s&&(this._allTilesSorted=!1,this._allTilesDirty=!0),a){if(!i){i=!0;continue}if(!s)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}r||(this._allTilesDirty=!0),this._batchUpdateUpdatedTileNeighbors(),this._sortTiles(e)}_updateElevation(e){return this._prepareBatchTileGeometryUpdate(),this._allTiles.some((t=>(t.resetPendingUpdate(Ie.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),this._batchUpdateUpdatedTileNeighbors(),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(He.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ce}_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(){u(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e,!1))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i],!1)||t;return e.unsetChildren(),t}_purgeTile(e,t){const i=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),t&&this._updateTileNeighborsAfterGeometryChange(e),this._tilePool.release(e),i}_unloadTile(e){this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e),e.unload(this._renderer)}_splitTile(e){fe(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(Ie.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){nt.spatialReference=this.spatialReference,nt.extent=e.extent,nt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",nt)}_createTile(e,t,i,r){fe(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ie.SPLIT&&s.setPendingUpdate(Ie.SPLIT),s}_mergeTile(e){fe(!e.hasPendingUpdate(Ie.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(fe(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._updateTileNeighborsAfterGeometryChange(e),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_checkTileAndNeighborsWaterproofness(e){e.checkGeometryWaterproofness(),this._checkTileNeighborsWaterproofness(e)}_checkTileNeighborsWaterproofness(e){Ce&&e.forallNeighbors((e=>!!e.isLoaded&&(e.checkGeometryWaterproofness(),!0)))}_loadChildren(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e),fe(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._prepareToLoadTile(e))),t.forEach((e=>this._loadTilePrepared(e))),this._updateTileNeighborsAfterGeometryChange(e,e.level+1),this.deferTileNeighborUpdate||(t.forEach((e=>e.updateNeighborsWithChangedEdgeResolution())),t.forEach((e=>e.checkGeometryWaterproofness())),this._checkTileNeighborsWaterproofness(e))}_loadParent(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._updateTileNeighborsAfterGeometryChange(t),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(t)}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_postLoadTile(e){e.setPendingUpdate(Ie.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_loadTile(e){e.load(this._renderer),this._postLoadTile(e)}_loadTilePrepared(e){e.loadPrepared(this._renderer),this._postLoadTile(e)}_prepareToLoadTile(e){e.prepareToLoad(this._renderer)}_elevationDataArrived(e,t,i){const r=new ee(e.lij,e.extent,i);e.dataArrived(t,se.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=ze){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),ye(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allSurfaceLayersTransparent(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(ve(t)&&!W(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if(we(e)){const t=Le(e.layer.parent)?"normal":e.layer.blendMode;if(We(Fe[t]))return!0}return!1}_layerClassFromLayerView(e){return Se(e)?se.ELEVATION:se.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(re.UNFADED)))),t.push(T((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),we(e)&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(re.UNFADED)}))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!ye(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===se.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ae){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),o=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 l=e.indexOf(i[t]);n[t]=l,t!==l&&(a=!0),l>-1&&(o[l]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(o,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===se.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(se.MAP),e===re.IMMEDIATE?this.renderer.updateTileTexture(t,Ie.TEXTURE_NOFADING):t.updateRenderData(se.MAP,e)})),this._renderer.isTransparent=this._allSurfaceLayersTransparent()}_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=He.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,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===se.ELEVATION?Se(i)?this._requestElevationTileData(e,i,r):Promise.reject():ve(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(m(i))return;const s=this._layerIndexByUid[se.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):o.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer %d %s",se.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,se.ELEVATION,t,i),this.requestUpdate())};if(Ee(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:_e,signal:i.signal}).then((e=>{if(!m(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);o.getLogger(this.declaredClass).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:_e},i.signal))).then((e=>{e?r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue}):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,xe(s),m(i)||(this._dataMissing(e,se.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?xe(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(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,n)}if(De(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(Ue(t)&&Ee(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return o.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let l=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);q(t.layer)&&t.layer.refreshTimestamp&&(l+=`${l.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(l,h,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(se.MAP,t.uid);u(r)?e.dataArrived(r,se.MAP,i):(xe(i),o.getLogger(this.declaredClass).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);u(s)?e.dataMissing(s,t,r):o.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?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 u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return fe(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){st.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&st.push(e)}));const t=st.toArray();return Be(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTileWaterproofness(){if(!Ce)return;const e=this.rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.indices?.length>0??!1,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{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 shadingEnabled(){return this._renderer.shadingEnabled}get isWebMercator(){return!!this.tilingScheme?.spatialReference.isWebMercator}get isWebMercatorOnPlateeCarree(){return this.isWebMercator&&B(this.view?.renderSpatialReference)}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+(u(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){Pe(e)}enableWaterproofnessChecks(e){Re(e)}};e([S()],$e.prototype,"_renderer",void 0),e([S()],$e.prototype,"_hasPendingUpdates",void 0),e([S()],$e.prototype,"_asyncWorkItems",void 0),e([S()],$e.prototype,"_allTilesDirty",void 0),e([S()],$e.prototype,"_allTilesSorted",void 0),e([S()],$e.prototype,"_viewChanged",void 0),e([S({readOnly:!0})],$e.prototype,"_watchUpdatingTracking",void 0),e([S()],$e.prototype,"_frameTask",void 0),e([S({readOnly:!0})],$e.prototype,"snapLevel",null),e([S({readOnly:!0})],$e.prototype,"lodSnapping",null),e([S({constructOnly:!0})],$e.prototype,"view",void 0),e([S()],$e.prototype,"_userClippingExtent",null),e([S()],$e.prototype,"_rootTilesExtent",void 0),e([S({readOnly:!0})],$e.prototype,"extent",null),e([S({readOnly:!0})],$e.prototype,"groundExtent",null),e([S({readOnly:!0})],$e.prototype,"_tilingSchemeExtent",null),e([S({readOnly:!0})],$e.prototype,"updating",null),e([S(K)],$e.prototype,"updatingProgress",void 0),e([S({readOnly:!0})],$e.prototype,"updatingProgressValue",null),e([S()],$e.prototype,"_maxNumUpdating",void 0),e([S({aliasOf:"view.map.ground.opacity"})],$e.prototype,"baseOpacity",void 0),e([S()],$e.prototype,"hasCompositeBlendMode",void 0),e([S({readOnly:!0})],$e.prototype,"overlayManager",void 0),e([S({readOnly:!0})],$e.prototype,"viewingMode",null),e([S()],$e.prototype,"maxTextureScale",void 0),e([S({readOnly:!0})],$e.prototype,"ready",null),e([S({value:le.FRONT_TO_BACK})],$e.prototype,"renderOrder",null),e([S({readOnly:!0})],$e.prototype,"rootTiles",void 0),e([S({readOnly:!0})],$e.prototype,"spatialReference",null),e([S({type:t,aliasOf:"view.map.ground.surfaceColor"})],$e.prototype,"backgroundColor",void 0),e([S({value:!1})],$e.prototype,"slicePlaneEnabled",null),e([S({readOnly:!0})],$e.prototype,"tilingScheme",void 0),e([S({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],$e.prototype,"tilingSchemeLocked",void 0),e([S({readOnly:!0})],$e.prototype,"tilingSchemeLogic",void 0),e([S({value:!0})],$e.prototype,"velvetOverground",null),e([L("_renderer.wireframe")],$e.prototype,"wireframe",void 0),e([S({value:!1})],$e.prototype,"suspended",null),e([S({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],$e.prototype,"textureFadeDuration",void 0),e([S()],$e.prototype,"_layerViewsDirty",void 0),e([L("_renderer.renderPatchBorders")],$e.prototype,"renderPatchBorders",void 0),e([L("_renderer.renderingDisabled")],$e.prototype,"renderingDisabled",void 0),$e=e([b("esri.views.3d.terrain.TerrainSurface")],$e);const Ke=$e;function Je(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Ze(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>Ze(e))))}function et(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const tt=C(),it=A(),rt=[0,0,0],st=new _,at={spatialReference:null,tile:null,extent:null,context:"ground"},nt={spatialReference:null,extent:null,scale:0};export{Ke as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{property as L}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{m as b}from"../../../chunks/mat4.js";import{c as E}from"../../../chunks/mat4f64.js";import{c as D}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as x}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as C}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as P,projectPointToVector as R}from"../../../geometry/projection.js";import{getReferenceEllipsoid as M}from"../../../geometry/projectionEllipsoid.js";import{create as j,equals as A,intersection as I,intersectsSphere as V}from"../../../geometry/support/aaBoundingRect.js";import{create as O,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as k}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as B}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as q}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as G}from"../../../layers/support/layerUtils.js";import{acquireDecoder as W}from"../../../layers/support/LercDecoder.js";import{printAllocations as F}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as H,scaleToZoom as Q}from"../support/cameraUtils.js";import X from"../support/debugFlags.js";import{toBoundingRect as z}from"../support/extentUtils.js";import{ClientType as Y}from"../support/index.js";import{updatingProgress as $}from"../support/updatingProperties.js";import{ElevationBounds as K}from"./ElevationBounds.js";import{sampleElevation as J,ElevationData as Z}from"./ElevationData.js";import{create as ee}from"./ExtentHelper.js";import{LODSnapping as te,TextureUpdate as ie}from"./interfaces.js";import{LayerClass as re,LayerClasses as se}from"./LayerClass.js";import{OverlayManager as ae}from"./OverlayManager.js";import{PlanarPatch as ne}from"./PlanarPatch.js";import{RenderOrder as le}from"./RenderOrder.js";import{SphericalPatch as oe}from"./SphericalPatch.js";import{MAX_ROOT_TILES as he,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as de,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as pe,MAX_MEMORY_LOD_BIAS as ue,ELEVATION_NODATA_VALUE as ce}from"./TerrainConst.js";import _e from"./TerrainRenderer.js";import ge from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as me,internalAssert as fe,isSurfaceLayerView as Te,isMapTileLayerView as ye,isBlendableLayerView as ve,isGroupLayer as we,isElevationLayerView as Le,isVectorTileLayerView as Se,useFetchTileForLayer as be,isImageryTileLayerView as Ee,isTileLayerView as De,releaseTileData as Ue,ENABLE_WATERPROOFNESS_TESTS as xe,enableTerrainInternalChecks as Ce,enableTerrainWaterproofnessChecks as Pe}from"./terrainUtils.js";import{SplitLimits as Re,Tile as Me}from"./Tile.js";import{printAllocations as je}from"./TilePerLayerInfo.js";import{TileUpdate as Ae}from"./TileUpdate.js";import{IteratorPreorder as Ie,IteratorPostorder as Ve,hasLoadableSiblings as Oe,sortTilesByPOI as Ne,sortTiles as ke}from"./tileUtils.js";import{TilingSchemeLogic as Be}from"./TilingSchemeLogic.js";import{UpsampleInfo as qe}from"./UpsampleInfo.js";import{isCompositeBlendMode as Ge,blendModeFromString as We}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as Fe}from"../webgl-engine/lib/basicInterfaces.js";import{ImmediateTask as He,TaskPriority as Qe,noBudget as Xe}from"../../support/Scheduler.js";const ze=.25;let Ye=class extends(a.EventedMixin(i)){constructor(e){super(e),this._elevationBounds=new K,this._iteratorPool=new c(Ie,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new Ve,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new ge,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new Re,this._snapLevel=1/0,this._frustum=O(),this._viewProjectionMatrix=E(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new C,this._frameTask=He,this._allTiles=new _,this._upsampleInfoPool=new c(qe),this._rootTilesExtent=j(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.backgroundColor=null,this._updatingRootTiles=!1,this.deferTileNeighborUpdate=!1,this.neighborTilesToUpdate=new Set,this.enableBatchTileGeometryUpdates=!0,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._layerViewsDirty=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=W(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(ne):new c(oe);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new q(e.newCache("elevation-query")),this._set("overlayManager",new ae({surface:this})),this._handles.add([T((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new _e({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:M(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles}),this._handles.add([T((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),T((()=>this.hasCompositeBlendMode),(()=>{this._updateBaseOpacity(this.baseOpacity)}),y),T((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),T((()=>X.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&X.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=ee(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new Be({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(Y.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(Y.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(Qe.TERRAIN_SURFACE,this),this._handles.add([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),T((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),w),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Me.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),F(),je()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){const e=this.view.pointsOfInterest?.contentCameraOnSurface?.scale;if(e){const t=this.view.state.contentCamera;let i=H(this.view,t.eye,t.viewForward,t.up).tilt;i>90&&(i=180-i);const r=2*(i/90)**2,s=Q(this.view,e)-r;Math.abs(this._snapLevel-s)>ze&&(Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s)}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?te.ON:te.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=j(),r=z(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 u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get spatialReference(){return this.tilingScheme?.spatialReference??null}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._updateTransparentTerrain()}_updateTransparentTerrain(){const e=!this.renderingDisabled&&!this.opaque;this.view?._stage?.renderView.setRenderParameters({transparentTerrain:e})}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}get wireframe(){return this._renderer.wireframe}set wireframe(e){this._renderer.wireframe=e}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,et);return p(s)?null:J(et[0],et[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=et){const a=this.rootTiles;if(p(a)||!a.length)return null;if(0===a[0].layerInfo[re.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!P(s,r,s,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let n of a){if(!n.containsPoint(s))continue;for(;n&&!n.rendered&&!n.isLeaf;){let e=0;s[0]>.5*(n.extent[0]+n.extent[2])&&(e+=1),s[1]<.5*(n.extent[1]+n.extent[3])&&(e+=2),n=n.children[e]}const e=n.renderData;return(e?e.geometryState.samplerData:null)?n:null}return null}get elevationBounds(){return this._elevationBounds}getScale(e){if(this.tilingScheme){if(!R(e,et,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(u(t))for(let e of t)if(e?.containsPoint(et)){for(;!e.isLeaf&&!e.rendered;){let t=0;et[0]>e.children[0].extent[2]&&(t+=1),et[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereElevationBounds(e,t,i,r,s){if(et[0]=e,et[1]=t,et[2]=i,et[3]=r,!P(et,s,et,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&V(e.extent,et))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},h=this.rootTiles;if(u(h))for(const l of h)o(l);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!R(e,et,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;et[3]=t;let i=null;const r=e=>{if(e&&V(e.extent,et))if(e.isLeaf||e.rendered){const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}else for(const t of e.children)r(t)},s=this.rootTiles;if(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1&&!this.hasCompositeBlendMode,this._renderer.isTransparent=this._allSurfaceLayersTransparent();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?ie.UNFADED:ie.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(me(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return it[0]=e,it[1]=t,it[2]=i,s.init(it,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=tt;let s=t.rootTilesInExtent(e,i,5*he);if(u(this.rootTiles)){if(s.length>he)return void l.getLogger(this.declaredClass).warn(de);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,Ke);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>Ke(t,e.lij)))>-1)||(this._purgeTile(e,!0),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>he&&(l.getLogger(this.declaredClass).warn(pe),s=t.rootTilesInExtent(e,i,he)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=j(i)),this._visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._allTiles.forEach((e=>{e.isLoaded&&this._prepareToLoadTile(e)})),this._allTiles.forAll((e=>{e.isLoaded&&(this._updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e))})),this._updatingRootTiles=!1,this.checkAllTileWaterproofness()}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ae.SPLIT&&t.setPendingUpdate(Ae.SPLIT),this._loadTile(t),this.deferTileNeighborUpdate||t.checkGeometryWaterproofness(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ae.GEOMETRY)&&this._updateTileGeometry(e)}_updateTilesVisibility(e){if(p(e))return;const t=Oe(e);let i=t?this._elevationBounds.min:1/0,r=t?this._elevationBounds.max:-1/0;const s=this.extent,a=this._viewProjectionMatrix;this.setTileTreeDirty();const n=this._iteratorPool.acquire();for(n.reset(e);!n.done;){const e=n.next();e.updateClippingStatus(s)&&e.resetPendingUpdate(Ae.GEOMETRY)&&this._updateTileGeometry(e),e.setPendingUpdate(Ae.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(a),e.renderData&&(i=Math.min(e.elevationBounds[0],i),r=Math.max(e.elevationBounds[1],r))}n.remove(),this._viewChanged=!0,this._allTilesDirty=!0,isFinite(i)&&isFinite(r)&&(this._elevationBounds.min===i&&this._elevationBounds.max===r||(this._elevationBounds.min=i,this._elevationBounds.max=r,this.emit("elevation-bounds-change",null)))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=O()),N(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,N(this._frustum,e.frustum),b(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),D(this._eyePosRenderSR,t.eye),P(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(Je(e)?(this._loadChildren(e),this.deferTileNeighborUpdate||(this._checkTileNeighborsWaterproofness(e),e.children.forEach((e=>e.checkGeometryWaterproofness())))):Ze(e)&&this._loadParent(e))}_updateTileGeometry(e){e.updateVisibility(),this._renderer.updateTileGeometry(e),this._updateTileNeighborsAfterGeometryChange(e),this._elevationUpdate(e),this._usedMemory=null,this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e)}_updateTileNeighborsAfterGeometryChange(e,t){if(this.deferTileNeighborUpdate){const t=this.neighborTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}else e.updateNeighborsAfterGeometryChange(t)}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ae.TEXTURE_FADING)?Ae.TEXTURE_FADING:!!e.resetPendingUpdate(Ae.TEXTURE_NOFADING)&&Ae.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_elevationUpdate(e){st.spatialReference=this.spatialReference,st.tile=e,st.extent=e.extent,this.emit("elevation-change",st)}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateTileStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),e.done?this.requestUpdate():this._usedMemory=this._recalculateUsedMemory(),this.notifyChange("updatingProgressValue")}_updateTileStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next(),i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i!==Ae.SPLIT){if(e.resetPendingUpdate(Ae.SPLIT)&&e.updateAgentSuspension(),i===Ae.VSPLITMERGE&&e.updateAgents(re.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ae.MERGE),e.resetPendingUpdate(Ae.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}else e.resetPendingUpdate(Ae.MERGE),e.isLeaf&&(e.setPendingUpdate(Ae.SPLIT),t.skipSubtree())}t.remove(),this.requestUpdate(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Ne(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_prepareBatchTileGeometryUpdate(){fe(0===this.neighborTilesToUpdate.size),this.enableBatchTileGeometryUpdates&&(this.deferTileNeighborUpdate=!0)}_batchUpdateUpdatedTileNeighbors(){if(this.enableBatchTileGeometryUpdates){this.deferTileNeighborUpdate=!1;const e=this.neighborTilesToUpdate;(()=>{const t=()=>{for(const t of e)t.updateNeighborsWithChangedEdgeResolution()};(()=>{for(const t of e)t.updateNeighborDataAndGeometryIfNeeded()})(),t(),e.clear()})()}}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate(),this._prepareBatchTileGeometryUpdate();let i=!1,r=!1;for(;!e.done;){r=!0;let s=!1;const a=!this._allTiles.some((r=>{if(!i&&!r.loadable)return e.done;let a=r;if(r.resetPendingUpdate(Ae.MERGE)){if(!t)return r.setPendingUpdate(Ae.MERGE),e.done;for(;a.parent?.resetPendingUpdate(Ae.MERGE);)a=a.parent;this._mergeTile(a),s=!0,e.madeProgress()}else r.resetPendingUpdate(Ae.SPLIT)&&(this._splitTile(r),s=!0,e.madeProgress());return!e.done&&a===r&&r.resetPendingUpdate(Ae.RENDERDATA)&&(this._updateRenderData(r),e.madeProgress()),e.done}));if(s&&(this._allTilesSorted=!1,this._allTilesDirty=!0),a){if(!i){i=!0;continue}if(!s)break;this._updateTilesVisibility(this.rootTiles)}else this._allTilesDirty=!0}r||(this._allTilesDirty=!0),this._batchUpdateUpdatedTileNeighbors(),this._sortTiles(e)}_updateElevation(e){return this._prepareBatchTileGeometryUpdate(),this._allTiles.some((t=>(t.resetPendingUpdate(Ae.GEOMETRY)&&(this._updateTileGeometry(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),this._batchUpdateUpdatedTileNeighbors(),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Fe.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ue}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){u(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e,!1))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i],!1)||t;return e.unsetChildren(),t}_purgeTile(e,t){const i=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),t&&this._updateTileNeighborsAfterGeometryChange(e),this._tilePool.release(e),i}_unloadTile(e){this.deferTileNeighborUpdate&&this.neighborTilesToUpdate.delete(e),e.unload(this._renderer)}_splitTile(e){me(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ae.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,this._emitTileScaleChange(e,t),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){at.spatialReference=this.spatialReference,at.extent=e.extent,at.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",at)}_createTile(e,t,i,r){me(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===Ae.SPLIT&&s.setPendingUpdate(Ae.SPLIT),s}_mergeTile(e){me(!e.hasPendingUpdate(Ae.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(me(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._updateTileNeighborsAfterGeometryChange(e),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e)),this._allTilesDirty=!0,++this._performanceInfo.numMerged,this._emitTileScaleChange(e)}_checkTileAndNeighborsWaterproofness(e){e.checkGeometryWaterproofness(),this._checkTileNeighborsWaterproofness(e)}_checkTileNeighborsWaterproofness(e){xe&&e.forallNeighbors((e=>!!e.isLoaded&&(e.checkGeometryWaterproofness(),!0)))}_loadChildren(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e),me(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._prepareToLoadTile(e))),t.forEach((e=>this._loadTilePrepared(e))),this._updateTileNeighborsAfterGeometryChange(e,e.level+1),this.deferTileNeighborUpdate||(t.forEach((e=>e.updateNeighborsWithChangedEdgeResolution())),t.forEach((e=>e.checkGeometryWaterproofness())),this._checkTileNeighborsWaterproofness(e))}_loadParent(e){this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(e);const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._updateTileNeighborsAfterGeometryChange(t),this.deferTileNeighborUpdate||this._checkTileAndNeighborsWaterproofness(t)}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_postLoadTile(e){e.setPendingUpdate(Ae.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e),this._elevationUpdate(e)}_loadTile(e){e.load(this._renderer),this._postLoadTile(e)}_loadTilePrepared(e){e.loadPrepared(this._renderer),this._postLoadTile(e)}_prepareToLoadTile(e){e.prepareToLoad(this._renderer)}_elevationDataArrived(e,t,i){const r=new Z(e.lij,e.extent,i);e.dataArrived(t,re.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=Xe){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),Te(s))if(this._basemapLayerViewHandles.has(s.uid)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allSurfaceLayersTransparent(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(ye(t)&&!G(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if(ve(e)){const t=we(e.layer.parent)?"normal":e.layer.blendMode;if(Ge(We[t]))return!0}return!1}_layerClassFromLayerView(e){return Le(e)?re.ELEVATION:re.MAP}_registerTiledLayerView(e){const t=[],i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(ie.UNFADED)))),t.push(T((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),ve(e)&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ie.UNFADED)}))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!Te(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===re.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of se){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===re.ELEVATION&&i.computeElevationBounds()}}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(re.MAP),e===ie.IMMEDIATE?this.renderer.updateTileTexture(t,Ae.TEXTURE_NOFADING):t.updateRenderData(re.MAP,e)})),this._renderer.isTransparent=this._allSurfaceLayersTransparent()}_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=Fe.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||Se(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===re.ELEVATION?Le(i)?this._requestElevationTileData(e,i,r):Promise.reject():ye(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(m(i))return;const s=this._layerIndexByUid[re.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer %d %s",re.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,re.ELEVATION,t,i),this.requestUpdate())};if(be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:ce,signal:i.signal}).then((e=>{if(!m(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);l.getLogger(this.declaredClass).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:ce},i.signal))).then((e=>{e?r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue}):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ue(s),m(i)||(this._dataMissing(e,re.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Ue(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Se(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(Ee(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(De(t)&&be(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);B(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,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(re.MAP,t.uid);u(r)?e.dataArrived(r,re.MAP,i):(Ue(i),l.getLogger(this.declaredClass).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);u(s)?e.dataMissing(s,t,r):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?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 u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return me(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 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:()=>{u(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){rt.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&rt.push(e)}));const t=rt.toArray();return ke(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTileWaterproofness(){if(!xe)return;const e=this.rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.indices?.length>0??!1,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{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 shadingEnabled(){return this._renderer.shadingEnabled}get isWebMercator(){return!!this.tilingScheme?.spatialReference.isWebMercator}get isWebMercatorOnPlateeCarree(){return this.isWebMercator&&k(this.view?.renderSpatialReference)}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+(u(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){Ce(e)}enableWaterproofnessChecks(e){Pe(e)}};e([L()],Ye.prototype,"_renderer",void 0),e([L()],Ye.prototype,"_hasPendingUpdates",void 0),e([L()],Ye.prototype,"_asyncWorkItems",void 0),e([L()],Ye.prototype,"_allTilesDirty",void 0),e([L()],Ye.prototype,"_allTilesSorted",void 0),e([L()],Ye.prototype,"_viewChanged",void 0),e([L({readOnly:!0})],Ye.prototype,"_watchUpdatingTracking",void 0),e([L()],Ye.prototype,"_frameTask",void 0),e([L({readOnly:!0})],Ye.prototype,"snapLevel",null),e([L({readOnly:!0})],Ye.prototype,"lodSnapping",null),e([L({constructOnly:!0})],Ye.prototype,"view",void 0),e([L()],Ye.prototype,"_userClippingExtent",null),e([L()],Ye.prototype,"_rootTilesExtent",void 0),e([L({readOnly:!0})],Ye.prototype,"extent",null),e([L({readOnly:!0})],Ye.prototype,"groundExtent",null),e([L({readOnly:!0})],Ye.prototype,"_tilingSchemeExtent",null),e([L({readOnly:!0})],Ye.prototype,"updating",null),e([L($)],Ye.prototype,"updatingProgress",void 0),e([L({readOnly:!0})],Ye.prototype,"updatingProgressValue",null),e([L()],Ye.prototype,"_maxNumUpdating",void 0),e([L({aliasOf:"view.map.ground.opacity"})],Ye.prototype,"baseOpacity",void 0),e([L()],Ye.prototype,"hasCompositeBlendMode",void 0),e([L({readOnly:!0})],Ye.prototype,"overlayManager",void 0),e([L({readOnly:!0})],Ye.prototype,"viewingMode",null),e([L()],Ye.prototype,"maxTextureScale",void 0),e([L({readOnly:!0})],Ye.prototype,"ready",null),e([L({value:le.FRONT_TO_BACK})],Ye.prototype,"renderOrder",null),e([L({readOnly:!0})],Ye.prototype,"rootTiles",void 0),e([L({readOnly:!0})],Ye.prototype,"spatialReference",null),e([L({type:t,aliasOf:"view.map.ground.surfaceColor"})],Ye.prototype,"backgroundColor",void 0),e([L({value:!1})],Ye.prototype,"slicePlaneEnabled",null),e([L({readOnly:!0})],Ye.prototype,"tilingScheme",void 0),e([L({readOnly:!0,aliasOf:"tilingSchemeLogic.tilingSchemeLocked"})],Ye.prototype,"tilingSchemeLocked",void 0),e([L({readOnly:!0})],Ye.prototype,"tilingSchemeLogic",void 0),e([L({value:!0})],Ye.prototype,"velvetOverground",null),e([L()],Ye.prototype,"wireframe",null),e([L({value:!1})],Ye.prototype,"suspended",null),e([L({readOnly:!0,aliasOf:"view.qualitySettings.tiledSurface.textureFadeDuration"})],Ye.prototype,"textureFadeDuration",void 0),e([L()],Ye.prototype,"_layerViewsDirty",void 0),e([L()],Ye.prototype,"renderPatchBorders",null),e([L()],Ye.prototype,"renderingDisabled",null),Ye=e([S("esri.views.3d.terrain.TerrainSurface")],Ye);const $e=Ye;function Ke(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Je(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>Je(e))))}function Ze(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const et=x(),tt=j(),it=[0,0,0],rt=new _,st={spatialReference:null,tile:null,extent:null,context:"ground"},at={spatialReference:null,extent:null,scale:0};export{$e 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.25/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as e}from"../../../core/mathUtils.js";import{isSome as t,abortMaybe as i,isNone as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{c as r,s as a}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{b as h,p as l,e as d,g as u,a as c,l as g}from"../../../chunks/vec3.js";import{c as f,u as p}from"../../../chunks/vec3f64.js";import{E as m}from"../../../chunks/common.js";import{getReferenceEllipsoid as _}from"../../../geometry/projectionEllipsoid.js";import{create as y,equals as A}from"../../../geometry/support/aaBoundingRect.js";import{c as E}from"../../../chunks/sphere.js";import{VectorTile as T}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as v}from"../support/StreamDataLoader.js";import{ElevationBounds as L}from"./ElevationBounds.js";import{ElevationTileAgent as M}from"./ElevationTileAgent.js";import{LODSnapping as I,TextureUpdate as D,NeighborIndex as N}from"./interfaces.js";import{LayerClasses as b,LayerClass as S}from"./LayerClass.js";import{MapTileAgent as x}from"./MapTileAgent.js";import{RasterTile as j}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as O,getElevationDesiredResolutionLevel as C}from"./TerrainConst.js";import{weakAssert as U,getLayerWithExtentRange as R,isBlendableLayerView as P,oppositeCorner as B,neighborCornerIndices as G,neighborEdgeIndices as V,oppositeEdge as W,internalAssert as w,ENABLE_TERRAIN_INTERNAL_CHECKS as q,isNorth as H,isSouth as F,isWest as k,isEast as X,ENABLE_WATERPROOFNESS_TESTS as z,isWestCorner as J,isNorthCorner as Y}from"./terrainUtils.js";import{TILE_AGENT_DONE as $}from"./TileAgent.js";import{TilePerLayerInfo as Q}from"./TilePerLayerInfo.js";import K from"./TileTexture.js";import{TileUpdate as Z}from"./TileUpdate.js";import{fallsWithinLayer as ee}from"./tileUtils.js";import{getGpuMemoryUsage as te}from"../../webgl/Util.js";const ie=f(),se=f(),ne=f(),re=.1;class ae{constructor(){this.fovX=0,this.fovY=0,this.relativeWidthLimit=0,this.relativeHeightLimit=0,this.maxLod=0,this.angledSplitBias=0,this.aboveGround=!0}}class oe{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=y(),this._elevationBounds=o(),this.layerInfo=[[],[]],this.extentInRadians=y(),this.centerAtSeaLevel=f(),this._center=[f(),E(),f()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemoryInternal=0,this._mapDataRefCount=0,this._screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0}static prune(){de.prune(0),ue.prune(0),Q.prune()}get _isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[ge.MIDDLE][3]}get screenDepth(){return this._screenDepth}get visible(){return this._dirty&&this.computeVisibility(),this._visible}computeVisibility(){this._dirty=!1;const e=this._intersectsClippingArea&&this._isVisible(this.surface.frustum);return e!==this._visible&&(this._visible=e,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setNeedsRender(),this.updateAgentSuspension()),this._visible}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setNeedsRender()),e}get shouldLoad(){if(this._surface.lodSnapping===I.ON){const e=this.level-this._surface.snapLevel;if(0===e)return!0;if(1===e)return!1}return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=_(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[ge.MIDDLE][3]=0,this.vlevel=e?e[0]:0,t&&t.elevationBounds?r(this._elevationBounds,t.elevationBounds):a(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this._screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of b){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=Q.acquire(this._surface.upsampleInfoPool),s===S.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,O)}release(){U(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of b){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null,this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){this.setMemoryDirty();const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemoryInternal)}get _cachedMemory(){return this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[S.MAP].reduce(((e,t)=>e+(t instanceof T?t.memoryUsage:0)),this._mapTileMemoryInternal)}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(t(this._usedMemory))return this._usedMemory;this._usedMemory=0,this._mapTileMemoryInternal=0;let e=0;for(const{data:t}of this.layerInfo[S.MAP])t instanceof T?e+=this._getTerrainDataMemory(t):this._mapTileMemoryInternal+=this._getTerrainDataMemory(t);const i=this._cpuImageMemorySize;for(const t of this.layerInfo[S.ELEVATION])this._usedMemory+=t.data?i:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemoryInternal+=te(this.renderData.textureDescriptor)),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemoryInternal+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===S.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===S.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof K?te(e.texture):e instanceof HTMLImageElement||e instanceof v?this._cpuImageMemorySize:e instanceof T||e instanceof j?e.memoryUsage:0}updateScreenDepth(e){const t=this._center[ge.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this._screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,i,s){if(t(e.frustum)&&(!this._intersectsClippingArea||!this._isVisible(e.frustum)))return Z.NONE;if(!this.visible)return Z.NONE;const n=this.level;h(ie,this._center[ge.MIDDLE],i);let r=l(ie),a=ge.MIDDLE;h(se,this._center[ge.TOP],i);const o=l(se);o<r&&(r=o,a=ge.TOP),h(se,this._center[ge.BOTTOM],i);const f=l(se);if(f<r&&(r=f,a=ge.BOTTOM),this._edgeLen2>r&&n<e.maxLod)return Z.SPLIT;const p=Math.sqrt(r),m=e.fovX*p*2,_=this._edgeLen/m,y=()=>{const t=n+Math.ceil(-Math.log2(e.relativeWidthLimit/_));return t!==this.vlevel?(this.vlevel=t,Z.VSPLITMERGE):Z.NONE_HIT_MAXLOD};if(s===I.ON){if(1===this._surface.snapLevel-n)return n>=e.maxLod?y():Z.SPLIT}const A=d(this.up,ie),E=this._elevationBounds[1]-this._elevationBounds[0],T=E/this.edgeLen;if(e.aboveGround&&A>0&&T<.001){if(A/p-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-T>0)return Z.NONE}if(_<e.relativeWidthLimit)return this.vlevel!==this.level?(this.vlevel=this.level,Z.VSPLITMERGE):Z.NONE;if(n>=e.maxLod)return y();if(n>6){h(se,this._center[a],i),u(ne,this.up,A),h(ne,ne,se);const t=l(ne);if(t>this.radius*this.radius){u(ne,ne,this.radius/Math.sqrt(t)),c(ne,ne,this._center[a]),h(ne,i,ne);const s=Math.min(1,(Math.abs(d(ne,this.up))+.5*E+this._curvatureHeight)/g(ne)),n=re/e.angledSplitBias,r=e.fovY*p*2;if(s*(this._edgeLen/r)<n*e.relativeHeightLimit)return Z.NONE}}return Z.SPLIT}setChildren(e,t,i,s){U(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}prepareToLoad(e){this.refMapData();for(const t of b)this._createOrUpdateAgents(0,t);e.updateTileGeometryState(this)}load(e){this.prepareToLoad(e),this.loadPrepared(e)}loadPrepared(e){e.loadTile(this)}unload(e){e.unloadTile(this);for(const t of b){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(le(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(Z.GEOMETRY),this.resetPendingUpdate(Z.TEXTURE_NOFADING),this.resetPendingUpdate(Z.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[S.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(le(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(A(e,this._clippingArea))return!1;const i=this._intersectsClippingArea,s=this._isWithinClippingArea;t(e)?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const n=s&&this._isWithinClippingArea,r=!(s||i||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||n||r||this.setPendingUpdate(Z.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of b){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==$&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(Z.SPLIT)||e!==S.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===Z.SPLIT||e===Z.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated)return console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),s.dataArrived(this),!0;if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;if(this.isLeaf)return null;const t=this._children[0].findByLij(e)||this._children[1].findByLij(e)||this._children[2].findByLij(e)||this._children[3].findByLij(e);return t||null}distanceToSquared(e){return l(h(ne,this._center[ge.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);U(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=this.layerInfo[t][e];s.data=i,s.dataInvalidated=!1,s.waitingAgents.forAll((e=>e.dataArrived(this))),s.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t){switch(e){case S.MAP:return this._updateTexture(t);case S.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===D.FADING?Z.TEXTURE_NOFADING:Z.TEXTURE_FADING),this.setPendingUpdate(e===D.FADING?Z.TEXTURE_FADING:Z.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(Z.GEOMETRY);for(const e of this.layerInfo[S.ELEVATION])e.pendingUpdates|=Z.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds;a(e,Number.MAX_VALUE,-Number.MAX_VALUE);const i=this.layerInfo[S.ELEVATION];let s=!0;for(const n of i)t(n.elevationBounds)&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(s=!1));s&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),this.updateRadiusAndCenter(),this._surface.setTileTreeDirty()}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]);u(ne,this.up,t),c(this._center[ge.MIDDLE],this.centerAtSeaLevel,ne),u(ne,this.up,e[0]),c(this._center[ge.TOP],this.centerAtSeaLevel,ne),u(ne,this.up,e[1]),c(this._center[ge.BOTTOM],this.centerAtSeaLevel,ne)}findElevationBoundsForLayer(e,i){const n=this.layerInfo[S.ELEVATION][e];if(t(n.elevationBounds)&&n.elevationBounds.level>=i)return;const r=this._surface.layerViewByIndex(e,S.ELEVATION),a=R(r);if(!ee(this,a,!1))return;const o=ce;let h=!1;if(n.data){const e=n.data;o.min=e.bounds[0],o.max=e.bounds[1],o.hasNoDataValues=e.hasNoDataValues,o.level=this.level,h=!0}else{let t,i,s=0;for(let n=this._parent;n&&(!i||s<C(this.level))&&(s=this.vlevel-n.level,t=i||t,i=n.layerInfo[S.ELEVATION][e].data,!(!i&&t&&s>=C(this.level)));n=n.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],o),o.min!==1/0&&(o.level=i.level,h=!0))}h&&(s(n.elevationBounds)&&(n.elevationBounds=new L),n.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==$&&(le(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:Q.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,D.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===$&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of b){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==$&&(i.loadingAgent.setSuspension(t),i.loadingAgent===$&&this.updateRenderData(e,D.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==$&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=$,!i.data&&s(i.upsampleInfo)&&this._createOrUpdateAgents(e+1,t)}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=(()=>{for(let s=e;s<i.length;++s){const e=this._surface.layerViewByIndex(s,t);if(P(e)&&"normal"!==e.layer.blendMode)return!0}return!1})(),n=this._isSuspended(t);for(let r=e;r<i.length;++r){const e=i[r];let a=!1;const o=this._surface.layerViewByIndex(r,t),h=R(o);if(e.loadingAgent?ee(this,h,!1)?(e.loadingAgent!==$&&e.loadingAgent.setSuspension(n),e.loadingAgent!==$&&(a=e.loadingAgent.update())):e.dispose():ee(this,h,!1)&&(e.loadingAgent=he(this,r,t,n),a=e.loadingAgent.startLoading(),a?e.loadingAgent===$&&this.setPendingUpdate(Z.GEOMETRY):(le(e.loadingAgent),e.loadingAgent=$)),e.loadingAgent===$&&this.updateRenderData(t,D.FADING),!s&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationBasedVerticesPerSide(t){const i=this.vlevel-this.level,s=Math.max(this.level-t,C(this.level)-i);return e(1+(this.maxTesselation>>s),2,this.maxTesselation+1)}get test(){return{cachedMemory:this._cachedMemory}}_findLIJ(e,i){if(!e)return null;const s=this.surface.rootTiles;if(t(s))for(const t of s)if(fe(t,e)){let s=t,n=e[0]-s.level-1;for(;n>=0&&!s.isLeaf&&!i(s);){const t=e[1]>>n&1,i=e[2]>>n&1;s=s.children[2*t+i],n--}return i(s)?s:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?pe(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===N.NORTH_EAST?1:e===N.NORTH_WEST?0:e===N.SOUTH_WEST?2:3;let s=this;for(;!(s.isLeaf||t&&t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)}forAllSubtreeOnSide(e,t){const i=e===N.NORTH?[0,1]:e===N.NORTH_EAST?[1]:e===N.EAST?[1,3]:e===N.SOUTH_EAST?[3]:e===N.SOUTH?[2,3]:e===N.SOUTH_WEST?[2]:e===N.WEST?[0,2]:[0],s=e=>{t(e)||e.isLeaf||i.forEach((t=>s(e.children[t])))};s(this)}forallNeighbors(e){G.forEach((t=>this.findNeighborCornerTileExact(t,e))),V.forEach((t=>this.findNeighborTile(t,(t=>t.level===this.level||e(t)))?.forAllSubtreeOnSide(W(t),e)))}getNeighborEdgeStartVertexIndex(e,t){const i=t??this.findNeighborTile(V[e],(e=>e.isLoaded));if(!i)return 0;const s=this.level-i.level;if(w(!q||s>=0),0===s)return 0;const n=2**s,r=1==(1&e),a=r?0:1,o=i.lij[a+1]*n,h=this.lij[a+1],l=h-o,d=r?n-1-l:l;return q&&(w(o<=h&&h<o+n),w(0<=d&&d<n)),d}_updateNeighborsWithChangedEdgeResolution(){for(let e=0;e<4;++e)if(this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]){const t=V[e],i=this.findNeighborTile(t,(e=>e.isLoaded||e.level===this.level));if(!i)continue;if(!i.isLoaded){w(!i.isLeaf);const s=(e+2)%4,n=W(t);i.forAllSubtreeOnSide(n,(e=>e.isLoaded?(e.updateEdgeAfterResolutionChange(s),!0):(w(!e.isLeaf),!1)))}this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]=!1}}updateNeighborDataAndGeometryIfNeeded(){this.isLoaded&&this.renderData.updateNeighborDataAndGeometryIfNeeded()}updateNeighborsAfterGeometryChange(e=this.level){this.forEachLoadedNeighbor((e=>this._updateNeighbor(e))),V.forEach((t=>{this.findNeighborTile(t,(t=>t.isLoaded&&t.level<e))?.updateNeighborsWithChangedEdgeResolution()}))}updateNeighborsWithChangedEdgeResolution(){this.isLoaded&&this._updateNeighborsWithChangedEdgeResolution()}updateEdgeAfterResolutionChange(e){this.renderData.updateEdgeAfterResolutionChange(e)}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach(((t,s)=>{const n=this.findNeighborTile(t,i);null!=n&&n!==this&&n.forAllSubtreeOnSide(W(t),(t=>!!t.isLoaded&&(e(t),!0)));const r=this.renderData?.geometryState?.neighborData;r&&(r.modifiedEdgeResolutions[s]=!1)})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));w(!s||ye(this,s,t)),s?.isLoaded&&e(s)}))}_updateNeighbor(e){e?.isLoaded&&e.updateNeighborDataAndGeometryIfNeeded()}getNeighborLIJ(e,t){const i=H(t)?-1:F(t)?1:0,s=k(t)?-1:X(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){return this.extent[1]+m>=this.surface.extent[1]}compareLIJs(e){const t=this.lij,i=t[0],s=e[0];if(i===s)return[t,e];const n=i-s;if(n<0){const i=2**-n;return[[s,t[1]*i,t[2]*i],e]}{const s=2**n;return[t,[i,e[1]*s,e[2]*s]]}}checkGeometryWaterproofness(){z&&(w(this.isLoaded),this.renderData.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(H(e)&&t[3]+s>=i[3])return!1;if(F(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&k(e)&&t[0]-s<=i[0])&&!(!n&&X(e)&&t[2]+s>=i[2])}}function he(e,t,i,s){const n=i===S.ELEVATION?ue.acquire():de.acquire();return n.init(e,t,i,s),n}function le(e){e.dispose(),e instanceof M?ue.release(e):e instanceof x&&de.release(e)}const de=new n(x),ue=new n(M),ce=new L;var ge;function fe(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=Math.floor(t[1]/2**n),a=Math.floor(t[2]/2**n);return r===e.lij[1]&&a===e.lij[2]}function pe(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function me(e,t,i){return Math.abs(e-t)<=i}function _e(e,t,i){if(s(e)||s(t))return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===N.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===N.WEST)return!0}const n=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case N.NORTH:return me(e.extent[3],t.extent[1],n);case N.SOUTH:return me(e.extent[1],t.extent[3],n);case N.EAST:return me(e.extent[2],t.extent[0],n)||me(e.extent[2],-t.extent[0],n);case N.WEST:return me(e.extent[0],t.extent[2],n)||me(e.extent[0],-t.extent[2],n)}}function ye(e,t,i){return!s(e)&&!s(t)&&t!==e&&(e.level>=t.level?Ae(e,t,i):Ae(t,e,B(i)))}function Ae(e,t,i){w(e.level>=t.level);const s=J(i),n=Y(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],h=[s?a[2]:a[0],n?a[1]:a[3]],l=1e-5*(r[2]-r[0]),d=me(o[0],h[0],l)||e.surface.isGlobal&&me(o[0],-h[0],l),u=me(o[1],h[1],l);if(d&&u)return!0;if(e.level===t.level)return w(!1),!1;if(!d&&!u)return w(!1),!1;const c=d?Ee(a[1],a[3],r[1],r[3],l):Ee(a[0],a[2],r[0],r[2],l);return w(c),c}function Ee(e,t,i,s,n=m){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(ge||(ge={}));export{ge as CenterPosition,ae as SplitLimits,oe as Tile,me as almostEquals,ye as isCornerNeighbor,_e as isEdgeNeighbor};
5
+ import{clamp as e}from"../../../core/mathUtils.js";import{isSome as t,abortMaybe as i,isNone as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{c as r,s as a}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{b as h,p as l,e as d,g as u,a as c,l as g}from"../../../chunks/vec3.js";import{c as f,u as p}from"../../../chunks/vec3f64.js";import{g as m}from"../../../chunks/common.js";import{getReferenceEllipsoid as _}from"../../../geometry/projectionEllipsoid.js";import{create as y,equals as A}from"../../../geometry/support/aaBoundingRect.js";import{c as E}from"../../../chunks/sphere.js";import{VectorTile as T}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as v}from"../support/StreamDataLoader.js";import{ElevationBounds as L}from"./ElevationBounds.js";import{ElevationTileAgent as M}from"./ElevationTileAgent.js";import{LODSnapping as D,TextureUpdate as I,NeighborIndex as N}from"./interfaces.js";import{LayerClasses as b,LayerClass as S}from"./LayerClass.js";import{MapTileAgent as x}from"./MapTileAgent.js";import{RasterTile as j}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as O,getElevationDesiredResolutionLevel as C}from"./TerrainConst.js";import{weakAssert as U,getLayerWithExtentRange as R,isBlendableLayerView as P,oppositeCorner as B,neighborCornerIndices as G,neighborEdgeIndices as V,oppositeEdge as W,internalAssert as w,ENABLE_TERRAIN_INTERNAL_CHECKS as q,isNorth as H,isSouth as F,isWest as k,isEast as X,ENABLE_WATERPROOFNESS_TESTS as z,isWestCorner as J,isNorthCorner as Y}from"./terrainUtils.js";import{TILE_AGENT_DONE as $}from"./TileAgent.js";import{TilePerLayerInfo as Q}from"./TilePerLayerInfo.js";import K from"./TileTexture.js";import{TileUpdate as Z}from"./TileUpdate.js";import{fallsWithinLayer as ee}from"./tileUtils.js";import{getGpuMemoryUsage as te}from"../../webgl/Util.js";const ie=f(),se=f(),ne=f(),re=.1;class ae{constructor(){this.fovX=0,this.fovY=0,this.relativeWidthLimit=0,this.relativeHeightLimit=0,this.maxLod=0,this.angledSplitBias=0,this.aboveGround=!0}}class oe{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=y(),this._elevationBounds=o(),this.layerInfo=[[],[]],this.extentInRadians=y(),this.centerAtSeaLevel=f(),this._center=[f(),E(),f()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemoryInternal=0,this._mapDataRefCount=0,this._screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0}static prune(){de.prune(0),ue.prune(0),Q.prune()}get _isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[ge.MIDDLE][3]}get screenDepth(){return this._screenDepth}get visible(){return this._dirty&&this.computeVisibility(),this._visible}computeVisibility(){this._dirty=!1;const e=this._intersectsClippingArea&&this._isVisible(this.surface.frustum);return e!==this._visible&&(this._visible=e,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension()),this._visible}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}get shouldLoad(){if(this._surface.lodSnapping===D.ON){const e=this.level-this._surface.snapLevel;if(0===e)return!0;if(1===e)return!1}return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=_(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[ge.MIDDLE][3]=0,this.vlevel=e?e[0]:0,t&&t.elevationBounds?r(this._elevationBounds,t.elevationBounds):a(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this._screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of b){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=Q.acquire(this._surface.upsampleInfoPool),s===S.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,O)}release(){U(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of b){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null,this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){this.setMemoryDirty();const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemoryInternal)}get _cachedMemory(){return this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[S.MAP].reduce(((e,t)=>e+(t instanceof T?t.memoryUsage:0)),this._mapTileMemoryInternal)}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(t(this._usedMemory))return this._usedMemory;this._usedMemory=0,this._mapTileMemoryInternal=0;let e=0;for(const{data:t}of this.layerInfo[S.MAP])t instanceof T?e+=this._getTerrainDataMemory(t):this._mapTileMemoryInternal+=this._getTerrainDataMemory(t);const i=this._cpuImageMemorySize;for(const t of this.layerInfo[S.ELEVATION])this._usedMemory+=t.data?i:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemoryInternal+=te(this.renderData.textureDescriptor)),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemoryInternal+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===S.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===S.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof K?te(e.texture):e instanceof HTMLImageElement||e instanceof v?this._cpuImageMemorySize:e instanceof T||e instanceof j?e.memoryUsage:0}updateScreenDepth(e){const t=this._center[ge.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this._screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,i,s){if(t(e.frustum)&&(!this._intersectsClippingArea||!this._isVisible(e.frustum)))return Z.NONE;if(!this.visible)return Z.NONE;const n=this.level;h(ie,this._center[ge.MIDDLE],i);let r=l(ie),a=ge.MIDDLE;h(se,this._center[ge.TOP],i);const o=l(se);o<r&&(r=o,a=ge.TOP),h(se,this._center[ge.BOTTOM],i);const f=l(se);if(f<r&&(r=f,a=ge.BOTTOM),this._edgeLen2>r&&n<e.maxLod)return Z.SPLIT;const p=Math.sqrt(r),m=e.fovX*p*2,_=this._edgeLen/m,y=()=>{const t=n+Math.ceil(-Math.log2(e.relativeWidthLimit/_));return t!==this.vlevel?(this.vlevel=t,Z.VSPLITMERGE):Z.NONE_HIT_MAXLOD};if(s===D.ON){if(1===this._surface.snapLevel-n)return n>=e.maxLod?y():Z.SPLIT}const A=d(this.up,ie),E=this._elevationBounds[1]-this._elevationBounds[0],T=E/this.edgeLen;if(e.aboveGround&&A>0&&T<.001){if(A/p-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-T>0)return Z.NONE}if(_<e.relativeWidthLimit)return this.vlevel!==this.level?(this.vlevel=this.level,Z.VSPLITMERGE):Z.NONE;if(n>=e.maxLod)return y();if(n>6){h(se,this._center[a],i),u(ne,this.up,A),h(ne,ne,se);const t=l(ne);if(t>this.radius*this.radius){u(ne,ne,this.radius/Math.sqrt(t)),c(ne,ne,this._center[a]),h(ne,i,ne);const s=Math.min(1,(Math.abs(d(ne,this.up))+.5*E+this._curvatureHeight)/g(ne)),n=re/e.angledSplitBias,r=e.fovY*p*2;if(s*(this._edgeLen/r)<n*e.relativeHeightLimit)return Z.NONE}}return Z.SPLIT}setChildren(e,t,i,s){U(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}prepareToLoad(e){this.refMapData();for(const t of b)this._createOrUpdateAgents(0,t);e.updateTileGeometryState(this)}load(e){this.prepareToLoad(e),this.loadPrepared(e)}loadPrepared(e){e.loadTile(this)}unload(e){e.unloadTile(this);for(const t of b){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(le(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(Z.GEOMETRY),this.resetPendingUpdate(Z.TEXTURE_NOFADING),this.resetPendingUpdate(Z.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[S.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(le(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(A(e,this._clippingArea))return!1;const i=this._intersectsClippingArea,s=this._isWithinClippingArea;t(e)?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const n=s&&this._isWithinClippingArea,r=!(s||i||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||n||r||this.setPendingUpdate(Z.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of b){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==$&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(Z.SPLIT)||e!==S.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===Z.SPLIT||e===Z.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated)return console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),s.dataArrived(this),!0;if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;if(this.isLeaf)return null;const t=this._children[0].findByLij(e)||this._children[1].findByLij(e)||this._children[2].findByLij(e)||this._children[3].findByLij(e);return t||null}distanceToSquared(e){return l(h(ne,this._center[ge.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);U(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=this.layerInfo[t][e];s.data=i,s.dataInvalidated=!1,s.waitingAgents.forAll((e=>e.dataArrived(this))),s.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t){switch(e){case S.MAP:return this._updateTexture(t);case S.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===I.FADING?Z.TEXTURE_NOFADING:Z.TEXTURE_FADING),this.setPendingUpdate(e===I.FADING?Z.TEXTURE_FADING:Z.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(Z.GEOMETRY);for(const e of this.layerInfo[S.ELEVATION])e.pendingUpdates|=Z.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds;a(e,Number.MAX_VALUE,-Number.MAX_VALUE);const i=this.layerInfo[S.ELEVATION];let s=!0;for(const n of i)t(n.elevationBounds)&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(s=!1));s&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),this.updateRadiusAndCenter(),this._surface.setTileTreeDirty()}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]);u(ne,this.up,t),c(this._center[ge.MIDDLE],this.centerAtSeaLevel,ne),u(ne,this.up,e[0]),c(this._center[ge.TOP],this.centerAtSeaLevel,ne),u(ne,this.up,e[1]),c(this._center[ge.BOTTOM],this.centerAtSeaLevel,ne)}findElevationBoundsForLayer(e,i){const n=this.layerInfo[S.ELEVATION][e];if(t(n.elevationBounds)&&n.elevationBounds.level>=i)return;const r=this._surface.layerViewByIndex(e,S.ELEVATION),a=R(r);if(!ee(this,a,!1))return;const o=ce;let h=!1;if(n.data){const e=n.data;o.min=e.bounds[0],o.max=e.bounds[1],o.hasNoDataValues=e.hasNoDataValues,o.level=this.level,h=!0}else{let t,i,s=0;for(let n=this._parent;n&&(!i||s<C(this.level))&&(s=this.vlevel-n.level,t=i||t,i=n.layerInfo[S.ELEVATION][e].data,!(!i&&t&&s>=C(this.level)));n=n.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],o),o.min!==1/0&&(o.level=i.level,h=!0))}h&&(s(n.elevationBounds)&&(n.elevationBounds=new L),n.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==$&&(le(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:Q.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,I.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===$&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of b){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==$&&(i.loadingAgent.setSuspension(t),i.loadingAgent===$&&this.updateRenderData(e,I.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==$&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=$,!i.data&&s(i.upsampleInfo)&&this._createOrUpdateAgents(e+1,t)}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=(()=>{for(let s=e;s<i.length;++s){const e=this._surface.layerViewByIndex(s,t);if(P(e)&&"normal"!==e.layer.blendMode)return!0}return!1})(),n=this._isSuspended(t);for(let r=e;r<i.length;++r){const e=i[r];let a=!1;const o=this._surface.layerViewByIndex(r,t),h=R(o);if(e.loadingAgent?ee(this,h,!1)?(e.loadingAgent!==$&&e.loadingAgent.setSuspension(n),e.loadingAgent!==$&&(a=e.loadingAgent.update())):e.dispose():ee(this,h,!1)&&(e.loadingAgent=he(this,r,t,n),a=e.loadingAgent.startLoading(),a?e.loadingAgent===$&&this.setPendingUpdate(Z.GEOMETRY):(le(e.loadingAgent),e.loadingAgent=$)),e.loadingAgent===$&&this.updateRenderData(t,I.FADING),!s&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationBasedVerticesPerSide(t){const i=this.vlevel-this.level,s=Math.max(this.level-t,C(this.level)-i);return e(1+(this.maxTesselation>>s),2,this.maxTesselation+1)}get test(){return{cachedMemory:this._cachedMemory}}_findLIJ(e,i){if(!e)return null;const s=this.surface.rootTiles;if(t(s))for(const t of s)if(fe(t,e)){let s=t,n=e[0]-s.level-1;for(;n>=0&&!s.isLeaf&&!i(s);){const t=e[1]>>n&1,i=e[2]>>n&1;s=s.children[2*t+i],n--}return i(s)?s:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?pe(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===N.NORTH_EAST?1:e===N.NORTH_WEST?0:e===N.SOUTH_WEST?2:3;let s=this;for(;!(s.isLeaf||t&&t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)}forAllSubtreeOnSide(e,t){const i=e===N.NORTH?[0,1]:e===N.NORTH_EAST?[1]:e===N.EAST?[1,3]:e===N.SOUTH_EAST?[3]:e===N.SOUTH?[2,3]:e===N.SOUTH_WEST?[2]:e===N.WEST?[0,2]:[0],s=e=>{t(e)||e.isLeaf||i.forEach((t=>s(e.children[t])))};s(this)}forallNeighbors(e){G.forEach((t=>this.findNeighborCornerTileExact(t,e))),V.forEach((t=>this.findNeighborTile(t,(t=>t.level===this.level||e(t)))?.forAllSubtreeOnSide(W(t),e)))}getNeighborEdgeStartVertexIndex(e,t){const i=t??this.findNeighborTile(V[e],(e=>e.isLoaded));if(!i)return 0;const s=this.level-i.level;if(w(!q||s>=0),0===s)return 0;const n=2**s,r=1==(1&e),a=r?0:1,o=i.lij[a+1]*n,h=this.lij[a+1],l=h-o,d=r?n-1-l:l;return q&&(w(o<=h&&h<o+n),w(0<=d&&d<n)),d}_updateNeighborsWithChangedEdgeResolution(){for(let e=0;e<4;++e)if(this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]){const t=V[e],i=this.findNeighborTile(t,(e=>e.isLoaded||e.level===this.level));if(!i)continue;if(!i.isLoaded){w(!i.isLeaf);const s=(e+2)%4,n=W(t);i.forAllSubtreeOnSide(n,(e=>e.isLoaded?(e.updateEdgeAfterResolutionChange(s),!0):(w(!e.isLeaf),!1)))}this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]=!1}}updateNeighborDataAndGeometryIfNeeded(){this.isLoaded&&this.renderData.updateNeighborDataAndGeometryIfNeeded()}updateNeighborsAfterGeometryChange(e=this.level){this.forEachLoadedNeighbor((e=>this._updateNeighbor(e))),V.forEach((t=>{this.findNeighborTile(t,(t=>t.isLoaded&&t.level<e))?.updateNeighborsWithChangedEdgeResolution()}))}updateNeighborsWithChangedEdgeResolution(){this.isLoaded&&this._updateNeighborsWithChangedEdgeResolution()}updateEdgeAfterResolutionChange(e){this.renderData.updateEdgeAfterResolutionChange(e)}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach(((t,s)=>{const n=this.findNeighborTile(t,i);null!=n&&n!==this&&n.forAllSubtreeOnSide(W(t),(t=>!!t.isLoaded&&(e(t),!0)));const r=this.renderData?.geometryState?.neighborData;r&&(r.modifiedEdgeResolutions[s]=!1)})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));w(!s||ye(this,s,t)),s?.isLoaded&&e(s)}))}_updateNeighbor(e){e?.isLoaded&&e.updateNeighborDataAndGeometryIfNeeded()}getNeighborLIJ(e,t){const i=H(t)?-1:F(t)?1:0,s=k(t)?-1:X(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){return this.extent[1]+m()>=this.surface.extent[1]}compareLIJs(e){const t=this.lij,i=t[0],s=e[0];if(i===s)return[t,e];const n=i-s;if(n<0){const i=2**-n;return[[s,t[1]*i,t[2]*i],e]}{const s=2**n;return[t,[i,e[1]*s,e[2]*s]]}}checkGeometryWaterproofness(){z&&(w(this.isLoaded),this.renderData.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(H(e)&&t[3]+s>=i[3])return!1;if(F(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&k(e)&&t[0]-s<=i[0])&&!(!n&&X(e)&&t[2]+s>=i[2])}}function he(e,t,i,s){const n=i===S.ELEVATION?ue.acquire():de.acquire();return n.init(e,t,i,s),n}function le(e){e.dispose(),e instanceof M?ue.release(e):e instanceof x&&de.release(e)}const de=new n(x),ue=new n(M),ce=new L;var ge;function fe(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=Math.floor(t[1]/2**n),a=Math.floor(t[2]/2**n);return r===e.lij[1]&&a===e.lij[2]}function pe(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function me(e,t,i){return Math.abs(e-t)<=i}function _e(e,t,i){if(s(e)||s(t))return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===N.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===N.WEST)return!0}const n=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case N.NORTH:return me(e.extent[3],t.extent[1],n);case N.SOUTH:return me(e.extent[1],t.extent[3],n);case N.EAST:return me(e.extent[2],t.extent[0],n)||me(e.extent[2],-t.extent[0],n);case N.WEST:return me(e.extent[0],t.extent[2],n)||me(e.extent[0],-t.extent[2],n)}}function ye(e,t,i){return!s(e)&&!s(t)&&t!==e&&(e.level>=t.level?Ae(e,t,i):Ae(t,e,B(i)))}function Ae(e,t,i){w(e.level>=t.level);const s=J(i),n=Y(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],h=[s?a[2]:a[0],n?a[1]:a[3]],l=1e-5*(r[2]-r[0]),d=me(o[0],h[0],l)||e.surface.isGlobal&&me(o[0],-h[0],l),u=me(o[1],h[1],l);if(d&&u)return!0;if(e.level===t.level)return w(!1),!1;if(!d&&!u)return w(!1),!1;const c=d?Ee(a[1],a[3],r[1],r[3],l):Ee(a[0],a[2],r[0],r[2],l);return w(c),c}function Ee(e,t,i,s,n=m()){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(ge||(ge={}));export{ge as CenterPosition,ae as SplitLimits,oe as Tile,me as almostEquals,ye as isCornerNeighbor,_e as isEdgeNeighbor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t,isNone as e}from"../../../core/maybe.js";import n from"../../../core/PooledArray.js";class r{constructor(){this._queue=new n,this._last=null,this.remove=()=>{}}get done(){return 0===this._queue.length&&(!this._last||this._last.isLeaf)}resetOne(t){this._queue.clear(),this._queue.push(t),this._last=null}reset(e=null){this._queue.clear(),t(e)&&this._queue.pushArray(e),this._last=null}skipSubtree(){this._last=null}next(){return this._last&&!this._last.isLeaf&&this._queue.pushArray(this._last.children),this._last=this._queue.pop(),this._last}}class i{constructor(){this.q=new n}get done(){return 0===this.q.length}reset(t){if(this.q.clear(),!e(t)){this.q.pushArray(t);for(let t=0;t<this.q.length;++t){const e=this.q.data[t];e.isLeaf||this.q.pushArray(e.children)}}}next(){return this.q.pop()}}function s(t,e){if(Array.isArray(t))for(let n=0;n<t.length;n++)l(t[n],e);else l(t,e)}function l(t,e){if(e(t),!t.isLeaf)for(const n of t.children)l(n,e)}function u(t,n,r){if(e(n)||e(n.fullExtent))return!1;const i=n.fullExtent,s=t.extent;if(r){if(s[0]<i.xmin||s[1]<i.ymin||s[2]>i.xmax||s[3]>i.ymax)return!1}else if(i.xmin>s[2]||i.ymin>s[3]||i.xmax<s[0]||i.ymax<s[1])return!1;const l=t.surface.tilingScheme.levels[t.level].scale;return!(n.minScale>0&&l>1.00000001*n.minScale)&&!(n.maxScale>0&&l<.99999999*n.maxScale)}function o(t,e){return t.lij[0]-e.lij[0]||t.lij[1]-e.lij[1]||t.lij[2]-e.lij[2]}function a(t,e){e.sort(((e,n)=>h(e,n,t)))}function h(t,e,n){const r=t.screenDepth,i=e.screenDepth;return r<i?-n:r>i?n:o(t,e)}function c(t,e){const n=new Map;t.forAll((t=>n.set(t.lij,t.distanceToSquared(e)))),t.sort(((t,e)=>n.get(t.lij)-n.get(e.lij)||o(t,e)))}function f(t,e,n){let r=1,i=0,s=0;for(;t!==e;)if(r*=.5,i*=.5,s*=.5,1&t.lij[2]&&(i+=.5),0==(1&t.lij[1])&&(s+=.5),null==(t=t.parent))throw new Error("tile was not a descendant of upsampleTile");n.init(e,i,s,r)}function m(t){for(let e=0;e<t.length;e++){const n=t[e],r=n.parent;if(r)for(let t=0;t<4;t++){const e=r.children[t];if(e&&e!==n)return!0}}return!1}function p(t,e){if(!t||!e||t[0]===e[0])return!1;const n=t[0]<e[0],r=n?t:e,i=n?e:t,s=1<<i[0]-r[0];return Math.floor(i[1]/s)===r[1]&&Math.floor(i[2]/s)===r[2]}export{i as IteratorPostorder,r as IteratorPreorder,h as compareTiles,f as computeUpsampleInfo,u as fallsWithinLayer,m as hasLoadableSiblings,a as sortTiles,c as sortTilesByPOI,p as tilesAreRelated,s as traverseTilesPreorder};
5
+ import{isSome as t,isNone as e}from"../../../core/maybe.js";import n from"../../../core/PooledArray.js";class r{constructor(){this._queue=new n,this._last=null,this.remove=()=>{}}get done(){return 0===this._queue.length&&(!this._last||this._last.isLeaf)}resetOne(t){this._queue.clear(),this._queue.push(t),this._last=null}reset(e=null){this._queue.clear(),t(e)&&this._queue.pushArray(e),this._last=null}skipSubtree(){this._last=null}next(){return this._last&&!this._last.isLeaf&&this._queue.pushArray(this._last.children),this._last=this._queue.pop(),this._last}}class i{constructor(){this.q=new n}get done(){return 0===this.q.length}reset(t){if(this.q.clear(),!e(t)){this.q.pushArray(t);for(let t=0;t<this.q.length;++t){const e=this.q.data[t];e.isLeaf||this.q.pushArray(e.children)}}}next(){return this.q.pop()}}function s(t,e){if(Array.isArray(t))for(let n=0;n<t.length;n++)l(t[n],e);else l(t,e)}function l(t,e){if(e(t),!t.isLeaf)for(const n of t.children)l(n,e)}function u(t,n,r){if(e(n)||e(n.fullExtent))return!1;const i=n.fullExtent,s=t.extent;if(r){if(s[0]<i.xmin||s[1]<i.ymin||s[2]>i.xmax||s[3]>i.ymax)return!1}else if(i.xmin>s[2]||i.ymin>s[3]||i.xmax<s[0]||i.ymax<s[1])return!1;const l=t.surface.tilingScheme.levels[t.level].scale;return!(n.minScale>0&&l>1.00000001*n.minScale)&&!(n.maxScale>0&&l<.99999999*n.maxScale)}function o(t,e){return t.lij[0]-e.lij[0]||t.lij[1]-e.lij[1]||t.lij[2]-e.lij[2]}function a(t,n,r=null){e(r)||0===r.length?n.sort(((e,n)=>c(e,n,t))):n.sort(((e,n)=>h(e,n,t,r)))}function c(t,e,n){const r=t.screenDepth,i=e.screenDepth;return r<i?-n:r>i?n:o(t,e)}function h(t,e,n,r){return f(t,r)===f(e,r)?c(t,e,n):t?n:-n}function f(t,e){for(const n of e)if(t.intersectsExtent(n))return!0;return!1}function m(t,e){const n=new Map;t.forAll((t=>n.set(t.lij,t.distanceToSquared(e)))),t.sort(((t,e)=>n.get(t.lij)-n.get(e.lij)||o(t,e)))}function p(t,e,n){let r=1,i=0,s=0;for(;t!==e;)if(r*=.5,i*=.5,s*=.5,1&t.lij[2]&&(i+=.5),0==(1&t.lij[1])&&(s+=.5),null==(t=t.parent))throw new Error("tile was not a descendant of upsampleTile");n.init(e,i,s,r)}function _(t){for(let e=0;e<t.length;e++){const n=t[e],r=n.parent;if(r)for(let t=0;t<4;t++){const e=r.children[t];if(e&&e!==n)return!0}}return!1}function q(t,e){if(!t||!e||t[0]===e[0])return!1;const n=t[0]<e[0],r=n?t:e,i=n?e:t,s=1<<i[0]-r[0];return Math.floor(i[1]/s)===r[1]&&Math.floor(i[2]/s)===r[2]}export{i as IteratorPostorder,r as IteratorPreorder,c as compareTiles,h as compareTilesWithStencil,p as computeUpsampleInfo,u as fallsWithinLayer,_ as hasLoadableSiblings,a as sortTiles,m as sortTilesByPOI,q as tilesAreRelated,s as traverseTilesPreorder};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../core/Logger.js";import{isNone as t,isSome as o,unwrap as n,applySome as r}from"../../../../../core/maybe.js";import i from"../../../../../core/PooledArray.js";import{g as s,t as a}from"../../../../../chunks/mat3.js";import{c}from"../../../../../chunks/mat3f32.js";import{d as m,w as l,t as f}from"../../../../../chunks/vec3.js";import{a as p,c as h}from"../../../../../chunks/vec3f64.js";import{c as u}from"../../../../../chunks/vec4f32.js";import{a as b}from"../../../../../chunks/vec32.js";import{c as g}from"../../../../../chunks/vec33.js";import{ViewingMode as d}from"../../../../ViewingMode.js";import{computeOffsetObb as y}from"../../../layers/i3s/I3SUtil.js";import{ColorMixModeEnum as C,encodeSymbolColor as j}from"../../../layers/support/symbolColorUtils.js";import{clone as v,radius as w}from"../../../support/orientedBoundingBox.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{newLayout as M}from"../../../support/buffer/InterleavedLayout.js";import x from"./ComponentData.js";import{State as O,ComponentObject as D}from"./ComponentObject.js";import S from"./IntersectionGeometry.js";import{Renderable as A}from"./Renderable.js";import{RenderGeometry as I}from"./RenderGeometry.js";import{RenderSubmitSystem as P}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as E}from"./SourceGeometry.js";import{ComponentParametersVarying as R,ComponentParametersUniform as U,ComponentParameterSummary as k,ComponentMaterial as B}from"./Material/ComponentMaterial.js";import{encodeElevationOffset as T}from"./Material/shader/ComponentData.glsl.js";import{getVisibility as V,updateVisibilityWithCount as G}from"../../lib/ComponentUtils.js";import{assert as L}from"../../lib/Util.js";import{VertexAttribute as N}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as H}from"../../lib/verticalOffsetUtils.js";import{EdgeInputBufferLayout as q}from"../../lib/edgeRendering/bufferLayouts.js";import{extractComponentsEdgeLocationsLayout as z}from"../../lib/edgeRendering/edgeProcessing.js";import{BufferManager as W}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as X}from"../../../../webgl/BufferObject.js";import{Usage as Y,PrimitiveType as F}from"../../../../webgl/enums.js";import{VertexArrayObject as J}from"../../../../webgl/VertexArrayObject.js";const K=e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class Q{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._objects=[new i,new i],this._renderSubmit=new P(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new W(e.rctx,2)}dispose(){L(0===this._objects[O.Hidden].length&&0===this._objects[O.Visible].length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy()}createObject(e){const t=new D;return t.toMapSpace=e.toMapSpace,t.transform=e.transform,t.obb=v(e.obb),t.components=new x(this._componentBufferManager,e.geometry.componentOffsets),t.renderable=this._createRenderable(e,t.components),t.intersectionGeometry=new S(e.geometry.positionData,t.components),this._objects[t.visible].push(t),t}destroyObject(e){const t=e;this._objects[t.visible].removeUnordered(t),t.dispose(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(this._objects[o.visible].removeUnordered(o),this._objects[t].push(o),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=m(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.components.visibility.reset(t),o.components.visibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.components.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.components.visibility.componentCount();return{visible:o,invisible:t.components.count-o}}setComponentData(e,n){const r=e,i=r.renderable.material,s=r.components,a=s.materialDataBuffer,c=s.materialDataIndices,m={castShadows:!0,pickable:!0,externalColor:u(),externalColorMixMode:C.Multiply,elevationOffset:0},l=a.textureBuffer,f=new Uint8Array(4),p=new Uint32Array(f.buffer);let h=0,b=0,g=0,d=s.verticalOffsets,w=1/0,_=-1/0,M=!1,x=!1,O=0;for(let u=0;u<s.count;u++)n(u,m),h+=+(m.externalColor[3]<1),b+=+(m.externalColorMixMode===C.Replace&&1===m.externalColor[3]),g+=+m.castShadows,j(m.externalColor,m.externalColorMixMode,f),f[2]=254&f[2]|+m.castShadows,l.setData(c[u],0,f[0],f[1],f[2],f[3]),M||(M=u>0&&O!==p[0]),O=p[0],x||(x=0!==m.elevationOffset),x&&t(d)&&(d=new Array(u).fill(0)),o(d)&&(d[u]=m.elevationOffset),w=Math.min(w,m.elevationOffset),_=Math.max(_,m.elevationOffset),T(m.elevationOffset,f),l.setData(c[u],1,f[0],f[1],f[2],f[3]),m.pickable!==V(s.pickability,u)&&(s.pickability=G(s.pickability,s.count,u,m.pickable));s.verticalOffsets=x?d:null,r.offsetObb=x?y(r.obb,w,_,this._viewingMode,o(r.offsetObb)?r.offsetObb:v(r.obb)):null,M||x?(i.componentParameters=new R,i.componentParameters.castShadows=$(g,s.count),i.componentParameters.transparent=$(h,s.count),i.componentParameters.opaqueOverride=$(b,s.count),i.componentParameters.texture=l,l.updateTexture()):(i.componentParameters=new U,i.componentParameters.castShadows=m.castShadows?k.All:k.None,i.componentParameters.externalColor=m.externalColor,i.componentParameters.externalColorMixMode=m.externalColorMixMode),this._notifyDirty()}getComponentAabb(e,o,r,i=!1){e.intersectionGeometry.getComponentAabb(o,r);const s=e,a=s.components.verticalOffsets;if(i||t(a))return r;const c=a[o];if(this._viewingMode===d.Local||0===c)return r[2]+=c,r[5]+=c,r;const m=n(H(c));return m.localOrigin=s.transform.position,m.applyToAabb(r)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}intersect(e,t,n,r,i,c){const m=e;o(i)&&(i.localOrigin=m.transform.position);const p=s(ee,m.transform.rotationScale);l(te,t,m.transform.position),l(oe,n,m.transform.position),f(te,te,p),f(oe,oe,p);const h=a(ee,p);return m.intersectionGeometry.intersect(te,oe,r,h,i,m.components.verticalOffsets,c)}addEdges(e,t,o,n){const r=e,{indices:i,positions:s}=r.intersectionGeometry,a=r.components.offsets;return t.addComponentObject(e,r.transform,{center:r.obb.center,radius:w(r.obb)},s,i,a,o,n)}async extractEdgeInformation(e,t,o){const n=e,r=n.components.visibility;if(r.allInvisible())return{buffer:z.createBuffer(0),origin:[0,0,0]};const{indices:i,positions:s}=n.intersectionGeometry,a=n.components.offsets,c=q.createBuffer(s.count);g(c.position,s),b(c.position,c.position,n.transform.rotationScale),this._setComponentIndices(c.componentIndex,i,a);const m=c.count,l=this._computeVisibilityIndices(i,r,a,m);return{origin:p(n.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:l,indicesLength:l.length,skipDeduplicate:!0,data:c,writerSettings:{reducedPrecision:!1,variants:0}},o)}}_setComponentIndices(e,t,o){let n=0;for(let r=0;r<o.length-1;r++){const i=o[r],s=o[r+1];for(let o=i;o<s;o++){const r=t?t[o]:o;e.set(r,n)}n++}}_computeVisibilityIndices(e,t,o,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange(((e,t)=>(r+=o[t]-o[e],!0)));const i=2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r);let s=0;return t.forEachComponentRange(((t,n)=>{const r=o[t],a=o[n];for(let o=r;o<a;o++)i[s++]=e?e[o]:o;return!0})),i}addComponentHighlight(e,o){const n=e.components;t(n.highlightCounts)&&(n.highlightCounts=new Uint32Array(n.count+1));0===n.highlightCounts[o]++&&(n.highlightsDirty(),this._notifyDirty()),n.highlightCounts[n.count]++}removeComponentHighlight(e,o){const n=e.components;if(t(n.highlightCounts))return void K.warn("Removing non-existing highlight.");const r=n.highlightCounts[o],i=n.highlightCounts[n.count];if(0!==r){if(r>1)return n.highlightCounts[o]=r-1,void(n.highlightCounts[n.count]=i-1);n.highlightCounts[o]=0,n.highlightsDirty(),this._notifyDirty(),1===i?n.highlightCounts=null:n.highlightCounts[n.count]=i-1}else K.warn("Removing non-existing highlight.")}clearHighlights(e){const t=e.components;o(t.highlightCounts)&&(t.highlightCounts=null,t.highlightsDirty(),this._notifyDirty())}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._objects[O.Visible]}_createRenderable(e,t){const i=this._renderManager.rctx,s=e.geometry,a=s.vertices.layoutParameters,c=X.createVertex(i,Y.STATIC_DRAW,s.vertices.data),m=r(s.indices,(e=>X.createIndex(i,Y.STATIC_DRAW,e))),l=_(E(a)),f=new Uint16Array(s.vertices.count);for(let n=0;n<t.count;n++){const e=t.offsets[n],r=t.offsets[n+1],i=t.materialDataIndices[n];if(o(s.indices))for(let t=e;t<r;t++){f[s.indices[t]]=i}else for(let t=e;t<r;t++)f[t]=i}const p=X.createVertex(i,Y.STATIC_DRAW,f.buffer),h=new B(e.transform,e.toMapSpace),u=new J(i,h.attributeLocations,{data:l,componentIndices:Z},{data:c,componentIndices:p},n(m)),b=new I(u,F.TRIANGLES,a,o(m)),g={cameraDepthSquared:.5,gpuMemoryEstimate:c.byteSize+p.byteSize+(o(m)?m.byteSize:0)};return new A(h,b,g)}_notifyDirty(){this._renderManager.notifyDirty()}}const Z=_(M().u16(N.COMPONENTINDEX));function $(e,t){return e===t?k.All:0===e?k.None:k.Some}const ee=c(),te=h(),oe=h();export{Q as ComponentObjectCollection};
5
+ import e from"../../../../../core/Logger.js";import{isNone as t,isSome as o,unwrap as n,applySome as r}from"../../../../../core/maybe.js";import i from"../../../../../core/PooledArray.js";import{g as s,t as a}from"../../../../../chunks/mat3.js";import{c}from"../../../../../chunks/mat3f32.js";import{d as m,w as l,t as f}from"../../../../../chunks/vec3.js";import{a as p,c as h}from"../../../../../chunks/vec3f64.js";import{c as u}from"../../../../../chunks/vec4f32.js";import{a as b}from"../../../../../chunks/vec32.js";import{c as g}from"../../../../../chunks/vec33.js";import{ViewingMode as d}from"../../../../ViewingMode.js";import{computeOffsetObb as y}from"../../../layers/i3s/I3SUtil.js";import{ColorMixModeEnum as C,encodeSymbolColor as j}from"../../../layers/support/symbolColorUtils.js";import{clone as v,radius as w}from"../../../support/orientedBoundingBox.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{newLayout as M}from"../../../support/buffer/InterleavedLayout.js";import x from"./ComponentData.js";import{State as O,ComponentObject as D}from"./ComponentObject.js";import S from"./IntersectionGeometry.js";import{Renderable as A}from"./Renderable.js";import{RenderGeometry as I}from"./RenderGeometry.js";import{RenderSubmitSystem as P}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as E}from"./SourceGeometry.js";import{ComponentParametersVarying as R,ComponentParametersUniform as U,ComponentParameterSummary as k,ComponentMaterial as T}from"./Material/ComponentMaterial.js";import{attributeLocations as B}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as V}from"./Material/shader/ComponentData.glsl.js";import{getVisibility as G,updateVisibilityWithCount as L}from"../../lib/ComponentUtils.js";import{assert as N}from"../../lib/Util.js";import{VertexAttribute as q}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as H}from"../../lib/verticalOffsetUtils.js";import{EdgeInputBufferLayout as z}from"../../lib/edgeRendering/bufferLayouts.js";import{extractComponentsEdgeLocationsLayout as W}from"../../lib/edgeRendering/edgeProcessing.js";import{BufferManager as X}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as Y}from"../../../../webgl/BufferObject.js";import{Usage as F,PrimitiveType as J}from"../../../../webgl/enums.js";import{VertexArrayObject as K}from"../../../../webgl/VertexArrayObject.js";const Q=e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class Z{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._objects=[new i,new i],this._renderSubmit=new P(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new X(e.rctx,2)}dispose(){N(0===this._objects[O.Hidden].length&&0===this._objects[O.Visible].length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy()}createObject(e){const t=new D;return t.toMapSpace=e.toMapSpace,t.transform=e.transform,t.obb=v(e.obb),t.components=new x(this._componentBufferManager,e.geometry.componentOffsets),t.renderable=this._createRenderable(e,t.components),t.intersectionGeometry=new S(e.geometry.positionData,t.components),this._objects[t.visible].push(t),t}destroyObject(e){const t=e;this._objects[t.visible].removeUnordered(t),t.dispose(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(this._objects[o.visible].removeUnordered(o),this._objects[t].push(o),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=m(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.components.visibility.reset(t),o.components.visibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.components.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.components.visibility.componentCount();return{visible:o,invisible:t.components.count-o}}setComponentData(e,n){const r=e,i=r.renderable.material,s=r.components,a=s.materialDataBuffer,c=s.materialDataIndices,m={castShadows:!0,pickable:!0,externalColor:u(),externalColorMixMode:C.Multiply,elevationOffset:0},l=a.textureBuffer,f=new Uint8Array(4),p=new Uint32Array(f.buffer);let h=0,b=0,g=0,d=s.verticalOffsets,w=1/0,_=-1/0,M=!1,x=!1,O=0;for(let u=0;u<s.count;u++)n(u,m),h+=+(m.externalColor[3]<1),b+=+(m.externalColorMixMode===C.Replace&&1===m.externalColor[3]),g+=+m.castShadows,j(m.externalColor,m.externalColorMixMode,f),f[2]=254&f[2]|+m.castShadows,l.setData(c[u],0,f[0],f[1],f[2],f[3]),M||(M=u>0&&O!==p[0]),O=p[0],x||(x=0!==m.elevationOffset),x&&t(d)&&(d=new Array(u).fill(0)),o(d)&&(d[u]=m.elevationOffset),w=Math.min(w,m.elevationOffset),_=Math.max(_,m.elevationOffset),V(m.elevationOffset,f),l.setData(c[u],1,f[0],f[1],f[2],f[3]),m.pickable!==G(s.pickability,u)&&(s.pickability=L(s.pickability,s.count,u,m.pickable));s.verticalOffsets=x?d:null,r.offsetObb=x?y(r.obb,w,_,this._viewingMode,o(r.offsetObb)?r.offsetObb:v(r.obb)):null,M||x?(i.componentParameters=new R,i.componentParameters.castShadows=ee(g,s.count),i.componentParameters.transparent=ee(h,s.count),i.componentParameters.opaqueOverride=ee(b,s.count),i.componentParameters.texture=l,l.updateTexture()):(i.componentParameters=new U,i.componentParameters.castShadows=m.castShadows?k.All:k.None,i.componentParameters.externalColor=m.externalColor,i.componentParameters.externalColorMixMode=m.externalColorMixMode),this._notifyDirty()}getComponentAabb(e,o,r,i=!1){e.intersectionGeometry.getComponentAabb(o,r);const s=e,a=s.components.verticalOffsets;if(i||t(a))return r;const c=a[o];if(this._viewingMode===d.Local||0===c)return r[2]+=c,r[5]+=c,r;const m=n(H(c));return m.localOrigin=s.transform.position,m.applyToAabb(r)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}intersect(e,t,n,r,i,c){const m=e;o(i)&&(i.localOrigin=m.transform.position);const p=s(te,m.transform.rotationScale);l(oe,t,m.transform.position),l(ne,n,m.transform.position),f(oe,oe,p),f(ne,ne,p);const h=a(te,p);return m.intersectionGeometry.intersect(oe,ne,r,h,i,m.components.verticalOffsets,c)}addEdges(e,t,o,n){const r=e,{indices:i,positions:s}=r.intersectionGeometry,a=r.components.offsets;return t.addComponentObject(e,r.transform,{center:r.obb.center,radius:w(r.obb)},s,i,a,o,n)}async extractEdgeInformation(e,t,o){const n=e,r=n.components.visibility;if(r.allInvisible())return{buffer:W.createBuffer(0),origin:[0,0,0]};const{indices:i,positions:s}=n.intersectionGeometry,a=n.components.offsets,c=z.createBuffer(s.count);g(c.position,s),b(c.position,c.position,n.transform.rotationScale),this._setComponentIndices(c.componentIndex,i,a);const m=c.count,l=this._computeVisibilityIndices(i,r,a,m);return{origin:p(n.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:l,indicesLength:l.length,skipDeduplicate:!0,data:c,writerSettings:{reducedPrecision:!1,variants:0}},o)}}_setComponentIndices(e,t,o){let n=0;for(let r=0;r<o.length-1;r++){const i=o[r],s=o[r+1];for(let o=i;o<s;o++){const r=t?t[o]:o;e.set(r,n)}n++}}_computeVisibilityIndices(e,t,o,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange(((e,t)=>(r+=o[t]-o[e],!0)));const i=2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r);let s=0;return t.forEachComponentRange(((t,n)=>{const r=o[t],a=o[n];for(let o=r;o<a;o++)i[s++]=e?e[o]:o;return!0})),i}addComponentHighlight(e,o){const n=e.components;t(n.highlightCounts)&&(n.highlightCounts=new Uint32Array(n.count+1));0===n.highlightCounts[o]++&&(n.highlightsDirty(),this._notifyDirty()),n.highlightCounts[n.count]++}removeComponentHighlight(e,o){const n=e.components;if(t(n.highlightCounts))return void Q.warn("Removing non-existing highlight.");const r=n.highlightCounts[o],i=n.highlightCounts[n.count];if(0!==r){if(r>1)return n.highlightCounts[o]=r-1,void(n.highlightCounts[n.count]=i-1);n.highlightCounts[o]=0,n.highlightsDirty(),this._notifyDirty(),1===i?n.highlightCounts=null:n.highlightCounts[n.count]=i-1}else Q.warn("Removing non-existing highlight.")}clearHighlights(e){const t=e.components;o(t.highlightCounts)&&(t.highlightCounts=null,t.highlightsDirty(),this._notifyDirty())}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._objects[O.Visible]}_createRenderable(e,t){const i=this._renderManager.rctx,s=e.geometry,a=s.vertices.layoutParameters,c=Y.createVertex(i,F.STATIC_DRAW,s.vertices.data),m=r(s.indices,(e=>Y.createIndex(i,F.STATIC_DRAW,e))),l=_(E(a)),f=new Uint16Array(s.vertices.count);for(let n=0;n<t.count;n++){const e=t.offsets[n],r=t.offsets[n+1],i=t.materialDataIndices[n];if(o(s.indices))for(let t=e;t<r;t++){f[s.indices[t]]=i}else for(let t=e;t<r;t++)f[t]=i}const p=Y.createVertex(i,F.STATIC_DRAW,f.buffer),h=new T(e.transform,e.toMapSpace),u=new K(i,B,{data:l,componentIndices:$},{data:c,componentIndices:p},n(m)),b=new I(u,J.TRIANGLES,a,o(m)),g={cameraDepthSquared:.5,gpuMemoryEstimate:c.byteSize+p.byteSize+(o(m)?m.byteSize:0)};return new A(h,b,g)}_notifyDirty(){this._renderManager.notifyDirty()}}const $=_(M().u16(q.COMPONENTINDEX));function ee(e,t){return e===t?k.All:0===e?k.None:k.Some}const te=c(),oe=h(),ne=h();export{Z as ComponentObjectCollection};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{releaseMaybe as t,isSome as r,isNone as s}from"../../../../../../core/maybe.js";import{g as o,t as a}from"../../../../../../chunks/mat3.js";import{a as i}from"../../../../../../chunks/mat3f32.js";import{F as n}from"../../../../../../chunks/vec3.js";import{f as l}from"../../../../../../chunks/vec3f32.js";import{v as h}from"../../../../../../chunks/vec4.js";import{f as u}from"../../../../../../chunks/vec4f32.js";import{ColorMixModeEnum as p}from"../../../../layers/support/symbolColorUtils.js";import{OverlayIndex as c,RenderTargetType as d}from"../../../../terrain/interfaces.js";import{ComponentTechnique as m}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as g,IntegratedMeshMode as T}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as y}from"./shader/ComponentData.glsl.js";import{g as x,a as v}from"../../../../../../chunks/ComponentShader.glsl.js";import{VertexDiscardMode as f}from"./shader/VertexDiscardByOpacity.glsl.js";import{parameter as M,parameterBlock as b,MaterialBase as O,MaterialParameterBlock as C}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as w,MaterialSubPass as S}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as P}from"../../../core/shaderLibrary/ShaderOutputOptions.js";import{NormalAttributeType as N}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as A}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as D}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as q}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as R}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as j}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as E,TransparencyPassType as I,CullFaceOptions as F}from"../../../lib/basicInterfaces.js";class _ extends O{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=l(1,1,.5),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new B,this.componentParameters=new L,this.textureAlphaCutoff=q,this.alphaDiscardMode=E.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=R.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new g;const r=new j(e.position),s=i(e.rotationScale);o(s,s),this.transformNormalGlobalFromModel=a(s,s),this.transformWorldFromModelTL=r.low,this.transformWorldFromModelTH=r.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return r(this.baseColorTexture)?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return r(this.metallicRoughnessTexture)?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return r(this.emissionTexture)?this.emissionTexture.glTexture:null}get textureOcclusion(){return r(this.occlusionTexture)?this.occlusionTexture.glTexture:null}get textureNormal(){return r(this.normalTexture)?this.normalTexture.glTexture:null}prepareTechnique(e,t,o,a){const i=this._techniqueConfiguration;i.hasVertexColors=a.colors,i.hasNormals=a.normals,i.textureCoordinateType=a.textureCoordinates,i.hasMetalnessAndRoughnessTexture=r(this.metallicRoughnessTexture),i.hasEmissionTexture=r(this.emissionTexture),i.hasOcclusionTexture=r(this.occlusionTexture),i.hasNormalTexture=r(this.normalTexture),i.transparencyPassType=t.identifier===w.Material&&null!=o.transparencyPassType?o.transparencyPassType:I.NONE,i.hasMultipassTerrain=t.identifier===w.Material&&null!=o.multipassTerrain&&o.multipassTerrain.enabled,i.cullAboveGround=t.identifier===w.Material&&null!=o.multipassTerrain&&o.multipassTerrain.cullAboveGround,i.ellipsoidMode=this.ellipsoidMode,i.componentData=this.componentParameters.type,i.cullFace=this.commonMaterialParameters.cullFace,i.doubleSidedMode=this.commonMaterialParameters.doubleSided?A.View:A.None,i.hasBaseColorTexture=r(this.baseColorTexture);const n=this._computeWhichMaterialPass();i.blendingEnabled=n===V.Transparent||n===V.OpaqueAndTransparent,i.alphaDiscardMode=this.alphaDiscardMode,i.integratedMeshMode=this.isIntegratedMesh?X(o)?x(o)?T.ColorOverlayWithWater:T.ColorOverlay:T.NoOverlay:T.None,i.isGround=this.isIntegratedMesh,i.hasPolygonOffset=this.polygonOffsetEnabled;const l=this.hasParametersFromSource&&s(this.baseColorTexture);return i.pbrMode=i.integratedMeshMode===T.ColorOverlayWithWater?D.WaterOnIntegratedMesh:this.usePBR?l?D.Schematic:D.Normal:D.Disabled,i.normalType=i.integratedMeshMode===T.None?i.hasNormals?N.CompressedAttribute:N.ScreenDerivative:N.Ground,i.hasSlicePlane=r(o.slicePlane)&&this.commonMaterialParameters.hasSlicePlane,t.identifier===w.ShadowMap?(i.output=P.Shadow,i.vertexDiscardMode=f.None):t.identifier===w.Highlight?(i.output=P.Highlight,i.vertexDiscardMode=f.None):(this._computeWhichMaterialPass()===V.OpaqueAndTransparent?i.vertexDiscardMode=t.transparent?f.Opaque:f.Transparent:i.vertexDiscardMode=f.None,i.output=H(t.subPass),t.subPass===S.Alpha&&(i.hasOccludees=o.hasOccludees),t.subPass===S.Color?(i.receiveAmbientOcclusion=o.ssaoHelper.ready,i.hasOccludees=o.hasOccludees,i.receiveShadows=o.shadowMap.ready,i.hasScreenSpaceReflections=o.ssr.enabled,i.hasCloudsReflections=r(o.clouds.data)):(i.receiveAmbientOcclusion=!1,i.receiveShadows=!1),i.snowCover=this.hasSnowCover(o)),this._technique=e.releaseAndAcquire(m,i,this._technique),this._setClean(),this._technique}hasSnowCover(e){return r(e.weather)&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,s){if(0===this.objectOpacity)return;const o=s.renderable.geometry,a=s.components,i=s.renderable.meta.cameraDepthSquared,n=a.geometryRanges,l=a.highlightRanges,h=a.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case V.Opaque:e.materialOpaque.submitDraw(this,o,n,i);break;case V.Transparent:e.materialTransparent.submitDraw(this,o,n,i);break;case V.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,n,i),e.materialTransparent.submitDraw(this,o,n,i);break;case V.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,n,i),U(t)&&e.highlightIntegratedMesh.submitDraw(this,o,n,i)}const u=this.componentParameters.castShadows!==W.None;u&&e.shadowMap.submitDraw(this,o,n,i),r(l)&&(e.highlight.submitDraw(this,o,l,i),u&&e.highlightShadowMap.submitDraw(this,o,l,i)),u&&r(h)&&e.defaultShadowMap.submitDraw(this,o,h,i)}get attributeLocations(){return v}_computeWhichMaterialPass(){return this.isIntegratedMesh?V.IntegratedMesh:this.objectOpacity<1?V.Transparent:this.componentParameters.opaqueOverride===W.All?V.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===E.Blend||this.alphaDiscardMode===E.MaskBlend?V.Transparent:this.componentParameters.transparent===W.None?V.Opaque:this.componentParameters.transparent===W.All?V.Transparent:V.OpaqueAndTransparent}}var k,V,W;e([M({vectorOps:h})],_.prototype,"baseColor",void 0),e([M()],_.prototype,"usePBR",void 0),e([M()],_.prototype,"hasParametersFromSource",void 0),e([M({vectorOps:n})],_.prototype,"mrrFactors",void 0),e([M({vectorOps:n})],_.prototype,"emissiveFactor",void 0),e([M({dispose:!0})],_.prototype,"baseColorTexture",void 0),e([M({dispose:!0})],_.prototype,"metallicRoughnessTexture",void 0),e([M({dispose:!0})],_.prototype,"emissionTexture",void 0),e([M({dispose:!0})],_.prototype,"occlusionTexture",void 0),e([M({dispose:!0})],_.prototype,"normalTexture",void 0),e([M()],_.prototype,"objectOpacity",void 0),e([b()],_.prototype,"commonMaterialParameters",void 0),e([b()],_.prototype,"componentParameters",void 0),e([M()],_.prototype,"textureAlphaCutoff",void 0),e([M()],_.prototype,"alphaDiscardMode",void 0),e([M()],_.prototype,"isIntegratedMesh",void 0),e([M()],_.prototype,"polygonOffsetEnabled",void 0),e([M()],_.prototype,"ellipsoidMode",void 0),e([M()],_.prototype,"hasOccludees",void 0),function(e){e[e.VERTEX=0]="VERTEX",e[e.GROUND=1]="GROUND",e[e.SCREEN_DERIVATIVE=2]="SCREEN_DERIVATIVE"}(k||(k={})),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(V||(V={}));class B extends C{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=F.Back,this.hasSlicePlane=!0}}e([M()],B.prototype,"doubleSided",void 0),e([M()],B.prototype,"cullFace",void 0),e([M()],B.prototype,"hasSlicePlane",void 0);class L extends C{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=p.Multiply,this.castShadows=W.All}get transparent(){return this.externalColor[3]<1?W.All:W.None}get opaqueOverride(){return this.externalColorMixMode===p.Replace&&1===this.externalColor[3]?W.All:W.None}get visible(){return this.externalColor[3]>0?W.All:W.None}get type(){return y.Uniform}}e([M({vectorOps:h})],L.prototype,"externalColor",void 0),e([M()],L.prototype,"externalColorMixMode",void 0),e([M()],L.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(W||(W={}));class G extends C{constructor(){super(...arguments),this.texture=null,this.transparent=W.None,this.opaqueOverride=W.None,this.castShadows=W.None}get type(){return y.Varying}}function H(e){switch(e){case S.Color:return P.Color;case S.Alpha:return P.Alpha;case S.Depth:return P.Depth;case S.Normal:return P.Normal}}function U(e){return 0!==e.overlays.length&&r(e.overlays[c.INNER].getValidTexture(d.Highlight))}function X(e){return 0!==e.overlays.length&&r(e.overlays[c.INNER].getColorTextureNoRasterImage())}e([M()],G.prototype,"texture",void 0),e([M()],G.prototype,"transparent",void 0),e([M()],G.prototype,"opaqueOverride",void 0),e([M()],G.prototype,"castShadows",void 0);export{B as CommonMaterialParameters,_ as ComponentMaterial,W as ComponentParameterSummary,L as ComponentParametersUniform,G as ComponentParametersVarying,k as ShadingNormalSource};
5
+ import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{releaseMaybe as t,isSome as r,isNone as s}from"../../../../../../core/maybe.js";import{g as o,t as a}from"../../../../../../chunks/mat3.js";import{a as i}from"../../../../../../chunks/mat3f32.js";import{F as n}from"../../../../../../chunks/vec3.js";import{f as l}from"../../../../../../chunks/vec3f32.js";import{v as h}from"../../../../../../chunks/vec4.js";import{f as u}from"../../../../../../chunks/vec4f32.js";import{ColorMixModeEnum as p}from"../../../../layers/support/symbolColorUtils.js";import{OverlayIndex as c,RenderTargetType as d}from"../../../../terrain/interfaces.js";import{ComponentTechnique as m}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as g,IntegratedMeshMode as T}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as y}from"./shader/ComponentData.glsl.js";import{g as x}from"../../../../../../chunks/ComponentShader.glsl.js";import{VertexDiscardMode as f}from"./shader/VertexDiscardByOpacity.glsl.js";import{parameter as v,parameterBlock as M,MaterialBase as b,MaterialParameterBlock as O}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as C,MaterialSubPass as w}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as P}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalAttributeType as S}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as N}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as A}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as D}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as q}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as R}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as j,CullFaceOptions as E}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as I}from"../../../lib/TransparencyPassType.js";class F extends b{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=l(1,1,.5),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new W,this.componentParameters=new B,this.textureAlphaCutoff=D,this.alphaDiscardMode=j.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=q.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new g;const r=new R(e.position),s=i(e.rotationScale);o(s,s),this.transformNormalGlobalFromModel=a(s,s),this.transformWorldFromModelTL=r.low,this.transformWorldFromModelTH=r.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return r(this.baseColorTexture)?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return r(this.metallicRoughnessTexture)?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return r(this.emissionTexture)?this.emissionTexture.glTexture:null}get textureOcclusion(){return r(this.occlusionTexture)?this.occlusionTexture.glTexture:null}get textureNormal(){return r(this.normalTexture)?this.normalTexture.glTexture:null}prepareTechnique(e,t,o,a){const i=this._techniqueConfiguration;i.hasVertexColors=a.colors,i.hasNormals=a.normals,i.textureCoordinateType=a.textureCoordinates,i.hasMetalnessAndRoughnessTexture=r(this.metallicRoughnessTexture),i.hasEmissionTexture=r(this.emissionTexture),i.hasOcclusionTexture=r(this.occlusionTexture),i.hasNormalTexture=r(this.normalTexture),i.transparencyPassType=t.identifier===C.Material&&null!=o.transparencyPassType?o.transparencyPassType:I.NONE,i.hasMultipassTerrain=t.identifier===C.Material&&null!=o.multipassTerrain&&o.multipassTerrain.enabled,i.cullAboveGround=t.identifier===C.Material&&null!=o.multipassTerrain&&o.multipassTerrain.cullAboveGround,i.ellipsoidMode=this.ellipsoidMode,i.componentData=this.componentParameters.type,i.cullFace=this.commonMaterialParameters.cullFace,i.doubleSidedMode=this.commonMaterialParameters.doubleSided?N.View:N.None,i.hasBaseColorTexture=r(this.baseColorTexture);const n=this._computeWhichMaterialPass();i.blendingEnabled=n===k.Transparent||n===k.OpaqueAndTransparent,i.alphaDiscardMode=this.alphaDiscardMode,i.integratedMeshMode=this.isIntegratedMesh?U(o)?x(o)?T.ColorOverlayWithWater:T.ColorOverlay:T.NoOverlay:T.None,i.isGround=this.isIntegratedMesh,i.hasPolygonOffset=this.polygonOffsetEnabled;const l=this.hasParametersFromSource&&s(this.baseColorTexture);return i.pbrMode=i.integratedMeshMode===T.ColorOverlayWithWater?A.WaterOnIntegratedMesh:this.usePBR?l?A.Schematic:A.Normal:A.Disabled,i.normalType=i.integratedMeshMode===T.None?i.hasNormals?S.CompressedAttribute:S.ScreenDerivative:S.Ground,i.hasSlicePlane=r(o.slicePlane)&&this.commonMaterialParameters.hasSlicePlane,t.identifier===C.ShadowMap?(i.output=P.Shadow,i.vertexDiscardMode=f.None):t.identifier===C.Highlight?(i.output=P.Highlight,i.vertexDiscardMode=f.None):(this._computeWhichMaterialPass()===k.OpaqueAndTransparent?i.vertexDiscardMode=t.transparent?f.Opaque:f.Transparent:i.vertexDiscardMode=f.None,i.output=L(t.subPass),t.subPass===w.Alpha&&(i.hasOccludees=o.hasOccludees),t.subPass===w.Color?(i.receiveAmbientOcclusion=o.ssaoHelper.ready,i.hasOccludees=o.hasOccludees,i.receiveShadows=o.shadowMap.ready,i.hasScreenSpaceReflections=o.ssr.enabled,i.hasCloudsReflections=r(o.clouds.data)):(i.receiveAmbientOcclusion=!1,i.receiveShadows=!1),i.snowCover=this.hasSnowCover(o)),this._technique=e.releaseAndAcquire(m,i,this._technique),this._setClean(),this._technique}hasSnowCover(e){return r(e.weather)&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,s){if(0===this.objectOpacity)return;const o=s.renderable.geometry,a=s.components,i=s.renderable.meta.cameraDepthSquared,n=a.geometryRanges,l=a.highlightRanges,h=a.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case k.Opaque:e.materialOpaque.submitDraw(this,o,n,i);break;case k.Transparent:e.materialTransparent.submitDraw(this,o,n,i);break;case k.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,n,i),e.materialTransparent.submitDraw(this,o,n,i);break;case k.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,n,i),H(t)&&e.highlightIntegratedMesh.submitDraw(this,o,n,i)}const u=this.componentParameters.castShadows!==V.None;u&&e.shadowMap.submitDraw(this,o,n,i),r(l)&&(e.highlight.submitDraw(this,o,l,i),u&&e.highlightShadowMap.submitDraw(this,o,l,i)),u&&r(h)&&e.defaultShadowMap.submitDraw(this,o,h,i)}_computeWhichMaterialPass(){return this.isIntegratedMesh?k.IntegratedMesh:this.objectOpacity<1?k.Transparent:this.componentParameters.opaqueOverride===V.All?k.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===j.Blend||this.alphaDiscardMode===j.MaskBlend?k.Transparent:this.componentParameters.transparent===V.None?k.Opaque:this.componentParameters.transparent===V.All?k.Transparent:k.OpaqueAndTransparent}}var _,k,V;e([v({vectorOps:h})],F.prototype,"baseColor",void 0),e([v()],F.prototype,"usePBR",void 0),e([v()],F.prototype,"hasParametersFromSource",void 0),e([v({vectorOps:n})],F.prototype,"mrrFactors",void 0),e([v({vectorOps:n})],F.prototype,"emissiveFactor",void 0),e([v({dispose:!0})],F.prototype,"baseColorTexture",void 0),e([v({dispose:!0})],F.prototype,"metallicRoughnessTexture",void 0),e([v({dispose:!0})],F.prototype,"emissionTexture",void 0),e([v({dispose:!0})],F.prototype,"occlusionTexture",void 0),e([v({dispose:!0})],F.prototype,"normalTexture",void 0),e([v()],F.prototype,"objectOpacity",void 0),e([M()],F.prototype,"commonMaterialParameters",void 0),e([M()],F.prototype,"componentParameters",void 0),e([v()],F.prototype,"textureAlphaCutoff",void 0),e([v()],F.prototype,"alphaDiscardMode",void 0),e([v()],F.prototype,"isIntegratedMesh",void 0),e([v()],F.prototype,"polygonOffsetEnabled",void 0),e([v()],F.prototype,"ellipsoidMode",void 0),e([v()],F.prototype,"hasOccludees",void 0),function(e){e[e.VERTEX=0]="VERTEX",e[e.GROUND=1]="GROUND",e[e.SCREEN_DERIVATIVE=2]="SCREEN_DERIVATIVE"}(_||(_={})),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(k||(k={}));class W extends O{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=E.Back,this.hasSlicePlane=!0}}e([v()],W.prototype,"doubleSided",void 0),e([v()],W.prototype,"cullFace",void 0),e([v()],W.prototype,"hasSlicePlane",void 0);class B extends O{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=p.Multiply,this.castShadows=V.All}get transparent(){return this.externalColor[3]<1?V.All:V.None}get opaqueOverride(){return this.externalColorMixMode===p.Replace&&1===this.externalColor[3]?V.All:V.None}get visible(){return this.externalColor[3]>0?V.All:V.None}get type(){return y.Uniform}}e([v({vectorOps:h})],B.prototype,"externalColor",void 0),e([v()],B.prototype,"externalColorMixMode",void 0),e([v()],B.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(V||(V={}));class G extends O{constructor(){super(...arguments),this.texture=null,this.transparent=V.None,this.opaqueOverride=V.None,this.castShadows=V.None}get type(){return y.Varying}}function L(e){switch(e){case w.Color:return P.Color;case w.Alpha:return P.Alpha;case w.Depth:return P.Depth;case w.Normal:return P.Normal}}function H(e){return 0!==e.overlays.length&&r(e.overlays[c.INNER].getValidTexture(d.Highlight))}function U(e){return 0!==e.overlays.length&&r(e.overlays[c.INNER].getColorTextureNoRasterImage())}e([v()],G.prototype,"texture",void 0),e([v()],G.prototype,"transparent",void 0),e([v()],G.prototype,"opaqueOverride",void 0),e([v()],G.prototype,"castShadows",void 0);export{W as CommonMaterialParameters,F as ComponentMaterial,V as ComponentParameterSummary,B as ComponentParametersUniform,G as ComponentParametersVarying,_ as ShadingNormalSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{ViewingMode as e}from"../../../../../ViewingMode.js";import{IntegratedMeshMode as r}from"./ComponentTechniqueConfiguration.js";import{C as i}from"../../../../../../chunks/ComponentShader.glsl.js";import{ShaderOutput as t}from"../../../core/shaderLibrary/ShaderOutputOptions.js";import{doublePrecisionRequiresObfuscation as o}from"../../../core/shaderLibrary/util/DoublePrecision.glsl.js";import{ReloadableShaderModule as n}from"../../../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as s}from"../../../core/shaderTechnique/ShaderTechnique.js";import{TransparencyPassType as l,StencilBits as a}from"../../../lib/basicInterfaces.js";import{blendingDefault as c,oitBlending as u,oitDepthTest as d,OITPolygonOffset as p}from"../../../lib/OrderIndependentTransparency.js";import{Program as h}from"../../../lib/Program.js";import{stencilWriteMaskOn as m,replaceBitWhenDepthTestPasses as f,stencilBaseAllZerosParams as g}from"../../../lib/StencilUtils.js";import{makePipelineState as b,cullingParams as j,defaultDepthWriteParams as O,defaultColorWriteParams as P}from"../../../../../webgl/renderState.js";class S extends s{initializeConfiguration(r,i){i.spherical=r.viewingMode===e.Global,i.doublePrecisionRequiresObfuscation=o(r.rctx)}initializeProgram(e){const r=S.shader.get(),i=r.build(this.configuration);return new h(e.rctx,i,r.attributeLocations)}_setPipelineState(e){const i=this.configuration,o=i.integratedMeshMode!==r.None,n=e===l.NONE,s=e===l.FrontFace;return b({blending:i.output!==t.Color&&i.output!==t.Alpha||!i.blendingEnabled?null:n?c:u(e),culling:j(i.cullFace),depthTest:{func:d(e)},depthWrite:n||s?O:null,colorWrite:P,stencilWrite:o||i.hasOccludees?m:null,stencilTest:o?f(a.IntegratedMeshMaskExcluded):i.hasOccludees?g:null,polygonOffset:n||s?i.hasPolygonOffset?{factor:2,units:2}:null:p})}initializePipeline(){return this._setPipelineState(this.configuration.transparencyPassType)}}S.shader=new n(i,(()=>import("./shader/ComponentShader.glsl.js")));export{S as ComponentTechnique};
5
+ import{ViewingMode as e}from"../../../../../ViewingMode.js";import{IntegratedMeshMode as r}from"./ComponentTechniqueConfiguration.js";import{C as i}from"../../../../../../chunks/ComponentShader.glsl.js";import{ShaderOutput as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{doublePrecisionRequiresObfuscation as o}from"../../../core/shaderLibrary/util/DoublePrecision.glsl.js";import{ReloadableShaderModule as n}from"../../../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as s}from"../../../core/shaderTechnique/ShaderTechnique.js";import{StencilBits as l}from"../../../lib/basicInterfaces.js";import{blendingDefault as a,oitBlending as c,oitDepthTest as u,OITPolygonOffset as p}from"../../../lib/OrderIndependentTransparency.js";import{Program as d}from"../../../lib/Program.js";import{stencilWriteMaskOn as m,replaceBitWhenDepthTestPasses as h,stencilBaseAllZerosParams as f}from"../../../lib/StencilUtils.js";import{TransparencyPassType as g}from"../../../lib/TransparencyPassType.js";import{VertexAttribute as b}from"../../../lib/VertexAttribute.js";import{makePipelineState as O,cullingParams as j,defaultDepthWriteParams as P,defaultColorWriteParams as M}from"../../../../../webgl/renderState.js";class S extends s{initializeConfiguration(r,i){i.spherical=r.viewingMode===e.Global,i.doublePrecisionRequiresObfuscation=o(r.rctx)}initializeProgram(e){return new d(e.rctx,S.shader.get().build(this.configuration),T)}_setPipelineState(e){const i=this.configuration,o=i.integratedMeshMode!==r.None,n=e===g.NONE,s=e===g.FrontFace;return O({blending:i.output!==t.Color&&i.output!==t.Alpha||!i.blendingEnabled?null:n?a:c(e),culling:j(i.cullFace),depthTest:{func:u(e)},depthWrite:n||s?P:null,colorWrite:M,stencilWrite:o||i.hasOccludees?m:null,stencilTest:o?h(l.IntegratedMeshMaskExcluded):i.hasOccludees?f:null,polygonOffset:n||s?i.hasPolygonOffset?{factor:2,units:2}:null:p})}initializePipeline(){return this._setPipelineState(this.configuration.transparencyPassType)}}S.shader=new n(i,(()=>import("./shader/ComponentShader.glsl.js")));const T=new Map([[b.POSITION,0],[b.NORMAL,1],[b.NORMALCOMPRESSED,1],[b.COLOR,2],[b.UV0,3],[b.UVREGION,4],[b.COMPONENTINDEX,5]]);export{S as ComponentTechnique,T as attributeLocations};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../../../../chunks/tslib.es6.js";import{ComponentDataType as e}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as t}from"./shader/VertexDiscardByOpacity.glsl.js";import{ShaderOutput as r}from"../../../core/shaderLibrary/ShaderOutputOptions.js";import{NormalAttributeType as s}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttributeType as i}from"../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{NormalsDoubleSidedMode as a}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as p}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{EllipsoidMode as n}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{BindType as d}from"../../../core/shaderTechnique/BindType.js";import{parameter as l,ShaderTechniqueConfiguration as h}from"../../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{CullFaceOptions as c,AlphaDiscardMode as u,TransparencyPassType as y}from"../../../lib/basicInterfaces.js";var v,T;!function(o){o[o.None=0]="None",o[o.Transparent=1]="Transparent",o[o.Opaque=2]="Opaque",o[o.COUNT=3]="COUNT"}(v||(v={})),function(o){o[o.None=0]="None",o[o.NoOverlay=1]="NoOverlay",o[o.ColorOverlay=2]="ColorOverlay",o[o.ColorOverlayWithWater=3]="ColorOverlayWithWater",o[o.COUNT=4]="COUNT"}(T||(T={}));class m extends h{constructor(){super(...arguments),this.output=r.Color,this.textureCoordinateType=i.None,this.componentData=e.Uniform,this.cullFace=c.Back,this.vertexDiscardMode=t.None,this.doubleSidedMode=a.WindingOrder,this.alphaDiscardMode=u.Opaque,this.integratedMeshMode=T.None,this.transparencyPassType=y.NONE,this.ellipsoidMode=n.Earth,this.pbrMode=p.Disabled,this.normalType=s.Attribute,this.spherical=!1,this.doublePrecisionRequiresObfuscation=!1,this.hasVertexColors=!1,this.hasNormals=!1,this.hasSlicePlane=!1,this.hasBaseColorTexture=!1,this.receiveAmbientOcclusion=!0,this.receiveShadows=!0,this.blendingEnabled=!0,this.hasScreenSpaceReflections=!1,this.hasPolygonOffset=!1,this.hasMetalnessAndRoughnessTexture=!1,this.hasEmissionTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.hasOccludees=!1,this.hasMultipassTerrain=!1,this.cullAboveGround=!1,this.isGround=!1,this.hasCloudsReflections=!0,this.snowCover=!1}}o([l({count:r.COUNT})],m.prototype,"output",void 0),o([l({count:i.COUNT})],m.prototype,"textureCoordinateType",void 0),o([l({count:e.COUNT})],m.prototype,"componentData",void 0),o([l({count:c.COUNT})],m.prototype,"cullFace",void 0),o([l({count:t.COUNT})],m.prototype,"vertexDiscardMode",void 0),o([l({count:a.COUNT})],m.prototype,"doubleSidedMode",void 0),o([l({count:u.COUNT})],m.prototype,"alphaDiscardMode",void 0),o([l({count:T.COUNT})],m.prototype,"integratedMeshMode",void 0),o([l({count:y.COUNT})],m.prototype,"transparencyPassType",void 0),o([l({count:n.COUNT})],m.prototype,"ellipsoidMode",void 0),o([l({count:p.COUNT})],m.prototype,"pbrMode",void 0),o([l({count:s.COUNT})],m.prototype,"normalType",void 0),o([l()],m.prototype,"spherical",void 0),o([l()],m.prototype,"doublePrecisionRequiresObfuscation",void 0),o([l()],m.prototype,"hasVertexColors",void 0),o([l()],m.prototype,"hasNormals",void 0),o([l()],m.prototype,"hasSlicePlane",void 0),o([l()],m.prototype,"hasBaseColorTexture",void 0),o([l()],m.prototype,"receiveAmbientOcclusion",void 0),o([l()],m.prototype,"receiveShadows",void 0),o([l()],m.prototype,"blendingEnabled",void 0),o([l()],m.prototype,"hasScreenSpaceReflections",void 0),o([l()],m.prototype,"hasPolygonOffset",void 0),o([l()],m.prototype,"hasMetalnessAndRoughnessTexture",void 0),o([l()],m.prototype,"hasEmissionTexture",void 0),o([l()],m.prototype,"hasOcclusionTexture",void 0),o([l()],m.prototype,"hasNormalTexture",void 0),o([l()],m.prototype,"hasOccludees",void 0),o([l()],m.prototype,"hasMultipassTerrain",void 0),o([l()],m.prototype,"cullAboveGround",void 0),o([l()],m.prototype,"isGround",void 0),o([l()],m.prototype,"hasCloudsReflections",void 0),o([l()],m.prototype,"snowCover",void 0),o([l({constValue:d.Draw})],m.prototype,"pbrTextureBindType",void 0),o([l({constValue:!0})],m.prototype,"hasSliceHighlight",void 0),o([l({constValue:!1})],m.prototype,"hasSliceInVertexProgram",void 0),o([l({constValue:!1})],m.prototype,"useCustomDTRExponentForWater",void 0),o([l({constValue:!1})],m.prototype,"hasVertexTangents",void 0),o([l({constValue:!0})],m.prototype,"supportsTextureAtlas",void 0),o([l({constValue:!1})],m.prototype,"highStepCount",void 0),o([l({constValue:!1})],m.prototype,"instancedDoublePrecision",void 0),o([l({constValue:!0})],m.prototype,"useFillLights",void 0);export{m as ComponentTechniqueConfiguration,T as IntegratedMeshMode,v as PassDiscardMode};
5
+ import{_ as o}from"../../../../../../chunks/tslib.es6.js";import{ComponentDataType as e}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as t}from"./shader/VertexDiscardByOpacity.glsl.js";import{ShaderOutput as r}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalAttributeType as s}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttributeType as i}from"../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{NormalsDoubleSidedMode as a}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as p}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{EllipsoidMode as n}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{BindType as d}from"../../../core/shaderTechnique/BindType.js";import{parameter as l,ShaderTechniqueConfiguration as h}from"../../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{CullFaceOptions as c,AlphaDiscardMode as u}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as y}from"../../../lib/TransparencyPassType.js";var v,T;!function(o){o[o.None=0]="None",o[o.Transparent=1]="Transparent",o[o.Opaque=2]="Opaque",o[o.COUNT=3]="COUNT"}(v||(v={})),function(o){o[o.None=0]="None",o[o.NoOverlay=1]="NoOverlay",o[o.ColorOverlay=2]="ColorOverlay",o[o.ColorOverlayWithWater=3]="ColorOverlayWithWater",o[o.COUNT=4]="COUNT"}(T||(T={}));class m extends h{constructor(){super(...arguments),this.output=r.Color,this.textureCoordinateType=i.None,this.componentData=e.Uniform,this.cullFace=c.Back,this.vertexDiscardMode=t.None,this.doubleSidedMode=a.WindingOrder,this.alphaDiscardMode=u.Opaque,this.integratedMeshMode=T.None,this.transparencyPassType=y.NONE,this.ellipsoidMode=n.Earth,this.pbrMode=p.Disabled,this.normalType=s.Attribute,this.spherical=!1,this.doublePrecisionRequiresObfuscation=!1,this.hasVertexColors=!1,this.hasNormals=!1,this.hasSlicePlane=!1,this.hasBaseColorTexture=!1,this.receiveAmbientOcclusion=!0,this.receiveShadows=!0,this.blendingEnabled=!0,this.hasScreenSpaceReflections=!1,this.hasPolygonOffset=!1,this.hasMetalnessAndRoughnessTexture=!1,this.hasEmissionTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.hasOccludees=!1,this.hasMultipassTerrain=!1,this.cullAboveGround=!1,this.isGround=!1,this.hasCloudsReflections=!0,this.snowCover=!1}}o([l({count:r.COUNT})],m.prototype,"output",void 0),o([l({count:i.COUNT})],m.prototype,"textureCoordinateType",void 0),o([l({count:e.COUNT})],m.prototype,"componentData",void 0),o([l({count:c.COUNT})],m.prototype,"cullFace",void 0),o([l({count:t.COUNT})],m.prototype,"vertexDiscardMode",void 0),o([l({count:a.COUNT})],m.prototype,"doubleSidedMode",void 0),o([l({count:u.COUNT})],m.prototype,"alphaDiscardMode",void 0),o([l({count:T.COUNT})],m.prototype,"integratedMeshMode",void 0),o([l({count:y.COUNT})],m.prototype,"transparencyPassType",void 0),o([l({count:n.COUNT})],m.prototype,"ellipsoidMode",void 0),o([l({count:p.COUNT})],m.prototype,"pbrMode",void 0),o([l({count:s.COUNT})],m.prototype,"normalType",void 0),o([l()],m.prototype,"spherical",void 0),o([l()],m.prototype,"doublePrecisionRequiresObfuscation",void 0),o([l()],m.prototype,"hasVertexColors",void 0),o([l()],m.prototype,"hasNormals",void 0),o([l()],m.prototype,"hasSlicePlane",void 0),o([l()],m.prototype,"hasBaseColorTexture",void 0),o([l()],m.prototype,"receiveAmbientOcclusion",void 0),o([l()],m.prototype,"receiveShadows",void 0),o([l()],m.prototype,"blendingEnabled",void 0),o([l()],m.prototype,"hasScreenSpaceReflections",void 0),o([l()],m.prototype,"hasPolygonOffset",void 0),o([l()],m.prototype,"hasMetalnessAndRoughnessTexture",void 0),o([l()],m.prototype,"hasEmissionTexture",void 0),o([l()],m.prototype,"hasOcclusionTexture",void 0),o([l()],m.prototype,"hasNormalTexture",void 0),o([l()],m.prototype,"hasOccludees",void 0),o([l()],m.prototype,"hasMultipassTerrain",void 0),o([l()],m.prototype,"cullAboveGround",void 0),o([l()],m.prototype,"isGround",void 0),o([l()],m.prototype,"hasCloudsReflections",void 0),o([l()],m.prototype,"snowCover",void 0),o([l({constValue:d.Draw})],m.prototype,"pbrTextureBindType",void 0),o([l({constValue:!0})],m.prototype,"hasSliceHighlight",void 0),o([l({constValue:!1})],m.prototype,"hasSliceInVertexProgram",void 0),o([l({constValue:!1})],m.prototype,"useCustomDTRExponentForWater",void 0),o([l({constValue:!1})],m.prototype,"hasVertexTangents",void 0),o([l({constValue:!0})],m.prototype,"supportsTextureAtlas",void 0),o([l({constValue:!1})],m.prototype,"highStepCount",void 0),o([l({constValue:!1})],m.prototype,"instancedDoublePrecision",void 0),o([l({constValue:!0})],m.prototype,"useFillLights",void 0);export{m as ComponentTechniqueConfiguration,T as IntegratedMeshMode,v as PassDiscardMode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../../../geometry/support/Ellipsoid.js";import"../../../../../terrain/interfaces.js";import"../ComponentTechniqueConfiguration.js";import"./ComponentData.glsl.js";import"./VertexDiscardByOpacity.glsl.js";import"../../../../core/shaderLibrary/ForwardLinearDepth.glsl.js";import"../../../../core/shaderLibrary/ShaderOutputOptions.js";import"../../../../core/shaderLibrary/Slice.glsl.js";import"../../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import"../../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../../core/shaderLibrary/output/ReadLinearDepth.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeShadingNormal.glsl.js";import"../../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import"../../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../../core/shaderLibrary/util/AlphaCutoff.js";import"../../../../core/shaderLibrary/util/AlphaDiscard.glsl.js";import"../../../../core/shaderLibrary/util/EllipsoidMode.js";import"../../../../core/shaderModules/Float3PassUniform.js";import"../../../../core/shaderModules/FloatPassUniform.js";import"../../../../core/shaderModules/interfaces.js";import"../../../../core/shaderModules/ShaderBuilder.js";import"../../../../core/shaderModules/Texture2DPassUniform.js";import"../../../../lib/basicInterfaces.js";import"../../../../lib/VertexAttribute.js";export{a as attributeLocations,b as build,g as getOverlayNormalTexture}from"../../../../../../../chunks/ComponentShader.glsl.js";
5
+ import"../../../../../../../geometry/support/Ellipsoid.js";import"../../../../../terrain/interfaces.js";import"../ComponentTechniqueConfiguration.js";import"./ComponentData.glsl.js";import"./VertexDiscardByOpacity.glsl.js";import"../../../../core/shaderLibrary/ForwardLinearDepth.glsl.js";import"../../../../core/shaderLibrary/ShaderOutput.js";import"../../../../core/shaderLibrary/Slice.glsl.js";import"../../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import"../../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../../core/shaderLibrary/output/ReadLinearDepth.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeShadingNormal.glsl.js";import"../../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import"../../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../../core/shaderLibrary/util/AlphaCutoff.js";import"../../../../core/shaderLibrary/util/AlphaDiscard.glsl.js";import"../../../../core/shaderLibrary/util/EllipsoidMode.js";import"../../../../core/shaderModules/Float3PassUniform.js";import"../../../../core/shaderModules/FloatPassUniform.js";import"../../../../core/shaderModules/interfaces.js";import"../../../../core/shaderModules/ShaderBuilder.js";import"../../../../core/shaderModules/Texture2DPassUniform.js";import"../../../../lib/TransparencyPassType.js";export{b as build,g as getOverlayNormalTexture}from"../../../../../../../chunks/ComponentShader.glsl.js";
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{unwrap as e}from"../../../../../core/maybe.js";import t from"../../../../../core/PooledArray.js";import{TransparencyPassType as r}from"../../lib/basicInterfaces.js";import{DataType as i}from"../../../../webgl/enums.js";var s;!function(e){e[e.FrontToBack=0]="FrontToBack",e[e.BackToFront=1]="BackToFront"}(s||(s={}));class o{constructor(e,r,i=s.FrontToBack){this._rctx=e,this._techniqueRepository=r,this._sorting=i,this._draws=new t({initialSize:32,allocator:e=>e||{material:null,geometry:null,geometryRanges:null,bindDrawParams:null,depthSquaredHint:0,indexType:0}}),this._previouslyBoundDraw=new Map}submitDraw(t,r,i,s){const o=this._draws.pushNew();o.geometry=r,o.geometryRanges=i,o.material=t,o.depthSquaredHint=s,o.indexType=r.indexed?e(r.vao.indexBuffer).indexType:0}dispatch(e,t){const i=this._rctx;this._previouslyBoundDraw.clear();let s=null;const o=this._draws.map((r=>r.material.prepareTechnique(this._techniqueRepository,e,t,r.geometry.parameters))),n=this._draws.length;for(let c=0;c<n;c++){const n=o[c];n===s&&n.configuration.transparencyPassType===r.NONE||(i.bindTechnique(n,e,t),s=n);const d=this._draws.data[c],l=d.geometry;i.bindVAO(l.vao),this._previouslyBoundDraw.get(n)!==d.material&&(n.bindDraw(d.material,t,e),this._previouslyBoundDraw.set(n,d.material));const p=d.geometryRanges,m=p.length;if(0!==d.indexType){const e=a.get(d.indexType);for(let t=0;t<m;t+=2){const r=p[t],s=p[t+1];i.drawElements(l.primitiveType,s,d.indexType,r*e)}}else for(let e=0;e<m;e+=2){const t=p[e],r=p[e+1];i.drawArrays(l.primitiveType,t,r)}}}prepareSubmit(){this._draws.clear()}finishSubmit(){const e=this._sorting===s.FrontToBack?1:-1;this._draws.sort(((t,r)=>{const i=e*(t.depthSquaredHint-r.depthSquaredHint);return 0!==i?i:t.geometry.vao.size-r.geometry.vao.size}))}get count(){return this._draws.length}}const a=new Map;a.set(i.UNSIGNED_BYTE,1),a.set(i.UNSIGNED_SHORT,2),a.set(i.UNSIGNED_INT,4);export{o as RenderPass,s as RenderPassSorting};
5
+ import{unwrap as e}from"../../../../../core/maybe.js";import t from"../../../../../core/PooledArray.js";import{TransparencyPassType as r}from"../../lib/TransparencyPassType.js";import{DataType as i}from"../../../../webgl/enums.js";var s;!function(e){e[e.FrontToBack=0]="FrontToBack",e[e.BackToFront=1]="BackToFront"}(s||(s={}));class o{constructor(e,r,i=s.FrontToBack){this._rctx=e,this._techniqueRepository=r,this._sorting=i,this._draws=new t({initialSize:32,allocator:e=>e||{material:null,geometry:null,geometryRanges:null,bindDrawParams:null,depthSquaredHint:0,indexType:0}}),this._previouslyBoundDraw=new Map}submitDraw(t,r,i,s){const o=this._draws.pushNew();o.geometry=r,o.geometryRanges=i,o.material=t,o.depthSquaredHint=s,o.indexType=r.indexed?e(r.vao.indexBuffer).indexType:0}dispatch(e,t){const i=this._rctx;this._previouslyBoundDraw.clear();let s=null;const o=this._draws.map((r=>r.material.prepareTechnique(this._techniqueRepository,e,t,r.geometry.parameters))),n=this._draws.length;for(let p=0;p<n;p++){const n=o[p];n===s&&n.configuration.transparencyPassType===r.NONE||(i.bindTechnique(n,e,t),s=n);const c=this._draws.data[p],d=c.geometry;i.bindVAO(d.vao),this._previouslyBoundDraw.get(n)!==c.material&&(n.program.bindDraw(c.material,t,e),this._previouslyBoundDraw.set(n,c.material));const l=c.geometryRanges,m=l.length;if(0!==c.indexType){const e=a.get(c.indexType);for(let t=0;t<m;t+=2){const r=l[t],s=l[t+1];i.drawElements(d.primitiveType,s,c.indexType,r*e)}}else for(let e=0;e<m;e+=2){const t=l[e],r=l[e+1];i.drawArrays(d.primitiveType,t,r)}}}prepareSubmit(){this._draws.clear()}finishSubmit(){const e=this._sorting===s.FrontToBack?1:-1;this._draws.sort(((t,r)=>{const i=e*(t.depthSquaredHint-r.depthSquaredHint);return 0!==i?i:t.geometry.vao.size-r.geometry.vao.size}))}get count(){return this._draws.length}}const a=new Map;a.set(i.UNSIGNED_BYTE,1),a.set(i.UNSIGNED_SHORT,2),a.set(i.UNSIGNED_INT,4);export{o as RenderPass,s as RenderPassSorting};