@arcgis/core 5.0.0-next.16 → 5.0.0-next.18

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 (262) hide show
  1. package/analysis/ElevationProfile/ElevationProfileLineInput.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{adf7ccf4ef629211c7ee.js → 08aacbfb651cc2e1c054.js} +1 -1
  4. package/assets/esri/core/workers/chunks/234b52b2a391631ceff6.js +1 -0
  5. package/assets/esri/core/workers/chunks/{658cd45b5fb304fd840a.js → 3aa77696c5ea54a238da.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{8f3503b2fb6cd38757b9.js → 458e87902abc24b375da.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{57b410198d83bf0ab708.js → 4a89e120be142ab58a27.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{49571d6875de1f2e7e25.js → 4b9dfdc23ba3d6ebcc1b.js} +2 -2
  9. package/assets/esri/core/workers/chunks/{a410dcf80d17a2383337.js → 65a4099bdbe31834d0cc.js} +1 -1
  10. package/assets/esri/core/workers/chunks/722da7a39a0ad9300752.js +1 -0
  11. package/assets/esri/core/workers/chunks/{cdb4664fd59860ddeb5a.js → 72f1c3d97e7b9546c113.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{bc318b6fef192cee2a72.js → 76e945da8f30d8641c3d.js} +20 -20
  13. package/assets/esri/core/workers/chunks/{319c3f46f2afb8f3e5a9.js → 89c9cf7f799858d14c76.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{e19cd07df8ce87e18832.js → 8b33732e3c2924c1f60d.js} +1 -1
  15. package/assets/esri/core/workers/chunks/98739414c107ad78e4d8.js +1 -0
  16. package/assets/esri/core/workers/chunks/{8b73db0f4d6714396eb0.js → a6fa90eab77ac0e1cdfc.js} +1 -1
  17. package/assets/esri/core/workers/chunks/ac366221e8636b60aee5.js +1 -0
  18. package/assets/esri/core/workers/chunks/{23e17b745adf71a5efc7.js → aca72ca7f43f70eb8077.js} +1 -1
  19. package/assets/esri/core/workers/chunks/ad0c7225941437d18408.js +1 -0
  20. package/assets/esri/core/workers/chunks/b30897952494a3e5b9fe.js +1 -0
  21. package/assets/esri/core/workers/chunks/bfd3d81e8e148be99686.js +1 -0
  22. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  23. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  24. package/assets/esri/themes/base/widgets/_Editor.scss +2 -1
  25. package/assets/esri/themes/base/widgets/_FeatureForm.scss +1 -1
  26. package/assets/esri/themes/dark/main.css +1 -1
  27. package/assets/esri/themes/light/main.css +1 -1
  28. package/assets/esri/themes/light/view.css +1 -1
  29. package/chunks/GaussianSplat.glsl.js +2 -2
  30. package/chunks/ImageMaterial.glsl.js +1 -1
  31. package/chunks/lyr3DMain.js +1 -1
  32. package/config.js +1 -1
  33. package/graphic/graphicOriginUtils.js +1 -1
  34. package/interfaces.d.ts +113 -54
  35. package/intl/locale.js +1 -1
  36. package/kernel.js +1 -1
  37. package/layers/BingMapsLayer.js +1 -1
  38. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  39. package/layers/support/attributionUtils.js +5 -0
  40. package/layers/support/fieldConfigUtils.js +1 -1
  41. package/layers/support/fieldFormatUtils.js +1 -1
  42. package/layers/video/VideoController.js +1 -1
  43. package/libs/parquet/parquet.js +1 -1
  44. package/package.json +1 -1
  45. package/support/revision.js +1 -1
  46. package/symbols/cim/SDFHelper.js +1 -1
  47. package/symbols/cim/cimAnalyzer.js +1 -1
  48. package/views/2d/LabelManager.js +1 -1
  49. package/views/2d/analysis/ElevationProfile/ElevationProfileLineVisualization2D.js +1 -1
  50. package/views/2d/engine/flow/dataUtils.js +1 -1
  51. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  52. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  53. package/views/2d/engine/webgl/TextureManager.js +1 -1
  54. package/views/2d/engine/webgl/VideoScreenRenderer.js +1 -1
  55. package/views/2d/engine/webgl/animations/store/AnimationStore.js +1 -1
  56. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AAnimatedPolyShader.js +1 -1
  57. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedFillShader.js +1 -1
  58. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedLineShader.js +1 -1
  59. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedPolyMeshWriters.js +1 -1
  60. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedTechnique.js +1 -1
  61. package/views/2d/engine/webgl/shaderGraph/techniques/colorize/ColorizeTechnique.js +1 -1
  62. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityResources.js +1 -1
  63. package/views/2d/engine/webgl/shaderGraph/techniques/drop-shadow/DropShadowTechnique.js +1 -1
  64. package/views/2d/engine/webgl/shaderGraph/techniques/opacity/OpacityTechnique.js +1 -1
  65. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
  66. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
  67. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  68. package/views/2d/engine/webgl/textureUtils.js +1 -1
  69. package/views/2d/layers/features/FeatureContainer.js +1 -1
  70. package/views/2d/layers/features/Processor.js +1 -1
  71. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  72. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  73. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  74. package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
  75. package/views/3d/GroundView3D.js +1 -1
  76. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  77. package/views/3d/analysis/ElevationProfile/ElevationProfileGeometryVisualization3D.js +1 -1
  78. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  79. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
  80. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
  81. package/views/3d/analysis/images/Factory.js +1 -1
  82. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  83. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  84. package/views/3d/environment/CloudsCompositionTechnique.js +1 -1
  85. package/views/3d/environment/CloudsTechnique.js +1 -1
  86. package/views/3d/environment/EnvironmentManager.js +1 -1
  87. package/views/3d/environment/FogTechnique.js +1 -1
  88. package/views/3d/environment/NoiseTextureAtlasTechnique.js +1 -1
  89. package/views/3d/environment/PrecipitationTechnique.js +1 -1
  90. package/views/3d/environment/SimpleAtmosphereTechnique.js +1 -1
  91. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  92. package/views/3d/layers/DrapedSubView3D.js +1 -1
  93. package/views/3d/layers/FlowSubView3D.js +1 -1
  94. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  95. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  96. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  97. package/views/3d/layers/MediaLayerView3D.js +1 -1
  98. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  99. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  100. package/views/3d/layers/SceneLayerView3D.js +1 -1
  101. package/views/3d/layers/TiledLayerView3D.js +1 -1
  102. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  103. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  104. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  105. package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
  106. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  107. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  108. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  109. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  110. package/views/3d/support/QualityProfile.js +5 -0
  111. package/views/3d/support/QualitySettings.js +1 -1
  112. package/views/3d/support/StreamTextureCollection.js +1 -1
  113. package/views/3d/support/TextureCollection.js +1 -1
  114. package/views/3d/support/engineContent/marker.js +1 -1
  115. package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
  116. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  117. package/views/3d/support/flow/FlowWorker.js +1 -1
  118. package/views/3d/support/flow/FlowWorkerHandle.js +1 -1
  119. package/views/3d/support/flow/StreamlineResources3D.js +1 -1
  120. package/views/3d/support/flow/StreamlineResources3DOverlay.js +1 -1
  121. package/views/3d/support/flow/StreamlineResources3DShape.js +1 -1
  122. package/views/3d/support/flow/constants.js +1 -1
  123. package/views/3d/support/flow/loadUtils.js +1 -1
  124. package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
  125. package/views/3d/support/popupHitTest.js +1 -1
  126. package/views/3d/terrain/BlendLayersTechnique.js +1 -1
  127. package/views/3d/terrain/OverlayRenderer.js +1 -1
  128. package/views/3d/terrain/RasterColorizerTechnique.js +1 -1
  129. package/views/3d/terrain/TerrainSurface.js +1 -1
  130. package/views/3d/terrain/TileAgent.js +1 -1
  131. package/views/3d/terrain/TileCompositor.js +1 -1
  132. package/views/3d/webgl-engine/Stage.js +1 -1
  133. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  134. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  135. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  136. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  137. package/views/3d/webgl-engine/core/material/MaterialBase.js +1 -1
  138. package/views/3d/webgl-engine/core/material/RenderTexture.js +1 -1
  139. package/views/3d/webgl-engine/core/shaderTechnique/{ReloadableShaderModule.js → ReloadableShader.js} +1 -1
  140. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js +1 -1
  141. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorTechnique.js +1 -1
  142. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskTechnique.js +1 -1
  143. package/views/3d/webgl-engine/effects/glow/GlowBlurTechnique.js +1 -1
  144. package/views/3d/webgl-engine/effects/glow/GlowCompositionTechnique.js +1 -1
  145. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  146. package/views/3d/webgl-engine/effects/haze/HazeCompositingTechnique.js +1 -1
  147. package/views/3d/webgl-engine/effects/haze/HazeTechnique.js +1 -1
  148. package/views/3d/webgl-engine/effects/highlight/HighlightApplyTechnique.js +1 -1
  149. package/views/3d/webgl-engine/effects/highlight/HighlightBlurTechnique.js +1 -1
  150. package/views/3d/webgl-engine/effects/highlight/HighlightDownsampleTechnique.js +1 -1
  151. package/views/3d/webgl-engine/effects/highlight/HighlightToSingleTechnique.js +1 -1
  152. package/views/3d/webgl-engine/effects/highlight/ShadowHighlightTechnique.js +1 -1
  153. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathTechnique.js +1 -1
  154. package/views/3d/webgl-engine/effects/laserlines/LaserlineTechnique.js +1 -1
  155. package/views/3d/webgl-engine/effects/magnifier/MagnifierTechnique.js +1 -1
  156. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  157. package/views/3d/webgl-engine/effects/smaa/SMAABlendWeightsTechnique.js +1 -1
  158. package/views/3d/webgl-engine/effects/smaa/SMAABlurTechnique.js +1 -1
  159. package/views/3d/webgl-engine/effects/smaa/SMAAEdgeDetectTechnique.js +1 -1
  160. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  161. package/views/3d/webgl-engine/effects/ssao/SSAOBlurTechnique.js +1 -1
  162. package/views/3d/webgl-engine/effects/ssao/SSAOTechnique.js +1 -1
  163. package/views/3d/webgl-engine/effects/stars/StarsTechnique.js +1 -1
  164. package/views/3d/webgl-engine/effects/transparency/OITBlendTechnique.js +1 -1
  165. package/views/3d/webgl-engine/lib/AnimationTimeStep.js +1 -1
  166. package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
  167. package/views/3d/webgl-engine/lib/DDSUtil.js +1 -1
  168. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  169. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  170. package/views/3d/webgl-engine/lib/ManagedTexture.js +5 -0
  171. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  172. package/views/3d/webgl-engine/lib/Program.js +1 -1
  173. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  174. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  175. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  176. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  177. package/views/3d/webgl-engine/lib/TextTextureFactory.js +1 -1
  178. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  179. package/views/3d/webgl-engine/lib/TextureTechnique.js +1 -1
  180. package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderTechnique.js +1 -1
  181. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  182. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  183. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  184. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  185. package/views/3d/webgl-engine/materials/internal/WaterTextureRepository.js +1 -1
  186. package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
  187. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  188. package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
  189. package/views/3d/webgl-engine/shaders/CheckerBoardTechnique.js +1 -1
  190. package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
  191. package/views/3d/webgl-engine/shaders/CompositingTechnique.js +1 -1
  192. package/views/3d/webgl-engine/shaders/CutFillCompositionTechnique.js +1 -1
  193. package/views/3d/webgl-engine/shaders/CutFillDepthTechnique.js +1 -1
  194. package/views/3d/webgl-engine/shaders/CutFillMaskTechnique.js +1 -1
  195. package/views/3d/webgl-engine/shaders/CutFillReductionTechnique.js +1 -1
  196. package/views/3d/webgl-engine/shaders/CutFillTargetDepthTechnique.js +1 -1
  197. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  198. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  199. package/views/3d/webgl-engine/shaders/GaussianSplatCompositionTechnique.js +1 -1
  200. package/views/3d/webgl-engine/shaders/GaussianSplatDepthCompositionTechnique.js +1 -1
  201. package/views/3d/webgl-engine/shaders/GaussianSplatDepthTechnique.js +1 -1
  202. package/views/3d/webgl-engine/shaders/GaussianSplatTechnique.js +1 -1
  203. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  204. package/views/3d/webgl-engine/shaders/HUDCompositingTechnique.js +1 -1
  205. package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
  206. package/views/3d/webgl-engine/shaders/HeatmapDensityTechnique.js +1 -1
  207. package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +1 -1
  208. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  209. package/views/3d/webgl-engine/shaders/LineCalloutTechnique.js +1 -1
  210. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  211. package/views/3d/webgl-engine/shaders/MeasurementArrowTechnique.js +1 -1
  212. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  213. package/views/3d/webgl-engine/shaders/OverlayCompositingTechnique.js +1 -1
  214. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  215. package/views/3d/webgl-engine/shaders/PointRendererTechnique.js +1 -1
  216. package/views/3d/webgl-engine/shaders/RealisticTreeTechnique.js +1 -1
  217. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  218. package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechnique.js +1 -1
  219. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  220. package/views/3d/webgl-engine/shaders/ShadowCastClearTechnique.js +1 -1
  221. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
  222. package/views/3d/webgl-engine/shaders/SlicePlaneMaterialTechnique.js +1 -1
  223. package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
  224. package/views/3d/webgl-engine/shaders/ViewshedTechnique.js +1 -1
  225. package/views/GroundView.js +1 -1
  226. package/views/SceneView.js +1 -1
  227. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  228. package/views/analysis/ElevationProfile/types.d.ts +5 -0
  229. package/views/analysis/ElevationProfile/types.js +5 -0
  230. package/views/support/layerViewUtils.js +1 -1
  231. package/views/webgl/Texture.js +1 -1
  232. package/views/webgl/VertexAttributeLocations.js +1 -1
  233. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  234. package/widgets/Attribution/AttributionViewModel.js +1 -1
  235. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  236. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  237. package/widgets/Editor/UpdateWorkflow.js +1 -1
  238. package/widgets/Editor/Workflow.js +1 -1
  239. package/widgets/Editor/components/CreateFeaturesPanelContent.js +1 -1
  240. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  241. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  242. package/widgets/Editor.js +1 -1
  243. package/widgets/Feature/support/featureUtils.js +1 -1
  244. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  245. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
  246. package/widgets/FeatureTable/FieldColumn.js +1 -1
  247. package/widgets/FeatureTable/Grid/Column.js +1 -1
  248. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  249. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  250. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  251. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  252. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  253. package/assets/esri/core/workers/chunks/38ee69125da60464d5a1.js +0 -1
  254. package/assets/esri/core/workers/chunks/4f0016111fd84c612f41.js +0 -1
  255. package/assets/esri/core/workers/chunks/8208dfa8f7fae7e616b9.js +0 -1
  256. package/assets/esri/core/workers/chunks/847f4fc39100fac1df01.js +0 -1
  257. package/assets/esri/core/workers/chunks/ab005fe84952f0676020.js +0 -1
  258. package/assets/esri/core/workers/chunks/bc19a232076d98825eef.js +0 -1
  259. package/assets/esri/core/workers/chunks/c3dcfe26c2c3c829762d.js +0 -1
  260. package/views/3d/support/DisplayQualityProfile.js +0 -5
  261. package/views/3d/webgl-engine/lib/Texture.js +0 -5
  262. /package/views/3d/webgl-engine/lib/{ITexture.js → IManagedTexture.js} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{createPrimitive as r}from"./sdfPrimitives.js";import{SizedPixelFormat as e,PixelType as t}from"../../../webgl/enums.js";import{Texture as o}from"../../../webgl/Texture.js";import{TextureDescriptor as m}from"../../../webgl/TextureDescriptor.js";const i=64,s=i/2,n=s/5,p=i/n,a=.25;function f(p,a){const f=r(p,i,s,n),u=new m(i);return u.internalFormat=e.R16F,u.dataType=t.FLOAT,u.pixelFormat=6403,u.wrapMode=33071,new o(a,u,f)}export{f as createMarkerTexture,p as markerSizePerLineWidth,s as markerSymbolSize,i as markerTextureSize,n as markerThickness,a as markerTipThicknessFactor};
5
+ import{createPrimitive as r}from"./sdfPrimitives.js";import{SizedPixelFormat as e,PixelType as t}from"../../../webgl/enums.js";import{Texture as o}from"../../../webgl/Texture.js";import{TextureDescriptor as m}from"../../../webgl/TextureDescriptor.js";const i=64,n=i/2,s=n/5,p=i/s,a=.25;function f(p,a){const f=r(p,i,n,s),w=new m(i);return w.internalFormat=e.R16F,w.dataType=t.FLOAT,w.pixelFormat=6403,w.wrapMode=33071,new o(a,w,f)}export{f as createMarkerTexture,p as markerSizePerLineWidth,n as markerSymbolSize,i as markerTextureSize,s as markerThickness,a as markerTipThicknessFactor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{freeze as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Texture as r}from"../../webgl-engine/lib/Texture.js";import{SizedPixelFormat as n,PixelType as e}from"../../../webgl/enums.js";const a=128,o=.5,u=t(o/2,o/2,1-o/2,1-o/2);function s(t){return"cross"===t||"x"===t}function c(t,n=a,e=n*o,u=0){const{data:s,parameters:c}=i(t,n,e,u);return new r(s,c)}function i(t,r=a,u=r*o,s=0){return{data:f(t,r,u,s),parameters:{mipmap:!1,wrap:{s:33071,t:33071},width:r,height:r,noUnpackFlip:!0,dataType:e.FLOAT,pixelFormat:6403,internalFormat:n.R16F,reloadable:!0}}}function f(t,r=a,n=r*o,e=0){switch(t){case"circle":default:return h(r,n);case"square":return M(r,n);case"cross":return m(r,n,e);case"x":return p(r,n,e);case"kite":return l(r,n);case"triangle":return b(r,n);case"arrow":return x(r,n)}}function h(t,r){const n=t/2-.5;return g(t,R(n,n,r/2))}function M(t,r){return T(t,r,!1)}function l(t,r){return T(t,r,!0)}function m(t,r,n=0){return w(t,r,!1,n)}function p(t,r,n=0){return w(t,r,!0,n)}function b(t,r){return g(t,d(t/2,r,r/2))}function x(t,r){const n=r,e=r/2,a=t/2,o=.8*n,u=R(a,(t-r)/2-o,Math.sqrt(o*o+e*e)),s=d(a,n,e);return g(t,(t,r)=>Math.max(s(t,r),-u(t,r)))}function T(t,r,n){return n&&(r/=Math.SQRT2),g(t,(e,a)=>{let o=e-.5*t+.25,u=.5*t-a-.75;if(n){const t=(o+u)/Math.SQRT2;u=(u-o)/Math.SQRT2,o=t}return Math.max(Math.abs(o),Math.abs(u))-.5*r})}function w(t,r,n,e=0){r-=e,n&&(r*=Math.SQRT2);const a=.5*r;return g(t,(r,o)=>{let u,s=r-.5*t,c=.5*t-o-1;if(n){const t=(s+c)/Math.SQRT2;c=(c-s)/Math.SQRT2,s=t}return s=Math.abs(s),c=Math.abs(c),u=s>c?s>a?Math.sqrt((s-a)*(s-a)+c*c):c:c>a?Math.sqrt(s*s+(c-a)*(c-a)):s,u-=e/2,u})}function R(t,r,n){return(e,a)=>{const o=e-t,u=a-r;return Math.sqrt(o*o+u*u)-n}}function d(t,r,n){const e=Math.sqrt(r*r+n*n);return(a,o)=>{const u=Math.abs(a-t)-n,s=o-t+r/2+.75,c=(r*u+n*s)/e,i=-s;return Math.max(c,i)}}function g(t,r){const n=new Float32Array(t*t);for(let e=0;e<t;e++)for(let a=0;a<t;a++){n[a+t*e]=r(a,e)/t}return n}export{x as createArrow,h as createCircle,m as createCross,l as createKite,f as createPrimitive,M as createSquare,c as createTexture,i as createTextureInfo,b as createTriangle,p as createX,u as defaultBoundingBox,o as defaultSymbolSizeRatio,a as defaultTexSize,s as requiresHalfTexelOffset};
5
+ import"../../../../core/has.js";import{freeze as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ManagedTexture as r}from"../../webgl-engine/lib/ManagedTexture.js";import{SizedPixelFormat as n,PixelType as e}from"../../../webgl/enums.js";const a=128,o=.5,u=t(o/2,o/2,1-o/2,1-o/2);function s(t){return"cross"===t||"x"===t}function c(t,n=a,e=n*o,u=0){const{data:s,parameters:c}=i(t,n,e,u);return new r(s,c)}function i(t,r=a,u=r*o,s=0){return{data:f(t,r,u,s),parameters:{mipmap:!1,wrap:{s:33071,t:33071},width:r,height:r,noUnpackFlip:!0,dataType:e.FLOAT,pixelFormat:6403,internalFormat:n.R16F,reloadable:!0}}}function f(t,r=a,n=r*o,e=0){switch(t){case"circle":default:return h(r,n);case"square":return M(r,n);case"cross":return m(r,n,e);case"x":return p(r,n,e);case"kite":return l(r,n);case"triangle":return b(r,n);case"arrow":return x(r,n)}}function h(t,r){const n=t/2-.5;return R(t,d(n,n,r/2))}function M(t,r){return T(t,r,!1)}function l(t,r){return T(t,r,!0)}function m(t,r,n=0){return w(t,r,!1,n)}function p(t,r,n=0){return w(t,r,!0,n)}function b(t,r){return R(t,g(t/2,r,r/2))}function x(t,r){const n=r,e=r/2,a=t/2,o=.8*n,u=d(a,(t-r)/2-o,Math.sqrt(o*o+e*e)),s=g(a,n,e);return R(t,(t,r)=>Math.max(s(t,r),-u(t,r)))}function T(t,r,n){return n&&(r/=Math.SQRT2),R(t,(e,a)=>{let o=e-.5*t+.25,u=.5*t-a-.75;if(n){const t=(o+u)/Math.SQRT2;u=(u-o)/Math.SQRT2,o=t}return Math.max(Math.abs(o),Math.abs(u))-.5*r})}function w(t,r,n,e=0){r-=e,n&&(r*=Math.SQRT2);const a=.5*r;return R(t,(r,o)=>{let u,s=r-.5*t,c=.5*t-o-1;if(n){const t=(s+c)/Math.SQRT2;c=(c-s)/Math.SQRT2,s=t}return s=Math.abs(s),c=Math.abs(c),u=s>c?s>a?Math.sqrt((s-a)*(s-a)+c*c):c:c>a?Math.sqrt(s*s+(c-a)*(c-a)):s,u-=e/2,u})}function d(t,r,n){return(e,a)=>{const o=e-t,u=a-r;return Math.sqrt(o*o+u*u)-n}}function g(t,r,n){const e=Math.sqrt(r*r+n*n);return(a,o)=>{const u=Math.abs(a-t)-n,s=o-t+r/2+.75,c=(r*u+n*s)/e,i=-s;return Math.max(c,i)}}function R(t,r){const n=new Float32Array(t*t);for(let e=0;e<t;e++)for(let a=0;a<t;a++){n[a+t*e]=r(a,e)/t}return n}export{x as createArrow,h as createCircle,m as createCross,l as createKite,f as createPrimitive,M as createSquare,c as createTexture,i as createTextureInfo,b as createTriangle,p as createX,u as defaultBoundingBox,o as defaultSymbolSizeRatio,a as defaultTexSize,s as requiresHalfTexelOffset};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{watch as t,sync as s}from"../../../../core/reactiveUtils.js";import{throttle as r}from"../../../../core/throttle.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{clone as a}from"../../../../geometry/support/aaBoundingRect.js";import{toFlowData as o}from"../../../2d/engine/flow/dataUtils.js";import n from"../../layers/FlowSubView3D.js";import{tilesWaitingTime as d}from"./constants.js";import{tileToKey as h,FlowDataTile as u}from"./loadUtils.js";import{isRasterTile as g}from"../../terrain/TerrainData.js";let c=class extends n{constructor(e){super(e),this._resetTileData=!0,this._throttledTriggerLoad=null,this._throttling=!1}initialize(){this.addHandles([this.surface.on("tile-data-changed",({tile:e,layerIndex:t,layerClass:s})=>{null!=this.renderedTiles&&this.loadByTileTreesAllowed&&t===this._layerIndex&&1===s&&this._updateFlowDataTile(e)}),t(()=>this.renderedTiles,e=>{const t=this.frameTask.scheduleGenerator(t=>this._updateFlowDataTiles(e,t));this.updatingHandles.addPromise(t)},s)]),this._throttledTriggerLoad=r(()=>{super.triggerLoad(),this._throttling=!1},()=>this._throttling=!0,d,this),this.addHandles(this._throttledTriggerLoad)}async*_updateFlowDataTiles(e,t){const s=f();for(const r of e??[]){const e=this._flowDataTiles?.get(h(r)),i=null==e||"delete"===e||"waiting"===e?this._getFlowDataCopy(r):e;null!=i&&s.set(h(r),i),t.madeProgress(),t.done&&(t=yield)}this._flowDataTiles=s,this._resetTileData=!0,this.triggerLoad()}abort(){super.abort(),this._throttling=!1}get _layerIndex(){return this.surface.getLayerIndexByUID(1,this.layerView.uid)}get loadByTileTreesAllowed(){return super.loadByTileTreesAllowed||!this._allTilesLoaded}doRefresh(){const{_flowDataTiles:e}=this;null!=e&&(e.forEach((t,s)=>{e.set(s,"waiting")}),super.doRefresh())}triggerLoad(){const{_throttledTriggerLoad:e}=this;this._allTilesLoaded?(e.hasPendingUpdates()||e(),e.forceUpdate()):e()}async fetchDataAndGenerateStreamlines(e,t){const{_flowDataTiles:s,needsMagnitude:r,workerHandle:i}=this,l=this.getSimulationSettings(e);if(null==l||null==i||null==s)return;const a=this._resetTileData;this._resetTileData=!1;const o=f();s.forEach((e,t)=>{"delete"===e?(o.set(t,"delete"),s.delete(t)):(a||"on-worker"!==e&&"waiting"!==e)&&(o.set(t,e),s.set(t,"on-worker"))});const n={simulationSettings:l,flowExtentInfo:e.flowExtentInfo,flowDataTiles:o,pixelSize:this.surface.tilingScheme.pixelSize,reset:a,needsMagnitude:r,startPositions:this.startPositions(e)},{streamlines:d}=await i.generateTiledStreamlines(n,t);return d}getUpdating(){return super.getUpdating()||this._throttling}_getFlowDataCopy(e){const{_layerIndex:t}=this,s=null==e.surface;if(null==t||s)return null;const r=e.getLayerInfo(t,1);if(null==r)return null;if(!e.visible&&null==r.requestAbort)return r.requestAbort=new AbortController,this.surface.requestTileData(e,t,1,r.requestAbort),null;if(r.dataMissing||!e.hasLayerData(t,1))return null;const{data:i}=r;if(!g(i))return null;const l=o(this.layer.serviceRasterInfo.dataType,i.source),n=new Uint8Array(l.width*l.height);for(let a=0;a<n.length;a++)n[a]=l.mask[a];return new u(l.data,n,l.width,l.height,e.lij,a(e.extent))}_updateFlowDataTile(e){const t=this.renderedTiles?.has(e)?this._getFlowDataCopy(e)??"delete":"delete";this._setTileData(e,t)&&this.triggerLoad()}_setTileData(e,t){const{_flowDataTiles:s}=this;if(null==s)return!1;const r=h(e);return(null!=s.get(r)||"delete"!==t)&&(s.set(r,t),!0)}get _allTilesLoaded(){let e=0;for(const t of this._flowDataTiles?.values()??[])"delete"!==t&&"waiting"!==t&&e++;return e===this.renderedTiles?.size}get test(){return{...super.test,loadedTiles:this._flowDataTiles??f()}}};function f(){return new Map}e([i()],c.prototype,"_throttling",void 0),c=e([l("esri.views.3d.support.flow.FlowSubViewTiles3D")],c);export{c as default};
5
+ import{__decorate as e}from"tslib";import{watch as t,sync as s}from"../../../../core/reactiveUtils.js";import{throttle as i}from"../../../../core/throttle.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{clone as l}from"../../../../geometry/support/aaBoundingRect.js";import{toFlowData as o}from"../../../2d/engine/flow/dataUtils.js";import n from"../../layers/FlowSubView3D.js";import{tilesWaitingTime as d}from"./constants.js";import{tileToKey as u,FlowDataTile as h}from"./loadUtils.js";import{isRasterTile as p}from"../../terrain/TerrainData.js";const c={type:"delete"},g={type:"waiting"},f={type:"on-worker",upsampled:!1},_={type:"on-worker",upsampled:!0};let T=class extends n{constructor(e){super(e),this._resetTileData=!0,this._throttledTriggerLoad=null,this._throttling=!1}initialize(){this.addHandles([this.surface.on("tile-data-changed",({tile:e,layerIndex:t,layerClass:s})=>{null!=this.renderedTiles&&(this.loadByTileTreesAllowed||this._tileIsUpsampled(e))&&t===this._layerIndex&&1===s&&this._updateFlowDataTile(e)}),t(()=>this.renderedTiles,e=>{const t=this.frameTask.scheduleGenerator(t=>this._updateFlowDataTiles(e,t));this.updatingHandles.addPromise(t)},s),t(()=>this._pixelSize,()=>{this.invalidateTileData(),this._resetTileData=!0},s)]),this._throttledTriggerLoad=i(()=>{super.triggerLoad(),this._throttling=!1},()=>this._throttling=!0,d,this),this.addHandles(this._throttledTriggerLoad)}async*_updateFlowDataTiles(e,t){const s=m();for(const i of e??[]){const e=this._flowDataTiles?.get(u(i)),r=null==e||"delete"===e.type||"waiting"===e.type?this._getLoadedState(i):e;null!=r&&s.set(u(i),r),t.madeProgress(),t.done&&(t=yield)}this._flowDataTiles=s,this._resetTileData=!0,this.triggerLoad()}abort(){super.abort(),this._throttling=!1}get _layerIndex(){return this.surface.getLayerIndexByUID(1,this.layerView.uid)}get loadByTileTreesAllowed(){return super.loadByTileTreesAllowed||!this._allTilesLoaded}get _pixelSize(){return this.surface.tilingScheme.pixelSize}doRefresh(){this.invalidateTileData(),super.doRefresh()}triggerLoad(){const{_throttledTriggerLoad:e}=this;this._allTilesLoaded?(e.hasPendingUpdates()||e(),e.forceUpdate()):e()}async fetchDataAndGenerateStreamlines(e,t){const{_flowDataTiles:s,needsMagnitude:i,workerHandle:r}=this,a=this.getSimulationSettings(e);if(null==a||null==r||null==s)return;const l=this._resetTileData;this._resetTileData=!1;const o=m();s.forEach((e,t)=>{"delete"===e.type?(o.set(t,c),s.delete(t)):(l||"on-worker"!==e.type&&"waiting"!==e.type)&&(o.set(t,e),s.set(t,"waiting"!==e.type&&e.upsampled?_:f))});const n={simulationSettings:a,flowExtentInfo:e.flowExtentInfo,flowDataTiles:o,reset:l,needsMagnitude:i,startPositions:this.startPositions(e)},{streamlines:d}=await r.generateTiledStreamlines(n,t);return d}getUpdating(){return super.getUpdating()||this._throttling}_getLoadedState(e){const{_layerIndex:t}=this,s=null==e.surface;if(null==t||s)return c;const i=e.getLayerInfo(t,1);if(null==i)return c;if(!e.visible&&null==i.requestAbort)return i.requestAbort=new AbortController,this.surface.requestTileData(e,t,1,i.requestAbort),c;const r=this._getRasterTile(i,e,t);return null==r?this._upsampleFlowData(t,i.upsampleInfo,e.lij,e.extent):{type:"loaded",data:this._createFlowDataTile(r,e.lij,e.extent,this._pixelSize),upsampled:!1}}_upsampleFlowData(e,t,s,i){if(null==t)return c;const r=t.tile;if(null==r)return c;const a=r.getLayerInfo(e,1);if(null==a)return c;const l=this._getRasterTile(a,r,e);if(null==l)return c;const{scale:o,offset:n}=t,d=Math.max(Math.floor(this._pixelSize*o),1),u=l.source,h=Math.floor(n[0]*u.width),p=Math.floor((1-n[1]-o)*u.height);return{type:"loaded",data:this._createFlowDataTile(l,s,i,d,h,p),upsampled:!0}}_getRasterTile(e,t,s){const{data:i}=e;return!e.dataMissing&&t.hasLayerData(s,1)&&p(i)?i:null}_createFlowDataTile(e,t,s,i,r,a){const n=o(this.layer.serviceRasterInfo.dataType,e.source,i,i,r,a),d=n.mask.slice();return new h(n.data,d,n.width,n.height,t,l(s))}_updateFlowDataTile(e){const{renderedTiles:t,_layerIndex:s}=this;if(null==t||null==s)return;if(t.has(e)){const t=this._getLoadedState(e);return void(this._setTileData(e,t)&&this.triggerLoad())}let i=this._setTileData(e,c);for(const r of t.values()){const t=r.getLayerInfo(s,1);if(null==t)continue;if(null!=this._getRasterTile(t,r,s))continue;const a=t.upsampleInfo?.tile;if(a!==e)continue;const l=this._getLoadedState(r),o=this._setTileData(r,l);i||=o}i&&this.triggerLoad()}_setTileData(e,t){const{_flowDataTiles:s}=this;if(null==s)return!1;const i=u(e);return(null!=s.get(i)||"delete"!==t.type)&&(s.set(i,t),!0)}get _allTilesLoaded(){let e=0;for(const t of this._flowDataTiles?.values()??[])"delete"!==t.type&&"waiting"!==t.type&&e++;return e===this.renderedTiles?.size}invalidateTileData(){const{_flowDataTiles:e}=this;e?.forEach((t,s)=>{e.set(s,g)})}_tileIsUpsampled(e){const t=this._flowDataTiles?.get(u(e));return null!=t&&("loaded"===t.type||"on-worker"===t.type)&&t.upsampled}get usedMemory(){const e=9*this._pixelSize**2,t=(this._flowDataTiles?.size??0)*e;return super.usedMemory+t}get test(){return{...super.test,loadedTiles:this._flowDataTiles??m()}}};function m(){return new Map}e([r()],T.prototype,"_throttling",void 0),T=e([a("esri.views.3d.support.flow.FlowSubViewTiles3D")],T);export{T 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as e}from"../../../../core/accessorSupport/decorators/subclass.js";import{createFlowFieldFromData as s,traceFlowPaths as r}from"../../../2d/engine/flow/dataUtils.js";import{createFlowFieldFromDataTiled as o,valuesPerFlowVertex as i}from"./loadUtils.js";let a=class{constructor(){this._tileData=new Map}async generateStreamlines(t){const{flowData:e,flowExtentInfo:r,needsMagnitude:o,simulationSettings:i,startPositions:a}=t,n=l(s(i,e),i,r.modelSize,o,a);return{result:{streamlines:n},transferList:n?.map(t=>t.vertices.buffer)}}async generateTiledStreamlines(t){const{flowDataTiles:e,flowExtentInfo:s,needsMagnitude:r,reset:i,pixelSize:a,simulationSettings:n,startPositions:c}=t;this._updateTileData(e,i);const f=l(o(n,this._tileData,s,a),n,s.modelSize,r,c);return{result:{streamlines:f},transferList:f?.map(t=>t.vertices.buffer)??[]}}_updateTileData(t,e){e&&this._tileData.forEach((e,s)=>{null==t.get(s)&&this._tileData.delete(s)}),t.forEach((t,e)=>{"delete"===t?this._tileData.delete(e):"on-worker"!==t&&"waiting"!==t&&this._tileData.set(e,t)})}};a=t([e("esri.views.3d.support.flow.FlowWorker")],a);const n=a;function l(t,e,s,o,a){if(null==t)return;const n=r(e,t,s[0],s[1],{positions:a}),l=[],c=i(o);for(const{vertices:r,stage:i}of n){const t=new Float32Array(r.length*c);for(let e=0;e<r.length;e++)t[e*c]=r[e].x,t[e*c+1]=r[e].y,t[e*c+2]=r[e].t,o&&(t[e*c+3]=r[e].speed);l.push({vertices:t,stage:i,hasMagnitude:o})}return l}export{n as default};
5
+ import{__decorate as t}from"tslib";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as e}from"../../../../core/accessorSupport/decorators/subclass.js";import{createFlowFieldFromData as s,traceFlowPaths as r}from"../../../2d/engine/flow/dataUtils.js";import{createFlowFieldFromDataTiled as o,valuesPerFlowVertex as a}from"./loadUtils.js";let i=class{constructor(){this._tileData=new Map}async generateStreamlines(t){const{flowData:e,flowExtentInfo:r,needsMagnitude:o,simulationSettings:a,startPositions:i}=t,n=l(s(a,e),a,r.modelSize,o,i);return{result:{streamlines:n},transferList:n?.map(t=>t.vertices.buffer)}}async generateTiledStreamlines(t){const{flowDataTiles:e,flowExtentInfo:s,needsMagnitude:r,reset:a,simulationSettings:i,startPositions:n}=t;this._updateTileData(e,a);const c=l(o(i,this._tileData,s),i,s.modelSize,r,n);return{result:{streamlines:c},transferList:c?.map(t=>t.vertices.buffer)??[]}}_updateTileData(t,e){e&&this._tileData.forEach((e,s)=>{null==t.get(s)&&this._tileData.delete(s)}),t.forEach((t,e)=>{"delete"===t.type?this._tileData.delete(e):"on-worker"!==t.type&&"waiting"!==t.type&&this._tileData.set(e,t.data)})}};i=t([e("esri.views.3d.support.flow.FlowWorker")],i);const n=i;function l(t,e,s,o,i){if(null==t)return;const n=r(e,t,s[0],s[1],{positions:i}),l=[],c=a(o);for(const{vertices:r,stage:a}of n){const t=new Float32Array(r.length*c);for(let e=0;e<r.length;e++)t[e*c]=r[e].x,t[e*c+1]=r[e].y,t[e*c+2]=r[e].t,o&&(t[e*c+3]=r[e].speed);l.push({vertices:t,stage:a,hasMagnitude:o})}return l}export{n 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{WorkerHandle as e}from"../../../../core/workers/WorkerHandle.js";class r extends e{constructor(e){super("FlowWorker","generateStreamlines",{generateStreamlines:e=>[e.flowData.data.buffer,e.flowData.mask.buffer],generateTiledStreamlines:e=>{const r=[];return e.flowDataTiles.forEach(e=>{"string"!=typeof e&&r.push(e.data.buffer,e.mask.buffer)}),r}},e,{strategy:"dedicated"})}generateStreamlines(e,r){return this.invokeMethod("generateStreamlines",e,r)}generateTiledStreamlines(e,r){return this.invokeMethod("generateTiledStreamlines",e,r)}}export{r as FlowWorkerHandle};
5
+ import{WorkerHandle as e}from"../../../../core/workers/WorkerHandle.js";class r extends e{constructor(e){super("FlowWorker","generateStreamlines",{generateStreamlines:e=>[e.flowData.data.buffer,e.flowData.mask.buffer],generateTiledStreamlines:e=>{const r=[];return e.flowDataTiles.forEach(e=>{"loaded"===e.type&&r.push(e.data.data.buffer,e.data.mask.buffer)}),r}},e,{strategy:"dedicated"})}generateStreamlines(e,r){return this.invokeMethod("generateStreamlines",e,r)}generateTiledStreamlines(e,r){return this.invokeMethod("generateTiledStreamlines",e,r)}}export{r as FlowWorkerHandle};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{Seconds as e}from"../../../../core/time.js";import{FlowQuery3D as t}from"./FlowQuery3D.js";class i{constructor(e,t,i,r){this._query=e,this.streamlines=t,this._material=i,this.geometries=r,this._startTime=0,this._endTime=1/0,this.startTime=this._query.time}get startTime(){return this._startTime}set startTime(i){this._query.time!==i&&(this._query=new t(this._query.extent,this._query.timeExtent,this._query.size,this._query.pixelRatio,e(i))),this._startTime=i,this.setMaterialParameters({startTime:i})}get endTime(){return this._endTime}set endTime(e){this._endTime=e,this.setMaterialParameters({endTime:e})}get query(){return this._query}hasFadedOut(e){return this.endTime+this._material.parameters.fadeOutTime<e}setMaterialParameters(e){this._material.setParameters(e)}get test(){return null}}export{i as StreamlineResources3D};
5
+ import"../../../../core/has.js";import{estimateNestedObjectMemory as e}from"../../../../core/memoryEstimations.js";import{Seconds as t}from"../../../../core/time.js";import{FlowQuery3D as s}from"./FlowQuery3D.js";class i{constructor(e,t,s,i,r){this._query=e,this.streamlines=t,this._material=s,this.geometries=i,this._bytesPerFeature=r,this._startTime=0,this._endTime=1/0,this.usedMemory=null,this.startTime=this._query.time,this.computeMemory()}computeMemory(){const t=e(this.streamlines),s=e(this.geometries.map(e=>e.attributes)),i=this.streamlines.length*this._bytesPerFeature;this.usedMemory=t+s+i}get startTime(){return this._startTime}set startTime(e){this._query.time!==e&&(this._query=new s(this._query.extent,this._query.timeExtent,this._query.size,this._query.pixelRatio,t(e))),this._startTime=e,this.setMaterialParameters({startTime:e})}get endTime(){return this._endTime}set endTime(e){this._endTime=e,this.setMaterialParameters({endTime:e})}get query(){return this._query}hasFadedOut(e){return this.endTime+this._material.parameters.fadeOutTime<e}setMaterialParameters(e){this._material.setParameters(e)}get test(){return null}}export{i as StreamlineResources3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{removeMaybe as e,destroyMaybe as r}from"../../../../core/maybe.js";import{streamlinGeometryBatchSize as t}from"./constants.js";import{StreamlineResources3D as s}from"./StreamlineResources3D.js";import{RenderGeometry as i}from"../../webgl-engine/lib/RenderGeometry.js";import{TaskPriority as a}from"../../../support/Scheduler.js";class h extends s{constructor(e,r,t,s,i){super(e,r,t,s),this._layerView=i,this._drapeRenderer=null,this.drapeSourceType=2,this.updatePolicy=0,this.renderGroup=0,this._frameTask=null,this._renderGeometries=[]}get _view(){return this._layerView.view}get layer(){return this._layerView.layer}get fullOpacity(){return this._layerView.fullOpacity}get attached(){return null!=this._drapeRenderer}get destroyed(){return this.attached}async attach(){const{geometries:e}=this;null!=e&&(this.detach(),this._frameTask=this._view.resourceController.scheduler.registerTask(a.FLOW_GENERATOR),await this._frameTask.scheduleGenerator(r=>this._addGeometryToOverlay(e,r)))}async*_addGeometryToOverlay(e,r){this._drapeRenderer=this._view.overlayManager.registerGeometryDrapeSource(this);for(let s=0;s<e.length;s+=t){const a=e.slice(s,s+t).map(e=>new i(e));this._drapeRenderer.addGeometries(a,0),this._renderGeometries.push(...a),this._drapeRenderer.commitChanges(),r.madeProgress(),r.done&&(r=yield)}}detach(){this._frameTask=e(this._frameTask),this._drapeRenderer&&(this._drapeRenderer.removeGeometries(this._renderGeometries,2),this._drapeRenderer.commitChanges(),this._renderGeometries.length=0),this.attached&&this._view.overlayManager.unregisterDrapeSource(this),this._drapeRenderer=r(this._drapeRenderer)}}export{h as StreamlineResources3DOverlay};
5
+ import{removeMaybe as e,destroyMaybe as r}from"../../../../core/maybe.js";import{memoryEstimators as t}from"../../layers/graphics/defaultSymbolComplexity.js";import{streamlinGeometryBatchSize as s}from"./constants.js";import{StreamlineResources3D as i}from"./StreamlineResources3D.js";import{RenderGeometry as a}from"../../webgl-engine/lib/RenderGeometry.js";import{TaskPriority as o}from"../../../support/Scheduler.js";class d extends i{constructor(e,r,s,i,a){super(e,r,s,i,t.LINE_ROUND.draped.bytesPerFeature),this._layerView=a,this._drapeRenderer=null,this.drapeSourceType=2,this.updatePolicy=0,this.renderGroup=0,this._frameTask=null,this._renderGeometries=[]}get _view(){return this._layerView.view}get layer(){return this._layerView.layer}get fullOpacity(){return this._layerView.fullOpacity}get attached(){return null!=this._drapeRenderer}get destroyed(){return this.attached}async attach(){const{geometries:e}=this;null!=e&&(this.detach(),this._frameTask=this._view.resourceController.scheduler.registerTask(o.FLOW_GENERATOR),await this._frameTask.scheduleGenerator(r=>this._addGeometryToOverlay(e,r)))}async*_addGeometryToOverlay(e,r){this._drapeRenderer=this._view.overlayManager.registerGeometryDrapeSource(this);for(let t=0;t<e.length;t+=s){const i=e.slice(t,t+s).map(e=>new a(e));this._drapeRenderer.addGeometries(i,0),this._renderGeometries.push(...i),this._drapeRenderer.commitChanges(),r.madeProgress(),r.done&&(r=yield)}}detach(){this._frameTask=e(this._frameTask),this._drapeRenderer&&(this._drapeRenderer.removeGeometries(this._renderGeometries,2),this._drapeRenderer.commitChanges(),this._renderGeometries.length=0),this.attached&&this._view.overlayManager.unregisterDrapeSource(this),this._drapeRenderer=r(this._drapeRenderer)}}export{d as StreamlineResources3DOverlay};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{removeMaybe as e}from"../../../../core/maybe.js";import{streamlinGeometryBatchSize as t}from"./constants.js";import{StreamlineResources3D as s}from"./StreamlineResources3D.js";import{Object3D as r}from"../../webgl-engine/lib/Object3D.js";import{WebGLLayer as i}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as a}from"../../../support/Scheduler.js";class o extends s{constructor(e,t,s,r,i){super(e,t,s,r),this._view=i,this._objects3D=[],this._engineLayer=null,this._frameTask=null}get attached(){return null!=this._engineLayer}async attach(){const{geometries:e}=this;null!=e&&(this.detach(),this._frameTask=this._view.resourceController.scheduler.registerTask(a.FLOW_GENERATOR),await this._frameTask.scheduleGenerator(t=>this._addGeometryToLayer(e,t)))}detach(){this.attached&&(this._engineLayer?.removeMany(this._objects3D),this._objects3D.forEach(e=>e.dispose()),this._objects3D=[],this._engineLayer=null,this._frameTask=e(this._frameTask))}async*_addGeometryToLayer(e,s){const{stage:a}=this._view,o=new i(a,{pickable:!1,updatePolicy:1});for(let i=0;i<e.length;i+=t){const a=new r({geometries:e.slice(i,i+t),castShadow:!1});o.add(a),this._objects3D.push(a),o.commit(),s.madeProgress(),s.done&&(s=yield)}this._engineLayer=o}}export{o as StreamlineResources3DShape};
5
+ import{removeMaybe as e}from"../../../../core/maybe.js";import{memoryEstimators as t}from"../../layers/graphics/defaultSymbolComplexity.js";import{streamlinGeometryBatchSize as s}from"./constants.js";import{StreamlineResources3D as r}from"./StreamlineResources3D.js";import{Object3D as i}from"../../webgl-engine/lib/Object3D.js";import{WebGLLayer as a}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as o}from"../../../support/Scheduler.js";class n extends r{constructor(e,s,r,i,a){super(e,s,r,i,t.LINE_ROUND.bytesPerFeature),this._view=a,this._objects3D=[],this._engineLayer=null,this._frameTask=null}get attached(){return null!=this._engineLayer}async attach(){const{geometries:e}=this;null!=e&&(this.detach(),this._frameTask=this._view.resourceController.scheduler.registerTask(o.FLOW_GENERATOR),await this._frameTask.scheduleGenerator(t=>this._addGeometryToLayer(e,t)))}detach(){this.attached&&(this._engineLayer?.removeMany(this._objects3D),this._objects3D.forEach(e=>e.dispose()),this._engineLayer?.commit(),this._objects3D=[],this._engineLayer=null,this._frameTask=e(this._frameTask))}async*_addGeometryToLayer(e,t){const{stage:r}=this._view,o=new a(r,{pickable:!1,updatePolicy:1});for(let a=0;a<e.length;a+=s){const r=new i({geometries:e.slice(a,a+s),castShadow:!1});o.add(r),this._objects3D.push(r),o.commit(),t.madeProgress(),t.done&&(t=yield)}this._engineLayer=o}}export{n as StreamlineResources3DShape};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- const e=.1,o=1,t=1,c=1e3,n=!1,p=3,r=1,s=1.1,x=501;export{e as averageLoadingTimeSmoothingFactor,r as defaultTransitionDuration,t as fadeInTime,o as fadeOutTime,n as seamlessTransitionEnabled,x as streamlinGeometryBatchSize,s as thresholdForLoadingAllTiles,c as tilesWaitingTime,p as transitionDurationFactor};
5
+ const e=.1,o=1,t=1,c=1e3,n=!1,p=3,r=1,s=1.1,x=501,a=256,b=!0,d=3;export{e as averageLoadingTimeSmoothingFactor,r as defaultTransitionDuration,t as fadeInTime,o as fadeOutTime,a as minimumTracingResolution,n as seamlessTransitionEnabled,x as streamlinGeometryBatchSize,s as thresholdForLoadingAllTiles,d as tileFilterDistance,b as tileFilteringByDistanceEnabled,c as tilesWaitingTime,p as transitionDurationFactor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{containsXY as t,width as n,height as r,create as e}from"../../../../geometry/support/aaBoundingRect.js";import{createFlowFieldFromData as l}from"../../../2d/engine/flow/dataUtils.js";import{getFeatureTileId as o}from"../../layers/support/FeatureTileDescriptor.js";import{modelToMapSpace as u,insideMapExtent as i,isFullExtent as s}from"./FlowQuery3D.js";function f(t){return t?4:3}function a(t){return t[0].vertices instanceof Float32Array}class c{constructor(t,n,r,e,l,o){this.data=t,this.mask=n,this.width=r,this.height=e,this.lij=l,this.extent=o}}function h(t){return o(t.lij[0],t.lij[1],t.lij[2])}function m(t,n){let[r,l,o,u]=[null,null,null,null];for(const e of t){const t=e.extent;r=d(t[0],r),l=d(t[1],l),o=p(t[2],o),u=p(t[3],u)}if(null==r||null==l||null==o||null==u)return null;if(s(r,o,n)){const n=[...t].toSorted((t,n)=>t.extent[0]-n.extent[0]);let e=n[0].extent[2],l=0,u=0,i=0;for(let t=1;t<n.length;t++){const[r,o,s]=n[t].extent;if(e<r&&(i++,l=e,u=r,i>1))break;e=Math.max(e,s)}1===i&&(r=u,o=l)}return e([r,l,o,u])}function p(t,n){return null==n?t:Math.max(t,n)}function d(t,n){return null==n?t:Math.min(t,n)}function x(e,o,s,f){const[a,c]=s.modelSize;let h=null;const m=new Map;o.forEach(t=>{m.set(t.lij,l(e,t))});const p=(n,r,e)=>t(n.extent,r,e);return(t,l)=>{const d=Math.round(t),x=Math.round(l);if(!e.wrapAround&&(d<0||d>=a||x<0||x>=c))return[0,0];const[j,g]=u(s,t,l,!0);if(!i(s,j,g))return[0,0];if(null==h||!p(h,j,g)){h=null;for(const[t,n]of o)if(p(n,j,g)){h=n;break}}if(null==h?.data)return[0,0];const M=m.get(h.lij);if(null==M)return[0,0];const w=h.extent;return M((j-w[0])/n(w)*f,f-(g-w[1])/r(w)*f)}}export{c as FlowDataTile,m as boundingRectOfTiles,x as createFlowFieldFromDataTiled,a as isFlowPathBuffer,h as tileToKey,f as valuesPerFlowVertex};
5
+ import{containsXY as t,width as n,height as e,create as r}from"../../../../geometry/support/aaBoundingRect.js";import{createFlowFieldFromData as l}from"../../../2d/engine/flow/dataUtils.js";import{getFeatureTileId as o}from"../../layers/support/FeatureTileDescriptor.js";import{modelToMapSpace as i,insideMapExtent as u,isFullExtent as s}from"./FlowQuery3D.js";function f(t){return t?4:3}function a(t){return t[0].vertices instanceof Float32Array}class c{constructor(t,n,e,r,l,o){this.data=t,this.mask=n,this.width=e,this.height=r,this.lij=l,this.extent=o}}function h(t){return o(t.lij[0],t.lij[1],t.lij[2])}function m(t,n){let[e,l,o,i]=[null,null,null,null];for(const r of t){const t=r.extent;e=p(t[0],e),l=p(t[1],l),o=d(t[2],o),i=d(t[3],i)}if(null==e||null==l||null==o||null==i)return null;if(s(e,o,n)){const n=[...t].toSorted((t,n)=>t.extent[0]-n.extent[0]);let r=n[0].extent[2],l=0,i=0,u=0;for(let t=1;t<n.length;t++){const[e,o,s]=n[t].extent;if(r<e&&(u++,l=r,i=e,u>1))break;r=Math.max(r,s)}1===u&&(e=i,o=l)}return r([e,l,o,i])}function d(t,n){return null==n?t:Math.max(t,n)}function p(t,n){return null==n?t:Math.min(t,n)}function x(r,o,s){const[f,a]=s.modelSize;let c=null;const h=new Map;o.forEach(t=>{h.set(t.lij,l(r,t))});const m=(n,e,r)=>t(n.extent,e,r);return(t,l)=>{const d=Math.round(t),p=Math.round(l);if(!r.wrapAround&&(d<0||d>=f||p<0||p>=a))return[0,0];const[x,j]=i(s,t,l,!0);if(!u(s,x,j))return[0,0];if(null==c||!m(c,x,j)){c=null;for(const[t,n]of o)if(m(n,x,j)){c=n;break}}if(null==c?.data)return[0,0];const g=h.get(c.lij);if(null==g)return[0,0];const{width:w,height:M,extent:y}=c;return g((x-y[0])/n(y)*w,M-(j-y[1])/e(y)*M)}}export{c as FlowDataTile,m as boundingRectOfTiles,x as createFlowFieldFromDataTiled,a as isFlowPathBuffer,h as tileToKey,f as valuesPerFlowVertex};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import{Texture as r}from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as s,SizedPixelFormat as i}from"../../../webgl/enums.js";import"../../../webgl/checkWebGLError.js";import{TextureDescriptor as o}from"../../../webgl/TextureDescriptor.js";class a{constructor(e){this.texture=null,this._orderTextureCapacity=0,this._rctx=e}ensureCapacity(t){if(this._orderTextureCapacity<t){this.texture?.dispose();const a=Math.ceil(t*e),c=this._evalTextureSize(a),u=c[0]*c[1];this._orderBuffer=new Uint32Array(u);const h=new o;h.height=c[0],h.width=c[1],h.pixelFormat=36244,h.dataType=s.UNSIGNED_INT,h.internalFormat=i.R32UI,h.wrapMode=33071,h.samplingMode=9728,this.texture=new r(this._rctx,h),this._orderTextureCapacity=u}}setData(e,t){this.ensureCapacity(t),this._orderBuffer?.set(e),this.texture?.setData(this._orderBuffer)}clear(){this._orderTextureCapacity=0,this.texture?.dispose(),this.texture=null}destroy(){this.texture?.dispose()}_evalTextureSize(e){const r=Math.ceil(Math.sqrt(e)),s=Math.ceil(e/r);return t(r,s)}}export{a as GaussianSplatOrderTexture};
5
+ import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import{Texture as r}from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as i,SizedPixelFormat as s}from"../../../webgl/enums.js";import"../../../webgl/checkWebGLError.js";import{TextureDescriptor as o}from"../../../webgl/TextureDescriptor.js";class a{constructor(e){this.texture=null,this._orderTextureCapacity=0,this._rctx=e}ensureCapacity(t){if(this._orderTextureCapacity<t){this.texture?.dispose();const a=Math.ceil(t*e),c=this._evalTextureSize(a),u=c[0]*c[1];this._orderBuffer=new Uint32Array(u);const h=new o;h.height=c[0],h.width=c[1],h.pixelFormat=36244,h.dataType=i.UNSIGNED_INT,h.internalFormat=s.R32UI,h.wrapMode=33071,h.samplingMode=9728,this.texture=new r(this._rctx,h),this._orderTextureCapacity=u}}setData(e,t){this.ensureCapacity(t),this._orderBuffer?.set(e),this.texture?.setData(this._orderBuffer)}clear(){this._orderTextureCapacity=0,this.texture?.dispose(),this.texture=null}destroy(){this.texture?.dispose()}_evalTextureSize(e){const r=Math.ceil(Math.sqrt(e)),i=Math.ceil(e/r);return t(r,i)}}export{a as GaussianSplatOrderTexture};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{isIntegratedMeshLayer as e}from"../../../layers/support/layerUtils.js";import{hitTestSelectSimilarDistance as a}from"../../support/hitTestSelectUtils.js";async function r(r,i){const{results:o,ground:l}=await a(r,i),c=(!l.layer||!e(l.layer))&&l.mapPoint,y=[],p=s(r),d=c?t(r,p):n;let u=0,f=0;const m=()=>{const e=d.layerViews[f];c&&e&&"fetchPopupFeaturesAtLocation"in e&&y.push({mapPoint:l.mapPoint,layerView:e}),++f};let w=null;for(;u<o.length||f<d.layerViews.length;){const e=o[u];if(e&&"graphic"!==e.type)++u;else if("scene"!==e?.layer?.type||e?.layer?.parent!==r?.map?.basemap)if(e){const a=e.layer?.uid,r=d.layerUids.has(a)&&e.distance===l.distance,t=p.get(e.layer?.uid);if(w??=e.mapPoint,f<d.layerViews.length&&(r||(e.distance??0)>l.distance)&&d.layerViews[f]!==t){m();continue}y.push({graphic:e.graphic,layerView:t}),++u}else m();else++u}return w??=l.mapPoint,{hits:y,location:w}}function t(e,a){const r=new Set,t=new Set;for(let s=e.basemapTerrain.numLayers(1)-1;s>=0;s--){const a=e.basemapTerrain.layerViewByIndex(s,1);r.add(a.layer.uid),t.add(a)}const n=e.overlayManager.renderer.layers;for(const{uid:s}of n){const e=a.get(s);e&&(r.add(s),t.add(e))}return{layerUids:r,layerViews:Array.from(t).reverse()}}const n={layerUids:new Set,layerViews:[]};function s(e){const a=new Map;for(const r of e.allLayerViews){const e=r.layer.uid;a.set(e,r)}return a}export{r as popupHitTest};
5
+ import{isIntegratedMeshLayer as e,isTiledLayer as a}from"../../../layers/support/layerUtils.js";import{hitTestSelectSimilarDistance as r}from"../../support/hitTestSelectUtils.js";import{isInEffectiveScaleRange as t}from"../../support/layerViewUtils.js";async function n(n,o){const{results:c,ground:y}=await r(n,o),p=(!y.layer||!e(y.layer))&&y.mapPoint,f=[],u=l(n),d=p?s(n,u):i;let m=0,w=0;const g=()=>{const e=d.layerViews[w++];if(!p||!e||!("fetchPopupFeaturesAtLocation"in e))return;const r=y.mapPoint,s=e.layer;if(a(s)&&"effectiveScaleRange"in s){const a=n.basemapTerrain.getScale(r);if(!t(e.layer.effectiveScaleRange,a))return}f.push({mapPoint:r,layerView:e})};let h=null;for(;m<c.length||w<d.layerViews.length;){const e=c[m];if(e&&"graphic"!==e.type)++m;else if("scene"!==e?.layer?.type||e?.layer?.parent!==n?.map?.basemap)if(e){const a=e.layer?.uid,r=d.layerUids.has(a)&&e.distance===y.distance,t=u.get(e.layer?.uid);if(h??=e.mapPoint,w<d.layerViews.length&&(r||(e.distance??0)>y.distance)&&d.layerViews[w]!==t){g();continue}f.push({graphic:e.graphic,layerView:t}),++m}else g();else++m}return h??=y.mapPoint,{hits:f,location:h}}function s(e,a){const r=new Set,t=new Set;for(let s=e.basemapTerrain.numLayers(1)-1;s>=0;s--){const a=e.basemapTerrain.layerViewByIndex(s,1);r.add(a.layer.uid),t.add(a)}const n=e.overlayManager.renderer.layers;for(const{uid:s}of n){const e=a.get(s);e&&(r.add(s),t.add(e))}return{layerUids:r,layerViews:Array.from(t).reverse()}}const i={layerUids:new Set,layerViews:[]};function l(e){const a=new Map;for(const r of e.allLayerViews){const e=r.layer.uid;a.set(e,r)}return a}export{n as popupHitTest};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{ZEROS as e}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{TileCompositePassParameters as r}from"../webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js";import{B as s}from"../../../chunks/BlendLayers.glsl.js";import{ReloadableShaderModule as o}from"../webgl-engine/core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as t}from"../webgl-engine/core/shaderTechnique/ShaderTechnique.js";import{Pos2TexF16 as i}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{fromLayout as l}from"../../webgl/VertexAttributeLocations.js";class n extends r{constructor(){super(...arguments),this.opacity=1,this.baseOpacity=1,this.texture=null,this.fboTexture=null,this.backgroundColor=e}}class a extends t{constructor(e,r){super(e,r,new o(s,()=>import("../webgl-engine/core/shaderLibrary/util/BlendLayers.glsl.js")),l(i))}}export{n as BlendLayersPassParameters,a as BlendLayersTechnique};
5
+ import{__decorate as e}from"tslib";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{ZEROS as s}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{TileCompositePassParameters as o}from"../webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js";import{B as t}from"../../../chunks/BlendLayers.glsl.js";import{ReloadableShader as i}from"../webgl-engine/core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as l}from"../webgl-engine/core/shaderTechnique/ShaderTechnique.js";import{Pos2TexF16 as a}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{PrimitiveType as c}from"../../webgl/enums.js";import{fromLayout as n}from"../../webgl/VertexAttributeLocations.js";class m extends o{constructor(){super(...arguments),this.opacity=1,this.baseOpacity=1,this.texture=null,this.fboTexture=null,this.backgroundColor=s}}let p=class extends l{constructor(e,r){super(e,r,n(a)),this.shader=new i(t,()=>import("../webgl-engine/core/shaderLibrary/util/BlendLayers.glsl.js")),this.primitiveType=c.TRIANGLE_STRIP}};p=e([r("esri.views.3d.terrain.BlendLayersTechnique")],p);export{m as BlendLayersPassParameters,p as BlendLayersTechnique};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{unique as r}from"../../../core/arrayUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as s,everyMap as i}from"../../../core/MapUtils.js";import{disposeMaybe as n}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as a,on as h,syncAndInitial as d,initial as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as _,fromTranslation as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{j as m}from"../../../chunks/vec32.js";import{ones as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{debugFlags as f}from"../support/debugFlags.js";import{Overlay as R}from"./Overlay.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import x from"../webgl/RenderCamera.js";import{T}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as w}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as S,renderHighlightBuffer as b}from"../webgl-engine/effects/highlight/Highlight.js";import{GLMaterialRepository as O}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as D}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderContext as C,defaultRenderOccludedMask as P}from"../webgl-engine/lib/RenderContext.js";import{ShadowMap as j}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as E}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as M}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as F}from"../webgl-engine/lighting/Lightsources.js";import{O as W}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as q}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as V,noBudget as A}from"../../support/Scheduler.js";import{Texture as k}from"../../webgl/Texture.js";import{TextureDescriptor as G}from"../../webgl/TextureDescriptor.js";let I=class extends w{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new W,this.hasHighlights=!1,this.renderOccludedFlags=1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new T,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new x,this.events=new t,this.longitudeCyclical=null,this.produces=new Map([[18,e=>9!==e||this.hasHighlights],[19,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1,this._hasDrapedFlowSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,techniques:i}=r.renderView;this._renderContext=new C(this._rctx,new j(t,e.state.viewingMode),i),this.addHandles([a(()=>s.updating,()=>this.events.emit("content-changed"),d),a(()=>this._spatialReference,e=>this._localOriginFactory=new D(e),d),h(()=>e.allLayerViews,"after-changes",()=>this._sortedDrapeSourceRenderersDirty=!0),a(()=>S(e.state.highlights),()=>this._sortedDrapeSourceRenderersDirty=!0,l),a(()=>e.state.highlights,r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap},l),e.resourceController.scheduler.registerTask(V.OVERLAY_RENDERER,this)]);const{_bindParameters:n,_camera:o}=this;o.near=1,o.far=1e4,o.relativeElevation=null,n.slot=18,n.mainDepth=null,n.camera=o,n.oitPass=0,n.updateLighting([new F(y())],0,0,0)}destroy(){this._renderers.forEach(e=>e.destroy()),this._renderers.clear(),this._passParameters.texture=n(this._passParameters.texture),this.disposeOverlays(),this._renderContext=null,this._sortedRenderers.prune()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get _spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new O(this._view.stage.renderView.textures,this._techniques,()=>{this._onMaterialOrContentChanged(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")},()=>this.events.emit("content-changed"));this._pluginContext={...e,materials:r},this._techniques.precompile(q)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,e=>e.updating||e.canCompact)}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),r(this._sortedRenderers.map(e=>e.drapeSource.layer).filter(e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(a(()=>e.fullOpacity,()=>this.events.emit("content-changed")),e)}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(e){this._renderTargets?.dispose(e)}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&c(e,e=>1===e.drapeTargetType)}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=c(e,e=>1===e.drapeSourceType),this._hasDrapedRasterSource=c(e,e=>0===e.drapeSourceType),this._hasDrapedFlowSource=c(e,e=>2===e.drapeSourceType)):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=this._hasDrapedFlowSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this._stage.renderer.fboCache),this._overlays=[new R,new R]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets?.dispose(1),this._renderTargets=null,this.events.emit("textures-disposed")}_useOverlayColorInsteadOfColorNoRasterImage(e){return 1===e&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource}getTexture(e){const r=this._useOverlayColorInsteadOfColorNoRasterImage(e);return this._renderTargets?.getTexture(r?0:e)}get readyToRun(){return this.updating}runTask(e){this._processDrapeSources(e,()=>!0)}_onMaterialOrContentChanged(){this.renderOccludedFlags=s(this._renderers,e=>e.hasOccluders)?H:1}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this._onMaterialOrContentChanged(),this.hasHighlights=s(this._renderers,e=>e.hasHighlights),this.events.emit("content-changed"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return s(this._renderers,r=>r.hasHighlight(e))}processSyncDrapeSources(){this._processDrapeSources(A,e=>1===e.updatePolicy)}get isEmpty(){return!f.OVERLAY_DRAW_DEBUG_TEXTURE&&i(this._renderers,e=>e.isEmpty)}get hasWater(){const e=s(this._renderers,({hasWater:e})=>e);return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}renders(e){if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==e&&2!==e)return!0;if(!this._overlays)return!1;const r=this._overlays[0];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._renderContext.output;this._renderContext.output=this._renderTargets?.targets.find(r=>r.content===e)?.output??0,++this._techniques.precompiling;const s=this._sortedRenderers.some(({renderer:e})=>e.precompile(this._renderContext));return--this._techniques.precompiling,this._renderContext.output=t,s}get mode(){return this.isEmpty?0:this.hasWater&&this.renders(3)?2:this._renderTargets?.getTexture(0)?1:0}updateAnimation(e){let r=!1;return this._renderers.forEach(t=>r=t.updateAnimation(e)||r),r&&this.parent.requestRender(0),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return!1;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(1===t.content&&!this._needsColorWithoutRasterImage)continue;const{output:e}=t;this._renderContext.output=e,r.slot=3===e?19:18,9===e&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null);const s=this._renderContext.renderOccludedMask;4===t.content&&(this._renderContext.renderOccludedMask=H),this._sortedRenderers.forAll(({drapeSource:e,renderer:r})=>{1===t.content&&0===e.drapeSourceType||4===t.content&&r.hasOnlyOccluders||r.precompile(this._renderContext)}),this._renderContext.renderOccludedMask=s,r.highlightMixTexture=null}return--this._techniques.precompiling,!0}drawOverlays(e,r){if(!this._overlays||!this._renderTargets)return;for(const s of this._overlays)s.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;const t=this.allSourcesOccluders;for(const s of this._renderTargets.targets){if(!(0===s.content&&this._hasDrapedFlowSource)&&!s.handleRenderRequest(r)||1===s.content&&!this._needsColorWithoutRasterImage||4===s.content&&t)continue;const e=this._drawTarget(0,s),i=this._drawTarget(1,s);(e||i)&&s.fbo.generateMipMap()}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n}=r;if(this.isEmpty||3===n&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:o,_camera:a,_renderContext:h,_bindParameters:d}=this;if(a.pixelRatio=t.pixelRatio*i,h.output=n,d.screenToWorldRatio=this._screenToWorldRatio,d.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,d.slot=3===n?19:18,4===r.content&&(h.renderOccludedMask=H),!this.renders(r.content))return h.renderOccludedMask=P,!1;const{resolution:l}=t,c=0===e,u=c?0:l;if(o.setViewport(u,0,l,l),this._bindTargetFBO(r),c)if(9!==r.output)o.setClearColor(0,0,0,0),o.clear(16384);else{const{gl:e}=o;e.clearBufferuiv(e.COLOR,0,[0,0,0,0])}if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==r.content&&2!==r.content){this._techniques.precompile(E,z);const r=this._techniques.get(E,z);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,U[e]),o.bindTechnique(r,d,this._passParameters),o.screen.draw()}if(9===r.output){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),b(o,t,{width:s,height:s},d,()=>this._renderAllGeometry(e,r),u)}else this._renderAllGeometry(e,r);return o.bindFramebuffer(null),h.renderOccludedMask=P,!0}get allSourcesOccluders(){return i(this._renderers,e=>e.hasOnlyOccluders)}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll(({drapeSource:i,renderer:n})=>{if(1===r.content&&0===i.drapeSourceType)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&0===r.output&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(q);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}})}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.ensureFramebuffer(t,r),e.fbo.bind(this._rctx)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(16384),s}get _resolution(){return this._overlays?.[0].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers.map(e=>e.uid),r=e.length;this._renderers.forEach((t,s)=>{const i=e.indexOf(s.layer?.uid),n=i>=0,o=s.renderGroup??(n?0:1),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new L(s,t,h))}),this._sortedRenderers.sort((e,r)=>e.index-r.index)}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),g(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(m(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new G(e);i.samplingMode=9728,this._passParameters.texture=new k(this._rctx,i,t)}get test(){}};e([u()],I.prototype,"hasHighlights",void 0),e([u()],I.prototype,"renderOccludedFlags",void 0),e([u()],I.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({constructOnly:!0})],I.prototype,"parent",void 0),e([u({readOnly:!0})],I.prototype,"_techniques",null),e([u({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([u()],I.prototype,"isEmpty",null),I=e([p("esri.views.3d.terrain.OverlayRenderer")],I);class L{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const U=[[1,.5,.5],[.5,.5,1]],B=-2,H=4,z=new M;z.hasAlpha=!0;export{I as OverlayRenderer,B as drapedZ,H as overlayRenderOccludedFlag};
5
+ import{__decorate as e}from"tslib";import{unique as r}from"../../../core/arrayUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as s,everyMap as i}from"../../../core/MapUtils.js";import{disposeMaybe as n}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as a,on as h,syncAndInitial as d,initial as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as _,fromTranslation as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{j as m}from"../../../chunks/vec32.js";import{ones as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{debugFlags as f}from"../support/debugFlags.js";import{Overlay as R}from"./Overlay.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import x from"../webgl/RenderCamera.js";import{T as w}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as T}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as S,renderHighlightBuffer as b}from"../webgl-engine/effects/highlight/Highlight.js";import{GLMaterialRepository as O}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as D}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderContext as C,defaultRenderOccludedMask as P}from"../webgl-engine/lib/RenderContext.js";import{ShadowMap as j}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as E}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as M}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as F}from"../webgl-engine/lighting/Lightsources.js";import{O as W}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as q}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as V,noBudget as A}from"../../support/Scheduler.js";import{Texture as k}from"../../webgl/Texture.js";import{TextureDescriptor as G}from"../../webgl/TextureDescriptor.js";let I=class extends T{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new W,this.hasHighlights=!1,this.renderOccludedFlags=1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new w,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new x,this.events=new t,this.longitudeCyclical=null,this.produces=new Map([[18,e=>9!==e||this.hasHighlights],[19,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1,this._hasDrapedFlowSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,techniques:i}=r.renderView;this._renderContext=new C(this._rctx,new j(t,e.state.viewingMode),i),this.addHandles([a(()=>s.updating,()=>this.events.emit("content-changed"),d),a(()=>this._spatialReference,e=>this._localOriginFactory=new D(e),d),h(()=>e.allLayerViews,"after-changes",()=>this._sortedDrapeSourceRenderersDirty=!0),a(()=>S(e.state.highlights),()=>this._sortedDrapeSourceRenderersDirty=!0,l),a(()=>e.state.highlights,r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap},l),e.resourceController.scheduler.registerTask(V.OVERLAY_RENDERER,this)]);const{_bindParameters:n,_camera:o}=this;o.near=1,o.far=1e4,o.relativeElevation=null,n.slot=18,n.mainDepth=null,n.camera=o,n.oitPass=0,n.updateLighting([new F(y())],0,0,0)}destroy(){this._renderers.forEach(e=>e.destroy()),this._renderers.clear(),this._passParameters.texture=n(this._passParameters.texture),this.disposeOverlays(),this._renderContext=null,this._sortedRenderers.prune()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get _spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new O(this._view.stage.renderView.textures,this._techniques,()=>{this._onMaterialOrContentChanged(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")},()=>this.events.emit("content-changed"));this._pluginContext={...e,materials:r},this._techniques.precompile(q)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,e=>e.updating||e.canCompact)}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),r(this._sortedRenderers.map(e=>e.drapeSource.layer).filter(e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(a(()=>e.fullOpacity,()=>this.events.emit("content-changed")),e)}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(e){this._renderTargets?.dispose(e)}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&c(e,e=>1===e.drapeTargetType)}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=c(e,e=>1===e.drapeSourceType),this._hasDrapedRasterSource=c(e,e=>0===e.drapeSourceType),this._hasDrapedFlowSource=c(e,e=>2===e.drapeSourceType)):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=this._hasDrapedFlowSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this._stage.renderer.fboCache),this._overlays=[new R,new R]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets?.dispose(1),this._renderTargets=null,this.events.emit("textures-disposed")}_useOverlayColorInsteadOfColorNoRasterImage(e){return 1===e&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource}getTexture(e){const r=this._useOverlayColorInsteadOfColorNoRasterImage(e);return this._renderTargets?.getTexture(r?0:e)}get readyToRun(){return this.updating}runTask(e){this._processDrapeSources(e,()=>!0)}_onMaterialOrContentChanged(){this.renderOccludedFlags=s(this._renderers,e=>e.hasOccluders)?H:1}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this._onMaterialOrContentChanged(),this.hasHighlights=s(this._renderers,e=>e.hasHighlights),this.events.emit("content-changed"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return s(this._renderers,r=>r.hasHighlight(e))}processSyncDrapeSources(){this._processDrapeSources(A,e=>1===e.updatePolicy)}get isEmpty(){return!f.OVERLAY_DRAW_DEBUG_TEXTURE&&i(this._renderers,e=>e.isEmpty)}get hasWater(){const e=s(this._renderers,({hasWater:e})=>e);return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}renders(e){if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==e&&2!==e)return!0;if(!this._overlays)return!1;const r=this._overlays[0];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._renderContext.output;this._renderContext.output=this._renderTargets?.targets.find(r=>r.content===e)?.output??0,++this._techniques.precompiling;const s=this._sortedRenderers.some(({renderer:e})=>e.precompile(this._renderContext));return--this._techniques.precompiling,this._renderContext.output=t,s}get mode(){return this.isEmpty?0:this.hasWater&&this.renders(3)?2:this._renderTargets?.getTexture(0)?1:0}updateAnimation(e){let r=!1;return this._renderers.forEach(t=>r=t.updateAnimation(e)||r),r&&this.parent.requestRender(0),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return!1;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(1===t.content&&!this._needsColorWithoutRasterImage)continue;const{output:e}=t;this._renderContext.output=e,r.slot=3===e?19:18,9===e&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null);const s=this._renderContext.renderOccludedMask;4===t.content&&(this._renderContext.renderOccludedMask=H),this._sortedRenderers.forAll(({drapeSource:e,renderer:r})=>{1===t.content&&0===e.drapeSourceType||4===t.content&&r.hasOnlyOccluders||r.precompile(this._renderContext)}),this._renderContext.renderOccludedMask=s,r.highlightMixTexture=null}return--this._techniques.precompiling,!0}drawOverlays(e,r){if(!this._overlays||!this._renderTargets)return;for(const s of this._overlays)s.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;const t=this.allSourcesOccluders;for(const s of this._renderTargets.targets){if(!(0===s.content&&this._hasDrapedFlowSource)&&!s.handleRenderRequest(r)||1===s.content&&!this._needsColorWithoutRasterImage||4===s.content&&t)continue;const e=this._drawTarget(0,s),i=this._drawTarget(1,s);(e||i)&&s.fbo.generateMipMap()}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n}=r;if(this.isEmpty||3===n&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:o,_camera:a,_renderContext:h,_bindParameters:d}=this;if(a.pixelRatio=t.pixelRatio*i,h.output=n,d.screenToWorldRatio=this._screenToWorldRatio,d.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,d.slot=3===n?19:18,4===r.content&&(h.renderOccludedMask=H),!this.renders(r.content))return h.renderOccludedMask=P,!1;const{resolution:l}=t,c=0===e,u=c?0:l;if(o.setViewport(u,0,l,l),this._bindTargetFBO(r),c)if(9!==r.output)o.setClearColor(0,0,0,0),o.clear(16384);else{const{gl:e}=o;e.clearBufferuiv(e.COLOR,0,[0,0,0,0])}if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==r.content&&2!==r.content){this._techniques.precompile(E,z);const r=this._techniques.get(E,z);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,U[e]),o.bindTechnique(r,d,this._passParameters),o.screen.draw()}if(9===r.output){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),b(o,t,{width:s,height:s},d,()=>this._renderAllGeometry(e,r),u)}else this._renderAllGeometry(e,r);return o.bindFramebuffer(null),h.renderOccludedMask=P,!0}get allSourcesOccluders(){return i(this._renderers,e=>e.hasOnlyOccluders)}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll(({drapeSource:i,renderer:n})=>{if(1===r.content&&0===i.drapeSourceType)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&0===r.output&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(q);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}})}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.ensureFramebuffer(t,r),e.fbo.bind(this._rctx)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(16384),s}get _resolution(){return this._overlays?.[0].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers.map(e=>e.uid),r=e.length;this._renderers.forEach((t,s)=>{const i=e.indexOf(s.layer?.uid),n=i>=0,o=s.renderGroup??(n?0:1),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new L(s,t,h))}),this._sortedRenderers.sort((e,r)=>e.index-r.index)}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),g(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(m(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new G(e);i.samplingMode=9728,this._passParameters.texture=new k(this._rctx,i,t)}get test(){}};e([u()],I.prototype,"hasHighlights",void 0),e([u()],I.prototype,"renderOccludedFlags",void 0),e([u()],I.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({constructOnly:!0})],I.prototype,"parent",void 0),e([u({readOnly:!0})],I.prototype,"_techniques",null),e([u({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([u()],I.prototype,"isEmpty",null),I=e([p("esri.views.3d.terrain.OverlayRenderer")],I);class L{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const U=[[1,.5,.5],[.5,.5,1]],B=-2,H=4,z=new M;z.hasAlpha=!0;export{I as OverlayRenderer,B as drapedZ,H as overlayRenderOccludedFlag};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{R as e}from"../../../chunks/RasterColorizer.glsl.js";import{ReloadableShaderModule as r}from"../webgl-engine/core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as o}from"../webgl-engine/core/shaderTechnique/ShaderTechnique.js";import{Pos2TexF16 as s}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{fromLayout as t}from"../../webgl/VertexAttributeLocations.js";class i extends o{constructor(o,i){super(o,i,new r(e,()=>import("../webgl-engine/core/shaderLibrary/raster/RasterColorizer.glsl.js")),t(s))}}export{i as RasterColorizerTechnique};
5
+ import{__decorate as r}from"tslib";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{R as o}from"../../../chunks/RasterColorizer.glsl.js";import{ReloadableShader as s}from"../webgl-engine/core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as i}from"../webgl-engine/core/shaderTechnique/ShaderTechnique.js";import{Pos2TexF16 as t}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{PrimitiveType as a}from"../../webgl/enums.js";import{fromLayout as m}from"../../webgl/VertexAttributeLocations.js";let c=class extends i{constructor(r,e){super(r,e,m(t)),this.shader=new s(o,()=>import("../webgl-engine/core/shaderLibrary/raster/RasterColorizer.glsl.js")),this.primitiveType=a.TRIANGLE_STRIP}};c=r([e("esri.views.3d.terrain.RasterColorizerTechnique")],c);export{c as RasterColorizerTechnique};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as i,difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as n}from"../../../core/Evented.js";import"../../../core/has.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import u from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as m}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as f,sync as y,initial as T}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../core/unitUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{q as C,j as b,d as x}from"../../../chunks/vec32.js";import{create as E}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as P,radiusModifier as U}from"../../../geometry/ellipsoidUtils.js";import M from"../../../geometry/SpatialReference.js";import{getProjector as j}from"../../../geometry/projection/projectors.js";import{projectPointToVector as D}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as R}from"../../../geometry/projection/projectVectorToVector.js";import{create as B,equals as I,intersection as k,intersectsSphere as A,empty as V,expand as O}from"../../../geometry/support/aaBoundingRect.js";import{copy as N,create as G}from"../../../geometry/support/frustum.js";import{createSpatialReferenceCyclical as q}from"../../../geometry/support/normalizeUtils.js";import{isPlateCarree as F}from"../../../geometry/support/spatialReferenceUtils.js";import{m as W,c as H,n as $,o as z,e as Q}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as Y}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as X}from"../../../layers/support/layerUtils.js";import{debugFlags as K}from"../support/debugFlags.js";import{ElevationRange as J}from"../support/ElevationRange.js";import{toBoundingRect as Z}from"../support/extentUtils.js";import{updatingProgress as ee}from"../support/updatingProperties.js";import{ElevationBounds as te}from"./ElevationBounds.js";import{ElevationData as ie,sampleElevation as re}from"./ElevationData.js";import{ElevationUpdateEventImplementation as se}from"./ElevationUpdateEvent.js";import{create as ae}from"./ExtentHelper.js";import{LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{Queue as he}from"./Queue.js";import{ScaleRangeQueries as de}from"./ScaleRangeQueries.js";import{SphericalPatch as pe}from"./SphericalPatch.js";import{SplitLimits as ue}from"./SplitLimits.js";import{maxRootTiles as ce,tooManyRootTilesAfterChangeError as ge,tooManyRootTilesForLayerError as me,maxTileNeighborLevelDelta as _e,maxMemoryLodBias as fe}from"./TerrainConst.js";import{TerrainRenderer as ye}from"./TerrainRenderer.js";import Te from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as ve,isVectorTileLayerView as we,neighborEdgeIndices as Se,internalAssert as Ce,oppositeEdge as be,isSurfaceLayerView as xe,isGroupLayerView as Ee,isMapTileLayerView as Le,isBlendableLayerView as Pe,isElevationLayerView as Ue,releaseTerrainData as Me,enableTerrainInternalChecks as je,oppositeCorner as De,enableWaterproofTests as Re,enableInternalTerrainChecks as Be,enableTerrainWaterproofChecks as Ie,neighborCornerIndices as ke}from"./terrainUtils.js";import{Tile as Ae,lijEquals as Ve}from"./Tile.js";import{printAllocations as Oe}from"./TilePerLayerInfo.js";import{sortTiles as Ne,IteratorPreorder as Ge,IteratorPostorder as qe,compareTilesByLij as Fe,hasLoadableSiblings as We,sortTilesByPOI as He}from"./tileUtils.js";import{TilingSchemeLogic as $e}from"./TilingSchemeLogic.js";import{UpsampleInfo as ze}from"./UpsampleInfo.js";import{isCompositeBlendMode as Qe,blendModeFromString as Ye}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as Xe}from"../../support/layerViewUtils.js";import{ImmediateTask as Ke,TaskPriority as Je,noBudget as Ze}from"../../support/Scheduler.js";import{TextureCompressionTracker as et}from"../../support/TextureCompressionTracker.js";import{Yield as tt}from"../../support/Yield.js";var it;let rt=class extends n{static{it=this}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Ne(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){const{_allTiles:e,tilingScheme:t}=this;if(0===e.length)return{min:1,max:1};const i=v(t.spatialReference);let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const a of e){const e=t.resolutionAtLevel(a.level)*i;r=Math.min(r,e),s=Math.max(s,e)}return{min:r,max:s}}constructor(e){super(e),this.terrainTextureCompressionTracker=new et,this._iteratorPool=new p(()=>new Ge,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new qe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new Te,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=E(),this._eyePosSurfaceSR=E(),this._splitLimits=new ue,this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new L,this._frameTask=Ke,this._allTiles=new u,this._upsampleInfoPool=new p(()=>new ze),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=B(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=M.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new te(1/0,-1/0),this.rootTileElevationBounds=new te(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;const{view:t}=e;this.overlayManager=new le({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?pe:oe,this._ellipsoid=P(t.spatialReference),this._renderer=new ye(this.overlayManager.renderer,t.stage,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),Xe()||(this._scaleRangeQueries=new de)}initialize(){const{view:e}=this,{resourceController:t}=e,{memoryController:i}=t;this._tileCache=new d((e,t)=>i.newCache(e,t),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new Y(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([_(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),_(()=>this.renderer.visible,e=>this.suspended=!e),_(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)}),_(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(2===t||Math.min(r,360-r)>=30)&&(this.heading=i)})],"overlayManager"),this.addHandles([_(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},f),_(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),f),_(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},y),_(()=>this.snapLevel,()=>this._viewChanged=!0,y),_(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:C})}),_(()=>K.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&K.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=h(this._treeDebugger))},T)]);const{spatialReference:a}=e;this._extentHelper=ae(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new $e({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme();const o=t.scheduler;this._frameTask=o.registerTask(Je.TERRAIN_SURFACE,this),this.addHandles([_(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),T),_(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),y),_(()=>this.extent,()=>this._updateRootTiles(),T),e.on("resize",()=>this._viewChangeUpdate()),_(()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),f),_(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,T),_(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,T),_(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),_(()=>this._userClippingExtent,()=>this._updateClippingExtent(),y)]),this.addHandles(e.allLayerViews.on("after-changes",()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._watchUpdatingTracking?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._frameTask.remove(),this._frameTask=Ke,this._watchUpdatingTracking?.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),this._allTiles.prune(),Ae.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),Oe(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){if(this.lodSnappingEnabled){const{view:e,tilingScheme:t}=this,i=e.scale;if(t&&i){const r=t.levelAtScale(i)+e.qualitySettings.tiledSurface.lodBias,s=t.getMaxLod();return r<=0?null:Math.min(r,s||1/0)}}return null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get _userClippingExtent(){const{spatialReference:e}=this,t=this.view?.clippingArea;if(null==t||null==e)return null;const i=B(),r=Z(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=k(this.groundExtent,this._userClippingExtent,B()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||null!=this._rootTiles}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return 0===this._renderer.transparency}get invisible(){return 3===this._renderer.transparency}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return q(this._spatialReference)}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length||!this.enabled)return null;if(0===s[0].layerInfo[0].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=j(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return l.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const n=b(at,e,t,i);a(n,0,n,0);return pt(s,this._xNormalizer?.normalize(n[0])??n[0],n[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[0].length:0;if(r?.length&&0!==s&&this.enabled)for(let a=0;a<t;++a){const t=3*a;i(a,pt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!D(e,at,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(at)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;at[0]>t[2]&&(i+=1),at[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=j(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationBounds(e,t){if(!this.enabled||null==this._rootTiles)return null;const i=this._ensureProjector(t);if(null==i)return l.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;W(e,nt);const r=$(nt,E());i(r,0,r,0),z(nt,r);const s=new J,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!A(i.extent,nt))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return this.enabled&&null!=this._rootTiles?new J(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max):null}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationBounds.min)*U;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!D(e,ft,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Q(nt,ft,t);let i=null;const r=e=>{if(e&&A(e.extent,nt)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){if(!this._scaleRangeQueries)return;const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._isFullyTransparent?t?3:2:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,i!==r}_updateTilingScheme(){const{tilingScheme:e}=this.tilingSchemeLogic;if(!(e!==this.tilingScheme))return;ve(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??M.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&F(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(it._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=lt;let s=t.rootTilesInExtent(e,i,5*ce);if(null!=this._rootTiles){if(s.length>ce)return void l.getLogger(this).warn(ge);const e=this._rootTiles.map(e=>e.lij),t=r(e,s,Ve);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter(e=>!(t.removed.findIndex(t=>Ve(t,e.lij))>-1)||(this._purgeTile(e),!1));t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>ce&&(l.getLogger(this).warn(me),s=t.rootTilesInExtent(e,i,ce)),this._setRootTiles(s.map(e=>this._newRootTile(e)));I(i,this._rootTilesExtent)||(this._rootTilesExtent=B(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter(e=>e.loaded&&e.intersectsClippingArea);e.sort(Fe),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Fe);const t=this.renderer;e.forEach(e=>t.updateGeometryIfNeeded(e)),e.forEach(e=>this._pendingTilesForElevationUpdateEvent.add(e))}_shouldSplit(e){return 1===e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=We(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new te(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach(({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)});const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new te(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=N(this._splitLimits.frustum??G(),t.frustum):this._splitLimits.frustum=null,x(this._eyePosRenderSR,t.eye),R(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(we)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){const i=e.resetPendingUpdate(32)?32:!!e.resetPendingUpdate(16)&&16;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=ht.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach(t=>O(e,t.extent,e)),this._pendingTilesForElevationUpdateEvent.clear(),ht.spatialReference=this.spatialReference,this.emit("elevation-change",ht),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),je&&this._checkTileInvariant(),!e.hasProgressed)return tt}_checkTileInvariant(){const e=new Map;this._allTiles.forAll(t=>e.set(t,new Set)),this._allTiles.forAll(t=>{if(ve(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce((t,i)=>t+(e(i)?0:1),0);if(ve(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(4)){ve(!t.hasPendingUpdate(1),"Tile can be both split and merge at the same time");for(const e of t.children)ve(e.leaf||e.hasPendingUpdate(4),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=_e;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${_e} (edge[${i}])`),ve(r,`tile level delta [${t.level}] vs [${e.level}] > ${_e}`))}ve(t.level-e.level<=_e,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-_e,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(Se[i],s);if(null!=a){if(t.leaf&&t.level>=_e){let i=a;for(;t.level-i.level<_e;)i=i.parent;const s=[r,t.lij[1]>>_e,t.lij[2]>>_e];if(!Ve(s,i.lij)){const r=e.get(i);ve(!r.has(t),"Cannot already have neighbor"),r.add(t)}}ve(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),ve(t.level-a.level<=_e,`Tile level delta [${t.level}] vs [${a.level}] > ${_e}`)}}}),this._allTiles.forAll(t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);ve(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)})}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new he(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=n?.hasPendingUpdate(4),o=l?4:e.shouldSplit(r,s,i),h=1===o;e.leaf?ut(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(1),e.leaf||e.setPendingUpdate(4),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),2===o&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||!this.view.pointsOfInterest?.focus||(He(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){Ce(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter(e=>e.loaded&&e.intersectsClippingArea);if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Fe);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Ce(r.loaded),Ce(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=ke[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(De(t),e=>e.loaded))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(be(Se[t]),t=>!(!t.loaded||!t.intersectsClippingArea)&&(Ce(e.has(t)||Fe(r,t)<0),i(r,t),!0)),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,je&&Re&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some(s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(4)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(4);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(4);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(1)){let t=!0;const i=s.level;if(i>=_e){const e=e=>e.leaf||i-e.level<_e;for(let r=0;r<4;++r){const a=s.findNeighborTile(Se[r],e);null!=a&&i-a.level===_e&&(t=!1,je&&(Ce(a.leaf),Ce(a.hasPendingUpdate(1))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done)),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*fe}_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(){null!=this._rootTiles&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?gt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(it._tileMemcacheKey,e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){ve(e.leaf,"Tile that is already split should not be split again!"),ve(e.rendered,"Tile marked to split is not rendered"),gt(e);const t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),e.updateAgentSuspension(),ve(e.rendered,"parent should be rendered"),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>ut(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){dt.spatialReference=this.spatialReference,dt.extent=e.extent,dt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",dt)}createTile(e,t,i,r){ve(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(1),s}get _shortBatches(){return 2!==this.view.state.mode}_mergeTile(e){ve(!e.hasPendingUpdate(1),"_mergeTile sanity check"),ve(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),ve(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),ut(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=Ze){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),xe(e)||Ee(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Ee(e)){const i=this._layerClassFromLayerView(e),s=this.getLayerIndexByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(const e of this.view.allLayerViews.items)if(Le(e)&&!X(e.layer)&&0!==e.fullOpacity)return!1;return!0}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Pe(e)||Ee(e))&&Qe(Ye[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Ue(e)?0:1}_registerTiledLayerView(e){const t=[];if((Pe(e)||Ee(e))&&t.push(_(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!Ee(e)){const i=this._layerClassFromLayerView(e);t.push(_(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(_(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));const{layer:r}=e;"effectiveScaleRange"in r&&t.push(_(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(i))),t.push(e.on("data-changed",()=>{const t=this.getLayerIndexByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach(e=>{if(!e.layer||e.suspended||!xe(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(1===r){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)});for(const r of ne){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),0===e&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),1===e?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll(i=>i.removeLayerAgent(e,t)),this._allTiles.forAll(i=>i.invalidateLayerData(e,t))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=1){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||we(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then(()=>--this._asyncWorkItems).catch(t=>{throw--this._asyncWorkItems,c(r),g(t)||this._dataMissing(e,i,s),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,i,s,r),r.signal)))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();return 0===t?Ue(i)?this._requestElevationTileData(e,i,r):Promise.reject():Le(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!m(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{g(i)||(l.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${i}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,i).then(e=>this._frameTask.schedule(()=>r(e)),s).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[0].get(t.uid);if(null==r)return void l.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",0,e.lij.toString());const s=new ie(e.lij,e.extent,i);e.dataArrived(r,0,s),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:0});const a=[e],n=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,n),e.computeElevationBounds()}0===n&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{Me(s),m(i)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule(()=>{this.requestUpdate(),m(i)?Me(r):this._mapTileDataArrived(e,t,r)},i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule(()=>r(e,t));return t.fetchTile(e.lij,i).then(a,n).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,i){const r=this.getLayerIndexByUID(1,t.uid);if(null==r)return Me(i),void l.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,1,i),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:1})}_dataMissing(e,t,i){const r=this.getLayerIndexByUID(t,i.uid);null!=r?(e.dataMissing(r,t),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:t})):l.getLogger(this).warn("TerrainSurface: received data from unknown layer")}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.leaf&&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}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(i,e.uid);return null!=r&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(i,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Re)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)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.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Be(e)}enableWaterproofnessChecks(e){Ie(e)}static cleanupTerrainSurface(){ot.prune()}enable(e){e!==this.enabled&&(e?(this._updateRootTiles(),this.suspended=!1):(this.suspended=!0,this._removeAllTiles(),this._setRootTiles(null)),this._set("enabled",e),this.notifyChange("ready"))}updateOverlayParameters(){const{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([w()],rt.prototype,"_renderer",void 0),e([w({constructOnly:!0})],rt.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],rt.prototype,"view",void 0),e([w({constructOnly:!0})],rt.prototype,"overlayManager",void 0),e([w({constructOnly:!0})],rt.prototype,"terrainTextureCompressionTracker",void 0),e([w()],rt.prototype,"_hasPendingUpdates",void 0),e([w()],rt.prototype,"_asyncWorkItems",void 0),e([w()],rt.prototype,"_allTilesDirty",void 0),e([w()],rt.prototype,"_allTilesSorted",void 0),e([w()],rt.prototype,"_viewChanged",void 0),e([w({type:Number})],rt.prototype,"heading",void 0),e([w()],rt.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],rt.prototype,"_watchUpdatingTracking",void 0),e([w()],rt.prototype,"_frameTask",void 0),e([w()],rt.prototype,"demResolution",null),e([w({readOnly:!0})],rt.prototype,"snapLevel",null),e([w({readOnly:!0})],rt.prototype,"lodSnappingEnabled",null),e([w()],rt.prototype,"_userClippingExtent",null),e([w()],rt.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],rt.prototype,"extent",null),e([w({readOnly:!0})],rt.prototype,"groundExtent",null),e([w({readOnly:!0})],rt.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],rt.prototype,"updating",null),e([w({readOnly:!0})],rt.prototype,"readyToRun",null),e([w(ee)],rt.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],rt.prototype,"updatingProgressValue",null),e([w()],rt.prototype,"_maxNumUpdating",void 0),e([w()],rt.prototype,"baseOpacity",null),e([w()],rt.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],rt.prototype,"viewingMode",null),e([w()],rt.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],rt.prototype,"ready",null),e([w({readOnly:!0})],rt.prototype,"rootTiles",null),e([w()],rt.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],rt.prototype,"spatialReference",null),e([w({type:t})],rt.prototype,"backgroundColor",null),e([w({value:!1})],rt.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],rt.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],rt.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],rt.prototype,"tilingSchemeLogic",void 0),e([w()],rt.prototype,"wireframe",null),e([w({value:!1})],rt.prototype,"suspended",null),e([w()],rt.prototype,"fadeDuration",null),e([w()],rt.prototype,"_xNormalizer",null),e([w()],rt.prototype,"visibleElevationBounds",void 0),e([w()],rt.prototype,"rootTileElevationBounds",void 0),e([w()],rt.prototype,"_layerViewsDirty",void 0),e([w()],rt.prototype,"renderPatchBorders",null),e([w()],rt.prototype,"visualizeNormals",null),e([w()],rt.prototype,"renderingDisabled",null),e([w({readOnly:!0})],rt.prototype,"enabled",void 0),rt=it=e([S("esri.views.3d.terrain.TerrainSurface")],rt);const st=rt,at=E(),nt=H(),lt=B(),ot=new u,ht=new se("ground"),dt={spatialReference:null,extent:null,scale:0};function pt(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return re(t,i,s)}return null}function ut(e,t){!e.leaf||e.level<_e||_t(e,e=>{t&&ct(e);const i=mt(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=mt(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}})}function ct(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<_e||_t(e,e=>{ct(e)})}function gt(e){e.level<_e||_t(e,e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,mt(t));)t=t.parent}})}function mt(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function _t(e,t){if(e.level<_e)return;const i=e.level-_e,r=e.lij[1]>>_e,s=e.lij[2]>>_e,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(Se[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}const ft=E();export{st as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as i,difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as n}from"../../../core/Evented.js";import"../../../core/has.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import u from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as m}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as y,sync as f,initial as T}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../core/unitUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{q as C,j as b,d as x}from"../../../chunks/vec32.js";import{create as E}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as P,radiusModifier as U}from"../../../geometry/ellipsoidUtils.js";import M from"../../../geometry/SpatialReference.js";import{getProjector as j}from"../../../geometry/projection/projectors.js";import{projectPointToVector as D}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as R}from"../../../geometry/projection/projectVectorToVector.js";import{create as B,equals as I,intersection as k,intersectsSphere as V,empty as A,expand as O}from"../../../geometry/support/aaBoundingRect.js";import{copy as N,create as G}from"../../../geometry/support/frustum.js";import{createSpatialReferenceCyclical as q}from"../../../geometry/support/normalizeUtils.js";import{isPlateCarree as F}from"../../../geometry/support/spatialReferenceUtils.js";import{m as W,c as H,n as $,o as z,e as Q}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as Y}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as X}from"../../../layers/support/layerUtils.js";import{debugFlags as K}from"../support/debugFlags.js";import{ElevationRange as J}from"../support/ElevationRange.js";import{toBoundingRect as Z}from"../support/extentUtils.js";import{updatingProgress as ee}from"../support/updatingProperties.js";import{ElevationBounds as te}from"./ElevationBounds.js";import{ElevationData as ie,sampleElevation as re}from"./ElevationData.js";import{ElevationUpdateEventImplementation as se}from"./ElevationUpdateEvent.js";import{create as ae}from"./ExtentHelper.js";import{LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{Queue as he}from"./Queue.js";import{ScaleRangeQueries as de}from"./ScaleRangeQueries.js";import{SphericalPatch as pe}from"./SphericalPatch.js";import{SplitLimits as ue}from"./SplitLimits.js";import{maxRootTiles as ce,tooManyRootTilesAfterChangeError as ge,tooManyRootTilesForLayerError as me,maxTileNeighborLevelDelta as _e,maxMemoryLodBias as ye}from"./TerrainConst.js";import{TerrainRenderer as fe}from"./TerrainRenderer.js";import Te from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as ve,isVectorTileLayerView as we,neighborEdgeIndices as Se,internalAssert as Ce,oppositeEdge as be,isSurfaceLayerView as xe,isGroupLayerView as Ee,isMapTileLayerView as Le,isBlendableLayerView as Pe,isElevationLayerView as Ue,releaseTerrainData as Me,enableTerrainInternalChecks as je,oppositeCorner as De,enableWaterproofTests as Re,enableInternalTerrainChecks as Be,enableTerrainWaterproofChecks as Ie,neighborCornerIndices as ke}from"./terrainUtils.js";import{Tile as Ve,lijEquals as Ae}from"./Tile.js";import{printAllocations as Oe}from"./TilePerLayerInfo.js";import{sortTiles as Ne,IteratorPreorder as Ge,IteratorPostorder as qe,compareTilesByLij as Fe,hasLoadableSiblings as We,sortTilesByPOI as He}from"./tileUtils.js";import{TilingSchemeLogic as $e}from"./TilingSchemeLogic.js";import{UpsampleInfo as ze}from"./UpsampleInfo.js";import{isCompositeBlendMode as Qe,blendModeFromString as Ye}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as Xe}from"../../support/layerViewUtils.js";import{ImmediateTask as Ke,TaskPriority as Je,noBudget as Ze}from"../../support/Scheduler.js";import{TextureCompressionTracker as et}from"../../support/TextureCompressionTracker.js";import{Yield as tt}from"../../support/Yield.js";var it;let rt=class extends n{static{it=this}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Ne(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){const{_allTiles:e,tilingScheme:t}=this;if(0===e.length)return{min:1,max:1};const i=v(t.spatialReference);let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const a of e){const e=t.resolutionAtLevel(a.level)*i;r=Math.min(r,e),s=Math.max(s,e)}return{min:r,max:s}}constructor(e){super(e),this.terrainTextureCompressionTracker=new et,this._iteratorPool=new p(()=>new Ge,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new qe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new Te,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=E(),this._eyePosSurfaceSR=E(),this._splitLimits=new ue,this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new L,this._frameTask=Ke,this._allTiles=new u,this._upsampleInfoPool=new p(()=>new ze),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=B(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=M.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new te(1/0,-1/0),this.rootTileElevationBounds=new te(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;const{view:t}=e;this.overlayManager=new le({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?pe:oe,this._ellipsoid=P(t.spatialReference),this._renderer=new fe(this.overlayManager.renderer,t.stage,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),Xe()||(this._scaleRangeQueries=new de)}initialize(){const{view:e}=this,{resourceController:t}=e,{memoryController:i}=t;this._tileCache=new d((e,t)=>i.newCache(e,t),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new Y(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([_(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),_(()=>this.renderer.visible,e=>this.suspended=!e),_(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)}),_(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(2===t||Math.min(r,360-r)>=30)&&(this.heading=i)})],"overlayManager"),this.addHandles([_(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},y),_(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),y),_(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},f),_(()=>this.snapLevel,()=>this._viewChanged=!0,f),_(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:C})}),_(()=>K.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&K.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=h(this._treeDebugger))},T)]);const{spatialReference:a}=e;this._extentHelper=ae(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new $e({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme();const o=t.scheduler;this._frameTask=o.registerTask(Je.TERRAIN_SURFACE,this),this.addHandles([_(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),T),_(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),f),_(()=>this.extent,()=>this._updateRootTiles(),T),e.on("resize",()=>this._viewChangeUpdate()),_(()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),y),_(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,T),_(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,T),_(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),_(()=>this._userClippingExtent,()=>this._updateClippingExtent(),f)]),this.addHandles(e.allLayerViews.on("after-changes",()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._watchUpdatingTracking?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._frameTask.remove(),this._frameTask=Ke,this._watchUpdatingTracking?.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),this._allTiles.prune(),Ve.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),Oe(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){return this.lodSnappingEnabled?this.view.terrainLevel:null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get _userClippingExtent(){const{spatialReference:e}=this,t=this.view?.clippingArea;if(null==t||null==e)return null;const i=B(),r=Z(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=k(this.groundExtent,this._userClippingExtent,B()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||null!=this._rootTiles}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return 0===this._renderer.transparency}get invisible(){return 3===this._renderer.transparency}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return q(this._spatialReference)}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length||!this.enabled)return null;if(0===s[0].layerInfo[0].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=j(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return l.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const n=b(at,e,t,i);a(n,0,n,0);return pt(s,this._xNormalizer?.normalize(n[0])??n[0],n[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[0].length:0;if(r?.length&&0!==s&&this.enabled)for(let a=0;a<t;++a){const t=3*a;i(a,pt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!D(e,at,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(at)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;at[0]>t[2]&&(i+=1),at[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=j(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationBounds(e,t){if(!this.enabled||null==this._rootTiles)return null;const i=this._ensureProjector(t);if(null==i)return l.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;W(e,nt);const r=$(nt,E());i(r,0,r,0),z(nt,r);const s=new J,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!V(i.extent,nt))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return this.enabled&&null!=this._rootTiles?new J(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max):null}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationBounds.min)*U;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!D(e,yt,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Q(nt,yt,t);let i=null;const r=e=>{if(e&&V(e.extent,nt)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){if(!this._scaleRangeQueries)return;const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._isFullyTransparent?t?3:2:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,i!==r}_updateTilingScheme(){const{tilingScheme:e}=this.tilingSchemeLogic;if(!(e!==this.tilingScheme))return;ve(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??M.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&F(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(it._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=lt;let s=t.rootTilesInExtent(e,i,5*ce);if(null!=this._rootTiles){if(s.length>ce)return void l.getLogger(this).warn(ge);const e=this._rootTiles.map(e=>e.lij),t=r(e,s,Ae);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter(e=>!(t.removed.findIndex(t=>Ae(t,e.lij))>-1)||(this._purgeTile(e),!1));t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>ce&&(l.getLogger(this).warn(me),s=t.rootTilesInExtent(e,i,ce)),this._setRootTiles(s.map(e=>this._newRootTile(e)));I(i,this._rootTilesExtent)||(this._rootTilesExtent=B(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter(e=>e.loaded&&e.intersectsClippingArea);e.sort(Fe),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Fe);const t=this.renderer;e.forEach(e=>t.updateGeometryIfNeeded(e)),e.forEach(e=>this._pendingTilesForElevationUpdateEvent.add(e))}_shouldSplit(e){return 1===e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=We(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new te(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach(({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)});const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new te(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=N(this._splitLimits.frustum??G(),t.frustum):this._splitLimits.frustum=null,x(this._eyePosRenderSR,t.eye),R(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(we)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){const i=e.resetPendingUpdate(32)?32:!!e.resetPendingUpdate(16)&&16;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=ht.extent;A(e),this._pendingTilesForElevationUpdateEvent.forEach(t=>O(e,t.extent,e)),this._pendingTilesForElevationUpdateEvent.clear(),ht.spatialReference=this.spatialReference,this.emit("elevation-change",ht),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),je&&this._checkTileInvariant(),!e.hasProgressed)return tt}_checkTileInvariant(){const e=new Map;this._allTiles.forAll(t=>e.set(t,new Set)),this._allTiles.forAll(t=>{if(ve(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce((t,i)=>t+(e(i)?0:1),0);if(ve(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(4)){ve(!t.hasPendingUpdate(1),"Tile can be both split and merge at the same time");for(const e of t.children)ve(e.leaf||e.hasPendingUpdate(4),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=_e;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${_e} (edge[${i}])`),ve(r,`tile level delta [${t.level}] vs [${e.level}] > ${_e}`))}ve(t.level-e.level<=_e,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-_e,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(Se[i],s);if(null!=a){if(t.leaf&&t.level>=_e){let i=a;for(;t.level-i.level<_e;)i=i.parent;const s=[r,t.lij[1]>>_e,t.lij[2]>>_e];if(!Ae(s,i.lij)){const r=e.get(i);ve(!r.has(t),"Cannot already have neighbor"),r.add(t)}}ve(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),ve(t.level-a.level<=_e,`Tile level delta [${t.level}] vs [${a.level}] > ${_e}`)}}}),this._allTiles.forAll(t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);ve(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)})}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new he(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=n?.hasPendingUpdate(4),o=l?4:e.shouldSplit(r,s,i),h=1===o;e.leaf?ut(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(1),e.leaf||e.setPendingUpdate(4),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),2===o&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||!this.view.pointsOfInterest?.focus||(He(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){Ce(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter(e=>e.loaded&&e.intersectsClippingArea);if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Fe);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Ce(r.loaded),Ce(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=ke[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(De(t),e=>e.loaded))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(be(Se[t]),t=>!(!t.loaded||!t.intersectsClippingArea)&&(Ce(e.has(t)||Fe(r,t)<0),i(r,t),!0)),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,je&&Re&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some(s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(4)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(4);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(4);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(1)){let t=!0;const i=s.level;if(i>=_e){const e=e=>e.leaf||i-e.level<_e;for(let r=0;r<4;++r){const a=s.findNeighborTile(Se[r],e);null!=a&&i-a.level===_e&&(t=!1,je&&(Ce(a.leaf),Ce(a.hasPendingUpdate(1))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done)),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.updateOverlayParameters(),this.requestRender(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*ye}_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(){null!=this._rootTiles&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?gt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(it._tileMemcacheKey,e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){ve(e.leaf,"Tile that is already split should not be split again!"),ve(e.rendered,"Tile marked to split is not rendered"),gt(e);const t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),e.updateAgentSuspension(),ve(e.rendered,"parent should be rendered"),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>ut(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){dt.spatialReference=this.spatialReference,dt.extent=e.extent,dt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",dt)}createTile(e,t,i,r){ve(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(1),s}get _shortBatches(){return 2!==this.view.state.mode}_mergeTile(e){ve(!e.hasPendingUpdate(1),"_mergeTile sanity check"),ve(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),ve(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),ut(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&e.updateOverlayParameters(this.overlayManager)}_handleLayerViewChanges(e=Ze){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),xe(e)||Ee(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Ee(e)){const i=this._layerClassFromLayerView(e),s=this.getLayerIndexByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(const e of this.view.allLayerViews.items)if(Le(e)&&!X(e.layer)&&0!==e.fullOpacity)return!1;return!0}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Pe(e)||Ee(e))&&Qe(Ye[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Ue(e)?0:1}_registerTiledLayerView(e){const t=[];if((Pe(e)||Ee(e))&&t.push(_(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!Ee(e)){const i=this._layerClassFromLayerView(e);t.push(_(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(_(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));const{layer:r}=e;"effectiveScaleRange"in r&&t.push(_(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(i))),t.push(e.on("data-changed",()=>{const t=this.getLayerIndexByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach(e=>{if(!e.layer||e.suspended||!xe(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(1===r){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)});for(const r of ne){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),0===e&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),1===e?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll(i=>i.removeLayerAgent(e,t)),this._allTiles.forAll(i=>i.invalidateLayerData(e,t))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=1){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||we(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then(()=>--this._asyncWorkItems).catch(t=>{throw--this._asyncWorkItems,c(r),g(t)||this._dataMissing(e,i,s),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,i,s,r),r.signal)))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();return 0===t?Ue(i)?this._requestElevationTileData(e,i,r):Promise.reject():Le(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!m(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{g(i)||(l.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${i}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,i).then(e=>this._frameTask.schedule(()=>r(e)),s).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[0].get(t.uid);if(null==r)return void l.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",0,e.lij.toString());const s=new ie(e.lij,e.extent,i);e.dataArrived(r,0,s),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:0});const a=[e],n=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,n),e.computeElevationBounds()}0===n&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{Me(s),m(i)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule(()=>{this.requestUpdate(),m(i)?Me(r):this._mapTileDataArrived(e,t,r)},i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule(()=>r(e,t));return t.fetchTile(e.lij,i).then(a,n).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,i){const r=this.getLayerIndexByUID(1,t.uid);if(null==r)return Me(i),void l.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,1,i),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:1})}_dataMissing(e,t,i){const r=this.getLayerIndexByUID(t,i.uid);null!=r?(e.dataMissing(r,t),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:t})):l.getLogger(this).warn("TerrainSurface: received data from unknown layer")}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.leaf&&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}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(i,e.uid);return null!=r&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(i,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Re)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)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.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Be(e)}enableWaterproofnessChecks(e){Ie(e)}static cleanupTerrainSurface(){ot.prune()}enable(e){e!==this.enabled&&(e?(this._updateRootTiles(),this.suspended=!1):(this.suspended=!0,this._removeAllTiles(),this._setRootTiles(null)),this._set("enabled",e),this.notifyChange("ready"))}updateOverlayParameters(){const{overlayManager:e}=this;this.allTiles.forAll(t=>t.updateOverlayParameters(e))}};e([w()],rt.prototype,"_renderer",void 0),e([w({constructOnly:!0})],rt.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],rt.prototype,"view",void 0),e([w({constructOnly:!0})],rt.prototype,"overlayManager",void 0),e([w({constructOnly:!0})],rt.prototype,"terrainTextureCompressionTracker",void 0),e([w()],rt.prototype,"_hasPendingUpdates",void 0),e([w()],rt.prototype,"_asyncWorkItems",void 0),e([w()],rt.prototype,"_allTilesDirty",void 0),e([w()],rt.prototype,"_allTilesSorted",void 0),e([w()],rt.prototype,"_viewChanged",void 0),e([w({type:Number})],rt.prototype,"heading",void 0),e([w()],rt.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],rt.prototype,"_watchUpdatingTracking",void 0),e([w()],rt.prototype,"_frameTask",void 0),e([w()],rt.prototype,"demResolution",null),e([w({readOnly:!0})],rt.prototype,"snapLevel",null),e([w({readOnly:!0})],rt.prototype,"lodSnappingEnabled",null),e([w()],rt.prototype,"_userClippingExtent",null),e([w()],rt.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],rt.prototype,"extent",null),e([w({readOnly:!0})],rt.prototype,"groundExtent",null),e([w({readOnly:!0})],rt.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],rt.prototype,"updating",null),e([w({readOnly:!0})],rt.prototype,"readyToRun",null),e([w(ee)],rt.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],rt.prototype,"updatingProgressValue",null),e([w()],rt.prototype,"_maxNumUpdating",void 0),e([w()],rt.prototype,"baseOpacity",null),e([w()],rt.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],rt.prototype,"viewingMode",null),e([w()],rt.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],rt.prototype,"ready",null),e([w({readOnly:!0})],rt.prototype,"rootTiles",null),e([w()],rt.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],rt.prototype,"spatialReference",null),e([w({type:t})],rt.prototype,"backgroundColor",null),e([w({value:!1})],rt.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],rt.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],rt.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],rt.prototype,"tilingSchemeLogic",void 0),e([w()],rt.prototype,"wireframe",null),e([w({value:!1})],rt.prototype,"suspended",null),e([w()],rt.prototype,"fadeDuration",null),e([w()],rt.prototype,"_xNormalizer",null),e([w()],rt.prototype,"visibleElevationBounds",void 0),e([w()],rt.prototype,"rootTileElevationBounds",void 0),e([w()],rt.prototype,"_layerViewsDirty",void 0),e([w()],rt.prototype,"renderPatchBorders",null),e([w()],rt.prototype,"visualizeNormals",null),e([w()],rt.prototype,"renderingDisabled",null),e([w({readOnly:!0})],rt.prototype,"enabled",void 0),rt=it=e([S("esri.views.3d.terrain.TerrainSurface")],rt);const st=rt,at=E(),nt=H(),lt=B(),ot=new u,ht=new se("ground"),dt={spatialReference:null,extent:null,scale:0};function pt(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return re(t,i,s)}return null}function ut(e,t){!e.leaf||e.level<_e||_t(e,e=>{t&&ct(e);const i=mt(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=mt(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}})}function ct(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<_e||_t(e,e=>{ct(e)})}function gt(e){e.level<_e||_t(e,e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,mt(t));)t=t.parent}})}function mt(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function _t(e,t){if(e.level<_e)return;const i=e.level-_e,r=e.lij[1]>>_e,s=e.lij[2]>>_e,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(Se[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}const yt=E();export{st 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import"../../../core/has.js";import{progressiveLoadingModulo as e}from"./TerrainConst.js";import{fallsWithinLayerView as t,getTileMapCache as s}from"./tileUtils.js";class i{get updating(){return!!this._tileRequested}init(e,t,s,i){this.tile=e,this._layerIdx=t,this._layerClass=s,this._suspended=i,this._tileLayerInfo=e.getLayerInfo(t,s),this._tileRequested=null;const l=this._findAncestorWithData();this._setUpsampleTile(l)}startLoading(){return this._requestNext()}dispose(){this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null),this.tile=null,this._tileLayerInfo=null}setSuspension(e){e!==this._suspended&&(this._suspended=e,e?this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null):this._tileLayerInfo.data||this.update())}update(){const e=this._findAncestorWithData();return this._setUpsampleTile(e),this._requestNext()}dataArrived(e,t){this._setUpsampleTile(e,t),this._tileRequested=null,e===this.tile?this.tile.updateRenderData(this._layerClass,0,t):this._requestNext()}dataMissing(){this._tileRequested=null,this._tileLayerInfo.data=null,this._requestNext()}_agentDone(){this.tile.agentDone(this._layerIdx,this._layerClass),this.dispose()}_requestNext(){if(this._suspended)return!0;const e=this._findNextDownload();if(this._tileRequested){if(e===this._tileRequested)return!0;this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null}return null!=e?e.requestLayerData(this._layerIdx,this._layerClass,this)&&(this._tileRequested=e):this._agentDone(),!!this._tileRequested}_findNextDownload(){const i=this._layerIdx,l=this._layerClass,a=this.tile.surface.layerViewByIndex(i,l),{minLevel:n,maxLevel:r}=a.fetchLevelRange,h=this._desiredMinLevelDelta,d=this._progressiveLevelModulo+h,u=this._scaleRangeEnabled?t:()=>!0;let _=this.tile;const o=_.level;let p;const y=this._tileLayerInfo.upsampleInfo,f=y?.tile?.level??-1,c=null!=y&&f-o>=h,v=s(a),q="vector-tile-3d"===a.type?a.schemaHelper:null;for(;_&&u(_,a)&&_.level>=n;){const t=_.level,s=o-t,a=_.layerInfo[l][i];if(a.data&&s>=h){(!c||t>f)&&this._setUpsampleTile(_),a.dataInvalidated&&(p=_);break}const u=q?.getLevelRowColumn(_.lij)??_.lij;if("unavailable"!==v?.getAvailability(u[0],u[1],u[2])&&t<=r&&!a.data&&!a.dataMissing&&((!p||_.level===n||t%e===0||o-p.level<h)&&(p=_),s>=d))break;_=_.parent}if(null!=p&&o-p.level<h)if(y)p=null;else{const e=this._findAncestorWithData();if(null!=e){this._setUpsampleTile(e);p=e.layerInfo[l][i].dataInvalidated?e:null}}return p}_findAncestorWithData(){const e=this.tile.elevationLevel,t=this._desiredMinLevelDelta;let s;for(let i=this.tile;i;i=i.parent)if(i.hasLayerData(this._layerIdx,this._layerClass)){if(e-i.level>=t)return i;s=i}return s}_setUpsampleTile(e,t){this._tileLayerInfo.setUpsampleInfo(this.tile,e),this.tile.updateRenderData(this._layerClass,0,t)}get test(){}}class l extends i{constructor(){super(...arguments),this.type="none"}get _desiredMinLevelDelta(){throw a}get _progressiveLevelModulo(){throw a}dispose(){}}const a=new Error("Abstract method called on TileAgent"),n=new l;export{i as TileAgent,n as tileAgentDone};
5
+ import"../../../core/has.js";import{progressiveLoadingModulo as e}from"./TerrainConst.js";import{fallsWithinLayerView as t,getTileMapCache as s}from"./tileUtils.js";class i{get updating(){return!!this._tileRequested}init(e,t,s,i){this.tile=e,this._layerIdx=t,this._layerClass=s,this._suspended=i,this._tileLayerInfo=e.getLayerInfo(t,s),this._tileRequested=null;const l=this._findAncestorWithData();this._setUpsampleTile(l)}startLoading(){return this._requestNext()}dispose(){this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null),this.tile=null,this._tileLayerInfo=null}setSuspension(e){e!==this._suspended&&(this._suspended=e,e?this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null):this._tileLayerInfo.data||this.update())}update(){const e=this._findAncestorWithData();return this._setUpsampleTile(e),this._requestNext()}dataArrived(e,t){this._setUpsampleTile(e,t),this._tileRequested=null,e===this.tile?this.tile.updateRenderData(this._layerClass,0,t):this._requestNext()}dataMissing(){this._tileRequested=null,this._tileLayerInfo.data=null,this._requestNext()}_agentDone(){this.tile.agentDone(this._layerIdx,this._layerClass),this.dispose()}_requestNext(){if(this._suspended)return!0;const e=this._findNextDownload();if(this._tileRequested){if(e===this._tileRequested)return!0;this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null}return null!=e?e.requestLayerData(this._layerIdx,this._layerClass,this)&&(this._tileRequested=e):this._agentDone(),!!this._tileRequested}_findNextDownload(){const i=this._layerIdx,l=this._layerClass,a=this.tile.surface.layerViewByIndex(i,l),{minLevel:n,maxLevel:r}=a.dataLevelRange,h=this._desiredMinLevelDelta,d=this._progressiveLevelModulo+h,u=this._scaleRangeEnabled?t:()=>!0;let _=this.tile;const o=_.level;let p;const y=this._tileLayerInfo.upsampleInfo,f=y?.tile?.level??-1,v=null!=y&&f-o>=h,c=s(a),q="vector-tile-3d"===a.type?a.schemaHelper:null;for(;_&&u(_,a)&&_.level>=n;){const t=_.level,s=o-t,a=_.layerInfo[l][i];if(a.data&&s>=h){(!v||t>f)&&this._setUpsampleTile(_),a.dataInvalidated&&(p=_);break}const u=q?.getLevelRowColumn(_.lij)??_.lij;if("unavailable"!==c?.getAvailability(u[0],u[1],u[2])&&t<=r&&!a.data&&!a.dataMissing&&((!p||_.level===n||t%e===0||o-p.level<h)&&(p=_),s>=d))break;_=_.parent}if(null!=p&&o-p.level<h)if(y)p=null;else{const e=this._findAncestorWithData();if(null!=e){this._setUpsampleTile(e);p=e.layerInfo[l][i].dataInvalidated?e:null}}return p}_findAncestorWithData(){const e=this.tile.elevationLevel,t=this._desiredMinLevelDelta;let s;for(let i=this.tile;i;i=i.parent)if(i.hasLayerData(this._layerIdx,this._layerClass)){if(e-i.level>=t)return i;s=i}return s}_setUpsampleTile(e,t){this._tileLayerInfo.setUpsampleInfo(this.tile,e),this.tile.updateRenderData(this._layerClass,0,t)}get test(){}}class l extends i{constructor(){super(...arguments),this.type="none"}get _desiredMinLevelDelta(){throw a}get _progressiveLevelModulo(){throw a}dispose(){}}const a=new Error("Abstract method called on TileAgent"),n=new l;export{i as TileAgent,n as tileAgentDone};