@arcgis/core 4.25.0-next.20220920 → 4.25.0-next.20220921

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 (460) hide show
  1. package/AggregateGraphic.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{9f31ab2247c9defb882c.js → 01ac91fc0bc6b4d4e3c6.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{8588cbecb8e808f451fe.js → 249e32af1f2d433fae4c.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{5b16b30ac3166f33e81e.js → 26690f4ec1f3cb8099c2.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{be93b0cef85665446944.js → 274b4cdf6c8d77e8a2e6.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{d5650f455ce5ba15ad10.js → 2cae0ec5f60ab42a49aa.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{f436c86f86236ea7ea04.js → 4641e10e0e8e9d257521.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{7a45333de9ded92619c2.js → 466008f793c2e11e854c.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{c9d655675552dcf6cef7.js → 4a699b41072ee88f0956.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{14ea96e398f4842abe4e.js → 4fdd18f5cdaa0d82ebc1.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{9662da3e1e37f3445186.js → 562b9619b8ee13734813.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{8bab21bc6164a593278f.js → 771b92e524802de840ba.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{4969b64dc17378d7781f.js → 7ce250cc6fbe68aef50d.js} +3 -3
  15. package/assets/esri/core/workers/chunks/{2c4938512dd726a177dd.js → 7fab18074b130b71a648.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{f67357b3c6c591c9da5e.js → 872f1cb3596fb80e387f.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{31de71018575457155e5.js → 8ee3da8677255b8c8709.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{2e44aee22e70857b893c.js → 93631b10452b0e0189b3.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{cb2dc84d972469445da6.js → 95cd9edca50ea163d50f.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{d31bbb13af45ce8e45dc.js → acf9f753741b677afb44.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{1455944edeba1560eb07.js → afdafa77f5ca1b9e3acc.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{cf3e1ac63580bc495ea6.js → b4da35f1093f3731f9ac.js} +1 -1
  23. package/assets/esri/core/workers/chunks/bb0d86937faf0cd7d16d.js +1 -0
  24. package/assets/esri/core/workers/chunks/bf3e80023e156d5906c7.js +1 -0
  25. package/assets/esri/core/workers/chunks/{8ba83fee56dd4f306d87.js → c2a6ac7046134f725cf3.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{5d3fabe66e1bce1b30fb.js → cc7569489b572b8b3b53.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{fddd4ea487788e003fb1.js → d09f06eb4157a7c2c8ab.js} +1 -1
  28. package/assets/esri/core/workers/chunks/e064035f959d68e9603f.js +1 -0
  29. package/assets/esri/core/workers/chunks/{d92975e56a1290255252.js → e09df62cf35d636b0975.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{674fa5b93704ef08c9e8.js → e0c763e05feb1c2093ba.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{51289d2f5277af4023e9.js → ed33e019bc7775db2e50.js} +1 -1
  32. package/assets/esri/core/workers/chunks/ef95d6ab7b1c032ab4ad.js +1 -0
  33. package/assets/esri/core/workers/chunks/{169f4354a375db5de121.js → ffcbcb928b6cb8c596ad.js} +1 -1
  34. package/assets/esri/t9n/common_ar.json +1 -1
  35. package/assets/esri/t9n/common_bg.json +1 -1
  36. package/assets/esri/t9n/common_bs.json +1 -1
  37. package/assets/esri/t9n/common_ca.json +1 -1
  38. package/assets/esri/t9n/common_cs.json +1 -1
  39. package/assets/esri/t9n/common_da.json +1 -1
  40. package/assets/esri/t9n/common_de.json +1 -1
  41. package/assets/esri/t9n/common_el.json +1 -1
  42. package/assets/esri/t9n/common_es.json +1 -1
  43. package/assets/esri/t9n/common_et.json +1 -1
  44. package/assets/esri/t9n/common_fi.json +1 -1
  45. package/assets/esri/t9n/common_fr.json +1 -1
  46. package/assets/esri/t9n/common_he.json +1 -1
  47. package/assets/esri/t9n/common_hr.json +1 -1
  48. package/assets/esri/t9n/common_hu.json +1 -1
  49. package/assets/esri/t9n/common_id.json +1 -1
  50. package/assets/esri/t9n/common_it.json +1 -1
  51. package/assets/esri/t9n/common_ja.json +1 -1
  52. package/assets/esri/t9n/common_ko.json +1 -1
  53. package/assets/esri/t9n/common_lt.json +1 -1
  54. package/assets/esri/t9n/common_lv.json +1 -1
  55. package/assets/esri/t9n/common_nb.json +1 -1
  56. package/assets/esri/t9n/common_nl.json +1 -1
  57. package/assets/esri/t9n/common_pl.json +1 -1
  58. package/assets/esri/t9n/common_pt-BR.json +1 -1
  59. package/assets/esri/t9n/common_pt-PT.json +1 -1
  60. package/assets/esri/t9n/common_ro.json +1 -1
  61. package/assets/esri/t9n/common_ru.json +1 -1
  62. package/assets/esri/t9n/common_sk.json +1 -1
  63. package/assets/esri/t9n/common_sl.json +1 -1
  64. package/assets/esri/t9n/common_sr.json +1 -1
  65. package/assets/esri/t9n/common_sv.json +1 -1
  66. package/assets/esri/t9n/common_th.json +1 -1
  67. package/assets/esri/t9n/common_tr.json +1 -1
  68. package/assets/esri/t9n/common_uk.json +1 -1
  69. package/assets/esri/t9n/common_vi.json +1 -1
  70. package/assets/esri/t9n/common_zh-CN.json +1 -1
  71. package/assets/esri/t9n/common_zh-HK.json +1 -1
  72. package/assets/esri/t9n/common_zh-TW.json +1 -1
  73. package/assets/esri/widgets/Feature/t9n/Feature_ar.json +1 -1
  74. package/assets/esri/widgets/Feature/t9n/Feature_bg.json +1 -1
  75. package/assets/esri/widgets/Feature/t9n/Feature_bs.json +1 -1
  76. package/assets/esri/widgets/Feature/t9n/Feature_ca.json +1 -1
  77. package/assets/esri/widgets/Feature/t9n/Feature_cs.json +1 -1
  78. package/assets/esri/widgets/Feature/t9n/Feature_da.json +1 -1
  79. package/assets/esri/widgets/Feature/t9n/Feature_de.json +1 -1
  80. package/assets/esri/widgets/Feature/t9n/Feature_el.json +1 -1
  81. package/assets/esri/widgets/Feature/t9n/Feature_es.json +1 -1
  82. package/assets/esri/widgets/Feature/t9n/Feature_et.json +1 -1
  83. package/assets/esri/widgets/Feature/t9n/Feature_fi.json +1 -1
  84. package/assets/esri/widgets/Feature/t9n/Feature_fr.json +1 -1
  85. package/assets/esri/widgets/Feature/t9n/Feature_he.json +1 -1
  86. package/assets/esri/widgets/Feature/t9n/Feature_hr.json +1 -1
  87. package/assets/esri/widgets/Feature/t9n/Feature_hu.json +1 -1
  88. package/assets/esri/widgets/Feature/t9n/Feature_id.json +1 -1
  89. package/assets/esri/widgets/Feature/t9n/Feature_it.json +1 -1
  90. package/assets/esri/widgets/Feature/t9n/Feature_ja.json +1 -1
  91. package/assets/esri/widgets/Feature/t9n/Feature_ko.json +1 -1
  92. package/assets/esri/widgets/Feature/t9n/Feature_lt.json +1 -1
  93. package/assets/esri/widgets/Feature/t9n/Feature_lv.json +1 -1
  94. package/assets/esri/widgets/Feature/t9n/Feature_nb.json +1 -1
  95. package/assets/esri/widgets/Feature/t9n/Feature_nl.json +1 -1
  96. package/assets/esri/widgets/Feature/t9n/Feature_pl.json +1 -1
  97. package/assets/esri/widgets/Feature/t9n/Feature_pt-BR.json +1 -1
  98. package/assets/esri/widgets/Feature/t9n/Feature_pt-PT.json +1 -1
  99. package/assets/esri/widgets/Feature/t9n/Feature_ro.json +1 -1
  100. package/assets/esri/widgets/Feature/t9n/Feature_ru.json +1 -1
  101. package/assets/esri/widgets/Feature/t9n/Feature_sk.json +1 -1
  102. package/assets/esri/widgets/Feature/t9n/Feature_sl.json +1 -1
  103. package/assets/esri/widgets/Feature/t9n/Feature_sr.json +1 -1
  104. package/assets/esri/widgets/Feature/t9n/Feature_sv.json +1 -1
  105. package/assets/esri/widgets/Feature/t9n/Feature_th.json +1 -1
  106. package/assets/esri/widgets/Feature/t9n/Feature_tr.json +1 -1
  107. package/assets/esri/widgets/Feature/t9n/Feature_uk.json +1 -1
  108. package/assets/esri/widgets/Feature/t9n/Feature_vi.json +1 -1
  109. package/assets/esri/widgets/Feature/t9n/Feature_zh-CN.json +1 -1
  110. package/assets/esri/widgets/Feature/t9n/Feature_zh-HK.json +1 -1
  111. package/assets/esri/widgets/Feature/t9n/Feature_zh-TW.json +1 -1
  112. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ar.json +1 -1
  113. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bg.json +1 -1
  114. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bs.json +1 -1
  115. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ca.json +1 -1
  116. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_cs.json +1 -1
  117. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_da.json +1 -1
  118. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_de.json +1 -1
  119. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_el.json +1 -1
  120. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_es.json +1 -1
  121. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_et.json +1 -1
  122. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fi.json +1 -1
  123. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fr.json +1 -1
  124. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_he.json +1 -1
  125. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hr.json +1 -1
  126. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hu.json +1 -1
  127. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_id.json +1 -1
  128. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_it.json +1 -1
  129. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ja.json +1 -1
  130. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ko.json +1 -1
  131. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lt.json +1 -1
  132. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lv.json +1 -1
  133. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_nb.json +1 -1
  134. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_nl.json +1 -1
  135. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pl.json +1 -1
  136. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-BR.json +1 -1
  137. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-PT.json +1 -1
  138. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ro.json +1 -1
  139. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ru.json +1 -1
  140. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sk.json +1 -1
  141. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sl.json +1 -1
  142. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sr.json +1 -1
  143. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sv.json +1 -1
  144. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_th.json +1 -1
  145. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_tr.json +1 -1
  146. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_uk.json +1 -1
  147. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_vi.json +1 -1
  148. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-CN.json +1 -1
  149. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-HK.json +1 -1
  150. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-TW.json +1 -1
  151. package/assets/esri/widgets/Popup/t9n/Popup_ar.json +1 -1
  152. package/assets/esri/widgets/Popup/t9n/Popup_bg.json +1 -1
  153. package/assets/esri/widgets/Popup/t9n/Popup_bs.json +1 -1
  154. package/assets/esri/widgets/Popup/t9n/Popup_ca.json +1 -1
  155. package/assets/esri/widgets/Popup/t9n/Popup_cs.json +1 -1
  156. package/assets/esri/widgets/Popup/t9n/Popup_da.json +1 -1
  157. package/assets/esri/widgets/Popup/t9n/Popup_de.json +1 -1
  158. package/assets/esri/widgets/Popup/t9n/Popup_el.json +1 -1
  159. package/assets/esri/widgets/Popup/t9n/Popup_es.json +1 -1
  160. package/assets/esri/widgets/Popup/t9n/Popup_et.json +1 -1
  161. package/assets/esri/widgets/Popup/t9n/Popup_fi.json +1 -1
  162. package/assets/esri/widgets/Popup/t9n/Popup_fr.json +1 -1
  163. package/assets/esri/widgets/Popup/t9n/Popup_he.json +1 -1
  164. package/assets/esri/widgets/Popup/t9n/Popup_hr.json +1 -1
  165. package/assets/esri/widgets/Popup/t9n/Popup_hu.json +1 -1
  166. package/assets/esri/widgets/Popup/t9n/Popup_id.json +1 -1
  167. package/assets/esri/widgets/Popup/t9n/Popup_it.json +1 -1
  168. package/assets/esri/widgets/Popup/t9n/Popup_ja.json +1 -1
  169. package/assets/esri/widgets/Popup/t9n/Popup_ko.json +1 -1
  170. package/assets/esri/widgets/Popup/t9n/Popup_lt.json +1 -1
  171. package/assets/esri/widgets/Popup/t9n/Popup_lv.json +1 -1
  172. package/assets/esri/widgets/Popup/t9n/Popup_nb.json +1 -1
  173. package/assets/esri/widgets/Popup/t9n/Popup_nl.json +1 -1
  174. package/assets/esri/widgets/Popup/t9n/Popup_pl.json +1 -1
  175. package/assets/esri/widgets/Popup/t9n/Popup_pt-BR.json +1 -1
  176. package/assets/esri/widgets/Popup/t9n/Popup_pt-PT.json +1 -1
  177. package/assets/esri/widgets/Popup/t9n/Popup_ro.json +1 -1
  178. package/assets/esri/widgets/Popup/t9n/Popup_ru.json +1 -1
  179. package/assets/esri/widgets/Popup/t9n/Popup_sk.json +1 -1
  180. package/assets/esri/widgets/Popup/t9n/Popup_sl.json +1 -1
  181. package/assets/esri/widgets/Popup/t9n/Popup_sr.json +1 -1
  182. package/assets/esri/widgets/Popup/t9n/Popup_sv.json +1 -1
  183. package/assets/esri/widgets/Popup/t9n/Popup_th.json +1 -1
  184. package/assets/esri/widgets/Popup/t9n/Popup_tr.json +1 -1
  185. package/assets/esri/widgets/Popup/t9n/Popup_uk.json +1 -1
  186. package/assets/esri/widgets/Popup/t9n/Popup_vi.json +1 -1
  187. package/assets/esri/widgets/Popup/t9n/Popup_zh-CN.json +1 -1
  188. package/assets/esri/widgets/Popup/t9n/Popup_zh-HK.json +1 -1
  189. package/assets/esri/widgets/Popup/t9n/Popup_zh-TW.json +1 -1
  190. package/assets/esri/widgets/support/t9n/DatePicker_ar.json +1 -1
  191. package/assets/esri/widgets/support/t9n/DatePicker_bg.json +1 -1
  192. package/assets/esri/widgets/support/t9n/DatePicker_bs.json +1 -1
  193. package/assets/esri/widgets/support/t9n/DatePicker_ca.json +1 -1
  194. package/assets/esri/widgets/support/t9n/DatePicker_cs.json +1 -1
  195. package/assets/esri/widgets/support/t9n/DatePicker_da.json +1 -1
  196. package/assets/esri/widgets/support/t9n/DatePicker_de.json +1 -1
  197. package/assets/esri/widgets/support/t9n/DatePicker_el.json +1 -1
  198. package/assets/esri/widgets/support/t9n/DatePicker_es.json +1 -1
  199. package/assets/esri/widgets/support/t9n/DatePicker_et.json +1 -1
  200. package/assets/esri/widgets/support/t9n/DatePicker_fi.json +1 -1
  201. package/assets/esri/widgets/support/t9n/DatePicker_fr.json +1 -1
  202. package/assets/esri/widgets/support/t9n/DatePicker_he.json +1 -1
  203. package/assets/esri/widgets/support/t9n/DatePicker_hr.json +1 -1
  204. package/assets/esri/widgets/support/t9n/DatePicker_hu.json +1 -1
  205. package/assets/esri/widgets/support/t9n/DatePicker_id.json +1 -1
  206. package/assets/esri/widgets/support/t9n/DatePicker_it.json +1 -1
  207. package/assets/esri/widgets/support/t9n/DatePicker_ja.json +1 -1
  208. package/assets/esri/widgets/support/t9n/DatePicker_ko.json +1 -1
  209. package/assets/esri/widgets/support/t9n/DatePicker_lt.json +1 -1
  210. package/assets/esri/widgets/support/t9n/DatePicker_lv.json +1 -1
  211. package/assets/esri/widgets/support/t9n/DatePicker_nb.json +1 -1
  212. package/assets/esri/widgets/support/t9n/DatePicker_nl.json +1 -1
  213. package/assets/esri/widgets/support/t9n/DatePicker_pl.json +1 -1
  214. package/assets/esri/widgets/support/t9n/DatePicker_pt-BR.json +1 -1
  215. package/assets/esri/widgets/support/t9n/DatePicker_pt-PT.json +1 -1
  216. package/assets/esri/widgets/support/t9n/DatePicker_ro.json +1 -1
  217. package/assets/esri/widgets/support/t9n/DatePicker_ru.json +1 -1
  218. package/assets/esri/widgets/support/t9n/DatePicker_sk.json +1 -1
  219. package/assets/esri/widgets/support/t9n/DatePicker_sl.json +1 -1
  220. package/assets/esri/widgets/support/t9n/DatePicker_sr.json +1 -1
  221. package/assets/esri/widgets/support/t9n/DatePicker_sv.json +1 -1
  222. package/assets/esri/widgets/support/t9n/DatePicker_th.json +1 -1
  223. package/assets/esri/widgets/support/t9n/DatePicker_tr.json +1 -1
  224. package/assets/esri/widgets/support/t9n/DatePicker_uk.json +1 -1
  225. package/assets/esri/widgets/support/t9n/DatePicker_vi.json +1 -1
  226. package/assets/esri/widgets/support/t9n/DatePicker_zh-CN.json +1 -1
  227. package/assets/esri/widgets/support/t9n/DatePicker_zh-HK.json +1 -1
  228. package/assets/esri/widgets/support/t9n/DatePicker_zh-TW.json +1 -1
  229. package/assets/esri/widgets/support/t9n/TimePicker_ar.json +1 -1
  230. package/assets/esri/widgets/support/t9n/TimePicker_bg.json +1 -1
  231. package/assets/esri/widgets/support/t9n/TimePicker_bs.json +1 -1
  232. package/assets/esri/widgets/support/t9n/TimePicker_ca.json +1 -1
  233. package/assets/esri/widgets/support/t9n/TimePicker_cs.json +1 -1
  234. package/assets/esri/widgets/support/t9n/TimePicker_da.json +1 -1
  235. package/assets/esri/widgets/support/t9n/TimePicker_de.json +1 -1
  236. package/assets/esri/widgets/support/t9n/TimePicker_el.json +1 -1
  237. package/assets/esri/widgets/support/t9n/TimePicker_es.json +1 -1
  238. package/assets/esri/widgets/support/t9n/TimePicker_et.json +1 -1
  239. package/assets/esri/widgets/support/t9n/TimePicker_fi.json +1 -1
  240. package/assets/esri/widgets/support/t9n/TimePicker_fr.json +1 -1
  241. package/assets/esri/widgets/support/t9n/TimePicker_he.json +1 -1
  242. package/assets/esri/widgets/support/t9n/TimePicker_hr.json +1 -1
  243. package/assets/esri/widgets/support/t9n/TimePicker_hu.json +1 -1
  244. package/assets/esri/widgets/support/t9n/TimePicker_id.json +1 -1
  245. package/assets/esri/widgets/support/t9n/TimePicker_it.json +1 -1
  246. package/assets/esri/widgets/support/t9n/TimePicker_ja.json +1 -1
  247. package/assets/esri/widgets/support/t9n/TimePicker_ko.json +1 -1
  248. package/assets/esri/widgets/support/t9n/TimePicker_lt.json +1 -1
  249. package/assets/esri/widgets/support/t9n/TimePicker_lv.json +1 -1
  250. package/assets/esri/widgets/support/t9n/TimePicker_nb.json +1 -1
  251. package/assets/esri/widgets/support/t9n/TimePicker_nl.json +1 -1
  252. package/assets/esri/widgets/support/t9n/TimePicker_pl.json +1 -1
  253. package/assets/esri/widgets/support/t9n/TimePicker_pt-BR.json +1 -1
  254. package/assets/esri/widgets/support/t9n/TimePicker_pt-PT.json +1 -1
  255. package/assets/esri/widgets/support/t9n/TimePicker_ro.json +1 -1
  256. package/assets/esri/widgets/support/t9n/TimePicker_ru.json +1 -1
  257. package/assets/esri/widgets/support/t9n/TimePicker_sk.json +1 -1
  258. package/assets/esri/widgets/support/t9n/TimePicker_sl.json +1 -1
  259. package/assets/esri/widgets/support/t9n/TimePicker_sr.json +1 -1
  260. package/assets/esri/widgets/support/t9n/TimePicker_sv.json +1 -1
  261. package/assets/esri/widgets/support/t9n/TimePicker_th.json +1 -1
  262. package/assets/esri/widgets/support/t9n/TimePicker_tr.json +1 -1
  263. package/assets/esri/widgets/support/t9n/TimePicker_uk.json +1 -1
  264. package/assets/esri/widgets/support/t9n/TimePicker_vi.json +1 -1
  265. package/assets/esri/widgets/support/t9n/TimePicker_zh-CN.json +1 -1
  266. package/assets/esri/widgets/support/t9n/TimePicker_zh-HK.json +1 -1
  267. package/assets/esri/widgets/support/t9n/TimePicker_zh-TW.json +1 -1
  268. package/chunks/Compositing.glsl.js +4 -19
  269. package/chunks/HUDCompositing.glsl.js +7 -0
  270. package/chunks/Laserlines.glsl.js +5 -5
  271. package/chunks/OITCompositing.glsl.js +13 -0
  272. package/chunks/OverlayCompositing.glsl.js +8 -0
  273. package/chunks/Precipitation.glsl.js +1 -1
  274. package/chunks/ShadowHighlight.glsl.js +1 -1
  275. package/chunks/boundedPlane.js +1 -1
  276. package/chunks/cameraUtilsPlanar.js +1 -1
  277. package/chunks/cameraUtilsSpherical.js +1 -1
  278. package/chunks/mat3.js +1 -1
  279. package/chunks/quat.js +1 -1
  280. package/chunks/quat2.js +1 -1
  281. package/chunks/quatf64.js +1 -1
  282. package/chunks/sphere.js +1 -1
  283. package/chunks/vec3.js +1 -1
  284. package/chunks/vec3f32.js +1 -1
  285. package/chunks/vec4f64.js +1 -1
  286. package/core/VectorStack.js +1 -1
  287. package/core/libs/gl-matrix-2/factories/quatf64.js +1 -1
  288. package/core/libs/gl-matrix-2/factories/vec3f32.js +1 -1
  289. package/core/libs/gl-matrix-2/factories/vec4f64.js +1 -1
  290. package/core/libs/gl-matrix-2/math/mat3.js +1 -1
  291. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  292. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  293. package/core/perspectiveUtils.js +1 -1
  294. package/geohash/GeohashTree.js +1 -1
  295. package/geometry/support/MeshTransform.js +1 -1
  296. package/geometry/support/axisAngle.js +1 -1
  297. package/geometry/support/axisAngleDegrees.js +1 -1
  298. package/geometry/support/lineSegment.js +1 -1
  299. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  300. package/geometry/support/meshUtils/exporters/gltf/node.js +1 -1
  301. package/geometry/support/meshUtils/georeference.js +1 -1
  302. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  303. package/geometry/support/meshUtils/projection.js +1 -1
  304. package/geometry/support/meshUtils/rotate.js +1 -1
  305. package/geometry/support/plane.js +1 -1
  306. package/interfaces.d.ts +70 -0
  307. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  308. package/layers/graphics/featureConversionUtils.js +1 -1
  309. package/layers/mixins/EditBusLayer.js +1 -1
  310. package/layers/support/AggregateField.js +1 -1
  311. package/layers/support/ControlPointsGeoreference.js +1 -1
  312. package/layers/support/OutStatistic.js +1 -1
  313. package/layers/support/VoxelVolume.js +1 -1
  314. package/layers/support/voxelPlaneUtils.js +1 -1
  315. package/package.json +1 -1
  316. package/rest/support/AggregateFeatureSet.js +5 -0
  317. package/support/revision.js +1 -1
  318. package/views/2d/ViewState.js +1 -1
  319. package/views/2d/engine/flow/FlowDisplayObject.js +1 -1
  320. package/views/2d/engine/imagery/RasterVFTile.js +1 -1
  321. package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
  322. package/views/2d/engine/webgl/OverlayContainer.js +1 -1
  323. package/views/2d/engine/webgl/TiledDisplayObject.js +1 -1
  324. package/views/2d/engine/webgl/WGLTile.js +1 -1
  325. package/views/2d/engine/webgl/WorldExtentClipRenderer.js +1 -1
  326. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  327. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  328. package/views/2d/layers/features/schemaUtils.js +1 -1
  329. package/views/2d/layers/features/support/BinStore.js +1 -1
  330. package/views/2d/layers/features/support/ClusterStore.js +1 -1
  331. package/views/2d/layers/graphics/GraphicBoundsRenderer.js +1 -1
  332. package/views/2d/layers/support/DebugOverlay.js +1 -1
  333. package/views/2d/layers/support/FeatureLayerProxy.js +1 -1
  334. package/views/2d/layers/support/clusterUtils.js +1 -1
  335. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  336. package/views/3d/analysis/Dimensioning/LengthDimensionSubTool.js +1 -1
  337. package/views/3d/analysis/Dimensioning/LengthDimensionVisualization.js +1 -1
  338. package/views/3d/analysis/Dimensioning/lengthDimensionUtils.js +1 -1
  339. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  340. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  341. package/views/3d/analysis/Slice/sliceToolConfig.js +1 -1
  342. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  343. package/views/3d/camera/constraintUtils/distance.js +1 -1
  344. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  345. package/views/3d/environment/PanoramicAtmosphere.js +1 -1
  346. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  347. package/views/3d/environment/SimpleAtmosphere.js +1 -1
  348. package/views/3d/glTF/internal/Resource.js +1 -1
  349. package/views/3d/interactive/Manipulator3D.js +1 -1
  350. package/views/3d/interactive/editingTools/reshapeGraphic/edgeOffsetUtils.js +1 -1
  351. package/views/3d/interactive/editingTools/settings.js +1 -1
  352. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  353. package/views/3d/interactive/editingTools/transformGraphic/GraphicScaleRotateTransform.js +1 -1
  354. package/views/3d/interactive/manipulatorUtils.js +1 -1
  355. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  356. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  357. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  358. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  359. package/views/3d/layers/I3SMeshView3D.js +1 -1
  360. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  361. package/views/3d/layers/PointCloudWorker.js +1 -1
  362. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  363. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  364. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  365. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  366. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  367. package/views/3d/layers/graphics/Graphics3DLodInstanceGraphicLayer.js +1 -1
  368. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  369. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  370. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  371. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  372. package/views/3d/layers/i3s/I3SElevationProvider.js +1 -1
  373. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  374. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  375. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  376. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  377. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  378. package/views/3d/layers/support/I3STreeDebugger.js +1 -1
  379. package/views/3d/layers/support/edgeUtils.js +1 -1
  380. package/views/3d/layers/support/uvUtils.js +1 -1
  381. package/views/3d/state/Frustum.js +1 -1
  382. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  383. package/views/3d/state/controllers/RotateController.js +1 -1
  384. package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
  385. package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
  386. package/views/3d/state/controllers/local/ZoomController.js +1 -1
  387. package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
  388. package/views/3d/state/utils/navigationUtils.js +1 -1
  389. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  390. package/views/3d/support/orientedBoundingBox.js +1 -1
  391. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  392. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  393. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  394. package/views/3d/support/sunUtils.js +1 -1
  395. package/views/3d/terrain/OverlayRenderer.js +1 -1
  396. package/views/3d/terrain/PatchRenderData.js +1 -1
  397. package/views/3d/terrain/TerrainSurface.js +1 -1
  398. package/views/3d/terrain/Tile.js +1 -1
  399. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  400. package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
  401. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  402. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  403. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +1 -1
  404. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +2 -2
  405. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js +1 -1
  406. package/views/3d/webgl-engine/core/util/TwoVectorPosition.js +1 -1
  407. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  408. package/views/3d/webgl-engine/lib/CompositingHelper.js +1 -1
  409. package/views/3d/webgl-engine/lib/GeometryRecord.js +1 -1
  410. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  411. package/views/3d/webgl-engine/lib/Highlight.js +1 -1
  412. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  413. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  414. package/views/3d/webgl-engine/lib/ObjectAndLayerIdRenderHelper.js +1 -1
  415. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  416. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  417. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  418. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  419. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  420. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  421. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  422. package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
  423. package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
  424. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  425. package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
  426. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  427. package/views/3d/webgl-engine/lighting/SphericalHarmonics.js +1 -1
  428. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  429. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  430. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  431. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  432. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  433. package/views/3d/webgl-engine/shaders/Compositing.glsl.js +1 -1
  434. package/views/3d/webgl-engine/shaders/CompositingTechnique.js +1 -1
  435. package/views/3d/webgl-engine/shaders/CompositingTechniqueConfiguration.js +1 -1
  436. package/views/3d/webgl-engine/shaders/HUDCompositing.glsl.js +5 -0
  437. package/views/3d/webgl-engine/shaders/HUDCompositingTechnique.js +5 -0
  438. package/views/3d/webgl-engine/shaders/OITCompositing.glsl.js +5 -0
  439. package/views/3d/webgl-engine/shaders/OITCompositingTechnique.js +5 -0
  440. package/views/3d/webgl-engine/shaders/OverlayCompositing.glsl.js +5 -0
  441. package/views/3d/webgl-engine/shaders/OverlayCompositingTechnique.js +5 -0
  442. package/views/draw/support/surfaceCoordinateSystems.js +1 -1
  443. package/views/interactive/coordinateHelper.js +1 -1
  444. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  445. package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
  446. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  447. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  448. package/views/layers/FeatureLayerView.js +1 -1
  449. package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
  450. package/views/support/Scheduler.js +1 -1
  451. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  452. package/views/support/geometry3dUtils.js +1 -1
  453. package/widgets/ElevationProfile/support/ProfileLines3D.js +1 -1
  454. package/widgets/ElevationProfile/support/constants.js +1 -1
  455. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  456. package/widgets/Feature/FeatureRelationship.js +1 -1
  457. package/assets/esri/core/workers/chunks/0059699bf824f851d51c.js +0 -1
  458. package/assets/esri/core/workers/chunks/36dd5654df5c7f00406d.js +0 -1
  459. package/assets/esri/core/workers/chunks/de128d8a643b4297940b.js +0 -1
  460. package/assets/esri/core/workers/chunks/e00327925ca82b63fded.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,mapOr as s}from"../../../core/maybe.js";import{i as a,j as n,u as o,b as l,n as h,e as d,y as g,F as c}from"../../../chunks/vec3.js";import{c as u,a as m}from"../../../chunks/vec3f64.js";import{empty as p}from"../../../geometry/support/aaBoundingBox.js";import{containsXY as f}from"../../../geometry/support/aaBoundingRect.js";import{earth as y}from"../../../geometry/support/Ellipsoid.js";import{glLayout as _}from"../support/buffer/glUtil.js";import{GeometryState as x}from"./GeometryState.js";import{NeighborIndex as D}from"./interfaces.js";import{LayerClass as v}from"./LayerClass.js";import{PatchGeometry as C,releaseGeometry as S}from"./PatchGeometry.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as $,internalAssert as E,neighborEdgeIndices as b,oppositeEdge as T,neighborCornerIndices as j,v32s as A,lij2s as V}from"./terrainUtils.js";import{TextureFader as R,ActivationTime as L}from"./TextureFader.js";export{ActivationTime}from"./TextureFader.js";import{isEdgeNeighbor as w}from"./Tile.js";import P from"./TileOverlayData.js";import{fallsWithinLayer as N}from"./tileUtils.js";import{VertexArrayObject as I}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as G}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as M}from"../../webgl/BufferObject.js";class O{constructor(){this.geometryInfo=new C,this.intersectionData=null,this.geometryState=null,this._textureRef=new R((()=>this.tile.surface.textureFadeDuration)),this.overlay=new P,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._clippingAreaChanged=!1,this._wireframeChanged=!1,this._shadingChanged=!1,this._dirtyEdgeResolutions=15,this._dirtyEdges=15,this._dirtyCorners=15}get tile(){return this._tile}init(e){this.clear(),this._tile=e;const t=this.geometryInfo;t.indices=null,t.vertexAttributes=null,p(t.boundingBox),t.indexCount=0,t.numVerticesPerSide=0,this.intersectionData=null,this.geometryState=new x,this.localOrigin=null,this.overlay.clear()}clear(){this._releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this._wireframeChanged||this._shadingChanged||this._clippingAreaChanged||this._samplerDataChanged||this._numVerticesPerSideChanged||this._dirtyCorners||this._dirtyEdgeResolutions||this._dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),$&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)E(this.geometryInfo.outerEdges[t].count===this.geometryState.neighborData.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const s=this.tile,a=this.geometryState.numVerticesPerSide-1;if(!s.surface.isGlobal){const t=s.surface.extent;if(r(t)&&(0===e&&s.extent[3]>t[3]||1===e&&s.extent[2]>t[2]||2===e&&s.extent[1]<t[1]||3===e&&s.extent[0]<t[0]))return a}const n=s.level,o=b[e];if(!t)return E(i(s.surface?.rootTiles)||s.surface.updatingRootTiles||!s.shouldHaveNeighbor(o)),a;if(t.isLoaded){const r=t,i=r.renderData.geometryState,s=n-r.level;if(E(s>=0),0===s){const e=i.numVerticesPerSide-1;return Math.max(e,a)}const o=2**s,l=i.neighborData.edgeResolutions[(e+2)%4]/o;return Math.max(1,l)}E(!t.isLeaf);let l=a;return t.forAllSubtreeOnSide(T(o),(e=>e===s||(e.isLoaded?(l=Math.max(l,2**(e.level-n)),!0):(E(!e.isLeaf),!1)))),l}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState.neighborData,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,a=r.edgePeerNeighborSamplerVersions;for(let o=0;o<4;++o){const n=e.findNeighborTile(b[o],i),l=z(e,n),h=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[o],g=l!==z(e,d),c=a[o]!==h;s[o]=n,(g||c)&&(a[o]=h,this._markEdgeDirty(o));const u=r.edgeResolutions[o],m=this._calculateEdgeResolution(o,n);E(t(m)),E(m>=1),r.edgeResolutions[o]=m,u!==m&&this._markEdgeResolutionDirty(o)}const n=r.cornerPeerNeighbors;for(let t=0;t<4;++t){const a=e.findNeighborTile(j[t],i);n[t]=a;const o=z(e,s[t]),l=z(e,s[(t+1)%4]),h=z(e,a);q[t]=h,q[(t+1)%4]=l,q[(t+2)%4]=e,q[(t+3)%4]=o,E(q.some((t=>t?.isLoaded||t===e)));const d=q.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);q.forEach(((e,t)=>{e?.level>d&&(q[t]=null)})),E(q.some((t=>t?.isLoaded||t===e)));const g=r.cornerNeighborData[t].cornerTiles,c=r.cornerNeighborData[t].cornerTileSamplerVersions;for(let e=0;e<4;++e){const r=q[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=g[e]!==r,a=!s&&c[e]!==i;(s||a)&&(g[e]=r,c[e]=i,this._markCornerDirty(t))}E(g.some((t=>t?.isLoaded||t===e)))}$&&E(this.geometryState.neighborData.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)q[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;$&&E(!this.tile.intersectsClippingArea||this.geometryState.neighborData.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const t=this.tile,r=this._vao,i=this.geometryInfo.vertexAttributes,s=!r||!i||this._wireframeChanged||this._shadingChanged||this._numVerticesPerSideChanged||this._samplerDataChanged||this._clippingAreaChanged||this._dirtyEdgeResolutions,a=!s&&(0!==this._dirtyEdges||0!==this._dirtyEdgeResolutions),n=!a&&0!==this._dirtyCorners;s?(this._releaseGeometry(),this._createGeometry(e)):a||n?t.updateEdgeElevations():n?t.updateCornerElevations():console.warn("Update for no reason?"),this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._dirtyEdgeResolutions=0,this._dirtyEdges=0,this._dirtyCorners=0,this._clippingAreaChanged=!1,this._wireframeChanged=!1}releaseGeometry(){return this._releaseGeometry()}get hasGeometry(){return this._hasGeometry}ensureTexture(e,t){return r(this._texture)&&this._texture.descriptor.width!==e&&this.releaseTexture(),i(this._texture)&&(this._texture=t(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){r(this._texture)&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}_markCornerDirty(e){const t=1<<e;this._dirtyCorners|=t}_markEdgeDirty(e){const t=1<<e;this._dirtyEdges|=t}_markEdgeResolutionDirty(e){const t=1<<e;this._dirtyEdgeResolutions|=t,this._dirtyEdges|=t}_markAllEdgesAndCornersDirty(){this._dirtyCorners=15,this._dirtyEdges=15,this._dirtyEdgeResolutions=15}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationBasedVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerRowOnLevel(),s=Math.max(i,5);let a=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(a=null);const n=this.geometryState;let o=!1;n.numVerticesPerSide!==s&&(this._numVerticesPerSideChanged=!0,n.numVerticesPerSide=s,n.samplerDataVersion++,o=!0),t.changed&&(this._samplerDataChanged=!0,n.samplerData=t.samplerData,n.samplerDataVersion++,o=!0),e(n.clippingArea,a)||(this._clippingAreaChanged=!0,n.clippingArea=a,o=!0);const l=r.surface,h=l.wireframe;n.wireframe!==h&&(this._wireframeChanged=!0,n.wireframe=h,o=!0);const d=l.shading;return n.shading!==d&&(this._shadingChanged=d,n.shading=d,o=d),this._geometryStateChangedSinceLastUpdate||(this._geometryStateChangedSinceLastUpdate=o),o&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometryInfo.vertexAttributes,r=this.geometryInfo.indices,i=e.gl;this._vao=new I(e,G,{geometry:_(t.layout)},{geometry:M.createVertex(e,i.STATIC_DRAW,t.buffer)},M.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}_releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao.dispose(),this._vao=null,S(this.geometryInfo),!0)}get vao(){return this._vao}setTextureReference(e,t=L.Immediate){r(e)&&e.texture!==this._texture&&this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[v.ELEVATION],i=t.length;let s=new Array(i),a=0,n=0,o=!1;for(let l=0;l<i;l++){const i=t[l];if(r(i.upsampleInfo)){const t=i.upsampleInfo.tile,r=t.layerInfo[v.ELEVATION][l].data,h=r&&r.samplerData;e&&e[a]===h||(o=!0),s[a++]=h,n=Math.max(n,t.lij[0])}else if(i.data){const t=this.tile.surface.layerViewByIndex(l,v.ELEVATION);if(N(this.tile,t.layer,!1)){const t=i.data;e&&e[a]===t.samplerData||(o=!0),s[a++]=t.samplerData,n=this.tile.level}}}return r(e)&&e.length!==a&&(o=!0),a>0?s.length=a:s=null,{changed:o,samplerData:s,maxTileLevel:n}}get estimatedGeometryMemoryUsage(){const e=s(this.intersectionData,0,(e=>e.estimatedMemoryUsage));return(this.geometryInfo.indices?.byteLength??0)+(this.geometryInfo.vertexAttributes?.byteLength??0)+e}get textureDescriptor(){return r(this._texture)?this._texture.descriptor:null}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!$)return;const e=this.tile;if(E(e?.isLoaded),!e.isLoaded||!e.intersectsClippingArea)return;if(0===e.level)return;const s=e.surface.extent;if(r(s)&&!e.intersectsExtent(s))return;const p=b.map(((t,i)=>!!r(s)&&(i<2?-1:1)*(e.extent[3-i]-s[3-i])<0)),_=e.level;E(0===this._dirtyCorners),E(0===this._dirtyEdges),E(0===this._dirtyEdgeResolutions),E(!this._numVerticesPerSideChanged),E(!this._samplerDataChanged),E(!this._clippingAreaChanged),E(!this._wireframeChanged);const x=j.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),v=this.geometryState.neighborData;for(let t=0;t<4;++t){const r=v.cornerPeerNeighbors[t],i=x[t];E(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}b.forEach(((s,x)=>{if(p[x])return;const v=e.findNeighborTile(s,(e=>(e.level===_||e?.isLoaded)&&e?.intersectsClippingArea));if(!v){const t=!e.surface.updatingRootTiles&&r(e.surface.rootTiles)&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(s);return void E(!t)}E(v.isLoaded||v.level===e.level),E(v===this.geometryState.neighborData.edgePeerNeighbors[x]);const C=_-v.level;if(!v.isLoaded)return E(!v.isLeaf),void E(0===C);E(w(e,v,s)),E(C>=0);const S=2**C;if(C<0)return void E(!1);const $=e.renderData.geometryInfo,b=$.outerEdges[x],T=$.numVerticesPerSide-1,j=v.renderData.geometryInfo;if(!j)return void E(!1);{const t=this.geometryState.neighborData.edgePeerNeighbors[x];(t?.isLoaded||t.isLoaded)&&(E(t==t),E(e.renderData.geometryState.neighborData.edgePeerNeighborSamplerVersions[x]===t.renderData.geometryState.samplerDataVersion),E(this.geometryState.neighborData.edgePeerNeighborSamplerVersions[x]===t.renderData.geometryState.samplerDataVersion))}const R=(x+2)%4,L=j.outerEdges[R],P=b.count-1,N=L.count-1;E(P*S===N,`Tile[${e.lij}]:e${x},res=${P} edgeRes mismatch with Neighbor[${v.lij}]:e${R},res=${N} (expected:${P*S})`);const I=e.extent,G=s===D.NORTH||s===D.SOUTH,M=L.count-1,O=M/2**C,q=b.count-1;if(O<1)return void E(1===q);E(O===q),E(t(O));const z=j.numVerticesPerSide-1;E(C>0||O===Math.max(z,T));const J=e.getNeighborEdgeStartVertexIndex(x,v);E(0<=J&&J<S);const K=J*O;E(0<=K&&K<=M-O);let Q=0,Y=K;b.getVertexPos(U,0),b.getVertexPos(k,b.count-1);const Z=a(U,k),ee=Math.max(W,1e-4*Z);for(let t=0;t<=O;++t){b.getVertexPos(U,Q),L.getVertexPos(k,Y);const a=t/O,p=G?I[0]+a*(I[2]-I[0]):s===D.WEST?I[0]:I[2],_=G?s===D.SOUTH?I[1]:I[3]:I[1]+a*(I[3]-I[1]),C=e.surface.extent;if(i(C)||f(C,p,_)){const t=n(U,k),i=o(U)-y.radius,s=o(k)-y.radius,a=t<ee;if(!a){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${x}[${Q}/${b.count}] and [${v.lij}].edge${R}[${Y}/${L.count}]`),r(C)&&console.warn(" surface extent= ",C," x,y=",p,",",_);const n=u();l(n,e.renderData.localOrigin,v.renderData.localOrigin),o(n)>0&&console.warn(` localOrigins: ${e.renderData.localOrigin} vs ${v.renderData.localOrigin} d=${o(n)} [${n}]`);(()=>{const t=m(U),r=m(k);e.updateEdgeElevations(),v.updateEdgeElevations(),b.getVertexPos(U,Q),L.getVertexPos(k,Y);const i=u();g(i,U,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${U} d=${o(i)} [${i}]`),g(i,k,r),o(i)>0&&console.warn(` XXX Neighbor[${v.lij}] edge out of date: ${r} vs ${k} d=${o(i)} [${i}]`)})(),E(a,`Mismatch in tile [${e.lij}].edge[${x}][${Q}/${b.count}] vs neighbor [${v.lij}].edge[${R}][${Y}/${L.count}] ${A(U)} vs ${A(k)} dist=${t} h(t|n|d)=${i}|${s}|${s-i}`)}if(e.surface.shading){b.getNormal(F,Q),L.getNormal(B,Y),h(X,F),h(H,B);const t=d(X,H),r=!1,i=1-t<.01||r||e===v;if(!i){const r=u();g(r,F,B);const s=()=>`Mismatch in tile edge normal ${V(e.lij)} (${Q}/${b.count-1}) edge ${x} vs neighbor ${V(v.lij)} (${Y}/${L.count-1}) nedge ${R} :${A(F)} vs ${A(B)} dot = ${t} : ${A(r)}`;console.warn("Mismatch in tile edge normal: ",s());{e.updateEdgeElevations(),v.updateEdgeElevations();const t=u(),r=u();b.getNormal(t,Q),L.getNormal(r,Y),c(F,t)||console.warn("Missing update in tile normal: ",A(F)," => ",A(t)),c(B,r)||console.warn("Missing update in neighbor normal: ",A(B)," => ",A(r))}E(i,s())}}}Q+=1,Y+=1}}))}}const U=u(),k=u(),F=u(),B=u(),X=u(),H=u(),W=1,q=[null,null,null,null];function z(e,t){return t?.isLoaded||t===e?t:null}export{O as PatchRenderData,z as neighborTileIfLoadedOrSelf};
5
+ import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,mapOr as s}from"../../../core/maybe.js";import{i as a,j as n,y as o,b as l,n as h,e as d,p as g,F as c}from"../../../chunks/vec3.js";import{c as u,a as m}from"../../../chunks/vec3f64.js";import{empty as p}from"../../../geometry/support/aaBoundingBox.js";import{containsXY as f}from"../../../geometry/support/aaBoundingRect.js";import{earth as y}from"../../../geometry/support/Ellipsoid.js";import{glLayout as _}from"../support/buffer/glUtil.js";import{GeometryState as x}from"./GeometryState.js";import{NeighborIndex as D}from"./interfaces.js";import{LayerClass as v}from"./LayerClass.js";import{PatchGeometry as C,releaseGeometry as S}from"./PatchGeometry.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as $,internalAssert as E,neighborEdgeIndices as b,oppositeEdge as T,neighborCornerIndices as j,v32s as A,lij2s as V}from"./terrainUtils.js";import{TextureFader as R,ActivationTime as L}from"./TextureFader.js";export{ActivationTime}from"./TextureFader.js";import{isEdgeNeighbor as w}from"./Tile.js";import P from"./TileOverlayData.js";import{fallsWithinLayer as N}from"./tileUtils.js";import{VertexArrayObject as I}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as G}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as M}from"../../webgl/BufferObject.js";class O{constructor(){this.geometryInfo=new C,this.intersectionData=null,this.geometryState=null,this._textureRef=new R((()=>this.tile.surface.textureFadeDuration)),this.overlay=new P,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._clippingAreaChanged=!1,this._wireframeChanged=!1,this._shadingChanged=!1,this._dirtyEdgeResolutions=15,this._dirtyEdges=15,this._dirtyCorners=15}get tile(){return this._tile}init(e){this.clear(),this._tile=e;const t=this.geometryInfo;t.indices=null,t.vertexAttributes=null,p(t.boundingBox),t.indexCount=0,t.numVerticesPerSide=0,this.intersectionData=null,this.geometryState=new x,this.localOrigin=null,this.overlay.clear()}clear(){this._releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this._wireframeChanged||this._shadingChanged||this._clippingAreaChanged||this._samplerDataChanged||this._numVerticesPerSideChanged||this._dirtyCorners||this._dirtyEdgeResolutions||this._dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),$&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)E(this.geometryInfo.outerEdges[t].count===this.geometryState.neighborData.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const s=this.tile,a=this.geometryState.numVerticesPerSide-1;if(!s.surface.isGlobal){const t=s.surface.extent;if(r(t)&&(0===e&&s.extent[3]>t[3]||1===e&&s.extent[2]>t[2]||2===e&&s.extent[1]<t[1]||3===e&&s.extent[0]<t[0]))return a}const n=s.level,o=b[e];if(!t)return E(i(s.surface?.rootTiles)||s.surface.updatingRootTiles||!s.shouldHaveNeighbor(o)),a;if(t.isLoaded){const r=t,i=r.renderData.geometryState,s=n-r.level;if(E(s>=0),0===s){const e=i.numVerticesPerSide-1;return Math.max(e,a)}const o=2**s,l=i.neighborData.edgeResolutions[(e+2)%4]/o;return Math.max(1,l)}E(!t.isLeaf);let l=a;return t.forAllSubtreeOnSide(T(o),(e=>e===s||(e.isLoaded?(l=Math.max(l,2**(e.level-n)),!0):(E(!e.isLeaf),!1)))),l}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState.neighborData,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,a=r.edgePeerNeighborSamplerVersions;for(let o=0;o<4;++o){const n=e.findNeighborTile(b[o],i),l=z(e,n),h=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[o],g=l!==z(e,d),c=a[o]!==h;s[o]=n,(g||c)&&(a[o]=h,this._markEdgeDirty(o));const u=r.edgeResolutions[o],m=this._calculateEdgeResolution(o,n);E(t(m)),E(m>=1),r.edgeResolutions[o]=m,u!==m&&this._markEdgeResolutionDirty(o)}const n=r.cornerPeerNeighbors;for(let t=0;t<4;++t){const a=e.findNeighborTile(j[t],i);n[t]=a;const o=z(e,s[t]),l=z(e,s[(t+1)%4]),h=z(e,a);q[t]=h,q[(t+1)%4]=l,q[(t+2)%4]=e,q[(t+3)%4]=o,E(q.some((t=>t?.isLoaded||t===e)));const d=q.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);q.forEach(((e,t)=>{e?.level>d&&(q[t]=null)})),E(q.some((t=>t?.isLoaded||t===e)));const g=r.cornerNeighborData[t].cornerTiles,c=r.cornerNeighborData[t].cornerTileSamplerVersions;for(let e=0;e<4;++e){const r=q[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=g[e]!==r,a=!s&&c[e]!==i;(s||a)&&(g[e]=r,c[e]=i,this._markCornerDirty(t))}E(g.some((t=>t?.isLoaded||t===e)))}$&&E(this.geometryState.neighborData.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)q[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;$&&E(!this.tile.intersectsClippingArea||this.geometryState.neighborData.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const t=this.tile,r=this._vao,i=this.geometryInfo.vertexAttributes,s=!r||!i||this._wireframeChanged||this._shadingChanged||this._numVerticesPerSideChanged||this._samplerDataChanged||this._clippingAreaChanged||this._dirtyEdgeResolutions,a=!s&&(0!==this._dirtyEdges||0!==this._dirtyEdgeResolutions),n=!a&&0!==this._dirtyCorners;s?(this._releaseGeometry(),this._createGeometry(e)):a||n?t.updateEdgeElevations():n?t.updateCornerElevations():console.warn("Update for no reason?"),this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._dirtyEdgeResolutions=0,this._dirtyEdges=0,this._dirtyCorners=0,this._clippingAreaChanged=!1,this._wireframeChanged=!1}releaseGeometry(){return this._releaseGeometry()}get hasGeometry(){return this._hasGeometry}ensureTexture(e,t){return r(this._texture)&&this._texture.descriptor.width!==e&&this.releaseTexture(),i(this._texture)&&(this._texture=t(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){r(this._texture)&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}_markCornerDirty(e){const t=1<<e;this._dirtyCorners|=t}_markEdgeDirty(e){const t=1<<e;this._dirtyEdges|=t}_markEdgeResolutionDirty(e){const t=1<<e;this._dirtyEdgeResolutions|=t,this._dirtyEdges|=t}_markAllEdgesAndCornersDirty(){this._dirtyCorners=15,this._dirtyEdges=15,this._dirtyEdgeResolutions=15}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationBasedVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerRowOnLevel(),s=Math.max(i,5);let a=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(a=null);const n=this.geometryState;let o=!1;n.numVerticesPerSide!==s&&(this._numVerticesPerSideChanged=!0,n.numVerticesPerSide=s,n.samplerDataVersion++,o=!0),t.changed&&(this._samplerDataChanged=!0,n.samplerData=t.samplerData,n.samplerDataVersion++,o=!0),e(n.clippingArea,a)||(this._clippingAreaChanged=!0,n.clippingArea=a,o=!0);const l=r.surface,h=l.wireframe;n.wireframe!==h&&(this._wireframeChanged=!0,n.wireframe=h,o=!0);const d=l.shading;return n.shading!==d&&(this._shadingChanged=d,n.shading=d,o=d),this._geometryStateChangedSinceLastUpdate||(this._geometryStateChangedSinceLastUpdate=o),o&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometryInfo.vertexAttributes,r=this.geometryInfo.indices,i=e.gl;this._vao=new I(e,G,{geometry:_(t.layout)},{geometry:M.createVertex(e,i.STATIC_DRAW,t.buffer)},M.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}_releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao.dispose(),this._vao=null,S(this.geometryInfo),!0)}get vao(){return this._vao}setTextureReference(e,t=L.Immediate){r(e)&&e.texture!==this._texture&&this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[v.ELEVATION],i=t.length;let s=new Array(i),a=0,n=0,o=!1;for(let l=0;l<i;l++){const i=t[l];if(r(i.upsampleInfo)){const t=i.upsampleInfo.tile,r=t.layerInfo[v.ELEVATION][l].data,h=r&&r.samplerData;e&&e[a]===h||(o=!0),s[a++]=h,n=Math.max(n,t.lij[0])}else if(i.data){const t=this.tile.surface.layerViewByIndex(l,v.ELEVATION);if(N(this.tile,t.layer,!1)){const t=i.data;e&&e[a]===t.samplerData||(o=!0),s[a++]=t.samplerData,n=this.tile.level}}}return r(e)&&e.length!==a&&(o=!0),a>0?s.length=a:s=null,{changed:o,samplerData:s,maxTileLevel:n}}get estimatedGeometryMemoryUsage(){const e=s(this.intersectionData,0,(e=>e.estimatedMemoryUsage));return(this.geometryInfo.indices?.byteLength??0)+(this.geometryInfo.vertexAttributes?.byteLength??0)+e}get textureDescriptor(){return r(this._texture)?this._texture.descriptor:null}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!$)return;const e=this.tile;if(E(e?.isLoaded),!e.isLoaded||!e.intersectsClippingArea)return;if(0===e.level)return;const s=e.surface.extent;if(r(s)&&!e.intersectsExtent(s))return;const p=b.map(((t,i)=>!!r(s)&&(i<2?-1:1)*(e.extent[3-i]-s[3-i])<0)),_=e.level;E(0===this._dirtyCorners),E(0===this._dirtyEdges),E(0===this._dirtyEdgeResolutions),E(!this._numVerticesPerSideChanged),E(!this._samplerDataChanged),E(!this._clippingAreaChanged),E(!this._wireframeChanged);const x=j.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),v=this.geometryState.neighborData;for(let t=0;t<4;++t){const r=v.cornerPeerNeighbors[t],i=x[t];E(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}b.forEach(((s,x)=>{if(p[x])return;const v=e.findNeighborTile(s,(e=>(e.level===_||e?.isLoaded)&&e?.intersectsClippingArea));if(!v){const t=!e.surface.updatingRootTiles&&r(e.surface.rootTiles)&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(s);return void E(!t)}E(v.isLoaded||v.level===e.level),E(v===this.geometryState.neighborData.edgePeerNeighbors[x]);const C=_-v.level;if(!v.isLoaded)return E(!v.isLeaf),void E(0===C);E(w(e,v,s)),E(C>=0);const S=2**C;if(C<0)return void E(!1);const $=e.renderData.geometryInfo,b=$.outerEdges[x],T=$.numVerticesPerSide-1,j=v.renderData.geometryInfo;if(!j)return void E(!1);{const t=this.geometryState.neighborData.edgePeerNeighbors[x];(t?.isLoaded||t.isLoaded)&&(E(t==t),E(e.renderData.geometryState.neighborData.edgePeerNeighborSamplerVersions[x]===t.renderData.geometryState.samplerDataVersion),E(this.geometryState.neighborData.edgePeerNeighborSamplerVersions[x]===t.renderData.geometryState.samplerDataVersion))}const R=(x+2)%4,L=j.outerEdges[R],P=b.count-1,N=L.count-1;E(P*S===N,`Tile[${e.lij}]:e${x},res=${P} edgeRes mismatch with Neighbor[${v.lij}]:e${R},res=${N} (expected:${P*S})`);const I=e.extent,G=s===D.NORTH||s===D.SOUTH,M=L.count-1,O=M/2**C,q=b.count-1;if(O<1)return void E(1===q);E(O===q),E(t(O));const z=j.numVerticesPerSide-1;E(C>0||O===Math.max(z,T));const J=e.getNeighborEdgeStartVertexIndex(x,v);E(0<=J&&J<S);const K=J*O;E(0<=K&&K<=M-O);let Q=0,Y=K;b.getVertexPos(U,0),b.getVertexPos(k,b.count-1);const Z=a(U,k),ee=Math.max(W,1e-4*Z);for(let t=0;t<=O;++t){b.getVertexPos(U,Q),L.getVertexPos(k,Y);const a=t/O,p=G?I[0]+a*(I[2]-I[0]):s===D.WEST?I[0]:I[2],_=G?s===D.SOUTH?I[1]:I[3]:I[1]+a*(I[3]-I[1]),C=e.surface.extent;if(i(C)||f(C,p,_)){const t=n(U,k),i=o(U)-y.radius,s=o(k)-y.radius,a=t<ee;if(!a){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${x}[${Q}/${b.count}] and [${v.lij}].edge${R}[${Y}/${L.count}]`),r(C)&&console.warn(" surface extent= ",C," x,y=",p,",",_);const n=u();l(n,e.renderData.localOrigin,v.renderData.localOrigin),o(n)>0&&console.warn(` localOrigins: ${e.renderData.localOrigin} vs ${v.renderData.localOrigin} d=${o(n)} [${n}]`);(()=>{const t=m(U),r=m(k);e.updateEdgeElevations(),v.updateEdgeElevations(),b.getVertexPos(U,Q),L.getVertexPos(k,Y);const i=u();g(i,U,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${U} d=${o(i)} [${i}]`),g(i,k,r),o(i)>0&&console.warn(` XXX Neighbor[${v.lij}] edge out of date: ${r} vs ${k} d=${o(i)} [${i}]`)})(),E(a,`Mismatch in tile [${e.lij}].edge[${x}][${Q}/${b.count}] vs neighbor [${v.lij}].edge[${R}][${Y}/${L.count}] ${A(U)} vs ${A(k)} dist=${t} h(t|n|d)=${i}|${s}|${s-i}`)}if(e.surface.shading){b.getNormal(F,Q),L.getNormal(B,Y),h(X,F),h(H,B);const t=d(X,H),r=!1,i=1-t<.01||r||e===v;if(!i){const r=u();g(r,F,B);const s=()=>`Mismatch in tile edge normal ${V(e.lij)} (${Q}/${b.count-1}) edge ${x} vs neighbor ${V(v.lij)} (${Y}/${L.count-1}) nedge ${R} :${A(F)} vs ${A(B)} dot = ${t} : ${A(r)}`;console.warn("Mismatch in tile edge normal: ",s());{e.updateEdgeElevations(),v.updateEdgeElevations();const t=u(),r=u();b.getNormal(t,Q),L.getNormal(r,Y),c(F,t)||console.warn("Missing update in tile normal: ",A(F)," => ",A(t)),c(B,r)||console.warn("Missing update in neighbor normal: ",A(B)," => ",A(r))}E(i,s())}}}Q+=1,Y+=1}}))}}const U=u(),k=u(),F=u(),B=u(),X=u(),H=u(),W=1,q=[null,null,null,null];function z(e,t){return t?.isLoaded||t===e?t:null}export{O as PatchRenderData,z as neighborTileIfLoadedOrSelf};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as T}from"../../../core/promiseUtils.js";import{watch as f,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as L}from"../../../core/accessorSupport/decorators/subclass.js";import{m as E}from"../../../chunks/mat4.js";import{c as D}from"../../../chunks/mat4f64.js";import{c as P}from"../../../chunks/vec3.js";import{c as C}from"../../../chunks/vec3f64.js";import{c as x}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as b}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as U,projectPointToVector as R}from"../../../geometry/projection.js";import{getReferenceEllipsoid as M}from"../../../geometry/projectionEllipsoid.js";import{create as j,equals as A,intersection as I,empty as V,expand as O,intersectsSphere as B}from"../../../geometry/support/aaBoundingRect.js";import{create as k,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as q}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as G}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as F}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{acquireDecoder as H}from"../../../layers/support/LercDecoder.js";import{printAllocations as z}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as Q,scaleToZoom as X}from"../support/cameraUtils.js";import Y from"../support/debugFlags.js";import{toBoundingRect as $}from"../support/extentUtils.js";import{ClientType as K}from"../support/index.js";import{updatingProgress as J}from"../support/updatingProperties.js";import{ElevationBounds as Z}from"./ElevationBounds.js";import{sampleElevation as ee,ElevationData as te}from"./ElevationData.js";import{create as ie}from"./ExtentHelper.js";import{LODSnapping as re,TextureUpdate as se}from"./interfaces.js";import{LayerClass as ae,LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as he}from"./RenderOrder.js";import{SphericalPatch as de}from"./SphericalPatch.js";import{MAX_ROOT_TILES as pe,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as ue,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ce,MAX_MEMORY_LOD_BIAS as _e,ELEVATION_NODATA_VALUE as ge}from"./TerrainConst.js";import me from"./TerrainRenderer.js";import Te from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as fe,internalAssert as ye,oppositeEdge as ve,isSurfaceLayerView as we,isGroupLayerView as Se,isMapTileLayerView as Le,isBlendableLayerView as Ee,isElevationLayerView as De,isVectorTileLayerView as Pe,useFetchTileForLayer as Ce,isImageryTileLayerView as xe,isTileLayerView as be,releaseTileData as Ue,neighborEdgeIndices as Re,ENABLE_TERRAIN_INTERNAL_CHECKS as Me,ENABLE_WATERPROOFNESS_TESTS as je,enableTerrainInternalChecks as Ae,enableTerrainWaterproofnessChecks as Ie}from"./terrainUtils.js";import{SplitLimits as Ve,Tile as Oe}from"./Tile.js";import{printAllocations as Be}from"./TilePerLayerInfo.js";import{TileUpdate as ke}from"./TileUpdate.js";import{IteratorPreorder as Ne,IteratorPostorder as qe,compareTilesByLij as Ge,hasLoadableSiblings as Fe,sortTilesByPOI as We,sortTiles as He}from"./tileUtils.js";import{TilingSchemeLogic as ze}from"./TilingSchemeLogic.js";import{UpsampleInfo as Qe}from"./UpsampleInfo.js";import{isCompositeBlendMode as Xe,blendModeFromString as Ye}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as $e}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as Ke}from"../../support/RenderState.js";import{ImmediateTask as Je,TaskPriority as Ze,noBudget as et}from"../../support/Scheduler.js";let tt=class extends(a.EventedMixin(i)){constructor(e){super(e),this._iteratorPool=new c(Ne,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new qe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new Te,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=C(),this._eyePosSurfaceSR=C(),this._splitLimits=new Ve,this._snapLevel=1/0,this._frustum=k(),this._viewProjectionMatrix=D(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new b,this._frameTask=Je,this._allTiles=new _,this._upsampleInfoPool=new c(Qe),this._rootTilesExtent=j(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.visibleElevationBounds=new Z(1/0,-1/0),this.rootTileElevationBounds=new Z(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this.shortBatches=!1,this.oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this._shading=!0,this._isWebMercator=!1,this._isWebMercatorOnPlateeCarree=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=H(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(oe):new c(de);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new F(e.newCache("elevation-query")),this._set("overlayManager",new le({surface:this})),this._handles.add([f((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),f((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new me({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:M(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles}),this._handles.add([f((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),f((()=>this.hasCompositeBlendMode),(()=>{this._updateBaseOpacity(this.baseOpacity)}),y),f((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),f((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),f((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),f((()=>Y.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&Y.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=ie(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new ze({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(K.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(K.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(Ze.TERRAIN_SURFACE,this),this._handles.add([f((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),f((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),f((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),f((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),f((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),w),f((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._handles.add([f((()=>this.view?.map.ground.shading),(()=>{this._updateShadingIfChanged()}))]),this._updateShading(),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Oe.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),z(),Be()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){const e=this.view.pointsOfInterest?.contentCameraOnSurface?.scale;if(e){const t=this.view.state.contentCamera;let i=Q(this.view,t.eye,t.viewForward,t.up).tilt;i>90&&(i=180-i);const r=2*(i/90)**2,s=X(this.view,e)-r;Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?re.ON:re.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=j(),r=$(t,i,e)?i:null,s=this._get("extent");return A(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=I(this.groundExtent,this._userClippingExtent,j()),t=this._get("extent");return A(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this._watchUpdatingTracking.updating||this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||this._asyncWorkItems>0||!this._allTilesSorted||this._layerViewsDirty)&&this.ready&&!this.suspended||this.overlayManager.updating||this._frameTask.updating)}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view.map.ground.opacity}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get 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._updateTransparentTerrain()}_updateTransparentTerrain(){const e=!this.renderingDisabled&&!this.opaque;this.view?._stage?.renderView.setRenderParameters({transparentTerrain:e})}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}get wireframe(){return this._renderer.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get textureFadeDuration(){return this.view.qualitySettings.tiledSurface.textureFadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,nt);return p(s)?null:ee(nt[0],nt[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=nt){const a=this.rootTiles;if(p(a)||!a.length)return null;if(0===a[0].layerInfo[ae.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!U(s,r,s,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let n of a){if(!n.containsPoint(s))continue;for(;n&&!n.rendered&&!n.isLeaf;){let e=0;s[0]>.5*(n.extent[0]+n.extent[2])&&(e+=1),s[1]<.5*(n.extent[1]+n.extent[3])&&(e+=2),n=n.children[e]}const e=n.renderData;return(e?e.geometryState.samplerData:null)?n:null}return null}getScale(e){if(this.tilingScheme){if(!R(e,nt,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(u(t))for(let e of t)if(e?.containsPoint(nt)){for(;!e.isLeaf&&!e.rendered;){let t=0;nt[0]>e.children[0].extent[2]&&(t+=1),nt[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereElevationBounds(e,t,i,r,s){if(nt[0]=e,nt[1]=t,nt[2]=i,nt[3]=r,!U(nt,s,nt,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&B(e.extent,nt))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},h=this.rootTiles;if(u(h))for(const l of h)o(l);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!R(e,nt,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;nt[3]=t;let i=null;const r=e=>{if(e&&B(e.extent,nt))if(e.isLeaf||e.rendered){const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}else for(const t of e.children)r(t)},s=this.rootTiles;if(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1&&!this.hasCompositeBlendMode,this._renderer.isTransparent=this._allSurfaceLayersTransparent();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?se.UNFADED:se.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(fe(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()),this._isWebMercator=!!this.tilingScheme?.spatialReference.isWebMercator,this._isWebMercatorOnPlateeCarree=this._isWebMercator&&q(this.view?.renderSpatialReference))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return ot[0]=e,ot[1]=t,ot[2]=i,s.init(ot,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=lt;let s=t.rootTilesInExtent(e,i,5*pe);if(u(this.rootTiles)){if(s.length>pe)return void l.getLogger(this.declaredClass).warn(ue);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,rt);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>rt(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.declaredClass).warn(ce),s=t.rootTilesInExtent(e,i,pe)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=j(i)),this._visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.isLoaded&&e.intersectsClippingArea));e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Ge);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e)))}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===ke.SPLIT&&t.setPendingUpdate(ke.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e,!0)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate(!1))}_viewChangeUpdate(e=!0){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles,e)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e,t=!0){if(p(e))return;const i=Fe(e),r=this.visibleElevationBounds;let s=i?r.min:1/0,a=i?r.max:-1/0;const n=this.extent,l=this._viewProjectionMatrix;this.setTileTreeDirty();const o=this._iteratorPool.acquire();for(o.reset(e);!o.done;){const e=o.next();e.updateClippingStatus(n)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e),e.setPendingUpdate(ke.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(l),e.renderData&&(s=Math.min(e.elevationBounds[0],s),a=Math.max(e.elevationBounds[1],a))}o.remove(),this._viewChanged=!0,this._allTilesDirty=!0,t&&this._batchUpdatePendingTileGeometries(),isFinite(s)&&isFinite(a)&&(r.min!==s||r.max!==a)&&(this.visibleElevationBounds=new Z(s,a))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this.rootTiles;u(i)&&i.forEach((({elevationBounds:i})=>{e=Math.min(e,i[0]),t=Math.max(t,i[1])}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new Z(e,t))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=k()),N(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,N(this._frustum,e.frustum),E(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),P(this._eyePosRenderSR,t.eye),U(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(st(e)?this._loadChildren(e):at(e)&&this._loadParent(e))}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForGeometryUpdate(e){const t=this._pendingTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(ke.TEXTURE_FADING)?ke.TEXTURE_FADING:!!e.resetPendingUpdate(ke.TEXTURE_NOFADING)&&ke.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(e){const t=dt.extent;V(t);const i=e.length;for(let r=0;r<i;r++)O(t,e[r].extent,t);dt.spatialReference=this.spatialReference,this.emit("elevation-change",dt)}get running(){return this.updating&&this.ready&&!this.suspended}runTask(e){this.shortBatches=e.state===Ke.ANIMATING,this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),e.done?this.requestUpdate():this.getUsedMemory(),this.notifyChange("updatingProgressValue"),this.shortBatches=!1}_updateAllTilesStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next(),i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i!==ke.SPLIT){if(e.resetPendingUpdate(ke.SPLIT)&&e.updateAgentSuspension(),i===ke.VSPLITMERGE&&e.updateAgents(ae.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(ke.MERGE),e.resetPendingUpdate(ke.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}else e.resetPendingUpdate(ke.MERGE),e.isLeaf&&(e.setPendingUpdate(ke.SPLIT),t.skipSubtree()),e.rendered&&e.setPendingUpdate(ke.RENDERDATA)}t.remove(),this.requestUpdate(),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(We(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){ye(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForGeometryUpdate(e),this.shortBatches&&this._batchUpdatePendingTileGeometries())}_batchUpdatePendingTileGeometries(){const e=this._pendingTilesToUpdate;if(0===e.size)return;const t=Array.from(this._pendingTilesToUpdate.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea)),i=(i,r)=>{!r?.isLoaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Ge);const r=t.length;for(let s=0;s<r;++s){const r=t[s];ye(r.isLoaded),ye(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData;for(let t=0;t<4;++t)if(n&1<<t){const s=r.renderData.geometryState.neighborData.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(ve(Re[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(ye(e.has(t)||Ge(r,t)<0),i(r,t),!0))),i(r,l.cornerPeerNeighbors[t]),i(r,l.cornerPeerNeighbors[(t+1)%4])}}e.clear(),this._updateTilesGeometries(t),this._emitElevationUpdateEventForTiles(t),Me&&je&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1,r=!1;for(;!e.done;){r=!0;let s=!1;const a=!this._allTiles.some((r=>{if(!i&&!r.loadable)return e.done;let a=r;if(r.resetPendingUpdate(ke.MERGE)){if(!t)return r.setPendingUpdate(ke.MERGE),e.done;for(;a.parent?.resetPendingUpdate(ke.MERGE);)a=a.parent;this._mergeTile(a),s=!0,e.madeProgress()}else r.resetPendingUpdate(ke.SPLIT)&&(this._splitTile(r),s=!0,e.madeProgress());return!e.done&&a===r&&r.resetPendingUpdate(ke.RENDERDATA)&&(this._updateRenderData(r),e.madeProgress()),e.done}));if(s&&(this._allTilesSorted=!1,this._allTilesDirty=!0),a){if(!i){i=!0;continue}if(!s)break}else this._allTilesDirty=!0}r||(this._allTilesDirty=!0),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){return this._allTiles.some((t=>(t.resetPendingUpdate(ke.GEOMETRY)&&(this._updateTileGeometryState(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams($e.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;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(){u(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i])||t;return e.unsetChildren(),t}_purgeTile(e){const t=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),this._tilePool.release(e),t}_unloadTile(e){this._pendingTilesToUpdate.delete(e),e.unload(this._renderer)}_splitTile(e){fe(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(ke.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){pt.spatialReference=this.spatialReference,pt.extent=e.extent,pt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",pt)}_createTile(e,t,i,r){fe(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===ke.SPLIT&&s.setPendingUpdate(ke.SPLIT),s}_mergeTile(e){fe(!e.hasPendingUpdate(ke.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(fe(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this.shortBatches&&this._batchUpdatePendingTileGeometries()),this._allTilesDirty=!0,++this._performanceInfo.numMerged}_loadChildren(e){fe(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForGeometryUpdate(e),this._emitTileScaleChange(e,e.level+1),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._markTileToUpdate(t),this._emitTileScaleChange(t,t.level),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_loadTile(e){e.load(),e.setPendingUpdate(ke.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new te(e.lij,e.extent,i);e.dataArrived(t,ae.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=et){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),we(s)||Se(s))if(this._basemapLayerViewHandles.has(s.uid)&&!Se(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allSurfaceLayersTransparent(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(Le(t)&&!W(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ee(e)||Se(e))&&Xe(Ye[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return De(e)?ae.ELEVATION:ae.MAP}_registerTiledLayerView(e){const t=[];if((Ee(e)||Se(e))&&t.push(f((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(se.UNFADED)}))),Se(e))return;const i=this._layerClassFromLayerView(e);t.push(f((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(f((()=>e.fullOpacity),(()=>this._updateTileTextures(se.UNFADED)))),t.push(f((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!we(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===ae.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ne){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===ae.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(ae.MAP),e===se.IMMEDIATE?this.renderer.updateTileTexture(t,ke.TEXTURE_NOFADING):t.updateRenderData(ae.MAP,e)})),this._renderer.isTransparent=this._allSurfaceLayersTransparent()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=$e.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Pe(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===ae.ELEVATION?De(i)?this._requestElevationTileData(e,i,r):Promise.reject():Le(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(m(i))return;const s=this._layerIndexByUid[ae.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer %d %s",ae.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,ae.ELEVATION,t,i),this.requestUpdate())};if(Ce(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:ge,signal:i.signal}).then((e=>{if(!m(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:ge},i.signal))).then((e=>{e?r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue}):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ue(s),m(i)||(this._dataMissing(e,ae.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Ue(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Pe(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(xe(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(be(t)&&Ce(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(T());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);G(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(ae.MAP,t.uid);u(r)?e.dataArrived(r,ae.MAP,i):(Ue(i),l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return fe(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){ht.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&ht.push(e)}));const t=ht.toArray();return He(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!je)return;const e=this.rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shading(){return this._shading}_updateShadingIfChanged(){const e=this.view?.map?.ground?.shading;e!==this._shading&&this._updateShading()}_updateShading(){const e=this.view?.map?.ground?.shading;this._shading=e,this.renderer&&(this.renderer.shading=e,this.renderer.setNeedsRender()),this._updateAllTileGeometries()}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateeCarree(){return this._isWebMercatorOnPlateeCarree}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(u(this.spatialReference)&&this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ae(e)}enableWaterproofnessChecks(e){Ie(e)}};e([S()],tt.prototype,"_renderer",void 0),e([S()],tt.prototype,"_hasPendingUpdates",void 0),e([S()],tt.prototype,"_asyncWorkItems",void 0),e([S()],tt.prototype,"_allTilesDirty",void 0),e([S()],tt.prototype,"_allTilesSorted",void 0),e([S()],tt.prototype,"_viewChanged",void 0),e([S({readOnly:!0})],tt.prototype,"_watchUpdatingTracking",void 0),e([S()],tt.prototype,"_frameTask",void 0),e([S({readOnly:!0})],tt.prototype,"snapLevel",null),e([S({readOnly:!0})],tt.prototype,"lodSnapping",null),e([S({constructOnly:!0})],tt.prototype,"view",void 0),e([S()],tt.prototype,"_userClippingExtent",null),e([S()],tt.prototype,"_rootTilesExtent",void 0),e([S({readOnly:!0})],tt.prototype,"extent",null),e([S({readOnly:!0})],tt.prototype,"groundExtent",null),e([S({readOnly:!0})],tt.prototype,"_tilingSchemeExtent",null),e([S({readOnly:!0})],tt.prototype,"updating",null),e([S(J)],tt.prototype,"updatingProgress",void 0),e([S({readOnly:!0})],tt.prototype,"updatingProgressValue",null),e([S()],tt.prototype,"_maxNumUpdating",void 0),e([S()],tt.prototype,"baseOpacity",null),e([S()],tt.prototype,"hasCompositeBlendMode",void 0),e([S({readOnly:!0})],tt.prototype,"overlayManager",void 0),e([S({readOnly:!0})],tt.prototype,"viewingMode",null),e([S()],tt.prototype,"maxTextureScale",void 0),e([S({readOnly:!0})],tt.prototype,"ready",null),e([S({value:he.FRONT_TO_BACK})],tt.prototype,"renderOrder",null),e([S({readOnly:!0})],tt.prototype,"rootTiles",void 0),e([S({readOnly:!0})],tt.prototype,"spatialReference",null),e([S({type:t})],tt.prototype,"backgroundColor",null),e([S({value:!1})],tt.prototype,"slicePlaneEnabled",null),e([S({readOnly:!0})],tt.prototype,"tilingScheme",void 0),e([S({readOnly:!0})],tt.prototype,"tilingSchemeLocked",null),e([S({readOnly:!0})],tt.prototype,"tilingSchemeLogic",void 0),e([S({value:!0})],tt.prototype,"velvetOverground",null),e([S()],tt.prototype,"wireframe",null),e([S({value:!1})],tt.prototype,"suspended",null),e([S()],tt.prototype,"textureFadeDuration",null),e([S()],tt.prototype,"visibleElevationBounds",void 0),e([S()],tt.prototype,"rootTileElevationBounds",void 0),e([S()],tt.prototype,"_layerViewsDirty",void 0),e([S()],tt.prototype,"renderPatchBorders",null),e([S()],tt.prototype,"visualizeNormals",null),e([S()],tt.prototype,"renderingDisabled",null),tt=e([L("esri.views.3d.terrain.TerrainSurface")],tt);const it=tt;function rt(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function st(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>st(e))))}function at(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const nt=x(),lt=j(),ot=[0,0,0],ht=new _,dt={spatialReference:null,extent:j(),context:"ground"},pt={spatialReference:null,extent:null,scale:0};export{it as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{isAbortError as g,isAborted as m,createAbortError as T}from"../../../core/promiseUtils.js";import{watch as f,syncAndInitial as y,sync as v,initial as w}from"../../../core/reactiveUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as L}from"../../../core/accessorSupport/decorators/subclass.js";import{m as E}from"../../../chunks/mat4.js";import{c as D}from"../../../chunks/mat4f64.js";import{c as P}from"../../../chunks/vec3.js";import{c as C}from"../../../chunks/vec3f64.js";import{c as x}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as b}from"../../../core/support/WatchUpdatingTracking.js";import{projectVectorToVector as U,projectPointToVector as R}from"../../../geometry/projection.js";import{getReferenceEllipsoid as M}from"../../../geometry/projectionEllipsoid.js";import{create as j,equals as A,intersection as I,empty as V,expand as O,intersectsSphere as B}from"../../../geometry/support/aaBoundingRect.js";import{create as k,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as q}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as G}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as F}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as W}from"../../../layers/support/layerUtils.js";import{acquireDecoder as H}from"../../../layers/support/LercDecoder.js";import{printAllocations as z}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as Q,scaleToZoom as X}from"../support/cameraUtils.js";import Y from"../support/debugFlags.js";import{toBoundingRect as $}from"../support/extentUtils.js";import{ClientType as K}from"../support/index.js";import{updatingProgress as J}from"../support/updatingProperties.js";import{ElevationBounds as Z}from"./ElevationBounds.js";import{sampleElevation as ee,ElevationData as te}from"./ElevationData.js";import{create as ie}from"./ExtentHelper.js";import{LODSnapping as re,TextureUpdate as se}from"./interfaces.js";import{LayerClass as ae,LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as he}from"./RenderOrder.js";import{SphericalPatch as de}from"./SphericalPatch.js";import{MAX_ROOT_TILES as pe,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as ue,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ce,MAX_MEMORY_LOD_BIAS as _e,ELEVATION_NODATA_VALUE as ge}from"./TerrainConst.js";import me from"./TerrainRenderer.js";import Te from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as fe,internalAssert as ye,oppositeEdge as ve,isSurfaceLayerView as we,isGroupLayerView as Se,isMapTileLayerView as Le,isBlendableLayerView as Ee,isElevationLayerView as De,isVectorTileLayerView as Pe,useFetchTileForLayer as Ce,isImageryTileLayerView as xe,isTileLayerView as be,releaseTileData as Ue,neighborEdgeIndices as Re,ENABLE_TERRAIN_INTERNAL_CHECKS as Me,ENABLE_WATERPROOFNESS_TESTS as je,enableTerrainInternalChecks as Ae,enableTerrainWaterproofnessChecks as Ie}from"./terrainUtils.js";import{SplitLimits as Ve,Tile as Oe}from"./Tile.js";import{printAllocations as Be}from"./TilePerLayerInfo.js";import{TileUpdate as ke}from"./TileUpdate.js";import{IteratorPreorder as Ne,IteratorPostorder as qe,compareTilesByLij as Ge,hasLoadableSiblings as Fe,sortTilesByPOI as We,sortTiles as He}from"./tileUtils.js";import{TilingSchemeLogic as ze}from"./TilingSchemeLogic.js";import{UpsampleInfo as Qe}from"./UpsampleInfo.js";import{isCompositeBlendMode as Xe,blendModeFromString as Ye}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as $e}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as Ke}from"../../support/RenderState.js";import{ImmediateTask as Je,TaskPriority as Ze,noBudget as et}from"../../support/Scheduler.js";let tt=class extends(a.EventedMixin(i)){constructor(e){super(e),this._iteratorPool=new c(Ne,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new qe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new Te,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=C(),this._eyePosSurfaceSR=C(),this._splitLimits=new Ve,this._snapLevel=1/0,this._frustum=k(),this._viewProjectionMatrix=D(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new b,this._frameTask=Je,this._allTiles=new _,this._upsampleInfoPool=new c(Qe),this._rootTilesExtent=j(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this.visibleElevationBounds=new Z(1/0,-1/0),this.rootTileElevationBounds=new Z(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this.shortBatches=!1,this.oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this._shading=!0,this._isWebMercator=!1,this._isWebMercatorOnPlateeCarree=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=H(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(oe):new c(de);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new F(e.newCache("elevation-query")),this._set("overlayManager",new le({surface:this})),this._handles.add([f((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),f((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e)))],"overlayManager"),this._renderer=new me({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:M(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles}),this._handles.add([f((()=>this.baseOpacity),(e=>{this._handleLayerViewChanges(),this._updateBaseOpacity(e)}),y),f((()=>this.hasCompositeBlendMode),(()=>{this._updateBaseOpacity(this.baseOpacity)}),y),f((()=>this.renderingDisabled),(()=>this._updateTransparentTerrain()),v),f((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),f((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>()=>this._allTilesSorted=!1))})),f((()=>Y.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&Y.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),w)]),this._extentHelper=ie(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=this.view.defaultsFromMap?new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}):this.view.map.allLayers,i=new ze({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(K.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(K.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(Ze.TERRAIN_SURFACE,this),this._handles.add([f((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),w),f((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),v),f((()=>this.extent),(()=>this._updateRootTiles()),w),this.view.on("resize",(()=>this._viewChangeUpdate())),f((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),f((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),w),f((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),v)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._handles.add([f((()=>this.view?.map.ground.shading),(()=>{this._updateShadingIfChanged()}))]),this._updateShading(),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache),this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),this._extentHelper=d(this._extentHelper),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Oe.prune(),this._treeDebugger&&(this._treeDebugger.destroy(),this._treeDebugger=null),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),z(),Be()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){const e=this.view.pointsOfInterest?.contentCameraOnSurface?.scale;if(e){const t=this.view.state.contentCamera;let i=Q(this.view,t.eye,t.viewForward,t.up).tilt;i>90&&(i=180-i);const r=2*(i/90)**2,s=X(this.view,e)-r;Math.round(s)!==Math.round(this._snapLevel)&&(this._viewChanged=!0),this._snapLevel=s}return Math.round(this._snapLevel)}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?re.ON:re.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=j(),r=$(t,i,e)?i:null,s=this._get("extent");return A(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=I(this.groundExtent,this._userClippingExtent,j()),t=this._get("extent");return A(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager.updating)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view.map.ground.opacity}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this.rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get 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._updateTransparentTerrain()}_updateTransparentTerrain(){const e=!this.renderingDisabled&&!this.opaque;this.view?._stage?.renderView.setRenderParameters({transparentTerrain:e})}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}set velvetOverground(e){e!==this.velvetOverground&&(this._renderer.velvetOverground=e),this._set("velvetOverground",e)}get wireframe(){return this._renderer.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get textureFadeDuration(){return this.view.qualitySettings.tiledSurface.textureFadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this.getTileWithElevation(e,t,i,r,nt);return p(s)?null:ee(nt[0],nt[1],s.renderData.geometryState.samplerData)}getTileWithElevation(e,t,i,r,s=nt){const a=this.rootTiles;if(p(a)||!a.length)return null;if(0===a[0].layerInfo[ae.ELEVATION].length)return null;if(s[0]=e,s[1]=t,s[2]=i,!U(s,r,s,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;for(let n of a){if(!n.containsPoint(s))continue;for(;n&&!n.rendered&&!n.isLeaf;){let e=0;s[0]>.5*(n.extent[0]+n.extent[2])&&(e+=1),s[1]<.5*(n.extent[1]+n.extent[3])&&(e+=2),n=n.children[e]}const e=n.renderData;return(e?e.geometryState.samplerData:null)?n:null}return null}getScale(e){if(this.tilingScheme){if(!R(e,nt,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this.rootTiles;if(u(t))for(let e of t)if(e?.containsPoint(nt)){for(;!e.isLeaf&&!e.rendered;){let t=0;nt[0]>e.children[0].extent[2]&&(t+=1),nt[1]<e.children[0].extent[1]&&(t+=2),e=e.children[t]}return this._getLodBiasCorrectedScale(e.level)}}return 1e100}getSphereElevationBounds(e,t,i,r,s){if(nt[0]=e,nt[1]=t,nt[2]=i,nt[3]=r,!U(nt,s,nt,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&B(e.extent,nt))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},h=this.rootTiles;if(u(h))for(const l of h)o(l);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!R(e,nt,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;nt[3]=t;let i=null;const r=e=>{if(e&&B(e.extent,nt))if(e.isLeaf||e.rendered){const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}else for(const t of e.children)r(t)},s=this.rootTiles;if(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_updateBaseOpacity(e){const t=this._renderer.opaque;this._renderer.opaque=e>=1&&!this.hasCompositeBlendMode,this._renderer.isTransparent=this._allSurfaceLayersTransparent();const i=t!==this._renderer.opaque;i&&this._updateTransparentTerrain(),this._updateTileTextures(i?se.UNFADED:se.IMMEDIATE)}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;e!==this.tilingScheme&&(fe(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles(),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles()),this._isWebMercator=!!this.tilingScheme?.spatialReference.isWebMercator,this._isWebMercatorOnPlateeCarree=this._isWebMercator&&q(this.view?.renderSpatialReference))}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return ot[0]=e,ot[1]=t,ot[2]=i,s.init(ot,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=lt;let s=t.rootTilesInExtent(e,i,5*pe);if(u(this.rootTiles)){if(s.length>pe)return void l.getLogger(this.declaredClass).warn(ue);const e=this.rootTiles.map((e=>e.lij)),t=r(e,s,rt);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this.rootTiles.filter((e=>!(t.removed.findIndex((t=>rt(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.declaredClass).warn(ce),s=t.rootTilesInExtent(e,i,pe)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=j(i)),this._visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.isLoaded&&e.intersectsClippingArea));e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Ge);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e)))}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return t.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===ke.SPLIT&&t.setPendingUpdate(ke.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._set("rootTiles",e),this._allTiles.clear(),u(e)){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this.rootTiles),this._updateTilesVisibility(e,!0)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate(!1))}_viewChangeUpdate(e=!0){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this.rootTiles,e)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e,t=!0){if(p(e))return;const i=Fe(e),r=this.visibleElevationBounds;let s=i?r.min:1/0,a=i?r.max:-1/0;const n=this.extent,l=this._viewProjectionMatrix;this.setTileTreeDirty();const o=this._iteratorPool.acquire();for(o.reset(e);!o.done;){const e=o.next();e.updateClippingStatus(n)&&e.resetPendingUpdate(ke.GEOMETRY)&&this._updateTileGeometryState(e),e.setPendingUpdate(ke.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(l),e.renderData&&(s=Math.min(e.elevationBounds[0],s),a=Math.max(e.elevationBounds[1],a))}o.remove(),this._viewChanged=!0,this._allTilesDirty=!0,t&&this._batchUpdatePendingTileGeometries(),isFinite(s)&&isFinite(a)&&(r.min!==s||r.max!==a)&&(this.visibleElevationBounds=new Z(s,a))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this.rootTiles;u(i)&&i.forEach((({elevationBounds:i})=>{e=Math.min(e,i[0]),t=Math.max(t,i[1])}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new Z(e,t))}_updateViewDependentParameters(){const e=this.view.state.camera,t=this.view.state.contentCamera,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=k()),N(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,N(this._frustum,e.frustum),E(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),P(this._eyePosRenderSR,t.eye),U(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(st(e)?this._loadChildren(e):at(e)&&this._loadParent(e))}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForGeometryUpdate(e){const t=this._pendingTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(ke.TEXTURE_FADING)?ke.TEXTURE_FADING:!!e.resetPendingUpdate(ke.TEXTURE_NOFADING)&&ke.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(e){const t=dt.extent;V(t);const i=e.length;for(let r=0;r<i;r++)O(t,e[r].extent,t);dt.spatialReference=this.spatialReference,this.emit("elevation-change",dt)}runTask(e){this.shortBatches=e.state===Ke.ANIMATING,this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),e.run((()=>this._updateElevation(e))),e.run((()=>this._updateTextures(e))),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),e.done?this.requestUpdate():this.getUsedMemory(),this.notifyChange("updatingProgressValue"),this.shortBatches=!1}_updateAllTilesStatus(e){if(!this._viewChanged||!this.rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();for(t.reset(this.rootTiles);!t.done;){const e=t.next(),i=e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping);if(i!==ke.SPLIT){if(e.resetPendingUpdate(ke.SPLIT)&&e.updateAgentSuspension(),i===ke.VSPLITMERGE&&e.updateAgents(ae.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(ke.MERGE),e.resetPendingUpdate(ke.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(this._viewProjectionMatrix);t.remove()}}else e.resetPendingUpdate(ke.MERGE),e.isLeaf&&(e.setPendingUpdate(ke.SPLIT),t.skipSubtree()),e.rendered&&e.setPendingUpdate(ke.RENDERDATA)}t.remove(),this.requestUpdate(),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(We(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){ye(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForGeometryUpdate(e),this.shortBatches&&this._batchUpdatePendingTileGeometries())}_batchUpdatePendingTileGeometries(){const e=this._pendingTilesToUpdate;if(0===e.size)return;const t=Array.from(this._pendingTilesToUpdate.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea)),i=(i,r)=>{!r?.isLoaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Ge);const r=t.length;for(let s=0;s<r;++s){const r=t[s];ye(r.isLoaded),ye(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData;for(let t=0;t<4;++t)if(n&1<<t){const s=r.renderData.geometryState.neighborData.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(ve(Re[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(ye(e.has(t)||Ge(r,t)<0),i(r,t),!0))),i(r,l.cornerPeerNeighbors[t]),i(r,l.cornerPeerNeighbors[(t+1)%4])}}e.clear(),this._updateTilesGeometries(t),this._emitElevationUpdateEventForTiles(t),Me&&je&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1,r=!1;for(;!e.done;){r=!0;let s=!1;const a=!this._allTiles.some((r=>{if(!i&&!r.loadable)return e.done;let a=r;if(r.resetPendingUpdate(ke.MERGE)){if(!t)return r.setPendingUpdate(ke.MERGE),e.done;for(;a.parent?.resetPendingUpdate(ke.MERGE);)a=a.parent;this._mergeTile(a),s=!0,e.madeProgress()}else r.resetPendingUpdate(ke.SPLIT)&&(this._splitTile(r),s=!0,e.madeProgress());return!e.done&&a===r&&r.resetPendingUpdate(ke.RENDERDATA)&&(this._updateRenderData(r),e.madeProgress()),e.done}));if(s&&(this._allTilesSorted=!1,this._allTilesDirty=!0),a){if(!i){i=!0;continue}if(!s)break}else this._allTilesDirty=!0}r||(this._allTilesDirty=!0),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){return this._allTiles.some((t=>(t.resetPendingUpdate(ke.GEOMETRY)&&(this._updateTileGeometryState(t),this._updateTileTexture(t,e),e.madeProgress()),e.done))),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),e.hasProgressed}_updateTextures(e){return this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done))),e.hasProgressed}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams($e.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;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(){u(this.rootTiles)&&(this.rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(e.isLeaf)return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i])||t;return e.unsetChildren(),t}_purgeTile(e){const t=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),this._tilePool.release(e),t}_unloadTile(e){this._pendingTilesToUpdate.delete(e),e.unload(this._renderer)}_splitTile(e){fe(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(ke.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){pt.spatialReference=this.spatialReference,pt.extent=e.extent,pt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",pt)}_createTile(e,t,i,r){fe(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),s.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.lodSnapping)===ke.SPLIT&&s.setPendingUpdate(ke.SPLIT),s}_mergeTile(e){fe(!e.hasPendingUpdate(ke.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(fe(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this.shortBatches&&this._batchUpdatePendingTileGeometries()),this._allTilesDirty=!0,++this._performanceInfo.numMerged}_loadChildren(e){fe(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForGeometryUpdate(e),this._emitTileScaleChange(e,e.level+1),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._markTileToUpdate(t),this._emitTileScaleChange(t,t.level),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_unloadChildren(e){if(!e.isLeaf)for(let t=0;t<4;++t){const i=e.children[t];this._unloadChildren(i),this._unloadTile(i)}}_loadTile(e){e.load(),e.setPendingUpdate(ke.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new te(e.lij,e.extent,i);e.dataArrived(t,ae.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=et){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),we(s)||Se(s))if(this._basemapLayerViewHandles.has(s.uid)&&!Se(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.layer.loaded&&(t=!0);this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this._renderer.isTransparent=this._allSurfaceLayersTransparent(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(Le(t)&&!W(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ee(e)||Se(e))&&Xe(Ye[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return De(e)?ae.ELEVATION:ae.MAP}_registerTiledLayerView(e){const t=[];if((Ee(e)||Se(e))&&t.push(f((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(se.UNFADED)}))),Se(e))return;const i=this._layerClassFromLayerView(e);t.push(f((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(f((()=>e.fullOpacity),(()=>this._updateTileTextures(se.UNFADED)))),t.push(f((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)t[e].remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!we(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===ae.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ne){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this.rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this.rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&this._viewChangeUpdate()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this.rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===ae.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(ae.MAP),e===se.IMMEDIATE?this.renderer.updateTileTexture(t,ke.TEXTURE_NOFADING):t.updateRenderData(ae.MAP,e)})),this._renderer.isTransparent=this._allSurfaceLayersTransparent()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=$e.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Pe(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===ae.ELEVATION?De(i)?this._requestElevationTileData(e,i,r):Promise.reject():Le(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(m(i))return;const s=this._layerIndexByUid[ae.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer %d %s",ae.ELEVATION,e.lij.toString())},s=i=>{g(i)||(this._dataMissing(e,ae.ELEVATION,t,i),this.requestUpdate())};if(Ce(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:ge,signal:i.signal}).then((e=>{if(!m(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:ge},i.signal))).then((e=>{e?r({values:e.pixelData,width:e.width,height:e.height,noDataValue:e.noDataValue,minValue:e.minValue,maxValue:e.maxValue}):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ue(s),m(i)||(this._dataMissing(e,ae.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),m(i)?Ue(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(Pe(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(xe(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(be(t)&&Ce(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(m(i))return l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(T());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);G(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(ae.MAP,t.uid);u(r)?e.dataArrived(r,ae.MAP,i):(Ue(i),l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this.rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.isLeaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this.rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this.rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this.rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return fe(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e.rootTiles)&&(e._mergeTile(e.rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){ht.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&ht.push(e)}));const t=ht.toArray();return He(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!je)return;const e=this.rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shading(){return this._shading}_updateShadingIfChanged(){const e=this.view?.map?.ground?.shading;e!==this._shading&&this._updateShading()}_updateShading(){const e=this.view?.map?.ground?.shading;this._shading=e,this.renderer&&(this.renderer.shading=e,this.renderer.setNeedsRender()),this._updateAllTileGeometries()}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateeCarree(){return this._isWebMercatorOnPlateeCarree}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(u(this.spatialReference)&&this.spatialReference.isGeographic?1:0))}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this.isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ae(e)}enableWaterproofnessChecks(e){Ie(e)}};e([S()],tt.prototype,"_renderer",void 0),e([S()],tt.prototype,"_hasPendingUpdates",void 0),e([S()],tt.prototype,"_asyncWorkItems",void 0),e([S()],tt.prototype,"_allTilesDirty",void 0),e([S()],tt.prototype,"_allTilesSorted",void 0),e([S()],tt.prototype,"_viewChanged",void 0),e([S({readOnly:!0})],tt.prototype,"_watchUpdatingTracking",void 0),e([S()],tt.prototype,"_frameTask",void 0),e([S({readOnly:!0})],tt.prototype,"snapLevel",null),e([S({readOnly:!0})],tt.prototype,"lodSnapping",null),e([S({constructOnly:!0})],tt.prototype,"view",void 0),e([S()],tt.prototype,"_userClippingExtent",null),e([S()],tt.prototype,"_rootTilesExtent",void 0),e([S({readOnly:!0})],tt.prototype,"extent",null),e([S({readOnly:!0})],tt.prototype,"groundExtent",null),e([S({readOnly:!0})],tt.prototype,"_tilingSchemeExtent",null),e([S({readOnly:!0})],tt.prototype,"updating",null),e([S({readOnly:!0})],tt.prototype,"running",null),e([S(J)],tt.prototype,"updatingProgress",void 0),e([S({readOnly:!0})],tt.prototype,"updatingProgressValue",null),e([S()],tt.prototype,"_maxNumUpdating",void 0),e([S()],tt.prototype,"baseOpacity",null),e([S()],tt.prototype,"hasCompositeBlendMode",void 0),e([S({readOnly:!0})],tt.prototype,"overlayManager",void 0),e([S({readOnly:!0})],tt.prototype,"viewingMode",null),e([S()],tt.prototype,"maxTextureScale",void 0),e([S({readOnly:!0})],tt.prototype,"ready",null),e([S({value:he.FRONT_TO_BACK})],tt.prototype,"renderOrder",null),e([S({readOnly:!0})],tt.prototype,"rootTiles",void 0),e([S({readOnly:!0})],tt.prototype,"spatialReference",null),e([S({type:t})],tt.prototype,"backgroundColor",null),e([S({value:!1})],tt.prototype,"slicePlaneEnabled",null),e([S({readOnly:!0})],tt.prototype,"tilingScheme",void 0),e([S({readOnly:!0})],tt.prototype,"tilingSchemeLocked",null),e([S({readOnly:!0})],tt.prototype,"tilingSchemeLogic",void 0),e([S({value:!0})],tt.prototype,"velvetOverground",null),e([S()],tt.prototype,"wireframe",null),e([S({value:!1})],tt.prototype,"suspended",null),e([S()],tt.prototype,"textureFadeDuration",null),e([S()],tt.prototype,"visibleElevationBounds",void 0),e([S()],tt.prototype,"rootTileElevationBounds",void 0),e([S()],tt.prototype,"_layerViewsDirty",void 0),e([S()],tt.prototype,"renderPatchBorders",null),e([S()],tt.prototype,"visualizeNormals",null),e([S()],tt.prototype,"renderingDisabled",null),tt=e([L("esri.views.3d.terrain.TerrainSurface")],tt);const it=tt;function rt(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function st(e){return!e.isLeaf&&(e.children.some((e=>e.shouldLoad))||e.children.some((e=>st(e))))}function at(e){return e.isLeaf&&e.parent&&e.parent.shouldLoad}const nt=x(),lt=j(),ot=[0,0,0],ht=new _,dt={spatialReference:null,extent:j(),context:"ground"},pt={spatialReference:null,extent:null,scale:0};export{it as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as e}from"../../../core/mathUtils.js";import{isSome as t,abortMaybe as i,isNone as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{c as r,s as a}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{b as l,p as h,e as u,g as d,a as c,l as f}from"../../../chunks/vec3.js";import{c as g,u as p}from"../../../chunks/vec3f64.js";import{g as m}from"../../../chunks/common.js";import{getReferenceEllipsoid as _}from"../../../geometry/projectionEllipsoid.js";import{create as y,equals as A}from"../../../geometry/support/aaBoundingRect.js";import{c as T}from"../../../chunks/sphere.js";import{VectorTile as E}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as v}from"../support/StreamDataLoader.js";import{ElevationBounds as I}from"./ElevationBounds.js";import{ElevationTileAgent as M}from"./ElevationTileAgent.js";import{TileFrustumVisibility as D,LODSnapping as L,TextureUpdate as S,NeighborIndex as x}from"./interfaces.js";import{LayerClasses as O,LayerClass as N}from"./LayerClass.js";import{MapTileAgent as j}from"./MapTileAgent.js";import{RasterTile as b}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as U,getElevationDesiredResolutionLevel as C}from"./TerrainConst.js";import{weakAssert as P,getLayerWithExtentRange as B,isBlendableLayerView as R,isGroupLayer as V,oppositeCorner as G,neighborCornerIndices as w,neighborEdgeIndices as W,oppositeEdge as q,internalAssert as H,ENABLE_TERRAIN_INTERNAL_CHECKS as F,isNorth as k,isSouth as X,isWest as z,isEast as J,ENABLE_WATERPROOFNESS_TESTS as Y,isWestCorner as $,isNorthCorner as Q}from"./terrainUtils.js";import{TILE_AGENT_DONE as K}from"./TileAgent.js";import{TilePerLayerInfo as Z}from"./TilePerLayerInfo.js";import ee from"./TileTexture.js";import{TileUpdate as te}from"./TileUpdate.js";import{fallsWithinLayer as ie}from"./tileUtils.js";import{getGpuMemoryUsage as se}from"../../webgl/Util.js";const ne=g(),re=g(),ae=g(),oe=.1;class le{constructor(){this.fovX=0,this.fovY=0,this.relativeWidthLimit=0,this.relativeHeightLimit=0,this.maxLod=0,this.angledSplitBias=0,this.aboveGround=!0}}class he{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=y(),this._elevationBounds=o(),this.layerInfo=[[],[]],this.extentInRadians=y(),this.centerAtSeaLevel=g(),this._center=[g(),T(),g()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemoryInternal=0,this._mapDataRefCount=0,this._screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0}static prune(){ce.prune(0),fe.prune(0),Z.prune()}get _isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[pe.MIDDLE][3]}get screenDepth(){return this._screenDepth}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent?.frustumVisibility??D.INTERSECTS;this._frustumVisibility=e===D.INSIDE?D.INSIDE:e===D.OUTSIDE?D.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const t=this._frustumVisibility!==D.OUTSIDE&&this._intersectsClippingArea;t!==this._visible&&(this._visible=t,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}get shouldLoad(){if(this._surface.lodSnapping===L.ON){const e=this.level-this._surface.snapLevel;if(0===e)return!0;if(1===e)return!1}return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=_(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[pe.MIDDLE][3]=0,this.vlevel=e?e[0]:0,t&&t.elevationBounds?r(this._elevationBounds,t.elevationBounds):a(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this._screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of O){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=Z.acquire(this._surface.upsampleInfoPool),s===N.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,U)}release(){P(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of O){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null;for(let e=0;e<4;++e)this._children[e]=null;this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){this.setMemoryDirty();const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemoryInternal)}get _cachedMemory(){return this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[N.MAP].reduce(((e,t)=>e+(t instanceof E?t.memoryUsage:0)),this._mapTileMemoryInternal)}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(t(this._usedMemory))return this._usedMemory;this._usedMemory=0,this._mapTileMemoryInternal=0;let e=0;for(const{data:t}of this.layerInfo[N.MAP])t instanceof E?e+=this._getTerrainDataMemory(t):this._mapTileMemoryInternal+=this._getTerrainDataMemory(t);const i=this._cpuImageMemorySize;for(const t of this.layerInfo[N.ELEVATION])this._usedMemory+=t.data?i:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemoryInternal+=se(this.renderData.textureDescriptor)),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemoryInternal+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===N.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===N.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof ee?se(e.texture):e instanceof HTMLImageElement||e instanceof v?this._cpuImageMemorySize:e instanceof E||e instanceof b?e.memoryUsage:0}updateScreenDepth(e){const t=this._center[pe.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this._screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,i,s){if(!this.visible)return te.NONE;if(t(e.frustum)&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===D.OUTSIDE))return te.NONE;const n=this.level;l(ne,this._center[pe.MIDDLE],i);let r=h(ne),a=pe.MIDDLE;l(re,this._center[pe.TOP],i);const o=h(re);o<r&&(r=o,a=pe.TOP),l(re,this._center[pe.BOTTOM],i);const g=h(re);if(g<r&&(r=g,a=pe.BOTTOM),this._edgeLen2>r&&n<e.maxLod)return te.SPLIT;const p=Math.sqrt(r),m=e.fovX*p*2,_=this._edgeLen/m,y=()=>{const t=n+Math.ceil(-Math.log2(e.relativeWidthLimit/_));return t!==this.vlevel?(this.vlevel=t,te.VSPLITMERGE):te.NONE_HIT_MAXLOD};if(s===L.ON){if(1===this._surface.snapLevel-n)return n>=e.maxLod?y():te.SPLIT}const A=u(this.up,ne),T=this._elevationBounds[1]-this._elevationBounds[0],E=T/this.edgeLen;if(e.aboveGround&&A>0&&E<.001){if(A/p-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return te.NONE}if(_<e.relativeWidthLimit)return this.vlevel!==this.level?(this.vlevel=this.level,te.VSPLITMERGE):te.NONE;if(n>=e.maxLod)return y();if(n>6){l(re,this._center[a],i),d(ae,this.up,A),l(ae,ae,re);const t=h(ae);if(t>this.radius*this.radius){d(ae,ae,this.radius/Math.sqrt(t)),c(ae,ae,this._center[a]),l(ae,i,ae);const s=Math.min(1,(Math.abs(u(ae,this.up))+.5*T+this._curvatureHeight)/f(ae)),n=oe/e.angledSplitBias,r=e.fovY*p*2;if(s*(this._edgeLen/r)<n*e.relativeHeightLimit)return te.NONE}}return te.SPLIT}setChildren(e,t,i,s){P(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of O)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){e.unloadTile(this);for(const t of O){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==K&&(de(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(te.GEOMETRY),this.resetPendingUpdate(te.TEXTURE_NOFADING),this.resetPendingUpdate(te.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[N.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==K&&(de(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(A(e,this._clippingArea))return!1;const i=this._intersectsClippingArea,s=this._isWithinClippingArea;t(e)?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const n=s&&this._isWithinClippingArea,r=!(s||i||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||n||r||this.setPendingUpdate(te.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of O){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==K&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(te.SPLIT)||e!==N.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===te.SPLIT||e===te.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated)return console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),s.dataArrived(this),!0;if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;if(this.isLeaf)return null;const t=this._children[0].findByLij(e)||this._children[1].findByLij(e)||this._children[2].findByLij(e)||this._children[3].findByLij(e);return t||null}distanceToSquared(e){return h(l(ae,this._center[pe.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);P(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=this.layerInfo[t][e];s.data=i,s.dataInvalidated=!1,s.waitingAgents.forAll((e=>e.dataArrived(this))),s.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t){switch(e){case N.MAP:return this._updateTexture(t);case N.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===S.FADING?te.TEXTURE_NOFADING:te.TEXTURE_FADING),this.setPendingUpdate(e===S.FADING?te.TEXTURE_FADING:te.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(te.GEOMETRY);for(const e of this.layerInfo[N.ELEVATION])e.pendingUpdates|=te.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds;a(e,1/0,-1/0);const i=this.layerInfo[N.ELEVATION];let s=!0;for(const n of i)t(n.elevationBounds)&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(s=!1));s&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),this.updateRadiusAndCenter(),this._surface.setTileTreeDirty()}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]);d(ae,this.up,t),c(this._center[pe.MIDDLE],this.centerAtSeaLevel,ae),d(ae,this.up,e[0]),c(this._center[pe.TOP],this.centerAtSeaLevel,ae),d(ae,this.up,e[1]),c(this._center[pe.BOTTOM],this.centerAtSeaLevel,ae)}findElevationBoundsForLayer(e,i){const n=this.layerInfo[N.ELEVATION][e];if(t(n.elevationBounds)&&n.elevationBounds.level>=i)return;const r=this._surface.layerViewByIndex(e,N.ELEVATION),a=B(r);if(!ie(this,a,!1))return;const o=ge;let l=!1;if(n.data){const e=n.data;o.min=e.bounds[0],o.max=e.bounds[1],o.hasNoDataValues=e.hasNoDataValues,o.level=this.level,l=!0}else{let t,i,s=0;for(let n=this._parent;n&&(!i||s<C(this.level))&&(s=this.vlevel-n.level,t=i||t,i=n.layerInfo[N.ELEVATION][e].data,!(!i&&t&&s>=C(this.level)));n=n.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],o),o.min!==1/0&&(o.level=i.level,l=!0))}l&&(s(n.elevationBounds)&&(n.elevationBounds=new I),n.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==K&&(de(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:Z.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,S.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===K&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of O){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==K&&(i.loadingAgent.setSuspension(t),i.loadingAgent===K&&this.updateRenderData(e,S.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==K&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=K,!i.data&&s(i.upsampleInfo)&&this._createOrUpdateAgents(e+1,t)}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=e=>"normal"!==e.blendMode||V(e.parent)&&s(e.parent),n=(()=>{for(let n=e;n<i.length;++n){const e=this._surface.layerViewByIndex(n,t);if(R(e)&&"normal"!==e.layer.blendMode||V(e.layer.parent)&&s(e.layer.parent))return!0}return!1})(),r=this._isSuspended(t);for(let a=e;a<i.length;++a){const e=i[a];let s=!1;const o=this._surface.layerViewByIndex(a,t),l=B(o);if(e.loadingAgent?ie(this,l,!1)?(e.loadingAgent!==K&&e.loadingAgent.setSuspension(r),e.loadingAgent!==K&&(s=e.loadingAgent.update())):e.dispose():ie(this,l,!1)&&(e.loadingAgent=ue(this,a,t,r),s=e.loadingAgent.startLoading(),s?e.loadingAgent===K&&this.setPendingUpdate(te.GEOMETRY):(de(e.loadingAgent),e.loadingAgent=K)),e.loadingAgent===K&&this.updateRenderData(t,S.FADING),!n&&s&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationBasedVerticesPerSide(t){const i=this.vlevel-this.level,s=Math.max(this.level-t,C(this.level)-i);return e(1+(this.maxTesselation>>s),2,this.maxTesselation+1)}get test(){return{cachedMemory:this._cachedMemory}}_findLIJ(e,i){if(!e)return null;const s=this.surface.rootTiles;if(t(s))for(const t of s)if(me(t,e)){let s=t,n=e[0]-s.level-1;for(;n>=0&&!s.isLeaf&&!i(s);){const t=e[1]>>n&1,i=e[2]>>n&1;s=s.children[2*t+i],n--}return i(s)?s:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?_e(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===x.NORTH_EAST?1:e===x.NORTH_WEST?0:e===x.SOUTH_WEST?2:3;let s=this;for(;!(s.isLeaf||t&&t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(G(e),t)}forAllSubtreeOnSide(e,t){const i=e===x.NORTH?[0,1]:e===x.NORTH_EAST?[1]:e===x.EAST?[1,3]:e===x.SOUTH_EAST?[3]:e===x.SOUTH?[2,3]:e===x.SOUTH_WEST?[2]:e===x.WEST?[0,2]:[0],s=e=>{t(e)||e.isLeaf||i.forEach((t=>s(e.children[t])))};s(this)}forallNeighbors(e){w.forEach((t=>this.findNeighborCornerTileExact(t,e))),W.forEach((t=>this.findNeighborTile(t,(t=>t.level===this.level||e(t)))?.forAllSubtreeOnSide(q(t),e)))}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(H(!F||i>=0),0===i)return 0;const s=2**i,n=1==(1&e),r=n?0:1,a=t.lij[r+1]*s,o=this.lij[r+1],l=o-a,h=n?s-1-l:l;return F&&(H(a<=o&&o<a+s),H(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;W.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(q(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),w.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(G(t),(e=>e.isLoaded));H(!s||Te(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=k(t)?-1:X(t)?1:0,s=z(t)?-1:J(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){return this.extent[1]+m()>=this.surface.extent[1]}compareLIJs(e){const t=this.lij,i=t[0],s=e[0];if(i===s)return[t,e];const n=i-s;if(n<0){const i=2**-n;return[[s,t[1]*i,t[2]*i],e]}{const s=2**n;return[t,[i,e[1]*s,e[2]*s]]}}checkGeometryWaterproofness(){Y&&(H(this.isLoaded),this.renderData.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(k(e)&&t[3]+s>=i[3])return!1;if(X(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&z(e)&&t[0]-s<=i[0])&&!(!n&&J(e)&&t[2]+s>=i[2])}}function ue(e,t,i,s){const n=i===N.ELEVATION?fe.acquire():ce.acquire();return n.init(e,t,i,s),n}function de(e){e.dispose(),e instanceof M?fe.release(e):e instanceof j&&ce.release(e)}const ce=new n(j),fe=new n(M),ge=new I;var pe;function me(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=Math.floor(t[1]/2**n),a=Math.floor(t[2]/2**n);return r===e.lij[1]&&a===e.lij[2]}function _e(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ye(e,t,i){return Math.abs(e-t)<=i}function Ae(e,t,i){if(s(e)||s(t))return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===x.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===x.WEST)return!0}const n=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case x.NORTH:return ye(e.extent[3],t.extent[1],n);case x.SOUTH:return ye(e.extent[1],t.extent[3],n);case x.EAST:return ye(e.extent[2],t.extent[0],n)||ye(e.extent[2],-t.extent[0],n);case x.WEST:return ye(e.extent[0],t.extent[2],n)||ye(e.extent[0],-t.extent[2],n)}}function Te(e,t,i){return!s(e)&&!s(t)&&t!==e&&(e.level>=t.level?Ee(e,t,i):Ee(t,e,G(i)))}function Ee(e,t,i){H(e.level>=t.level);const s=$(i),n=Q(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=ye(o[0],l[0],h)||e.surface.isGlobal&&ye(o[0],-l[0],h),d=ye(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return H(!1),!1;if(!u&&!d)return H(!1),!1;const c=u?ve(a[1],a[3],r[1],r[3],h):ve(a[0],a[2],r[0],r[2],h);return H(c),c}function ve(e,t,i,s,n=m()){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(pe||(pe={}));export{pe as CenterPosition,le as SplitLimits,he as Tile,ye as almostEquals,Te as isCornerNeighbor,Ae as isEdgeNeighbor};
5
+ import{clamp as e}from"../../../core/mathUtils.js";import{isSome as t,abortMaybe as i,isNone as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{c as r,s as a}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{b as l,z as h,e as u,g as d,a as c,l as f}from"../../../chunks/vec3.js";import{c as g,u as p}from"../../../chunks/vec3f64.js";import{g as m}from"../../../chunks/common.js";import{getReferenceEllipsoid as _}from"../../../geometry/projectionEllipsoid.js";import{create as y,equals as A}from"../../../geometry/support/aaBoundingRect.js";import{c as T}from"../../../chunks/sphere.js";import{VectorTile as E}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as v}from"../support/StreamDataLoader.js";import{ElevationBounds as I}from"./ElevationBounds.js";import{ElevationTileAgent as M}from"./ElevationTileAgent.js";import{TileFrustumVisibility as D,LODSnapping as L,TextureUpdate as S,NeighborIndex as x}from"./interfaces.js";import{LayerClasses as O,LayerClass as N}from"./LayerClass.js";import{MapTileAgent as j}from"./MapTileAgent.js";import{RasterTile as b}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as U,getElevationDesiredResolutionLevel as C}from"./TerrainConst.js";import{weakAssert as P,getLayerWithExtentRange as B,isBlendableLayerView as R,isGroupLayer as V,oppositeCorner as G,neighborCornerIndices as w,neighborEdgeIndices as W,oppositeEdge as q,internalAssert as H,ENABLE_TERRAIN_INTERNAL_CHECKS as F,isNorth as k,isSouth as X,isWest as z,isEast as J,ENABLE_WATERPROOFNESS_TESTS as Y,isWestCorner as $,isNorthCorner as Q}from"./terrainUtils.js";import{TILE_AGENT_DONE as K}from"./TileAgent.js";import{TilePerLayerInfo as Z}from"./TilePerLayerInfo.js";import ee from"./TileTexture.js";import{TileUpdate as te}from"./TileUpdate.js";import{fallsWithinLayer as ie}from"./tileUtils.js";import{getGpuMemoryUsage as se}from"../../webgl/Util.js";const ne=g(),re=g(),ae=g(),oe=.1;class le{constructor(){this.fovX=0,this.fovY=0,this.relativeWidthLimit=0,this.relativeHeightLimit=0,this.maxLod=0,this.angledSplitBias=0,this.aboveGround=!0}}class he{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=y(),this._elevationBounds=o(),this.layerInfo=[[],[]],this.extentInRadians=y(),this.centerAtSeaLevel=g(),this._center=[g(),T(),g()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemoryInternal=0,this._mapDataRefCount=0,this._screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0}static prune(){ce.prune(0),fe.prune(0),Z.prune()}get _isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[pe.MIDDLE][3]}get screenDepth(){return this._screenDepth}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent?.frustumVisibility??D.INTERSECTS;this._frustumVisibility=e===D.INSIDE?D.INSIDE:e===D.OUTSIDE?D.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const t=this._frustumVisibility!==D.OUTSIDE&&this._intersectsClippingArea;t!==this._visible&&(this._visible=t,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}get shouldLoad(){if(this._surface.lodSnapping===L.ON){const e=this.level-this._surface.snapLevel;if(0===e)return!0;if(1===e)return!1}return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=_(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[pe.MIDDLE][3]=0,this.vlevel=e?e[0]:0,t&&t.elevationBounds?r(this._elevationBounds,t.elevationBounds):a(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this._screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of O){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=Z.acquire(this._surface.upsampleInfoPool),s===N.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,U)}release(){P(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of O){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null;for(let e=0;e<4;++e)this._children[e]=null;this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){this.setMemoryDirty();const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemoryInternal)}get _cachedMemory(){return this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[N.MAP].reduce(((e,t)=>e+(t instanceof E?t.memoryUsage:0)),this._mapTileMemoryInternal)}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(t(this._usedMemory))return this._usedMemory;this._usedMemory=0,this._mapTileMemoryInternal=0;let e=0;for(const{data:t}of this.layerInfo[N.MAP])t instanceof E?e+=this._getTerrainDataMemory(t):this._mapTileMemoryInternal+=this._getTerrainDataMemory(t);const i=this._cpuImageMemorySize;for(const t of this.layerInfo[N.ELEVATION])this._usedMemory+=t.data?i:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemoryInternal+=se(this.renderData.textureDescriptor)),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemoryInternal+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===N.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===N.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof ee?se(e.texture):e instanceof HTMLImageElement||e instanceof v?this._cpuImageMemorySize:e instanceof E||e instanceof b?e.memoryUsage:0}updateScreenDepth(e){const t=this._center[pe.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this._screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,i,s){if(!this.visible)return te.NONE;if(t(e.frustum)&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===D.OUTSIDE))return te.NONE;const n=this.level;l(ne,this._center[pe.MIDDLE],i);let r=h(ne),a=pe.MIDDLE;l(re,this._center[pe.TOP],i);const o=h(re);o<r&&(r=o,a=pe.TOP),l(re,this._center[pe.BOTTOM],i);const g=h(re);if(g<r&&(r=g,a=pe.BOTTOM),this._edgeLen2>r&&n<e.maxLod)return te.SPLIT;const p=Math.sqrt(r),m=e.fovX*p*2,_=this._edgeLen/m,y=()=>{const t=n+Math.ceil(-Math.log2(e.relativeWidthLimit/_));return t!==this.vlevel?(this.vlevel=t,te.VSPLITMERGE):te.NONE_HIT_MAXLOD};if(s===L.ON){if(1===this._surface.snapLevel-n)return n>=e.maxLod?y():te.SPLIT}const A=u(this.up,ne),T=this._elevationBounds[1]-this._elevationBounds[0],E=T/this.edgeLen;if(e.aboveGround&&A>0&&E<.001){if(A/p-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return te.NONE}if(_<e.relativeWidthLimit)return this.vlevel!==this.level?(this.vlevel=this.level,te.VSPLITMERGE):te.NONE;if(n>=e.maxLod)return y();if(n>6){l(re,this._center[a],i),d(ae,this.up,A),l(ae,ae,re);const t=h(ae);if(t>this.radius*this.radius){d(ae,ae,this.radius/Math.sqrt(t)),c(ae,ae,this._center[a]),l(ae,i,ae);const s=Math.min(1,(Math.abs(u(ae,this.up))+.5*T+this._curvatureHeight)/f(ae)),n=oe/e.angledSplitBias,r=e.fovY*p*2;if(s*(this._edgeLen/r)<n*e.relativeHeightLimit)return te.NONE}}return te.SPLIT}setChildren(e,t,i,s){P(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of O)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){e.unloadTile(this);for(const t of O){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==K&&(de(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(te.GEOMETRY),this.resetPendingUpdate(te.TEXTURE_NOFADING),this.resetPendingUpdate(te.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[N.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==K&&(de(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(A(e,this._clippingArea))return!1;const i=this._intersectsClippingArea,s=this._isWithinClippingArea;t(e)?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const n=s&&this._isWithinClippingArea,r=!(s||i||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||n||r||this.setPendingUpdate(te.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of O){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==K&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(te.SPLIT)||e!==N.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===te.SPLIT||e===te.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated)return console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),s.dataArrived(this),!0;if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;if(this.isLeaf)return null;const t=this._children[0].findByLij(e)||this._children[1].findByLij(e)||this._children[2].findByLij(e)||this._children[3].findByLij(e);return t||null}distanceToSquared(e){return h(l(ae,this._center[pe.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);P(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=this.layerInfo[t][e];s.data=i,s.dataInvalidated=!1,s.waitingAgents.forAll((e=>e.dataArrived(this))),s.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t){switch(e){case N.MAP:return this._updateTexture(t);case N.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===S.FADING?te.TEXTURE_NOFADING:te.TEXTURE_FADING),this.setPendingUpdate(e===S.FADING?te.TEXTURE_FADING:te.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(te.GEOMETRY);for(const e of this.layerInfo[N.ELEVATION])e.pendingUpdates|=te.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds;a(e,1/0,-1/0);const i=this.layerInfo[N.ELEVATION];let s=!0;for(const n of i)t(n.elevationBounds)&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(s=!1));s&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),this.updateRadiusAndCenter(),this._surface.setTileTreeDirty()}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]);d(ae,this.up,t),c(this._center[pe.MIDDLE],this.centerAtSeaLevel,ae),d(ae,this.up,e[0]),c(this._center[pe.TOP],this.centerAtSeaLevel,ae),d(ae,this.up,e[1]),c(this._center[pe.BOTTOM],this.centerAtSeaLevel,ae)}findElevationBoundsForLayer(e,i){const n=this.layerInfo[N.ELEVATION][e];if(t(n.elevationBounds)&&n.elevationBounds.level>=i)return;const r=this._surface.layerViewByIndex(e,N.ELEVATION),a=B(r);if(!ie(this,a,!1))return;const o=ge;let l=!1;if(n.data){const e=n.data;o.min=e.bounds[0],o.max=e.bounds[1],o.hasNoDataValues=e.hasNoDataValues,o.level=this.level,l=!0}else{let t,i,s=0;for(let n=this._parent;n&&(!i||s<C(this.level))&&(s=this.vlevel-n.level,t=i||t,i=n.layerInfo[N.ELEVATION][e].data,!(!i&&t&&s>=C(this.level)));n=n.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],o),o.min!==1/0&&(o.level=i.level,l=!0))}l&&(s(n.elevationBounds)&&(n.elevationBounds=new I),n.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==K&&(de(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:Z.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,S.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===K&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of O){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==K&&(i.loadingAgent.setSuspension(t),i.loadingAgent===K&&this.updateRenderData(e,S.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==K&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=K,!i.data&&s(i.upsampleInfo)&&this._createOrUpdateAgents(e+1,t)}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=e=>"normal"!==e.blendMode||V(e.parent)&&s(e.parent),n=(()=>{for(let n=e;n<i.length;++n){const e=this._surface.layerViewByIndex(n,t);if(R(e)&&"normal"!==e.layer.blendMode||V(e.layer.parent)&&s(e.layer.parent))return!0}return!1})(),r=this._isSuspended(t);for(let a=e;a<i.length;++a){const e=i[a];let s=!1;const o=this._surface.layerViewByIndex(a,t),l=B(o);if(e.loadingAgent?ie(this,l,!1)?(e.loadingAgent!==K&&e.loadingAgent.setSuspension(r),e.loadingAgent!==K&&(s=e.loadingAgent.update())):e.dispose():ie(this,l,!1)&&(e.loadingAgent=ue(this,a,t,r),s=e.loadingAgent.startLoading(),s?e.loadingAgent===K&&this.setPendingUpdate(te.GEOMETRY):(de(e.loadingAgent),e.loadingAgent=K)),e.loadingAgent===K&&this.updateRenderData(t,S.FADING),!n&&s&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationBasedVerticesPerSide(t){const i=this.vlevel-this.level,s=Math.max(this.level-t,C(this.level)-i);return e(1+(this.maxTesselation>>s),2,this.maxTesselation+1)}get test(){return{cachedMemory:this._cachedMemory}}_findLIJ(e,i){if(!e)return null;const s=this.surface.rootTiles;if(t(s))for(const t of s)if(me(t,e)){let s=t,n=e[0]-s.level-1;for(;n>=0&&!s.isLeaf&&!i(s);){const t=e[1]>>n&1,i=e[2]>>n&1;s=s.children[2*t+i],n--}return i(s)?s:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?_e(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===x.NORTH_EAST?1:e===x.NORTH_WEST?0:e===x.SOUTH_WEST?2:3;let s=this;for(;!(s.isLeaf||t&&t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(G(e),t)}forAllSubtreeOnSide(e,t){const i=e===x.NORTH?[0,1]:e===x.NORTH_EAST?[1]:e===x.EAST?[1,3]:e===x.SOUTH_EAST?[3]:e===x.SOUTH?[2,3]:e===x.SOUTH_WEST?[2]:e===x.WEST?[0,2]:[0],s=e=>{t(e)||e.isLeaf||i.forEach((t=>s(e.children[t])))};s(this)}forallNeighbors(e){w.forEach((t=>this.findNeighborCornerTileExact(t,e))),W.forEach((t=>this.findNeighborTile(t,(t=>t.level===this.level||e(t)))?.forAllSubtreeOnSide(q(t),e)))}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(H(!F||i>=0),0===i)return 0;const s=2**i,n=1==(1&e),r=n?0:1,a=t.lij[r+1]*s,o=this.lij[r+1],l=o-a,h=n?s-1-l:l;return F&&(H(a<=o&&o<a+s),H(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;W.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(q(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),w.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(G(t),(e=>e.isLoaded));H(!s||Te(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=k(t)?-1:X(t)?1:0,s=z(t)?-1:J(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){return this.extent[1]+m()>=this.surface.extent[1]}compareLIJs(e){const t=this.lij,i=t[0],s=e[0];if(i===s)return[t,e];const n=i-s;if(n<0){const i=2**-n;return[[s,t[1]*i,t[2]*i],e]}{const s=2**n;return[t,[i,e[1]*s,e[2]*s]]}}checkGeometryWaterproofness(){Y&&(H(this.isLoaded),this.renderData.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(k(e)&&t[3]+s>=i[3])return!1;if(X(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&z(e)&&t[0]-s<=i[0])&&!(!n&&J(e)&&t[2]+s>=i[2])}}function ue(e,t,i,s){const n=i===N.ELEVATION?fe.acquire():ce.acquire();return n.init(e,t,i,s),n}function de(e){e.dispose(),e instanceof M?fe.release(e):e instanceof j&&ce.release(e)}const ce=new n(j),fe=new n(M),ge=new I;var pe;function me(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=Math.floor(t[1]/2**n),a=Math.floor(t[2]/2**n);return r===e.lij[1]&&a===e.lij[2]}function _e(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ye(e,t,i){return Math.abs(e-t)<=i}function Ae(e,t,i){if(s(e)||s(t))return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===x.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===x.WEST)return!0}const n=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case x.NORTH:return ye(e.extent[3],t.extent[1],n);case x.SOUTH:return ye(e.extent[1],t.extent[3],n);case x.EAST:return ye(e.extent[2],t.extent[0],n)||ye(e.extent[2],-t.extent[0],n);case x.WEST:return ye(e.extent[0],t.extent[2],n)||ye(e.extent[0],-t.extent[2],n)}}function Te(e,t,i){return!s(e)&&!s(t)&&t!==e&&(e.level>=t.level?Ee(e,t,i):Ee(t,e,G(i)))}function Ee(e,t,i){H(e.level>=t.level);const s=$(i),n=Q(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=ye(o[0],l[0],h)||e.surface.isGlobal&&ye(o[0],-l[0],h),d=ye(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return H(!1),!1;if(!u&&!d)return H(!1),!1;const c=u?ve(a[1],a[3],r[1],r[3],h):ve(a[0],a[2],r[0],r[2],h);return H(c),c}function ve(e,t,i,s,n=m()){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(pe||(pe={}));export{pe as CenterPosition,le as SplitLimits,he as Tile,ye as almostEquals,Te as isCornerNeighbor,Ae as isEdgeNeighbor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import{isNone as t,isSome as o,unwrap as r,applySome as n}from"../../../../../core/maybe.js";import i from"../../../../../core/PooledArray.js";import{c as s,t as a}from"../../../../../chunks/mat3.js";import{c}from"../../../../../chunks/mat3f32.js";import{d as m,y as l,t as f}from"../../../../../chunks/vec3.js";import{a as p,c as h}from"../../../../../chunks/vec3f64.js";import{c as b}from"../../../../../chunks/vec4f32.js";import{a as u}from"../../../../../chunks/vec32.js";import{c as d}from"../../../../../chunks/vec33.js";import{ViewingMode as g}from"../../../../ViewingMode.js";import{computeOffsetObb as y}from"../../../layers/i3s/I3SUtil.js";import{ColorMixModeEnum as j,encodeSymbolColor as C}from"../../../layers/support/symbolColorUtils.js";import{clone as v,radius as _}from"../../../support/orientedBoundingBox.js";import{glLayout as w}from"../../../support/buffer/glUtil.js";import{newLayout as M}from"../../../support/buffer/InterleavedLayout.js";import O from"./ComponentData.js";import{State as x,ComponentObject as A}from"./ComponentObject.js";import D from"./IntersectionGeometry.js";import{Renderable as S}from"./Renderable.js";import{RenderGeometry as I}from"./RenderGeometry.js";import{RenderSubmitSystem as P}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as E}from"./SourceGeometry.js";import{ComponentParametersVarying as L,ComponentParametersUniform as R,ComponentParameterSummary as U,ComponentMaterial as k}from"./Material/ComponentMaterial.js";import{attributeLocations as T}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as B}from"./Material/shader/ComponentData.glsl.js";import{getVisibility as V,updateVisibilityWithCount as G}from"../../lib/ComponentUtils.js";import{assert as N}from"../../lib/Util.js";import{VertexAttribute as q}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as H}from"../../lib/verticalOffsetUtils.js";import{EdgeInputBufferLayout as z}from"../../lib/edgeRendering/bufferLayouts.js";import{extractComponentsEdgeLocationsLayout as W}from"../../lib/edgeRendering/edgeProcessing.js";import{BufferManager as X}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as Y}from"../../../../webgl/BufferObject.js";import{Usage as F,PrimitiveType as J}from"../../../../webgl/enums.js";import{VertexArrayObject as K}from"../../../../webgl/VertexArrayObject.js";const Q=e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class Z{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._objects=[new i,new i],this._renderSubmit=new P(this),this._renderManager.register(this._renderSubmit),this._hasObjectAndLayerId=has("enable-feature:objectAndLayerId-rendering"),this._componentBufferManager=new X(e.rctx,2+(this._hasObjectAndLayerId?1:0))}dispose(){N(0===this._objects[x.Hidden].length&&0===this._objects[x.Visible].length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy()}createObject(e){const t=new A;return t.toMapSpace=e.toMapSpace,t.transform=e.transform,t.obb=v(e.obb),t.components=new O(this._componentBufferManager,e.geometry.componentOffsets),t.renderable=this._createRenderable(e,t.components),t.intersectionGeometry=new D(e.geometry.positionData,t.components),this._objects[t.visible].push(t),t}destroyObject(e){const t=e;this._objects[t.visible].removeUnordered(t),t.dispose(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(this._objects[o.visible].removeUnordered(o),this._objects[t].push(o),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=m(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.components.visibility.reset(t),o.components.visibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.components.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.components.visibility.componentCount();return{visible:o,invisible:t.components.count-o}}setComponentData(e,r){const n=e,i=n.renderable.material,s=n.components,a=s.materialDataBuffer,c=s.materialDataIndices,m={castShadows:!0,pickable:!0,externalColor:b(),externalColorMixMode:j.Multiply,elevationOffset:0,objectAndLayerIdColor:this._hasObjectAndLayerId?b():null},l=a.textureBuffer,f=new Uint8Array(4),p=new Uint32Array(f.buffer);let h=0,u=0,d=0,g=s.verticalOffsets,_=1/0,w=-1/0,M=!1,O=!1,x=0;for(let b=0;b<s.count;b++){if(r(b,m),h+=+(m.externalColor[3]<1),u+=+(m.externalColorMixMode===j.Replace&&1===m.externalColor[3]),d+=+m.castShadows,C(m.externalColor,m.externalColorMixMode,f),f[2]=254&f[2]|+m.castShadows,l.setData(c[b],0,f[0],f[1],f[2],f[3]),M||(M=b>0&&x!==p[0]),x=p[0],O||(O=0!==m.elevationOffset),O&&t(g)&&(g=new Array(b).fill(0)),o(g)&&(g[b]=m.elevationOffset),_=Math.min(_,m.elevationOffset),w=Math.max(w,m.elevationOffset),B(m.elevationOffset,f),l.setData(c[b],1,f[0],f[1],f[2],f[3]),this._hasObjectAndLayerId){const e=m.objectAndLayerIdColor;l.setData(c[b],2,e[0],e[1],e[2],e[3])}m.pickable!==V(s.pickability,b)&&(s.pickability=G(s.pickability,s.count,b,m.pickable))}s.verticalOffsets=O?g:null,n.offsetObb=O?y(n.obb,_,w,this._viewingMode,o(n.offsetObb)?n.offsetObb:v(n.obb)):null,M||O||this._hasObjectAndLayerId?(i.componentParameters=new L,i.componentParameters.castShadows=ee(d,s.count),i.componentParameters.transparent=ee(h,s.count),i.componentParameters.opaqueOverride=ee(u,s.count),i.componentParameters.texture=l,l.updateTexture()):(i.componentParameters=new R,i.componentParameters.castShadows=m.castShadows?U.All:U.None,i.componentParameters.externalColor=m.externalColor,i.componentParameters.externalColorMixMode=m.externalColorMixMode),this._notifyDirty()}getComponentAabb(e,o,n,i=!1){e.intersectionGeometry.getComponentAabb(o,n);const s=e,a=s.components.verticalOffsets;if(i||t(a))return n;const c=a[o];if(this._viewingMode===g.Local||0===c)return n[2]+=c,n[5]+=c,n;const m=r(H(c));return m.localOrigin=s.transform.position,m.applyToAabb(n)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}intersect(e,t,r,n,i,c){const m=e;o(i)&&(i.localOrigin=m.transform.position);const p=s(te,m.transform.rotationScale);l(oe,t,m.transform.position),l(re,r,m.transform.position),f(oe,oe,p),f(re,re,p);const h=a(te,p);return m.intersectionGeometry.intersect(oe,re,n,h,i,m.components.verticalOffsets,c)}addEdges(e,t,o,r){const n=e,{indices:i,positions:s}=n.intersectionGeometry,a=n.components.offsets;return t.addComponentObject(e,n.transform,{center:n.obb.center,radius:_(n.obb)},s,i,a,o,r)}async extractEdgeInformation(e,t,o){const r=e,n=r.components.visibility;if(n.allInvisible())return{buffer:W.createBuffer(0),origin:[0,0,0]};const{indices:i,positions:s}=r.intersectionGeometry,a=r.components.offsets,c=z.createBuffer(s.count);d(c.position,s),u(c.position,c.position,r.transform.rotationScale),this._setComponentIndices(c.componentIndex,i,a);const m=c.count,l=this._computeVisibilityIndices(i,n,a,m);return{origin:p(r.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:l,indicesLength:l.length,skipDeduplicate:!0,data:c,writerSettings:{reducedPrecision:!1,variants:0}},o)}}_setComponentIndices(e,t,o){let r=0;for(let n=0;n<o.length-1;n++){const i=o[n],s=o[n+1];for(let o=i;o<s;o++){const n=t?t[o]:o;e.set(n,r)}r++}}_computeVisibilityIndices(e,t,o,r){if(e&&t.allVisible())return e;let n=0;t.forEachComponentRange(((e,t)=>(n+=o[t]-o[e],!0)));const i=Array.isArray(e)?new Array(n):2===e?.BYTES_PER_ELEMENT||r<=65536?new Uint16Array(n):new Uint32Array(n);let s=0;return t.forEachComponentRange(((t,r)=>{const n=o[t],a=o[r];for(let o=n;o<a;o++)i[s++]=e?e[o]:o;return!0})),i}addComponentHighlight(e,o){const r=e.components;t(r.highlightCounts)&&(r.highlightCounts=new Uint32Array(r.count+1));0===r.highlightCounts[o]++&&(r.highlightsDirty(),this._notifyDirty()),r.highlightCounts[r.count]++}removeComponentHighlight(e,o){const r=e.components;if(t(r.highlightCounts))return void Q.warn("Removing non-existing highlight.");const n=r.highlightCounts[o],i=r.highlightCounts[r.count];if(0!==n){if(n>1)return r.highlightCounts[o]=n-1,void(r.highlightCounts[r.count]=i-1);r.highlightCounts[o]=0,r.highlightsDirty(),this._notifyDirty(),1===i?r.highlightCounts=null:r.highlightCounts[r.count]=i-1}else Q.warn("Removing non-existing highlight.")}clearHighlights(e){const t=e.components;o(t.highlightCounts)&&(t.highlightCounts=null,t.highlightsDirty(),this._notifyDirty())}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._objects[x.Visible]}_createRenderable(e,t){const i=this._renderManager.rctx,s=e.geometry,a=s.vertices.layoutParameters,c=Y.createVertex(i,F.STATIC_DRAW,s.vertices.data),m=n(s.indices,(e=>Y.createIndex(i,F.STATIC_DRAW,e))),l=w(E(a)),f=new Uint16Array(s.vertices.count);for(let r=0;r<t.count;r++){const e=t.offsets[r],n=t.offsets[r+1],i=t.materialDataIndices[r];if(o(s.indices))for(let t=e;t<n;t++){f[s.indices[t]]=i}else for(let t=e;t<n;t++)f[t]=i}const p=Y.createVertex(i,F.STATIC_DRAW,f.buffer),h=new k(e.transform,e.toMapSpace),b=new K(i,T,{data:l,componentIndices:$},{data:c,componentIndices:p},r(m)),u=new I(b,J.TRIANGLES,a,o(m)),d={cameraDepthSquared:.5,gpuMemoryEstimate:c.byteSize+p.byteSize+(o(m)?m.byteSize:0)};return new S(h,u,d)}_notifyDirty(){this._renderManager.notifyDirty()}}const $=w(M().u16(q.COMPONENTINDEX));function ee(e,t){return e===t?U.All:0===e?U.None:U.Some}const te=c(),oe=h(),re=h();export{Z as ComponentObjectCollection};
5
+ import has from"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import{isNone as t,isSome as o,unwrap as r,applySome as n}from"../../../../../core/maybe.js";import i from"../../../../../core/PooledArray.js";import{e as s,t as a}from"../../../../../chunks/mat3.js";import{c}from"../../../../../chunks/mat3f32.js";import{d as m,p as l,t as f}from"../../../../../chunks/vec3.js";import{a as p,c as h}from"../../../../../chunks/vec3f64.js";import{c as b}from"../../../../../chunks/vec4f32.js";import{a as u}from"../../../../../chunks/vec32.js";import{c as d}from"../../../../../chunks/vec33.js";import{ViewingMode as g}from"../../../../ViewingMode.js";import{computeOffsetObb as y}from"../../../layers/i3s/I3SUtil.js";import{ColorMixModeEnum as j,encodeSymbolColor as C}from"../../../layers/support/symbolColorUtils.js";import{clone as v,radius as _}from"../../../support/orientedBoundingBox.js";import{glLayout as w}from"../../../support/buffer/glUtil.js";import{newLayout as M}from"../../../support/buffer/InterleavedLayout.js";import O from"./ComponentData.js";import{State as x,ComponentObject as A}from"./ComponentObject.js";import D from"./IntersectionGeometry.js";import{Renderable as S}from"./Renderable.js";import{RenderGeometry as I}from"./RenderGeometry.js";import{RenderSubmitSystem as P}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as E}from"./SourceGeometry.js";import{ComponentParametersVarying as L,ComponentParametersUniform as R,ComponentParameterSummary as U,ComponentMaterial as k}from"./Material/ComponentMaterial.js";import{attributeLocations as T}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as B}from"./Material/shader/ComponentData.glsl.js";import{getVisibility as V,updateVisibilityWithCount as G}from"../../lib/ComponentUtils.js";import{assert as N}from"../../lib/Util.js";import{VertexAttribute as q}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as H}from"../../lib/verticalOffsetUtils.js";import{EdgeInputBufferLayout as z}from"../../lib/edgeRendering/bufferLayouts.js";import{extractComponentsEdgeLocationsLayout as W}from"../../lib/edgeRendering/edgeProcessing.js";import{BufferManager as X}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as Y}from"../../../../webgl/BufferObject.js";import{Usage as F,PrimitiveType as J}from"../../../../webgl/enums.js";import{VertexArrayObject as K}from"../../../../webgl/VertexArrayObject.js";const Q=e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class Z{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._objects=[new i,new i],this._renderSubmit=new P(this),this._renderManager.register(this._renderSubmit),this._hasObjectAndLayerId=has("enable-feature:objectAndLayerId-rendering"),this._componentBufferManager=new X(e.rctx,2+(this._hasObjectAndLayerId?1:0))}dispose(){N(0===this._objects[x.Hidden].length&&0===this._objects[x.Visible].length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy()}createObject(e){const t=new A;return t.toMapSpace=e.toMapSpace,t.transform=e.transform,t.obb=v(e.obb),t.components=new O(this._componentBufferManager,e.geometry.componentOffsets),t.renderable=this._createRenderable(e,t.components),t.intersectionGeometry=new D(e.geometry.positionData,t.components),this._objects[t.visible].push(t),t}destroyObject(e){const t=e;this._objects[t.visible].removeUnordered(t),t.dispose(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(this._objects[o.visible].removeUnordered(o),this._objects[t].push(o),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=m(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.components.visibility.reset(t),o.components.visibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.components.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.components.visibility.componentCount();return{visible:o,invisible:t.components.count-o}}setComponentData(e,r){const n=e,i=n.renderable.material,s=n.components,a=s.materialDataBuffer,c=s.materialDataIndices,m={castShadows:!0,pickable:!0,externalColor:b(),externalColorMixMode:j.Multiply,elevationOffset:0,objectAndLayerIdColor:this._hasObjectAndLayerId?b():null},l=a.textureBuffer,f=new Uint8Array(4),p=new Uint32Array(f.buffer);let h=0,u=0,d=0,g=s.verticalOffsets,_=1/0,w=-1/0,M=!1,O=!1,x=0;for(let b=0;b<s.count;b++){if(r(b,m),h+=+(m.externalColor[3]<1),u+=+(m.externalColorMixMode===j.Replace&&1===m.externalColor[3]),d+=+m.castShadows,C(m.externalColor,m.externalColorMixMode,f),f[2]=254&f[2]|+m.castShadows,l.setData(c[b],0,f[0],f[1],f[2],f[3]),M||(M=b>0&&x!==p[0]),x=p[0],O||(O=0!==m.elevationOffset),O&&t(g)&&(g=new Array(b).fill(0)),o(g)&&(g[b]=m.elevationOffset),_=Math.min(_,m.elevationOffset),w=Math.max(w,m.elevationOffset),B(m.elevationOffset,f),l.setData(c[b],1,f[0],f[1],f[2],f[3]),this._hasObjectAndLayerId){const e=m.objectAndLayerIdColor;l.setData(c[b],2,e[0],e[1],e[2],e[3])}m.pickable!==V(s.pickability,b)&&(s.pickability=G(s.pickability,s.count,b,m.pickable))}s.verticalOffsets=O?g:null,n.offsetObb=O?y(n.obb,_,w,this._viewingMode,o(n.offsetObb)?n.offsetObb:v(n.obb)):null,M||O||this._hasObjectAndLayerId?(i.componentParameters=new L,i.componentParameters.castShadows=ee(d,s.count),i.componentParameters.transparent=ee(h,s.count),i.componentParameters.opaqueOverride=ee(u,s.count),i.componentParameters.texture=l,l.updateTexture()):(i.componentParameters=new R,i.componentParameters.castShadows=m.castShadows?U.All:U.None,i.componentParameters.externalColor=m.externalColor,i.componentParameters.externalColorMixMode=m.externalColorMixMode),this._notifyDirty()}getComponentAabb(e,o,n,i=!1){e.intersectionGeometry.getComponentAabb(o,n);const s=e,a=s.components.verticalOffsets;if(i||t(a))return n;const c=a[o];if(this._viewingMode===g.Local||0===c)return n[2]+=c,n[5]+=c,n;const m=r(H(c));return m.localOrigin=s.transform.position,m.applyToAabb(n)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}intersect(e,t,r,n,i,c){const m=e;o(i)&&(i.localOrigin=m.transform.position);const p=s(te,m.transform.rotationScale);l(oe,t,m.transform.position),l(re,r,m.transform.position),f(oe,oe,p),f(re,re,p);const h=a(te,p);return m.intersectionGeometry.intersect(oe,re,n,h,i,m.components.verticalOffsets,c)}addEdges(e,t,o,r){const n=e,{indices:i,positions:s}=n.intersectionGeometry,a=n.components.offsets;return t.addComponentObject(e,n.transform,{center:n.obb.center,radius:_(n.obb)},s,i,a,o,r)}async extractEdgeInformation(e,t,o){const r=e,n=r.components.visibility;if(n.allInvisible())return{buffer:W.createBuffer(0),origin:[0,0,0]};const{indices:i,positions:s}=r.intersectionGeometry,a=r.components.offsets,c=z.createBuffer(s.count);d(c.position,s),u(c.position,c.position,r.transform.rotationScale),this._setComponentIndices(c.componentIndex,i,a);const m=c.count,l=this._computeVisibilityIndices(i,n,a,m);return{origin:p(r.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:l,indicesLength:l.length,skipDeduplicate:!0,data:c,writerSettings:{reducedPrecision:!1,variants:0}},o)}}_setComponentIndices(e,t,o){let r=0;for(let n=0;n<o.length-1;n++){const i=o[n],s=o[n+1];for(let o=i;o<s;o++){const n=t?t[o]:o;e.set(n,r)}r++}}_computeVisibilityIndices(e,t,o,r){if(e&&t.allVisible())return e;let n=0;t.forEachComponentRange(((e,t)=>(n+=o[t]-o[e],!0)));const i=Array.isArray(e)?new Array(n):2===e?.BYTES_PER_ELEMENT||r<=65536?new Uint16Array(n):new Uint32Array(n);let s=0;return t.forEachComponentRange(((t,r)=>{const n=o[t],a=o[r];for(let o=n;o<a;o++)i[s++]=e?e[o]:o;return!0})),i}addComponentHighlight(e,o){const r=e.components;t(r.highlightCounts)&&(r.highlightCounts=new Uint32Array(r.count+1));0===r.highlightCounts[o]++&&(r.highlightsDirty(),this._notifyDirty()),r.highlightCounts[r.count]++}removeComponentHighlight(e,o){const r=e.components;if(t(r.highlightCounts))return void Q.warn("Removing non-existing highlight.");const n=r.highlightCounts[o],i=r.highlightCounts[r.count];if(0!==n){if(n>1)return r.highlightCounts[o]=n-1,void(r.highlightCounts[r.count]=i-1);r.highlightCounts[o]=0,r.highlightsDirty(),this._notifyDirty(),1===i?r.highlightCounts=null:r.highlightCounts[r.count]=i-1}else Q.warn("Removing non-existing highlight.")}clearHighlights(e){const t=e.components;o(t.highlightCounts)&&(t.highlightCounts=null,t.highlightsDirty(),this._notifyDirty())}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._objects[x.Visible]}_createRenderable(e,t){const i=this._renderManager.rctx,s=e.geometry,a=s.vertices.layoutParameters,c=Y.createVertex(i,F.STATIC_DRAW,s.vertices.data),m=n(s.indices,(e=>Y.createIndex(i,F.STATIC_DRAW,e))),l=w(E(a)),f=new Uint16Array(s.vertices.count);for(let r=0;r<t.count;r++){const e=t.offsets[r],n=t.offsets[r+1],i=t.materialDataIndices[r];if(o(s.indices))for(let t=e;t<n;t++){f[s.indices[t]]=i}else for(let t=e;t<n;t++)f[t]=i}const p=Y.createVertex(i,F.STATIC_DRAW,f.buffer),h=new k(e.transform,e.toMapSpace),b=new K(i,T,{data:l,componentIndices:$},{data:c,componentIndices:p},r(m)),u=new I(b,J.TRIANGLES,a,o(m)),d={cameraDepthSquared:.5,gpuMemoryEstimate:c.byteSize+p.byteSize+(o(m)?m.byteSize:0)};return new S(h,u,d)}_notifyDirty(){this._renderManager.notifyDirty()}}const $=w(M().u16(q.COMPONENTINDEX));function ee(e,t){return e===t?U.All:0===e?U.None:U.Some}const te=c(),oe=h(),re=h();export{Z as ComponentObjectCollection};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{nullifyNonNullableForDispose as t,isSome as e}from"../../../../../core/maybe.js";import o from"../../../../../core/PooledArray.js";import{d as n,e as r}from"../../../../../chunks/mat3.js";import{c as a}from"../../../../../chunks/mat3f64.js";import{c as s}from"../../../../../chunks/quat.js";import{a as f}from"../../../../../chunks/quatf64.js";import{e as c,y as l,q as u,s as i,h,c as m,t as p,a as b}from"../../../../../chunks/vec3.js";import{c as j}from"../../../../../chunks/vec3f64.js";import{signedDistance as d}from"../../../../../geometry/support/plane.js";import{projectedRadius as g,intersectPlane as k}from"../../../support/orientedBoundingBox.js";import{empty as w,within as z,union as S}from"../../lib/depthRange.js";function y(t,o){const n=w(),{eye:r,frustum:a,viewForward:s}=t;o.forAll((t=>{const o=e(t.offsetObb)?t.offsetObb:t.obb,f=c(l(G,o.center,r),s),u=g(o,s);if(z(n,f-u)&&z(n,f+u))return;const i=C(o,a);if(-1===i)return;if(0===i)return v.far=f+u,v.near=f-u,void S(n,v);const h=q.pushNew();h.near=f-u,h.far=f+u,h.mask=i,h.object=t}));for(let f=0;f<q.length;f++){const t=q.data[f];if(z(n,t.near)&&z(n,t.far))continue;v.far=t.far,v.near=1/0;const o=N(e(t.object.offsetObb)?t.object.offsetObb:t.object.obb,r,x,(e=>{let o=B;for(let n=0;n<R&&e.length>0;n++){if(0==(t.mask&1<<n))continue;F(a[n],e,o);const r=e;e=o,o=r}for(let t=0;t<e.length;t+=3){i(O,e.data[t+0],e.data[t+1],e.data[t+2]);const o=c(l(O,O,r),s);v.near=Math.min(v.near,o)}}));0===o&&(v.near=0),S(n,v)}return q.length=0,n}const q=new o({allocator:t=>t||{near:1/0,far:-1/0,mask:0,object:null},deallocator:e=>(e.object=t(e.object),e)}),v=w(),O=j(),A=j(),x=new o({deallocator:null}),B=new o({deallocator:null});function F(t,e,o){o.length=0;const n=e.length-3;I(O,e,n);const r=d(t,O);r<=0&&(o.push(O[0]),o.push(O[1]),o.push(O[2]));let a=0,s=r;for(;a<n;a+=3){I(A,e,a);const n=d(t,A);if(s*n<0){h(O,A,O,n/(n-s)),M(o,O)}n<=0&&M(o,A),s=n,m(O,A)}if(s*r<0){I(A,e,n);h(O,A,O,r/(r-s)),M(o,O)}}function I(t,e,o){return i(t,e.data[o+0],e.data[o+1],e.data[o+2])}function M(t,e){t.push(e[0]),t.push(e[1]),t.push(e[2])}function N(t,e,o,a){s(E,t.quaternion),l(G,e,t.center),u(G,G,E);const f=8*((G[0]<-t.halfSize[0]?-1:G[0]>t.halfSize[0]?1:0)+3*(G[1]<-t.halfSize[1]?-1:G[1]>t.halfSize[1]?1:0)+9*(G[2]<-t.halfSize[2]?-1:G[2]>t.halfSize[2]?1:0)+13),c=P[f];if(0===c)return c;n(D,t.quaternion),r(D,D,t.halfSize);const h=(e,o)=>{const n=P[f+o+1];return i(e,((1&n)<<1)-1,(2&n)-1,((4&n)>>1)-1),p(e,e,D),b(e,t.center,e)};return o.length=0,M(o,h(H,0)),M(o,h(J,1)),M(o,h(G,2)),M(o,h(K,3)),a(o),1===c?c:(o.length=0,M(o,H),M(o,K),M(o,h(G,4)),M(o,h(L,5)),a(o),2===c||(o.length=0,M(o,H),M(o,L),M(o,h(G,6)),M(o,J),a(o)),c)}const P=(()=>{const t=new Int8Array(216);let e=0;const o=o=>{for(let n=0;n<o.length;n++)t[e+n]=o[n];e+=8};return o([3,0,6,2,3,1,5,4]),o([2,0,2,3,1,5,4,0]),o([3,1,0,2,3,7,5,4]),o([2,0,1,3,2,6,4,0]),o([1,0,1,3,2,0,0,0]),o([2,1,5,7,3,2,0,0]),o([3,2,0,1,3,7,6,4]),o([2,2,0,1,3,7,6,0]),o([3,3,0,1,5,7,6,2]),o([2,0,1,5,4,6,2,0]),o([1,0,1,5,4,0,0,0]),o([2,1,3,7,5,4,0,0]),o([1,0,2,6,4,0,0,0]),o([0,0,0,0,0,0,0,0]),o([1,1,3,7,5,0,0,0]),o([2,2,3,7,6,4,0,0]),o([1,2,3,7,6,0,0,0]),o([2,3,1,5,7,6,2,0]),o([3,4,0,1,5,7,6,2]),o([2,5,7,6,4,0,1,0]),o([3,5,0,1,3,7,6,4]),o([2,4,5,7,6,2,0,0]),o([1,4,5,7,6,0,0,0]),o([2,5,1,3,7,6,4,0]),o([3,6,0,2,3,7,5,4]),o([2,6,2,3,7,5,4,0]),o([3,7,6,2,3,1,5,4]),t})(),R=4;function C(t,e){let o=0;for(let n=0;n<R;n++){const r=k(t,e[n]);if(r>0)return-1;0===r&&(o|=1<<n)}return o}const D=a(),E=f(),G=j(),H=j(),J=j(),K=j(),L=j();export{y as computeDepthRange};
5
+ import{nullifyNonNullableForDispose as t,isSome as o}from"../../../../../core/maybe.js";import e from"../../../../../core/PooledArray.js";import{a as n,s as r}from"../../../../../chunks/mat3.js";import{c as a}from"../../../../../chunks/mat3f64.js";import{a as s}from"../../../../../chunks/quat.js";import{c as f}from"../../../../../chunks/quatf64.js";import{e as c,p as l,k as u,s as i,h,c as m,t as p,a as b}from"../../../../../chunks/vec3.js";import{c as j}from"../../../../../chunks/vec3f64.js";import{signedDistance as d}from"../../../../../geometry/support/plane.js";import{projectedRadius as g,intersectPlane as k}from"../../../support/orientedBoundingBox.js";import{empty as w,within as z,union as S}from"../../lib/depthRange.js";function y(t,e){const n=w(),{eye:r,frustum:a,viewForward:s}=t;e.forAll((t=>{const e=o(t.offsetObb)?t.offsetObb:t.obb,f=c(l(G,e.center,r),s),u=g(e,s);if(z(n,f-u)&&z(n,f+u))return;const i=C(e,a);if(-1===i)return;if(0===i)return v.far=f+u,v.near=f-u,void S(n,v);const h=q.pushNew();h.near=f-u,h.far=f+u,h.mask=i,h.object=t}));for(let f=0;f<q.length;f++){const t=q.data[f];if(z(n,t.near)&&z(n,t.far))continue;v.far=t.far,v.near=1/0;const e=N(o(t.object.offsetObb)?t.object.offsetObb:t.object.obb,r,x,(o=>{let e=B;for(let n=0;n<R&&o.length>0;n++){if(0==(t.mask&1<<n))continue;F(a[n],o,e);const r=o;o=e,e=r}for(let t=0;t<o.length;t+=3){i(O,o.data[t+0],o.data[t+1],o.data[t+2]);const e=c(l(O,O,r),s);v.near=Math.min(v.near,e)}}));0===e&&(v.near=0),S(n,v)}return q.length=0,n}const q=new e({allocator:t=>t||{near:1/0,far:-1/0,mask:0,object:null},deallocator:o=>(o.object=t(o.object),o)}),v=w(),O=j(),A=j(),x=new e({deallocator:null}),B=new e({deallocator:null});function F(t,o,e){e.length=0;const n=o.length-3;I(O,o,n);const r=d(t,O);r<=0&&(e.push(O[0]),e.push(O[1]),e.push(O[2]));let a=0,s=r;for(;a<n;a+=3){I(A,o,a);const n=d(t,A);if(s*n<0){h(O,A,O,n/(n-s)),M(e,O)}n<=0&&M(e,A),s=n,m(O,A)}if(s*r<0){I(A,o,n);h(O,A,O,r/(r-s)),M(e,O)}}function I(t,o,e){return i(t,o.data[e+0],o.data[e+1],o.data[e+2])}function M(t,o){t.push(o[0]),t.push(o[1]),t.push(o[2])}function N(t,o,e,a){s(E,t.quaternion),l(G,o,t.center),u(G,G,E);const f=8*((G[0]<-t.halfSize[0]?-1:G[0]>t.halfSize[0]?1:0)+3*(G[1]<-t.halfSize[1]?-1:G[1]>t.halfSize[1]?1:0)+9*(G[2]<-t.halfSize[2]?-1:G[2]>t.halfSize[2]?1:0)+13),c=P[f];if(0===c)return c;n(D,t.quaternion),r(D,D,t.halfSize);const h=(o,e)=>{const n=P[f+e+1];return i(o,((1&n)<<1)-1,(2&n)-1,((4&n)>>1)-1),p(o,o,D),b(o,t.center,o)};return e.length=0,M(e,h(H,0)),M(e,h(J,1)),M(e,h(G,2)),M(e,h(K,3)),a(e),1===c?c:(e.length=0,M(e,H),M(e,K),M(e,h(G,4)),M(e,h(L,5)),a(e),2===c||(e.length=0,M(e,H),M(e,L),M(e,h(G,6)),M(e,J),a(e)),c)}const P=(()=>{const t=new Int8Array(216);let o=0;const e=e=>{for(let n=0;n<e.length;n++)t[o+n]=e[n];o+=8};return e([3,0,6,2,3,1,5,4]),e([2,0,2,3,1,5,4,0]),e([3,1,0,2,3,7,5,4]),e([2,0,1,3,2,6,4,0]),e([1,0,1,3,2,0,0,0]),e([2,1,5,7,3,2,0,0]),e([3,2,0,1,3,7,6,4]),e([2,2,0,1,3,7,6,0]),e([3,3,0,1,5,7,6,2]),e([2,0,1,5,4,6,2,0]),e([1,0,1,5,4,0,0,0]),e([2,1,3,7,5,4,0,0]),e([1,0,2,6,4,0,0,0]),e([0,0,0,0,0,0,0,0]),e([1,1,3,7,5,0,0,0]),e([2,2,3,7,6,4,0,0]),e([1,2,3,7,6,0,0,0]),e([2,3,1,5,7,6,2,0]),e([3,4,0,1,5,7,6,2]),e([2,5,7,6,4,0,1,0]),e([3,5,0,1,3,7,6,4]),e([2,4,5,7,6,2,0,0]),e([1,4,5,7,6,0,0,0]),e([2,5,1,3,7,6,4,0]),e([3,6,0,2,3,7,5,4]),e([2,6,2,3,7,5,4,0]),e([3,7,6,2,3,1,5,4]),t})(),R=4;function C(t,o){let e=0;for(let n=0;n<R;n++){const r=k(t,o[n]);if(r>0)return-1;0===r&&(e|=1<<n)}return e}const D=a(),E=f(),G=j(),H=j(),J=j(),K=j(),L=j();export{y as computeDepthRange};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{releaseMaybe as t,isSome as r,isNone as s}from"../../../../../../core/maybe.js";import{c as o,t as a}from"../../../../../../chunks/mat3.js";import{a as i}from"../../../../../../chunks/mat3f32.js";import{G as n}from"../../../../../../chunks/vec3.js";import{f as l}from"../../../../../../chunks/vec3f32.js";import{v as h}from"../../../../../../chunks/vec4.js";import{f as u}from"../../../../../../chunks/vec4f32.js";import{ColorMixModeEnum as p}from"../../../../layers/support/symbolColorUtils.js";import c from"../../../../support/debugFlags.js";import{OverlayIndex as d,RenderTargetType as m}from"../../../../terrain/interfaces.js";import{ComponentTechnique as g}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as y,IntegratedMeshMode as T}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as x}from"./shader/ComponentData.glsl.js";import{g as b}from"../../../../../../chunks/ComponentShader.glsl.js";import{VertexDiscardMode as f}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as v,parameter as M,parameterBlock as C,MaterialParameterBlock as O}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as w,MaterialSubPass as P}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as S}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalAttributeType as A}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as N}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as j}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as q}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as D}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as R}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as I,CullFaceOptions as F}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as _}from"../../../lib/TransparencyPassType.js";class E extends v{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=l(1,1,.5),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new W,this.componentParameters=new B,this.textureAlphaCutoff=q,this.alphaDiscardMode=I.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=D.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new y;const r=new R(e.position),s=i(e.rotationScale);o(s,s),this.transformNormalGlobalFromModel=a(s,s),this.transformWorldFromModelTL=r.low,this.transformWorldFromModelTH=r.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return r(this.baseColorTexture)?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return r(this.metallicRoughnessTexture)?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return r(this.emissionTexture)?this.emissionTexture.glTexture:null}get textureOcclusion(){return r(this.occlusionTexture)?this.occlusionTexture.glTexture:null}get textureNormal(){return r(this.normalTexture)?this.normalTexture.glTexture:null}prepareTechnique(e,t,o,a){const i=this._techniqueConfiguration;i.hasVertexColors=a.colors,i.hasNormals=a.normals,i.textureCoordinateType=a.textureCoordinates,i.hasMetallicRoughnessTexture=r(this.metallicRoughnessTexture),i.hasEmissionTexture=r(this.emissionTexture),i.hasOcclusionTexture=r(this.occlusionTexture),i.hasNormalTexture=r(this.normalTexture),i.transparencyPassType=t.identifier===w.Material&&null!=o.transparencyPassType?o.transparencyPassType:_.NONE,i.hasMultipassTerrain=t.identifier===w.Material&&null!=o.multipassTerrain&&o.multipassTerrain.enabled,i.cullAboveGround=t.identifier===w.Material&&null!=o.multipassTerrain&&o.multipassTerrain.cullAboveGround,i.ellipsoidMode=this.ellipsoidMode,i.componentData=this.componentParameters.type,i.cullFace=this.commonMaterialParameters.cullFace,i.doubleSidedMode=this.commonMaterialParameters.doubleSided?N.View:N.None,i.hasBaseColorTexture=r(this.baseColorTexture);const n=this._computeWhichMaterialPass();i.blendingEnabled=n===k.Transparent||n===k.OpaqueAndTransparent,i.alphaDiscardMode=this.alphaDiscardMode,i.integratedMeshMode=this.isIntegratedMesh?U(o)?b(o)?T.ColorOverlayWithWater:T.ColorOverlay:T.NoOverlay:T.None,i.useLegacyTerrainShading=this.isIntegratedMesh&&c.TERRAIN_USE_LEGACY_SHADING,i.hasPolygonOffset=this.polygonOffsetEnabled;const l=this.hasParametersFromSource&&s(this.baseColorTexture);return i.pbrMode=i.integratedMeshMode===T.ColorOverlayWithWater?j.WaterOnIntegratedMesh:this.usePBR?l?j.Schematic:j.Normal:j.Disabled,i.normalType=i.integratedMeshMode===T.None?i.hasNormals?A.CompressedAttribute:A.ScreenDerivative:A.Ground,i.hasSlicePlane=r(o.slicePlane)&&this.commonMaterialParameters.hasSlicePlane,t.identifier===w.ShadowMap?(i.output=S.Shadow,i.vertexDiscardMode=f.None):t.identifier===w.Highlight?(i.output=S.Highlight,i.vertexDiscardMode=f.None):(this._computeWhichMaterialPass()===k.OpaqueAndTransparent?i.vertexDiscardMode=t.transparent?f.Opaque:f.Transparent:i.vertexDiscardMode=f.None,i.output=V(t.subPass),t.subPass===P.Alpha&&(i.hasOccludees=o.hasOccludees),t.subPass===P.Color?(i.receiveAmbientOcclusion=o.ssaoHelper.ready,i.hasOccludees=o.hasOccludees,i.receiveShadows=o.shadowMap.ready,i.hasScreenSpaceReflections=o.ssr.enabled,i.hasCloudsReflections=r(o.cloudsFade.data)):(i.receiveAmbientOcclusion=!1,i.receiveShadows=!1),i.snowCover=this.hasSnowCover(o),t.subPass===P.ObjectAndLayerIdColor&&(i.objectAndLayerIdColor=!0)),this._technique=e.releaseAndAcquire(g,i,this._technique),this._setClean(),this._technique}hasSnowCover(e){return r(e.weather)&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,s){if(0===this.objectOpacity)return;const o=s.renderable.geometry,a=s.components,i=s.renderable.meta.cameraDepthSquared,n=a.geometryRanges,l=a.highlightRanges,h=a.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case k.Opaque:e.materialOpaque.submitDraw(this,o,n,i);break;case k.Transparent:e.materialTransparent.submitDraw(this,o,n,i);break;case k.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,n,i),e.materialTransparent.submitDraw(this,o,n,i);break;case k.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,n,i),H(t)&&e.highlightIntegratedMesh.submitDraw(this,o,n,i)}const u=this.componentParameters.castShadows!==L.None;u&&e.shadowMap.submitDraw(this,o,n,i),r(l)&&(e.highlight.submitDraw(this,o,l,i),u&&e.highlightShadowMap.submitDraw(this,o,l,i)),u&&r(h)&&e.defaultShadowMap.submitDraw(this,o,h,i)}_computeWhichMaterialPass(){return this.isIntegratedMesh?k.IntegratedMesh:this.objectOpacity<1?k.Transparent:this.componentParameters.opaqueOverride===L.All?k.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===I.Blend||this.alphaDiscardMode===I.MaskBlend?k.Transparent:this.componentParameters.transparent===L.None?k.Opaque:this.componentParameters.transparent===L.All?k.Transparent:k.OpaqueAndTransparent}}var k,L;e([M({vectorOps:h})],E.prototype,"baseColor",void 0),e([M()],E.prototype,"usePBR",void 0),e([M()],E.prototype,"hasParametersFromSource",void 0),e([M({vectorOps:n})],E.prototype,"mrrFactors",void 0),e([M({vectorOps:n})],E.prototype,"emissiveFactor",void 0),e([M({dispose:!0})],E.prototype,"baseColorTexture",void 0),e([M({dispose:!0})],E.prototype,"metallicRoughnessTexture",void 0),e([M({dispose:!0})],E.prototype,"emissionTexture",void 0),e([M({dispose:!0})],E.prototype,"occlusionTexture",void 0),e([M({dispose:!0})],E.prototype,"normalTexture",void 0),e([M()],E.prototype,"objectOpacity",void 0),e([C()],E.prototype,"commonMaterialParameters",void 0),e([C()],E.prototype,"componentParameters",void 0),e([M()],E.prototype,"textureAlphaCutoff",void 0),e([M()],E.prototype,"alphaDiscardMode",void 0),e([M()],E.prototype,"isIntegratedMesh",void 0),e([M()],E.prototype,"polygonOffsetEnabled",void 0),e([M()],E.prototype,"ellipsoidMode",void 0),e([M()],E.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(k||(k={}));class W extends O{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=F.Back,this.hasSlicePlane=!0}}e([M()],W.prototype,"doubleSided",void 0),e([M()],W.prototype,"cullFace",void 0),e([M()],W.prototype,"hasSlicePlane",void 0);class B extends O{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=p.Multiply,this.castShadows=L.All}get transparent(){return this.externalColor[3]<1?L.All:L.None}get opaqueOverride(){return this.externalColorMixMode===p.Replace&&1===this.externalColor[3]?L.All:L.None}get visible(){return this.externalColor[3]>0?L.All:L.None}get type(){return x.Uniform}}e([M({vectorOps:h})],B.prototype,"externalColor",void 0),e([M()],B.prototype,"externalColorMixMode",void 0),e([M()],B.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(L||(L={}));class G extends O{constructor(){super(...arguments),this.texture=null,this.transparent=L.None,this.opaqueOverride=L.None,this.castShadows=L.None}get type(){return x.Varying}}function V(e){switch(e){case P.Color:return S.Color;case P.Alpha:return S.Alpha;case P.Depth:return S.Depth;case P.Normal:return S.Normal;case P.ObjectAndLayerIdColor:return S.ObjectAndLayerIdColor}}function H(e){return 0!==e.overlays.length&&r(e.overlays[d.INNER].getValidTexture(m.Highlight))}function U(e){return 0!==e.overlays.length&&r(e.overlays[d.INNER].getColorTextureNoRasterImage())}e([M()],G.prototype,"texture",void 0),e([M()],G.prototype,"transparent",void 0),e([M()],G.prototype,"opaqueOverride",void 0),e([M()],G.prototype,"castShadows",void 0);export{W as CommonMaterialParameters,E as ComponentMaterial,L as ComponentParameterSummary,B as ComponentParametersUniform,G as ComponentParametersVarying};
5
+ import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{releaseMaybe as t,isSome as r,isNone as s}from"../../../../../../core/maybe.js";import{e as o,t as a}from"../../../../../../chunks/mat3.js";import{a as i}from"../../../../../../chunks/mat3f32.js";import{G as n}from"../../../../../../chunks/vec3.js";import{f as l}from"../../../../../../chunks/vec3f32.js";import{v as h}from"../../../../../../chunks/vec4.js";import{f as u}from"../../../../../../chunks/vec4f32.js";import{ColorMixModeEnum as p}from"../../../../layers/support/symbolColorUtils.js";import c from"../../../../support/debugFlags.js";import{OverlayIndex as d,RenderTargetType as m}from"../../../../terrain/interfaces.js";import{ComponentTechnique as g}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as y,IntegratedMeshMode as T}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as x}from"./shader/ComponentData.glsl.js";import{g as b}from"../../../../../../chunks/ComponentShader.glsl.js";import{VertexDiscardMode as f}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as v,parameter as M,parameterBlock as C,MaterialParameterBlock as O}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as w,MaterialSubPass as P}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as S}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalAttributeType as A}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as N}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as j}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as q}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as D}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as R}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as I,CullFaceOptions as F}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as _}from"../../../lib/TransparencyPassType.js";class E extends v{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=l(1,1,.5),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new W,this.componentParameters=new B,this.textureAlphaCutoff=q,this.alphaDiscardMode=I.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=D.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new y;const r=new R(e.position),s=i(e.rotationScale);o(s,s),this.transformNormalGlobalFromModel=a(s,s),this.transformWorldFromModelTL=r.low,this.transformWorldFromModelTH=r.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return r(this.baseColorTexture)?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return r(this.metallicRoughnessTexture)?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return r(this.emissionTexture)?this.emissionTexture.glTexture:null}get textureOcclusion(){return r(this.occlusionTexture)?this.occlusionTexture.glTexture:null}get textureNormal(){return r(this.normalTexture)?this.normalTexture.glTexture:null}prepareTechnique(e,t,o,a){const i=this._techniqueConfiguration;i.hasVertexColors=a.colors,i.hasNormals=a.normals,i.textureCoordinateType=a.textureCoordinates,i.hasMetallicRoughnessTexture=r(this.metallicRoughnessTexture),i.hasEmissionTexture=r(this.emissionTexture),i.hasOcclusionTexture=r(this.occlusionTexture),i.hasNormalTexture=r(this.normalTexture),i.transparencyPassType=t.identifier===w.Material&&null!=o.transparencyPassType?o.transparencyPassType:_.NONE,i.hasMultipassTerrain=t.identifier===w.Material&&null!=o.multipassTerrain&&o.multipassTerrain.enabled,i.cullAboveGround=t.identifier===w.Material&&null!=o.multipassTerrain&&o.multipassTerrain.cullAboveGround,i.ellipsoidMode=this.ellipsoidMode,i.componentData=this.componentParameters.type,i.cullFace=this.commonMaterialParameters.cullFace,i.doubleSidedMode=this.commonMaterialParameters.doubleSided?N.View:N.None,i.hasBaseColorTexture=r(this.baseColorTexture);const n=this._computeWhichMaterialPass();i.blendingEnabled=n===k.Transparent||n===k.OpaqueAndTransparent,i.alphaDiscardMode=this.alphaDiscardMode,i.integratedMeshMode=this.isIntegratedMesh?U(o)?b(o)?T.ColorOverlayWithWater:T.ColorOverlay:T.NoOverlay:T.None,i.useLegacyTerrainShading=this.isIntegratedMesh&&c.TERRAIN_USE_LEGACY_SHADING,i.hasPolygonOffset=this.polygonOffsetEnabled;const l=this.hasParametersFromSource&&s(this.baseColorTexture);return i.pbrMode=i.integratedMeshMode===T.ColorOverlayWithWater?j.WaterOnIntegratedMesh:this.usePBR?l?j.Schematic:j.Normal:j.Disabled,i.normalType=i.integratedMeshMode===T.None?i.hasNormals?A.CompressedAttribute:A.ScreenDerivative:A.Ground,i.hasSlicePlane=r(o.slicePlane)&&this.commonMaterialParameters.hasSlicePlane,t.identifier===w.ShadowMap?(i.output=S.Shadow,i.vertexDiscardMode=f.None):t.identifier===w.Highlight?(i.output=S.Highlight,i.vertexDiscardMode=f.None):(this._computeWhichMaterialPass()===k.OpaqueAndTransparent?i.vertexDiscardMode=t.transparent?f.Opaque:f.Transparent:i.vertexDiscardMode=f.None,i.output=V(t.subPass),t.subPass===P.Alpha&&(i.hasOccludees=o.hasOccludees),t.subPass===P.Color?(i.receiveAmbientOcclusion=o.ssaoHelper.ready,i.hasOccludees=o.hasOccludees,i.receiveShadows=o.shadowMap.ready,i.hasScreenSpaceReflections=o.ssr.enabled,i.hasCloudsReflections=r(o.cloudsFade.data)):(i.receiveAmbientOcclusion=!1,i.receiveShadows=!1),i.snowCover=this.hasSnowCover(o),t.subPass===P.ObjectAndLayerIdColor&&(i.objectAndLayerIdColor=!0)),this._technique=e.releaseAndAcquire(g,i,this._technique),this._setClean(),this._technique}hasSnowCover(e){return r(e.weather)&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,s){if(0===this.objectOpacity)return;const o=s.renderable.geometry,a=s.components,i=s.renderable.meta.cameraDepthSquared,n=a.geometryRanges,l=a.highlightRanges,h=a.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case k.Opaque:e.materialOpaque.submitDraw(this,o,n,i);break;case k.Transparent:e.materialTransparent.submitDraw(this,o,n,i);break;case k.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,n,i),e.materialTransparent.submitDraw(this,o,n,i);break;case k.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,n,i),H(t)&&e.highlightIntegratedMesh.submitDraw(this,o,n,i)}const u=this.componentParameters.castShadows!==L.None;u&&e.shadowMap.submitDraw(this,o,n,i),r(l)&&(e.highlight.submitDraw(this,o,l,i),u&&e.highlightShadowMap.submitDraw(this,o,l,i)),u&&r(h)&&e.defaultShadowMap.submitDraw(this,o,h,i)}_computeWhichMaterialPass(){return this.isIntegratedMesh?k.IntegratedMesh:this.objectOpacity<1?k.Transparent:this.componentParameters.opaqueOverride===L.All?k.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===I.Blend||this.alphaDiscardMode===I.MaskBlend?k.Transparent:this.componentParameters.transparent===L.None?k.Opaque:this.componentParameters.transparent===L.All?k.Transparent:k.OpaqueAndTransparent}}var k,L;e([M({vectorOps:h})],E.prototype,"baseColor",void 0),e([M()],E.prototype,"usePBR",void 0),e([M()],E.prototype,"hasParametersFromSource",void 0),e([M({vectorOps:n})],E.prototype,"mrrFactors",void 0),e([M({vectorOps:n})],E.prototype,"emissiveFactor",void 0),e([M({dispose:!0})],E.prototype,"baseColorTexture",void 0),e([M({dispose:!0})],E.prototype,"metallicRoughnessTexture",void 0),e([M({dispose:!0})],E.prototype,"emissionTexture",void 0),e([M({dispose:!0})],E.prototype,"occlusionTexture",void 0),e([M({dispose:!0})],E.prototype,"normalTexture",void 0),e([M()],E.prototype,"objectOpacity",void 0),e([C()],E.prototype,"commonMaterialParameters",void 0),e([C()],E.prototype,"componentParameters",void 0),e([M()],E.prototype,"textureAlphaCutoff",void 0),e([M()],E.prototype,"alphaDiscardMode",void 0),e([M()],E.prototype,"isIntegratedMesh",void 0),e([M()],E.prototype,"polygonOffsetEnabled",void 0),e([M()],E.prototype,"ellipsoidMode",void 0),e([M()],E.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(k||(k={}));class W extends O{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=F.Back,this.hasSlicePlane=!0}}e([M()],W.prototype,"doubleSided",void 0),e([M()],W.prototype,"cullFace",void 0),e([M()],W.prototype,"hasSlicePlane",void 0);class B extends O{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=p.Multiply,this.castShadows=L.All}get transparent(){return this.externalColor[3]<1?L.All:L.None}get opaqueOverride(){return this.externalColorMixMode===p.Replace&&1===this.externalColor[3]?L.All:L.None}get visible(){return this.externalColor[3]>0?L.All:L.None}get type(){return x.Uniform}}e([M({vectorOps:h})],B.prototype,"externalColor",void 0),e([M()],B.prototype,"externalColorMixMode",void 0),e([M()],B.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(L||(L={}));class G extends O{constructor(){super(...arguments),this.texture=null,this.transparent=L.None,this.opaqueOverride=L.None,this.castShadows=L.None}get type(){return x.Varying}}function V(e){switch(e){case P.Color:return S.Color;case P.Alpha:return S.Alpha;case P.Depth:return S.Depth;case P.Normal:return S.Normal;case P.ObjectAndLayerIdColor:return S.ObjectAndLayerIdColor}}function H(e){return 0!==e.overlays.length&&r(e.overlays[d.INNER].getValidTexture(m.Highlight))}function U(e){return 0!==e.overlays.length&&r(e.overlays[d.INNER].getColorTextureNoRasterImage())}e([M()],G.prototype,"texture",void 0),e([M()],G.prototype,"transparent",void 0),e([M()],G.prototype,"opaqueOverride",void 0),e([M()],G.prototype,"castShadows",void 0);export{W as CommonMaterialParameters,E as ComponentMaterial,L as ComponentParameterSummary,B as ComponentParametersUniform,G as ComponentParametersVarying};