@arcgis/core 4.26.0-next.20230111 → 4.26.0-next.20230113

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 (296) hide show
  1. package/arcade/ArcadeDate.js +5 -0
  2. package/arcade/Dictionary.js +1 -1
  3. package/arcade/Feature.js +1 -1
  4. package/arcade/arcadeAsyncRuntime.js +1 -1
  5. package/arcade/arcadeCompiler.js +1 -1
  6. package/arcade/arcadeRuntime.js +1 -1
  7. package/arcade/arcadeTimeUtils.js +5 -0
  8. package/arcade/executionError.js +1 -1
  9. package/arcade/featureset/actions/Adapted.js +1 -1
  10. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  11. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  12. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  13. package/arcade/featureset/support/FeatureSet.js +1 -1
  14. package/arcade/featureset/support/shared.js +1 -1
  15. package/arcade/featureset/support/sqlUtils.js +1 -1
  16. package/arcade/functions/date.js +1 -1
  17. package/arcade/functions/featuresetbase.js +1 -1
  18. package/arcade/functions/featuresetstring.js +1 -1
  19. package/arcade/functions/geomasync.js +1 -1
  20. package/arcade/functions/geometry.js +1 -1
  21. package/arcade/functions/geomsync.js +1 -1
  22. package/arcade/functions/maths.js +1 -1
  23. package/arcade/functions/string.js +1 -1
  24. package/arcade/languageUtils.js +1 -1
  25. package/arcade/treeAnalysis.js +1 -1
  26. package/arcade.js +1 -1
  27. package/assets/esri/core/workers/RemoteClient.js +1 -1
  28. package/assets/esri/core/workers/chunks/{c9477250a5d5ebdef00c.js → 01cd5a9cd4cb1f13691c.js} +1 -1
  29. package/assets/esri/core/workers/chunks/028f9a133104e78e60d2.js +1 -0
  30. package/assets/esri/core/workers/chunks/033e6ae5da6afebd993c.js +1 -0
  31. package/assets/esri/core/workers/chunks/05ab092987251d4a1242.js +1 -0
  32. package/assets/esri/core/workers/chunks/1186a56dacaf269d5271.js +1 -0
  33. package/assets/esri/core/workers/chunks/264e1c00936bcafb9a36.js +1 -0
  34. package/assets/esri/core/workers/chunks/2680392cef77d98ad097.js +1 -0
  35. package/assets/esri/core/workers/chunks/27ba1889fe9f1812389a.js +1165 -0
  36. package/assets/esri/core/workers/chunks/2dfb17fa5b6a5d239942.js +1 -0
  37. package/assets/esri/core/workers/chunks/2e3962506c353b562a88.js +1 -0
  38. package/assets/esri/core/workers/chunks/30ae4c22f6b8aab9f841.js +1 -0
  39. package/assets/esri/core/workers/chunks/329e512f210cb3e904f1.js +1 -0
  40. package/assets/esri/core/workers/chunks/3878efe67f43962b46f8.js +1 -0
  41. package/assets/esri/core/workers/chunks/3b6748f414437cc6cfde.js +1 -0
  42. package/assets/esri/core/workers/chunks/41d25407888326c91566.js +1 -0
  43. package/assets/esri/core/workers/chunks/493e2b00133682748e62.js +1 -0
  44. package/assets/esri/core/workers/chunks/4b2edcb8ef7fae4f7d28.js +1 -0
  45. package/assets/esri/core/workers/chunks/{c11d857dca43de2229fc.js → 4c085cee22ff64ce6d1f.js} +1 -1
  46. package/assets/esri/core/workers/chunks/4d8c53e961275b6a4ee1.js +1 -0
  47. package/assets/esri/core/workers/chunks/5049771eeffe208a9cb8.js +1 -0
  48. package/assets/esri/core/workers/chunks/{58d219ffd9dcc45bb0d1.js → 5191f80f2413ee92c875.js} +1 -1
  49. package/assets/esri/core/workers/chunks/5dfed65b615b33588488.js +1 -0
  50. package/assets/esri/core/workers/chunks/5e9869849d999aac5756.js +1 -0
  51. package/assets/esri/core/workers/chunks/6216cd8134703fd9d9b4.js +1 -0
  52. package/assets/esri/core/workers/chunks/62c8e43741f2d6141f00.js +1 -0
  53. package/assets/esri/core/workers/chunks/64f137358100a1c818f0.js +1 -0
  54. package/assets/esri/core/workers/chunks/6f5f81855985db7c1936.js +1 -0
  55. package/assets/esri/core/workers/chunks/6fba07833345b2d8d373.js +1 -0
  56. package/assets/esri/core/workers/chunks/{80c7726743baf9f54079.js → 7747ee359d357f6e5858.js} +1 -1
  57. package/assets/esri/core/workers/chunks/78fd609f334a29ef39dc.js +1 -0
  58. package/assets/esri/core/workers/chunks/798cd875d64182741364.js +1 -0
  59. package/assets/esri/core/workers/chunks/{9d247a46e0cfdad26273.js → 8176286f8dd055c8ae05.js} +1 -1
  60. package/assets/esri/core/workers/chunks/8530ac02c840c89cc1df.js +1 -0
  61. package/assets/esri/core/workers/chunks/8a69a9b5a04e7321740d.js +1 -0
  62. package/assets/esri/core/workers/chunks/8bd26c71e78698c16778.js +1 -0
  63. package/assets/esri/core/workers/chunks/8c12b82612f050492fef.js +1 -0
  64. package/assets/esri/core/workers/chunks/90653ef5e718bafd6960.js +1 -0
  65. package/assets/esri/core/workers/chunks/{418922fd99e733df023f.js → 9070aa0a94a9204ded1c.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{2ac0d2164a1b49e6f057.js → 94633a9bb5fa4f4ba4de.js} +1 -1
  67. package/assets/esri/core/workers/chunks/969bb94d5bdc9da114e2.js +1 -0
  68. package/assets/esri/core/workers/chunks/9785dba81a6af339e35a.js +1 -0
  69. package/assets/esri/core/workers/chunks/99e16173584702577b80.js +1 -0
  70. package/assets/esri/core/workers/chunks/9aee6f171d4fbac941d9.js +1 -0
  71. package/assets/esri/core/workers/chunks/a194f90ffe13b3d448b0.js +1 -0
  72. package/assets/esri/core/workers/chunks/a53d194e3eede703a6df.js +1 -0
  73. package/assets/esri/core/workers/chunks/a605bf8bc29099ae1b1a.js +1 -0
  74. package/assets/esri/core/workers/chunks/ba7239089a04098e3619.js +1 -0
  75. package/assets/esri/core/workers/chunks/bd2fe663a2b090b134e9.js +1 -0
  76. package/assets/esri/core/workers/chunks/c16003307aad2f84ac51.js +1 -0
  77. package/assets/esri/core/workers/chunks/c6eb6a97ecc6ed9ce713.js +1 -0
  78. package/assets/esri/core/workers/chunks/c81d898f4aef6ecacdb5.js +1 -0
  79. package/assets/esri/core/workers/chunks/cb83480d7074f6185e21.js +1 -0
  80. package/assets/esri/core/workers/chunks/cd0fa942d57a278b0a44.js +1 -0
  81. package/assets/esri/core/workers/chunks/d55332e4d7b8184fd718.js +1 -0
  82. package/assets/esri/core/workers/chunks/d6842acbfa7a39f3ca30.js +1 -0
  83. package/assets/esri/core/workers/chunks/d798bd544433e932f772.js +1 -0
  84. package/assets/esri/core/workers/chunks/e18851e915cb69f53032.js +1 -0
  85. package/assets/esri/core/workers/chunks/{54899827baea77776fc7.js → ea1054116ec842a4f813.js} +1 -1
  86. package/assets/esri/core/workers/chunks/ed1312c2627c0d7e654d.js +1 -0
  87. package/assets/esri/core/workers/chunks/f2750a7b44e8bc8b1e4c.js +1 -0
  88. package/assets/esri/themes/base/widgets/_Editor.scss +1 -11
  89. package/assets/esri/themes/base/widgets/_ItemList.scss +0 -13
  90. package/assets/esri/themes/dark/main.css +1 -1
  91. package/assets/esri/themes/light/main.css +1 -1
  92. package/assets/esri/themes/light/view.css +1 -1
  93. package/assets/esri/widgets/Sketch/t9n/Sketch_ar.json +1 -1
  94. package/assets/esri/widgets/Sketch/t9n/Sketch_bg.json +1 -1
  95. package/assets/esri/widgets/Sketch/t9n/Sketch_bs.json +1 -1
  96. package/assets/esri/widgets/Sketch/t9n/Sketch_ca.json +1 -1
  97. package/assets/esri/widgets/Sketch/t9n/Sketch_cs.json +1 -1
  98. package/assets/esri/widgets/Sketch/t9n/Sketch_da.json +1 -1
  99. package/assets/esri/widgets/Sketch/t9n/Sketch_de.json +1 -1
  100. package/assets/esri/widgets/Sketch/t9n/Sketch_el.json +1 -1
  101. package/assets/esri/widgets/Sketch/t9n/Sketch_es.json +1 -1
  102. package/assets/esri/widgets/Sketch/t9n/Sketch_et.json +1 -1
  103. package/assets/esri/widgets/Sketch/t9n/Sketch_fi.json +1 -1
  104. package/assets/esri/widgets/Sketch/t9n/Sketch_fr.json +1 -1
  105. package/assets/esri/widgets/Sketch/t9n/Sketch_he.json +1 -1
  106. package/assets/esri/widgets/Sketch/t9n/Sketch_hr.json +1 -1
  107. package/assets/esri/widgets/Sketch/t9n/Sketch_hu.json +1 -1
  108. package/assets/esri/widgets/Sketch/t9n/Sketch_id.json +1 -1
  109. package/assets/esri/widgets/Sketch/t9n/Sketch_it.json +1 -1
  110. package/assets/esri/widgets/Sketch/t9n/Sketch_ja.json +1 -1
  111. package/assets/esri/widgets/Sketch/t9n/Sketch_ko.json +1 -1
  112. package/assets/esri/widgets/Sketch/t9n/Sketch_lt.json +1 -1
  113. package/assets/esri/widgets/Sketch/t9n/Sketch_lv.json +1 -1
  114. package/assets/esri/widgets/Sketch/t9n/Sketch_nb.json +1 -1
  115. package/assets/esri/widgets/Sketch/t9n/Sketch_nl.json +1 -1
  116. package/assets/esri/widgets/Sketch/t9n/Sketch_pl.json +1 -1
  117. package/assets/esri/widgets/Sketch/t9n/Sketch_pt-BR.json +1 -1
  118. package/assets/esri/widgets/Sketch/t9n/Sketch_pt-PT.json +1 -1
  119. package/assets/esri/widgets/Sketch/t9n/Sketch_ro.json +1 -1
  120. package/assets/esri/widgets/Sketch/t9n/Sketch_ru.json +1 -1
  121. package/assets/esri/widgets/Sketch/t9n/Sketch_sk.json +1 -1
  122. package/assets/esri/widgets/Sketch/t9n/Sketch_sl.json +1 -1
  123. package/assets/esri/widgets/Sketch/t9n/Sketch_sr.json +1 -1
  124. package/assets/esri/widgets/Sketch/t9n/Sketch_sv.json +1 -1
  125. package/assets/esri/widgets/Sketch/t9n/Sketch_th.json +1 -1
  126. package/assets/esri/widgets/Sketch/t9n/Sketch_tr.json +1 -1
  127. package/assets/esri/widgets/Sketch/t9n/Sketch_uk.json +1 -1
  128. package/assets/esri/widgets/Sketch/t9n/Sketch_vi.json +1 -1
  129. package/assets/esri/widgets/Sketch/t9n/Sketch_zh-CN.json +1 -1
  130. package/assets/esri/widgets/Sketch/t9n/Sketch_zh-HK.json +1 -1
  131. package/assets/esri/widgets/Sketch/t9n/Sketch_zh-TW.json +1 -1
  132. package/chunks/ComponentShader.glsl.js +1 -1
  133. package/chunks/Path.glsl.js +1 -1
  134. package/chunks/Terrain.glsl.js +1 -1
  135. package/chunks/languageUtils.js +1 -1
  136. package/geometry/support/MeshTexture.js +1 -1
  137. package/geometry/support/aaBoundingBox.js +1 -1
  138. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  139. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  140. package/interfaces.d.ts +1400 -1314
  141. package/layers/ImageryTileLayer.js +1 -1
  142. package/layers/VoxelWasmPerSceneView.js +1 -1
  143. package/layers/graphics/data/FeatureStore.js +1 -1
  144. package/layers/graphics/data/QueryEngine.js +1 -1
  145. package/layers/graphics/data/timeSupport.js +1 -1
  146. package/layers/graphics/featureConversionUtils.js +1 -1
  147. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  148. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  149. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  150. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  151. package/layers/mixins/ArcGISImageService.js +1 -1
  152. package/layers/mixins/ImageryTileMixin.js +1 -1
  153. package/layers/support/layerOriginUtils.js +1 -1
  154. package/layers/support/rasterFormats/JpgPlus.js +1 -1
  155. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  156. package/layers/support/rasterFunctions/ConvolutionFunction.js +1 -1
  157. package/layers/support/rasterFunctions/ConvolutionFunctionArguments.js +1 -1
  158. package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
  159. package/layers/support/rasterFunctions/ExtractBandFunctionArguments.js +1 -1
  160. package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
  161. package/layers/support/rasterFunctions/NDVIFunctionArguments.js +1 -1
  162. package/layers/support/rasterFunctions/SlopeFunctionArguments.js +1 -1
  163. package/layers/support/rasterFunctions/StatisticsHistogramFunction.js +5 -0
  164. package/layers/support/rasterFunctions/{StatisticsHistogramsFunctionArguments.js → StatisticsHistogramFunctionArguments.js} +1 -1
  165. package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
  166. package/package.json +1 -1
  167. package/rest/imageService.js +1 -1
  168. package/rest/support/BaseImageMeasureResult.d.ts +4 -0
  169. package/rest/support/ImageAreaParameters.d.ts +4 -0
  170. package/rest/support/{ImageMeasureAreaAndPerimeterParameters.js → ImageAreaParameters.js} +1 -1
  171. package/rest/support/ImageAreaResult.d.ts +4 -0
  172. package/rest/support/{ImageMeasureAreaAndPerimeterResult.js → ImageAreaResult.js} +1 -1
  173. package/rest/support/ImageDistanceParameters.d.ts +4 -0
  174. package/rest/support/{ImageMeasureDistanceAndAngleParameters.js → ImageDistanceParameters.js} +1 -1
  175. package/rest/support/ImageDistanceResult.d.ts +4 -0
  176. package/rest/support/ImageDistanceResult.js +5 -0
  177. package/rest/support/ImageHeightParameters.d.ts +4 -0
  178. package/rest/support/{ImageMeasureHeightParameters.js → ImageHeightParameters.js} +1 -1
  179. package/rest/support/ImageHeightResult.d.ts +4 -0
  180. package/rest/support/{ImageMeasureHeightResult.js → ImageHeightResult.js} +1 -1
  181. package/rest/support/ImagePointParameters.d.ts +4 -0
  182. package/rest/support/{ImageMeasurePointParameters.js → ImagePointParameters.js} +1 -1
  183. package/rest/support/ImagePointResult.d.ts +4 -0
  184. package/rest/support/{ImageMeasurePointResult.js → ImagePointResult.js} +1 -1
  185. package/support/arcadeUtils.js +1 -1
  186. package/support/revision.js +1 -1
  187. package/time/timeReferenceUtils.js +1 -1
  188. package/views/2d/engine/webgl/Overlay.js +1 -1
  189. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  190. package/views/2d/layers/features/FeatureStore2D.js +1 -1
  191. package/views/2d/layers/features/Pipeline.js +1 -1
  192. package/views/2d/layers/features/support/BinStore.js +1 -1
  193. package/views/2d/layers/features/support/ClusterStore.js +1 -1
  194. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  195. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  196. package/views/3d/glTF/internal/Resource.js +1 -1
  197. package/views/3d/glTF/internal/resourceUtils.js +5 -0
  198. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  199. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  200. package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
  201. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  202. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  203. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  204. package/views/3d/layers/graphics/Labeler.js +1 -1
  205. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  206. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  207. package/views/3d/layers/i3s/I3SQueryFeatureStore.js +1 -1
  208. package/views/3d/state/ViewState.js +1 -1
  209. package/views/3d/state/ViewStateManager.js +1 -1
  210. package/views/3d/terrain/Overlay.js +1 -1
  211. package/views/3d/terrain/OverlayManager.js +1 -1
  212. package/views/3d/terrain/TerrainRenderer.js +1 -1
  213. package/views/3d/terrain/TerrainSurface.js +1 -1
  214. package/views/3d/terrain/TileRenderer.js +1 -1
  215. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  216. package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +1 -1
  217. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  218. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +1 -1
  219. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js +1 -1
  220. package/views/3d/webgl-engine/lib/AnimationTimeStep.js +5 -0
  221. package/views/3d/webgl-engine/lib/AnimationTimer.js +1 -1
  222. package/views/3d/webgl-engine/lib/GLMaterial.js +1 -1
  223. package/views/3d/webgl-engine/lib/Material.js +1 -1
  224. package/views/3d/webgl-engine/lib/RenderFeature.js +5 -0
  225. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  226. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  227. package/views/3d/webgl-engine/lib/basicInterfaces.js +1 -1
  228. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  229. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  230. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  231. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  232. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  233. package/views/draw/support/layerUtils.js +1 -1
  234. package/views/webgl/RenderingContext.js +1 -1
  235. package/views/webgl/Texture.js +1 -1
  236. package/widgets/Editor/EditorViewModel.js +1 -1
  237. package/widgets/Editor.js +1 -1
  238. package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
  239. package/widgets/FeatureTemplates/ItemList.js +1 -1
  240. package/widgets/FeatureTemplates/TemplateItem.js +1 -1
  241. package/widgets/FeatureTemplates/TemplateItemGroup.js +1 -1
  242. package/widgets/FeatureTemplates.js +1 -1
  243. package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
  244. package/widgets/support/decorators/accessibleHandler.js +1 -1
  245. package/assets/esri/core/workers/chunks/038dc3f9ef06ef3c960c.js +0 -1
  246. package/assets/esri/core/workers/chunks/078a0b134210167b629d.js +0 -1
  247. package/assets/esri/core/workers/chunks/080a4be417be4943f6a0.js +0 -1
  248. package/assets/esri/core/workers/chunks/0877bab7c03a1de2e713.js +0 -1
  249. package/assets/esri/core/workers/chunks/0c9200ab19fd2f56f87f.js +0 -1
  250. package/assets/esri/core/workers/chunks/1cbffa96ea6683e5f3ec.js +0 -1
  251. package/assets/esri/core/workers/chunks/1f742c3b11c76814fa4d.js +0 -1
  252. package/assets/esri/core/workers/chunks/2eb2d49c549e53934b8b.js +0 -1
  253. package/assets/esri/core/workers/chunks/332494b96a47b378f4e0.js +0 -1
  254. package/assets/esri/core/workers/chunks/3326536d183a858a2a4d.js +0 -1
  255. package/assets/esri/core/workers/chunks/3f4fc8379fc11bc293cc.js +0 -1
  256. package/assets/esri/core/workers/chunks/43fecd621cd043f64828.js +0 -1165
  257. package/assets/esri/core/workers/chunks/47b0b660f5412097fe26.js +0 -1
  258. package/assets/esri/core/workers/chunks/4c0d7a074083aa9614bb.js +0 -1
  259. package/assets/esri/core/workers/chunks/594d7e871b648d5c9662.js +0 -1
  260. package/assets/esri/core/workers/chunks/680b90ac98e8d1ac0e33.js +0 -1
  261. package/assets/esri/core/workers/chunks/6b589f47cb4731df1639.js +0 -1
  262. package/assets/esri/core/workers/chunks/72557c4b1582aa18ad4d.js +0 -1
  263. package/assets/esri/core/workers/chunks/72b490ad371e0c2264f6.js +0 -1
  264. package/assets/esri/core/workers/chunks/75ce17cf13aab0440572.js +0 -1
  265. package/assets/esri/core/workers/chunks/75f4e884a1a0aedc0afd.js +0 -1
  266. package/assets/esri/core/workers/chunks/7b9ab3fb378172831c14.js +0 -1
  267. package/assets/esri/core/workers/chunks/7bef95b168303bdc4bf1.js +0 -1
  268. package/assets/esri/core/workers/chunks/803492088780e18de801.js +0 -1
  269. package/assets/esri/core/workers/chunks/89003e387684af5ebeac.js +0 -1
  270. package/assets/esri/core/workers/chunks/8f93026764a0cce0901b.js +0 -1
  271. package/assets/esri/core/workers/chunks/98350b6b95da62ef5f12.js +0 -1
  272. package/assets/esri/core/workers/chunks/a9cae0d386aa9c00f744.js +0 -1
  273. package/assets/esri/core/workers/chunks/ad65c24558098f21bbf3.js +0 -1
  274. package/assets/esri/core/workers/chunks/aef90ee3f0979a7acb38.js +0 -1
  275. package/assets/esri/core/workers/chunks/b68c7754b0220b194ecf.js +0 -1
  276. package/assets/esri/core/workers/chunks/c012317f045a74fdd79d.js +0 -1
  277. package/assets/esri/core/workers/chunks/cb42675e5b1c41634c63.js +0 -1
  278. package/assets/esri/core/workers/chunks/cb901033dd15b3b72025.js +0 -1
  279. package/assets/esri/core/workers/chunks/d398b6b8a6b0a95247de.js +0 -1
  280. package/assets/esri/core/workers/chunks/d447ebc944a9867f5a99.js +0 -1
  281. package/assets/esri/core/workers/chunks/daaabed988b6ea866350.js +0 -1
  282. package/assets/esri/core/workers/chunks/e048641971aef9dd4da9.js +0 -1
  283. package/assets/esri/core/workers/chunks/e3fd383aee378cbb0dae.js +0 -1
  284. package/assets/esri/core/workers/chunks/e967ffca641947212992.js +0 -1
  285. package/assets/esri/core/workers/chunks/e9c81eee503c1b112bad.js +0 -1
  286. package/assets/esri/core/workers/chunks/ea6cf948fe2de0242308.js +0 -1
  287. package/assets/esri/core/workers/chunks/ed5e71b45dfefcbb2da4.js +0 -1
  288. package/assets/esri/core/workers/chunks/ee50d5d0afe9bdccc84d.js +0 -1
  289. package/assets/esri/core/workers/chunks/ee91401507833875facc.js +0 -1
  290. package/assets/esri/core/workers/chunks/f7d40dd78ef116f5793b.js +0 -1
  291. package/assets/esri/core/workers/chunks/f8ab6e354834b9c0e857.js +0 -1
  292. package/assets/esri/core/workers/chunks/faea681c279486b7a5e7.js +0 -1
  293. package/layers/support/rasterFunctions/StatisticsHistogramsFunction.js +0 -5
  294. package/rest/support/ImageMeasureDistanceAndAngleResult.js +0 -5
  295. package/views/3d/support/animationUtils.js +0 -5
  296. package/views/3d/webgl-engine/lib/RenderStateFeature.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{nextHighestPowerOfTwo as e}from"../../../core/mathUtils.js";import{create as t,offset as r,copy as s}from"../../../geometry/support/aaBoundingRect.js";import{RenderTargetType as i,OverlayIndex as a}from"./interfaces.js";import{ValidationState as o}from"../webgl-engine/lib/basicInterfaces.js";import{fromValues as n}from"../webgl-engine/lib/LocalOriginFactory.js";var h;!function(e){e[e.None=0]="None",e[e.ColorAndWater=1]="ColorAndWater",e[e.Highlight=2]="Highlight",e[e.Occluded=3]="Occluded",e[e.ObjectAndLayerIdColor=4]="ObjectAndLayerIdColor"}(h||(h={}));class g{get extent(){return this._extent}constructor(e,r){this.index=e,this.renderTargets=r,this._extent=t(),this.resolution=0,this.renderLocalOrigin=n(0,0,0,"O"),this.pixelRatio=1,this.mapUnitsPerPixel=1,this.canvasGeometries=new d,this.hasDrapedFeatureSource=!1,this.hasDrapedRasterSource=!1,this.hasTargetWithoutRasterImage=!1,this.index=e,this.validTargets=new Array(r.renderTargets.length).fill(!1)}getValidTexture(e){return this.validTargets[e]?this.renderTargets.getTarget(e).getTexture():null}get _needsColorWithoutRasterImage(){return this.hasDrapedRasterSource&&this.hasDrapedFeatureSource&&this.hasTargetWithoutRasterImage}getColorTexture(e){const t=e===h.ColorAndWater?this.renderTargets.getTarget(i.Color):e===h.Highlight?this.renderTargets.getTarget(i.Highlight):e===h.ObjectAndLayerIdColor?this.renderTargets.getTarget(i.ObjectAndLayerIdColor):this.renderTargets.getTarget(i.Occluded);return t?t.getTexture():null}getColorTextureNoRasterImage(){return this._needsColorWithoutRasterImage?this.getValidTexture(i.ColorNoRasterImage):this.hasDrapedFeatureSource?this.getValidTexture(i.Color):null}getNormalTexture(e){const t=e===h.ColorAndWater?this.renderTargets.getTarget(i.Water):null;return t?t.getTexture():null}draw(e,t){const r=this.computeRenderTargetValidityBitfield();for(const s of this.renderTargets.renderTargets)s.type!==i.ColorNoRasterImage||this._needsColorWithoutRasterImage?this.validTargets[s.type]=e.drawTarget(this,s,t):this.validTargets[s.type]=!1;return r^this.computeRenderTargetValidityBitfield()?o.CHANGED:o.UNCHANGED}computeRenderTargetValidityBitfield(){const e=this.validTargets;return+e[i.Color]|+e[i.ColorNoRasterImage]<<1|+e[i.Highlight]<<2|+e[i.Water]<<3|+e[i.Occluded]<<4}setupGeometryViewsCyclical(e){this.setupGeometryViewsDirect();const t=.001*e.range;if(this._extent[0]-t<=e.min){const t=this.canvasGeometries.extents[this.canvasGeometries.numViews++];r(this._extent,e.range,0,t)}if(this._extent[2]+t>=e.max){const t=this.canvasGeometries.extents[this.canvasGeometries.numViews++];r(this._extent,-e.range,0,t)}}setupGeometryViewsDirect(){this.canvasGeometries.numViews=1,s(this.canvasGeometries.extents[0],this._extent)}hasSomeSizedView(){for(let e=0;e<this.canvasGeometries.numViews;e++){const t=this.canvasGeometries.extents[e];if(t[0]!==t[2]&&t[1]!==t[3])return!0}return!1}applyViewport(e){e.setViewport(this.index===a.INNER?0:this.resolution,0,this.resolution,this.resolution)}}function l(t,r,s){return Math.min(e(Math.max(t,r)+256),s)}class d{constructor(){this.extents=[t(),t(),t()],this.numViews=0}}export{g as Overlay,h as OverlaySource,l as computeOverlayResolution};
5
+ import{create as e,offset as t,copy as r}from"../../../geometry/support/aaBoundingRect.js";import{RenderTargetType as s,OverlayIndex as i}from"./interfaces.js";import{ValidationState as a}from"../webgl-engine/lib/basicInterfaces.js";import{fromValues as o}from"../webgl-engine/lib/LocalOriginFactory.js";var n;!function(e){e[e.None=0]="None",e[e.ColorAndWater=1]="ColorAndWater",e[e.Highlight=2]="Highlight",e[e.Occluded=3]="Occluded",e[e.ObjectAndLayerIdColor=4]="ObjectAndLayerIdColor"}(n||(n={}));class h{get extent(){return this._extent}constructor(t,r){this.index=t,this.renderTargets=r,this._extent=e(),this.resolution=0,this.renderLocalOrigin=o(0,0,0,"O"),this.pixelRatio=1,this.mapUnitsPerPixel=1,this.canvasGeometries=new g,this.hasDrapedFeatureSource=!1,this.hasDrapedRasterSource=!1,this.hasTargetWithoutRasterImage=!1,this.index=t,this.validTargets=new Array(r.renderTargets.length).fill(!1)}getValidTexture(e){return this.validTargets[e]?this.renderTargets.getTarget(e).getTexture():null}get _needsColorWithoutRasterImage(){return this.hasDrapedRasterSource&&this.hasDrapedFeatureSource&&this.hasTargetWithoutRasterImage}getColorTexture(e){const t=e===n.ColorAndWater?this.renderTargets.getTarget(s.Color):e===n.Highlight?this.renderTargets.getTarget(s.Highlight):e===n.ObjectAndLayerIdColor?this.renderTargets.getTarget(s.ObjectAndLayerIdColor):this.renderTargets.getTarget(s.Occluded);return t?t.getTexture():null}getColorTextureNoRasterImage(){return this._needsColorWithoutRasterImage?this.getValidTexture(s.ColorNoRasterImage):this.hasDrapedFeatureSource?this.getValidTexture(s.Color):null}getNormalTexture(e){const t=e===n.ColorAndWater?this.renderTargets.getTarget(s.Water):null;return t?t.getTexture():null}draw(e,t){const r=this.computeRenderTargetValidityBitfield();for(const i of this.renderTargets.renderTargets)i.type!==s.ColorNoRasterImage||this._needsColorWithoutRasterImage?this.validTargets[i.type]=e.drawTarget(this,i,t):this.validTargets[i.type]=!1;return r^this.computeRenderTargetValidityBitfield()?a.CHANGED:a.UNCHANGED}computeRenderTargetValidityBitfield(){const e=this.validTargets;return+e[s.Color]|+e[s.ColorNoRasterImage]<<1|+e[s.Highlight]<<2|+e[s.Water]<<3|+e[s.Occluded]<<4}setupGeometryViewsCyclical(e){this.setupGeometryViewsDirect();const r=.001*e.range;if(this._extent[0]-r<=e.min){const r=this.canvasGeometries.extents[this.canvasGeometries.numViews++];t(this._extent,e.range,0,r)}if(this._extent[2]+r>=e.max){const r=this.canvasGeometries.extents[this.canvasGeometries.numViews++];t(this._extent,-e.range,0,r)}}setupGeometryViewsDirect(){this.canvasGeometries.numViews=1,r(this.canvasGeometries.extents[0],this._extent)}hasSomeSizedView(){for(let e=0;e<this.canvasGeometries.numViews;e++){const t=this.canvasGeometries.extents[e];if(t[0]!==t[2]&&t[1]!==t[3])return!0}return!1}applyViewport(e){e.setViewport(this.index===i.INNER?0:this.resolution,0,this.resolution,this.resolution)}}class g{constructor(){this.extents=[e(),e(),e()],this.numViews=0}}export{h as Overlay,n as OverlaySource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{Cyclical as r,cyclicalPI as s}from"../../../core/Cyclical.js";import i from"../../../core/Handles.js";import has from"../../../core/has.js";import{clamp as a,deg2rad as n}from"../../../core/mathUtils.js";import{isSome as o,destroyMaybe as h,unwrapOr as l,isNone as c,unwrap as d}from"../../../core/maybe.js";import{watch as u,sync as p}from"../../../core/reactiveUtils.js";import{Milliseconds as _}from"../../../core/time.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import{a as g}from"../../../chunks/vec2.js";import{a as f,b as v,E as R,c as T,i as w}from"../../../chunks/vec3.js";import{c as O}from"../../../chunks/vec3f64.js";import{t as D,b as x,a as S}from"../../../chunks/vec4.js";import{c as E,f as P}from"../../../chunks/vec4f64.js";import{getReferenceEllipsoid as C}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as U}from"../../../geometry/projection.js";import{create as M,width as I,copy as N,center as j,height as b,intersection as A,contains as G,intersects as L,offset as H}from"../../../geometry/support/aaBoundingRect.js";import{create as k,wrap as q}from"../../../geometry/support/ray.js";import{b as B,e as F,t as V}from"../../../chunks/sphere.js";import{angleAroundAxis as W}from"../../../geometry/support/vector.js";import{y2lat as Y}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as z}from"../state/utils/viewUtils.js";import X from"../support/debugFlags.js";import{PointGraphics as K}from"../support/debugUtils.js";import{OverlayIndex as Z}from"./interfaces.js";import{computeOverlayResolution as J}from"./Overlay.js";import{OverlayRenderer as Q}from"./OverlayRenderer.js";import{RenderRequestType as $,ValidationState as ee}from"../webgl-engine/lib/basicInterfaces.js";import{newIntersector as te}from"../webgl-engine/lib/Intersector.js";import{fromValues as re}from"../webgl-engine/lib/LocalOriginFactory.js";import{SortedRenderGeometryRenderer as se}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{removeLoadedShaderModules as ie}from"../webgl-engine/parts/requireUtils.js";import{TaskPriority as ae,noBudget as ne,Task as oe}from"../../support/Scheduler.js";const he=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let le,ce=class extends t{get running(){return this._placementDirty&&(this._drapeSources.size>0||this._view.graphics.length>0||X.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.surface.ready}get _isSpherical(){return this._view.state.isGlobal}get _worldToPCSRatio(){return o(this._spatialReference)&&this._spatialReference.isGeographic&&!this._view.state.isLocal?C(this._spatialReference).metersPerDegree:1}get _view(){return this.surface.view}get _hidpiContent(){return this._view.state.hidpiContent}get suspended(){return this.surface.suspended}get updating(){return this.running||this.renderer.updating||this._contentUpdated}get hasHighlights(){return this.renderer.hasHighlights}get rendersOccluded(){return this.renderer.rendersOccluded}constructor(e){super(e),this._handles=new i,this._spatialReference=null,this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._hasUnusedRenderTargets=!1,this._longitudeCyclical=null,this._latestOriginId=0,this._maxResolution=has("esri-mobile")?2048:4096,this._animationTimeLast=0}initialize(){const e=this._view;this.renderer=new Q({view:e,worldToPCSRatio:this._worldToPCSRatio,spatialReference:this._spatialReference}),this._groundIntersector=te(this._view.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this._handles.add([this.renderer.events.on("has-highlights",(()=>{this.setDrawTexturesDirty(),this.notifyChange("hasHighlights")})),this.renderer.events.on("has-water",(t=>e._stage?.renderer.setParameters({hasOverlayWater:t}))),this.renderer.events.on("renders-occluded",(()=>{this.setDrawTexturesDirty(),this.notifyChange("rendersOccluded")})),this.renderer.events.on("content-changed",(()=>this.setDrawTexturesDirty())),this.renderer.events.on("textures-disposed",(()=>this.updateOverlayResult())),u((()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location]),(()=>this.setPlacementDirty())),u((()=>[e.state?.pixelRatio,e.state?.hidpiContent]),(()=>this.setPlacementDirty()),p),this.surface.on("elevation-change",(()=>this.setPlacementDirty())),e.on("resize",(()=>this.setPlacementDirty())),e.resourceController.scheduler.registerTask(ae.OVERLAY,this),e._stage.renderView.events.on("force-camera-for-screenshot",(e=>{this._updateOverlays(ne,e,$.BACKGROUND),this.renderer.hasOverlays&&this._drawOverlayTextures(this.renderer.overlays,$.BACKGROUND,e)}))]),e._stage?.renderer.setParameters({renderOverlay:e=>{this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.hasOverlays&&(this._dispatchAnimationUpdate(e),this._drawOverlayTextures(this.renderer.overlays,$.UPDATE)),this._hasUnusedRenderTargets&&this._collectUnusedRenderTargetMemory()}})}destroy(){this._handles=h(this._handles),o(le)&&(le.hide(),le=null)}get hasOverlays(){return this.renderer.hasOverlays}setSpatialReference(e){this._spatialReference=e,this.renderer.spatialReference=e,this._longitudeCyclical=null;const t=this._view.renderSpatialReference;o(e)&&o(t)?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this._longitudeCyclical=e.isWebMercator?new r(-20037508.342787,20037508.342787):new r(-180,180),this.renderer.longitudeCyclical=this._longitudeCyclical),this.renderer&&(this.renderer.worldToPCSRatio=this._worldToPCSRatio)):this.renderer.disposeOverlays()}get gpuMemoryUsage(){return this.renderer.gpuMemoryUsage}registerDrapeSource(e,t,r){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const s=this.renderer.createDrapeSourceRenderer(e,t,r);return this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("running"),s}registerGeometryDrapeSource(e){return this.registerDrapeSource(e,se)}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&o(e.setDrapingExtent)&&o(this._spatialReference)&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("running"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}updateOverlayResult(){this._view._stage?.renderer.setParameters({overlays:this.renderer.overlays})}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.setDrawTexturesDirty()}setPlacementDirty(){this._placementDirty=!0}runTask(e){return this._updateOverlays(e,this._view.state.contentCamera,$.UPDATE)}_updateOverlays(e,t,r){if(!this._spatialReference)return oe.YIELD;const s=J(t.fullWidth,t.fullHeight,this._maxResolution);this._computeOverlayExtents(t,s,_e);const i=I(_e.inner)/I(_e.outer);this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const a=this._updateOverlay(Z.INNER,_e.inner,s,1*_e.pixelRatioAdjustment,_e.mapUnitsPerPixel),n=this._updateOverlay(Z.OUTER,_e.outer,s,i*_e.pixelRatioAdjustment,_e.mapUnitsPerPixel);a!==fe.EXTENT&&n!==fe.EXTENT||(this._drapeSources.forEach((e=>this._updateDrapeSourceExtent(e))),this.surface.updateTileOverlayParams(r)),a===fe.NONE&&n===fe.NONE||this.setDrawTexturesDirty(),this._placementDirty=!1,e.madeProgress()}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return fe.NONE;const a=this.renderer.overlays[e],n=a.mapUnitsPerPixel;if(a.mapUnitsPerPixel=i,a.pixelRatio=s,de(t,a.extent)&&r===a.resolution)return n===i?fe.NONE:fe.RERENDER_ONLY;N(a.extent,t),a.resolution=r;const o=j(a.extent);return a.renderLocalOrigin=re(o[0],o[1],0,"OV_"+this._latestOriginId++),fe.EXTENT}setTileParameters(e){const t=e.renderData.overlay;if(this.renderer.overlays.length>0){const r=this.renderer.overlays[Z.INNER],s=this.renderer.overlays[Z.OUTER],i=e.extent;this._rectInsideRect(r.extent,i)||this._rectanglesOverlap(i,r.extent)||this._rectanglesOverlap(i,s.extent)?(this._setTileOverlayData(i,Z.INNER,t),this._setTileOverlayData(i,Z.OUTER,t)):(this._clearTileOverlayData(Z.INNER,t),this._clearTileOverlayData(Z.OUTER,t))}else this._clearTileOverlayData(Z.INNER,t),this._clearTileOverlayData(Z.OUTER,t)}overlayPixelSizeInMapUnits(e){if(0===this.renderer.overlays.length)return 0;const t=this.renderer.overlays[Z.INNER],r=this.renderer.overlays[Z.OUTER],s=this._pointIsInExtent(e,t.extent)?t:r;return(s.extent[2]-s.extent[0])/s.resolution}_setTileOverlayData(e,t,r){if(0===this.renderer.overlays.length)return;const s=this.renderer.overlays[t].extent,i=I(s),a=b(s);let n=e[0];if(this._longitudeCyclical){n=this._longitudeCyclical.minimalMonotonic(s[0],n);const t=this._longitudeCyclical.minimalMonotonic(s[0],e[2]);n>t&&(n=t-(e[2]-e[0]))}r.setScale(t,I(e)/i,b(e)/a),r.setOffset(t,(n-s[0])/i,(e[1]-s[1])/a)}_clearTileOverlayData(e,t){t.setScale(e,-1,-1),t.setOffset(e,-1,-1)}async reloadShaders(){ie(),await this.renderer.reloadShaders(),this.setDrawTexturesDirty(),this.runTask(ne)}_dispatchAnimationUpdate(e){const t=_(e-this._animationTimeLast);e=l(this._view.state.forcedAnimationTime,e),(t>=this.surface.view._stage.renderer.animationTimestep||o(this._view.state.forcedAnimationTime)||this._drawTexturesDirty||this._drawTexturesAnimateDirty)&&(this.renderer.updateAnimation({time:e,camera:this._view.state.camera})&&(this._drawTexturesAnimateDirty=!0),this._animationTimeLast=e)}setDrawTexturesDirty(){this.renderer.hasOverlays?(this._contentUpdated=!0,this._drawTexturesDirty=!0,this._view._stage.renderView.requestRender()):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s){const i=this._view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,ge,t,r);if(c(i))return!1;const a=i.origin,n=f(pe,i.origin,i.direction);return this._groundIntersector.reset(a,n,e),this._groundIntersector.intersect([]),this._view.basemapTerrain.intersect(this._groundIntersector,null,a,n),this._groundIntersector.results.min.getIntersectionPoint(s)}_findHorizonBasedPointOfInterest(e,t){let r=.5;const i=.55,n=this._view.renderCoordsHelper.getAltitude(e.eye),o=this._view.pointsOfInterest.centerOnSurfaceFrequent,h=1e-5,l=a(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:n+h,e.aboveGround?n-h:1/0),c=e.aboveGround;if("global"===this._view.viewingMode){const t=pe;B(F(V,C(this._view.spatialReference).radius+l),q(e.eye,e.viewForward),t),v(t,t,e.eye);const a=s.normalize(W(e.viewForward,t,e.viewRight))/e.fovY+.5,n=a<=0||a>=1?.5:i;r=c?n*a:a+n*(1-a)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),s=Math.tan(t),n=P(0,s,1,0),o=D(n,n,e.projectionMatrix)[1],h=a(.5+.5*o,0,1);r=1===h||0===h?.5:c?h*i:1-(1-h)*i}return!!this._intersectGroundFromView(e,.5,r,t)&&R(t,e.eye)<o.distance*o.distance}_computeOverlayExtents(e,t,r){const s=this._view.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,i=O();this._findHorizonBasedPointOfInterest(e,i)||T(i,s);const a=Math.max(.1,w(e.eye,i)),h=z(this._view.renderCoordsHelper,s,e.eye),l=Math.PI/2-Math.abs(h-Math.PI/2);X.OVERLAY_SHOW_CENTER?(c(le)&&(le=new K(this._view.graphics,"red")),le.show(i,this._renderSR)):o(le)&&le.hide(),this._overlaySREqualsRenderSR||U(i,this._renderSR,i,this._spatialReference);const u=this.surface.extent,p=!this._isSpherical&&o(this._spatialReference)&&this._spatialReference.isGeographic,_=p&&o(this._spatialReference)?1/C(this._spatialReference).metersPerDegree:1,m=(this._hidpiContent?e.perRenderPixelRatio:e.perScreenPixelRatio)*a*_;r.mapUnitsPerPixel=m/this._worldToPCSRatio;let y=t*m/2,f=!1,v=p?90:1/0;this._isSpherical&&o(u)&&o(this._spatialReference)&&(this._spatialReference.isWebMercator?(y/=Math.cos(Y(i[1])),v=u[3]):(f=!0,y/=C(this._spatialReference).metersPerDegree,v=90),y>=v&&(y=v,i[1]=0,this._spatialReference.isWebMercator&&(i[0]=0)));let R=1;f&&(R=1/Math.max(.2,Math.cos(Math.abs(n(i[1])))),y*R>180&&(R=180/y),r.mapUnitsPerPixel*=R);const D=Math.log(2)/12;y=Math.exp(Math.round(Math.log(y)/D)*D);const E=y*R,P=32,M=.5*t/(P*E),j=.5*t/(P*y);i[0]=Math.round(i[0]*M)/M,i[1]=Math.round(i[1]*j)/j;const b=r.inner;b[0]=i[0]-E,b[1]=i[1]-y,b[2]=i[0]+E,b[3]=i[1]+y,this._isSpherical&&this._shiftExtentToFitBounds(b,1/0,v);const L=r.outer;if(6*E>I(u))N(L,d(u));else if(l<=.25*Math.PI)L[0]=b[0]-E,L[1]=b[1]-y,L[2]=b[2]+E,L[3]=b[3]+y;else{U(e.eye,this._renderSR,pe,this._spatialReference),g(ue,i,pe);let t=-Math.atan2(ue[1],ue[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));x(ue,he[r],2*y),ue[0]*=R,ue[2]*=R,S(L,b,ue)}if(this._isSpherical)L[0]=this._longitudeCyclical.clamp(L[0]),L[2]=this._longitudeCyclical.clamp(L[2]),L[1]=Math.max(L[1],-v),L[3]=Math.min(L[3],v);else{const e=A(b,u,me),t=A(L,u,ye);G(e,t)&&(L[2]=L[0],L[3]=L[1])}const H=Math.abs(b[2]-b[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,H),r.pixelRatioAdjustment=r.mapUnitsPerPixel/H}_drawOverlayTextures(e,t,r=this._view.state.camera){if(0===e.length||!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return;const s=this._drawTexturesDirty;this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1;const i=this._drawOverlay(e[Z.INNER],r),a=this._drawOverlay(e[Z.OUTER],r);i!==ee.CHANGED&&a!==ee.CHANGED||this.surface.updateTileOverlayParams($.UPDATE),this._collectUnusedRenderTargetMemory(),this.updateOverlayResult(),s?(this.surface.requestRender(t),t===$.UPDATE&&this.surface.requestUpdate()):this.surface.requestRender($.BACKGROUND)}_drawOverlay(e,t){return this._longitudeCyclical?e.setupGeometryViewsCyclical(this._longitudeCyclical):e.setupGeometryViewsDirect(),e.draw(this.renderer,this._hidpiContent?t.pixelRatio:1)}_collectUnusedRenderTargetMemory(){if(this._hasUnusedRenderTargets=!1,this.renderer.hasOverlays){const e=performance.now();this._hasUnusedRenderTargets=this.renderer.collectUnusedRenderTargetMemory(e)}}_rectanglesOverlap(e,t){return!c(e)&&(this._longitudeCyclical?(this._longitudeCyclical.contains(t[0],t[2],e[0])||this._longitudeCyclical.contains(t[0],t[2],e[2])||this._longitudeCyclical.contains(e[0],e[2],t[0]))&&!(e[1]>t[3]||e[3]<t[1]):L(e,t))}_rectInsideRect(e,t){return!c(t)&&(this._longitudeCyclical?this._longitudeCyclical.contains(e[0],e[2],t[0])&&this._longitudeCyclical.contains(e[0],e[2],t[2])&&t[1]>e[1]&&t[3]<e[3]:G(e,t))}_pointIsInExtent(e,t){if(this._longitudeCyclical)return this._longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),H(e,s,i)}get test(){return{renderer:this.renderer,update:()=>this.runTask(ne)}}};function de(e,t){const r=1e-5,s=X.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([m()],ce.prototype,"_spatialReference",void 0),e([m({readOnly:!0})],ce.prototype,"running",null),e([m()],ce.prototype,"_placementDirty",void 0),e([m()],ce.prototype,"_contentUpdated",void 0),e([m()],ce.prototype,"_isSpherical",null),e([m()],ce.prototype,"_worldToPCSRatio",null),e([m({autoDestroy:!0})],ce.prototype,"renderer",void 0),e([m({constructOnly:!0})],ce.prototype,"surface",void 0),e([m()],ce.prototype,"suspended",null),e([m()],ce.prototype,"updating",null),e([m({type:Boolean})],ce.prototype,"hasHighlights",null),e([m({type:Boolean})],ce.prototype,"rendersOccluded",null),ce=e([y("esri.views.3d.terrain.OverlayManager")],ce);const ue=E(),pe=O(),_e={inner:M(),outer:M(),mapUnitsPerPixel:0,pixelRatioAdjustment:1},me=M(),ye=M(),ge=k();var fe;!function(e){e[e.NONE=0]="NONE",e[e.EXTENT=1]="EXTENT",e[e.RERENDER_ONLY=2]="RERENDER_ONLY"}(fe||(fe={}));export{ce as OverlayManager};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{Cyclical as r,cyclicalPI as s}from"../../../core/Cyclical.js";import i from"../../../core/Handles.js";import has from"../../../core/has.js";import{nextHighestPowerOfTwo as a,clamp as n,deg2rad as o}from"../../../core/mathUtils.js";import{isSome as l,destroyMaybe as h,isNone as c,unwrap as d}from"../../../core/maybe.js";import{watch as u,sync as p}from"../../../core/reactiveUtils.js";import{Milliseconds as _}from"../../../core/time.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import{a as g}from"../../../chunks/vec2.js";import{a as f,b as v,E as R,c as T,i as w}from"../../../chunks/vec3.js";import{c as O}from"../../../chunks/vec3f64.js";import{t as D,b as x,a as S}from"../../../chunks/vec4.js";import{c as E,f as P}from"../../../chunks/vec4f64.js";import{getReferenceEllipsoid as M}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as U}from"../../../geometry/projection.js";import{create as C,width as I,copy as N,center as j,height as b,intersection as A,contains as G,intersects as L,offset as H}from"../../../geometry/support/aaBoundingRect.js";import{create as k,wrap as q}from"../../../geometry/support/ray.js";import{b as B,e as F,t as V}from"../../../chunks/sphere.js";import{angleAroundAxis as W}from"../../../geometry/support/vector.js";import{y2lat as Y}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as z}from"../state/utils/viewUtils.js";import X from"../support/debugFlags.js";import{PointGraphics as K}from"../support/debugUtils.js";import{OverlayIndex as Z}from"./interfaces.js";import{OverlayRenderer as J}from"./OverlayRenderer.js";import{RenderRequestType as Q,ValidationState as $}from"../webgl-engine/lib/basicInterfaces.js";import{newIntersector as ee}from"../webgl-engine/lib/Intersector.js";import{fromValues as te}from"../webgl-engine/lib/LocalOriginFactory.js";import{UpdateParameters as re}from"../webgl-engine/lib/Material.js";import{SortedRenderGeometryRenderer as se}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{removeLoadedShaderModules as ie}from"../webgl-engine/parts/requireUtils.js";import{TaskPriority as ae,noBudget as ne,Task as oe}from"../../support/Scheduler.js";const le=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let he,ce=class extends t{get running(){return this._placementDirty&&(this._drapeSources.size>0||this._view.graphics.length>0||X.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.surface.ready}get _isSpherical(){return this._view.state.isGlobal}get _worldToPCSRatio(){return l(this._spatialReference)&&this._spatialReference.isGeographic&&!this._view.state.isLocal?M(this._spatialReference).metersPerDegree:1}get _view(){return this.surface.view}get suspended(){return this.surface.suspended}get updating(){return this.running||this.renderer.updating||this._contentUpdated}get hasHighlights(){return this.renderer.hasHighlights}get rendersOccluded(){return this.renderer.rendersOccluded}constructor(e){super(e),this._handles=new i,this._spatialReference=null,this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._hasUnusedRenderTargets=!1,this._longitudeCyclical=null,this._latestOriginId=0,this._maxResolution=has("esri-mobile")?2048:4096,this._animationTimeLast=0}initialize(){const e=this._view;this.renderer=new J({view:e,worldToPCSRatio:this._worldToPCSRatio,spatialReference:this._spatialReference}),this._groundIntersector=ee(this._view.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this._handles.add([this.renderer.events.on("has-highlights",(()=>{this.setDrawTexturesDirty(),this.notifyChange("hasHighlights")})),this.renderer.events.on("has-water",(t=>e._stage?.renderer.setParameters({hasOverlayWater:t}))),this.renderer.events.on("renders-occluded",(()=>{this.setDrawTexturesDirty(),this.notifyChange("rendersOccluded")})),this.renderer.events.on("content-changed",(()=>this.setDrawTexturesDirty())),this.renderer.events.on("textures-disposed",(()=>this.updateOverlayResult())),u((()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location]),(()=>this.setPlacementDirty())),u((()=>[e.state?.pixelRatio,e.state?.contentPixelRatio]),(()=>this.setPlacementDirty()),p),this.surface.on("elevation-change",(()=>this.setPlacementDirty())),e.on("resize",(()=>this.setPlacementDirty())),e.resourceController.scheduler.registerTask(ae.OVERLAY,this),e._stage.renderView.events.on("force-camera-for-screenshot",(e=>{this._updateOverlays(ne,e,Q.BACKGROUND),this.renderer.hasOverlays&&this._drawOverlayTextures(this.renderer.overlays,Q.BACKGROUND,e.pixelRatio)}))]),e._stage?.renderer.setParameters({renderOverlay:e=>{this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.hasOverlays&&(this._dispatchAnimationUpdate(e),this._drawOverlayTextures(this.renderer.overlays,Q.UPDATE)),this._hasUnusedRenderTargets&&this._collectUnusedRenderTargetMemory()}})}destroy(){this._handles=h(this._handles),l(he)&&(he.hide(),he=null)}get hasOverlays(){return this.renderer.hasOverlays}setSpatialReference(e){this._spatialReference=e,this.renderer.spatialReference=e,this._longitudeCyclical=null;const t=this._view.renderSpatialReference;l(e)&&l(t)?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this._longitudeCyclical=e.isWebMercator?new r(-20037508.342787,20037508.342787):new r(-180,180),this.renderer.longitudeCyclical=this._longitudeCyclical),this.renderer&&(this.renderer.worldToPCSRatio=this._worldToPCSRatio)):this.renderer.disposeOverlays()}get gpuMemoryUsage(){return this.renderer.gpuMemoryUsage}registerDrapeSource(e,t,r){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const s=this.renderer.createDrapeSourceRenderer(e,t,r);return this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("running"),s}registerGeometryDrapeSource(e){return this.registerDrapeSource(e,se)}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&l(e.setDrapingExtent)&&l(this._spatialReference)&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("running"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}updateOverlayResult(){this._view._stage?.renderer.setParameters({overlays:this.renderer.overlays})}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.setDrawTexturesDirty()}setPlacementDirty(){this._placementDirty=!0}runTask(e){return this._updateOverlays(e,this._view.state.contentCamera,Q.UPDATE)}_updateOverlays(e,t,r){if(!this._spatialReference)return oe.YIELD;const s=this._computeOverlayResolution(t);this._computeOverlayExtents(t,s,_e);const i=I(_e.inner)/I(_e.outer);this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const a=this._updateOverlay(Z.INNER,_e.inner,s,1*_e.pixelRatioAdjustment,_e.mapUnitsPerPixel),n=this._updateOverlay(Z.OUTER,_e.outer,s,i*_e.pixelRatioAdjustment,_e.mapUnitsPerPixel);a!==fe.EXTENT&&n!==fe.EXTENT||(this._drapeSources.forEach((e=>this._updateDrapeSourceExtent(e))),this.surface.updateTileOverlayParams(r)),a===fe.NONE&&n===fe.NONE||this.setDrawTexturesDirty(),this._placementDirty=!1,e.madeProgress()}_computeOverlayResolution(e){const t=this._view.state.contentPixelRatio,r=e.fullWidth/e.pixelRatio*t,s=e.fullHeight/e.pixelRatio*t;return Math.min(a(Math.max(r,s)+256),this._maxResolution)}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return fe.NONE;const a=this.renderer.overlays[e],n=a.mapUnitsPerPixel;if(a.mapUnitsPerPixel=i,a.pixelRatio=s,de(t,a.extent)&&r===a.resolution)return n===i?fe.NONE:fe.RERENDER_ONLY;N(a.extent,t),a.resolution=r;const o=j(a.extent);return a.renderLocalOrigin=te(o[0],o[1],0,"OV_"+this._latestOriginId++),fe.EXTENT}setTileParameters(e){const t=e.renderData.overlay;if(this.renderer.overlays.length>0){const r=this.renderer.overlays[Z.INNER],s=this.renderer.overlays[Z.OUTER],i=e.extent;this._rectInsideRect(r.extent,i)||this._rectanglesOverlap(i,r.extent)||this._rectanglesOverlap(i,s.extent)?(this._setTileOverlayData(i,Z.INNER,t),this._setTileOverlayData(i,Z.OUTER,t)):(this._clearTileOverlayData(Z.INNER,t),this._clearTileOverlayData(Z.OUTER,t))}else this._clearTileOverlayData(Z.INNER,t),this._clearTileOverlayData(Z.OUTER,t)}overlayPixelSizeInMapUnits(e){if(0===this.renderer.overlays.length)return 0;const t=this.renderer.overlays[Z.INNER],r=this.renderer.overlays[Z.OUTER],s=this._pointIsInExtent(e,t.extent)?t:r;return(s.extent[2]-s.extent[0])/s.resolution}_setTileOverlayData(e,t,r){if(0===this.renderer.overlays.length)return;const s=this.renderer.overlays[t].extent,i=I(s),a=b(s);let n=e[0];if(this._longitudeCyclical){n=this._longitudeCyclical.minimalMonotonic(s[0],n);const t=this._longitudeCyclical.minimalMonotonic(s[0],e[2]);n>t&&(n=t-(e[2]-e[0]))}r.setScale(t,I(e)/i,b(e)/a),r.setOffset(t,(n-s[0])/i,(e[1]-s[1])/a)}_clearTileOverlayData(e,t){t.setScale(e,-1,-1),t.setOffset(e,-1,-1)}async reloadShaders(){ie(),await this.renderer.reloadShaders(),this.setDrawTexturesDirty(),this.runTask(ne)}_dispatchAnimationUpdate(e){const t=_(e-this._animationTimeLast);if(t>=this.surface.view._stage.renderer.animationTimestep||l(this._view.state.forcedAnimationTime)||this._drawTexturesDirty||this._drawTexturesAnimateDirty){const r=_(t/this.surface.view._stage.renderer.animationTimeDilation),s=new re(this._view.state.camera,r,this._view.state.forcedAnimationTime);this.renderer.updateAnimation(s)&&(this._drawTexturesAnimateDirty=!0),this._animationTimeLast=e}}setDrawTexturesDirty(){this.renderer.hasOverlays?(this._contentUpdated=!0,this._drawTexturesDirty=!0,this._view._stage.renderView.requestRender()):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s){const i=this._view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,ge,t,r);if(c(i))return!1;const a=i.origin,n=f(pe,i.origin,i.direction);return this._groundIntersector.reset(a,n,e),this._groundIntersector.intersect([]),this._view.basemapTerrain.intersect(this._groundIntersector,null,a,n),this._groundIntersector.results.min.getIntersectionPoint(s)}_findHorizonBasedPointOfInterest(e,t){let r=.5;const i=.55,a=this._view.renderCoordsHelper.getAltitude(e.eye),o=this._view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=n(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:a+l,e.aboveGround?a-l:1/0),c=e.aboveGround;if("global"===this._view.viewingMode){const t=pe;B(F(V,M(this._view.spatialReference).radius+h),q(e.eye,e.viewForward),t),v(t,t,e.eye);const a=s.normalize(W(e.viewForward,t,e.viewRight))/e.fovY+.5,n=a<=0||a>=1?.5:i;r=c?n*a:a+n*(1-a)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),s=Math.tan(t),a=P(0,s,1,0),o=D(a,a,e.projectionMatrix)[1],l=n(.5+.5*o,0,1);r=1===l||0===l?.5:c?l*i:1-(1-l)*i}return!!this._intersectGroundFromView(e,.5,r,t)&&R(t,e.eye)<o.distance*o.distance}_computeOverlayExtents(e,t,r){const s=this._view.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,i=O();this._findHorizonBasedPointOfInterest(e,i)||T(i,s);const a=Math.max(.1,w(e.eye,i)),n=z(this._view.renderCoordsHelper,s,e.eye),h=Math.PI/2-Math.abs(n-Math.PI/2);X.OVERLAY_SHOW_CENTER?(c(he)&&(he=new K(this._view.graphics,"red")),he.show(i,this._renderSR)):l(he)&&he.hide(),this._overlaySREqualsRenderSR||U(i,this._renderSR,i,this._spatialReference);const u=this.surface.extent,p=!this._isSpherical&&l(this._spatialReference)&&this._spatialReference.isGeographic,_=p&&l(this._spatialReference)?1/M(this._spatialReference).metersPerDegree:1,m=this._view.state.contentPixelRatio,y=e.perScreenPixelRatio/m*a*_;r.mapUnitsPerPixel=y/this._worldToPCSRatio;let f=t*y/2,v=!1,R=p?90:1/0;this._isSpherical&&l(u)&&l(this._spatialReference)&&(this._spatialReference.isWebMercator?(f/=Math.cos(Y(i[1])),R=u[3]):(v=!0,f/=M(this._spatialReference).metersPerDegree,R=90),f>=R&&(f=R,i[1]=0,this._spatialReference.isWebMercator&&(i[0]=0)));let D=1;v&&(D=1/Math.max(.2,Math.cos(Math.abs(o(i[1])))),f*D>180&&(D=180/f),r.mapUnitsPerPixel*=D);const E=Math.log(2)/12;f=Math.exp(Math.round(Math.log(f)/E)*E);const P=f*D,C=32,j=.5*t/(C*P),b=.5*t/(C*f);i[0]=Math.round(i[0]*j)/j,i[1]=Math.round(i[1]*b)/b;const L=r.inner;L[0]=i[0]-P,L[1]=i[1]-f,L[2]=i[0]+P,L[3]=i[1]+f,this._isSpherical&&this._shiftExtentToFitBounds(L,1/0,R);const H=r.outer;if(6*P>I(u))N(H,d(u));else if(h<=.25*Math.PI)H[0]=L[0]-P,H[1]=L[1]-f,H[2]=L[2]+P,H[3]=L[3]+f;else{U(e.eye,this._renderSR,pe,this._spatialReference),g(ue,i,pe);let t=-Math.atan2(ue[1],ue[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));x(ue,le[r],2*f),ue[0]*=D,ue[2]*=D,S(H,L,ue)}if(this._isSpherical)H[0]=this._longitudeCyclical.clamp(H[0]),H[2]=this._longitudeCyclical.clamp(H[2]),H[1]=Math.max(H[1],-R),H[3]=Math.min(H[3],R);else{const e=A(L,u,me),t=A(H,u,ye);G(e,t)&&(H[2]=H[0],H[3]=H[1])}const k=Math.abs(L[2]-L[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,k),r.pixelRatioAdjustment=r.mapUnitsPerPixel/k}_drawOverlayTextures(e,t,r=this._view.state.contentPixelRatio){if(0===e.length||!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return;const s=this._drawTexturesDirty;this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1;const i=this._drawOverlay(e[Z.INNER],r),a=this._drawOverlay(e[Z.OUTER],r);i!==$.CHANGED&&a!==$.CHANGED||this.surface.updateTileOverlayParams(Q.UPDATE),this._collectUnusedRenderTargetMemory(),this.updateOverlayResult(),s?(this.surface.requestRender(t),t===Q.UPDATE&&this.surface.requestUpdate()):this.surface.requestRender(Q.BACKGROUND)}_drawOverlay(e,t){return this._longitudeCyclical?e.setupGeometryViewsCyclical(this._longitudeCyclical):e.setupGeometryViewsDirect(),e.draw(this.renderer,t)}_collectUnusedRenderTargetMemory(){if(this._hasUnusedRenderTargets=!1,this.renderer.hasOverlays){const e=performance.now();this._hasUnusedRenderTargets=this.renderer.collectUnusedRenderTargetMemory(e)}}_rectanglesOverlap(e,t){return!c(e)&&(this._longitudeCyclical?(this._longitudeCyclical.contains(t[0],t[2],e[0])||this._longitudeCyclical.contains(t[0],t[2],e[2])||this._longitudeCyclical.contains(e[0],e[2],t[0]))&&!(e[1]>t[3]||e[3]<t[1]):L(e,t))}_rectInsideRect(e,t){return!c(t)&&(this._longitudeCyclical?this._longitudeCyclical.contains(e[0],e[2],t[0])&&this._longitudeCyclical.contains(e[0],e[2],t[2])&&t[1]>e[1]&&t[3]<e[3]:G(e,t))}_pointIsInExtent(e,t){if(this._longitudeCyclical)return this._longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),H(e,s,i)}get test(){return{renderer:this.renderer,update:()=>this.runTask(ne)}}};function de(e,t){const r=1e-5,s=X.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([m()],ce.prototype,"_spatialReference",void 0),e([m({readOnly:!0})],ce.prototype,"running",null),e([m()],ce.prototype,"_placementDirty",void 0),e([m()],ce.prototype,"_contentUpdated",void 0),e([m()],ce.prototype,"_isSpherical",null),e([m()],ce.prototype,"_worldToPCSRatio",null),e([m({autoDestroy:!0})],ce.prototype,"renderer",void 0),e([m({constructOnly:!0})],ce.prototype,"surface",void 0),e([m()],ce.prototype,"suspended",null),e([m()],ce.prototype,"updating",null),e([m({type:Boolean})],ce.prototype,"hasHighlights",null),e([m({type:Boolean})],ce.prototype,"rendersOccluded",null),ce=e([y("esri.views.3d.terrain.OverlayManager")],ce);const ue=E(),pe=O(),_e={inner:C(),outer:C(),mapUnitsPerPixel:0,pixelRatioAdjustment:1},me=C(),ye=C(),ge=k();var fe;!function(e){e[e.NONE=0]="NONE",e[e.EXTENT=1]="EXTENT",e[e.RERENDER_ONLY=2]="RERENDER_ONLY"}(fe||(fe={}));export{ce as OverlayManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{isSome as r,disposeMaybe as s,isNone as n}from"../../../core/maybe.js";import a from"../../../core/ObjectPool.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{I as h}from"../../../chunks/mat4f64.js";import{b as c,s as d,e as u}from"../../../chunks/vec3.js";import{Z as p,f as g,c as _}from"../../../chunks/vec3f64.js";import{Z as f}from"../../../chunks/vec4f64.js";import{create as m,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as R}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlaySource as v}from"./Overlay.js";import{overlayRenderOccludedFlag as C}from"./OverlayRenderer.js";import{clearCaches as x}from"./PatchGeometry.js";import{PatchRenderData as D}from"./PatchRenderData.js";import{RenderOrder as P}from"./RenderOrder.js";import{ScaleRangeQueries as S}from"./ScaleRangeQueries.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as q}from"./terrainUtils.js";import{TileRenderer as E}from"./TileRenderer.js";import{TileUpdate as A}from"./TileUpdate.js";import{IteratorPreorder as w,sortTiles as N,compareTiles as j}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as G,ComponentIntersectionData as I}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as L}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as F}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as U}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as k}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{Attribute as B}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as M}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as z}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as V}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as H,StoreResults as Q}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as W}from"../webgl-engine/lib/Material.js";import{RenderSlot as Y}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as X}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Z}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as K,getVerticalOffsetTerrain as J}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as $}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as ee,intersectTriangles as te}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as ie}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as re}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as se}from"../../webgl/enums.js";const ne=7,ae=10,oe=m();var le;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(le||(le={}));let he=class extends i{get _isGlobal(){return this._stage.viewingMode===T.Global}get shading(){return this._techniqueConfiguration.shading}set shading(e){this._techniqueConfiguration.shading=e}constructor(e){super(e),this.type=H.TERRAIN,this.isGround=!0,this._tileSize=256,this._techniqueConfiguration=new re,this._passParameters=new U,this._rctx=null,this._scaleRangeQueries=new S,this._renderDataPool=new a(D),this._patchGroups=new Map,this._patchGroupsDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new w,this._highestVisibleLODTile=null,this._visible=!0,this._transparencyState=le.Opaque,this._velvetOverground=!0,this._castShadows=!0,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.needsHighlight=!1,this.renderOccludedFlags=W.Occlude}initialize(){const e=[Y.OPAQUE_TERRAIN,Y.TRANSPARENT_TERRAIN,Y.OCCLUDED_TERRAIN];this._stage.addRenderPlugin(e,this)}destroy(){this._stage.removeRenderPlugin(this),x()}get canRender(){return this._visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===le.TransparentWithDraped||e===le.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get needsLinearDepth(){return this._overlayRenderer.hasWater}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}set velvetOverground(e){this._velvetOverground!==e&&(this._velvetOverground=e,this.setNeedsRender())}get layerUid(){return K}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setNeedsHighlight(e){this.needsHighlight=e,this.setNeedsRender()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?C:W.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,r(this._tileRenderer)&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,A.TEXTURE_FADING)}queryVisibleLevelRange(e,t,i,r){this._scaleRangeQueries.queryVisibleLevelRange(e,t,i,r),this.setNeedsRender()}updateTileTexture(e,t){r(this._tileRenderer)&&(this._tileRenderer.updateTileTexture(e,t===A.TEXTURE_FADING?R.FADING:R.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[O.ELEVATION])i.pendingUpdates&=~A.GEOMETRY;e.resetPendingUpdate(A.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=ae-ne,i=Math.max(0,Math.floor((e.level-t)/ne)*ne);if(this._isGlobal&&0===i)return p;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}setVisibility(e){this._visible=e,this.setDirty()}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=M.UPDATE){this._patchGroupsDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=M.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=M.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._rctx=e.renderContext.rctx,this._techniqueRepository=e.techniqueRepository,this._tileRenderer=new E(this._rctx,this._tileSize,this._techniqueRepository),this.updateTileBackground(),this._emptyTex=z(this._rctx)}uninitializeRenderContext(){this._emptyTex=s(this._emptyTex),this._tileRenderer=s(this._tileRenderer)}intersect(e,t,i,s){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==le.Opaque)return;const a=ce,o=de;c(a,s,i),d(o,1/a[0],1/a[1],1/a[2]);const l=e.results.min,p=e.results.max,g=e.results.ground,_=e.options.store===Q.MIN,f=!!e.results.ground.target,m=J(e.verticalOffset),T=e.tolerance;let R,O=_&&r(l.dist)?l.dist:1/0;const v=d=>{const f=d.renderData;if(!f?.vao)return;const v=f.geometryInfo;b(oe,v.boundingBox);const C=f.localOrigin;r(m)&&(m.localOrigin=C,m.applyToAabb(oe));const x=oe;if(ue[0]=i[0]-C[0],ue[1]=i[1]-C[1],ue[2]=i[2]-C[2],!ee(x,ue,o,T,O))return;const D=(e,t,i)=>{e.set(this.type,d,t,i,h),O=_&&r(l.dist)?l.dist:1/0},P=(o,h)=>{if(r(h)&&o>=0&&(e.options.backfacesTerrain||u(h,a)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(i,s,o))){if((null==g.dist||o<g.dist)&&D(g,o,h),e.options.isFiltered)return;e.options.store===Q.ALL&&(n(R)?(R=V(e.ray),D(R,o,h),e.results.all.push(R)):o<R.dist&&D(R,o,h)),(null==l.dist||o<l.dist)&&D(l,o,h),e.options.store!==Q.MIN&&(null==p.dist||o>p.dist)&&D(p,o,h)}},S=pe;c(S,s,C);const q=v.indices,E=v.vertexAttributes,A=E.getField(Z.POSITION,y),w=new B(A.typedBuffer,3,!1,E.stride/4),N=v.indexCount/3;if(n(m)&&N>G){const e=d.renderData;n(e.intersectionData)&&(e.intersectionData=new I(q,0,N,w)),e.intersectionData.intersectRay({r0:ue,r1:S},P)}else te(ue,S,0,N,q,w,null,m,P)},C=this._rootTiles;if(r(C)){(()=>{const t=this._tileIterator;t.reset(C);const s=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||s&&e.intersectsClippingArea)||!r(m)&&!e.intersectsRay(i,a,T,O)||f&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}prepareTechnique(e){if(e.bindParameters.slot===Y.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&C))return null}else{const t=this.transparency===le.Opaque?Y.OPAQUE_TERRAIN:Y.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}switch(e.output){case L.Color:{if(this.transparency===le.Empty)return null;this._techniqueConfiguration.hasScreenSpaceReflections=e.bindParameters.ssr.enabled,this._techniqueConfiguration.hasCloudsReflections=r(e.bindParameters.cloudsFade.data),this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=e.bindParameters.ssaoHelper.enabled,this._techniqueConfiguration.overlayMode=this._overlayRenderer.isEmpty?F.Disabled:this._overlayRenderer.hasWater?F.EnabledWithWater:F.Enabled;const t=e.bindParameters.slot===Y.OCCLUDED_TERRAIN?v.Occluded:v.ColorAndWater;return this._updateTechnique(L.Color,t===v.Occluded)}case L.Shadow:case L.ShadowExludeHighlight:return this._castShadows&&1===e.bindParameters.lighting.globalFactor?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Shadow,!1)):null;case L.Depth:return this.transparency===le.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Depth,!1));case L.Normal:return this.transparency===le.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Normal,!1));case L.ObjectAndLayerIdColor:return this.transparency===le.Empty?null:this._updateTechnique(L.ObjectAndLayerIdColor,!1);case L.Highlight:return this.transparency!==le.Empty&&this.needsHighlight?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Highlight,!1)):null}return null}render(e,t){const i=1===e.bindParameters.lighting.globalFactor;switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case L.Color:{const i=e.bindParameters.slot===Y.OCCLUDED_TERRAIN?v.Occluded:v.ColorAndWater;this.transparency===le.Opaque?this._renderMaterialPass(e,t,i):e.offscreenRenderingHelper.renderToTargets((()=>this._renderMaterialPass(e,t,i)),e.offscreenRenderingHelper.tmpColor,e.offscreenRenderingHelper.mainDepth,[0,0,0,0]);break}case L.Depth:case L.Normal:this._renderAuxiliaryPass(e,t,v.None);break;case L.Highlight:this.needsHighlight&&this._renderAuxiliaryPass(e,t,v.Highlight);break;case L.Shadow:case L.ShadowExludeHighlight:this._castShadows&&i&&this._renderAuxiliaryPass(e,t,v.None);break;case L.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,v.ObjectAndLayerIdColor)}this._scaleRangeQueries.hasPendingQueries()&&this.setNeedsRender()}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlaySource=i,r.bindTechnique(t,this._passParameters,e.bindParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this._scaleRangeQueries.prepareQueries(),this._renderPatchGroups(e,t,i),this._scaleRangeQueries.processQueries()}_renderAuxiliaryPass(e,t,i){const r=e.rctx;this._passParameters.overlaySource=i,r.bindTechnique(t,this._passParameters,e.bindParameters),this._renderPatchGroupsAuxiliary(e,t,i)}updateTileBackground(e=null){if(n(this._tileRenderer))return;const i=this._tileRenderer;let s=null;if(r(e)){const i=t.toUnitRGBA(e);s=g(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(s),this._allTiles.forAll((e=>i.updateTileTexture(e,R.FADING))),this._techniqueConfiguration.tileBlendInput=i.backgroundIsGrid?k.GridComposite:r(i.backgroundColor)?k.ColorComposite:k.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchGroupsDirty&&(this._highestVisibleLODTile=null,this._rebuildPatchGroups(),this._patchGroupsDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==P.NONE){const e=Array.from(this._patchGroups.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>j(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(!n(e)){e[0]?.surface.checkAllTilesWaterproofness(),this._patchGroups.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}const r=i.localOrigin;let s=this._patchGroups.get(r);s||(s=new Array,this._patchGroups.set(r,s)),s.push(e),(!this._highestVisibleLODTile||e.vlevel>this._highestVisibleLODTile.vlevel)&&(this._highestVisibleLODTile=e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,i){const r=this._stencilEnabledLayerExtents.length>0;this._patchGroups.forEach((s=>{const n=s[0].renderData.localOrigin;t.program.bindDraw(new $(n),e.bindParameters,this._passParameters);for(let a=0;a<s.length;a++)this._renderPatch(e,t,s[a],se.TRIANGLES,r,i)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,i){const s=e.bindParameters.camera,a=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=X(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const o=this._stencilEnabledLayerExtents.length>0,l=i===v.Occluded;l&&(a.bindTexture("tex",this._emptyTex),a.setUniform1f("blend",1),a.setUniform4fv("texOffsetAndScale",f));const h=r(this._tileRenderer)&&r(this._tileRenderer.backgroundColor)?this._tileRenderer.backgroundColor:p;this._techniqueConfiguration.tileBlendInput===k.ColorComposite&&a.setUniform3fv("backgroundColor",h);const c=this.wireframe?se.LINES:se.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&a.bindTexture("texNext",this._emptyTex);const d=this._patchGroups;for(const u of d.values()){const s=u[0].renderData.localOrigin;t.program.bindDraw(new $(s),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const h of u){const s=h.renderData,d=s.textureReference;if(!n(d)){if(!l){this._scaleRangeQueries.scaleQueriesForTile(h),a.setUniform4fv("texOffsetAndScale",d.offsetAndScale),a.bindTexture("tex",d.texture.texture);const e=s.textureFadeFactor,t=e<1?s.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&r(t)&&e<1?(a.setUniform1f("fadeFactor",e),a.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),a.setUniform3fv("nextTexOpacities",t.opacities),a.bindTexture("texNext",t.texture.texture)):a.setUniform1f("fadeFactor",1),s.textureIsFading&&this.setNeedsRender(),a.setUniform3fv("textureOpacities",d.opacities)}this._renderPatch(e,t,h,c,o,i),h.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,a){const o=i.renderData,l=o.vao,h=l.indexBuffer;if(n(h))return void(q&&console.error("Rendered tile with no indices: ",i.lij," : ",o));const c=t.program;a===v.None||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,o.overlay),s&&(t.useStencil=this._useStencilForTile(i),t.bindPipelineState(e.rctx,e.bindParameters.slot));const d=o.geometryInfo.indexCount;e.rctx.bindVAO(l),c.assertCompatibleVertexAttributeLocations(l),e.rctx.drawElements(r,d,h.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,e===L.Color&&(this._techniqueConfiguration.atmosphere=this._isGlobal&&this._velvetOverground),this._techniqueConfiguration.renderOccluded=t,this._techniqueConfiguration.stencilEnabled=!1,this._shaderTechnique=this._techniqueRepository.releaseAndAcquire(ie,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([o({constructOnly:!0})],he.prototype,"_overlayRenderer",void 0),e([o({constructOnly:!0})],he.prototype,"_stage",void 0),e([o({readOnly:!0})],he.prototype,"_isGlobal",null),e([o({constructOnly:!0})],he.prototype,"_allTiles",void 0),e([o({constructOnly:!0})],he.prototype,"_ellipsoidRadius",void 0),e([o({value:!1})],he.prototype,"renderingDisabled",null),e([o()],he.prototype,"renderPatchBorders",null),e([o()],he.prototype,"visualizeNormals",null),e([o()],he.prototype,"cullBackFaces",null),e([o({value:P.FRONT_TO_BACK})],he.prototype,"renderOrder",null),e([o()],he.prototype,"wireframe",null),he=e([l("esri.views.3d.terrain.TerrainRenderer")],he);const ce=_(),de=_(),ue=_(),pe=_();export{he as TerrainRenderer,le as TransparencyMode};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{isSome as r,disposeMaybe as s,isNone as n}from"../../../core/maybe.js";import a from"../../../core/ObjectPool.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{I as h}from"../../../chunks/mat4f64.js";import{b as c,s as d,e as u}from"../../../chunks/vec3.js";import{Z as p,f as g,c as _}from"../../../chunks/vec3f64.js";import{Z as f}from"../../../chunks/vec4f64.js";import{create as m,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as R}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlaySource as v}from"./Overlay.js";import{overlayRenderOccludedFlag as C}from"./OverlayRenderer.js";import{clearCaches as x}from"./PatchGeometry.js";import{PatchRenderData as D}from"./PatchRenderData.js";import{RenderOrder as P}from"./RenderOrder.js";import{ScaleRangeQueries as S}from"./ScaleRangeQueries.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as q}from"./terrainUtils.js";import{TileRenderer as E}from"./TileRenderer.js";import{TileUpdate as A}from"./TileUpdate.js";import{IteratorPreorder as w,sortTiles as N,compareTiles as j}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as G,ComponentIntersectionData as I}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as L}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as F}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as U}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as k}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{Attribute as B}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as M}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as z}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as V}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as H,StoreResults as Q}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as W}from"../webgl-engine/lib/Material.js";import{RenderSlot as Y}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as X}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Z}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as K,getVerticalOffsetTerrain as J}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as $}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as ee,intersectTriangles as te}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as ie}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as re}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as se}from"../../webgl/enums.js";const ne=7,ae=10,oe=m();var le;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(le||(le={}));let he=class extends i{get _isGlobal(){return this._stage.viewingMode===T.Global}get shading(){return this._techniqueConfiguration.shading}set shading(e){this._techniqueConfiguration.shading=e}constructor(e){super(e),this.type=H.TERRAIN,this.isGround=!0,this._tileSize=256,this._techniqueConfiguration=new re,this._passParameters=new U,this._rctx=null,this._scaleRangeQueries=new S,this._renderDataPool=new a(D),this._patchGroups=new Map,this._patchGroupsDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new w,this._highestVisibleLODTile=null,this._visible=!0,this._transparencyState=le.Opaque,this._velvetOverground=!0,this._castShadows=!0,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.needsHighlight=!1,this.renderOccludedFlags=W.Occlude}initialize(){const e=[Y.OPAQUE_TERRAIN,Y.TRANSPARENT_TERRAIN,Y.OCCLUDED_TERRAIN];this._stage.addRenderPlugin(e,this)}destroy(){this._stage.removeRenderPlugin(this),x()}get canRender(){return this._visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===le.TransparentWithDraped||e===le.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get needsLinearDepth(){return this._overlayRenderer.hasWater}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}set velvetOverground(e){this._velvetOverground!==e&&(this._velvetOverground=e,this.setNeedsRender())}get layerUid(){return K}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setNeedsHighlight(e){this.needsHighlight=e,this.setNeedsRender()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?C:W.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,r(this._tileRenderer)&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,A.TEXTURE_FADING)}queryVisibleLevelRange(e,t,i,r){this._scaleRangeQueries.queryVisibleLevelRange(e,t,i,r),this.setNeedsRender()}updateTileTexture(e,t){r(this._tileRenderer)&&(this._tileRenderer.updateTileTexture(e,t===A.TEXTURE_FADING?R.FADING:R.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[O.ELEVATION])i.pendingUpdates&=~A.GEOMETRY;e.resetPendingUpdate(A.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=ae-ne,i=Math.max(0,Math.floor((e.level-t)/ne)*ne);if(this._isGlobal&&0===i)return p;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}setVisibility(e){this._visible=e,this.setDirty()}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=M.UPDATE){this._patchGroupsDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=M.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=M.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._rctx=e.renderContext.rctx,this._techniqueRepository=e.techniqueRepository,this._tileRenderer=new E(this._rctx,this._tileSize,this._techniqueRepository),this.updateTileBackground(),this._emptyTex=z(this._rctx)}uninitializeRenderContext(){this._emptyTex=s(this._emptyTex),this._tileRenderer=s(this._tileRenderer)}intersect(e,t,i,s){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==le.Opaque)return;const a=ce,o=de;c(a,s,i),d(o,1/a[0],1/a[1],1/a[2]);const l=e.results.min,p=e.results.max,g=e.results.ground,_=e.options.store===Q.MIN,f=!!e.results.ground.target,m=J(e.verticalOffset),T=e.tolerance;let R,O=_&&r(l.dist)?l.dist:1/0;const v=d=>{const f=d.renderData;if(!f?.vao)return;const v=f.geometryInfo;b(oe,v.boundingBox);const C=f.localOrigin;r(m)&&(m.localOrigin=C,m.applyToAabb(oe));const x=oe;if(ue[0]=i[0]-C[0],ue[1]=i[1]-C[1],ue[2]=i[2]-C[2],!ee(x,ue,o,T,O))return;const D=(e,t,i)=>{e.set(this.type,d,t,i,h),O=_&&r(l.dist)?l.dist:1/0},P=(o,h)=>{if(r(h)&&o>=0&&(e.options.backfacesTerrain||u(h,a)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(i,s,o))){if((null==g.dist||o<g.dist)&&D(g,o,h),e.options.isFiltered)return;e.options.store===Q.ALL&&(n(R)?(R=V(e.ray),D(R,o,h),e.results.all.push(R)):o<R.dist&&D(R,o,h)),(null==l.dist||o<l.dist)&&D(l,o,h),e.options.store!==Q.MIN&&(null==p.dist||o>p.dist)&&D(p,o,h)}},S=pe;c(S,s,C);const q=v.indices,E=v.vertexAttributes,A=E.getField(Z.POSITION,y),w=new B(A.typedBuffer,3,!1,E.stride/4),N=v.indexCount/3;if(n(m)&&N>G){const e=d.renderData;n(e.intersectionData)&&(e.intersectionData=new I(q,0,N,w)),e.intersectionData.intersectRay({r0:ue,r1:S},P)}else te(ue,S,0,N,q,w,null,m,P)},C=this._rootTiles;if(r(C)){(()=>{const t=this._tileIterator;t.reset(C);const s=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||s&&e.intersectsClippingArea)||!r(m)&&!e.intersectsRay(i,a,T,O)||f&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}prepareTechnique(e){if(e.bindParameters.slot===Y.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&C))return null}else{const t=this.transparency===le.Opaque?Y.OPAQUE_TERRAIN:Y.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}switch(e.output){case L.Color:{if(this.transparency===le.Empty)return null;this._techniqueConfiguration.hasScreenSpaceReflections=e.bindParameters.ssr.enabled,this._techniqueConfiguration.hasCloudsReflections=r(e.bindParameters.cloudsFade.data),this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=e.bindParameters.ssaoHelper.enabled,this._techniqueConfiguration.overlayMode=this._overlayRenderer.isEmpty?F.Disabled:this._overlayRenderer.hasWater?F.EnabledWithWater:F.Enabled;const t=e.bindParameters.slot===Y.OCCLUDED_TERRAIN?v.Occluded:v.ColorAndWater;return this._updateTechnique(L.Color,t===v.Occluded)}case L.Shadow:case L.ShadowExcludeHighlight:return this._castShadows&&1===e.bindParameters.lighting.globalFactor?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Shadow,!1)):null;case L.Depth:return this.transparency===le.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Depth,!1));case L.Normal:return this.transparency===le.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Normal,!1));case L.ObjectAndLayerIdColor:return this.transparency===le.Empty?null:this._updateTechnique(L.ObjectAndLayerIdColor,!1);case L.Highlight:return this.transparency!==le.Empty&&this.needsHighlight?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(L.Highlight,!1)):null}return null}render(e,t){const i=1===e.bindParameters.lighting.globalFactor;switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case L.Color:{const i=e.bindParameters.slot===Y.OCCLUDED_TERRAIN?v.Occluded:v.ColorAndWater;this.transparency===le.Opaque?this._renderMaterialPass(e,t,i):e.offscreenRenderingHelper.renderToTargets((()=>this._renderMaterialPass(e,t,i)),e.offscreenRenderingHelper.tmpColor,e.offscreenRenderingHelper.mainDepth,[0,0,0,0]);break}case L.Depth:case L.Normal:this._renderAuxiliaryPass(e,t,v.None);break;case L.Highlight:this.needsHighlight&&this._renderAuxiliaryPass(e,t,v.Highlight);break;case L.Shadow:case L.ShadowExcludeHighlight:this._castShadows&&i&&this._renderAuxiliaryPass(e,t,v.None);break;case L.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,v.ObjectAndLayerIdColor)}this._scaleRangeQueries.hasPendingQueries()&&this.setNeedsRender()}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlaySource=i,r.bindTechnique(t,this._passParameters,e.bindParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this._scaleRangeQueries.prepareQueries(),this._renderPatchGroups(e,t,i),this._scaleRangeQueries.processQueries()}_renderAuxiliaryPass(e,t,i){const r=e.rctx;this._passParameters.overlaySource=i,r.bindTechnique(t,this._passParameters,e.bindParameters),this._renderPatchGroupsAuxiliary(e,t,i)}updateTileBackground(e=null){if(n(this._tileRenderer))return;const i=this._tileRenderer;let s=null;if(r(e)){const i=t.toUnitRGBA(e);s=g(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(s),this._allTiles.forAll((e=>i.updateTileTexture(e,R.FADING))),this._techniqueConfiguration.tileBlendInput=i.backgroundIsGrid?k.GridComposite:r(i.backgroundColor)?k.ColorComposite:k.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchGroupsDirty&&(this._highestVisibleLODTile=null,this._rebuildPatchGroups(),this._patchGroupsDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==P.NONE){const e=Array.from(this._patchGroups.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>j(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(!n(e)){e[0]?.surface.checkAllTilesWaterproofness(),this._patchGroups.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}const r=i.localOrigin;let s=this._patchGroups.get(r);s||(s=new Array,this._patchGroups.set(r,s)),s.push(e),(!this._highestVisibleLODTile||e.vlevel>this._highestVisibleLODTile.vlevel)&&(this._highestVisibleLODTile=e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,i){const r=this._stencilEnabledLayerExtents.length>0;this._patchGroups.forEach((s=>{const n=s[0].renderData.localOrigin;t.program.bindDraw(new $(n),e.bindParameters,this._passParameters);for(let a=0;a<s.length;a++)this._renderPatch(e,t,s[a],se.TRIANGLES,r,i)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,i){const s=e.bindParameters.camera,a=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=X(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const o=this._stencilEnabledLayerExtents.length>0,l=i===v.Occluded;l&&(a.bindTexture("tex",this._emptyTex),a.setUniform1f("blend",1),a.setUniform4fv("texOffsetAndScale",f));const h=r(this._tileRenderer)&&r(this._tileRenderer.backgroundColor)?this._tileRenderer.backgroundColor:p;this._techniqueConfiguration.tileBlendInput===k.ColorComposite&&a.setUniform3fv("backgroundColor",h);const c=this.wireframe?se.LINES:se.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&a.bindTexture("texNext",this._emptyTex);const d=this._patchGroups;for(const u of d.values()){const s=u[0].renderData.localOrigin;t.program.bindDraw(new $(s),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const h of u){const s=h.renderData,d=s.textureReference;if(!n(d)){if(!l){this._scaleRangeQueries.scaleQueriesForTile(h),a.setUniform4fv("texOffsetAndScale",d.offsetAndScale),a.bindTexture("tex",d.texture.texture);const e=s.textureFadeFactor,t=e<1?s.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&r(t)&&e<1?(a.setUniform1f("fadeFactor",e),a.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),a.setUniform3fv("nextTexOpacities",t.opacities),a.bindTexture("texNext",t.texture.texture)):a.setUniform1f("fadeFactor",1),s.textureIsFading&&this.setNeedsRender(),a.setUniform3fv("textureOpacities",d.opacities)}this._renderPatch(e,t,h,c,o,i),h.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,a){const o=i.renderData,l=o.vao,h=l.indexBuffer;if(n(h))return void(q&&console.error("Rendered tile with no indices: ",i.lij," : ",o));const c=t.program;a===v.None||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,o.overlay),s&&(t.useStencil=this._useStencilForTile(i),t.bindPipelineState(e.rctx,e.bindParameters.slot));const d=o.geometryInfo.indexCount;e.rctx.bindVAO(l),c.assertCompatibleVertexAttributeLocations(l),e.rctx.drawElements(r,d,h.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,e===L.Color&&(this._techniqueConfiguration.atmosphere=this._isGlobal&&this._velvetOverground),this._techniqueConfiguration.renderOccluded=t,this._techniqueConfiguration.stencilEnabled=!1,this._shaderTechnique=this._techniqueRepository.releaseAndAcquire(ie,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([o({constructOnly:!0})],he.prototype,"_overlayRenderer",void 0),e([o({constructOnly:!0})],he.prototype,"_stage",void 0),e([o({readOnly:!0})],he.prototype,"_isGlobal",null),e([o({constructOnly:!0})],he.prototype,"_allTiles",void 0),e([o({constructOnly:!0})],he.prototype,"_ellipsoidRadius",void 0),e([o({value:!1})],he.prototype,"renderingDisabled",null),e([o()],he.prototype,"renderPatchBorders",null),e([o()],he.prototype,"visualizeNormals",null),e([o()],he.prototype,"cullBackFaces",null),e([o({value:P.FRONT_TO_BACK})],he.prototype,"renderOrder",null),e([o()],he.prototype,"wireframe",null),he=e([l("esri.views.3d.terrain.TerrainRenderer")],he);const ce=_(),de=_(),ue=_(),pe=_();export{he as TerrainRenderer,le as TransparencyMode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{throwIfAborted as g,isAbortError as m,isAborted as T,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as y,syncAndInitial as v,sync as w,initial as E}from"../../../core/reactiveUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as L}from"../../../core/accessorSupport/decorators/subclass.js";import{m as D}from"../../../chunks/mat4.js";import{c as C}from"../../../chunks/mat4f64.js";import{c as P}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as b}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as x}from"../../../core/support/WatchUpdatingTracking.js";import{getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as M,projectPointToVector as j}from"../../../geometry/projection.js";import A from"../../../geometry/SpatialReference.js";import{create as I,equals as O,intersection as V,empty as k,expand as B,intersectsSphere as N}from"../../../geometry/support/aaBoundingRect.js";import{create as F,copy as G}from"../../../geometry/support/frustum.js";import{isPlateCarree as q}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as W}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as H}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as z}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as X}from"../../../layers/support/layerUtils.js";import{acquireDecoder as Q}from"../../../layers/support/LercDecoder.js";import{printAllocations as Y}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as $}from"../support/cameraUtils.js";import K from"../support/debugFlags.js";import{toBoundingRect as J}from"../support/extentUtils.js";import{ClientType as Z}from"../support/index.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{create as se}from"./ExtentHelper.js";import{LODSnapping as ae,TextureUpdate as ne}from"./interfaces.js";import{LayerClass as le,LayerClasses as oe}from"./LayerClass.js";import{OverlayManager as he}from"./OverlayManager.js";import{PlanarPatch as de}from"./PlanarPatch.js";import{RenderOrder as pe}from"./RenderOrder.js";import{SphericalPatch as ue}from"./SphericalPatch.js";import{SplitLimits as ce}from"./SplitLimits.js";import{MAX_ROOT_TILES as _e,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as ge,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as me,MAX_MEMORY_LOD_BIAS as Te,ELEVATION_NODATA_VALUE as fe}from"./TerrainConst.js";import{TerrainRenderer as ye,TransparencyMode as ve}from"./TerrainRenderer.js";import we from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as Ee,internalAssert as Se,oppositeEdge as Le,isSurfaceLayerView as De,isGroupLayerView as Ce,isMapTileLayerView as Pe,isBlendableLayerView as Ue,isElevationLayerView as be,isVectorTileLayerView as xe,useFetchTileForLayer as Re,isImageryTileLayerView as Me,isTileLayerView as je,releaseTileData as Ae,neighborEdgeIndices as Ie,ENABLE_TERRAIN_INTERNAL_CHECKS as Oe,ENABLE_WATERPROOFNESS_TESTS as Ve,enableTerrainInternalChecks as ke,enableTerrainWaterproofnessChecks as Be}from"./terrainUtils.js";import{Tile as Ne}from"./Tile.js";import{printAllocations as Fe}from"./TilePerLayerInfo.js";import{TileUpdate as Ge}from"./TileUpdate.js";import{IteratorPreorder as qe,IteratorPostorder as We,compareTilesByLij as He,hasLoadableSiblings as ze,sortTilesByPOI as Xe,sortTiles as Qe}from"./tileUtils.js";import{TilingSchemeLogic as Ye}from"./TilingSchemeLogic.js";import{UpsampleInfo as $e}from"./UpsampleInfo.js";import{isCompositeBlendMode as Ke,blendModeFromString as Je}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as Ze}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as et}from"../../support/RenderState.js";import{ImmediateTask as tt,TaskPriority as it,noBudget as rt}from"../../support/Scheduler.js";let st=class extends(a.EventedMixin(i)){constructor(e){super(e),this._iteratorPool=new c(qe,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new We,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new we,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new ce,this._frustum=F(),this._viewProjectionMatrix=C(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new x,this._frameTask=tt,this._allTiles=new _,this._upsampleInfoPool=new c($e),this._rootTilesExtent=I(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=A.WebMercator,this.visibleElevationBounds=new te(1/0,-1/0),this.rootTileElevationBounds=new te(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this.oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this._shading=!0,this._isWebMercator=!1,this._isWebMercatorOnPlateeCarree=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=Q(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(de):new c(ue);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new H(e.newCache("elevation-query")),this._set("overlayManager",new he({surface:this})),this._handles.add([y((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),y((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e))),y((()=>this.overlayManager.renderer.isEmpty),(()=>this._evaluateTransparency()))],"overlayManager"),this._renderer=new ye({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:R(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles}),this._handles.add([y((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?ne.UNFADED:ne.IMMEDIATE)}),v),y((()=>this.hasCompositeBlendMode),(()=>{this._updateTileTextures(this._evaluateTransparency()?ne.UNFADED:ne.IMMEDIATE)}),v),y((()=>this.renderingDisabled),(()=>this.view?._stage?.renderer.setParameters({terrainRenderingEnabled:!this.renderingDisabled})),w),y((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),v),y((()=>this.snapLevel),(()=>this._viewChanged=!0),w),y((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),y((()=>K.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&K.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),E)]),this._extentHelper=se(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),i=new Ye({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(Z.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(Z.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(it.TERRAIN_SURFACE,this),this._handles.add([y((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),E),y((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),w),y((()=>this.extent),(()=>this._updateRootTiles()),E),this.view.on("resize",(()=>this._viewChangeUpdate())),y((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),v),y((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),E),y((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),w)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._handles.add([y((()=>this.view?.map.ground.shading),(()=>{this._updateShadingIfChanged()}))]),this._updateShading(),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache);const e=this.tilingSchemeLogic.layers;this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),e.destroy(),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Ne.prune(),this._treeDebugger=d(this._treeDebugger),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),Y(),Fe()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===ae.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(i&&t){const r=e.state.contentCamera;let s=$(e,r.eye,r.viewForward,r.up).tilt;s>90&&(s=180-s);const a=2*(s/90)**2,n=t.levelAtScale(i)-a;return Math.round(n)}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ae.ON:ae.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=I(),r=J(t,i,e)?i:null,s=this._get("extent");return O(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,I()),t=this._get("extent");return O(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager.updating)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._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}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this._rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get 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}set velvetOverground(e){this._renderer.velvetOverground=e,this._set("velvetOverground",e)}get wireframe(){return this._renderer.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.transparency===ve.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get textureFadeDuration(){return this.view.qualitySettings.tiledSurface.textureFadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this._rootTiles;if(p(s)||!s.length)return null;if(0===s[0].layerInfo[le.ELEVATION].length)return null;const a=ht;if(a[0]=e,a[1]=t,a[2]=i,!M(a,r,a,this._spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;return gt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[le.ELEVATION].length:0;if(!p(r)&&r.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,gt(r,e[t+0],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!j(e,ht,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(u(t))for(const i of t)if(i?.containsPoint(ht)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;ht[0]>t[2]&&(i+=1),ht[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}getSphereElevationBounds(e,t,i,r,s){if(ht[0]=e,ht[1]=t,ht[2]=i,ht[3]=r,!M(ht,s,ht,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&N(e.extent,ht))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},h=this._rootTiles;if(u(h))for(const l of h)o(l);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!j(e,ht,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;ht[3]=t;let i=null;const r=e=>{if(e&&N(e.extent,ht)){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(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?ve.Empty:ve.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?ve.Opaque:ve.Semitransparent,s=i!==r;return s&&(this._renderer.transparency=r,this.view?._stage?.renderer.setParameters({terrainTransparency:this._renderer.transparency})),s}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;Ee(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??A.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateeCarree=this._isWebMercator&&q(this.view?.renderSpatialReference),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles())}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return pt[0]=e,pt[1]=t,pt[2]=i,s.init(pt,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=dt;let s=t.rootTilesInExtent(e,i,5*_e);if(u(this._rootTiles)){if(s.length>_e)return void l.getLogger(this.declaredClass).warn(ge);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,nt);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>nt(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>_e&&(l.getLogger(this.declaredClass).warn(me),s=t.rootTilesInExtent(e,i,_e)),this._setRootTiles(s.map((e=>this._newRootTile(e))));O(i,this._rootTilesExtent)||(this._rootTilesExtent=I(i)),this._visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.isLoaded&&e.intersectsClippingArea));e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(He);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===Ge.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Ge.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(p(e))return;const t=ze(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e),e.setPendingUpdate(Ge.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBounds[0],r),s=Math.max(e.elevationBounds[1],s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._batchUpdatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new te(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;u(i)&&i.forEach((({elevationBounds:i})=>{e=Math.min(e,i[0]),t=Math.max(t,i[1])}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new 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?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=F()),G(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,G(this._frustum,e.frustum),D(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),P(this._eyePosRenderSR,t.eye),M(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(lt(e)?this._loadChildren(e):ot(e)&&this._loadParent(e))}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForGeometryUpdate(e){const t=this._pendingTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ge.TEXTURE_FADING)?Ge.TEXTURE_FADING:!!e.resetPendingUpdate(Ge.TEXTURE_NOFADING)&&Ge.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){const e=ct.extent;k(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),ct.spatialReference=this.spatialReference,this.emit("elevation-change",ct)}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._batchUpdatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed?this.requestUpdate():this.getUsedMemory(),this.notifyChange("updatingProgressValue")}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();t.reset(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;for(;!t.done;){const e=t.next(),a=e.shouldSplit(r,s,i);if(a!==Ge.SPLIT){if(e.resetPendingUpdate(Ge.SPLIT)&&e.updateAgentSuspension(),a===Ge.VSPLITMERGE&&e.updateAgents(le.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ge.MERGE),e.resetPendingUpdate(Ge.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);const i=this._viewProjectionMatrix;for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(i);t.remove()}}else e.resetPendingUpdate(Ge.MERGE),e.isLeaf&&(e.setPendingUpdate(Ge.SPLIT),t.skipSubtree()),e.rendered&&e.setPendingUpdate(Ge.RENDERDATA)}t.remove(),this.requestUpdate(),(this.shortBatches||!this.oneBatchPerFrameTask)&&this._batchUpdatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Xe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Se(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForGeometryUpdate(e))}_batchUpdatePendingTileGeometries(){const e=this._pendingTilesToUpdate;if(0===e.size)return;const t=Array.from(this._pendingTilesToUpdate.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea)),i=(i,r)=>{!r?.isLoaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(He);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Se(r.isLoaded),Se(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData;for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.neighborData.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Le(Ie[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(Se(e.has(t)||He(r,t)<0),i(r,t),!0))),i(r,l.cornerPeerNeighbors[t]),i(r,l.cornerPeerNeighbors[(t+1)%4])}}e.clear(),this._updateTilesGeometries(t),Oe&&Ve&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.resetPendingUpdate(Ge.MERGE)){if(!t)return s.setPendingUpdate(Ge.MERGE),e.done;for(;n.parent?.resetPendingUpdate(Ge.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else s.resetPendingUpdate(Ge.SPLIT)&&(this._splitTile(s),a=!0,e.madeProgress());return!e.done&&n===s&&s.resetPendingUpdate(Ge.RENDERDATA)&&(this._updateRenderData(s),e.madeProgress()),e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Ge.GEOMETRY)&&(this._updateTileGeometryState(t),this._updateTileTexture(t,e),this.shortBatches&&this._batchUpdatePendingTileGeometries(),e.madeProgress()),e.done))),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Ze.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*Te}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){u(this._rootTiles)&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(!e.children[0])return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i])||t;return e.unsetChildren(),t}_purgeTile(e){const t=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),this._tilePool.release(e),t}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){Ee(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ge.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){_t.spatialReference=this.spatialReference,_t.extent=e.extent,_t.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",_t)}_createTile(e,t,i,r){Ee(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(Ge.SPLIT),s}get shortBatches(){return this.view.state.mode!==et.IDLE}_mergeTile(e){Ee(!e.hasPendingUpdate(Ge.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(Ee(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this.shortBatches&&this._batchUpdatePendingTileGeometries()),this._allTilesDirty=!0,++this._performanceInfo.numMerged}_loadChildren(e){Ee(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForGeometryUpdate(e),this._emitTileScaleChange(e,e.level+1),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._markTileToUpdate(t),this._emitTileScaleChange(t,t.level),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_unloadChildren(e){const t=e.children;if(t[0])for(let i=0;i<4;++i){const e=t[i];this._unloadChildren(e),this._unloadTile(e)}}_loadTile(e){e.load(),e.setPendingUpdate(Ge.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new ie(e.lij,e.extent,i);e.dataArrived(t,le.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=rt){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),De(s)||Ce(s))if(this._basemapLayerViewHandles.has(s.uid)&&!Ce(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(Pe(t)&&!X(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ue(e)||Ce(e))&&Ke(Je[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return be(e)?le.ELEVATION:le.MAP}_registerTiledLayerView(e){const t=[];if((Ue(e)||Ce(e))&&t.push(y((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ne.UNFADED)}))),Ce(e))return;const i=this._layerClassFromLayerView(e);t.push(y((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(y((()=>e.fullOpacity),(()=>this._updateTileTextures(ne.UNFADED)))),t.push(y((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!De(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===le.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of oe){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===le.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(le.MAP),e===ne.IMMEDIATE?this.renderer.updateTileTexture(t,Ge.TEXTURE_NOFADING):t.updateRenderData(le.MAP,e)})),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=Ze.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||xe(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(r),m(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===le.ELEVATION?be(i)?this._requestElevationTileData(e,i,r):Promise.reject():Pe(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(T(i))return;const s=this._layerIndexByUid[le.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer %d %s",le.ELEVATION,e.lij.toString())},s=i=>{m(i)||(this._dataMissing(e,le.ELEVATION,t,i),this.requestUpdate())};if(Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:fe,signal:i.signal}).then((e=>{if(!T(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:fe},i.signal))).then((e=>{e?r(new z(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ae(s),T(i)||(this._dataMissing(e,le.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),T(i)?Ae(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(xe(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(Me(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(je(t)&&Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(T(i))return l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);W(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(le.MAP,t.uid);u(r)?e.dataArrived(r,le.MAP,i):(Ae(i),l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this._rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this._rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this._rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this._rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return Ee(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e._rootTiles)&&e._rootTiles.length>0&&(e._mergeTile(e._rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){ut.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&ut.push(e)}));const t=ut.toArray();return Qe(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!Ve)return;const e=this._rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.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.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shading(){return this._shading}_updateShadingIfChanged(){const e=this.view?.map?.ground?.shading;e!==this._shading&&this._updateShading()}_updateShading(){const e=this.view?.map?.ground?.shading;this._shading=e,this.renderer&&(this.renderer.shading=e,this.renderer.setNeedsRender()),this._updateAllTileGeometries()}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateeCarree(){return this._isWebMercatorOnPlateeCarree}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(u(this.spatialReference)&&this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){ke(e)}enableWaterproofnessChecks(e){Be(e)}};e([S()],st.prototype,"_renderer",void 0),e([S()],st.prototype,"_hasPendingUpdates",void 0),e([S()],st.prototype,"_asyncWorkItems",void 0),e([S()],st.prototype,"_allTilesDirty",void 0),e([S()],st.prototype,"_allTilesSorted",void 0),e([S()],st.prototype,"_viewChanged",void 0),e([S({readOnly:!0})],st.prototype,"_watchUpdatingTracking",void 0),e([S()],st.prototype,"_frameTask",void 0),e([S({readOnly:!0})],st.prototype,"snapLevel",null),e([S({readOnly:!0})],st.prototype,"lodSnapping",null),e([S({constructOnly:!0})],st.prototype,"view",void 0),e([S()],st.prototype,"_userClippingExtent",null),e([S()],st.prototype,"_rootTilesExtent",void 0),e([S({readOnly:!0})],st.prototype,"extent",null),e([S({readOnly:!0})],st.prototype,"groundExtent",null),e([S({readOnly:!0})],st.prototype,"_tilingSchemeExtent",null),e([S({readOnly:!0})],st.prototype,"updating",null),e([S({readOnly:!0})],st.prototype,"running",null),e([S(ee)],st.prototype,"updatingProgress",void 0),e([S({readOnly:!0})],st.prototype,"updatingProgressValue",null),e([S()],st.prototype,"_maxNumUpdating",void 0),e([S()],st.prototype,"baseOpacity",null),e([S()],st.prototype,"hasCompositeBlendMode",void 0),e([S({readOnly:!0})],st.prototype,"overlayManager",void 0),e([S({readOnly:!0})],st.prototype,"viewingMode",null),e([S()],st.prototype,"maxTextureScale",void 0),e([S({readOnly:!0})],st.prototype,"ready",null),e([S({value:pe.FRONT_TO_BACK})],st.prototype,"renderOrder",null),e([S({readOnly:!0})],st.prototype,"rootTiles",null),e([S()],st.prototype,"_rootTiles",void 0),e([S({readOnly:!0})],st.prototype,"spatialReference",null),e([S({type:t})],st.prototype,"backgroundColor",null),e([S({value:!1})],st.prototype,"slicePlaneEnabled",null),e([S({readOnly:!0})],st.prototype,"tilingScheme",void 0),e([S({readOnly:!0})],st.prototype,"tilingSchemeLocked",null),e([S({readOnly:!0})],st.prototype,"tilingSchemeLogic",void 0),e([S({value:!0})],st.prototype,"velvetOverground",null),e([S()],st.prototype,"wireframe",null),e([S({value:!1})],st.prototype,"suspended",null),e([S()],st.prototype,"textureFadeDuration",null),e([S()],st.prototype,"visibleElevationBounds",void 0),e([S()],st.prototype,"rootTileElevationBounds",void 0),e([S()],st.prototype,"_layerViewsDirty",void 0),e([S()],st.prototype,"renderPatchBorders",null),e([S()],st.prototype,"visualizeNormals",null),e([S()],st.prototype,"renderingDisabled",null),st=e([L("esri.views.3d.terrain.TerrainSurface")],st);const at=st;function nt(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function lt(e){const t=e.children;if(!t[0])return!1;for(const i of t)if(i.shouldLoad)return!0;for(const i of t)if(lt(i))return!0;return!1}function ot(e){return e.isLeaf&&(e.parent?.shouldLoad??!1)}const ht=b(),dt=I(),pt=[0,0,0],ut=new _,ct={spatialReference:null,extent:I(),context:"ground"},_t={spatialReference:null,extent:null,scale:0};function gt(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}export{at as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{throwIfAborted as g,isAbortError as m,isAborted as T,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as y,syncAndInitial as v,sync as w,initial as E}from"../../../core/reactiveUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as L}from"../../../core/accessorSupport/decorators/subclass.js";import{m as D}from"../../../chunks/mat4.js";import{c as C}from"../../../chunks/mat4f64.js";import{c as P}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as b}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as x}from"../../../core/support/WatchUpdatingTracking.js";import{getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as M,projectPointToVector as j}from"../../../geometry/projection.js";import A from"../../../geometry/SpatialReference.js";import{create as I,equals as O,intersection as V,empty as k,expand as B,intersectsSphere as N}from"../../../geometry/support/aaBoundingRect.js";import{create as F,copy as G}from"../../../geometry/support/frustum.js";import{isPlateCarree as q}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as W}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as H}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as z}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as X}from"../../../layers/support/layerUtils.js";import{acquireDecoder as Q}from"../../../layers/support/LercDecoder.js";import{printAllocations as Y}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as $}from"../support/cameraUtils.js";import K from"../support/debugFlags.js";import{toBoundingRect as J}from"../support/extentUtils.js";import{ClientType as Z}from"../support/index.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{create as se}from"./ExtentHelper.js";import{LODSnapping as ae,TextureUpdate as ne}from"./interfaces.js";import{LayerClass as le,LayerClasses as oe}from"./LayerClass.js";import{OverlayManager as he}from"./OverlayManager.js";import{PlanarPatch as de}from"./PlanarPatch.js";import{RenderOrder as pe}from"./RenderOrder.js";import{SphericalPatch as ue}from"./SphericalPatch.js";import{SplitLimits as ce}from"./SplitLimits.js";import{MAX_ROOT_TILES as _e,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as ge,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as me,MAX_MEMORY_LOD_BIAS as Te,ELEVATION_NODATA_VALUE as fe}from"./TerrainConst.js";import{TerrainRenderer as ye,TransparencyMode as ve}from"./TerrainRenderer.js";import we from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as Ee,internalAssert as Se,oppositeEdge as Le,isSurfaceLayerView as De,isGroupLayerView as Ce,isMapTileLayerView as Pe,isBlendableLayerView as Ue,isElevationLayerView as be,isVectorTileLayerView as xe,useFetchTileForLayer as Re,isImageryTileLayerView as Me,isTileLayerView as je,releaseTileData as Ae,neighborEdgeIndices as Ie,ENABLE_TERRAIN_INTERNAL_CHECKS as Oe,ENABLE_WATERPROOFNESS_TESTS as Ve,enableTerrainInternalChecks as ke,enableTerrainWaterproofnessChecks as Be}from"./terrainUtils.js";import{Tile as Ne}from"./Tile.js";import{printAllocations as Fe}from"./TilePerLayerInfo.js";import{TileUpdate as Ge}from"./TileUpdate.js";import{IteratorPreorder as qe,IteratorPostorder as We,compareTilesByLij as He,hasLoadableSiblings as ze,sortTilesByPOI as Xe,sortTiles as Qe}from"./tileUtils.js";import{TilingSchemeLogic as Ye}from"./TilingSchemeLogic.js";import{UpsampleInfo as $e}from"./UpsampleInfo.js";import{isCompositeBlendMode as Ke,blendModeFromString as Je}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as Ze}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as et}from"../../support/RenderState.js";import{ImmediateTask as tt,TaskPriority as it,noBudget as rt}from"../../support/Scheduler.js";let st=class extends(a.EventedMixin(i)){constructor(e){super(e),this._iteratorPool=new c(qe,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new We,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new we,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new ce,this._frustum=F(),this._viewProjectionMatrix=C(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new x,this._frameTask=tt,this._allTiles=new _,this._upsampleInfoPool=new c($e),this._rootTilesExtent=I(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=A.WebMercator,this.visibleElevationBounds=new te(1/0,-1/0),this.rootTileElevationBounds=new te(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this.oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this._shading=!0,this._isWebMercator=!1,this._isWebMercatorOnPlateeCarree=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=Q(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(de):new c(ue);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new H(e.newCache("elevation-query")),this._set("overlayManager",new he({surface:this})),this._handles.add([y((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),y((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e))),y((()=>this.overlayManager.renderer.isEmpty),(()=>this._evaluateTransparency()))],"overlayManager"),this._renderer=new ye({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:R(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles}),this._handles.add([y((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?ne.UNFADED:ne.IMMEDIATE)}),v),y((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?ne.UNFADED:ne.IMMEDIATE)),v),y((()=>this.renderingDisabled),(()=>this.view?._stage?.renderer.setParameters({terrainRenderingEnabled:!this.renderingDisabled})),w),y((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),v),y((()=>this.snapLevel),(()=>this._viewChanged=!0),w),y((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),y((()=>K.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&K.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),E)]),this._extentHelper=se(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),i=new Ye({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(Z.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(Z.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(it.TERRAIN_SURFACE,this),this._handles.add([y((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),E),y((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),w),y((()=>this.extent),(()=>this._updateRootTiles()),E),this.view.on("resize",(()=>this._viewChangeUpdate())),y((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),v),y((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),E),y((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),w)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._handles.add([y((()=>this.view?.map.ground.shading),(()=>{this._updateShadingIfChanged()}))]),this._updateShading(),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache);const e=this.tilingSchemeLogic.layers;this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),e.destroy(),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Ne.prune(),this._treeDebugger=d(this._treeDebugger),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),Y(),Fe()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===ae.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(i&&t){const r=e.state.contentCamera;let s=$(e,r.eye,r.viewForward,r.up).tilt;s>90&&(s=180-s);const a=2*(s/90)**2,n=t.levelAtScale(i)-a;return Math.round(n)}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ae.ON:ae.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=I(),r=J(t,i,e)?i:null,s=this._get("extent");return O(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,I()),t=this._get("extent");return O(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager.updating)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._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}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this._rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get 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}set velvetOverground(e){this._renderer.velvetOverground=e,this._set("velvetOverground",e)}get wireframe(){return this._renderer.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.transparency===ve.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get textureFadeDuration(){return this.view.qualitySettings.tiledSurface.textureFadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this._rootTiles;if(p(s)||!s.length)return null;if(0===s[0].layerInfo[le.ELEVATION].length)return null;const a=ht;if(a[0]=e,a[1]=t,a[2]=i,!M(a,r,a,this._spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;return gt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[le.ELEVATION].length:0;if(!p(r)&&r.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,gt(r,e[t+0],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!j(e,ht,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(u(t))for(const i of t)if(i?.containsPoint(ht)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;ht[0]>t[2]&&(i+=1),ht[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}getSphereElevationBounds(e,t,i,r,s){if(ht[0]=e,ht[1]=t,ht[2]=i,ht[3]=r,!M(ht,s,ht,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&N(e.extent,ht))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},h=this._rootTiles;if(u(h))for(const l of h)o(l);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!j(e,ht,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;ht[3]=t;let i=null;const r=e=>{if(e&&N(e.extent,ht)){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(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?ve.Empty:ve.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?ve.Opaque:ve.Semitransparent,s=i!==r;return s&&(this._renderer.transparency=r,this.view?._stage?.renderer.setParameters({terrainTransparency:this._renderer.transparency})),s}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;Ee(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??A.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateeCarree=this._isWebMercator&&q(this.view?.renderSpatialReference),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles())}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return pt[0]=e,pt[1]=t,pt[2]=i,s.init(pt,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=dt;let s=t.rootTilesInExtent(e,i,5*_e);if(u(this._rootTiles)){if(s.length>_e)return void l.getLogger(this.declaredClass).warn(ge);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,nt);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>nt(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>_e&&(l.getLogger(this.declaredClass).warn(me),s=t.rootTilesInExtent(e,i,_e)),this._setRootTiles(s.map((e=>this._newRootTile(e))));O(i,this._rootTilesExtent)||(this._rootTilesExtent=I(i)),this._visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.isLoaded&&e.intersectsClippingArea));e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(He);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===Ge.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Ge.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(p(e))return;const t=ze(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e),e.setPendingUpdate(Ge.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBounds[0],r),s=Math.max(e.elevationBounds[1],s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._batchUpdatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new te(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;u(i)&&i.forEach((({elevationBounds:i})=>{e=Math.min(e,i[0]),t=Math.max(t,i[1])}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new 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?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=F()),G(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,G(this._frustum,e.frustum),D(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),P(this._eyePosRenderSR,t.eye),M(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(lt(e)?this._loadChildren(e):ot(e)&&this._loadParent(e))}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForGeometryUpdate(e){const t=this._pendingTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ge.TEXTURE_FADING)?Ge.TEXTURE_FADING:!!e.resetPendingUpdate(Ge.TEXTURE_NOFADING)&&Ge.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){const e=ct.extent;k(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),ct.spatialReference=this.spatialReference,this.emit("elevation-change",ct)}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._batchUpdatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed?this.requestUpdate():this.getUsedMemory(),this.notifyChange("updatingProgressValue")}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();t.reset(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;for(;!t.done;){const e=t.next(),a=e.shouldSplit(r,s,i);if(a!==Ge.SPLIT){if(e.resetPendingUpdate(Ge.SPLIT)&&e.updateAgentSuspension(),a===Ge.VSPLITMERGE&&e.updateAgents(le.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ge.MERGE),e.resetPendingUpdate(Ge.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);const i=this._viewProjectionMatrix;for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(i);t.remove()}}else e.resetPendingUpdate(Ge.MERGE),e.isLeaf&&(e.setPendingUpdate(Ge.SPLIT),t.skipSubtree()),e.rendered&&e.setPendingUpdate(Ge.RENDERDATA)}t.remove(),this.requestUpdate(),(this.shortBatches||!this.oneBatchPerFrameTask)&&this._batchUpdatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Xe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Se(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForGeometryUpdate(e))}_batchUpdatePendingTileGeometries(){const e=this._pendingTilesToUpdate;if(0===e.size)return;const t=Array.from(this._pendingTilesToUpdate.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea)),i=(i,r)=>{!r?.isLoaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(He);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Se(r.isLoaded),Se(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData;for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.neighborData.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Le(Ie[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(Se(e.has(t)||He(r,t)<0),i(r,t),!0))),i(r,l.cornerPeerNeighbors[t]),i(r,l.cornerPeerNeighbors[(t+1)%4])}}e.clear(),this._updateTilesGeometries(t),Oe&&Ve&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.resetPendingUpdate(Ge.MERGE)){if(!t)return s.setPendingUpdate(Ge.MERGE),e.done;for(;n.parent?.resetPendingUpdate(Ge.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else s.resetPendingUpdate(Ge.SPLIT)&&(this._splitTile(s),a=!0,e.madeProgress());return!e.done&&n===s&&s.resetPendingUpdate(Ge.RENDERDATA)&&(this._updateRenderData(s),e.madeProgress()),e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Ge.GEOMETRY)&&(this._updateTileGeometryState(t),this._updateTileTexture(t,e),this.shortBatches&&this._batchUpdatePendingTileGeometries(),e.madeProgress()),e.done))),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Ze.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*Te}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){u(this._rootTiles)&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(!e.children[0])return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i])||t;return e.unsetChildren(),t}_purgeTile(e){const t=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),this._tilePool.release(e),t}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){Ee(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ge.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){_t.spatialReference=this.spatialReference,_t.extent=e.extent,_t.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",_t)}_createTile(e,t,i,r){Ee(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(Ge.SPLIT),s}get shortBatches(){return this.view.state.mode!==et.IDLE}_mergeTile(e){Ee(!e.hasPendingUpdate(Ge.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(Ee(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this.shortBatches&&this._batchUpdatePendingTileGeometries()),this._allTilesDirty=!0,++this._performanceInfo.numMerged}_loadChildren(e){Ee(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForGeometryUpdate(e),this._emitTileScaleChange(e,e.level+1),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._markTileToUpdate(t),this._emitTileScaleChange(t,t.level),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_unloadChildren(e){const t=e.children;if(t[0])for(let i=0;i<4;++i){const e=t[i];this._unloadChildren(e),this._unloadTile(e)}}_loadTile(e){e.load(),e.setPendingUpdate(Ge.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new ie(e.lij,e.extent,i);e.dataArrived(t,le.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=rt){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),De(s)||Ce(s))if(this._basemapLayerViewHandles.has(s.uid)&&!Ce(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(Pe(t)&&!X(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ue(e)||Ce(e))&&Ke(Je[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return be(e)?le.ELEVATION:le.MAP}_registerTiledLayerView(e){const t=[];if((Ue(e)||Ce(e))&&t.push(y((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ne.UNFADED)}))),Ce(e))return;const i=this._layerClassFromLayerView(e);t.push(y((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(y((()=>e.fullOpacity),(()=>this._updateTileTextures(ne.UNFADED)))),t.push(y((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!De(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===le.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of oe){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===le.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(le.MAP),e===ne.IMMEDIATE?this.renderer.updateTileTexture(t,Ge.TEXTURE_NOFADING):t.updateRenderData(le.MAP,e)})),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=Ze.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||xe(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(r),m(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===le.ELEVATION?be(i)?this._requestElevationTileData(e,i,r):Promise.reject():Pe(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(T(i))return;const s=this._layerIndexByUid[le.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer %d %s",le.ELEVATION,e.lij.toString())},s=i=>{m(i)||(this._dataMissing(e,le.ELEVATION,t,i),this.requestUpdate())};if(Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:fe,signal:i.signal}).then((e=>{if(!T(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:fe},i.signal))).then((e=>{e?r(new z(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ae(s),T(i)||(this._dataMissing(e,le.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),T(i)?Ae(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(xe(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(Me(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(je(t)&&Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(T(i))return l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);W(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(le.MAP,t.uid);u(r)?e.dataArrived(r,le.MAP,i):(Ae(i),l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this._rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this._rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this._rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this._rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return Ee(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e._rootTiles)&&e._rootTiles.length>0&&(e._mergeTile(e._rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){ut.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&ut.push(e)}));const t=ut.toArray();return Qe(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!Ve)return;const e=this._rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.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.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shading(){return this._shading}_updateShadingIfChanged(){const e=this.view?.map?.ground?.shading;e!==this._shading&&this._updateShading()}_updateShading(){const e=this.view?.map?.ground?.shading;this._shading=e,this.renderer&&(this.renderer.shading=e,this.renderer.setNeedsRender()),this._updateAllTileGeometries()}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateeCarree(){return this._isWebMercatorOnPlateeCarree}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(u(this.spatialReference)&&this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){ke(e)}enableWaterproofnessChecks(e){Be(e)}};e([S()],st.prototype,"_renderer",void 0),e([S()],st.prototype,"_hasPendingUpdates",void 0),e([S()],st.prototype,"_asyncWorkItems",void 0),e([S()],st.prototype,"_allTilesDirty",void 0),e([S()],st.prototype,"_allTilesSorted",void 0),e([S()],st.prototype,"_viewChanged",void 0),e([S({readOnly:!0})],st.prototype,"_watchUpdatingTracking",void 0),e([S()],st.prototype,"_frameTask",void 0),e([S({readOnly:!0})],st.prototype,"snapLevel",null),e([S({readOnly:!0})],st.prototype,"lodSnapping",null),e([S({constructOnly:!0})],st.prototype,"view",void 0),e([S()],st.prototype,"_userClippingExtent",null),e([S()],st.prototype,"_rootTilesExtent",void 0),e([S({readOnly:!0})],st.prototype,"extent",null),e([S({readOnly:!0})],st.prototype,"groundExtent",null),e([S({readOnly:!0})],st.prototype,"_tilingSchemeExtent",null),e([S({readOnly:!0})],st.prototype,"updating",null),e([S({readOnly:!0})],st.prototype,"running",null),e([S(ee)],st.prototype,"updatingProgress",void 0),e([S({readOnly:!0})],st.prototype,"updatingProgressValue",null),e([S()],st.prototype,"_maxNumUpdating",void 0),e([S()],st.prototype,"baseOpacity",null),e([S()],st.prototype,"hasCompositeBlendMode",void 0),e([S({readOnly:!0})],st.prototype,"overlayManager",void 0),e([S({readOnly:!0})],st.prototype,"viewingMode",null),e([S()],st.prototype,"maxTextureScale",void 0),e([S({readOnly:!0})],st.prototype,"ready",null),e([S({value:pe.FRONT_TO_BACK})],st.prototype,"renderOrder",null),e([S({readOnly:!0})],st.prototype,"rootTiles",null),e([S()],st.prototype,"_rootTiles",void 0),e([S({readOnly:!0})],st.prototype,"spatialReference",null),e([S({type:t})],st.prototype,"backgroundColor",null),e([S({value:!1})],st.prototype,"slicePlaneEnabled",null),e([S({readOnly:!0})],st.prototype,"tilingScheme",void 0),e([S({readOnly:!0})],st.prototype,"tilingSchemeLocked",null),e([S({readOnly:!0})],st.prototype,"tilingSchemeLogic",void 0),e([S({value:!0})],st.prototype,"velvetOverground",null),e([S()],st.prototype,"wireframe",null),e([S({value:!1})],st.prototype,"suspended",null),e([S()],st.prototype,"textureFadeDuration",null),e([S()],st.prototype,"visibleElevationBounds",void 0),e([S()],st.prototype,"rootTileElevationBounds",void 0),e([S()],st.prototype,"_layerViewsDirty",void 0),e([S()],st.prototype,"renderPatchBorders",null),e([S()],st.prototype,"visualizeNormals",null),e([S()],st.prototype,"renderingDisabled",null),st=e([L("esri.views.3d.terrain.TerrainSurface")],st);const at=st;function nt(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function lt(e){const t=e.children;if(!t[0])return!1;for(const i of t)if(i.shouldLoad)return!0;for(const i of t)if(lt(i))return!0;return!1}function ot(e){return e.isLeaf&&(e.parent?.shouldLoad??!1)}const ht=b(),dt=I(),pt=[0,0,0],ut=new _,ct={spatialReference:null,extent:I(),context:"ground"},_t={spatialReference:null,extent:null,scale:0};function gt(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}export{at as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{nextHighestPowerOfTwo as e}from"../../../core/mathUtils.js";import{disposeMaybe as t,releaseMaybe as r,isNone as s,isSome as o}from"../../../core/maybe.js";import{s as a,c as i}from"../../../chunks/vec2.js";import{Z as n}from"../../../chunks/vec2f64.js";import{isBaseLayer as c,isGroupLayer as u}from"../../../layers/support/layerUtils.js";import{ImageWithType as p}from"../support/StreamDataLoader.js";import{BlendLayersPassParameters as l}from"./BlendLayersTechnique.js";import{TextureUpdate as h}from"./interfaces.js";import{LayerClass as d}from"./LayerClass.js";import{isBlendableLayerView as m,isVectorTileLayerView as _,isVectorTileRenderInfo as f,isImageryTileRenderInfo as y,isRasterTileRenderInfo as T,isTextureTileRenderInfo as g}from"./terrainUtils.js";import{ActivationTime as x}from"./TextureFader.js";import{TextureReference as b}from"./TextureReference.js";import{TileCompositor as k}from"./TileCompositor.js";import w from"./TileTexture.js";import{TileUpdate as I}from"./TileUpdate.js";import{blendModeFromString as P}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BaseOpacityMode as A,BlendLayersOutput as D}from"../webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js";import{createColorTexture as E,createEmptyTexture as M}from"../webgl-engine/lib/glUtil3D.js";import{TextureSamplingMode as R,TextureType as L,PixelFormat as C,PixelType as j,TextureWrapMode as N}from"../../webgl/enums.js";import{Texture as O}from"../../webgl/Texture.js";class U{constructor(e,t,r,s){this.start=e,this.end=t,this.blendMode=r,this.opacity=s}}class B{constructor(e,t,r){this._rctx=e,this.tileSize=t,this._techniqueRepository=r,this._passParameters=new l,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1,this._blackTex=null,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._composition=new k(this._rctx,this._techniqueRepository),this._blackTex=new w(E(this._rctx,[0,0,0,1])),this._ensureBackgroundTexture(this.tileSize)}dispose(){this._composition=t(this._composition),this._backgroundTexture=r(this._backgroundTexture),this._blackTex=r(this._blackTex)}get backgroundIsGrid(){return s(this._backgroundColor)}get backgroundColor(){return this._backgroundColor}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let a=0,i=0,n=this.tileSize,p=!1;const l=r.view.state.hidpiContent?r.view.state.pixelRatio:1;let h=!1;Y.clear(),Z.length=0;const f=e.layerInfo[d.MAP];let y=f.length,T=0;for(;T<f.length;T++){const t=r.layerViewByIndex(T,d.MAP),g=t.layer.opacity;X[T]=g;const x=t.fullOpacity;if(v[T]=x,c(t.layer)&&y>=f.length&&(y=T),m(t)){V[T]=t.layer.blendMode;let e="normal"!==t.layer.blendMode;if(u(t.layer.parent)){const r=S(t.layer.parent);o(r)&&""!==r&&(e=q(t.layer.parent)||e)}e&&(h=e,p=!1)}if(0===g&&!h){f[T].pendingUpdates&=~(I.TEXTURE_NOFADING&I.TEXTURE_FADING);continue}++i;const b=F(e,T);if(b){if(f[T].pendingUpdates&=~(I.TEXTURE_NOFADING&I.TEXTURE_FADING),u(t.layer.parent)){const e=S(t.layer.parent);o(e)&&""!==e&&z(t.layer.parent,T)}_(t)?n=Math.max(n,this.tileSize*l):1===s&&1===x&&(t.isOpaque||this._dataToTexture(b)&&b.sourceLayerInfo.data.descriptor.isOpaque)&&(p=!0),++a}}n=G(n);const g=n/this.tileSize,x=T-1;this._ensureBackgroundTexture(this.tileSize),0!==a?1===a&&!h&&this._useLayerTexture(e,x,y,v[x])||this._composeMapLayers(e,t,x,y,X,V,n,g,!p||h,Y,h):this._useBackgroundTexture(e,i)}_ensureBackgroundTexture(e){s(this._backgroundTexture)&&(this._backgroundTexture=this._buildTexture(e),this._backgroundDirty=!0),this._backgroundDirty&&(this._composition.bind(e),this._passParameters.offset=n,this._passParameters.scale=1,this._passParameters.opacity=1,o(this.backgroundColor)&&(this._passParameters.backgroundColor=this.backgroundColor),this._composition.drawBackground(this._passParameters,o(this.backgroundColor)),this._composition.copyFBOToTexture(this._backgroundTexture),this._composition.unbind(),this._backgroundDirty=!1)}_useBackgroundTexture(e,t){let r=x.Immediate;(e.surface.view.layerViewManager.updating||t>0)&&(r=x.Delayed);const a=e.renderData;this._backgroundTexture&&s(a.textureReference)&&(r=x.Immediate),a.setTextureReference(o(this._backgroundTexture)?new b(this._backgroundTexture,h.FADING,J,e.surface.baseOpacity,0,1):null,r)}_useLayerTexture(e,t,r,s){const o=t<r,a=o?1:e.surface.baseOpacity,i=o?e.surface.baseOpacity:1,n=F(e,t);return!!this._dataToTexture(n)&&(e.renderData.setTextureReference(new b(n.sourceLayerInfo.data,h.FADING,n,a,i,s)),!0)}_composeMapLayers(e,t,r,s,o,a,i,c,u,p,l){this._composition.ensureBuffer(i);const h=e.surface.baseOpacity;let d=!1,m=R.LINEAR_MIPMAP_LINEAR,_=!1,T=0;for(let b=r;b>=0;b--){const t=F(e,b);if(!t)continue;if(0===o[b]&&!l)continue;const r=b<s&&h<1&&!d;this._passParameters.baseOpacity=r?h:1;const g=this._passParameters.baseOpacity<1?A.Required:A.NotRequired;r&&(d=!0);let x=!1;p.forEach((e=>{e.start===b&&(Z.push(e),this._composition.openGroup(i),x=!0)}));const k=0===T,w=x?D.GroupBackgroundComposite:u&&k?this.backgroundIsGrid?D.GridComposite:D.ColorComposite:D.Composite,I=P[a[b]];for(f(t)?(this._passParameters.opacity=o[b],_=this._composition.drawVectorData(this._passParameters,w,i,I,g,t,c,this.tileSize,_)):y(t)?(this._passParameters.opacity=o[b],this._composition.drawImageryTileData(this._passParameters,w,i,I,g,t),this._hasNearestInterpolation(t)&&(m=R.NEAREST)):this._dataToTexture(t)&&(this._passParameters.texture=t.sourceLayerInfo.data.texture,this._passParameters.offset=t.offset,this._passParameters.scale=t.scale,this._passParameters.opacity=o[b],this._composition.drawRasterData(this._passParameters,w,i,I,g));Z.length>0&&Z[Z.length-1].end===b;){const e=Z.pop();this._passParameters.opacity=e.opacity,this._passParameters.offset=n,this._passParameters.scale=1;const t=u&&k?this.backgroundIsGrid?D.GridComposite:D.ColorComposite:D.Composite;this._composition.drawGroup(this._passParameters,t,i,P[e.blendMode],g)}T++}const g=e.renderData,x=g.ensureTexture(i,(()=>this._buildTexture(i,m)));this._composition.copyFBOToTexture(x),this._composition.unbind(),g.setTextureReference(new b(x,t,J,d?1:h,0,1))}_hasNearestInterpolation(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}_dataToTexture(e){if(T(e)){const t=e.sourceLayerInfo;t.data=this._buildTexture(t.data),e.tile.setMemoryDirty()}return g(e)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t=R.LINEAR_MIPMAP_LINEAR){if(s(e))return null;const r={target:L.TEXTURE_2D,pixelFormat:C.RGBA,dataType:j.UNSIGNED_BYTE,wrapMode:N.CLAMP_TO_EDGE,samplingMode:t,maxAnisotropy:this._maxAnisotropy,preMultiplyAlpha:!0,flipped:!0,hasMipmap:!0},o=this._rctx;let a;if("number"==typeof e)r.width=r.height=e,a=new w(new O(o,r));else if(e instanceof p)r.isOpaque=e.isOpaque,a=new w(new O(o,r,e.image)),e.release();else try{r.width=e.width,r.height=e.height,a=new w(new O(o,r,e))}catch(n){a=new w(M(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const i=o.bindTexture(a.texture,O.TEXTURE_UNIT_FOR_UPDATES);return a.generateMipmap(),o.bindTexture(i,O.TEXTURE_UNIT_FOR_UPDATES),a}get test(){return{backgroundTexture:this._backgroundTexture}}}function G(t){const r=e(t),s=r*r,o=t*t;if(s===o)return t;const a=r/2;return s-o<o-a*a?r:a}function F(e,t){H.layerIndex=t;const r=e.layerInfo[d.MAP][t];if(o(r.data))return a(H.offset,0,0),H.tile=e,H.scale=1,H.sourceLod=e.lij,H.sourceLayerInfo=r,H;const s=r.upsampleInfo;if(o(s)){const e=s.tile.layerInfo[d.MAP][t];return H.tile=s.tile,i(H.offset,s.offset),H.scale=s.scale,H.sourceLod=s.tile.lij,H.sourceLayerInfo=e,H}return null}function S(e){return e.get("uid")}function q(e){let t="normal"!==e.blendMode;return u(e.parent)&&(t=q(e.parent)||t),t}function z(e,t){u(e.parent)&&z(e.parent,t);const r=S(e);if(o(r)&&""!==r){const s=Y.get(r);s?s.start=t:Y.set(r,new U(t,t,e.blendMode,e.opacity))}}const X=new Array,v=new Array,V=new Array,Y=new Map,Z=new Array,H={tile:null,sourceLayerInfo:null,sourceLod:null,offset:[0,0],scale:1,layerIndex:0},J={offset:[0,0],scale:1};export{U as GroupInfo,B as TileRenderer};
5
+ import{nextHighestPowerOfTwo as e}from"../../../core/mathUtils.js";import{disposeMaybe as t,releaseMaybe as r,isNone as s,isSome as o}from"../../../core/maybe.js";import{s as a,c as i}from"../../../chunks/vec2.js";import{Z as n}from"../../../chunks/vec2f64.js";import{isBaseLayer as c,isGroupLayer as u}from"../../../layers/support/layerUtils.js";import{ImageWithType as l}from"../support/StreamDataLoader.js";import{BlendLayersPassParameters as p}from"./BlendLayersTechnique.js";import{TextureUpdate as h}from"./interfaces.js";import{LayerClass as d}from"./LayerClass.js";import{isBlendableLayerView as m,isVectorTileLayerView as _,isVectorTileRenderInfo as f,isImageryTileRenderInfo as y,isRasterTileRenderInfo as T,isTextureTileRenderInfo as g}from"./terrainUtils.js";import{ActivationTime as x}from"./TextureFader.js";import{TextureReference as b}from"./TextureReference.js";import{TileCompositor as k}from"./TileCompositor.js";import w from"./TileTexture.js";import{TileUpdate as I}from"./TileUpdate.js";import{blendModeFromString as P}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BaseOpacityMode as A,BlendLayersOutput as D}from"../webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js";import{createColorTexture as E,createEmptyTexture as M}from"../webgl-engine/lib/glUtil3D.js";import{ContextType as R}from"../../webgl/context-util.js";import{TextureSamplingMode as L,TextureType as j,PixelFormat as C,PixelType as N,TextureWrapMode as O}from"../../webgl/enums.js";import{Texture as U}from"../../webgl/Texture.js";class B{constructor(e,t,r,s){this.start=e,this.end=t,this.blendMode=r,this.opacity=s}}class G{constructor(e,t,r){this._rctx=e,this.tileSize=t,this._techniqueRepository=r,this._passParameters=new p,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1,this._blackTex=null,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._composition=new k(this._rctx,this._techniqueRepository),this._blackTex=new w(E(this._rctx,[0,0,0,1])),this._ensureBackgroundTexture(this.tileSize)}dispose(){this._composition=t(this._composition),this._backgroundTexture=r(this._backgroundTexture),this._blackTex=r(this._blackTex)}get backgroundIsGrid(){return s(this._backgroundColor)}get backgroundColor(){return this._backgroundColor}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let a=0,i=0,n=this.tileSize,l=!1;const p=r.view.state.contentPixelRatio;let h=!1;Y.clear(),Z.length=0;const f=e.layerInfo[d.MAP];let y=f.length,T=0;for(;T<f.length;T++){const t=r.layerViewByIndex(T,d.MAP),g=t.layer.opacity;v[T]=g;const x=t.fullOpacity;if(V[T]=x,c(t.layer)&&y>=f.length&&(y=T),m(t)){W[T]=t.layer.blendMode;let e="normal"!==t.layer.blendMode;if(u(t.layer.parent)){const r=q(t.layer.parent);o(r)&&""!==r&&(e=z(t.layer.parent)||e)}e&&(h=e,l=!1)}if(0===g&&!h){f[T].pendingUpdates&=~(I.TEXTURE_NOFADING&I.TEXTURE_FADING);continue}++i;const b=S(e,T);if(b){if(f[T].pendingUpdates&=~(I.TEXTURE_NOFADING&I.TEXTURE_FADING),u(t.layer.parent)){const e=q(t.layer.parent);o(e)&&""!==e&&X(t.layer.parent,T)}_(t)?n=Math.max(n,this.tileSize*p):1===s&&1===x&&(t.isOpaque||this._dataToTexture(b)&&b.sourceLayerInfo.data.descriptor.isOpaque)&&(l=!0),++a}}this._rctx.type===R.WEBGL1&&(n=F(n));const g=n/this.tileSize,x=T-1;this._ensureBackgroundTexture(this.tileSize),0!==a?1===a&&!h&&this._useLayerTexture(e,x,y,V[x])||this._composeMapLayers(e,t,x,y,v,W,n,g,!l||h,Y,h):this._useBackgroundTexture(e,i)}_ensureBackgroundTexture(e){s(this._backgroundTexture)&&(this._backgroundTexture=this._buildTexture(e),this._backgroundDirty=!0),this._backgroundDirty&&(this._composition.bind(e),this._passParameters.offset=n,this._passParameters.scale=1,this._passParameters.opacity=1,o(this.backgroundColor)&&(this._passParameters.backgroundColor=this.backgroundColor),this._composition.drawBackground(this._passParameters,o(this.backgroundColor)),this._composition.copyFBOToTexture(this._backgroundTexture),this._composition.unbind(),this._backgroundDirty=!1)}_useBackgroundTexture(e,t){let r=x.Immediate;(e.surface.view.layerViewManager.updating||t>0)&&(r=x.Delayed);const a=e.renderData;this._backgroundTexture&&s(a.textureReference)&&(r=x.Immediate),a.setTextureReference(o(this._backgroundTexture)?new b(this._backgroundTexture,h.FADING,J,e.surface.baseOpacity,0,1):null,r)}_useLayerTexture(e,t,r,s){const o=t<r,a=o?1:e.surface.baseOpacity,i=o?e.surface.baseOpacity:1,n=S(e,t);return!!this._dataToTexture(n)&&(e.renderData.setTextureReference(new b(n.sourceLayerInfo.data,h.FADING,n,a,i,s)),!0)}_composeMapLayers(e,t,r,s,o,a,i,c,u,l,p){this._composition.ensureBuffer(i);const h=e.surface.baseOpacity;let d=!1,m=L.LINEAR_MIPMAP_LINEAR,_=!1,T=0;for(let b=r;b>=0;b--){const t=S(e,b);if(!t)continue;if(0===o[b]&&!p)continue;const r=b<s&&h<1&&!d;this._passParameters.baseOpacity=r?h:1;const g=this._passParameters.baseOpacity<1?A.Required:A.NotRequired;r&&(d=!0);let x=!1;l.forEach((e=>{e.start===b&&(Z.push(e),this._composition.openGroup(i),x=!0)}));const k=0===T,w=x?D.GroupBackgroundComposite:u&&k?this.backgroundIsGrid?D.GridComposite:D.ColorComposite:D.Composite,I=P[a[b]];for(f(t)?(this._passParameters.opacity=o[b],_=this._composition.drawVectorData(this._passParameters,w,i,I,g,t,c,this.tileSize,_)):y(t)?(this._passParameters.opacity=o[b],this._composition.drawImageryTileData(this._passParameters,w,i,I,g,t),this._hasNearestInterpolation(t)&&(m=L.NEAREST)):this._dataToTexture(t)&&(this._passParameters.texture=t.sourceLayerInfo.data.texture,this._passParameters.offset=t.offset,this._passParameters.scale=t.scale,this._passParameters.opacity=o[b],this._composition.drawRasterData(this._passParameters,w,i,I,g));Z.length>0&&Z[Z.length-1].end===b;){const e=Z.pop();this._passParameters.opacity=e.opacity,this._passParameters.offset=n,this._passParameters.scale=1;const t=u&&k?this.backgroundIsGrid?D.GridComposite:D.ColorComposite:D.Composite;this._composition.drawGroup(this._passParameters,t,i,P[e.blendMode],g)}T++}const g=e.renderData,x=g.ensureTexture(i,(()=>this._buildTexture(i,m)));this._composition.copyFBOToTexture(x),this._composition.unbind(),g.setTextureReference(new b(x,t,J,d?1:h,0,1))}_hasNearestInterpolation(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}_dataToTexture(e){if(T(e)){const t=e.sourceLayerInfo;t.data=this._buildTexture(t.data),e.tile.setMemoryDirty()}return g(e)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t=L.LINEAR_MIPMAP_LINEAR){if(s(e))return null;const r={target:j.TEXTURE_2D,pixelFormat:C.RGBA,dataType:N.UNSIGNED_BYTE,wrapMode:O.CLAMP_TO_EDGE,samplingMode:t,maxAnisotropy:this._maxAnisotropy,preMultiplyAlpha:!0,flipped:!0,hasMipmap:!0},o=this._rctx;let a;if("number"==typeof e)r.width=r.height=e,a=new w(new U(o,r));else if(e instanceof l)r.isOpaque=e.isOpaque,a=new w(new U(o,r,e.image)),e.release();else try{r.width=e.width,r.height=e.height,a=new w(new U(o,r,e))}catch(n){a=new w(M(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const i=o.bindTexture(a.texture,U.TEXTURE_UNIT_FOR_UPDATES);return a.generateMipmap(),o.bindTexture(i,U.TEXTURE_UNIT_FOR_UPDATES),a}get test(){return{backgroundTexture:this._backgroundTexture}}}function F(t){const r=e(t),s=r*r,o=t*t;if(s===o)return t;const a=r/2;return s-o<o-a*a?r:a}function S(e,t){H.layerIndex=t;const r=e.layerInfo[d.MAP][t];if(o(r.data))return a(H.offset,0,0),H.tile=e,H.scale=1,H.sourceLod=e.lij,H.sourceLayerInfo=r,H;const s=r.upsampleInfo;if(o(s)){const e=s.tile.layerInfo[d.MAP][t];return H.tile=s.tile,i(H.offset,s.offset),H.scale=s.scale,H.sourceLod=s.tile.lij,H.sourceLayerInfo=e,H}return null}function q(e){return e.get("uid")}function z(e){let t="normal"!==e.blendMode;return u(e.parent)&&(t=z(e.parent)||t),t}function X(e,t){u(e.parent)&&X(e.parent,t);const r=q(e);if(o(r)&&""!==r){const s=Y.get(r);s?s.start=t:Y.set(r,new B(t,t,e.blendMode,e.opacity))}}const v=new Array,V=new Array,W=new Array,Y=new Map,Z=new Array,H={tile:null,sourceLayerInfo:null,sourceLod:null,offset:[0,0],scale:1,layerIndex:0},J={offset:[0,0],scale:1};export{B as GroupInfo,G as TileRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as s}from"../../../../../core/maybe.js";import{f as a,t as e,e as t}from"../../../../../chunks/mat3.js";import{c as r}from"../../../../../chunks/mat3f64.js";import{c as i}from"../../../../../chunks/mat4.js";import{s as h,c as m}from"../../../../../chunks/vec3.js";import{c as n}from"../../../../../chunks/vec3f64.js";import{MaterialPassParameters as o,ShadowMapPassParameters as P,HighlightPassParameters as l,MaterialSubPass as d,RenderPassIdentifier as p}from"./AllRenderPasses.js";import{RenderPass as c,RenderPassSorting as u}from"./RenderPass.js";import{ShaderOutput as _}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as g}from"../util/TwoVectorPosition.js";import{union as b}from"../../lib/depthRange.js";import{RenderSlot as w}from"../../lib/RenderSlot.js";class f{constructor(s,a){this.rctx=s,this.shaderTechniqueRepository=a,this.canRender=!0,this._materialPassParameters=new o,this._shadowPassParameters=new P,this._highlightPassParameters=new l,this._systems=new Set,this._passes={materialOpaque:new c(s,a),materialTransparent:new c(s,a,u.BackToFront),materialIntegratedMesh:new c(s,a),shadowMap:new c(s,a),highlight:new c(s,a),highlightIntegratedMesh:new c(s,a),highlightShadowMap:new c(s,a),defaultShadowMap:new c(s,a)}}register(s){this._systems.add(s)}prepareRender(s){if(0!==this._systems.size){for(const s of Object.values(this._passes))s.prepareSubmit();this._systems.forEach((a=>a.submit(this._passes,s.bindParameters)));for(const s of Object.values(this._passes))s.finishSubmit();this.shaderTechniqueRepository.frameUpdate()}}render(s){if(0!==this._systems.size)switch(this._configure(s),s.bindParameters.slot){case w.OPAQUE_MATERIAL:switch(s.output){case _.Color:return this._materialPassParameters.subPass=d.Color,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Depth:return this._materialPassParameters.subPass=d.Depth,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Normal:return this._materialPassParameters.subPass=d.Normal,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Highlight:return this._passes.highlight.dispatch(this._highlightPassParameters,s.bindParameters);case _.Shadow:return this._passes.shadowMap.dispatch(this._shadowPassParameters,s.bindParameters);case _.ShadowHighlight:return this._passes.highlightShadowMap.dispatch(this._shadowPassParameters,s.bindParameters);case _.ShadowExludeHighlight:return this._passes.defaultShadowMap.dispatch(this._shadowPassParameters,s.bindParameters);case _.ObjectAndLayerIdColor:return this._materialPassParameters.subPass=d.ObjectAndLayerIdColor,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters)}return;case w.TRANSPARENT_MATERIAL:switch(s.output){case _.Color:return this._materialPassParameters.subPass=d.Color,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.Alpha:return this._materialPassParameters.subPass=d.Alpha,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.Depth:return this._materialPassParameters.subPass=d.Depth,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.Normal:return this._materialPassParameters.subPass=d.Normal,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.ObjectAndLayerIdColor:return this._materialPassParameters.subPass=d.ObjectAndLayerIdColor,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters)}return;case w.INTEGRATED_MESH:switch(s.output){case _.Color:return this._materialPassParameters.subPass=d.Color,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters);case _.Depth:return this._materialPassParameters.subPass=d.Depth,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters);case _.Normal:return this._materialPassParameters.subPass=d.Normal,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters);case _.Highlight:return this._passes.highlightIntegratedMesh.dispatch(this._highlightPassParameters,s.bindParameters);case _.ObjectAndLayerIdColor:return this._materialPassParameters.subPass=d.ObjectAndLayerIdColor,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters)}return}}notifyDirty(){this._context.requestRender()}slots(){return[w.OPAQUE_MATERIAL,w.TRANSPARENT_MATERIAL,w.INTEGRATED_MESH]}initializeRenderContext(s){this._context=s}uninitializeRenderContext(){}queryDepthRange(a){const e={near:1/0,far:-1/0};return this._systems.forEach((t=>{const r=t.queryShadowCasterDepthRange(a);s(r)&&b(e,r,e)})),e}_configure(s){const a=s.output===_.Shadow||s.output===_.ShadowHighlight||s.output===_.ShadowExludeHighlight?this._shadowPassParameters:s.output===_.Highlight?this._highlightPassParameters:this._materialPassParameters;this._updateParameters(s,a)}_updateParameters(s,r){const n=s.bindParameters.camera,o=n.viewInverseTransposeMatrix;h(T,o[3],o[7],o[11]),A.set(T),m(r.transformWorldFromViewTH,A.high),m(r.transformWorldFromViewTL,A.low),m(r.slicePlaneLocalOrigin,T),a(r.transformViewFromCameraRelativeRS,n.viewMatrix),i(r.transformProjFromView,n.projectionMatrix),r.identifier===p.Material&&(this._materialPassParameters.transparent=s.bindParameters.slot===w.TRANSPARENT_MATERIAL,this._materialPassParameters.integratedMesh=s.bindParameters.slot===w.INTEGRATED_MESH,e(R,r.transformViewFromCameraRelativeRS),t(r.transformNormalViewFromGlobal,R))}get needsHighlight(){return this._passes.highlight.count>0||this._passes.highlightIntegratedMesh.count>0}get needsTransparentPass(){return this._passes.materialTransparent.count>0}}const T=n(),R=r(),A=new g;export{f as RenderPassManager};
5
+ import{isSome as s}from"../../../../../core/maybe.js";import{f as a,t as e,e as t}from"../../../../../chunks/mat3.js";import{c as r}from"../../../../../chunks/mat3f64.js";import{c as i}from"../../../../../chunks/mat4.js";import{s as h,c as m}from"../../../../../chunks/vec3.js";import{c as n}from"../../../../../chunks/vec3f64.js";import{MaterialPassParameters as o,ShadowMapPassParameters as P,HighlightPassParameters as l,MaterialSubPass as d,RenderPassIdentifier as p}from"./AllRenderPasses.js";import{RenderPass as c,RenderPassSorting as u}from"./RenderPass.js";import{ShaderOutput as _}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as g}from"../util/TwoVectorPosition.js";import{union as b}from"../../lib/depthRange.js";import{RenderSlot as w}from"../../lib/RenderSlot.js";class f{constructor(s,a){this.rctx=s,this.shaderTechniqueRepository=a,this.canRender=!0,this._materialPassParameters=new o,this._shadowPassParameters=new P,this._highlightPassParameters=new l,this._systems=new Set,this._passes={materialOpaque:new c(s,a),materialTransparent:new c(s,a,u.BackToFront),materialIntegratedMesh:new c(s,a),shadowMap:new c(s,a),highlight:new c(s,a),highlightIntegratedMesh:new c(s,a),highlightShadowMap:new c(s,a),defaultShadowMap:new c(s,a)}}register(s){this._systems.add(s)}prepareRender(s){if(0!==this._systems.size){for(const s of Object.values(this._passes))s.prepareSubmit();this._systems.forEach((a=>a.submit(this._passes,s.bindParameters)));for(const s of Object.values(this._passes))s.finishSubmit();this.shaderTechniqueRepository.frameUpdate()}}render(s){if(0!==this._systems.size)switch(this._configure(s),s.bindParameters.slot){case w.OPAQUE_MATERIAL:switch(s.output){case _.Color:return this._materialPassParameters.subPass=d.Color,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Depth:return this._materialPassParameters.subPass=d.Depth,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Normal:return this._materialPassParameters.subPass=d.Normal,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Highlight:return this._passes.highlight.dispatch(this._highlightPassParameters,s.bindParameters);case _.Shadow:return this._passes.shadowMap.dispatch(this._shadowPassParameters,s.bindParameters);case _.ShadowHighlight:return this._passes.highlightShadowMap.dispatch(this._shadowPassParameters,s.bindParameters);case _.ShadowExcludeHighlight:return this._passes.defaultShadowMap.dispatch(this._shadowPassParameters,s.bindParameters);case _.ObjectAndLayerIdColor:return this._materialPassParameters.subPass=d.ObjectAndLayerIdColor,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters)}return;case w.TRANSPARENT_MATERIAL:switch(s.output){case _.Color:return this._materialPassParameters.subPass=d.Color,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.Alpha:return this._materialPassParameters.subPass=d.Alpha,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.Depth:return this._materialPassParameters.subPass=d.Depth,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.Normal:return this._materialPassParameters.subPass=d.Normal,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.ObjectAndLayerIdColor:return this._materialPassParameters.subPass=d.ObjectAndLayerIdColor,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters)}return;case w.INTEGRATED_MESH:switch(s.output){case _.Color:return this._materialPassParameters.subPass=d.Color,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters);case _.Depth:return this._materialPassParameters.subPass=d.Depth,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters);case _.Normal:return this._materialPassParameters.subPass=d.Normal,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters);case _.Highlight:return this._passes.highlightIntegratedMesh.dispatch(this._highlightPassParameters,s.bindParameters);case _.ObjectAndLayerIdColor:return this._materialPassParameters.subPass=d.ObjectAndLayerIdColor,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters)}return}}notifyDirty(){this._context.requestRender()}slots(){return[w.OPAQUE_MATERIAL,w.TRANSPARENT_MATERIAL,w.INTEGRATED_MESH]}initializeRenderContext(s){this._context=s}uninitializeRenderContext(){}queryDepthRange(a){const e={near:1/0,far:-1/0};return this._systems.forEach((t=>{const r=t.queryShadowCasterDepthRange(a);s(r)&&b(e,r,e)})),e}_configure(s){const a=s.output===_.Shadow||s.output===_.ShadowHighlight||s.output===_.ShadowExcludeHighlight?this._shadowPassParameters:s.output===_.Highlight?this._highlightPassParameters:this._materialPassParameters;this._updateParameters(s,a)}_updateParameters(s,r){const n=s.bindParameters.camera,o=n.viewInverseTransposeMatrix;h(T,o[3],o[7],o[11]),A.set(T),m(r.transformWorldFromViewTH,A.high),m(r.transformWorldFromViewTL,A.low),m(r.slicePlaneLocalOrigin,T),a(r.transformViewFromCameraRelativeRS,n.viewMatrix),i(r.transformProjFromView,n.projectionMatrix),r.identifier===p.Material&&(this._materialPassParameters.transparent=s.bindParameters.slot===w.TRANSPARENT_MATERIAL,this._materialPassParameters.integratedMesh=s.bindParameters.slot===w.INTEGRATED_MESH,e(R,r.transformViewFromCameraRelativeRS),t(r.transformNormalViewFromGlobal,R))}get needsHighlight(){return this._passes.highlight.count>0||this._passes.highlightIntegratedMesh.count>0}get needsTransparentPass(){return this._passes.materialTransparent.count>0}}const T=n(),R=r(),A=new g;export{f as RenderPassManager};
@@ -4,6 +4,6 @@ See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
5
  import{ShaderOutput as e}from"./ShaderOutput.js";import{VertexPosition as r}from"./attributes/VertexPosition.glsl.js";import{Float2PassUniform as a}from"../shaderModules/Float2PassUniform.js";import{glsl as o}from"../shaderModules/interfaces.js";function t(e){e.varyings.add("linearDepth","float")}function i(e){e.vertex.uniforms.add(new a("nearFar",((e,r)=>r.camera.nearFar)))}function n(e){e.vertex.code.add(o`float calculateLinearDepth(vec2 nearFar,float z) {
6
6
  return (-z - nearFar[0]) / (nearFar[1] - nearFar[0]);
7
- }`)}function d(a,d){const{vertex:s}=a;switch(d.output){case e.Color:if(d.receiveShadows)return t(a),void s.code.add(o`void forwardLinearDepth() { linearDepth = gl_Position.w; }`);break;case e.Depth:case e.Shadow:case e.ShadowHighlight:case e.ShadowExludeHighlight:return a.include(r,d),t(a),i(a),n(a),void s.code.add(o`void forwardLinearDepth() {
7
+ }`)}function d(a,d){const{vertex:s}=a;switch(d.output){case e.Color:if(d.receiveShadows)return t(a),void s.code.add(o`void forwardLinearDepth() { linearDepth = gl_Position.w; }`);break;case e.Depth:case e.Shadow:case e.ShadowHighlight:case e.ShadowExcludeHighlight:return a.include(r,d),t(a),i(a),n(a),void s.code.add(o`void forwardLinearDepth() {
8
8
  linearDepth = calculateLinearDepth(nearFar, vPosition_view.z);
9
9
  }`)}s.code.add(o`void forwardLinearDepth() {}`)}export{d as ForwardLinearDepth,n as addCalculateLinearDepth,t as addLinearDepth,i as addNearFar};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- var h;!function(h){h[h.Color=0]="Color",h[h.Depth=1]="Depth",h[h.Normal=2]="Normal",h[h.Shadow=3]="Shadow",h[h.ShadowHighlight=4]="ShadowHighlight",h[h.ShadowExludeHighlight=5]="ShadowExludeHighlight",h[h.Highlight=6]="Highlight",h[h.Alpha=7]="Alpha",h[h.ObjectAndLayerIdColor=8]="ObjectAndLayerIdColor",h[h.COUNT=9]="COUNT"}(h||(h={}));export{h as ShaderOutput};
5
+ var h;!function(h){h[h.Color=0]="Color",h[h.Depth=1]="Depth",h[h.Normal=2]="Normal",h[h.Shadow=3]="Shadow",h[h.ShadowHighlight=4]="ShadowHighlight",h[h.ShadowExcludeHighlight=5]="ShadowExcludeHighlight",h[h.Highlight=6]="Highlight",h[h.Alpha=7]="Alpha",h[h.ObjectAndLayerIdColor=8]="ObjectAndLayerIdColor",h[h.COUNT=9]="COUNT"}(h||(h={}));export{h as ShaderOutput};
@@ -2,7 +2,7 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as o}from"../../../../../../core/maybe.js";import{I as r}from"../../../../../../chunks/mat4f64.js";import{addNearFar as e}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as t}from"../ShaderOutput.js";import{SliceDraw as i}from"../Slice.glsl.js";import{Transform as a}from"../Transform.glsl.js";import{NormalAttribute as s,NormalAttributeType as l}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as d}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as n}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as c}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as u}from"../output/OutputDepth.glsl.js";import{OutputHighlight as m}from"../output/OutputHighlight.glsl.js";import{VisualVariables as p}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as v}from"../util/AlphaDiscard.glsl.js";import{addProjViewLocalOrigin as f}from"../util/View.glsl.js";import{glsl as g}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as h}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as x}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as j}from"../../../lib/basicInterfaces.js";function b(b,O){const{vertex:w,fragment:C}=b,T=O.hasModelTransformation;T&&w.uniforms.add(new h("model",(e=>o(e.modelTransformation)?e.modelTransformation:r)));const V=O.hasColorTexture&&O.alphaDiscardMode!==j.Opaque;switch(O.output){case t.Depth:case t.Shadow:case t.ShadowHighlight:case t.ShadowExludeHighlight:case t.ObjectAndLayerIdColor:f(w,O),b.include(a,O),b.include(n,O),b.include(p,O),b.include(u,O),b.include(i,O),b.include(d,O),e(b),b.varyings.add("depth","float"),V&&C.uniforms.add(new x("tex",(o=>o.texture))),w.code.add(g`
5
+ import{isSome as o}from"../../../../../../core/maybe.js";import{I as r}from"../../../../../../chunks/mat4f64.js";import{addNearFar as e}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as t}from"../ShaderOutput.js";import{SliceDraw as i}from"../Slice.glsl.js";import{Transform as a}from"../Transform.glsl.js";import{NormalAttribute as s,NormalAttributeType as l}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as d}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as n}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as c}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as u}from"../output/OutputDepth.glsl.js";import{OutputHighlight as m}from"../output/OutputHighlight.glsl.js";import{VisualVariables as p}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as v}from"../util/AlphaDiscard.glsl.js";import{addProjViewLocalOrigin as f}from"../util/View.glsl.js";import{glsl as g}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as h}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as x}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as j}from"../../../lib/basicInterfaces.js";function b(b,O){const{vertex:w,fragment:C}=b,T=O.hasModelTransformation;T&&w.uniforms.add(new h("model",(e=>o(e.modelTransformation)?e.modelTransformation:r)));const V=O.hasColorTexture&&O.alphaDiscardMode!==j.Opaque;switch(O.output){case t.Depth:case t.Shadow:case t.ShadowHighlight:case t.ShadowExcludeHighlight:case t.ObjectAndLayerIdColor:f(w,O),b.include(a,O),b.include(n,O),b.include(p,O),b.include(u,O),b.include(i,O),b.include(d,O),e(b),b.varyings.add("depth","float"),V&&C.uniforms.add(new x("tex",(o=>o.texture))),w.code.add(g`
6
6
  void main(void) {
7
7
  vpos = calculateVPos();
8
8
  vpos = subtractOrigin(vpos);
@@ -2,7 +2,7 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{ShaderOutput as t}from"../ShaderOutput.js";import{RgbaFloatEncoding as a}from"../util/RgbaFloatEncoding.glsl.js";import{glsl as e}from"../../shaderModules/interfaces.js";function o(o,l){switch(o.fragment.include(a),l.output){case t.Shadow:case t.ShadowHighlight:case t.ShadowExludeHighlight:o.extensions.add("GL_OES_standard_derivatives"),o.fragment.code.add(e`float _calculateFragDepth(const in float depth) {
5
+ import{ShaderOutput as t}from"../ShaderOutput.js";import{RgbaFloatEncoding as a}from"../util/RgbaFloatEncoding.glsl.js";import{glsl as e}from"../../shaderModules/interfaces.js";function o(o,l){switch(o.fragment.include(a),l.output){case t.Shadow:case t.ShadowHighlight:case t.ShadowExcludeHighlight:o.extensions.add("GL_OES_standard_derivatives"),o.fragment.code.add(e`float _calculateFragDepth(const in float depth) {
6
6
  const float SLOPE_SCALE = 2.0;
7
7
  const float BIAS = 20.0 * .000015259;
8
8
  float m = max(abs(dFdx(depth)), abs(dFdy(depth)));