@arcgis/core 4.34.0-next.75 → 4.34.0-next.77

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 (269) hide show
  1. package/Basemap.js +1 -1
  2. package/Ground.js +1 -1
  3. package/applications/Components/arcadeEditorUtils.d.ts +4 -0
  4. package/applications/Components/arcadeEditorUtils.js +5 -0
  5. package/applications/Components/featureUtils.d.ts +1 -0
  6. package/applications/Components/featureUtils.js +1 -1
  7. package/arcade/Feature.js +1 -1
  8. package/arcade/Pixel.js +1 -1
  9. package/arcade/Voxel.js +1 -1
  10. package/arcade/arcadeAsyncRuntime.js +1 -1
  11. package/arcade/arcadeCompiler.js +1 -1
  12. package/arcade/arcadeRuntime.js +1 -1
  13. package/arcade/featureset/support/FeatureSetIterator.js +1 -1
  14. package/arcade/functions/feature.js +1 -1
  15. package/arcade/functions/featuresetbase.js +1 -1
  16. package/arcade/functions/geometry.js +1 -1
  17. package/assets/esri/core/workers/RemoteClient.js +1 -1
  18. package/assets/esri/core/workers/chunks/025f1d78dfa5ec93178b.js +1 -0
  19. package/assets/esri/core/workers/chunks/050429f516149ce3b517.js +1 -0
  20. package/assets/esri/core/workers/chunks/0652d7e525d99e39c957.js +1 -0
  21. package/assets/esri/core/workers/chunks/0668eee42b3169e1bf66.js +1 -0
  22. package/assets/esri/core/workers/chunks/07a355a9c95154971aab.js +1 -0
  23. package/assets/esri/core/workers/chunks/0dd6b8b3e634bb5f0ca7.js +1 -0
  24. package/assets/esri/core/workers/chunks/124f8757ea18bfd158ec.js +1 -0
  25. package/assets/esri/core/workers/chunks/16d66770ef841564ee3f.js +1 -0
  26. package/assets/esri/core/workers/chunks/17103e6542aae53c7301.js +1 -0
  27. package/assets/esri/core/workers/chunks/1990162dcf73601d54f7.js +1 -0
  28. package/assets/esri/core/workers/chunks/{5c30252c1bb8350cae5f.js → 1c52999a6392370844a6.js} +1 -1
  29. package/assets/esri/core/workers/chunks/20850b0fdb55fb17bc90.js +1 -0
  30. package/assets/esri/core/workers/chunks/{6a1b652ccbf58ac44658.js → 23e17b745adf71a5efc7.js} +1 -1
  31. package/assets/esri/core/workers/chunks/2605062e44f2d4e73f14.js +1 -0
  32. package/assets/esri/core/workers/chunks/29a86d51407310bb7745.js +1 -0
  33. package/assets/esri/core/workers/chunks/2a2a925c45d5fd58628b.js +1 -0
  34. package/assets/esri/core/workers/chunks/2fe96bf7dedef11a3b63.js +1 -0
  35. package/assets/esri/core/workers/chunks/3452ba299f6ce0582f09.js +1 -0
  36. package/assets/esri/core/workers/chunks/36a006c55766f9540bfc.js +1 -0
  37. package/assets/esri/core/workers/chunks/{18641332bee3e9b9c44a.js → 388482cea4b9fdeaf06e.js} +1 -1
  38. package/assets/esri/core/workers/chunks/3b23c37e5bc552dc81d4.js +1 -0
  39. package/assets/esri/core/workers/chunks/{9325000c87295c473291.js → 3b2ef975831eb75b40fb.js} +1 -1
  40. package/assets/esri/core/workers/chunks/3ff3e1507220d3869c76.js +1 -0
  41. package/assets/esri/core/workers/chunks/43818bf53dd5445a7bdb.js +1 -0
  42. package/assets/esri/core/workers/chunks/4823e4522bd7379d858e.js +1 -0
  43. package/assets/esri/core/workers/chunks/49e6202da7a20f06c661.js +353 -0
  44. package/assets/esri/core/workers/chunks/4d47187bc0821413492d.js +1 -0
  45. package/assets/esri/core/workers/chunks/{b818b5e392d5eb7c7e70.js → 4e6e8dda6c12f6fbed8e.js} +1 -1
  46. package/assets/esri/core/workers/chunks/5019f1b8186a65a0313b.js +1 -0
  47. package/assets/esri/core/workers/chunks/5102c20645d9708c34b4.js +1 -0
  48. package/assets/esri/core/workers/chunks/512dcd6e34e217029391.js +1 -0
  49. package/assets/esri/core/workers/chunks/5248581d23ada240c78d.js +1 -0
  50. package/assets/esri/core/workers/chunks/614a00a3179f8fe23f45.js +1 -0
  51. package/assets/esri/core/workers/chunks/{e12e8d69c05c182b6a69.js → 61bb39597ccf89f99a72.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{5477ff0ce432c9e5b3ab.js → 6201356f7f91e5c06425.js} +1 -1
  53. package/assets/esri/core/workers/chunks/6271a706ac3fcba91432.js +1 -0
  54. package/assets/esri/core/workers/chunks/6593b419339e7598b760.js +1 -0
  55. package/assets/esri/core/workers/chunks/{51ddda291bbbf5db9905.js → 65e279516170ddbd4a65.js} +1 -1
  56. package/assets/esri/core/workers/chunks/67fdc8074cdcf374af9a.js +1 -0
  57. package/assets/esri/core/workers/chunks/6dafb2b95bae552c1cc2.js +1 -0
  58. package/assets/esri/core/workers/chunks/7680d4d739f7aa3f7ae1.js +1 -0
  59. package/assets/esri/core/workers/chunks/7889a909394c61a9d3e0.js +1 -0
  60. package/assets/esri/core/workers/chunks/79e965e8f7cf822b4f45.js +1 -0
  61. package/assets/esri/core/workers/chunks/804e3b3df375177e6c86.js +1 -0
  62. package/assets/esri/core/workers/chunks/81a8addcb858086ff9ee.js +1 -0
  63. package/assets/esri/core/workers/chunks/83065bef261314f9b2c5.js +1 -0
  64. package/assets/esri/core/workers/chunks/8a5e40f48a8265fd1b42.js +1 -0
  65. package/assets/esri/core/workers/chunks/8bd6c27a93a697a7fa3d.js +1 -0
  66. package/assets/esri/core/workers/chunks/8c94448a44fb27054a22.js +1 -0
  67. package/assets/esri/core/workers/chunks/92d0e0155563c6355079.js +1 -0
  68. package/assets/esri/core/workers/chunks/930322c9790572bd0c49.js +1 -0
  69. package/assets/esri/core/workers/chunks/96a14689815bec741308.js +1 -0
  70. package/assets/esri/core/workers/chunks/97d71459ad72b4b780a3.js +1 -0
  71. package/assets/esri/core/workers/chunks/9835c579edfc08125d31.js +1 -0
  72. package/assets/esri/core/workers/chunks/9971de3f38a55735cec9.js +1 -0
  73. package/assets/esri/core/workers/chunks/99ac292a858bbedc6a89.js +1 -0
  74. package/assets/esri/core/workers/chunks/9ce599dc1d385e6893c1.js +1 -0
  75. package/assets/esri/core/workers/chunks/{fec572f03f9514244972.js → a05a7df07b74e1957538.js} +1 -1
  76. package/assets/esri/core/workers/chunks/a0edff37fd4a3f2cb2eb.js +1 -0
  77. package/assets/esri/core/workers/chunks/a7e649b3b02e664ada80.js +1 -0
  78. package/assets/esri/core/workers/chunks/a8a79a5c804ef715aa94.js +1 -0
  79. package/assets/esri/core/workers/chunks/{10ec10ca361842efce92.js → ab005fe84952f0676020.js} +1 -1
  80. package/assets/esri/core/workers/chunks/acb49f3d2b783e81a215.js +1 -0
  81. package/assets/esri/core/workers/chunks/adc61d88c3c6936ad75a.js +1 -0
  82. package/assets/esri/core/workers/chunks/afa3ca2bd2648774f133.js +1 -0
  83. package/assets/esri/core/workers/chunks/afb76f9d6abedef771df.js +1 -0
  84. package/assets/esri/core/workers/chunks/b168b6ffc16cd509d316.js +1 -0
  85. package/assets/esri/core/workers/chunks/b19d723d09f5bea9ca27.js +1 -0
  86. package/assets/esri/core/workers/chunks/b246ed6d86c2c8df56fb.js +1 -0
  87. package/assets/esri/core/workers/chunks/b4a053063e6022080d31.js +1 -0
  88. package/assets/esri/core/workers/chunks/b4ba7f8ea81522ad1e2e.js +1 -0
  89. package/assets/esri/core/workers/chunks/b8d02f1b73c374767a5f.js +1 -0
  90. package/assets/esri/core/workers/chunks/b97f224972f1b1abaee8.js +1 -0
  91. package/assets/esri/core/workers/chunks/b9e725d2b5a7d0132663.js +1 -0
  92. package/assets/esri/core/workers/chunks/ba6452acee3d6defb37e.js +1 -0
  93. package/assets/esri/core/workers/chunks/bbb3b32affde9ea78534.js +1 -0
  94. package/assets/esri/core/workers/chunks/bbb585f0b484ab5eabb3.js +1 -0
  95. package/assets/esri/core/workers/chunks/bc83bcfe123525d21884.js +1 -0
  96. package/assets/esri/core/workers/chunks/c799f1c03cb22ef52f5f.js +1 -0
  97. package/assets/esri/core/workers/chunks/cac5732f9dfece4bf2c5.js +1 -0
  98. package/assets/esri/core/workers/chunks/cafc19bf2caaf7a8c2e8.js +1 -0
  99. package/assets/esri/core/workers/chunks/cc7423413747566f56e2.js +1 -0
  100. package/assets/esri/core/workers/chunks/ccd157ede169b93eea65.js +1 -0
  101. package/assets/esri/core/workers/chunks/ce0bf0d0cd9e9a90093b.js +1 -0
  102. package/assets/esri/core/workers/chunks/ce49ff6bf20cff349726.js +1 -0
  103. package/assets/esri/core/workers/chunks/d1657a29321adb259166.js +1 -0
  104. package/assets/esri/core/workers/chunks/d2b69f91eb85b561fe01.js +1 -0
  105. package/assets/esri/core/workers/chunks/d51e8eeb1e1eb0605cc9.js +1 -0
  106. package/assets/esri/core/workers/chunks/d69bd6b5d781a6c527d1.js +1 -0
  107. package/assets/esri/core/workers/chunks/d7fc8ea2ff527a09f4b9.js +1 -0
  108. package/assets/esri/core/workers/chunks/d8494617cebc68e50d35.js +1 -0
  109. package/assets/esri/core/workers/chunks/d89832617bac4890893e.js +1 -0
  110. package/assets/esri/core/workers/chunks/{d55c55d39a253630d228.js → db2396bf062468ee8b60.js} +1 -1
  111. package/assets/esri/core/workers/chunks/e4833b718a813a8d125b.js +1 -0
  112. package/assets/esri/core/workers/chunks/{b5f197e24982f6e14468.js → e7af5caab9aa9b6a12e3.js} +3 -3
  113. package/assets/esri/core/workers/chunks/e81386199a6db9a50fd3.js +1 -0
  114. package/assets/esri/core/workers/chunks/ecac5ca00c742bfb5898.js +1 -0
  115. package/assets/esri/core/workers/chunks/f45c343527709f6f91c2.js +1 -0
  116. package/assets/esri/core/workers/chunks/f5710ced8d38f9a90fc5.js +1 -0
  117. package/assets/esri/core/workers/chunks/f592c4e5e1746d4619db.js +1 -0
  118. package/assets/esri/core/workers/chunks/f8d2c52cc51d5f1bbce2.js +1 -0
  119. package/assets/esri/core/workers/chunks/{0d946a226b846b3c0849.js → fc06014fb484fc8c697e.js} +1 -1
  120. package/assets/esri/core/workers/chunks/feed74ed275f21a68a1b.js +1 -0
  121. package/assets/esri/core/workers/chunks/ffee8cc83d703c1dc0c0.js +1 -0
  122. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  123. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  124. package/chunks/Compositing.glsl.js +4 -3
  125. package/chunks/cameraUtilsSpherical.js +1 -1
  126. package/chunks/lyr3DMain.js +1 -1
  127. package/chunks/lyr3DWorker.js +1 -1
  128. package/config.js +1 -1
  129. package/core/sql.d.ts +1 -0
  130. package/geometry/support/heightModelInfoUtils.js +1 -1
  131. package/geometry/support/normalizeUtils.js +1 -1
  132. package/geometry/support/spatialReferenceUtils.js +1 -1
  133. package/interfaces.d.ts +45 -0
  134. package/kernel.js +1 -1
  135. package/layers/GaussianSplatLayer.js +1 -1
  136. package/layers/Layer.js +1 -1
  137. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  138. package/layers/Lyr3DWorkerHandle.js +1 -1
  139. package/layers/catalog/catalogUtils.js +1 -1
  140. package/layers/mixins/ScaleRangeLayer.js +1 -1
  141. package/layers/support/tiles3DUtils.js +1 -1
  142. package/networks/CircuitManager.js +1 -1
  143. package/networks/support/Circuit.js +1 -1
  144. package/networks/support/CircuitSection.js +1 -1
  145. package/networks/support/Subcircuit.js +1 -1
  146. package/package.json +1 -1
  147. package/support/LayersMixin.js +1 -1
  148. package/support/TablesMixin.js +1 -1
  149. package/support/arcadeUtils.js +1 -1
  150. package/support/modeUtils.js +1 -1
  151. package/support/revision.js +1 -1
  152. package/symbols/support/symbolUtils.js +1 -1
  153. package/views/2d/layers/MediaLayerView2D.js +1 -1
  154. package/views/2d/layers/TileLayerView2D.js +1 -1
  155. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
  156. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  157. package/views/3d/layers/Lyr3DWorker.js +1 -1
  158. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  159. package/views/3d/support/cameraUtils.js +1 -1
  160. package/views/3d/support/cameraUtilsSpherical.js +1 -1
  161. package/{layers/support/GaussianSplatAtlasPageAllocator.js → views/3d/support/gaussianSplatting/GaussianSplatAtlasPages.js} +1 -1
  162. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +5 -0
  163. package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +5 -0
  164. package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +5 -0
  165. package/views/3d/support/gaussianSplatting/GaussianTile.js +5 -0
  166. package/views/3d/terrain/OverlayManager.js +1 -1
  167. package/views/3d/terrain/TerrainSurface.js +1 -1
  168. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +12 -13
  169. package/views/3d/webgl-engine/lib/CompositingHelper.js +1 -1
  170. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  171. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  172. package/views/3d/webgl-engine/lib/edgeRendering/strokes.js +1 -1
  173. package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
  174. package/views/3d/webgl-engine/shaders/CompositingTechnique.js +1 -1
  175. package/views/3d/webgl-engine/shaders/CompositingTechniqueConfiguration.js +1 -1
  176. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/LineOffset.glsl.js +10 -11
  177. package/views/VideoView.js +1 -1
  178. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  179. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  180. package/widgets/support/widget.js +1 -1
  181. package/assets/esri/core/workers/chunks/03fac1122eb73bb14d2d.js +0 -1
  182. package/assets/esri/core/workers/chunks/0434a490326c0de47c22.js +0 -1
  183. package/assets/esri/core/workers/chunks/0618ea8bf9da93d713b1.js +0 -1
  184. package/assets/esri/core/workers/chunks/06b65105b15abf4d0fbf.js +0 -1
  185. package/assets/esri/core/workers/chunks/06bd58c219678315cf5c.js +0 -1
  186. package/assets/esri/core/workers/chunks/0751f539db31bdb5caec.js +0 -1
  187. package/assets/esri/core/workers/chunks/0b71100fa1e7ca706dbb.js +0 -1
  188. package/assets/esri/core/workers/chunks/181b3564a0e3939020bc.js +0 -1
  189. package/assets/esri/core/workers/chunks/19228ab0fe7944c554e5.js +0 -1
  190. package/assets/esri/core/workers/chunks/199a17b0a0f75cbaed16.js +0 -1
  191. package/assets/esri/core/workers/chunks/19c1f1431c0b2f4525a2.js +0 -1
  192. package/assets/esri/core/workers/chunks/28a2f74d4a449386d082.js +0 -1
  193. package/assets/esri/core/workers/chunks/2a19a4d7d1c580121065.js +0 -1
  194. package/assets/esri/core/workers/chunks/2afafaf40293d5ab1d8e.js +0 -1
  195. package/assets/esri/core/workers/chunks/2c399991e8627baa51b3.js +0 -1
  196. package/assets/esri/core/workers/chunks/2f44848916051f5501eb.js +0 -1
  197. package/assets/esri/core/workers/chunks/356c96fad88558be9054.js +0 -1
  198. package/assets/esri/core/workers/chunks/37ff19a9c5c99bd4e7c7.js +0 -1
  199. package/assets/esri/core/workers/chunks/38e7d1c6987aaa9b520b.js +0 -1
  200. package/assets/esri/core/workers/chunks/3bf99037befdedd75cb4.js +0 -1
  201. package/assets/esri/core/workers/chunks/3d2629357242492afcfa.js +0 -1
  202. package/assets/esri/core/workers/chunks/3e9c3e7c5cf7c0afbc80.js +0 -1
  203. package/assets/esri/core/workers/chunks/3fecfe4f8ca2a5fd7360.js +0 -1
  204. package/assets/esri/core/workers/chunks/43095bed5456251940b9.js +0 -1
  205. package/assets/esri/core/workers/chunks/433c4dc666a6b2c99063.js +0 -353
  206. package/assets/esri/core/workers/chunks/451761c7bd2da530e1d0.js +0 -1
  207. package/assets/esri/core/workers/chunks/48449abe795cb7a831eb.js +0 -1
  208. package/assets/esri/core/workers/chunks/4bc091770bab38874848.js +0 -1
  209. package/assets/esri/core/workers/chunks/52286d4135b8395a3400.js +0 -1
  210. package/assets/esri/core/workers/chunks/540506802776f77e47f3.js +0 -1
  211. package/assets/esri/core/workers/chunks/56f54d007b0da0d908aa.js +0 -1
  212. package/assets/esri/core/workers/chunks/5879cebb22157b0b4998.js +0 -1
  213. package/assets/esri/core/workers/chunks/5c4ba165816809e06340.js +0 -1
  214. package/assets/esri/core/workers/chunks/5f239972cb95afdfa77a.js +0 -1
  215. package/assets/esri/core/workers/chunks/61896e64e9ef49b4bb1b.js +0 -1
  216. package/assets/esri/core/workers/chunks/6531f33d6710960079e9.js +0 -1
  217. package/assets/esri/core/workers/chunks/6963ded8428cc8d51d85.js +0 -1
  218. package/assets/esri/core/workers/chunks/6c3ae96c6ef764fb9552.js +0 -1
  219. package/assets/esri/core/workers/chunks/6e59ba2afd444eb4be18.js +0 -1
  220. package/assets/esri/core/workers/chunks/7430c462c350fdd26349.js +0 -1
  221. package/assets/esri/core/workers/chunks/76ec3d2646ba64e3442f.js +0 -1
  222. package/assets/esri/core/workers/chunks/7aaa6b318195d7342e6c.js +0 -1
  223. package/assets/esri/core/workers/chunks/7e746427375e83fc4351.js +0 -1
  224. package/assets/esri/core/workers/chunks/810e4c16c6eae420508b.js +0 -1
  225. package/assets/esri/core/workers/chunks/8b587affaaa0b1e4368c.js +0 -1
  226. package/assets/esri/core/workers/chunks/8bc8caa384b24af12411.js +0 -1
  227. package/assets/esri/core/workers/chunks/8e428b0f33ef4688415e.js +0 -1
  228. package/assets/esri/core/workers/chunks/8fc13e0e1a5a8f3e4798.js +0 -1
  229. package/assets/esri/core/workers/chunks/90540fdfb0c5f68aa959.js +0 -1
  230. package/assets/esri/core/workers/chunks/925ad2665c2fe0f47cc3.js +0 -1
  231. package/assets/esri/core/workers/chunks/92d5b0559e128d62fbda.js +0 -1
  232. package/assets/esri/core/workers/chunks/9304c3cdf732745577fd.js +0 -1
  233. package/assets/esri/core/workers/chunks/93b2e0a300b2758a1ca4.js +0 -1
  234. package/assets/esri/core/workers/chunks/9421389888d4d9e4e809.js +0 -1
  235. package/assets/esri/core/workers/chunks/98c94a99e2e04d5ae65f.js +0 -1
  236. package/assets/esri/core/workers/chunks/9c35860439948638cb8f.js +0 -1
  237. package/assets/esri/core/workers/chunks/a0a519f498e9ea7623ff.js +0 -1
  238. package/assets/esri/core/workers/chunks/a25b75de1bca1dd21941.js +0 -1
  239. package/assets/esri/core/workers/chunks/a2baeb9fa805c3537049.js +0 -1
  240. package/assets/esri/core/workers/chunks/a33e1a031ba9f028023d.js +0 -1
  241. package/assets/esri/core/workers/chunks/ad3ebd4f05cc673140f3.js +0 -1
  242. package/assets/esri/core/workers/chunks/b03dcbc31bccb9fdf9fe.js +0 -1
  243. package/assets/esri/core/workers/chunks/b0de01f8c9b1c3182e0c.js +0 -1
  244. package/assets/esri/core/workers/chunks/b6c6f82df3b60c2f831f.js +0 -1
  245. package/assets/esri/core/workers/chunks/b7f5a26ff3a73c64552d.js +0 -1
  246. package/assets/esri/core/workers/chunks/bd2dc1282c49125ede89.js +0 -1
  247. package/assets/esri/core/workers/chunks/bd4e64d6e73cd4db9695.js +0 -1
  248. package/assets/esri/core/workers/chunks/c07507a42def2bd2a222.js +0 -1
  249. package/assets/esri/core/workers/chunks/c34a164a8ece4cb33e81.js +0 -1
  250. package/assets/esri/core/workers/chunks/c7ba8f2aca0fbd6ceded.js +0 -1
  251. package/assets/esri/core/workers/chunks/c908184d747d33366881.js +0 -1
  252. package/assets/esri/core/workers/chunks/d1711256493d55eca523.js +0 -1
  253. package/assets/esri/core/workers/chunks/e086b835a98b71a46825.js +0 -1
  254. package/assets/esri/core/workers/chunks/e3f2cdf5d71a7040894b.js +0 -1
  255. package/assets/esri/core/workers/chunks/e54df2128039425a9090.js +0 -1
  256. package/assets/esri/core/workers/chunks/e58c5c8639aa837c84d1.js +0 -1
  257. package/assets/esri/core/workers/chunks/e6e4e2fb9568319c6207.js +0 -1
  258. package/assets/esri/core/workers/chunks/e92d9e0ac789bcf1cdf4.js +0 -1
  259. package/assets/esri/core/workers/chunks/eb0a5d592f5805836203.js +0 -1
  260. package/assets/esri/core/workers/chunks/eccb4550edc4752cf41a.js +0 -1
  261. package/assets/esri/core/workers/chunks/ee391a41144855fc625d.js +0 -1
  262. package/assets/esri/core/workers/chunks/f060a52a9b69eb250d63.js +0 -1
  263. package/assets/esri/core/workers/chunks/f3ef59991c577ff5e825.js +0 -1
  264. package/assets/esri/core/workers/chunks/f749e2a89a14ab89ae59.js +0 -1
  265. package/assets/esri/core/workers/chunks/f7f5c4f30e5a0ddbf9a4.js +0 -1
  266. package/assets/esri/core/workers/chunks/fb0f729eff2f2911d6c3.js +0 -1
  267. package/assets/esri/core/workers/chunks/fdf2b980e8a8aa47ce91.js +0 -1
  268. package/assets/esri/core/workers/chunks/fe24c6d61a50898549a5.js +0 -1
  269. package/layers/support/gaussianSplatUtils.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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as i,difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as n}from"../../../core/Evented.js";import"../../../core/has.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import u from"../../../core/ObjectPool.js";import p from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as _}from"../../../core/promiseUtils.js";import{watch as m,syncAndInitial as f,sync as y,initial as T}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../core/unitUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{q as C,i as b,c as x}from"../../../chunks/vec32.js";import{create as E}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as P,radiusModifier as U}from"../../../geometry/ellipsoidUtils.js";import D from"../../../geometry/SpatialReference.js";import{getProjector as M}from"../../../geometry/projection/projectors.js";import{projectPointToVector as R}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as j}from"../../../geometry/projection/projectVectorToVector.js";import{create as B,equals as I,intersection as k,intersectsSphere as A,empty as V,expand as q}from"../../../geometry/support/aaBoundingRect.js";import{copy as O,create as G}from"../../../geometry/support/frustum.js";import{isPlateCarree as N}from"../../../geometry/support/spatialReferenceUtils.js";import{m as F,c as W,n as H,o as $,e as Q}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as z}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as Y}from"../../../layers/support/layerUtils.js";import{debugFlags as X}from"../support/debugFlags.js";import{ElevationRange as K}from"../support/ElevationRange.js";import{toBoundingRect as J}from"../support/extentUtils.js";import{updatingProgress as Z}from"../support/updatingProperties.js";import{ElevationBounds as ee}from"./ElevationBounds.js";import{ElevationData as te,sampleElevation as ie}from"./ElevationData.js";import{ElevationUpdateEventImplementation as re}from"./ElevationUpdateEvent.js";import{create as se}from"./ExtentHelper.js";import{LayerClasses as ae}from"./LayerClass.js";import{OverlayManager as ne}from"./OverlayManager.js";import{PlanarPatch as le}from"./PlanarPatch.js";import{ScaleRangeQueries as oe}from"./ScaleRangeQueries.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{SplitLimits as de}from"./SplitLimits.js";import{maxRootTiles as ue,tooManyRootTilesAfterChangeError as pe,tooManyRootTilesForLayerError as ce,maxTileNeighborLevelDelta as ge,maxMemoryLodBias as _e}from"./TerrainConst.js";import{TerrainRenderer as me}from"./TerrainRenderer.js";import fe from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as ye,isVectorTileLayerView as Te,neighborEdgeIndices as ve,internalAssert as we,oppositeEdge as Se,isSurfaceLayerView as Ce,isGroupLayerView as be,isMapTileLayerView as xe,isBlendableLayerView as Ee,isElevationLayerView as Le,releaseTerrainData as Pe,enableTerrainInternalChecks as Ue,oppositeCorner as De,enableWaterproofTests as Me,enableInternalTerrainChecks as Re,enableTerrainWaterproofChecks as je,neighborCornerIndices as Be}from"./terrainUtils.js";import{Tile as Ie,lijEquals as ke}from"./Tile.js";import{printAllocations as Ae}from"./TilePerLayerInfo.js";import{sortTiles as Ve,IteratorPreorder as qe,IteratorPostorder as Oe,compareTilesByLij as Ge,hasLoadableSiblings as Ne,sortTilesByPOI as Fe}from"./tileUtils.js";import{TilingSchemeLogic as We}from"./TilingSchemeLogic.js";import{UpsampleInfo as He}from"./UpsampleInfo.js";import{isCompositeBlendMode as $e,blendModeFromString as Qe}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as ze}from"../../support/layerViewUtils.js";import{ImmediateTask as Ye,TaskPriority as Xe,noBudget as Ke}from"../../support/Scheduler.js";import{TextureCompressionTracker as Je}from"../../support/TextureCompressionTracker.js";import{Yield as Ze}from"../../support/Yield.js";var et;let tt=class extends n{static{et=this}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Ve(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){const{_allTiles:e,tilingScheme:t}=this;if(0===e.length)return{min:1,max:1};const i=v(t.spatialReference);let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const a of e){const e=t.resolutionAtLevel(a.level)*i;r=Math.min(r,e),s=Math.max(s,e)}return{min:r,max:s}}constructor(e){super(e),this.terrainTextureCompressionTracker=new Je,this._iteratorPool=new u(()=>new qe,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new Oe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new fe,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=E(),this._eyePosSurfaceSR=E(),this._splitLimits=new de,this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new L,this._frameTask=Ye,this._allTiles=new p,this._upsampleInfoPool=new u(()=>new He),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=B(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=D.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new ee(1/0,-1/0),this.rootTileElevationBounds=new ee(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;const{view:t}=e;this.overlayManager=new ne({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?he:le,this._ellipsoid=P(t.spatialReference),this._renderer=new me(this.overlayManager.renderer,t.stage,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),ze()||(this._scaleRangeQueries=new oe)}initialize(){const{view:e}=this,{resourceController:t}=e,{memoryController:i}=t;this._tileCache=new d((e,t)=>i.newCache(e,t),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new z(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([m(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),m(()=>this.renderer.visible,e=>this.suspended=!e),m(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)}),m(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(2===t||Math.min(r,360-r)>=30)&&(this.heading=i)})],"overlayManager"),this.addHandles([m(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},f),m(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),f),m(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},y),m(()=>this.snapLevel,()=>this._viewChanged=!0,y),m(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:C})}),m(()=>X.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&X.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=h(this._treeDebugger))},T)]);const{spatialReference:a}=e;this._extentHelper=se(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new We({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(0),this._mapDataRequester=t.createStreamDataRequester(1);const o=t.scheduler;this._frameTask=o.registerTask(Xe.TERRAIN_SURFACE,this),this.addHandles([m(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),T),m(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),y),m(()=>this.extent,()=>this._updateRootTiles(),T),e.on("resize",()=>this._viewChangeUpdate()),m(()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),f),m(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,T),m(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,T),m(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),m(()=>this._userClippingExtent,()=>this._updateClippingExtent(),y)]),this.addHandles(e.allLayerViews.on("after-changes",()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._watchUpdatingTracking?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._frameTask.remove(),this._frameTask=Ye,this._watchUpdatingTracking?.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),this._allTiles.prune(),Ie.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),Ae(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){if(this.lodSnappingEnabled){const{view:e,tilingScheme:t}=this,i=e.scale;if(t&&i){const r=t.levelAtScale(i)+e.qualitySettings.tiledSurface.lodBias,s=t.getMaxLod();return r<=0?null:Math.min(r,s||1/0)}}return null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get _userClippingExtent(){const{spatialReference:e}=this,t=this.view?.clippingArea;if(null==t||null==e)return null;const i=B(),r=J(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=k(this.groundExtent,this._userClippingExtent,B()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||null!=this._rootTiles}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return 0===this._renderer.transparency}get invisible(){return 3===this._renderer.transparency}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length||!this.enabled)return null;if(0===s[0].layerInfo[0].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=M(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return l.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const n=b(rt,e,t,i);a(n,0,n,0);return ht(s,n[0],n[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[0].length:0;if(r?.length&&0!==s&&this.enabled)for(let a=0;a<t;++a){const t=3*a;i(a,ht(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!R(e,rt,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(rt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;rt[0]>t[2]&&(i+=1),rt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=M(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationBounds(e,t){if(!this.enabled||null==this._rootTiles)return null;const i=this._ensureProjector(t);if(null==i)return l.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;F(e,st);const r=H(st,E());i(r,0,r,0),$(st,r);const s=new K,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!A(i.extent,st))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return this.enabled&&null!=this._rootTiles?new K(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max):null}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationBounds.min)*U;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!R(e,mt,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Q(st,mt,t);let i=null;const r=e=>{if(e&&A(e.extent,st)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){if(!this._scaleRangeQueries)return;const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._isFullyTransparent?t?3:2:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,i!==r}_updateTilingScheme(){const{tilingScheme:e}=this.tilingSchemeLogic;if(!(e!==this.tilingScheme))return;ye(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??D.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&N(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(et._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=at;let s=t.rootTilesInExtent(e,i,5*ue);if(null!=this._rootTiles){if(s.length>ue)return void l.getLogger(this).warn(pe);const e=this._rootTiles.map(e=>e.lij),t=r(e,s,ke);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter(e=>!(t.removed.findIndex(t=>ke(t,e.lij))>-1)||(this._purgeTile(e),!1));t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>ue&&(l.getLogger(this).warn(ce),s=t.rootTilesInExtent(e,i,ue)),this._setRootTiles(s.map(e=>this._newRootTile(e)));I(i,this._rootTilesExtent)||(this._rootTilesExtent=B(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter(e=>e.loaded&&e.intersectsClippingArea);e.sort(Ge),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(Ge);const t=this.renderer;e.forEach(e=>t.updateGeometryIfNeeded(e)),e.forEach(e=>this._pendingTilesForElevationUpdateEvent.add(e))}_shouldSplit(e){return 1===e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Ne(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new ee(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach(({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)});const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new ee(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=O(this._splitLimits.frustum??G(),t.frustum):this._splitLimits.frustum=null,x(this._eyePosRenderSR,t.eye),j(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(Te)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){const i=e.resetPendingUpdate(32)?32:!!e.resetPendingUpdate(16)&&16;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=lt.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach(t=>q(e,t.extent,e)),this._pendingTilesForElevationUpdateEvent.clear(),lt.spatialReference=this.spatialReference,this.emit("elevation-change",lt),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),Ue&&this._checkTileInvariant(),!e.hasProgressed)return Ze}_checkTileInvariant(){const e=new Map;this._allTiles.forAll(t=>e.set(t,new Set)),this._allTiles.forAll(t=>{if(ye(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce((t,i)=>t+(e(i)?0:1),0);if(ye(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(4)){ye(!t.hasPendingUpdate(1),"Tile can be both split and merge at the same time");for(const e of t.children)ye(e.leaf||e.hasPendingUpdate(4),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=ge;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${ge} (edge[${i}])`),ye(r,`tile level delta [${t.level}] vs [${e.level}] > ${ge}`))}ye(t.level-e.level<=ge,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-ge,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(ve[i],s);if(null!=a){if(t.leaf&&t.level>=ge){let i=a;for(;t.level-i.level<ge;)i=i.parent;const s=[r,t.lij[1]>>ge,t.lij[2]>>ge];if(!ke(s,i.lij)){const r=e.get(i);ye(!r.has(t),"Cannot already have neighbor"),r.add(t)}}ye(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),ye(t.level-a.level<=ge,`Tile level delta [${t.level}] vs [${a.level}] > ${ge}`)}}}),this._allTiles.forAll(t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);ye(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)})}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new dt(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=n?.hasPendingUpdate(4),o=l?4:e.shouldSplit(r,s,i),h=1===o;e.leaf?ut(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(1),e.leaf||e.setPendingUpdate(4),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),2===o&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||!this.view.pointsOfInterest?.focus||(Fe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){we(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter(e=>e.loaded&&e.intersectsClippingArea);if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Ge);const r=t.length;for(let s=0;s<r;++s){const r=t[s];we(r.loaded),we(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=Be[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(De(t),e=>e.loaded))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Se(ve[t]),t=>!(!t.loaded||!t.intersectsClippingArea)&&(we(e.has(t)||Ge(r,t)<0),i(r,t),!0)),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,Ue&&Me&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some(s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(4)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(4);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(4);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(1)){let t=!0;const i=s.level;if(i>=ge){const e=e=>e.leaf||i-e.level<ge;for(let r=0;r<4;++r){const a=s.findNeighborTile(ve[r],e);null!=a&&i-a.level===ge&&(t=!1,Ue&&(we(a.leaf),we(a.hasPendingUpdate(1))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done)),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.overlayManager?.updateOverlayParameters(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*_e}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?ct(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(et._tileMemcacheKey,e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){ye(e.leaf,"Tile that is already split should not be split again!"),ye(e.rendered,"Tile marked to split is not rendered"),ct(e);const t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),e.updateAgentSuspension(),ye(e.rendered,"parent should be rendered"),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>ut(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){ot.spatialReference=this.spatialReference,ot.extent=e.extent,ot.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",ot)}createTile(e,t,i,r){ye(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(1),s}get _shortBatches(){return 2!==this.view.state.mode}_mergeTile(e){ye(!e.hasPendingUpdate(1),"_mergeTile sanity check"),ye(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),ye(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),ut(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&this.overlayManager.updateTileOverlayParameters(e)}_handleLayerViewChanges(e=Ke){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),Ce(e)||be(e))if(this._basemapLayerViewHandles.has(e.uid)&&!be(e)){const i=this._layerClassFromLayerView(e),s=this.getLayerIndexByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(const e of this.view.allLayerViews.items)if(xe(e)&&!Y(e.layer)&&0!==e.fullOpacity)return!1;return!0}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ee(e)||be(e))&&$e(Qe[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Le(e)?0:1}_registerTiledLayerView(e){const t=[];if((Ee(e)||be(e))&&t.push(m(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!be(e)){const i=this._layerClassFromLayerView(e);t.push(m(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(m(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));const{layer:r}=e;"effectiveScaleRange"in r&&t.push(m(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(i))),t.push(e.on("data-changed",()=>{const t=this.getLayerIndexByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach(e=>{if(!e.layer||e.suspended||!Ce(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(1===r){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)});for(const r of ae){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),0===e&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),1===e?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll(i=>i.removeLayerAgent(e,t)),this._allTiles.forAll(i=>i.invalidateLayerData(e,t))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=1){this.renderer.setNeedsRender(e)}requestUpdate(){1===++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Te(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then(()=>--this._asyncWorkItems).catch(t=>{throw--this._asyncWorkItems,c(r),g(t)||this._dataMissing(e,i,s),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,i,s,r),r.signal)))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();const s=0===t;return r.requester??=s?this._elevationDataRequester:this._mapDataRequester,s?Le(i)?this._requestElevationTileData(e,i,r):Promise.reject():xe(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!_(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{g(i)||(l.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${i}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,i).then(e=>this._frameTask.schedule(()=>r(e)),s).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[0].get(t.uid);if(null==r)return void l.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",0,e.lij.toString());const s=new te(e.lij,e.extent,i);e.dataArrived(r,0,s),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:0});const a=[e],n=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,n),e.computeElevationBounds()}0===n&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{Pe(s),_(i)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule(()=>{this.requestUpdate(),_(i)?Pe(r):this._mapTileDataArrived(e,t,r)},i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule(()=>r(e,t));return t.fetchTile(e.lij,i).then(a,n).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,i){const r=this.getLayerIndexByUID(1,t.uid);if(null==r)return Pe(i),void l.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,1,i),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:1})}_dataMissing(e,t,i){const r=this.getLayerIndexByUID(t,i.uid);null!=r?(e.dataMissing(r,t),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:t})):l.getLogger(this).warn("TerrainSurface: received data from unknown layer")}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(i,e.uid);return null!=r&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(i,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Me)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Re(e)}enableWaterproofnessChecks(e){je(e)}static cleanupTerrainSurface(){nt.prune()}enable(e){e!==this.enabled&&(e?(this._updateRootTiles(),this.suspended=!1):(this.suspended=!0,this._removeAllTiles(),this._setRootTiles(null)),this._set("enabled",e),this.notifyChange("ready"))}};e([w()],tt.prototype,"_renderer",void 0),e([w({constructOnly:!0})],tt.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],tt.prototype,"view",void 0),e([w({constructOnly:!0})],tt.prototype,"overlayManager",void 0),e([w({constructOnly:!0})],tt.prototype,"terrainTextureCompressionTracker",void 0),e([w()],tt.prototype,"_hasPendingUpdates",void 0),e([w()],tt.prototype,"_asyncWorkItems",void 0),e([w()],tt.prototype,"_allTilesDirty",void 0),e([w()],tt.prototype,"_allTilesSorted",void 0),e([w()],tt.prototype,"_viewChanged",void 0),e([w({type:Number})],tt.prototype,"heading",void 0),e([w()],tt.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],tt.prototype,"_watchUpdatingTracking",void 0),e([w()],tt.prototype,"_frameTask",void 0),e([w()],tt.prototype,"demResolution",null),e([w({readOnly:!0})],tt.prototype,"snapLevel",null),e([w({readOnly:!0})],tt.prototype,"lodSnappingEnabled",null),e([w()],tt.prototype,"_userClippingExtent",null),e([w()],tt.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],tt.prototype,"extent",null),e([w({readOnly:!0})],tt.prototype,"groundExtent",null),e([w({readOnly:!0})],tt.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],tt.prototype,"updating",null),e([w({readOnly:!0})],tt.prototype,"readyToRun",null),e([w(Z)],tt.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],tt.prototype,"updatingProgressValue",null),e([w()],tt.prototype,"_maxNumUpdating",void 0),e([w()],tt.prototype,"baseOpacity",null),e([w()],tt.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],tt.prototype,"viewingMode",null),e([w()],tt.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],tt.prototype,"ready",null),e([w({readOnly:!0})],tt.prototype,"rootTiles",null),e([w()],tt.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],tt.prototype,"spatialReference",null),e([w({type:t})],tt.prototype,"backgroundColor",null),e([w({value:!1})],tt.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],tt.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],tt.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],tt.prototype,"tilingSchemeLogic",void 0),e([w()],tt.prototype,"wireframe",null),e([w({value:!1})],tt.prototype,"suspended",null),e([w()],tt.prototype,"fadeDuration",null),e([w()],tt.prototype,"visibleElevationBounds",void 0),e([w()],tt.prototype,"rootTileElevationBounds",void 0),e([w()],tt.prototype,"_layerViewsDirty",void 0),e([w()],tt.prototype,"renderPatchBorders",null),e([w()],tt.prototype,"visualizeNormals",null),e([w()],tt.prototype,"renderingDisabled",null),e([w({readOnly:!0})],tt.prototype,"enabled",void 0),tt=et=e([S("esri.views.3d.terrain.TerrainSurface")],tt);const it=tt,rt=E(),st=W(),at=B(),nt=new p,lt=new re("ground"),ot={spatialReference:null,extent:null,scale:0};function ht(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 ie(t,i,s)}return null}class dt{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function ut(e,t){!e.leaf||e.level<ge||_t(e,e=>{t&&pt(e);const i=gt(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=gt(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}})}function pt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<ge||_t(e,e=>{pt(e)})}function ct(e){e.level<ge||_t(e,e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,gt(t));)t=t.parent}})}function gt(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function _t(e,t){if(e.level<ge)return;const i=e.level-ge,r=e.lij[1]>>ge,s=e.lij[2]>>ge,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(ve[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}const mt=E();export{it as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as i,difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as n}from"../../../core/Evented.js";import"../../../core/has.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import u from"../../../core/ObjectPool.js";import p from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as _}from"../../../core/promiseUtils.js";import{watch as m,syncAndInitial as f,sync as y,initial as T}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../core/unitUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{q as C,i as b,c as x}from"../../../chunks/vec32.js";import{create as E}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as P,radiusModifier as U}from"../../../geometry/ellipsoidUtils.js";import D from"../../../geometry/SpatialReference.js";import{getProjector as M}from"../../../geometry/projection/projectors.js";import{projectPointToVector as R}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as j}from"../../../geometry/projection/projectVectorToVector.js";import{create as B,equals as I,intersection as k,intersectsSphere as A,empty as V,expand as q}from"../../../geometry/support/aaBoundingRect.js";import{copy as N,create as O}from"../../../geometry/support/frustum.js";import{createSpatialReferenceCyclical as G}from"../../../geometry/support/normalizeUtils.js";import{isPlateCarree as F}from"../../../geometry/support/spatialReferenceUtils.js";import{m as W,c as H,n as $,o as z,e as Q}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as Y}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as X}from"../../../layers/support/layerUtils.js";import{debugFlags as K}from"../support/debugFlags.js";import{ElevationRange as J}from"../support/ElevationRange.js";import{toBoundingRect as Z}from"../support/extentUtils.js";import{updatingProgress as ee}from"../support/updatingProperties.js";import{ElevationBounds as te}from"./ElevationBounds.js";import{ElevationData as ie,sampleElevation as re}from"./ElevationData.js";import{ElevationUpdateEventImplementation as se}from"./ElevationUpdateEvent.js";import{create as ae}from"./ExtentHelper.js";import{LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{ScaleRangeQueries as he}from"./ScaleRangeQueries.js";import{SphericalPatch as de}from"./SphericalPatch.js";import{SplitLimits as ue}from"./SplitLimits.js";import{maxRootTiles as pe,tooManyRootTilesAfterChangeError as ce,tooManyRootTilesForLayerError as ge,maxTileNeighborLevelDelta as _e,maxMemoryLodBias as me}from"./TerrainConst.js";import{TerrainRenderer as fe}from"./TerrainRenderer.js";import ye from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as Te,isVectorTileLayerView as ve,neighborEdgeIndices as we,internalAssert as Se,oppositeEdge as Ce,isSurfaceLayerView as be,isGroupLayerView as xe,isMapTileLayerView as Ee,isBlendableLayerView as Le,isElevationLayerView as Pe,releaseTerrainData as Ue,enableTerrainInternalChecks as De,oppositeCorner as Me,enableWaterproofTests as Re,enableInternalTerrainChecks as je,enableTerrainWaterproofChecks as Be,neighborCornerIndices as Ie}from"./terrainUtils.js";import{Tile as ke,lijEquals as Ae}from"./Tile.js";import{printAllocations as Ve}from"./TilePerLayerInfo.js";import{sortTiles as qe,IteratorPreorder as Ne,IteratorPostorder as Oe,compareTilesByLij as Ge,hasLoadableSiblings as Fe,sortTilesByPOI as We}from"./tileUtils.js";import{TilingSchemeLogic as He}from"./TilingSchemeLogic.js";import{UpsampleInfo as $e}from"./UpsampleInfo.js";import{isCompositeBlendMode as ze,blendModeFromString as Qe}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as Ye}from"../../support/layerViewUtils.js";import{ImmediateTask as Xe,TaskPriority as Ke,noBudget as Je}from"../../support/Scheduler.js";import{TextureCompressionTracker as Ze}from"../../support/TextureCompressionTracker.js";import{Yield as et}from"../../support/Yield.js";var tt;let it=class extends n{static{tt=this}get allTiles(){return a(this._allTiles)}get renderedTiles(){return qe(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){const{_allTiles:e,tilingScheme:t}=this;if(0===e.length)return{min:1,max:1};const i=v(t.spatialReference);let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const a of e){const e=t.resolutionAtLevel(a.level)*i;r=Math.min(r,e),s=Math.max(s,e)}return{min:r,max:s}}constructor(e){super(e),this.terrainTextureCompressionTracker=new Ze,this._iteratorPool=new u(()=>new Ne,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new Oe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new ye,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=E(),this._eyePosSurfaceSR=E(),this._splitLimits=new ue,this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new L,this._frameTask=Xe,this._allTiles=new p,this._upsampleInfoPool=new u(()=>new $e),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=B(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=D.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new te(1/0,-1/0),this.rootTileElevationBounds=new te(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;const{view:t}=e;this.overlayManager=new le({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?de:oe,this._ellipsoid=P(t.spatialReference),this._renderer=new fe(this.overlayManager.renderer,t.stage,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),Ye()||(this._scaleRangeQueries=new he)}initialize(){const{view:e}=this,{resourceController:t}=e,{memoryController:i}=t;this._tileCache=new d((e,t)=>i.newCache(e,t),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new Y(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([m(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),m(()=>this.renderer.visible,e=>this.suspended=!e),m(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)}),m(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(2===t||Math.min(r,360-r)>=30)&&(this.heading=i)})],"overlayManager"),this.addHandles([m(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},f),m(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),f),m(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},y),m(()=>this.snapLevel,()=>this._viewChanged=!0,y),m(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:C})}),m(()=>K.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&K.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=h(this._treeDebugger))},T)]);const{spatialReference:a}=e;this._extentHelper=ae(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new He({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(0),this._mapDataRequester=t.createStreamDataRequester(1);const o=t.scheduler;this._frameTask=o.registerTask(Ke.TERRAIN_SURFACE,this),this.addHandles([m(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),T),m(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),y),m(()=>this.extent,()=>this._updateRootTiles(),T),e.on("resize",()=>this._viewChangeUpdate()),m(()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),f),m(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,T),m(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,T),m(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),m(()=>this._userClippingExtent,()=>this._updateClippingExtent(),y)]),this.addHandles(e.allLayerViews.on("after-changes",()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._watchUpdatingTracking?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._frameTask.remove(),this._frameTask=Xe,this._watchUpdatingTracking?.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),this._allTiles.prune(),ke.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),Ve(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){if(this.lodSnappingEnabled){const{view:e,tilingScheme:t}=this,i=e.scale;if(t&&i){const r=t.levelAtScale(i)+e.qualitySettings.tiledSurface.lodBias,s=t.getMaxLod();return r<=0?null:Math.min(r,s||1/0)}}return null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get _userClippingExtent(){const{spatialReference:e}=this,t=this.view?.clippingArea;if(null==t||null==e)return null;const i=B(),r=Z(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=k(this.groundExtent,this._userClippingExtent,B()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||null!=this._rootTiles}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return 0===this._renderer.transparency}get invisible(){return 3===this._renderer.transparency}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}get _xNormalizer(){return G(this._spatialReference)}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length||!this.enabled)return null;if(0===s[0].layerInfo[0].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=M(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return l.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const n=b(st,e,t,i);a(n,0,n,0);return dt(s,this._xNormalizer?.normalize(n[0])??n[0],n[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[0].length:0;if(r?.length&&0!==s&&this.enabled)for(let a=0;a<t;++a){const t=3*a;i(a,dt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!R(e,st,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(st)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;st[0]>t[2]&&(i+=1),st[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=M(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationBounds(e,t){if(!this.enabled||null==this._rootTiles)return null;const i=this._ensureProjector(t);if(null==i)return l.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;W(e,at);const r=$(at,E());i(r,0,r,0),z(at,r);const s=new J,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!A(i.extent,at))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return this.enabled&&null!=this._rootTiles?new J(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max):null}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationBounds.min)*U;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!R(e,ft,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Q(at,ft,t);let i=null;const r=e=>{if(e&&A(e.extent,at)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){if(!this._scaleRangeQueries)return;const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._isFullyTransparent?t?3:2:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,i!==r}_updateTilingScheme(){const{tilingScheme:e}=this.tilingSchemeLogic;if(!(e!==this.tilingScheme))return;Te(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??D.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&F(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(tt._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=nt;let s=t.rootTilesInExtent(e,i,5*pe);if(null!=this._rootTiles){if(s.length>pe)return void l.getLogger(this).warn(ce);const e=this._rootTiles.map(e=>e.lij),t=r(e,s,Ae);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter(e=>!(t.removed.findIndex(t=>Ae(t,e.lij))>-1)||(this._purgeTile(e),!1));t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>pe&&(l.getLogger(this).warn(ge),s=t.rootTilesInExtent(e,i,pe)),this._setRootTiles(s.map(e=>this._newRootTile(e)));I(i,this._rootTilesExtent)||(this._rootTilesExtent=B(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter(e=>e.loaded&&e.intersectsClippingArea);e.sort(Ge),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(Ge);const t=this.renderer;e.forEach(e=>t.updateGeometryIfNeeded(e)),e.forEach(e=>this._pendingTilesForElevationUpdateEvent.add(e))}_shouldSplit(e){return 1===e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Fe(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new te(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach(({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)});const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new te(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=N(this._splitLimits.frustum??O(),t.frustum):this._splitLimits.frustum=null,x(this._eyePosRenderSR,t.eye),j(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(ve)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){const i=e.resetPendingUpdate(32)?32:!!e.resetPendingUpdate(16)&&16;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=ot.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach(t=>q(e,t.extent,e)),this._pendingTilesForElevationUpdateEvent.clear(),ot.spatialReference=this.spatialReference,this.emit("elevation-change",ot),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),De&&this._checkTileInvariant(),!e.hasProgressed)return et}_checkTileInvariant(){const e=new Map;this._allTiles.forAll(t=>e.set(t,new Set)),this._allTiles.forAll(t=>{if(Te(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce((t,i)=>t+(e(i)?0:1),0);if(Te(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(4)){Te(!t.hasPendingUpdate(1),"Tile can be both split and merge at the same time");for(const e of t.children)Te(e.leaf||e.hasPendingUpdate(4),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=_e;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${_e} (edge[${i}])`),Te(r,`tile level delta [${t.level}] vs [${e.level}] > ${_e}`))}Te(t.level-e.level<=_e,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-_e,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(we[i],s);if(null!=a){if(t.leaf&&t.level>=_e){let i=a;for(;t.level-i.level<_e;)i=i.parent;const s=[r,t.lij[1]>>_e,t.lij[2]>>_e];if(!Ae(s,i.lij)){const r=e.get(i);Te(!r.has(t),"Cannot already have neighbor"),r.add(t)}}Te(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),Te(t.level-a.level<=_e,`Tile level delta [${t.level}] vs [${a.level}] > ${_e}`)}}}),this._allTiles.forAll(t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);Te(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)})}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new ut(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=n?.hasPendingUpdate(4),o=l?4:e.shouldSplit(r,s,i),h=1===o;e.leaf?pt(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(1),e.leaf||e.setPendingUpdate(4),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),2===o&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||!this.view.pointsOfInterest?.focus||(We(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){Se(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter(e=>e.loaded&&e.intersectsClippingArea);if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Ge);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Se(r.loaded),Se(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=Ie[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(Me(t),e=>e.loaded))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Ce(we[t]),t=>!(!t.loaded||!t.intersectsClippingArea)&&(Se(e.has(t)||Ge(r,t)<0),i(r,t),!0)),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,De&&Re&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some(s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(4)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(4);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(4);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(1)){let t=!0;const i=s.level;if(i>=_e){const e=e=>e.leaf||i-e.level<_e;for(let r=0;r<4;++r){const a=s.findNeighborTile(we[r],e);null!=a&&i-a.level===_e&&(t=!1,De&&(Se(a.leaf),Se(a.hasPendingUpdate(1))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done)),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.overlayManager?.updateOverlayParameters(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*me}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?gt(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(tt._tileMemcacheKey,e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){Te(e.leaf,"Tile that is already split should not be split again!"),Te(e.rendered,"Tile marked to split is not rendered"),gt(e);const t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),e.updateAgentSuspension(),Te(e.rendered,"parent should be rendered"),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>pt(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){ht.spatialReference=this.spatialReference,ht.extent=e.extent,ht.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",ht)}createTile(e,t,i,r){Te(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(1),s}get _shortBatches(){return 2!==this.view.state.mode}_mergeTile(e){Te(!e.hasPendingUpdate(1),"_mergeTile sanity check"),Te(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),Te(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),pt(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&this.overlayManager.updateTileOverlayParameters(e)}_handleLayerViewChanges(e=Je){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),be(e)||xe(e))if(this._basemapLayerViewHandles.has(e.uid)&&!xe(e)){const i=this._layerClassFromLayerView(e),s=this.getLayerIndexByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(const e of this.view.allLayerViews.items)if(Ee(e)&&!X(e.layer)&&0!==e.fullOpacity)return!1;return!0}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Le(e)||xe(e))&&ze(Qe[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Pe(e)?0:1}_registerTiledLayerView(e){const t=[];if((Le(e)||xe(e))&&t.push(m(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!xe(e)){const i=this._layerClassFromLayerView(e);t.push(m(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(m(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));const{layer:r}=e;"effectiveScaleRange"in r&&t.push(m(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(i))),t.push(e.on("data-changed",()=>{const t=this.getLayerIndexByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach(e=>{if(!e.layer||e.suspended||!be(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(1===r){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)});for(const r of ne){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),0===e&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),1===e?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll(i=>i.removeLayerAgent(e,t)),this._allTiles.forAll(i=>i.invalidateLayerData(e,t))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=1){this.renderer.setNeedsRender(e)}requestUpdate(){1===++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||ve(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then(()=>--this._asyncWorkItems).catch(t=>{throw--this._asyncWorkItems,c(r),g(t)||this._dataMissing(e,i,s),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,i,s,r),r.signal)))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();const s=0===t;return r.requester??=s?this._elevationDataRequester:this._mapDataRequester,s?Pe(i)?this._requestElevationTileData(e,i,r):Promise.reject():Ee(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!_(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{g(i)||(l.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${i}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,i).then(e=>this._frameTask.schedule(()=>r(e)),s).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[0].get(t.uid);if(null==r)return void l.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",0,e.lij.toString());const s=new ie(e.lij,e.extent,i);e.dataArrived(r,0,s),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:0});const a=[e],n=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,n),e.computeElevationBounds()}0===n&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{Ue(s),_(i)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule(()=>{this.requestUpdate(),_(i)?Ue(r):this._mapTileDataArrived(e,t,r)},i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule(()=>r(e,t));return t.fetchTile(e.lij,i).then(a,n).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,i){const r=this.getLayerIndexByUID(1,t.uid);if(null==r)return Ue(i),void l.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,1,i),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:1})}_dataMissing(e,t,i){const r=this.getLayerIndexByUID(t,i.uid);null!=r?(e.dataMissing(r,t),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:t})):l.getLogger(this).warn("TerrainSurface: received data from unknown layer")}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(i,e.uid);return null!=r&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(i,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Re)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){je(e)}enableWaterproofnessChecks(e){Be(e)}static cleanupTerrainSurface(){lt.prune()}enable(e){e!==this.enabled&&(e?(this._updateRootTiles(),this.suspended=!1):(this.suspended=!0,this._removeAllTiles(),this._setRootTiles(null)),this._set("enabled",e),this.notifyChange("ready"))}};e([w()],it.prototype,"_renderer",void 0),e([w({constructOnly:!0})],it.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],it.prototype,"view",void 0),e([w({constructOnly:!0})],it.prototype,"overlayManager",void 0),e([w({constructOnly:!0})],it.prototype,"terrainTextureCompressionTracker",void 0),e([w()],it.prototype,"_hasPendingUpdates",void 0),e([w()],it.prototype,"_asyncWorkItems",void 0),e([w()],it.prototype,"_allTilesDirty",void 0),e([w()],it.prototype,"_allTilesSorted",void 0),e([w()],it.prototype,"_viewChanged",void 0),e([w({type:Number})],it.prototype,"heading",void 0),e([w()],it.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],it.prototype,"_watchUpdatingTracking",void 0),e([w()],it.prototype,"_frameTask",void 0),e([w()],it.prototype,"demResolution",null),e([w({readOnly:!0})],it.prototype,"snapLevel",null),e([w({readOnly:!0})],it.prototype,"lodSnappingEnabled",null),e([w()],it.prototype,"_userClippingExtent",null),e([w()],it.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],it.prototype,"extent",null),e([w({readOnly:!0})],it.prototype,"groundExtent",null),e([w({readOnly:!0})],it.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],it.prototype,"updating",null),e([w({readOnly:!0})],it.prototype,"readyToRun",null),e([w(ee)],it.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],it.prototype,"updatingProgressValue",null),e([w()],it.prototype,"_maxNumUpdating",void 0),e([w()],it.prototype,"baseOpacity",null),e([w()],it.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],it.prototype,"viewingMode",null),e([w()],it.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],it.prototype,"ready",null),e([w({readOnly:!0})],it.prototype,"rootTiles",null),e([w()],it.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],it.prototype,"spatialReference",null),e([w({type:t})],it.prototype,"backgroundColor",null),e([w({value:!1})],it.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],it.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],it.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],it.prototype,"tilingSchemeLogic",void 0),e([w()],it.prototype,"wireframe",null),e([w({value:!1})],it.prototype,"suspended",null),e([w()],it.prototype,"fadeDuration",null),e([w()],it.prototype,"_xNormalizer",null),e([w()],it.prototype,"visibleElevationBounds",void 0),e([w()],it.prototype,"rootTileElevationBounds",void 0),e([w()],it.prototype,"_layerViewsDirty",void 0),e([w()],it.prototype,"renderPatchBorders",null),e([w()],it.prototype,"visualizeNormals",null),e([w()],it.prototype,"renderingDisabled",null),e([w({readOnly:!0})],it.prototype,"enabled",void 0),it=tt=e([S("esri.views.3d.terrain.TerrainSurface")],it);const rt=it,st=E(),at=H(),nt=B(),lt=new p,ot=new se("ground"),ht={spatialReference:null,extent:null,scale:0};function dt(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}class ut{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function pt(e,t){!e.leaf||e.level<_e||mt(e,e=>{t&&ct(e);const i=_t(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=_t(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}})}function ct(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<_e||mt(e,e=>{ct(e)})}function gt(e){e.level<_e||mt(e,e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,_t(t));)t=t.parent}})}function _t(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function mt(e,t){if(e.level<_e)return;const i=e.level-_e,r=e.lij[1]>>_e,s=e.lij[2]>>_e,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(we[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}const ft=E();export{rt as default};
@@ -2,27 +2,27 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{NoPerspectiveRead as e}from"../util/NoPerspective.glsl.js";import{RgbaFloatEncoding as t}from"../util/RgbaFloatEncoding.glsl.js";import{addCameraPosition as o,addPixelRatio as r}from"../util/View.glsl.js";import{Float4PassUniform as i}from"../../shaderModules/Float4PassUniform.js";import{FloatBindUniform as l}from"../../shaderModules/FloatBindUniform.js";import{FloatPassUniform as a}from"../../shaderModules/FloatPassUniform.js";import{glsl as n,If as s}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as p}from"../../shaderModules/Texture2DPassUniform.js";import{computeTextureSize as d,computeLongestPattern as c}from"../../../materials/stippleTextureRepository.js";import{ensureColor4 as f}from"../../../shaders/ensureColor4.js";function m(d,c){if(!c.stippleEnabled)return void d.fragment.code.add(n`float getStippleAlpha(float lineWidth) { return 1.0; }
5
+ import{NoPerspectiveRead as e}from"../util/NoPerspective.glsl.js";import{RgbaFloatEncoding as t}from"../util/RgbaFloatEncoding.glsl.js";import{addCameraPosition as o,addPixelRatio as i}from"../util/View.glsl.js";import{Float4PassUniform as r}from"../../shaderModules/Float4PassUniform.js";import{FloatBindUniform as l}from"../../shaderModules/FloatBindUniform.js";import{FloatPassUniform as a}from"../../shaderModules/FloatPassUniform.js";import{glsl as s,If as n}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as p}from"../../shaderModules/Texture2DPassUniform.js";import{computeTextureSize as d}from"../../../materials/stippleTextureRepository.js";import{ensureColor4 as c}from"../../../shaders/ensureColor4.js";function f(d,f){if(!f.stippleEnabled)return void d.fragment.code.add(s`float getStippleAlpha(float lineWidth) { return 1.0; }
6
6
  void discardByStippleAlpha(float stippleAlpha, float threshold) {}
7
- vec4 blendStipple(vec4 color, float stippleAlpha) { return color; }`);const m=!(c.draped&&c.stipplePreferContinuous),{vertex:h,fragment:v}=d;v.include(t),c.draped||(o(h,c),h.uniforms.add(new l("worldToScreenPerDistanceRatio",({camera:e})=>1/e.perScreenPixelRatio)).code.add(n`float computeWorldToScreenRatio(vec3 segmentCenter) {
7
+ vec4 blendStipple(vec4 color, float stippleAlpha) { return color; }`);const g=!(f.draped&&f.stipplePreferContinuous),{vertex:S,fragment:h}=d;h.include(t),f.draped||(o(S,f),S.uniforms.add(new l("worldToScreenPerDistanceRatio",({camera:e})=>1/e.perScreenPixelRatio)).code.add(s`float computeWorldToScreenRatio(vec3 segmentCenter) {
8
8
  float segmentDistanceToCamera = length(segmentCenter - cameraPosition);
9
9
  return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
10
- }`)),d.varyings.add("vStippleDistance","float"),d.varyings.add("vStippleDistanceLimits","vec2"),d.varyings.add("vStipplePatternStretch","float"),h.code.add(n`
10
+ }`)),d.varyings.add("vStippleDistance","float"),d.varyings.add("vStippleDistanceLimits","vec2"),d.varyings.add("vStipplePatternStretch","float"),S.code.add(s`
11
11
  float discretizeWorldToScreenRatio(float worldToScreenRatio) {
12
- float step = ${n.float(g)};
12
+ float step = ${s.float(u)};
13
13
 
14
14
  float discreteWorldToScreenRatio = log(worldToScreenRatio);
15
15
  discreteWorldToScreenRatio = ceil(discreteWorldToScreenRatio / step) * step;
16
16
  discreteWorldToScreenRatio = exp(discreteWorldToScreenRatio);
17
17
  return discreteWorldToScreenRatio;
18
18
  }
19
- `),r(h),h.code.add(n`
19
+ `),i(S),S.code.add(s`
20
20
  vec2 computeStippleDistanceLimits(float startPseudoScreen, float segmentLengthPseudoScreen, float segmentLengthScreen, float patternLength) {
21
21
 
22
22
  // First check if the segment is long enough to support fully screen space patterns.
23
23
  // Force sparse mode for segments that are very large in screen space even if it is not allowed,
24
24
  // to avoid imprecision from calculating with large floats.
25
- if (segmentLengthPseudoScreen >= ${m?"patternLength":"1e4"}) {
25
+ if (segmentLengthPseudoScreen >= ${g?"patternLength":"1e4"}) {
26
26
  // Round the screen length to get an integer number of pattern repetitions (minimum 1).
27
27
  float repetitions = segmentLengthScreen / (patternLength * pixelRatio);
28
28
  float flooredRepetitions = max(1.0, floor(repetitions + 0.5));
@@ -38,15 +38,14 @@ return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
38
38
  }
39
39
  return vec2(startPseudoScreen, startPseudoScreen + segmentLengthPseudoScreen);
40
40
  }
41
- `),v.uniforms.add(new p("stipplePatternTexture",e=>e.stippleTexture),new a("stipplePatternSDFNormalizer",e=>u(e.stipplePattern)),new a("stipplePatternPixelSizeInv",e=>1/S(e))),c.stippleOffColorEnabled&&v.uniforms.add(new i("stippleOffColor",e=>f(e.stippleOffColor))),d.include(e),v.code.add(n`float getStippleSDF(out bool isClamped) {
41
+ `),h.uniforms.add(new p("stipplePatternTexture",e=>e.stippleTexture),new a("stipplePatternPixelSizeInv",e=>1/m(e))),f.stippleOffColorEnabled&&h.uniforms.add(new r("stippleOffColor",e=>c(e.stippleOffColor))),d.include(e),h.code.add(s`float getStippleSDF(out bool isClamped) {
42
42
  float stippleDistanceClamped = noPerspectiveRead(clamp(vStippleDistance, vStippleDistanceLimits.x, vStippleDistanceLimits.y));
43
43
  float lineSizeInv = noPerspectiveRead(vLineSizeInv);
44
44
  vec2 aaCorrectedLimits = vStippleDistanceLimits + vec2(1.0, -1.0) / gl_FragCoord.w;
45
45
  isClamped = vStippleDistance < aaCorrectedLimits.x || vStippleDistance > aaCorrectedLimits.y;
46
46
  float u = stippleDistanceClamped * stipplePatternPixelSizeInv * lineSizeInv;
47
47
  u = fract(u);
48
- float encodedSDF = rgbaTofloat(texture(stipplePatternTexture, vec2(u, 0.5)));
49
- float sdf = (encodedSDF * 2.0 - 1.0) * stipplePatternSDFNormalizer;
48
+ float sdf = texture(stipplePatternTexture, vec2(u, 0.5)).r;
50
49
  return (sdf - 0.5) * vStipplePatternStretch + 0.5;
51
50
  }
52
51
  float getStippleSDF() {
@@ -58,12 +57,12 @@ bool isClamped;
58
57
  float stippleSDF = getStippleSDF(isClamped);
59
58
  float antiAliasedResult = clamp(stippleSDF * lineWidth + 0.5, 0.0, 1.0);
60
59
  return isClamped ? floor(antiAliasedResult + 0.5) : antiAliasedResult;
61
- }`),v.code.add(n`
60
+ }`),h.code.add(s`
62
61
  void discardByStippleAlpha(float stippleAlpha, float threshold) {
63
- ${s(!c.stippleOffColorEnabled,"if (stippleAlpha < threshold) { discard; }")}
62
+ ${n(!f.stippleOffColorEnabled,"if (stippleAlpha < threshold) { discard; }")}
64
63
  }
65
64
 
66
65
  vec4 blendStipple(vec4 color, float stippleAlpha) {
67
- return ${c.stippleOffColorEnabled?"mix(color, stippleOffColor, stippleAlpha)":"vec4(color.rgb, color.a * stippleAlpha)"};
66
+ return ${f.stippleOffColorEnabled?"mix(color, stippleOffColor, stippleAlpha)":"vec4(color.rgb, color.a * stippleAlpha)"};
68
67
  }
69
- `)}function u(e){return e?(Math.floor(.5*(c(e)-1))+.5)/e.pixelRatio:1}function S(e){const t=e.stipplePattern;return t?d(e.stipplePattern)/t.pixelRatio:1}const g=.4;export{m as LineStipple,S as computePixelSize};
68
+ `)}function m(e){const t=e.stipplePattern;return t?d(e.stipplePattern)/t.pixelRatio:1}const u=.4;export{f as LineStipple,m as computePixelSize};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{C as i}from"../../../../chunks/Compositing.glsl.js";import{CompositingTechnique as t}from"../shaders/CompositingTechnique.js";import{CompositingTechniqueConfiguration as s}from"../shaders/CompositingTechniqueConfiguration.js";import{H as e}from"../../../../chunks/HUDCompositing.glsl.js";import{HUDCompositingTechnique as o}from"../shaders/HUDCompositingTechnique.js";class r{constructor(r,h){this._rctx=r,this._techniques=h,this._configuration=new s,this._passParameters=new i,this._hudParameters=new e,this._configuration.blitMode=2,this._techniques.precompile(t,this._configuration),this._configuration.hasOpacityFactor=!0,this._techniques.precompile(t,this._configuration),this._configuration.hasOpacityFactor=!1,this._configuration.blitMode=1,this._techniques.precompile(t,this._configuration),this._configuration.blitMode=3,this._techniques.precompile(t,this._configuration),this._techniques.precompile(o)}compositeHUD(i,t){this._hudParameters.texture=t;const s=this._techniques.get(o);this._rctx.bindTechnique(s,i,this._hudParameters),this._rctx.screen.draw()}compositePreMultipliedAlpha(i,t,s=1){this._composite(i,t,2,s)}composite(i,t){this._composite(i,t,1,1)}blitDepthToLinearDepth(i,t){this._composite(i,t,3,1)}_composite(i,s,e,o){this._configuration.blitMode=e,this._configuration.hasOpacityFactor=1!==o,this._passParameters.texture=s,this._passParameters.opacity=o;const r=this._techniques.get(t,this._configuration);this._rctx.bindTechnique(r,i,this._passParameters),this._rctx.screen.draw()}}export{r as default};
5
+ import{C as i}from"../../../../chunks/Compositing.glsl.js";import{CompositingTechnique as t}from"../shaders/CompositingTechnique.js";import{CompositingTechniqueConfiguration as s}from"../shaders/CompositingTechniqueConfiguration.js";import{H as e}from"../../../../chunks/HUDCompositing.glsl.js";import{HUDCompositingTechnique as o}from"../shaders/HUDCompositingTechnique.js";class r{constructor(r,h){this._rctx=r,this._techniques=h,this._configuration=new s,this._passParameters=new i,this._hudParameters=new e,this._configuration.blitMode=2,this._techniques.precompile(t,this._configuration),this._configuration.hasOpacityFactor=!0,this._techniques.precompile(t,this._configuration),this._configuration.hasOpacityFactor=!1,this._configuration.blitMode=1,this._techniques.precompile(t,this._configuration),this._configuration.blitEmissiveMode=1,this._techniques.precompile(t,this._configuration),this._configuration.blitEmissiveMode=0,this._configuration.blitMode=3,this._techniques.precompile(t,this._configuration),this._techniques.precompile(o)}compositeHUD(i,t){this._hudParameters.texture=t;const s=this._techniques.get(o);this._rctx.bindTechnique(s,i,this._hudParameters),this._rctx.screen.draw()}compositePreMultipliedAlpha(i,t,s=1){this._composite(i,t,2,s)}composite(i,t,s){this._composite(i,t,1,1,s)}blitDepthToLinearDepth(i,t){this._composite(i,t,3,1)}_composite(i,s,e,o,r=0){this._configuration.blitMode=e,this._configuration.hasOpacityFactor=1!==o,this._configuration.blitEmissiveMode=r,this._passParameters.texture=s,this._passParameters.opacity=o;const h=this._techniques.get(t,this._configuration);this._rctx.bindTechnique(h,i,this._passParameters),this._rctx.screen.draw()}}export{r 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import s from"../../../../core/PooledArray.js";import{watch as i}from"../../../../core/reactiveUtils.js";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/Error.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as o,fromValues as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{d as l,l as h,g as u,u as c,e as p,k as m,J as d,c as _}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as g}from"../../../../chunks/vec42.js";import{create as b}from"../../../../geometry/support/aaBoundingBox.js";import{create as x}from"../../../../geometry/support/plane.js";import{fromPoints as T}from"../../../../geometry/support/ray.js";import{initialSplatAtlasTextureHeight as A,GaussianSplatAtlasPageAllocator as C,elementsPerSplatPage as w,splatAtlasTextureWidth as S}from"../../../../layers/support/GaussianSplatAtlasPageAllocator.js";import{GaussianSplatHit as y,isValidPointHit as P,maxAllowedVisibleGaussians as j,nodeToPosition as q}from"../../../../layers/support/gaussianSplatUtils.js";import"../../../webgl/BufferObject.js";import{FramebufferObject as v}from"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../webgl/Renderbuffer.js";import{Texture as G}from"../../../webgl/Texture.js";import{DepthStencilAttachment as D,PrimitiveType as I,PixelType as k,SizedPixelFormat as V}from"../../../webgl/enums.js";import"../../../webgl/checkWebGLError.js";import{RenderCategory as H}from"../../webgl.js";import{GaussianSplatTarget as M}from"../../layers/i3s/Intersector.js";import{makeScheduleFunction as U}from"../../layers/support/makeScheduleFunction.js";import{GaussianSplatSortWorkerHandle as B}from"../../support/GaussianSplatWorkerHandle.js";import F from"../../webgl/RenderNode.js";import{IntersectorResult as R}from"./IntersectorResult.js";import{G as E}from"../../../../chunks/GaussianSplat.glsl.js";import{G as O}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as N}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as z}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as W}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatDepthTechnique as L}from"../shaders/GaussianSplatDepthTechnique.js";import{GaussianSplatTechnique as Q}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as J}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{TextureDescriptor as Y}from"../../../webgl/TextureDescriptor.js";var K;let X=class extends F{static{K=this}static{this.tileSize=2.048}constructor(t){super(t),this.produces=H.OPAQUE,this.type=0,this.isGround=!1,this.layerViewUid="",this._gaussianSplatParameters=new E,this._gaussianSplatCompositionParameters=new O,this._gaussianSplatDepthCompositionParameters=new z,this._splatDepthTechniqueConfiguration=new J(!0),this._totalVisibleGaussians=0,this._orderTexture=null,this._textureAtlas=null,this._splatAtlasTextureHeight=A,this._visibleGaussianTiles=new s,this._workerHandle=null,this._isSorting=!1,this._pendingSortTask=!1,this._bufferCapacity=0,this._orderTextureCapacity=0,this._previousCameraPosition=f(),this._previousCameraDirection=f(),this._tanFov=o(),this._tempVec=f(),this._cameraDelta=f(),this._coarseCameraPosition=f(),this.point=f(),this.rayDir=f(),this.dirPlane=x(),this.tileBox=b(),this._slicePlaneEnabled=!1,this._cache=t.view.resourceController.memoryController.newCache("gaussian texture cache",t=>t.dispose()),this.pageAllocator=new C}async initialize(){this.view.sceneIntersectionHelper.addIntersectionHandler(this),this._ensureTextureAtlas(),this.addHandles([i(()=>this.view.state.camera,()=>this._onCameraChange())]);const{resourceController:t}=this.view;this._workerHandle=new B(U(t))}precompile(){this.techniques.precompile(Q),this.techniques.precompile(L,this._splatDepthTechniqueConfiguration),this.techniques.precompile(N),this.techniques.precompile(W)}render(t){const e=t.find(({name:t})=>t===H.OPAQUE),s=this.techniques.get(Q),i=this.techniques.get(L,this._splatDepthTechniqueConfiguration),r=this.techniques.get(N),o=this.techniques.get(W);if(!(s.compiled&&i.compiled&&o.compiled&&r.compiled))return this.requestRender(1),e;const{fullWidth:n,fullHeight:l}=this.bindParameters.camera,h=this.fboCache,u=h.acquire(n,l,"gaussian color output");u.attachDepth(e.getAttachment(D));const c=this.renderingContext;c.bindFramebuffer(u.fbo),c.setClearColor(0,0,0,0),c.clear(16384),this._gaussianSplatParameters.totalGaussians=this._totalVisibleGaussians,this._gaussianSplatParameters.splatOrder=this._orderTexture,this._gaussianSplatParameters.splatAtlas=this._textureAtlas;const p=Math.tan(.5*this.camera.fovY),m=p/l*n;a(this._tanFov,m,p);const d=l/(2*p);this._gaussianSplatParameters.focalLength=d,this._gaussianSplatParameters.tanFov=this._tanFov,this._prepareHighPrecisionCameraPosition(),this.renderingContext.bindTechnique(s,this.bindParameters,this._gaussianSplatParameters),this.renderingContext.drawArraysInstanced(I.TRIANGLE_STRIP,0,4,this._totalVisibleGaussians);const _=h.acquire(n,l,"splat depth",8);_.attachDepth(e.getAttachment(D)),c.bindFramebuffer(_.fbo),c.setClearColor(0,0,0,0),c.clear(16384),this.renderingContext.bindTechnique(i,this.bindParameters,this._gaussianSplatParameters),this.renderingContext.drawArraysInstanced(I.TRIANGLE_STRIP,0,4,this._totalVisibleGaussians);const f=h.acquire(n,l,this.produces);return this._gaussianSplatDepthCompositionParameters.splatDepth=_.getTexture(),f.attachDepth(e.getAttachment(D)),c.bindFramebuffer(f.fbo),c.bindTechnique(o,this.bindParameters,this._gaussianSplatDepthCompositionParameters),c.screen.draw(),this._gaussianSplatCompositionParameters.color=e.getTexture(),this._gaussianSplatCompositionParameters.splatColor=u.getTexture(),c.bindFramebuffer(f.fbo),c.bindTechnique(r,this.bindParameters,this._gaussianSplatCompositionParameters),c.screen.draw(),u.release(),_.release(),f}updateGaussianVisibility(t){this._visibleGaussianTiles=t,this._requestSort()}intersect(t,e,s,i){const r=f(),a=this.point,o=this.rayDir,n=this.dirPlane,d=this.layerViewUid;l(o,i,s);const _=1/h(o);u(o,o,_),c(r,o),g(n,o[0],o[1],o[2],-p(o,s));const b=new y,x=new y,A=new Array;this._visibleGaussianTiles.forAll(l=>{if(!l.obb.intersectRay(s,o,l.maxScale))return;const h=l.obb.minimumDistancePlane(n),u=l.obb.maximumDistancePlane(n),c=u<0,f=null!=b.dist&&null!=x.dist&&b.dist<h*_&&x.dist>u*_;if(c||f)return;const g=l.gaussianAtlasIndices.length,T=l.positions,C=l.squaredScales;for(let n=0;n<g;n++){const h=3*n;a[0]=T[h]-s[0],a[1]=T[h+1]-s[1],a[2]=T[h+2]-s[2];const u=C[n],c=p(a,o);if(m(a)-c*c>u)continue;const f=c*_,g=t=>(t.point=q(l,n,t.point),t.dist=f,t.normal=r,t.tile=l,t.pointId=n,t.layerViewUid=d,t);if((null==b.dist||f<b.dist)&&(null==e||e(s,i,f))&&g(b),0!==t.options.store&&(null==x.dist||f>x.dist)&&(null==e||e(s,i,f))&&g(x),2===t.options.store&&(null==e||e(s,i,f))){const t=new y;A.push(g(t))}}});const C=t=>{const{layerViewUid:e}=t;return new M(t.point,e)},w=(t,e)=>{const s=C(e);t.set(this.type,s,e.dist,e.normal)};if(P(b)){const e=t.results.min;(null==e.distance||b.dist<e.distance)&&w(e,b)}if(P(x)&&0!==t.options.store){const e=t.results.max;(null==e.distance||x.dist>e.distance)&&w(e,x)}if(2===t.options.store){const e=T(s,i);for(const s of A){const i=new R(e);w(i,s),t.results.all.push(i)}}}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(t){this._slicePlaneEnabled!==t&&(this._slicePlaneEnabled=t,this.requestRender(1))}destroy(){this._workerHandle?.destroyWorkerAndSelf(),this._textureAtlas?.dispose(),this._orderTexture?.dispose(),super.destroy()}updateTextureAtlas(t,e,s){this._ensureTextureAtlas(),this._textureAtlas.updateData(0,t,e,w,1,s)}growTextureAtlas(){if(!this._textureAtlas)return void this._ensureTextureAtlas();const t=Math.floor(this._splatAtlasTextureHeight*e),s=new v(this.renderingContext,this._textureAtlas),i=this.fboCache.acquire(S,t,"gaussian splat atlas resize",11);this.renderingContext.blitFramebuffer(s,i.fbo,16384,9728,0,0,S,this._splatAtlasTextureHeight,0,0,S,this._splatAtlasTextureHeight),this._textureAtlas?.dispose(),this._textureAtlas=i.fbo?.detachColorTexture(),i.dispose(),this._splatAtlasTextureHeight=t,this._updatePageAllocator()}_clearBuffersAndTextures(){this._bufferCapacity=0,this._orderTextureCapacity=0,this._orderTexture?.dispose(),this._orderTexture=null,this._textureAtlas&&(this._cache.put("splatTextureAtlas",this._textureAtlas),this._textureAtlas=null)}_ensureBufferCapacity(t){if(this._bufferCapacity<t){const s=Math.ceil(t*e);this._atlasIndicesBuffer=new Uint32Array(s),this._sortedAtlasIndicesBuffer=new Uint32Array(s),this._bufferCapacity=s}}_ensureOrderTextureCapacity(t){if(this._orderTextureCapacity<t){this._orderTexture?.dispose();const s=Z(Math.ceil(t*e)),i=s[0]*s[1];this._orderBuffer=new Uint32Array(i);const r=new Y;r.height=s[0],r.width=s[1],r.pixelFormat=36244,r.dataType=k.UNSIGNED_INT,r.internalFormat=V.R32UI,r.wrapMode=33071,r.samplingMode=9728,this._orderTexture=new G(this.renderingContext,r),this._orderTextureCapacity=i}}_ensureTextureAtlas(){if(this._textureAtlas)return;const t=this._cache.pop("splatTextureAtlas");if(t)return void(this._textureAtlas=t);const e=new Y;e.height=this._splatAtlasTextureHeight,e.width=S,e.pixelFormat=36249,e.dataType=k.UNSIGNED_INT,e.internalFormat=V.RGBA32UI,e.samplingMode=9728,e.wrapMode=33071,this._textureAtlas=new G(this.renderingContext,e),this._updatePageAllocator()}_updatePageAllocator(){const t=S*this._splatAtlasTextureHeight/w;this.pageAllocator.pageCount!==t&&this.pageAllocator.resize(t)}_onCameraChange(){const t=this.view.state.camera.eye,e=this.view.state.camera.ray.direction,s=.001;(Math.abs(t[0]-this._previousCameraPosition[0])>s||Math.abs(t[1]-this._previousCameraPosition[1])>s||Math.abs(t[2]-this._previousCameraPosition[2])>s||Math.abs(e[0]-this._previousCameraDirection[0])>s||Math.abs(e[1]-this._previousCameraDirection[1])>s||Math.abs(e[2]-this._previousCameraDirection[2])>s)&&this._requestSort()}_prepareHighPrecisionCameraPosition(){u(this._tempVec,this.camera.eye,1/K.tileSize),d(this._tempVec,this._tempVec),_(this._coarseCameraPosition,this._tempVec),this._gaussianSplatParameters.cameraPos8k=this._coarseCameraPosition,u(this._tempVec,this._tempVec,K.tileSize),l(this._cameraDelta,this.camera.eye,this._tempVec),this._gaussianSplatParameters.cameraDelta=this._cameraDelta}_requestSort(){this._isSorting?this._pendingSortTask=!0:(this._isSorting=!0,this._pendingSortTask=!1,this._sortOnWorker().then(()=>{this._isSorting=!1,this._pendingSortTask&&this._requestSort()}).catch(()=>{this._isSorting=!1,this._pendingSortTask&&this._requestSort()}))}async _sortOnWorker(){let t=0;if(this._visibleGaussianTiles.forAll(e=>t+=e.gaussianAtlasIndices.length),0===t||t>j)return this._totalVisibleGaussians=0,this._clearBuffersAndTextures(),void this.requestRender(1);this._ensureBufferCapacity(t),this._ensureTextureAtlas();const e=this.camera.ray.direction,s=e[0],i=e[1],r=e[2],a=1/Math.sqrt(s*s+i*i+r*r),o=s*a,n=i*a,l=r*a,h=this._atlasIndicesBuffer.subarray(0,t),u=new Float64Array(t);let c=0;this._visibleGaussianTiles.forAll(t=>{const e=t.gaussianAtlasIndices,s=t.positions;for(let i=0;i<e.length;i++){h[c]=e[i];const t=3*i,r=s[t],a=s[t+1],p=s[t+2];u[c]=r*o+a*n+p*l,c++}});const p=new Uint32Array(t);for(let d=0;d<t;d++)p[d]=d;const m={distances:u,sortOrderIndices:p};await(this._workerHandle?.sort(m).then(e=>{const s=this._sortedAtlasIndicesBuffer.subarray(0,t);for(let i=0;i<t;i++)s[i]=h[e.sortedOrderIndices[i]];this._ensureOrderTextureCapacity(t),this._orderBuffer?.set(s),this._orderTexture?.setData(this._orderBuffer),this._totalVisibleGaussians=t,this.requestRender(1)}))}};function Z(t){const e=Math.ceil(Math.sqrt(t)),s=Math.ceil(t/e);return n(e,s)}X=K=t([r("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],X);export{X as GaussianSplatRenderNode};
5
+ import{__decorate as t}from"tslib";import{watch as s}from"../../../../core/reactiveUtils.js";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as e}from"../../../../core/accessorSupport/decorators/subclass.js";import{set as i}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{d as r,l as n,g as o,u as h,e as l,k as c,J as m,c as p}from"../../../../chunks/vec32.js";import{create as u,clone as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as g}from"../../../../chunks/vec42.js";import{create as f}from"../../../../geometry/support/plane.js";import{fromPoints as _}from"../../../../geometry/support/ray.js";import{j as b,i as P}from"../../../../chunks/sphere.js";import{RenderCategory as C}from"../../webgl.js";import{GaussianSplatTarget as S}from"../../layers/i3s/Intersector.js";import{GaussianSplatDataStore as j}from"../../support/gaussianSplatting/GaussianSplatDataStore.js";import v from"../../webgl/RenderNode.js";import{IntersectorResult as w}from"./IntersectorResult.js";import{G as q}from"../../../../chunks/GaussianSplat.glsl.js";import{G as D}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as y}from"../shaders/GaussianSplatCompositionTechnique.js";import{G}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as T}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatDepthTechnique as x}from"../shaders/GaussianSplatDepthTechnique.js";import{GaussianSplatTechnique as A}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as R}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{DepthStencilAttachment as V,PrimitiveType as E}from"../../../webgl/enums.js";var I;let k=class extends v{constructor(){super(...arguments),this.gaussianPosition=u(),this.intersectionRayDir=u(),this.intersectionPlane=f(),this._slicePlaneEnabled=!1,this._data=null,this.produces=C.OPAQUE,this.type=0,this.isGround=!1,this.layerViewUid="",this._gaussianSplatParameters=new q,this._gaussianSplatCompositionParameters=new D,this._gaussianSplatDepthCompositionParameters=new G,this._splatDepthTechniqueConfiguration=new R(!0),this._previousCameraPosition=u(),this._previousCameraDirection=u(),this._tanFov=a(),this._tempVec=u(),this._cameraDelta=u(),this._coarseCameraPosition=u()}static{I=this}async initialize(){this._data=new j(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this),this.addHandles([s(()=>this.view.state.camera,()=>this._onCameraChange())])}precompile(){this.techniques.precompile(A),this.techniques.precompile(x,this._splatDepthTechniqueConfiguration),this.techniques.precompile(y),this.techniques.precompile(T)}render(t){const s=t.find(({name:t})=>t===C.OPAQUE),e=this.techniques.get(A),a=this.techniques.get(x,this._splatDepthTechniqueConfiguration),r=this.techniques.get(y),n=this.techniques.get(T);if(!(e.compiled&&a.compiled&&n.compiled&&r.compiled))return this.requestRender(1),s;const{fullWidth:o,fullHeight:h}=this.bindParameters.camera,l=this.fboCache,c=l.acquire(o,h,"gaussian color output");c.attachDepth(s.getAttachment(V));const m=this.renderingContext;m.bindFramebuffer(c.fbo),m.setClearColor(0,0,0,0),m.clear(16384),this._gaussianSplatParameters.totalGaussians=this._data.visibleGaussians,this._gaussianSplatParameters.splatOrder=this._data.orderTexture.texture,this._gaussianSplatParameters.splatAtlas=this._data.textureAtlas.texture;const p=Math.tan(.5*this.camera.fovY),u=p/h*o;i(this._tanFov,u,p);const d=h/(2*p);this._gaussianSplatParameters.focalLength=d,this._gaussianSplatParameters.tanFov=this._tanFov,this._prepareHighPrecisionCameraPosition(),this.renderingContext.bindTechnique(e,this.bindParameters,this._gaussianSplatParameters),this.renderingContext.drawArraysInstanced(E.TRIANGLE_STRIP,0,4,this._data.visibleGaussians);const g=l.acquire(o,h,"splat depth",8);g.attachDepth(s.getAttachment(V)),m.bindFramebuffer(g.fbo),m.setClearColor(0,0,0,0),m.clear(16384),this.renderingContext.bindTechnique(a,this.bindParameters,this._gaussianSplatParameters),this.renderingContext.drawArraysInstanced(E.TRIANGLE_STRIP,0,4,this._data.visibleGaussians);const f=l.acquire(o,h,this.produces);return this._gaussianSplatDepthCompositionParameters.splatDepth=g.getTexture(),f.attachDepth(s.getAttachment(V)),m.bindFramebuffer(f.fbo),m.bindTechnique(n,this.bindParameters,this._gaussianSplatDepthCompositionParameters),m.screen.draw(),this._gaussianSplatCompositionParameters.color=s.getTexture(),this._gaussianSplatCompositionParameters.splatColor=c.getTexture(),m.bindFramebuffer(f.fbo),m.bindTechnique(r,this.bindParameters,this._gaussianSplatCompositionParameters),m.screen.draw(),c.release(),g.release(),f}intersect(t,s,e,i){const{gaussianPosition:a,intersectionRayDir:m,intersectionPlane:p,layerViewUid:f}=this,C=_(e,i);r(m,i,e);const j=1/n(m);o(m,m,j);const v=u();h(v,m),g(p,m[0],m[1],m[2],-l(m,e));const q=new U,D=new U,y=new Array;this._data.visibleGaussianTiles.forEach(r=>{const{maxScale:n}=r,o=r.obb.minimumDistancePlane(p),h=r.obb.maximumDistancePlane(p),u=h<0,g=null!=q.dist&&null!=D.dist&&q.dist<o*j&&D.dist>h*j;if(u||g)return;const _=b(r.obb.center,r.obb.radius+n);if(!P(_,C,null))return;if(!r.obb.intersectRay(e,m,n))return;const{positions:S,squaredScales:w,gaussianAtlasIndices:G}=r,T=G.length;for(let p=0;p<T;p++){const r=3*p;a[0]=S[r]-e[0],a[1]=S[r+1]-e[1],a[2]=S[r+2]-e[2];const n=w[p],o=l(a,m),h=o*o;if(c(a)-h>n)continue;const u=o*j,g=t=>(t.point=t.point?t.point.fill(a[0],a[1],a[2]):d(a),t.dist=u,t.normal=v,t.layerViewUid=f,t);if((null==q.dist||u<q.dist)&&(null==s||s(e,i,u))&&g(q),0!==t.options.store&&(null==D.dist||u>D.dist)&&(null==s||s(e,i,u))&&g(D),2===t.options.store&&(null==s||s(e,i,u))){const t=new U;y.push(g(t))}}});const G=(t,s)=>{const{layerViewUid:e}=s,i=new S(s.point,e);t.set(0,i,s.dist,s.normal)};if(F(q)){const s=t.results.min;(null==s.distance||q.dist<s.distance)&&G(s,q)}if(F(D)&&0!==t.options.store){const s=t.results.max;(null==s.distance||D.dist>s.distance)&&G(s,D)}if(2===t.options.store)for(const r of y){const s=new w(C);G(s,r),t.results.all.push(s)}}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(t){this._slicePlaneEnabled!==t&&(this._slicePlaneEnabled=t,this.requestRender(1))}get data(){return this._data}destroy(){this._data.destroy(),super.destroy()}_onCameraChange(){const t=this.view.state.camera.eye,s=this.view.state.camera.ray.direction,e=.001;(Math.abs(t[0]-this._previousCameraPosition[0])>e||Math.abs(t[1]-this._previousCameraPosition[1])>e||Math.abs(t[2]-this._previousCameraPosition[2])>e||Math.abs(s[0]-this._previousCameraDirection[0])>e||Math.abs(s[1]-this._previousCameraDirection[1])>e||Math.abs(s[2]-this._previousCameraDirection[2])>e)&&this._data.requestSort()}_prepareHighPrecisionCameraPosition(){o(this._tempVec,this.camera.eye,1/I.tileSize),m(this._tempVec,this._tempVec),p(this._coarseCameraPosition,this._tempVec),this._gaussianSplatParameters.cameraPos8k=this._coarseCameraPosition,o(this._tempVec,this._tempVec,I.tileSize),r(this._cameraDelta,this.camera.eye,this._tempVec),this._gaussianSplatParameters.cameraDelta=this._cameraDelta}static{this.tileSize=2.048}};function F(t){return null!=t.dist&&null!=t.point}k=I=t([e("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],k);class U{constructor(){this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}export{k as GaussianSplatRenderNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as l}from"../../../../core/promiseUtils.js";import{watch as _,syncAndInitial as u,initial as p,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as f}from"../../../../core/time.js";import{property as g}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as P,invert as w,multiply as C}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as T,create as S}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as E}from"../../../../chunks/vec42.js";import{ZEROS as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as A,ZEROS as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as D}from"../../../../geometry/support/Indices.js";import{RenderCategory as I,InternalRenderCategory as R}from"../../webgl.js";import{innerAtmosphereFadeStart as O}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as v}from"../../state/NearFarHeuristic.js";import{debugFlags as F}from"../../support/debugFlags.js";import{FBOCache as H,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as N}from"../core/renderPasses/RenderPassManager.js";import{isColorOrColorEmission as q}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as G}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as L}from"../effects/RenderNodes.js";import{RenderPluginManager as V}from"../effects/RenderPluginManager.js";import{Blit as U}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as j,renderHighlightBuffer as B}from"../effects/highlight/Highlight.js";import{OITBlend as k}from"../effects/transparency/OITBlend.js";import{AnimationTimer as z}from"./AnimationTimer.js";import{AnimationTimeStep as Q}from"./AnimationTimeStep.js";import{BoundingInfo as W}from"./BoundingInfo.js";import{DepthRange as Y}from"./DepthRange.js";import{depthRangeFromScene as Z}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as J}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as K}from"./MainFramebuffer.js";import{RenderContext as X,defaultRenderOccludedMask as $}from"./RenderContext.js";import{RendererBase as ee}from"./RendererBase.js";import{setupFeatureDefaults as te}from"./RenderFeature.js";import{RenderPluginInput as re}from"./RenderPluginInput.js";import{ShadowAccumulator as ie}from"./ShadowAccumulator.js";import{ShadowMap as se}from"./ShadowMap.js";import ae from"./SliceHelper.js";import{MergedRenderer as ne}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as he}from"../parts/renderUtils.js";import{RendererPerformanceInfo as oe,PerformanceCategory as de}from"../statistics/RendererPerformanceInfo.js";import{PixelType as le,ColorAttachment1 as _e,ColorAttachment2 as ue}from"../../../webgl/enums.js";let pe=class extends ee{constructor(e,t,r,s,a,n){super({stage:e}),this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this.renderPassManager=new N,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=A(0,0,0,1),this._sliceHelper=new ae,this._blit=null,this._oitblend=null,this.sceneDepthRange=c(Y.Infinite),this._state=c(2),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new Q,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=f(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new re,this._releaseNormals=e=>{e.some(({name:e})=>"normals"===e)&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this._fboCache=new H(s),this._renderStateFeatures=c(te(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new K(this.fboCache),this._performanceInfo=new oe(this._rctx),this._shadowMap=new se(this.fboCache,e.viewingMode),this._shadowAccumulator=new ie(this.fboCache,r,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,r,i)=>{const s=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,r,i,!0,s),this._renderShadowCascades(4,t.shadowMap),t.shadowMap.finish(),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},n),this._renderContext=new X(this._rctx,this._shadowMap,r),this._nodes=new L(this._renderContext),this._plugins=new V({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([_(()=>e.view.state.camera,()=>n(),u),_(()=>F.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},n()},p),_(()=>e.view.environment.background?.color,e=>{const t=e?i(e):y;E(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()},u),_(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=G,u),_(()=>this._bindParameters.clouds.fadeFactor,()=>this._bindParameters.fadeLighting(),m),_(()=>this._bindParameters.clouds.data?.state,()=>n(),m),_(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,n()},p)])}destroy(){this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._blit=null,this._oitblend=null,this._compositingHelper=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,W.prune(),ne.prune(),D()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=te(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate(i=>i.set(t,e,r)),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(5))}get _hasHighlights(){return this._plugins.produces(9,2,4,18,13,14)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(9,13,14)}get hasSSAO(){return(this.stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(4))&&!this._inGlobeView}get hasSMAA(){return this.stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(0)}get fullResolutionAtmosphere(){return this.stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(3)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");l(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Ee(this.stage.view.resourceController)});return this.addHandles(_(()=>r.updating,()=>this._requestRender(),m)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(r)),this._edgeViewCallbacks.length=0,r})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&P(this._bindParameters.ssr.reprojectionMatrix,T)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,9)}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(0,...Pe),has.water=this._plugins.produces(3,19),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new z(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new he(this._pluginInput.get(I.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:l}=J,_=this.stage.view,u=_.stateManager.camera,p=_.qualitySettings.fadeDuration,m=2===e?r:i,c=s((u.tilt-h)/(o-h),0,1),f=s(((u.position.z??0)-d)/(l-d),0,1),g=a(a(1,m,c),1,f),b=this._bindParameters.hudOccludedFragmentOpacity;if(p<=0||b===g||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=g,void(this._lastFrameTime=t);const P=t-this._lastFrameTime;this._lastFrameTime=t;const w=Math.max(1-r,Math.abs(r-i)),C=Math.min(w*P/p,n);C>=Math.abs(g-b)?this._bindParameters.hudOccludedFragmentOpacity=g:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(g-b)*C,this._requestRender())}_render(e,t,r,i){const s=0===r;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=s,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h;const d=this._nodes.produces("magnifier-color"),l=this._nodes.produces(I.FINAL),_=this._plugins.hasEmitters,u=_?1:0;this._renderContext.time=t,this._renderContext.output=u,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null;const p=!i||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=p?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(R.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(R.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const m=this._framebuffer,c=m.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,_);this.hasReflections?(c?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=c):c?.release(),this._ensureBindParametersCamera(a,n),this._updateHUDOccludedFragmentOpacity(h,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const f=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(0,...ge);this._precompilePrepasses(),this.performanceInfo.advance(de.PREPARE);const b=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,b),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(b,a,n,!s),this._ensureBindParametersSSR(t),this._precompileShaders(f,g,u),this._renderContext.output=u,m.bind(),this._bindParameters.mainDepth=m.depth.attachment,this._renderOpaque(f),this._renderTransparent(g,f,u),this._shadowMap.disposeMainBuffer(),this._pluginInput.set(R.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(R.CUTFILL_DEPTH,this._renderCutFillDepth()),m.update(e=>this._renderNodes(R.TRANSPARENT_ENVIRONMENT,e)),m.update(e=>this._renderNodes(R.VIEWSHED,e)),m.update(e=>this._renderNodes(R.LASERLINES,e)),m.update(e=>this._renderNodes(R.FOCUSAREA_COLOR,e)),this._pluginInput.release(R.FOCUSAREA),this._pluginInput.release(R.CUTFILL_DEPTH),m.update(e=>this._renderNodes(R.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._renderHighlightShadowMap(a,this._bindParameters.lighting.mainLight.direction,b);const P=2===r?this._renderObjectAndLayerIdColor():null;m.update(e=>this._renderNodes(I.COMPOSITE,e)),this._shadowMap.disposeOffscreenBuffers();const w=s&&!l&&!(d&&!i),C=this._pluginInput.get(I.COMPOSITE),T=w?M:this.fboCache.acquire(C.fbo.width,C.fbo.height,R.ANTIALIASING),S=this._nodes.produces(R.ANTIALIASING)?this._renderNodes(R.ANTIALIASING,T):this.blitFBO(C,T,!1);let E;this._pluginInput.set(R.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(1,S,u),E=this._renderNodes(R.HIGHLIGHTS,S)):(E=this._renderNodes(R.HIGHLIGHTS,S),this._renderHUD(1,E,u));const x=this._renderNodes(R.MAGNIFIER,E);return s&&d&&!i&&!l&&this.blitFBO(x),l?(x.attachDepth(m.depth),this.blitFBO(this._renderNodes(I.FINAL,x)),x.detachDepth()):this._pluginInput.set(I.FINAL,x),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),m.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),s||(this._releaseFBOs(),this._disposeOffscreenBuffers()),new he(this._pluginInput.get(I.FINAL),P)}_precompileShaders(e,t,r){++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._nodes.precompile(R.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=2,this._plugins.precompile(6),this._plugins.precompile(7),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(6),this._plugins.precompile(7),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(R.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(12),this._plugins.precompile(15),this._precompileHUD(0),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(R.VIEWSHED,R.CUTFILL_DEPTH,R.LASERLINES,R.FOCUSAREA_COLOR,R.OCCLUDED,R.ANTIALIASING,R.HIGHLIGHTS);const i=this._bindParameters;i.highlightMixTexture=i.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(1),this._hasHighlights&&(i.highlights.forEach((e,t)=>{i.highlightLevel=t,this._precompileAllGeometry(9)}),i.highlightLevel=null),i.highlightMixTexture=null,this._nodes.precompile(I.COMPOSITE,R.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(8),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(R.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(de.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(13),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(de.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=0===e;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(y),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,le.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,6408,le.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"edges"),s=()=>t.render(this._bindParameters,e),a=this._bindParameters.geometryDepth;this.renderToTargets(s,i,a??this._framebuffer.depth,y),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?de.OPAQUE_EDGES:de.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(),this._bindParameters.overlay&&this.performanceInfo.advance(de.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const{contentCamera:i}=this._bindParameters,s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(6,this._shadowMap),s.copySnapshot(1),this._renderShadowCascades(5,this._shadowMap)):this._renderShadowCascades(4),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,i),this.performanceInfo.advance(de.SHADOW_MAP)}_renderHighlightShadowMap(e,t,r){if(!this.shadowsEnabled||!this._needsShadowHighlight)return;const{contentCamera:i}=this._bindParameters,s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(5,this._shadowMap),s.moveSnapshot(0),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,i),this.performanceInfo.advance(de.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(R.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){t.bindFbo();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(2)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(R.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(2),d(this._bindParameters.depth),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(de.DEPTH)):(e.detachDepth(),this._bindParameters.depth=d(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"geometry depth",13);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(1280),this.renderAllGeometry(2),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(de.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=2;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth",13);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(1280),this._renderTransparentTerrain(),d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(2),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return Y.Zero;const t=Z(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=Y.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<O)return void(this.sceneDepthRange.value=Y.Infinite);const t=e.clone();t.near=v,t.far=1e10;const r=Z(t,this._plugins.plugins,this.stage.layers,1);r.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(r)||(this.sceneDepthRange.value=r)}get _normalsRequired(){const e=this._nodes.require("normals",I.FINAL,I.COMPOSITE,I.OPAQUE,I.TRANSPARENT,R.VIEWSHED,R.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(3),this._needsDepth&&this._precompileAllGeometry(2),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(5),this._precompileShadowCascades(6),this._precompileShadowCascades(5)):this._precompileShadowCascades(4)),this._shadowAccumulator.active&&this._precompileAllGeometry(4)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",5);r.acquireDepth(13),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(y,!0,!0),this._renderGeometryWithNormals(3);const i=this._nodes.optional("normals",I.FINAL,I.COMPOSITE,I.OPAQUE,I.TRANSPARENT,R.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(de.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return;const t=this._nodes.produce(R.SSAO,this._pluginInput);return this._bindParameters.ssao=t,t&&this.performanceInfo.advance(de.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(6),this._plugins.precompile(7),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...be);this._renderContext.renderOccludedMask=$}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(9),this.renderSlots(e,...be),this._renderContext.renderOccludedMask=$}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(13)}precompileViewshedShadowMap(){this._precompileAllGeometry(7)}precompileCutFill(){const e=8,t=this._renderContext.output;this._renderContext.output=e,this._plugins.precompile(0,1,6),this._renderContext.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(7),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._renderContext.output=8,this._plugins.render(0,1),this._plugins.render(6),this._ensureBindParametersCamera(t,r),t.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(...me),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(...ce)}_precompileOpaqueGeometry(){this._plugins.precompile(...fe)}_renderOpaqueGeometry(){this._plugins.render(...fe)}_renderTransparentGeometry(){this._plugins.render(...ge)}get _hasTransparentTerrain(){return this._plugins.produces(0,6)}get _hasTransparentIntegratedMesh(){return this._plugins.produces(this._renderContext.output,7)}_renderTransparentTerrain(){const e=()=>this._plugins.render(6);if(!q(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,y),r}_renderTransparentIntegratedMesh(){const e=()=>this._plugins.render(7);if(!q(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent integrated mesh");return this.renderToTargets(e,r,this._framebuffer.depth,y),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,12)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(12),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(de.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(15),t=this._framebufferSize,r=this.fboCache.acquireDepth(12,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(15)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=9,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&q(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...Pe),this._bindParameters.oitPass=2,this._plugins.precompile(...Pe),this._bindParameters.oitPass=0):this._plugins.precompile(...Pe),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(1,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,0===e){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(12,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(0===e?de.HUD_OCCLUDED:de.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Pe)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(5,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>j?3:1);a.acquireDepth(13),t.bindFramebuffer(a.fbo);const{gl:n}=t;return n.clearBufferuiv(n.COLOR,0,[0,0,0,0]),this._renderContext.output=9,t.bindFramebuffer(a.fbo),B(t,e,i,r,()=>this._renderHighlightGeometries()),this.performanceInfo.advance(de.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(...we),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t,r,i){this._shadowAccumulator.updateDepthRange(e),this._shadowAccumulator.accumulating&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,t,r,i)&&this.performanceInfo.advance(de.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&q(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ge),this._bindParameters.oitPass=2,this._plugins.precompile(...ge),this._bindParameters.oitPass=0):this._plugins.precompile(...ge)}_renderOIT(e,t,r=2){const i=1===e,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=1;const d=a?"oit hud color+alpha":"oit color+alpha",l=this.fboCache.acquire(s.width,s.height,d,8),_=1===t;_&&l.acquireColor(_e,8,"oit emissive"),l.acquireColor(_?ue:_e,7),a||l.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(l.fbo),this._rctx.clearFramebuffer([0,0,0,1]),_&&this._rctx.clearBuffer(1,x),n(),l.detachDepth(),h.oitPass=2;const u=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return _&&u.acquireColor(_e,8,"oit emissive front"),a?u.acquireDepth(12):u.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(u.fbo),this._rctx.clearFramebuffer(y,!!a),n(),u.detachDepth(),h.oitPass=0,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):this._framebuffer.bind(),this._oitblend??=new k(this._techniques),this._oitblend.blend(this._rctx,l,u,h,_),a?.detachDepth(),u.release(),l.release(),this._renderContext.output=o,a}_renderOpaque(e){const t=this.plugins.produces(0,...fe);if(t){this._plugins.render(0,1);const e=this._framebuffer;e.update(e=>this._renderNodes(R.OPAQUE_TERRAIN,e)),e.bind(),this._plugins.render(2,3)}const r=this._framebuffer;r.update(e=>this._renderNodes(I.OPAQUE,e,t)),this.fboCache.debugCallback?.(I.OPAQUE,r.color.fbo),r.update(e=>this._renderNodes(R.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(R.OPAQUE_ENVIRONMENT,r.color.fbo),this._renderTerrainDepth(e),this._renderEdges(1)}_renderTransparent(e,t,r){const i=this._framebuffer;i.bind(),this._renderPlugins(20,de.VOXEL),this._renderHiddenTransparentEdges(),e&&(this._oitEnabled?this._renderOIT(0,r):this._renderTransparentGeometry()),i.update(t=>this._renderNodes(I.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(I.TRANSPARENT,i.color.fbo),this._renderGeometryDepth(t),this._renderHUDVisibility(),t||this._plugins.render(15),this._renderEdges(0);const s=this._hasTransparentTerrain?this._renderTransparentTerrain():null;s&&(this.performanceInfo.advance(de.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(t?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,s.getTexture())),this._renderHUD(0,i.color,r))),this._bindParameters.cullAboveTerrain=!1,s&&(i.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,s.getTexture()),s.release(),t&&(this._renderEdges(1),e&&(this._oitEnabled?this._renderOIT(0,r):this._renderTransparentGeometry(),this.performanceInfo.advance(de.TRANSPARENT)),this._renderEdges(0)));const a=this._hasTransparentIntegratedMesh?this._renderTransparentIntegratedMesh():null;a&&(i.bind(),this._compositingHelper.composite(this._bindParameters,a.getTexture()),a.release()),this._bindParameters.ssao=d(this._bindParameters.ssao),t&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(de.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(8),this.performanceInfo.advance(de.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}blitFBO(e,t=M,r=!0){return this._blit??=new U(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=T:(w(Te,this._bindParameters.camera.viewMatrix),w(Ce,this._bindParameters.camera.projectionMatrix),C(Se,Te,Ce),C(Se,this._renderContext.lastFrameCamera.viewMatrix,Se),C(Se,this._renderContext.lastFrameCamera.projectionMatrix,Se),this._reprojectionMatrix=Se);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=T,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}};e([g({readOnly:!0})],pe.prototype,"fullResolutionAtmosphere",null),e([g()],pe.prototype,"_edgeView",void 0),e([g()],pe.prototype,"updating",null),pe=e([b("esri.views.3d.webgl-engine.lib.Renderer")],pe);const me=[0,1,2,4],ce=[3,5],fe=[0,1,2,3],ge=[4,5],be=[2,4,8],Pe=[16,13,14],we=[4,5,2,3,6,0,1],Ce=S(),Te=S(),Se=S();function Ee(e){return t=>e.immediate.schedule(t)}export{pe as Renderer};
5
+ import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as s,lerp as a}from"../../../../core/mathUtils.js";import{removeMaybe as n,abortMaybe as h,destroyMaybe as o,releaseMaybe as d}from"../../../../core/maybe.js";import{throwIfAborted as l}from"../../../../core/promiseUtils.js";import{watch as _,syncAndInitial as u,initial as p,sync as m}from"../../../../core/reactiveUtils.js";import{signal as c}from"../../../../core/signal.js";import{Milliseconds as f}from"../../../../core/time.js";import{property as g}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as P,invert as w,multiply as C}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as T,create as S}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as x}from"../../../../chunks/vec42.js";import{ZEROS as E}from"../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{fromValues as A,ZEROS as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as D}from"../../../../geometry/support/Indices.js";import{RenderCategory as I,InternalRenderCategory as R}from"../../webgl.js";import{innerAtmosphereFadeStart as O}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as v}from"../../state/NearFarHeuristic.js";import{debugFlags as F}from"../../support/debugFlags.js";import{FBOCache as H,defaultWebGLFBO as M}from"../core/FBOCache.js";import{RenderPassManager as N}from"../core/renderPasses/RenderPassManager.js";import{isColorEmission as q,isColorOrColorEmission as G}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as L}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as V}from"../effects/RenderNodes.js";import{RenderPluginManager as U}from"../effects/RenderPluginManager.js";import{Blit as j}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as B,renderHighlightBuffer as k}from"../effects/highlight/Highlight.js";import{OITBlend as z}from"../effects/transparency/OITBlend.js";import{AnimationTimer as Q}from"./AnimationTimer.js";import{AnimationTimeStep as W}from"./AnimationTimeStep.js";import{BoundingInfo as Y}from"./BoundingInfo.js";import{DepthRange as Z}from"./DepthRange.js";import{depthRangeFromScene as J}from"./depthRangeUtils.js";import{hudFragmentOpacityParameters as K}from"./hudFragmentOpacityParameters.js";import{MainFramebuffer as X}from"./MainFramebuffer.js";import{RenderContext as $,defaultRenderOccludedMask as ee}from"./RenderContext.js";import{RendererBase as te}from"./RendererBase.js";import{setupFeatureDefaults as re}from"./RenderFeature.js";import{RenderPluginInput as ie}from"./RenderPluginInput.js";import{ShadowAccumulator as se}from"./ShadowAccumulator.js";import{ShadowMap as ae}from"./ShadowMap.js";import ne from"./SliceHelper.js";import{MergedRenderer as he}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as oe}from"../parts/renderUtils.js";import{RendererPerformanceInfo as de,PerformanceCategory as le}from"../statistics/RendererPerformanceInfo.js";import{PixelType as _e,ColorAttachment1 as ue,ColorAttachment2 as pe}from"../../../webgl/enums.js";let me=class extends te{constructor(e,t,r,s,a,n){super({stage:e}),this._techniques=r,this._rctx=s,this._compositingHelper=a,this._requestRender=n,this._pluginsHas={hudElements:!1,water:!1},this.renderPassManager=new N,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=A(0,0,0,1),this._sliceHelper=new ne,this._blit=null,this._oitblend=null,this.sceneDepthRange=c(Z.Infinite),this._state=c(2),this._highQualityTransparencyEnabled=!0,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new W,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=c(0),this._lastFrameTime=f(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new ie,this._releaseNormals=e=>{e.some(({name:e})=>"normals"===e)&&this._pluginInput.release("normals")},this._debugNeedsDepth=!1,this._fboCache=new H(s),this._renderStateFeatures=c(re(!has("disable-feature:high-quality-idle"),e.view.qualityProfile)),this._framebuffer=new X(this.fboCache),this._performanceInfo=new de(this._rctx),this._shadowMap=new ae(this.fboCache,e.viewingMode),this._shadowAccumulator=new se(this.fboCache,r,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,r,i)=>{const s=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,r,i,!0,s),this._renderShadowCascades(4,t.shadowMap),t.shadowMap.finish(),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},n),this._renderContext=new $(this._rctx,this._shadowMap,r),this._nodes=new V(this._renderContext),this._plugins=new U({renderContext:this._renderContext,techniques:r,materials:t,requestRender:n,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([_(()=>e.view.state.camera,()=>n(),u),_(()=>F.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},n()},p),_(()=>e.view.environment.background?.color,e=>{const t=e?i(e):y;x(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),n()},u),_(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=L,u),_(()=>this._bindParameters.clouds.fadeFactor,()=>this._bindParameters.fadeLighting(),m),_(()=>this._bindParameters.clouds.data?.state,()=>n(),m),_(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,n()},p)])}destroy(){this._gpuTimerHandle=n(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=h(this._loadEdgeViewTask),this._edgeView=o(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._blit=null,this._oitblend=null,this._compositingHelper=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,Y.prune(),he.prune(),D()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _framebufferSize(){return this._framebuffer.size}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e=null,t=!has("disable-feature:high-quality-idle")){this._renderStateFeatures.value=re(t,e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,r){this._renderStateFeatures.mutate(i=>i.set(t,e,r)),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&(this._ssrEnabled||this.isFeatureEnabled(5))}get _hasHighlights(){return this._plugins.produces(9,2,4,18,13,14)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(9,13,14)}get hasSSAO(){return(this.stage.view.qualitySettings.ambientOcclusion||this.isFeatureEnabled(4))&&!this._inGlobeView}get hasSMAA(){return this.stage.view.qualitySettings.antialiasingEnabled||this.isFeatureEnabled(0)}get fullResolutionAtmosphere(){return this.stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(3)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=d(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.depth=d(this._bindParameters.depth),this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=r(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");l(e);const r=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Ee(this.stage.view.resourceController)});return this.addHandles(_(()=>r.updating,()=>this._requestRender(),m)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(r)),this._edgeViewCallbacks.length=0,r})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&P(this._bindParameters.ssr.reprojectionMatrix,T)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:t,_bindParameters:r}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&t.maxCascades!==e.shadowMapMaxCascades&&(t.maxCascades=e.shadowMapMaxCascades,this._requestRender()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const t="virtual"!==e.environment.lighting.type;r.enableFillLights!==t&&(r.enableFillLights=t,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.shadowCast&&this._shadowAccumulator.setOptions(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,9)}updateHasFlags(){const has=this._pluginsHas;has.hudElements=this._plugins.produces(0,...we),has.water=this._plugins.produces(3,19),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new Q(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const r=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?n(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,r,i=!1){try{return this._isRendering=!0,this._render(e,t,r,i)}catch(s){console.error(`Exception during rendering: ${s}`)}finally{this._isRendering=!1}return new oe(this._pluginInput.get(I.FINAL),null)}_updateHUDOccludedFragmentOpacity(e,t){const{idleOpacity:r,navigatingOpacity:i,maxDelta:n,tiltFadeStart:h,tiltFadeEnd:o,altitudeStart:d,altitudeEnd:l}=K,_=this.stage.view,u=_.stateManager.camera,p=_.qualitySettings.fadeDuration,m=2===e?r:i,c=s((u.tilt-h)/(o-h),0,1),f=s(((u.position.z??0)-d)/(l-d),0,1),g=a(a(1,m,c),1,f),b=this._bindParameters.hudOccludedFragmentOpacity;if(p<=0||b===g||0===this._lastFrameTime||this._lastFrameTime>t)return this._bindParameters.hudOccludedFragmentOpacity=g,void(this._lastFrameTime=t);const P=t-this._lastFrameTime;this._lastFrameTime=t;const w=Math.max(1-r,Math.abs(r-i)),C=Math.min(w*P/p,n);C>=Math.abs(g-b)?this._bindParameters.hudOccludedFragmentOpacity=g:(this._bindParameters.hudOccludedFragmentOpacity=b+Math.sign(g-b)*C,this._requestRender())}_render(e,t,r,i){const s=0===r;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=s,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h;const d=this._nodes.produces("magnifier-color"),l=this._nodes.produces(I.FINAL),_=this._plugins.hasEmitters,u=_?1:0;this._renderContext.time=t,this._renderContext.output=u,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!i,this._bindParameters.mainDepth=null;const p=!i||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=p?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(R.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(R.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const m=this._framebuffer,c=m.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,_);this.hasReflections?(c?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=c):c?.release(),this._ensureBindParametersCamera(a,n),this._updateHUDOccludedFragmentOpacity(h,t),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!i;const f=this._highQualityTransparency&&this._hasTransparentTerrain,g=this._plugins.produces(0,...be);this._precompilePrepasses(),this.performanceInfo.advance(le.PREPARE);const b=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,b),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(b,a,n,!s),this._ensureBindParametersSSR(t),this._precompileShaders(f,g,u),this._renderContext.output=u,m.bind(),this._bindParameters.mainDepth=m.depth.attachment,this._renderOpaque(f),this._renderTransparent(g,f,u),this._shadowMap.disposeMainBuffer(),this._pluginInput.set(R.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(R.CUTFILL_DEPTH,this._renderCutFillDepth()),m.update(e=>this._renderNodes(R.TRANSPARENT_ENVIRONMENT,e)),m.update(e=>this._renderNodes(R.VIEWSHED,e)),m.update(e=>this._renderNodes(R.LASERLINES,e)),m.update(e=>this._renderNodes(R.FOCUSAREA_COLOR,e)),this._pluginInput.release(R.FOCUSAREA),this._pluginInput.release(R.CUTFILL_DEPTH),m.update(e=>this._renderNodes(R.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass()),this._renderHighlightShadowMap(a,this._bindParameters.lighting.mainLight.direction,b);const P=2===r?this._renderObjectAndLayerIdColor():null;m.update(e=>this._renderNodes(I.COMPOSITE,e)),this._shadowMap.disposeOffscreenBuffers();const w=s&&!l&&!(d&&!i),C=this._pluginInput.get(I.COMPOSITE),T=w?M:this.fboCache.acquire(C.fbo.width,C.fbo.height,R.ANTIALIASING),S=this._nodes.produces(R.ANTIALIASING)?this._renderNodes(R.ANTIALIASING,T):this.blitFBO(C,T,!1);let x;this._pluginInput.set(R.ANTIALIASING,S),this._hasHUDHighlights?(this._renderHUD(1,S,u),x=this._renderNodes(R.HIGHLIGHTS,S)):(x=this._renderNodes(R.HIGHLIGHTS,S),this._renderHUD(1,x,u));const E=this._renderNodes(R.MAGNIFIER,x);return s&&d&&!i&&!l&&this.blitFBO(E),l?(E.attachDepth(m.depth),this.blitFBO(this._renderNodes(I.FINAL,E)),E.detachDepth()):this._pluginInput.set(I.FINAL,E),this._pluginInput.release("highlights"),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),m.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),this.performanceInfo.finishFrame(),s||(this._releaseFBOs(),this._disposeOffscreenBuffers()),new oe(this._pluginInput.get(I.FINAL),P)}_precompileShaders(e,t,r){++this._plugins.context.techniques.precompiling,this._renderContext.output=r,this._precompileOpaqueGeometry(),this._nodes.precompile(R.OPAQUE_ENVIRONMENT),this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,this._renderContext.output=2,this._plugins.precompile(6),this._plugins.precompile(7),e&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._renderContext.output=r,this._plugins.precompile(6),this._plugins.precompile(7),t&&(this._precompileTransparentGeometry(),this._hasTransparentTerrain&&(this._bindParameters.cullAboveTerrain=!1,this._precompileTransparentGeometry(),this._bindParameters.cullAboveTerrain=e)),this._nodes.precompile(R.FOCUSAREA),this._needsHUDVisibility&&this._plugins.precompile(12),this._plugins.precompile(15),this._precompileHUD(0),this._bindParameters.terrainDepthTest=!1,this._bindParameters.cullAboveTerrain=!1,this._nodes.precompile(R.VIEWSHED,R.CUTFILL_DEPTH,R.LASERLINES,R.FOCUSAREA_COLOR,R.OCCLUDED,R.ANTIALIASING,R.HIGHLIGHTS);const i=this._bindParameters;i.highlightMixTexture=i.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(1),this._hasHighlights&&(i.highlights.forEach((e,t)=>{i.highlightLevel=t,this._precompileAllGeometry(9)}),i.highlightLevel=null),i.highlightMixTexture=null,this._nodes.precompile(I.COMPOSITE,R.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(8),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(R.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(le.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._renderContext.output;++this._techniques.precompiling;const t=this._framebufferSize;let r=this.fboCache.acquire(t.width,t.height,"olid");return r.acquireDepth(13),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(le.OBJECT_AND_LAYER_ID_COLOR),this._renderContext.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,r=0===e;if(r||t){const e=r?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const s=Math.max(e,i);this._animationTimestep.frame(s,r)}}readMainDepth(e,t){const{mainDepth:r,camera:i}=this._bindParameters;if(!r)return;const s=this.fboCache.acquire(this._framebufferSize.width,this._framebufferSize.height,"linear depth");this._rctx.bindFramebuffer(s.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(y),this._compositingHelper.blitDepthToLinearDepth(this._bindParameters,r),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),s.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,_e.UNSIGNED_BYTE,t),s.release()}readHUDVisibility(e,t,r,i,s){this._bindParameters.hudVisibility?.fbo?.readPixels(e,t,r,i,6408,_e.UNSIGNED_BYTE,s)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_renderEdges(e){const t=this._edgeView;if(!t?.shouldRender())return;const r=this._renderContext.output,i=this._framebufferSize,s=this.fboCache.acquire(i.width,i.height,"edges"),a=()=>t.render(this._bindParameters,e),n=this._bindParameters.geometryDepth;this.renderToTargets(a,s,n??this._framebuffer.depth,y),this._framebuffer.bind(),this._compositingHelper.composite(this._bindParameters,s.getTexture(),q(r)?1:0),s.release(),this.performanceInfo.advance(1===e?le.OPAQUE_EDGES:le.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(),this._bindParameters.overlay&&this.performanceInfo.advance(le.OVERLAY)}_renderShadowMap(e,t,r){if(!this.shadowsEnabled)return;const{contentCamera:i}=this._bindParameters,s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(6,this._shadowMap),s.copySnapshot(1),this._renderShadowCascades(5,this._shadowMap)):this._renderShadowCascades(4),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,i),this.performanceInfo.advance(le.SHADOW_MAP)}_renderHighlightShadowMap(e,t,r){if(!this.shadowsEnabled||!this._needsShadowHighlight)return;const{contentCamera:i}=this._bindParameters,s=this._shadowMap;s.start(e,t,r,this.isFeatureEnabled(6),this.stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(5,this._shadowMap),s.moveSnapshot(0),s.finish(),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,i),this.performanceInfo.advance(le.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(R.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){for(const t of this._shadowMap.cascades)t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.camera),this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){t.bindFbo();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e)}get _needsDepth(){return this._plugins.consumes(2)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(R.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(2),d(this._bindParameters.depth),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(le.DEPTH)):(e.detachDepth(),this._bindParameters.depth=d(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(!this._needsDepth)return void(this._bindParameters.depth=d(this._bindParameters.depth));const e=this._framebufferSize,t=this.fboCache.acquire(e.width,e.height,"geometry depth",13);this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(1280),this.renderAllGeometry(2),d(this._bindParameters.depth),this._bindParameters.depth=t.obtainDepthTexture(),t.release(),this.performanceInfo.advance(le.DEPTH)}_renderTerrainDepth(e){if(this._bindParameters.terrainDepthTest=e,this._bindParameters.cullAboveTerrain=e,!e)return void(this._bindParameters.terrainDepth=d(this._bindParameters.terrainDepth));const t=this._renderContext.output;this._renderContext.output=2;const r=this._framebufferSize,i=this.fboCache.acquire(r.width,r.height,"terrain depth",13);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(1280),this._renderTransparentTerrain(),d(this._bindParameters.terrainDepth),this._bindParameters.terrainDepth=i.obtainDepthTexture(),this._renderContext.output=t,i.release()}_renderGeometryDepth(e){if(!e)return void(this._bindParameters.geometryDepth=d(this._bindParameters.geometryDepth));const t=this._renderContext.output,{width:r,height:i}=this._framebufferSize,s=this.fboCache.acquire(r,i,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(2),this._renderContext.output=t,d(this._bindParameters.geometryDepth),this._bindParameters.geometryDepth=s.obtainDepthTexture(),s.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return Z.Zero;const t=J(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=Z.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<O)return void(this.sceneDepthRange.value=Z.Infinite);const t=e.clone();t.near=v,t.far=1e10;const r=J(t,this._plugins.plugins,this.stage.layers,1);r.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(r)||(this.sceneDepthRange.value=r)}get _normalsRequired(){const e=this._nodes.require("normals",I.FINAL,I.COMPOSITE,I.OPAQUE,I.TRANSPARENT,R.VIEWSHED,R.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(3),this._needsDepth&&this._precompileAllGeometry(2),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(5),this._precompileShadowCascades(6),this._precompileShadowCascades(5)):this._precompileShadowCascades(4)),this._shadowAccumulator.active&&this._precompileAllGeometry(4)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"normals",5);r.acquireDepth(13),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(y,!0,!0),this._renderGeometryWithNormals(3);const i=this._nodes.optional("normals",I.FINAL,I.COMPOSITE,I.OPAQUE,I.TRANSPARENT,R.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(le.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(!this.hasSSAO||!e)return;const t=this._nodes.produce(R.SSAO,this._pluginInput);return this._bindParameters.ssao=t,t&&this.performanceInfo.advance(le.SSAO),t}_precompileAllGeometry(e){const t=this._renderContext.output;this._renderContext.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(6),this._plugins.precompile(7),this._renderContext.output=t}renderAllGeometry(e){this._renderContext.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentTerrain()}precompileSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const r of t)this._renderContext.renderOccludedMask=r,this.precompileSlots(e,...Pe);this._renderContext.renderOccludedMask=ee}renderSlots(e,...t){for(const r of t)this._bindParameters.slot=r,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(9),this.renderSlots(e,...Pe),this._renderContext.renderOccludedMask=ee}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(13)}precompileViewshedShadowMap(){this._precompileAllGeometry(7)}precompileCutFill(){const e=8,t=this._renderContext.output;this._renderContext.output=e,this._plugins.precompile(0,1,6),this._renderContext.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(7),this._ensureBindParametersCamera(t,r),this._bindParameters.camera.setGLViewport(this._rctx),this._renderContext.output=i}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:r}=this._bindParameters,i=this._renderContext.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._renderContext.output=8,this._plugins.render(0,1),this._plugins.render(6),this._ensureBindParametersCamera(t,r),t.setGLViewport(this._rctx),this._renderContext.output=i}_renderOpaqueAndTransparentGeometry(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithNormals(e){this._renderContext.output=e,this._plugins.render(...ce),this._renderTransparentTerrain()}_renderGeometryWithoutNormals(e){this._renderContext.output=e,this._plugins.render(...fe)}_precompileOpaqueGeometry(){this._plugins.precompile(...ge)}_renderOpaqueGeometry(){this._plugins.render(...ge)}_renderTransparentGeometry(){this._plugins.render(...be)}get _hasTransparentTerrain(){return this._plugins.produces(0,6)}get _hasTransparentIntegratedMesh(){return this._plugins.produces(this._renderContext.output,7)}_renderTransparentTerrain(){const e=()=>this._plugins.render(6);if(!G(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent terrain");return this.renderToTargets(e,r,this._framebuffer.depth,y),r}_renderTransparentIntegratedMesh(){const e=()=>this._plugins.render(7);if(!G(this._renderContext.output))return void e();const t=this._framebufferSize,r=this.fboCache.acquire(t.width,t.height,"transparent integrated mesh");return this.renderToTargets(e,r,this._framebuffer.depth,y),r}get _needsHUDVisibility(){return this._plugins.produces(this._renderContext.output,12)}_renderHUDVisibility(){if(!this._needsHUDVisibility)return void(this._bindParameters.hudVisibility=d(this._bindParameters.hudVisibility));const{width:e,height:t}=this._framebufferSize;let r=this._bindParameters.hudVisibility;r?.fbo?.width===e&&r?.fbo?.height===t||(r?.release(),r=this.fboCache.acquire(e,t,"hud visibility",4),this._bindParameters.hudVisibility=r);const i=this._bindParameters.geometryDepth;r.attachDepth(i||this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer([0,1,0,1]),this._plugins.render(12),r.detachDepth(),this._framebuffer.bind(),this.performanceInfo.advance(le.HUD_VISIBILITY)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(15),t=this._framebufferSize,r=this.fboCache.acquireDepth(12,t.width,t.height,"line callouts");this.renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(15)}_precompileHUD(e){if(this._precompileHUDOutput(e),this._hasHighlights){const t=this._renderContext.output;this._renderContext.output=9,this._precompileHUDOutput(e),this._renderContext.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this._oitEnabled&&G(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...we),this._bindParameters.oitPass=2,this._plugins.precompile(...we),this._bindParameters.oitPass=0):this._plugins.precompile(...we),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t,r){if(this._pluginsHas.hudElements){if(this._oitEnabled){const i=this._renderOIT(1,r,e);this._rctx.bindFramebuffer(t.fbo),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,i.getTexture()),i.release()}else if(this._renderContext.output=r,0===e){const t=()=>this._renderHUDElements(e),r=this._framebufferSize,i=this.fboCache.acquireDepth(12,r.width,r.height,"hud");this.renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._renderHUDElements(e),t.detachDepth();this.performanceInfo.advance(0===e?le.HUD_OCCLUDED:le.HUD)}}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...we)}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(5,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:r}=this,i=this._framebufferSize,{highlights:s}=r,a=e.acquire(i.width,i.height,"highlights",s.length>B?3:1);a.acquireDepth(13),t.bindFramebuffer(a.fbo);const{gl:n}=t;return n.clearBufferuiv(n.COLOR,0,[0,0,0,0]),this._renderContext.output=9,t.bindFramebuffer(a.fbo),k(t,e,i,r,()=>this._renderHighlightGeometries()),this.performanceInfo.advance(le.HIGHLIGHTS),a}_renderHighlightGeometries(){this._plugins.render(...Ce),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t,r,i){this._shadowAccumulator.updateDepthRange(e),this._shadowAccumulator.accumulating&&this._bindParameters.depth&&this._shadowAccumulator.renderAccumulation(this._bindParameters.depth,t,r,i)&&this.performanceInfo.advance(le.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this._oitEnabled&&G(this._renderContext.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...be),this._bindParameters.oitPass=2,this._plugins.precompile(...be),this._bindParameters.oitPass=0):this._plugins.precompile(...be)}_renderOIT(e,t,r=2){const i=1===e,s=this._framebufferSize,a=i?this.fboCache.acquire(s.width,s.height,"oit hud composite"):null,n=i?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._renderContext.output;this._renderContext.output=t,h.oitPass=1;const d=a?"oit hud color+alpha":"oit color+alpha",l=this.fboCache.acquire(s.width,s.height,d,8),_=1===t;_&&l.acquireColor(ue,8,"oit emissive"),l.acquireColor(_?pe:ue,7),a||l.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(l.fbo),this._rctx.clearFramebuffer([0,0,0,1]),_&&this._rctx.clearBuffer(1,E),n(),l.detachDepth(),h.oitPass=2;const u=this.fboCache.acquire(s.width,s.height,a?"oit hud front":"oit front");return _&&u.acquireColor(ue,8,"oit emissive front"),a?u.acquireDepth(12):u.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(u.fbo),this._rctx.clearFramebuffer(y,!!a),n(),u.detachDepth(),h.oitPass=0,a?(this._rctx.bindFramebuffer(a.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):this._framebuffer.bind(),this._oitblend??=new z(this._techniques),this._oitblend.blend(this._rctx,l,u,h,_),a?.detachDepth(),u.release(),l.release(),this._renderContext.output=o,a}_renderOpaque(e){const t=this.plugins.produces(0,...ge);if(t){this._plugins.render(0,1);const e=this._framebuffer;e.update(e=>this._renderNodes(R.OPAQUE_TERRAIN,e)),e.bind(),this._plugins.render(2,3)}const r=this._framebuffer;r.update(e=>this._renderNodes(I.OPAQUE,e,t)),this.fboCache.debugCallback?.(I.OPAQUE,r.color.fbo),r.update(e=>this._renderNodes(R.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(R.OPAQUE_ENVIRONMENT,r.color.fbo),this._renderTerrainDepth(e),this._renderEdges(1)}_renderTransparent(e,t,r){const i=this._framebuffer;i.bind(),this._renderPlugins(20,le.VOXEL),this._renderHiddenTransparentEdges(),e&&(this._oitEnabled?this._renderOIT(0,r):this._renderTransparentGeometry()),i.update(t=>this._renderNodes(I.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(I.TRANSPARENT,i.color.fbo),this._renderGeometryDepth(t),this._renderHUDVisibility(),t||this._plugins.render(15),this._renderEdges(0);const s=this._hasTransparentTerrain?this._renderTransparentTerrain():null;s&&(this.performanceInfo.advance(le.TRANSPARENT_TERRAIN),this._bindParameters.hudVisibility&&(t?this._renderLineCallouts(0):(this._rctx.bindFramebuffer(this._bindParameters.hudVisibility?.fbo),this._compositingHelper.compositeHUD(this._bindParameters,s.getTexture())),this._renderHUD(0,i.color,r))),this._bindParameters.cullAboveTerrain=!1,s&&(i.bind(),this._compositingHelper.compositePreMultipliedAlpha(this._bindParameters,s.getTexture()),s.release(),t&&(this._renderEdges(1),e&&(this._oitEnabled?this._renderOIT(0,r):this._renderTransparentGeometry(),this.performanceInfo.advance(le.TRANSPARENT)),this._renderEdges(0)));const a=this._hasTransparentIntegratedMesh?this._renderTransparentIntegratedMesh():null;a&&(i.bind(),this._compositingHelper.composite(this._bindParameters,a.getTexture(),q(r)?1:0),a.release()),this._bindParameters.ssao=d(this._bindParameters.ssao),t&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(le.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(8),this.performanceInfo.advance(le.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderPlugins(e,t){this._plugins.produces(this._renderContext.output,e)&&(this._plugins.render(e),this.performanceInfo.advance(t))}_renderNodes(e,t,r=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return r&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNormals);return this.performanceInfo.advance(e),i}blitFBO(e,t=M,r=!0){return this._blit??=new j(this._techniques),this._blit.blit(this._rctx,e,t,this._bindParameters),this._pluginInput.set(e.name,t),r&&e.release(),t}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=T:(w(Se,this._bindParameters.camera.viewMatrix),w(Te,this._bindParameters.camera.projectionMatrix),C(xe,Se,Te),C(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),C(xe,this._renderContext.lastFrameCamera.projectionMatrix,xe),this._reprojectionMatrix=xe);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=T,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,r,i){this._bindParameters.updateLighting(e,t,r,i),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}renderToTargets(e,t,r,i,s=!1,a=!1){t.attachDepth(r),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(i,s,a),e(),t.detachDepth()}get test(){}};e([g({readOnly:!0})],me.prototype,"fullResolutionAtmosphere",null),e([g()],me.prototype,"_edgeView",void 0),e([g()],me.prototype,"updating",null),me=e([b("esri.views.3d.webgl-engine.lib.Renderer")],me);const ce=[0,1,2,4],fe=[3,5],ge=[0,1,2,3],be=[4,5],Pe=[2,4,8],we=[16,13,14],Ce=[4,5,2,3,6,0,1],Te=S(),Se=S(),xe=S();function Ee(e){return t=>e.immediate.schedule(t)}export{me as Renderer};