@arcgis/core 5.2.0-next.67 → 5.2.0-next.69

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 (443) hide show
  1. package/arcgisGlobal.d.ts +2 -0
  2. package/assets/components/assets/combobox/t9n/messages.ar.json +1 -1
  3. package/assets/components/assets/combobox/t9n/messages.bg.json +1 -1
  4. package/assets/components/assets/combobox/t9n/messages.bs.json +1 -1
  5. package/assets/components/assets/combobox/t9n/messages.ca.json +1 -1
  6. package/assets/components/assets/combobox/t9n/messages.cs.json +1 -1
  7. package/assets/components/assets/combobox/t9n/messages.da.json +1 -1
  8. package/assets/components/assets/combobox/t9n/messages.de.json +1 -1
  9. package/assets/components/assets/combobox/t9n/messages.el.json +1 -1
  10. package/assets/components/assets/combobox/t9n/messages.en.json +1 -1
  11. package/assets/components/assets/combobox/t9n/messages.es.json +1 -1
  12. package/assets/components/assets/combobox/t9n/messages.et.json +1 -1
  13. package/assets/components/assets/combobox/t9n/messages.fi.json +1 -1
  14. package/assets/components/assets/combobox/t9n/messages.fr.json +1 -1
  15. package/assets/components/assets/combobox/t9n/messages.he.json +1 -1
  16. package/assets/components/assets/combobox/t9n/messages.hr.json +1 -1
  17. package/assets/components/assets/combobox/t9n/messages.hu.json +1 -1
  18. package/assets/components/assets/combobox/t9n/messages.id.json +1 -1
  19. package/assets/components/assets/combobox/t9n/messages.it.json +1 -1
  20. package/assets/components/assets/combobox/t9n/messages.ja.json +1 -1
  21. package/assets/components/assets/combobox/t9n/messages.json +1 -1
  22. package/assets/components/assets/combobox/t9n/messages.ko.json +1 -1
  23. package/assets/components/assets/combobox/t9n/messages.lt.json +1 -1
  24. package/assets/components/assets/combobox/t9n/messages.lv.json +1 -1
  25. package/assets/components/assets/combobox/t9n/messages.nl.json +1 -1
  26. package/assets/components/assets/combobox/t9n/messages.no.json +1 -1
  27. package/assets/components/assets/combobox/t9n/messages.pl.json +1 -1
  28. package/assets/components/assets/combobox/t9n/messages.pt-BR.json +1 -1
  29. package/assets/components/assets/combobox/t9n/messages.pt-PT.json +1 -1
  30. package/assets/components/assets/combobox/t9n/messages.ro.json +1 -1
  31. package/assets/components/assets/combobox/t9n/messages.ru.json +1 -1
  32. package/assets/components/assets/combobox/t9n/messages.sk.json +1 -1
  33. package/assets/components/assets/combobox/t9n/messages.sl.json +1 -1
  34. package/assets/components/assets/combobox/t9n/messages.sr.json +1 -1
  35. package/assets/components/assets/combobox/t9n/messages.sv.json +1 -1
  36. package/assets/components/assets/combobox/t9n/messages.th.json +1 -1
  37. package/assets/components/assets/combobox/t9n/messages.tr.json +1 -1
  38. package/assets/components/assets/combobox/t9n/messages.uk.json +1 -1
  39. package/assets/components/assets/combobox/t9n/messages.vi.json +1 -1
  40. package/assets/components/assets/combobox/t9n/messages.zh-CN.json +1 -1
  41. package/assets/components/assets/combobox/t9n/messages.zh-HK.json +1 -1
  42. package/assets/components/assets/combobox/t9n/messages.zh-TW.json +1 -1
  43. package/assets/components/assets/icon/arcgisEnterprise16.json +1 -0
  44. package/assets/components/assets/icon/arcgisEnterprise24.json +1 -0
  45. package/assets/components/assets/icon/arcgisEnterprise32.json +1 -0
  46. package/assets/components/assets/icon/buildingIndex16.json +1 -0
  47. package/assets/components/assets/icon/buildingIndex24.json +1 -0
  48. package/assets/components/assets/icon/buildingIndex32.json +1 -0
  49. package/assets/components/assets/icon/fireIndex16.json +1 -0
  50. package/assets/components/assets/icon/fireIndex24.json +1 -0
  51. package/assets/components/assets/icon/fireIndex32.json +1 -0
  52. package/assets/components/assets/icon/geologyIndex16.json +1 -0
  53. package/assets/components/assets/icon/geologyIndex24.json +1 -0
  54. package/assets/components/assets/icon/geologyIndex32.json +1 -0
  55. package/assets/components/assets/icon/orientedImageryFullSuperimpose16.json +1 -0
  56. package/assets/components/assets/icon/orientedImageryFullSuperimpose24.json +1 -0
  57. package/assets/components/assets/icon/orientedImageryFullSuperimpose32.json +1 -0
  58. package/assets/components/assets/icon/orientedImageryHalfSuperimpose16.json +1 -0
  59. package/assets/components/assets/icon/orientedImageryHalfSuperimpose24.json +1 -0
  60. package/assets/components/assets/icon/orientedImageryHalfSuperimpose32.json +1 -0
  61. package/assets/components/assets/icon/orientedImagerySceneOnly16.json +1 -0
  62. package/assets/components/assets/icon/orientedImagerySceneOnly24.json +1 -0
  63. package/assets/components/assets/icon/orientedImagerySceneOnly32.json +1 -0
  64. package/assets/components/assets/icon/parquetFeatureLayer16.json +1 -0
  65. package/assets/components/assets/icon/parquetFeatureLayer24.json +1 -0
  66. package/assets/components/assets/icon/parquetFeatureLayer32.json +1 -0
  67. package/assets/components/assets/icon/publish32.json +1 -1
  68. package/assets/components/assets/icon/radarChart16.json +1 -0
  69. package/assets/components/assets/icon/radarChart24.json +1 -0
  70. package/assets/components/assets/icon/radarChart32.json +1 -0
  71. package/assets/components/assets/icon/returnToDefault16.json +1 -1
  72. package/assets/components/assets/icon/returnToDefault32.json +1 -1
  73. package/assets/components/assets/icon/smartSearch16.json +1 -0
  74. package/assets/components/assets/icon/smartSearch24.json +1 -0
  75. package/assets/components/assets/icon/smartSearch32.json +1 -0
  76. package/assets/components/assets/icon/snowIndex16.json +1 -0
  77. package/assets/components/assets/icon/snowIndex24.json +1 -0
  78. package/assets/components/assets/icon/snowIndex32.json +1 -0
  79. package/assets/components/assets/icon/soilAdjustedVegetationIndex16.json +1 -0
  80. package/assets/components/assets/icon/soilAdjustedVegetationIndex24.json +1 -0
  81. package/assets/components/assets/icon/soilAdjustedVegetationIndex32.json +1 -0
  82. package/assets/components/assets/icon/treeMap16.json +1 -0
  83. package/assets/components/assets/icon/treeMap24.json +1 -0
  84. package/assets/components/assets/icon/treeMap32.json +1 -0
  85. package/assets/components/assets/icon/userSave16.json +1 -0
  86. package/assets/components/assets/icon/userSave24.json +1 -0
  87. package/assets/components/assets/icon/userSave32.json +1 -0
  88. package/assets/components/assets/icon/vegetationIndex16.json +1 -0
  89. package/assets/components/assets/icon/vegetationIndex24.json +1 -0
  90. package/assets/components/assets/icon/vegetationIndex32.json +1 -0
  91. package/assets/components/assets/icon/weatherRadar16.json +1 -0
  92. package/assets/components/assets/icon/weatherRadar24.json +1 -0
  93. package/assets/components/assets/icon/weatherRadar32.json +1 -0
  94. package/assets/components/assets/input/t9n/messages.ar.json +1 -1
  95. package/assets/components/assets/input/t9n/messages.bg.json +1 -1
  96. package/assets/components/assets/input/t9n/messages.bs.json +1 -1
  97. package/assets/components/assets/input/t9n/messages.ca.json +1 -1
  98. package/assets/components/assets/input/t9n/messages.cs.json +1 -1
  99. package/assets/components/assets/input/t9n/messages.da.json +1 -1
  100. package/assets/components/assets/input/t9n/messages.de.json +1 -1
  101. package/assets/components/assets/input/t9n/messages.el.json +1 -1
  102. package/assets/components/assets/input/t9n/messages.en.json +1 -1
  103. package/assets/components/assets/input/t9n/messages.es.json +1 -1
  104. package/assets/components/assets/input/t9n/messages.et.json +1 -1
  105. package/assets/components/assets/input/t9n/messages.fi.json +1 -1
  106. package/assets/components/assets/input/t9n/messages.fr.json +1 -1
  107. package/assets/components/assets/input/t9n/messages.he.json +1 -1
  108. package/assets/components/assets/input/t9n/messages.hr.json +1 -1
  109. package/assets/components/assets/input/t9n/messages.hu.json +1 -1
  110. package/assets/components/assets/input/t9n/messages.id.json +1 -1
  111. package/assets/components/assets/input/t9n/messages.it.json +1 -1
  112. package/assets/components/assets/input/t9n/messages.ja.json +1 -1
  113. package/assets/components/assets/input/t9n/messages.json +1 -1
  114. package/assets/components/assets/input/t9n/messages.ko.json +1 -1
  115. package/assets/components/assets/input/t9n/messages.lt.json +1 -1
  116. package/assets/components/assets/input/t9n/messages.lv.json +1 -1
  117. package/assets/components/assets/input/t9n/messages.nl.json +1 -1
  118. package/assets/components/assets/input/t9n/messages.no.json +1 -1
  119. package/assets/components/assets/input/t9n/messages.pl.json +1 -1
  120. package/assets/components/assets/input/t9n/messages.pt-BR.json +1 -1
  121. package/assets/components/assets/input/t9n/messages.pt-PT.json +1 -1
  122. package/assets/components/assets/input/t9n/messages.ro.json +1 -1
  123. package/assets/components/assets/input/t9n/messages.ru.json +1 -1
  124. package/assets/components/assets/input/t9n/messages.sk.json +1 -1
  125. package/assets/components/assets/input/t9n/messages.sl.json +1 -1
  126. package/assets/components/assets/input/t9n/messages.sr.json +1 -1
  127. package/assets/components/assets/input/t9n/messages.sv.json +1 -1
  128. package/assets/components/assets/input/t9n/messages.th.json +1 -1
  129. package/assets/components/assets/input/t9n/messages.tr.json +1 -1
  130. package/assets/components/assets/input/t9n/messages.uk.json +1 -1
  131. package/assets/components/assets/input/t9n/messages.vi.json +1 -1
  132. package/assets/components/assets/input/t9n/messages.zh-CN.json +1 -1
  133. package/assets/components/assets/input/t9n/messages.zh-HK.json +1 -1
  134. package/assets/components/assets/input/t9n/messages.zh-TW.json +1 -1
  135. package/assets/components/assets/input-date-picker/t9n/messages.ar.json +1 -1
  136. package/assets/components/assets/input-date-picker/t9n/messages.bg.json +1 -1
  137. package/assets/components/assets/input-date-picker/t9n/messages.bs.json +1 -1
  138. package/assets/components/assets/input-date-picker/t9n/messages.ca.json +1 -1
  139. package/assets/components/assets/input-date-picker/t9n/messages.cs.json +1 -1
  140. package/assets/components/assets/input-date-picker/t9n/messages.da.json +1 -1
  141. package/assets/components/assets/input-date-picker/t9n/messages.de.json +1 -1
  142. package/assets/components/assets/input-date-picker/t9n/messages.el.json +1 -1
  143. package/assets/components/assets/input-date-picker/t9n/messages.en.json +1 -1
  144. package/assets/components/assets/input-date-picker/t9n/messages.es.json +1 -1
  145. package/assets/components/assets/input-date-picker/t9n/messages.et.json +1 -1
  146. package/assets/components/assets/input-date-picker/t9n/messages.fi.json +1 -1
  147. package/assets/components/assets/input-date-picker/t9n/messages.fr.json +1 -1
  148. package/assets/components/assets/input-date-picker/t9n/messages.he.json +1 -1
  149. package/assets/components/assets/input-date-picker/t9n/messages.hr.json +1 -1
  150. package/assets/components/assets/input-date-picker/t9n/messages.hu.json +1 -1
  151. package/assets/components/assets/input-date-picker/t9n/messages.id.json +1 -1
  152. package/assets/components/assets/input-date-picker/t9n/messages.it.json +1 -1
  153. package/assets/components/assets/input-date-picker/t9n/messages.ja.json +1 -1
  154. package/assets/components/assets/input-date-picker/t9n/messages.json +1 -1
  155. package/assets/components/assets/input-date-picker/t9n/messages.ko.json +1 -1
  156. package/assets/components/assets/input-date-picker/t9n/messages.lt.json +1 -1
  157. package/assets/components/assets/input-date-picker/t9n/messages.lv.json +1 -1
  158. package/assets/components/assets/input-date-picker/t9n/messages.nl.json +1 -1
  159. package/assets/components/assets/input-date-picker/t9n/messages.no.json +1 -1
  160. package/assets/components/assets/input-date-picker/t9n/messages.pl.json +1 -1
  161. package/assets/components/assets/input-date-picker/t9n/messages.pt-BR.json +1 -1
  162. package/assets/components/assets/input-date-picker/t9n/messages.pt-PT.json +1 -1
  163. package/assets/components/assets/input-date-picker/t9n/messages.ro.json +1 -1
  164. package/assets/components/assets/input-date-picker/t9n/messages.ru.json +1 -1
  165. package/assets/components/assets/input-date-picker/t9n/messages.sk.json +1 -1
  166. package/assets/components/assets/input-date-picker/t9n/messages.sl.json +1 -1
  167. package/assets/components/assets/input-date-picker/t9n/messages.sr.json +1 -1
  168. package/assets/components/assets/input-date-picker/t9n/messages.sv.json +1 -1
  169. package/assets/components/assets/input-date-picker/t9n/messages.th.json +1 -1
  170. package/assets/components/assets/input-date-picker/t9n/messages.tr.json +1 -1
  171. package/assets/components/assets/input-date-picker/t9n/messages.uk.json +1 -1
  172. package/assets/components/assets/input-date-picker/t9n/messages.vi.json +1 -1
  173. package/assets/components/assets/input-date-picker/t9n/messages.zh-CN.json +1 -1
  174. package/assets/components/assets/input-date-picker/t9n/messages.zh-HK.json +1 -1
  175. package/assets/components/assets/input-date-picker/t9n/messages.zh-TW.json +1 -1
  176. package/assets/components/assets/input-number/t9n/messages.ar.json +1 -1
  177. package/assets/components/assets/input-number/t9n/messages.bg.json +1 -1
  178. package/assets/components/assets/input-number/t9n/messages.bs.json +1 -1
  179. package/assets/components/assets/input-number/t9n/messages.ca.json +1 -1
  180. package/assets/components/assets/input-number/t9n/messages.cs.json +1 -1
  181. package/assets/components/assets/input-number/t9n/messages.da.json +1 -1
  182. package/assets/components/assets/input-number/t9n/messages.de.json +1 -1
  183. package/assets/components/assets/input-number/t9n/messages.el.json +1 -1
  184. package/assets/components/assets/input-number/t9n/messages.en.json +1 -1
  185. package/assets/components/assets/input-number/t9n/messages.es.json +1 -1
  186. package/assets/components/assets/input-number/t9n/messages.et.json +1 -1
  187. package/assets/components/assets/input-number/t9n/messages.fi.json +1 -1
  188. package/assets/components/assets/input-number/t9n/messages.fr.json +1 -1
  189. package/assets/components/assets/input-number/t9n/messages.he.json +1 -1
  190. package/assets/components/assets/input-number/t9n/messages.hr.json +1 -1
  191. package/assets/components/assets/input-number/t9n/messages.hu.json +1 -1
  192. package/assets/components/assets/input-number/t9n/messages.id.json +1 -1
  193. package/assets/components/assets/input-number/t9n/messages.it.json +1 -1
  194. package/assets/components/assets/input-number/t9n/messages.ja.json +1 -1
  195. package/assets/components/assets/input-number/t9n/messages.json +1 -1
  196. package/assets/components/assets/input-number/t9n/messages.ko.json +1 -1
  197. package/assets/components/assets/input-number/t9n/messages.lt.json +1 -1
  198. package/assets/components/assets/input-number/t9n/messages.lv.json +1 -1
  199. package/assets/components/assets/input-number/t9n/messages.nl.json +1 -1
  200. package/assets/components/assets/input-number/t9n/messages.no.json +1 -1
  201. package/assets/components/assets/input-number/t9n/messages.pl.json +1 -1
  202. package/assets/components/assets/input-number/t9n/messages.pt-BR.json +1 -1
  203. package/assets/components/assets/input-number/t9n/messages.pt-PT.json +1 -1
  204. package/assets/components/assets/input-number/t9n/messages.ro.json +1 -1
  205. package/assets/components/assets/input-number/t9n/messages.ru.json +1 -1
  206. package/assets/components/assets/input-number/t9n/messages.sk.json +1 -1
  207. package/assets/components/assets/input-number/t9n/messages.sl.json +1 -1
  208. package/assets/components/assets/input-number/t9n/messages.sr.json +1 -1
  209. package/assets/components/assets/input-number/t9n/messages.sv.json +1 -1
  210. package/assets/components/assets/input-number/t9n/messages.th.json +1 -1
  211. package/assets/components/assets/input-number/t9n/messages.tr.json +1 -1
  212. package/assets/components/assets/input-number/t9n/messages.uk.json +1 -1
  213. package/assets/components/assets/input-number/t9n/messages.vi.json +1 -1
  214. package/assets/components/assets/input-number/t9n/messages.zh-CN.json +1 -1
  215. package/assets/components/assets/input-number/t9n/messages.zh-HK.json +1 -1
  216. package/assets/components/assets/input-number/t9n/messages.zh-TW.json +1 -1
  217. package/assets/components/assets/input-text/t9n/messages.ar.json +1 -1
  218. package/assets/components/assets/input-text/t9n/messages.bg.json +1 -1
  219. package/assets/components/assets/input-text/t9n/messages.bs.json +1 -1
  220. package/assets/components/assets/input-text/t9n/messages.ca.json +1 -1
  221. package/assets/components/assets/input-text/t9n/messages.cs.json +1 -1
  222. package/assets/components/assets/input-text/t9n/messages.da.json +1 -1
  223. package/assets/components/assets/input-text/t9n/messages.de.json +1 -1
  224. package/assets/components/assets/input-text/t9n/messages.el.json +1 -1
  225. package/assets/components/assets/input-text/t9n/messages.en.json +1 -1
  226. package/assets/components/assets/input-text/t9n/messages.es.json +1 -1
  227. package/assets/components/assets/input-text/t9n/messages.et.json +1 -1
  228. package/assets/components/assets/input-text/t9n/messages.fi.json +1 -1
  229. package/assets/components/assets/input-text/t9n/messages.fr.json +1 -1
  230. package/assets/components/assets/input-text/t9n/messages.he.json +1 -1
  231. package/assets/components/assets/input-text/t9n/messages.hr.json +1 -1
  232. package/assets/components/assets/input-text/t9n/messages.hu.json +1 -1
  233. package/assets/components/assets/input-text/t9n/messages.id.json +1 -1
  234. package/assets/components/assets/input-text/t9n/messages.it.json +1 -1
  235. package/assets/components/assets/input-text/t9n/messages.ja.json +1 -1
  236. package/assets/components/assets/input-text/t9n/messages.json +1 -1
  237. package/assets/components/assets/input-text/t9n/messages.ko.json +1 -1
  238. package/assets/components/assets/input-text/t9n/messages.lt.json +1 -1
  239. package/assets/components/assets/input-text/t9n/messages.lv.json +1 -1
  240. package/assets/components/assets/input-text/t9n/messages.nl.json +1 -1
  241. package/assets/components/assets/input-text/t9n/messages.no.json +1 -1
  242. package/assets/components/assets/input-text/t9n/messages.pl.json +1 -1
  243. package/assets/components/assets/input-text/t9n/messages.pt-BR.json +1 -1
  244. package/assets/components/assets/input-text/t9n/messages.pt-PT.json +1 -1
  245. package/assets/components/assets/input-text/t9n/messages.ro.json +1 -1
  246. package/assets/components/assets/input-text/t9n/messages.ru.json +1 -1
  247. package/assets/components/assets/input-text/t9n/messages.sk.json +1 -1
  248. package/assets/components/assets/input-text/t9n/messages.sl.json +1 -1
  249. package/assets/components/assets/input-text/t9n/messages.sr.json +1 -1
  250. package/assets/components/assets/input-text/t9n/messages.sv.json +1 -1
  251. package/assets/components/assets/input-text/t9n/messages.th.json +1 -1
  252. package/assets/components/assets/input-text/t9n/messages.tr.json +1 -1
  253. package/assets/components/assets/input-text/t9n/messages.uk.json +1 -1
  254. package/assets/components/assets/input-text/t9n/messages.vi.json +1 -1
  255. package/assets/components/assets/input-text/t9n/messages.zh-CN.json +1 -1
  256. package/assets/components/assets/input-text/t9n/messages.zh-HK.json +1 -1
  257. package/assets/components/assets/input-text/t9n/messages.zh-TW.json +1 -1
  258. package/assets/components/assets/input-time-picker/t9n/messages.ar.json +1 -1
  259. package/assets/components/assets/input-time-picker/t9n/messages.bg.json +1 -1
  260. package/assets/components/assets/input-time-picker/t9n/messages.bs.json +1 -1
  261. package/assets/components/assets/input-time-picker/t9n/messages.ca.json +1 -1
  262. package/assets/components/assets/input-time-picker/t9n/messages.cs.json +1 -1
  263. package/assets/components/assets/input-time-picker/t9n/messages.da.json +1 -1
  264. package/assets/components/assets/input-time-picker/t9n/messages.de.json +1 -1
  265. package/assets/components/assets/input-time-picker/t9n/messages.el.json +1 -1
  266. package/assets/components/assets/input-time-picker/t9n/messages.en.json +1 -1
  267. package/assets/components/assets/input-time-picker/t9n/messages.es.json +1 -1
  268. package/assets/components/assets/input-time-picker/t9n/messages.et.json +1 -1
  269. package/assets/components/assets/input-time-picker/t9n/messages.fi.json +1 -1
  270. package/assets/components/assets/input-time-picker/t9n/messages.fr.json +1 -1
  271. package/assets/components/assets/input-time-picker/t9n/messages.he.json +1 -1
  272. package/assets/components/assets/input-time-picker/t9n/messages.hr.json +1 -1
  273. package/assets/components/assets/input-time-picker/t9n/messages.hu.json +1 -1
  274. package/assets/components/assets/input-time-picker/t9n/messages.id.json +1 -1
  275. package/assets/components/assets/input-time-picker/t9n/messages.it.json +1 -1
  276. package/assets/components/assets/input-time-picker/t9n/messages.ja.json +1 -1
  277. package/assets/components/assets/input-time-picker/t9n/messages.json +1 -1
  278. package/assets/components/assets/input-time-picker/t9n/messages.ko.json +1 -1
  279. package/assets/components/assets/input-time-picker/t9n/messages.lt.json +1 -1
  280. package/assets/components/assets/input-time-picker/t9n/messages.lv.json +1 -1
  281. package/assets/components/assets/input-time-picker/t9n/messages.nl.json +1 -1
  282. package/assets/components/assets/input-time-picker/t9n/messages.no.json +1 -1
  283. package/assets/components/assets/input-time-picker/t9n/messages.pl.json +1 -1
  284. package/assets/components/assets/input-time-picker/t9n/messages.pt-BR.json +1 -1
  285. package/assets/components/assets/input-time-picker/t9n/messages.pt-PT.json +1 -1
  286. package/assets/components/assets/input-time-picker/t9n/messages.ro.json +1 -1
  287. package/assets/components/assets/input-time-picker/t9n/messages.ru.json +1 -1
  288. package/assets/components/assets/input-time-picker/t9n/messages.sk.json +1 -1
  289. package/assets/components/assets/input-time-picker/t9n/messages.sl.json +1 -1
  290. package/assets/components/assets/input-time-picker/t9n/messages.sr.json +1 -1
  291. package/assets/components/assets/input-time-picker/t9n/messages.sv.json +1 -1
  292. package/assets/components/assets/input-time-picker/t9n/messages.th.json +1 -1
  293. package/assets/components/assets/input-time-picker/t9n/messages.tr.json +1 -1
  294. package/assets/components/assets/input-time-picker/t9n/messages.uk.json +1 -1
  295. package/assets/components/assets/input-time-picker/t9n/messages.vi.json +1 -1
  296. package/assets/components/assets/input-time-picker/t9n/messages.zh-CN.json +1 -1
  297. package/assets/components/assets/input-time-picker/t9n/messages.zh-HK.json +1 -1
  298. package/assets/components/assets/input-time-picker/t9n/messages.zh-TW.json +1 -1
  299. package/assets/esri/core/workers/RemoteClient.js +1 -1
  300. package/assets/esri/core/workers/chunks/{6f39545710d1b35d922c.js → 181f330314c1989f642f.js} +1 -1
  301. package/assets/esri/core/workers/chunks/{d4058352db1e8255b52e.js → 1d38a710cf799cb0e5b3.js} +1 -1
  302. package/assets/esri/core/workers/chunks/{59dd83e5aee2908c7eca.js → 3f84ade6285560b692d1.js} +1 -1
  303. package/assets/esri/core/workers/chunks/{25197ecb324d6f08e03e.js → 538bdf02c4dfb5ec72fe.js} +1 -1
  304. package/assets/esri/core/workers/chunks/{f5c9659fc5d571d501c9.js → 59a795eba31061dc357a.js} +1 -1
  305. package/assets/esri/core/workers/chunks/{7d163d9d90393e491ee5.js → 5fb0e8f89b885e5e3742.js} +1 -1
  306. package/assets/esri/core/workers/chunks/{19bf6826e7d9a4d52035.js → 6cc1120554bcb1b4899b.js} +1 -1
  307. package/assets/esri/core/workers/chunks/7dd672c25beb8813cc75.js +2 -0
  308. package/assets/esri/core/workers/chunks/{d7267f429a051943187b.js → 873d8332e2149eb1b36a.js} +1 -1
  309. package/assets/esri/core/workers/chunks/{a97e0b9b057664911c14.js → 8f8db62f126e4a8c1bf7.js} +1 -1
  310. package/assets/esri/core/workers/chunks/b526055794e64b0227ca.js +256 -0
  311. package/assets/esri/core/workers/chunks/be291d920ebc68fde02b.js +2 -0
  312. package/assets/esri/core/workers/chunks/c10a0eebd935472d8fae.js +1 -0
  313. package/assets/esri/core/workers/chunks/c97451f75c23be979476.js +1 -0
  314. package/assets/esri/core/workers/chunks/d198ecb1fe3690d6092f.js +2 -0
  315. package/assets/esri/core/workers/chunks/d2a51c797b2966cb95f3.js +2 -0
  316. package/assets/esri/core/workers/chunks/d303621c902330be5035.js +1 -0
  317. package/assets/esri/core/workers/chunks/{7d4c65311064a5c2e0b1.js → df89bf05c18f0c8e418b.js} +1 -1
  318. package/assets/esri/core/workers/chunks/f4e813ead56d963b16b8.js +1 -0
  319. package/assets/esri/core/workers/chunks/f6f1122bed931f1d960b.js +1 -0
  320. package/assets/esri/core/workers/chunks/f82cd34a79c8aa58d40c.js +2 -0
  321. package/assets/esri/themes/base/widgets/_SelectionToolbar.scss +1 -0
  322. package/assets/esri/themes/dark/main.css +1 -1
  323. package/assets/esri/themes/light/main.css +1 -1
  324. package/assets/esri/themes/light/view.css +1 -1
  325. package/assets/esri/views/3d/environment/resources/milkyway-band.ktx2 +0 -0
  326. package/chunks/DeepSky.glsl.js +66 -0
  327. package/chunks/GaussianSplat.glsl.js +10 -9
  328. package/chunks/GaussianSplatDepth.glsl.js +11 -0
  329. package/chunks/GaussianSplatShadow.glsl.js +7 -16
  330. package/config.js +1 -1
  331. package/interfaces.d.ts +0 -14
  332. package/kernel.js +1 -1
  333. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  334. package/networks/RulesTable.js +1 -1
  335. package/networks/UtilityNetwork.js +1 -1
  336. package/networks/support/utils.js +1 -1
  337. package/package.json +4 -4
  338. package/popup/FeatureContent.d.ts +17 -96
  339. package/popup/FeatureContentCollection.d.ts +71 -188
  340. package/support/revision.js +1 -1
  341. package/symbols/LabelSymbol3D.js +1 -1
  342. package/symbols/LineSymbol3D.js +1 -1
  343. package/symbols/MeshSymbol3D.js +1 -1
  344. package/symbols/PointSymbol3D.js +1 -1
  345. package/symbols/PolygonSymbol3D.js +1 -1
  346. package/third-party-notices.txt +9 -0
  347. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  348. package/views/2d/engine/webgl/AFeatureTile.js +1 -1
  349. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  350. package/views/2d/layers/support/MediaLayerInteraction.js +1 -1
  351. package/views/2d/layers/support/MediaLayerInteractionOptions.d.ts +46 -0
  352. package/views/2d/layers/support/MediaLayerInteractionOptions.js +1 -1
  353. package/views/2d/layers/support/MediaLayerInteractionReshapeOptions.d.ts +22 -0
  354. package/views/2d/layers/support/MediaLayerInteractionReshapeOptions.js +2 -0
  355. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  356. package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
  357. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  358. package/views/3d/analysis/Viewshed/ViewshedSnappingController.js +1 -1
  359. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  360. package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
  361. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  362. package/views/3d/layers/I3SMeshView3D.js +1 -1
  363. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  364. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  365. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  366. package/views/3d/layers/i3s/SweptSphereVolume.js +2 -0
  367. package/views/3d/layers/support/MediaLayerInteractionReshapeOptions.d.ts +0 -1
  368. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  369. package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
  370. package/views/3d/support/hitTest.js +1 -1
  371. package/views/3d/terrain/TerrainSurface.js +1 -1
  372. package/views/3d/webgl/RenderCamera.js +1 -1
  373. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  374. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
  375. package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +1 -1
  376. package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
  377. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  378. package/views/3d/webgl-engine/effects/stars/DeepSky.glsl.js +2 -0
  379. package/views/3d/webgl-engine/effects/stars/DeepSkyTechnique.js +2 -0
  380. package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
  381. package/views/3d/webgl-engine/effects/stars/starsUtils.js +2 -0
  382. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  383. package/views/3d/webgl-engine/lib/GaussianSplatDepthRenderer.js +2 -0
  384. package/views/3d/webgl-engine/lib/GaussianSplatRenderer.js +1 -1
  385. package/views/3d/webgl-engine/lib/GaussianSplatShadows.js +1 -1
  386. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  387. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  388. package/views/3d/webgl-engine/lib/screenPolygonOverlapUtils.js +1 -1
  389. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  390. package/views/3d/webgl-engine/shaders/GaussianSplatDepth.glsl.js +2 -0
  391. package/views/3d/webgl-engine/shaders/GaussianSplatDepthPolicy.js +2 -0
  392. package/views/3d/webgl-engine/shaders/GaussianSplatDepthTechnique.js +2 -0
  393. package/views/3d/webgl-engine/shaders/GaussianSplatPass.glsl.js +97 -0
  394. package/views/3d/webgl-engine/shaders/GaussianSplatShadow.glsl.js +1 -1
  395. package/views/3d/webgl-engine/shaders/GaussianSplatShadowTechnique.js +1 -1
  396. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  397. package/views/3d/webgl.js +1 -1
  398. package/widgets/BasemapLayerList.js +1 -1
  399. package/widgets/Bookmarks.js +1 -1
  400. package/widgets/Daylight.js +1 -1
  401. package/widgets/Editor/AddAssociationWorkflow.js +1 -1
  402. package/widgets/Editor/AddAssociationWorkflowData.js +1 -1
  403. package/widgets/Editor/legacy/AddAssociationWorkflow.js +1 -1
  404. package/widgets/Editor/legacy/AddAssociationWorkflowData.js +1 -1
  405. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/AssociationDetails.js +1 -1
  406. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  407. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  408. package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
  409. package/widgets/LayerList.js +1 -1
  410. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  411. package/widgets/OrientedImageryViewer/support/panConstraint.js +1 -1
  412. package/widgets/PanoramicVideoViewer.js +1 -1
  413. package/widgets/PanoramicViewer.js +1 -1
  414. package/widgets/Print.js +1 -1
  415. package/widgets/Search/support/locatorUtils.js +1 -1
  416. package/widgets/ShadowCast.js +1 -1
  417. package/widgets/Sketch.js +1 -1
  418. package/widgets/TableList.js +1 -1
  419. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
  420. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeaturesDrillIn.js +1 -1
  421. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  422. package/widgets/support/SelectionToolbar.js +1 -1
  423. package/widgets/support/SketchTooltipControls.js +1 -1
  424. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  425. package/widgets/support/UtilityNetworkAssociations/utils/createAssociation.js +1 -1
  426. package/widgets/support/UtilityNetworkAssociations/utils/isFromElement.js +1 -1
  427. package/assets/esri/core/workers/chunks/15de305ac3d6433748e7.js +0 -1
  428. package/assets/esri/core/workers/chunks/2426601b8cae7f06af4d.js +0 -256
  429. package/assets/esri/core/workers/chunks/242cad472fbc38b24dbc.js +0 -2
  430. package/assets/esri/core/workers/chunks/24c0b3586bb6500eda53.js +0 -2
  431. package/assets/esri/core/workers/chunks/394716bd1ecfd638d708.js +0 -2
  432. package/assets/esri/core/workers/chunks/55af58b6dff52dc040fe.js +0 -2
  433. package/assets/esri/core/workers/chunks/5b18696109fe84a1010a.js +0 -2
  434. package/assets/esri/core/workers/chunks/7f6eee102871769fdf8f.js +0 -1
  435. package/assets/esri/core/workers/chunks/93c0a620a147cbf4a0ba.js +0 -1
  436. package/assets/esri/core/workers/chunks/a27172dacdb85a774c4b.js +0 -1
  437. package/assets/esri/core/workers/chunks/ddafe402f1bc9e8285ef.js +0 -1
  438. package/views/3d/layers/i3s/SphereCone.js +0 -2
  439. /package/assets/esri/core/workers/chunks/{394716bd1ecfd638d708.js.LICENSE.txt → 7dd672c25beb8813cc75.js.LICENSE.txt} +0 -0
  440. /package/assets/esri/core/workers/chunks/{55af58b6dff52dc040fe.js.LICENSE.txt → be291d920ebc68fde02b.js.LICENSE.txt} +0 -0
  441. /package/assets/esri/core/workers/chunks/{24c0b3586bb6500eda53.js.LICENSE.txt → d198ecb1fe3690d6092f.js.LICENSE.txt} +0 -0
  442. /package/assets/esri/core/workers/chunks/{5b18696109fe84a1010a.js.LICENSE.txt → d2a51c797b2966cb95f3.js.LICENSE.txt} +0 -0
  443. /package/assets/esri/core/workers/chunks/{242cad472fbc38b24dbc.js.LICENSE.txt → f82cd34a79c8aa58d40c.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s,isSome as r}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import o from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../core/maybe.js";import l from"../../../core/PooledArray.js";import{ignoreAbortErrors as d,isAbortError as h,throwIfAborted as c}from"../../../core/promiseUtils.js";import{initial as u,watch as g}from"../../../core/reactiveUtils.js";import{schedule as _}from"../../../core/scheduling.js";import{equals as m}from"../../../core/SetUtils.js";import{isArrayBuffer as f}from"../../../core/typedArrayUtil.js";import{property as p,subclass as y}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as b,exactEquals as v,invert as I}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as C,IDENTITY as M}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as w,getTranslation as x}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as R,create as E}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as O}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as S,transformMat4 as j,transformMat3 as V,sub as F,add as A,scale as D,subtract as T}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as N}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as P}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as k}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as G}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as U}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as L}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as B}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as q}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{create as $,fromBuffer as W,toRect as K}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as J}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y,ensurePackedMat4f64 as X}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{Sphere as te}from"../../../geometry/support/sphere.js";import{newUByteArray as ie}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as se}from"../../../layers/LayerConstants.js";import re from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as oe}from"../../../layers/support/fieldUtils.js";import ne from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as le}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as de}from"../../../support/basemapUtils.js";import{getElevationOffset as he}from"../../../support/elevationInfoUtils.js";import{loadArcade as ce}from"../../../support/loadArcade.js";import ue from"../../../symbols/MeshSymbol3D.js";import ge from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as _e}from"./ContentGeometryLayerView.js";import me from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as fe}from"./I3SMeshViewPerformanceInfo.js";import{initialize as pe,setModificationsSync as ye,filterObbsForModificationsSync as be,interpretObbModificationResults as ve}from"./SceneLayerWorker.js";import{SceneLayerWorkerHandle as Ie,toWasmModification as Ce}from"./SceneLayerWorkerHandle.js";import{overrideColor as Me}from"./graphics/graphicUtils.js";import{areLabelsVisible as we}from"./graphics/Labeler.js";import xe from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Re}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Ee}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Oe,NodeCrossfadeMetaData as Se}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as je}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ve,TraversedIntersectionNode as Fe}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ae,selectEncoding as De,defaultMaterial as Te,createTexture as He,configureMaterial as Ne}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as Pe}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as ke}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Ge,checkSceneLayerValid as Ue,checkSceneLayerCompatibleWithView as Le,whenGraphicAttributes as Be,computeVisibilityObb as qe,filterInPlace as ze,intersectBoundingRectWithMbs as $e,addWraparound as We,getSymbolInfo as Ke,transparentEdgeMaterial as Qe,getClipRect as Je}from"./i3s/I3SUtil.js";import{IDBCache as Ye}from"./i3s/IDBCache.js";import{IDBMockCache as Xe}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as Ze}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as et}from"./i3s/SymbologyInfo.js";import{attributeLookup as tt}from"./support/attributeUtils.js";import{normalizeHighlightTarget as it,emptyHighlightHandle as st}from"./support/highlightUtils.js";import{makeScheduleFunction as rt}from"./support/makeScheduleFunction.js";import{debugFlags as ot}from"../support/debugFlags.js";import{ElevationRange as nt}from"../support/ElevationRange.js";import{toBoundingRect as at}from"../support/extentUtils.js";import{Obb as lt,ensurePackedObbData as dt}from"../support/orientedBoundingBox.js";import{updatingProgress as ht}from"../support/updatingProperties.js";import{glLayout as ct}from"../support/buffer/glUtil.js";import{ObjectParameters as ut}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as gt,ComponentGeometryParameters as _t,SourceGeometry as mt,VertexBufferLayoutCreationParameters as ft}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as pt}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as yt}from"../webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js";import{loadBasisTranscoder as bt}from"../webgl-engine/lib/BasisUtil.js";import{getHighlightName as vt}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as It}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Ct}from"../../../webscene/support/AlphaCutoff.js";const Mt=[1,1,1,1];class wt extends Se{constructor(e,t,i,s,r,o,n,a,l,d,h){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this._elevationAlignmentRange=new nt,this._geometryElevationRange=new nt,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0,this.cachedSymbologyStride=5,this.elevationAlignmentOffset=0,this._baseGeometryElevationRange=new nt(d,h),this.updateGeometryElevationRange()}get geometryElevationRange(){return this._geometryElevationRange}updateGeometryElevationRange(){const e=this._baseGeometryElevationRange;if(!e.elevationRangeValid||e.isEmpty)return this._elevationAlignmentRange.invalidateElevationRange(),void this._geometryElevationRange.invalidateElevationRange();const t=this.elevationOffsets;if(!t||0===t.length){const t=this.elevationAlignmentOffset;return this._elevationAlignmentRange.setElevationRangeValues(t,t),void this._geometryElevationRange.setElevationRangeValues(e.minElevation+t,e.maxElevation+t)}let i=1/0,s=-1/0;for(let r=0;r<t.length;++r){const e=this.elevationAlignmentOffset+(t[r]??0);i=Math.min(i,e),s=Math.max(s,e)}this._elevationAlignmentRange.setElevationRangeValues(i,s),this._geometryElevationRange.setElevationRangeValues(e.minElevation+i,e.maxElevation+s)}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}const xt=28,Rt=104857600,Et=t=>{const f=t;let te=class extends f{constructor(){super(...arguments),this._applySSAO=!0,this._imShading=!!has("enable-feature:im-shading"),this._imVertexNormals=!!has("enable-feature:im-vertex-normals"),this._updatingHandles=new k,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new It,this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new Oe(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerViewUid(){return this.uid}get layerId(){return this.layer.id}get sublayerId(){return null}get _isIntegratedMesh(){return"integrated-mesh"===this.layer.type}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>Ct}get legendEnabled(){return this.contentVisible&&!0===this.layer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Ge(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?63:53:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){const e=this.layer?.elevationInfo;return"absolute-height"===e?.mode?he(e,this.layer.spatialReference):0}get elevationInfo(){const e=this.layer?.elevationInfo;switch(e?.mode){case"absolute-height":return new Ut(0,he(e,this.layer.spatialReference));case"relative-to-ground":return new Ut(1,he(e,this.layer.spatialReference));case"on-the-ground":return new Ut(2,0);default:return new Ut(0,0)}}get supportedTextureEncodings(){return Ae(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new nt;for(const i of e.values()){const e=i?.geometryElevationRange;e?.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}return t.elevationRangeValid&&!t.isEmpty?t:null}get fullExtent(){return this.layer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new Xe(this.view,e):new Ye("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.layer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Pe({view:this.view,layer:this.layer,memoryController:i}),this._workerHandle=new Ie(rt(t)),this.addResolvingPromise(this._workerHandle.promise),Ue(this.layer),Le(this.layer,this.view);const s=this.layer.store.defaultGeometrySchema;if(this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,s).catch(d)),this._layerUrl=this.layer.parsedUrl.path,this._controller=new re({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection,this._isIntegratedMesh||!s)this._hasComponentData=!1;else{const e=s.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(s?.vertexAttributes.color??null)&&!this.layer.cachedDrawingInfo?.color;const r=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=r;const n=this._controller,l=this._nodeId2Meta,h=this._nodeId2MetaReloading;function*c(e){const t=n.index;if(!t)return;const i=t.rootNode;if(!i)return;let s=null;for(const r of t.traverseValues(i,t=>{const i=l.get(t.index)||h.get(t.index);return s=i?.objectHandle??null,e(t,s)}))yield new Fe(r,s)}this._intersectionHandler=new Ve({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:c}),this._elevationProvider=new Ze({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),u),this._updatingHandles.add(()=>this.fullOpacity,e=>this._opacityChange(e)),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this.elevationOffset,(e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()}),this._updatingHandles.add(()=>this.elevationInfo,(e,t)=>this._elevationInfoChanged(e,t),u),this._updatingHandles.add(()=>!this.suspended&&0!==this.elevationInfo.mode,(e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",({extent:e})=>this._ensureElevationTask().addExtent(e)),qt):t&&this.removeHandles(qt)},u),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e));const _=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add(()=>this.rendererTextureUsage,_),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),u),this._updatingHandles.add(()=>this.layer.labelsVisible,()=>this._labelingChanged(),u),this._updatingHandles.add(()=>this.layer.labelingInfo,()=>this._labelingChanged(),u),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),u),this.addHandles([g(()=>ot.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&ot.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||ot.I3S_TREE_SHOW_TILES||(this._treeDebugger=a(this._treeDebugger))},u),g(()=>ot.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),u)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>o.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));const{view:m}=this,{viewingMode:f,renderCoordsHelper:p}=m;this._planetRadiusInGlobalMode="local"===f?0:p.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=a(this._elevationTask),this.i3sOverrides=a(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.notifyObjectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=a(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=a(this._labeler),this._treeDebugger=a(this._treeDebugger),this._controller=a(this._controller),this._highlights=a(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=a(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=a(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.usedMemory;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach(t=>e+=null!=t?t.node.memory:0),this._nodeId2MetaReloading.forEach(t=>e+=null!=t?t.node.memory:0),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(we(this.layer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new me({view:this.view,layer:this.layer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});this._nodeId2Meta.forEach(t=>null!=t&&this._addMetaToLabeler(e,t)),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then(e=>(--this._asyncModuleLoading,e),e=>{throw--this._asyncModuleLoading,e})}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=pe().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()},()=>{}),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=e=>o.getLogger(this).error("set-modifications-error","Error when setting modifications:",e),t=this.uid,i=this.layer.spatialReference,s=i.isGeographic,r=Ce(this._layerClippingArea,this._modifications,i,this.view.state.isGlobal);this._workerHandle.setModifications(t,r,s).catch(e);try{ye({context:t,modifications:r,isGeodetic:s})}catch(a){e(a)}this._controller.modificationsChanged();const n=this.hasModifications?new l:null;this._nodeId2Meta.forEach((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=n&&n.push(e.node)}),this.notifyChange("elevationRange"),null!=n&&this._nodeId2MetaReloading.forEach(e=>n.push(e.node)),null!=n&&n.length>0&&(this.updateNodeModificationStatus(n),n.forAll(e=>{if(2!==e.imModificationImpact){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}})),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!ot.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.layer.spatialReference;const o=new ge({...t,color:e[s.type]});this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,(e,t)=>this._createAttributes(e,t))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule(()=>{this._nodeId2Meta.get(e)===s&&this._attributeValuesChanged(s)},i).catch(e=>{h(e)||o.getLogger(this).warn("Error while updating attribute values. Layer might not display correctly.",e)}))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,(e,t)=>this._createAttributes(e,t)),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear(),this._addTasks.forEach(e=>e.allowMemCache=!1)}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach(t=>null!=t&&e.push(t.node)),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach(t=>t&&e.push(this._collection.getComponentObb(t.objectHandle))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach((t,i)=>e.push(i)),this._nodeId2MetaReloading.forEach((t,i)=>e.push(i))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&2&this.supportedTextureEncodings&&this.layer.textureSetDefinitions?.some(e=>e.formats.some(e=>"basis"===e.format||"ktx2"===e.format))&&bt()}_getVertexBufferLayout(e,t){return ct(gt(this._getGeometryParameters({hasTexture:Dt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.layer.objectIdField||se}_getGlobalIdField(){return this.layer.globalIdField}_findGraphicNodeAndIndex(e){const t=tt(this.layer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.layer.fieldsIndex;for(const n of t){const e=tt(o,n.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this.getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this.getAABB(e.nodeIndex,e.componentIndex)}getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=je(t,this._collection,s,Y(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;return B(r,o,0,r,n,0)?W(r):null}whenGraphicAttributes(e,t){return Be(this.layer,e,this._getObjectIdField(),t,()=>this._nodeId2Meta.values().filter(r).toArray())}getGraphicFromIntersectorTarget(e,t){if(null==e.nodeIndex||null==e.componentIndex)return null;const i=this._nodeId2Meta.get(e.nodeIndex);if(null==i?.featureIds||e.componentIndex>=i.featureIds.length)return null;const s=this._createLayerGraphic(this._createAttributes(e.componentIndex,i));return s?t.defer?(t.defer(async()=>(s.geometry=(await import("./i3s/meshUtils.js")).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),s)),null):s:null}_getCacheKey(e){return`${this._layerUrl}/v${xt}/${e}${this._cacheKeySuffix}`}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return $t;if(e===G(e))return Wt;return this.layer.spatialReference.equals(e)?zt:null!=e.wkid?`@${e.wkid}`:null}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,i)}loadMissingTextures(e,t,i,s){const r=e?.filter((e,i)=>{if(0===(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=De(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)})??[];return 0===r.length?Promise.resolve(!1):i(r,s).then(i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0})}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then(s=>null==s?null:(s.globalTrafo=X(s.globalTrafo),s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=lt.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then(i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Nt(s.transformedGeometry,s.textureData),s.textureData.every(Ht)&&this._indexedDbSizeCheck(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch(t=>o.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),c(t),s))))):Promise.resolve(null)}addNode(e,t,i){return Tt(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,()=>this._transformNode(e,t,i).then(s=>this._safeReschedule(()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);const{obb:r,componentOffsets:n,featureIds:a,anchorIds:l,anchors:d,transformedGeometry:h,geometryMinElevation:c,geometryMaxElevation:u}=s;e.hasModifications=h.hasModifications;const g=X(s.globalTrafo),_=S(Lt,r.center.x,r.center.y,r.center.z);j(_,_,g);const m=new lt(_,[r.extents.x,r.extents.y,r.extents.z],O(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=m),t.geometryData.componentOffsets=n,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=l,t.geometryData.anchors=d;const f={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:h,globalTrafo:g,geometryObbData:m.data,geometryMinElevation:c,geometryMaxElevation:u,byteSize:Nt(h,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,f)){const t=null!=f.textureData?f.textureData.map(e=>Ht(e)?e:null):null;this._idbCache.put(this._getCacheKey(e.id),{...f,textureData:t}).catch(t=>o.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,f,i)},i))):Promise.reject()}getElevationRange(e){const t=new nt,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=i.viewportQueries,a=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=n.getAndUpdateVisibilityObbInRenderSR(i);let a=null;if(r){if(!r.intersectSphereWithMBS(e,r.radius))return!1}else if(a=n.calculateServiceMbsInRenderSRElevationAdjusted(i),a?.isValid&&!e.intersects(a))return!1;const l=o.get(i.index);if(l){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){const e=l.geometryElevationRange;e.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}}return s-(l?1:0)>0};return s.traverse(r,a),t}computeVisibilityObb(e){return qe(e,this.view.renderSpatialReference,this._controller.crsIndex,this.layer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=this.layer.normalReferenceFrame,n=t.normalReferenceFrame??o??"none",a=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=ke(a,l,n,d,c),g=q(d,h),_=q(h,c);if(null==g||null==_)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,geometryElevationOffset:l,mbs:a.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,planetRadiusInGlobalMode:this._planetRadiusInGlobalMode,needNormals:this._controller.isMeshPyramid||this._imVertexNormals,computeNormals:this._isIntegratedMesh&&this._imVertexNormals,normalReferenceFrame:n,indexToVertexProjector:g,vertexToRenderProjector:_};return this._workerHandle.invoke(m,i)}get _supportsNodeCrossFading(){return!this.view?.stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateElevationOffsets(t),null!=this._labeler&&this._addMetaToLabeler(this._labeler,t),this._updateMaterial(t),this._setNewNodeOpacity(t),0!==this.elevationInfo.mode&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights?.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,()=>this._addCachedNodeData(e,t,s))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter(e=>null!=e&&0!==(e.usage&this.rendererTextureUsage)):[];!has("disable-feature:i3s-basis")&&a.some(e=>null!=e&&(2===e.encoding||1===e.encoding))&&await bt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,g=this._collection,_=d[0],{layout:m,indices:f,interleavedVertexData:p,positionData:y,hasColors:O}=n,{material:S,geometryParameters:j}=this._materialParameters(_,m),A=p.byteLength/m[0].stride,D=l||new Uint32Array([0,f?f.length:A]),T=_.transformation?R(_.transformation):E(),N=X(t.globalTrafo);w(T,N,T);const k=x(H(),T),G=b(C(),T),L=this._isIntegratedMesh?this._imShading?2:0:1,B=j.textureCoordinateType,q=!v(G,M),$=new _t(m,L,B,q?1:0),W=new mt({interleavedVertexData:p,vertexCount:A,indexData:f},{positions:Z(y.data),indices:ee(y.indices)},D,$),K=this.view.renderSpatialReference,Q=this.view.basemapTerrain.spatialReference,J=lt.fromData(dt(t.geometryObbData)).getCenter(Xt),Y=[1,1,1];U(J,K,Y,Q)||o.getLogger(this).errorOnce("Unsupported coordinate system for IM overlay");const te=H();z(J,K,te,Q);const ie=C();I(ie,G);const se=H();V(se,F(se,J,k),ie);const re=te[0]-se[0]*Y[0],oe=te[1]-se[1]*Y[1],ne=2===j.textureCoordinateType,{textures:ae,texturePromise:le,materialParameters:de}=this._initMaterialAndTextures(S,a,ne,e),he=g.createObject(new ut(P(re,oe,Y[0],Y[1]),new pt(k,G),lt.fromData(dt(t.geometryObbData)),W,!this._isIntegratedMesh),de);e.memory+=this._memEstimateGeometryAdded(he),e.memory+=ae.reduce((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0),0);const ce=!!S.hasParametersFromSource,ue="blend"!==S.alphaMode&&S.metallicRoughness.baseColorFactor[3]>=1,ge=new wt(e,h,he,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:ce,isOpaque:ue},ae,c,u,t.geometryMinElevation,t.geometryMaxElevation);s.meta=ge,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(19&e))||!!e.resources.texture,this._hasData=!0,this._hasColors||=O,this.notifyChange("hasTexturesOrVertexColors");const _e=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(ge),le]).then(([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(ge.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._safeReschedule(()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,ge),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);g.setObjectVisibility(he,!0),t?.updateObjectVisibility(ge.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),ge.attributeInfo=i.attributeInfo;const s=ge.cachedRendererVersion!==this._rendererVersion,r=_e!==this.slicePlaneEnabled;this._updateElevationOffsets(ge);const o=ge.elevationOffsets;this._updateComponentData(ge);const n=this._applyFiltersToNode(ge);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(ge),null!=this._labeler&&this._addMetaToLabeler(this._labeler,ge),this._visibleGeometryChanged(ge,0),this._highlights?.objectCreated(ge),this._updateMaterial(ge),this._setNewNodeOpacity(ge),null!=this._treeDebugger&&this._treeDebugger.update()},i))).catch(e=>{const{meta:t,allowMemCache:i}=s;throw s.meta=null,t&&i?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e})}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){o.getLogger(this).error("Removing duplicated node");const t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Gt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;const{view:t,elevationInfo:i}=this,s=this._controller.crsIndex,{groundView:r,groundSpatialReference:o,renderSpatialReference:n}=t,a=i.mode;if(0===a)return e.elevationAlignmentOffset=i.offset,e.elevationOffsets=null,e.updateGeometryElevationRange(),void this.notifyChange("elevationRange");if(e.elevationAlignmentOffset=0,null==n||null==o)return e.elevationOffsets=null,e.updateGeometryElevationRange(),void this.notifyChange("elevationRange");const l=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const d=Lt,h=Bt,c=2===a,u=this.view.renderCoordsHelper,g=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const t=Y(3*g);e.cachedElevationAnchors=t;const{center:i}=e.node.serviceMbsInIndexSR;for(let r=0;r<g;r++){const a=3*r,c=e.anchorIds?.indexOf(r)??-1;e.anchors&&c>=0?(S(d,e.anchors[3*c],e.anchors[3*c+1],e.anchors[3*c+2]),A(d,d,i),z(d,s,d,o),t[a]=d[0],t[a+1]=d[1],t[a+2]=u.getAltitude(d)):(this._collection.getComponentAabb(e.objectHandle,r,h,!0),S(d,(h[0]+h[3])/2,(h[1]+h[4])/2,h[2]),V(d,d,l.rotationScale),A(d,d,l.position),t[a+2]=u.getAltitude(d),z(d,n,d,o),t[a]=d[0],t[a+1]=d[1])}return t})(),m=i.offset,f=e.elevationOffsets,p=(e,t)=>{const i=c?_[3*e+2]:0;f[e]=m+(t??0)-i};r.getElevations(_,g,p),e.updateGeometryElevationRange(),this.notifyChange("elevationRange")}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Re(this.view.resourceController.scheduler,e=>this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference)?.filterInPlace(e=>null!=this._nodeId2Meta.get(e)),e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e)),()=>this.elevationInfo?.mode)),this._elevationTask}_elevationInfoChanged(e,t){const i=0!==e.mode,s=!!t&&t!==e&&0!==t.mode;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach(e=>this._nodeElevationAlignmentChanged(e))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return c(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Te(),s=t.some(({name:e})=>"uvRegion"===e),r=t.some(({name:e})=>"normalCompressed"===e),o=Dt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,s.memory-=e},n=t.map(t=>He(t,e,i,r,this._compressionTracker,o));this._stage.addTextures(n);const{materialParameters:a,texturePromise:l}=Ne(e,n,t,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference,applySSAO:this._applySSAO});return{textures:n,texturePromise:l,materialParameters:a}}_getGeometryParameters(e){return new ft(this._hasVertexColors,e.hasNormals,e.hasTexture?e.hasRegions?2:1:0)}_addData(e,t,i){let s=this._addTasks.get(e.index);if(s)s.attributeInfo=t;else{const r=Promise.withResolvers();s=new kt(t,null,r.promise),this._addTasks.set(e.index,s),i().then(r.resolve,r.reject).then(()=>this._addTasks.delete(e.index)).catch(t=>{throw this._addTasks.delete(e.index),t})}return s.promise}_clearAddTasks(){this._addTasks.forEach(e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)}),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.layer.spatialReference,i=Q();this._renderClippingArea=at(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=at(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=Yt(this._nodeId2Meta.values()),this._filteredIdCounts=Yt(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=Yt(this._nodeId2Meta.values(),2),this.addHandles(g(()=>this._controller.updating,e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())},{sync:!0}),"updateFinished")):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles("updateFinished"),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,Jt(this._featureIdCounts,e.featureIds,t),Jt(this._filteredIdCounts,e.filteredIds,t),Jt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,Jt(this._filteredIdCounts,t,-1),Jt(this._filteredIdCounts,e.filteredIds,1),Jt(this._weaklyRemovedIdCounts,i,-1),Jt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","LayerView should have feature id node counts if and only if it has a geometry filter",{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;const t=Yt(this._nodeId2Meta.values());n(this._featureIdCounts,t)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=Yt(this._nodeId2Meta.values(),1);n(this._filteredIdCounts,i)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=Yt(this._nodeId2Meta.values(),2);n(this._weaklyRemovedIdCounts,s)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _weaklyRemovedIdCounts",{layerView:this,counts:this._weaklyRemovedIdCounts,expected:i})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(const[i,s]of this._filteredIdCounts){const r=this._featureIdCounts.get(i);if(r!==s){s+(this._weaklyRemovedIdCounts?.get(i)??0)===r?(e??=new Set,e.add(i)):(t??=new Set,t.add(i))}}m(e,this._mismatchShow)&&m(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;const t=Qt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach(e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,2))})}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push((e,i)=>this._boundingRectFilter(e,i,t)),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push((e,r)=>this._sqlFilter(e,r,t,s,i))}}_sqlFilter(e,t,i,s,r){const o={},n=this._createLayerGraphic(o);if(!n)return;const a=this.layer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every(e=>e===a||null!=d?.[e])&&ze(e,l,e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?Ee(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}})}_boundingRectNodeTest(e,t){return L(e.node.serviceMbsInIndexSR,this._controller.crsIndex,At,this.view.renderSpatialReference),$e(t,At)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Ot),K(Ot,St),J(i,St)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(3===r)return;if(0===r)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(jt,i,t.objectHandle);ze(e,t.featureIds,e=>this._boundingRectFeatureTest(t,e,n))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e);s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const o=this._edgeView;if(!o)return null;const n=o.hasObject(i);if(s){if(n){if(this.nodeCrossfadingEnabled){Gt(r,this.getNodeOpacity(e))}return o.updateAllComponentMaterials(i,r,this.slicePlaneEnabled,t).catch(e=>this._logEdgeViewError(e,this.layer.title)),o.updateObjectVisibility(i,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),o.updateAllVerticalOffsets(i,e.elevationOffsets).catch(e=>this._logEdgeViewError(e,this.layer.title)),o}const s=await this._collection.addEdges(i,o,r,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,o}return n&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,o.removeObject(i)),null}_applyFiltersToNode(e){const{filteredIds:t,weaklyRemovedIds:i}=e,s=this._applyFiltersToNodeComponents(e);return this._updateFilteredIdCounts(e,t,i),s&&this._labeler?.applyFilterChange(e),s}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(null!=e.filteredIds&&e.appliedFilters===this._filters||(e.weaklyRemovedIds=null,e.filteredIds=Kt(e,this._filters),e.appliedFilters=this._filters),s&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every(e=>!this._mismatchHide?.has(e))))return!r;const o=Qt(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach((t,i)=>this._removeNodeStageData(i,e)),this._nodeId2MetaReloading.forEach((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading)),this._elevationTask=a(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._visibleGeometryChanged(s,1),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights?.objectDeleted(s),i===this._nodeId2Meta?(this._updateFeatureIdCounts(s,-1),this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.removeTexture(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&i.objectHandle.updateMaterial({polygonOffset:0===t?1:0})}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=We(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.layer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await ce()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:o.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.symbols)"mesh-3d"!==t.type&&o.getLogger(this).error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=i*e.cachedSymbologyStride;N(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255);const o=this._stage.renderView.olidRenderHelper;if(o){const t=e.featureIds[i],r=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,n=de(this.view,this.uid);o.setUidToObjectAndLayerId(t,t,this.layerId,r,this.layerPopupEnabledAndHasTemplate&&!n,e.node.resources.attributes,i,this.sublayerId),s.olidColor=o.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:r})}s.externalColorMixMode=15&t[r+4],s.castShadows=!!(16&t[r+4]),s.pickable=!!(32&t[r+4]),s.elevationOffset=e.elevationOffsets?.[i]??0,s.emissiveStrength=e.emissiveStrengths?.[i]??1,s.emissiveSource=e.emissiveSources?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ue))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=Ke(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?oe(this.layer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=e.featureIds?this.layer.objectIdField:null,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=ie(e.featureIds.length*e.cachedSymbologyStride));const d=new et,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,g=1,_=Qe,m=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=Ee(l[e],f);const r=s?this._getSymbolInfo(s,t):null;let h,p;if(d.pickable=!0,s&&"visualVariables"in s){if(this._colorVariable){const e=ae(this._colorVariable,t,{color:Ft,arcade:this._arcade});e&&(h=d.color,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,h[3]=e.a??1,this._opacityVariable||null===e.a||(p=e.a))}this._opacityVariable&&(p=le(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?Me(h,p,e.color,e.alpha,Mt,d.color):Me(h,p,null,null,Mt,d.color)}h??=N(d.color,1,1,1,1);const y=r?.material;if(d.colorMixMode=y?.colorMixMode??1,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=3),d.pickable&&=h[3]>=Ct,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||3===d.colorMixMode)?1:0;d.edgeMaterial===u&&t===g||(_={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,g=t),e.cachedEdgeMaterials[f]=_}else e.cachedEdgeMaterials[f]=Qe;e.cachedSymbology[m++]=Math.round(255*h[0]),e.cachedSymbology[m++]=Math.round(255*h[1]),e.cachedSymbology[m++]=Math.round(255*h[2]),e.cachedSymbology[m++]=Math.round(255*h[3]),e.cachedSymbology[m++]=d.colorMixMode|+d.castShadows<<4|+d.pickable<<5;const b=y?.emissive?.strength??yt;b===yt||e.emissiveStrengths||(e.emissiveStrengths=new Array(e.featureIds.length).fill(yt)),e.emissiveStrengths&&(e.emissiveStrengths[f]=b);const v=y?.emissive?.source||0;0===v||e.emissiveSources||(e.emissiveSources=new Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[f]=v)}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Gt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some(e=>e!==Qe),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map((t,o)=>e.featureIds[o]!==i[s]?Qe:(r=r||t!==Qe,s++,t));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const{objectHandle:t}=e,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach(t=>{null!=t&&(this._collection.updateObjectOpacity(t.objectHandle,e),Gt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))})}_updateMaterial(e){e.objectHandle.updateMaterial({slicePlaneEnabled:this.slicePlaneEnabled,usePBR:this._usePBR})}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,2)}intersect(e,t,i,s){this._intersectionHandler.intersectRay(e,t,i,s,null,!1)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._foreachMeta(t=>{t.objectHandle.updateMaterial({slicePlaneEnabled:e}),this._updateEdgeRendering(t,!1)})}_updatePBR(e){this._foreachMeta(t=>t.objectHandle.updateMaterial({usePBR:e})),this._hasLoadedPBRTextures=!0}_foreachMeta(e){this._nodeId2Meta.forEach(t=>{null!=t&&e(t)})}get _usePBR(){return this._imShading&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?0:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values())if(!(null==s||t&&s.node.serviceMbsInIndexSR&&1===t(s.node.serviceMbsInIndexSR)))switch(i){case 1:this._forAllFeaturesOfNode(s,e);break;case 0:this._forAllVisibleFeaturesOfNode(s,e);break;case 2:this._forAllQueryableFeaturesOfNode(s,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((i,s)=>t(i,s,e))}_forAllVisibleFeaturesOfNode(e,t){const i=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,s=>0===t(i[s],s,e))}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(0===s)return;if(3===s)return this._forAllFeaturesOfNode(e,i);const r=e.featureIds,o=e.objectHandle,n=Je(this._renderClippingArea,this._collection.getObjectTransform(o));for(let a=0;a<r.length;a++)this._boundingRectFeatureTest(e,a,n)&&i(r[a],a,e)}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=Ee(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){const s=it(e);if(0===s.length)return st;const r=vt(t),o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return st;const n=this._ensureHighlights(),{set:a,handle:l}=n.acquireSet(r);return n.setFeatureIds(a,o),l}_featureIdsFromGraphics(e){const t=this.layer.fieldsIndex,i=this._getObjectIdField();return e.map(e=>tt(t,e.attributes,i))}_ensureHighlights(){return this._highlights??=new xe({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=a(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=_(()=>{const{node:t}=e,i=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(null!=i){const e=$();i.toAaBoundingBox(e),this.emit("visible-geometry-changed",new _e(e))}else this.emit("visible-geometry-changed");this._visibleGeometryChangedSchedulerHandle=null})),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new fe(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}checkInvariants(){}get test(){}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getObjectOpacity(e.objectHandle):0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateObjectOpacity(e.objectHandle,t),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;Gt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch(e=>this._logEdgeViewError(e,this.layer.title))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Pt(e);if(s){const t={context:i,buffer:s.buffer};be(t);const r=new Float64Array(s.buffer);e.forAll((e,t)=>{const i=r[t],s=ve(i);e.imModificationImpact=s,0!==s&&this._controller.invalidateGeometryVisibility(e.index)})}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.readyToRun||this._needFilterResolve||this._compressionTracker.compressing}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>s(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)}),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||0===this.elevationInfo.mode)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=H(),a=H(),l=(e,t)=>{A(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),A(e,e,D(a,a,t)),T(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)1!==t&&2!==t||r.events.remove(i),0!==t&&2!==t||r.events.add(i,s)}_logEdgeViewError(e,t){h(e)||o.getLogger(this).warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>Rt?(o.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([p()],te.prototype,"_hasLoadedPBRTextures",void 0),e([p()],te.prototype,"_asyncModuleLoading",void 0),e([p()],te.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([p()],te.prototype,"view",void 0),e([p()],te.prototype,"layer",void 0),e([p()],te.prototype,"_controller",void 0),e([p()],te.prototype,"_labeler",void 0),e([p()],te.prototype,"updating",void 0),e([p()],te.prototype,"suspended",void 0),e([p()],te.prototype,"contentVisible",null),e([p({readOnly:!0})],te.prototype,"legendEnabled",null),e([p(ht)],te.prototype,"updatingProgress",void 0),e([p()],te.prototype,"updatingProgressValue",null),e([p()],te.prototype,"hasTexturesOrVertexColors",null),e([p()],te.prototype,"rendererTextureUsage",null),e([p()],te.prototype,"elevationOffset",null),e([p()],te.prototype,"elevationInfo",null),e([p({type:Boolean})],te.prototype,"slicePlaneEnabled",void 0),e([p()],te.prototype,"supportedTextureEncodings",null),e([p({type:[ne]})],te.prototype,"_modifications",void 0),e([p({readOnly:!0})],te.prototype,"clientGeometry",null),e([p()],te.prototype,"elevationRange",null),e([p()],te.prototype,"fullExtent",null),e([p()],te.prototype,"_elevationTask",void 0),e([p({readOnly:!0})],te.prototype,"_usePBR",null),te=e([y("esri.views.3d.layers.I3SMeshView3D")],te),te},Ot=$(),St=Q(),jt=Q(),Vt=new lt,Ft=new t([0,0,0,0]),At=new te(0,0,0,0);function Dt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Tt(e){return"geometryData"in e}function Ht(e){return null!=e&&f(e.data)}function Nt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&f(s.data)&&(i+=s.data.byteLength);return i}function Pt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll(e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Vt,e.serviceMbsInIndexSR?(t.setCenter(e.serviceMbsInIndexSR.center),t.setHalfSizeFromValues(e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius)):t.invalidate());const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]}),i}class kt{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function Gt(e,t){e.forEach(e=>e.opacity=t)}class Ut{constructor(e,t){this.mode=e,this.offset=t}}const Lt=H(),Bt=$(),qt="elevation-change",zt="",$t="@null",Wt="@ECEF";function Kt(e,t){const i=e.featureIds.slice();for(const s of t)if(s(i,e),0===i.length)break;return i.length===e.featureIds.length?e.featureIds:i}function Qt(e,t,i){const s=new Array,r=e.filteredIds;if(null==r||t?.size||i?.size){if(null!=r){let o=0;e.featureIds.forEach((e,n)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(n)})}}else e.featureIds.forEach((e,t)=>{r[s.length]===e&&s.push(t)});return s}function Jt(e,t,i){if(e&&t)for(const s of t){const t=(e.get(s)??0)+i;t>0?e.set(s,t):e.delete(s)}}function Yt(e,t=0){const i=new Map;for(const s of e){Jt(i,0===t?s?.featureIds:1===t?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}const Xt=H();export{Et as I3SMeshView3D};
2
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s,isSome as r}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import o from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../core/maybe.js";import l from"../../../core/PooledArray.js";import{ignoreAbortErrors as d,isAbortError as h,throwIfAborted as c}from"../../../core/promiseUtils.js";import{initial as u,watch as g}from"../../../core/reactiveUtils.js";import{schedule as m}from"../../../core/scheduling.js";import{equals as _}from"../../../core/SetUtils.js";import{isArrayBuffer as f}from"../../../core/typedArrayUtil.js";import{property as p,subclass as y}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as b,exactEquals as v,invert as I}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as C,IDENTITY as M}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as x,getTranslation as w}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as R,create as E}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as O}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as S,transformMat4 as j,transformMat3 as V,sub as F,add as A,scale as D,subtract as T}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as N}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as P}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as U}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as k}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as G}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as L}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as B}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as q}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{create as $,fromBuffer as W,toRect as K}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as J}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y,ensurePackedMat4f64 as X}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{Sphere as te}from"../../../geometry/support/sphere.js";import{newUByteArray as ie}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as se}from"../../../layers/LayerConstants.js";import re from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as oe}from"../../../layers/support/fieldUtils.js";import ne from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as le}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as de}from"../../../support/basemapUtils.js";import{getElevationOffset as he}from"../../../support/elevationInfoUtils.js";import{loadArcade as ce}from"../../../support/loadArcade.js";import ue from"../../../symbols/MeshSymbol3D.js";import ge from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as me}from"./ContentGeometryLayerView.js";import _e from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as fe}from"./I3SMeshViewPerformanceInfo.js";import{initialize as pe,setModificationsSync as ye,filterObbsForModificationsSync as be,interpretObbModificationResults as ve}from"./SceneLayerWorker.js";import{SceneLayerWorkerHandle as Ie,toWasmModification as Ce}from"./SceneLayerWorkerHandle.js";import{overrideColor as Me}from"./graphics/graphicUtils.js";import{areLabelsVisible as xe}from"./graphics/Labeler.js";import we from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Re}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Ee}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Oe,NodeCrossfadeMetaData as Se}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as je}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ve,TraversedIntersectionNode as Fe}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ae,selectEncoding as De,defaultMaterial as Te,createTexture as He,configureMaterial as Ne}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as Pe}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Ue}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as ke,checkSceneLayerValid as Ge,checkSceneLayerCompatibleWithView as Le,whenGraphicAttributes as Be,computeVisibilityObb as qe,filterInPlace as ze,intersectBoundingRectWithMbs as $e,addWraparound as We,getSymbolInfo as Ke,transparentEdgeMaterial as Qe,getClipRect as Je}from"./i3s/I3SUtil.js";import{IDBCache as Ye}from"./i3s/IDBCache.js";import{IDBMockCache as Xe}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as Ze}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as et}from"./i3s/SymbologyInfo.js";import{attributeLookup as tt}from"./support/attributeUtils.js";import{normalizeHighlightTarget as it,emptyHighlightHandle as st}from"./support/highlightUtils.js";import{makeScheduleFunction as rt}from"./support/makeScheduleFunction.js";import{debugFlags as ot}from"../support/debugFlags.js";import{ElevationRange as nt}from"../support/ElevationRange.js";import{toBoundingRect as at}from"../support/extentUtils.js";import{Obb as lt,ensurePackedObbData as dt}from"../support/orientedBoundingBox.js";import{updatingProgress as ht}from"../support/updatingProperties.js";import{glLayout as ct}from"../support/buffer/glUtil.js";import{ObjectParameters as ut}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as gt,ComponentGeometryParameters as mt,SourceGeometry as _t,VertexBufferLayoutCreationParameters as ft}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as pt}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as yt}from"../webgl-engine/core/shaderLibrary/output/getEmissions.glsl.js";import{loadBasisTranscoder as bt}from"../webgl-engine/lib/BasisUtil.js";import{getHighlightName as vt}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as It}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Ct}from"../../../webscene/support/AlphaCutoff.js";const Mt=[1,1,1,1];class xt extends Se{constructor(e,t,i,s,r,o,n,a,l,d,h){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this._elevationAlignmentRange=new nt,this._geometryElevationRange=new nt,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0,this.cachedSymbologyStride=5,this.elevationAlignmentOffset=0,this._baseGeometryElevationRange=new nt(d,h),this.updateGeometryElevationRange()}get geometryElevationRange(){return this._geometryElevationRange}updateGeometryElevationRange(){const e=this._baseGeometryElevationRange;if(!e.elevationRangeValid||e.isEmpty)return this._elevationAlignmentRange.invalidateElevationRange(),void this._geometryElevationRange.invalidateElevationRange();const t=this.elevationOffsets;if(!t||0===t.length){const t=this.elevationAlignmentOffset;return this._elevationAlignmentRange.setElevationRangeValues(t,t),void this._geometryElevationRange.setElevationRangeValues(e.minElevation+t,e.maxElevation+t)}let i=1/0,s=-1/0;for(let r=0;r<t.length;++r){const e=this.elevationAlignmentOffset+(t[r]??0);i=Math.min(i,e),s=Math.max(s,e)}this._elevationAlignmentRange.setElevationRangeValues(i,s),this._geometryElevationRange.setElevationRangeValues(e.minElevation+i,e.maxElevation+s)}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}const wt=28,Rt=104857600,Et=t=>{const f=t;let te=class extends f{constructor(){super(...arguments),this._applySSAO=!0,this._imShading=!!has("enable-feature:im-shading"),this._imVertexNormals=!!has("enable-feature:im-vertex-normals"),this._updatingHandles=new U,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new It,this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._meshUtilsImporterModule=null,this._meshUtilsImporterPromise=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new Oe(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerViewUid(){return this.uid}get layerId(){return this.layer.id}get sublayerId(){return null}get _isIntegratedMesh(){return"integrated-mesh"===this.layer.type}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>Ct}get legendEnabled(){return this.contentVisible&&!0===this.layer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?63:53:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){const e=this.layer?.elevationInfo;return"absolute-height"===e?.mode?he(e,this.layer.spatialReference):0}get elevationInfo(){const e=this.layer?.elevationInfo;switch(e?.mode){case"absolute-height":return new Gt(0,he(e,this.layer.spatialReference));case"relative-to-ground":return new Gt(1,he(e,this.layer.spatialReference));case"on-the-ground":return new Gt(2,0);default:return new Gt(0,0)}}get supportedTextureEncodings(){return Ae(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new nt;for(const i of e.values()){const e=i?.geometryElevationRange;e?.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}return t.elevationRangeValid&&!t.isEmpty?t:null}get fullExtent(){return this.layer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new Xe(this.view,e):new Ye("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.layer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Pe({view:this.view,layer:this.layer,memoryController:i}),this._workerHandle=new Ie(rt(t)),this.addResolvingPromise(this._workerHandle.promise),Ge(this.layer),Le(this.layer,this.view);const s=this.layer.store.defaultGeometrySchema;if(this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,s).catch(d)),this._layerUrl=this.layer.parsedUrl.path,this._controller=new re({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection,this._isIntegratedMesh||!s)this._hasComponentData=!1;else{const e=s.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(s?.vertexAttributes.color??null)&&!this.layer.cachedDrawingInfo?.color;const r=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=r;const n=this._controller,l=this._nodeId2Meta,h=this._nodeId2MetaReloading;function*c(e){const t=n.index;if(!t)return;const i=t.rootNode;if(!i)return;let s=null;for(const r of t.traverseValues(i,t=>{const i=l.get(t.index)||h.get(t.index);return s=i?.objectHandle??null,e(t,s)}))yield new Fe(r,s)}this._intersectionHandler=new Ve({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:c}),this._elevationProvider=new Ze({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),u),this._updatingHandles.add(()=>this.fullOpacity,e=>this._opacityChange(e)),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this.elevationOffset,(e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()}),this._updatingHandles.add(()=>this.elevationInfo,(e,t)=>this._elevationInfoChanged(e,t),u),this._updatingHandles.add(()=>!this.suspended&&0!==this.elevationInfo.mode,(e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",({extent:e})=>this._ensureElevationTask().addExtent(e)),qt):t&&this.removeHandles(qt)},u),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e));const m=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add(()=>this.rendererTextureUsage,m),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),u),this._updatingHandles.add(()=>this.layer.labelsVisible,()=>this._labelingChanged(),u),this._updatingHandles.add(()=>this.layer.labelingInfo,()=>this._labelingChanged(),u),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),u),this.addHandles([g(()=>ot.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&ot.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||ot.I3S_TREE_SHOW_TILES||(this._treeDebugger=a(this._treeDebugger))},u),g(()=>ot.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),u)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>o.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));const{view:_}=this,{viewingMode:f,renderCoordsHelper:p}=_;this._planetRadiusInGlobalMode="local"===f?0:p.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=a(this._elevationTask),this.i3sOverrides=a(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.notifyObjectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=a(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=a(this._labeler),this._treeDebugger=a(this._treeDebugger),this._controller=a(this._controller),this._highlights=a(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=a(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=a(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.usedMemory;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach(t=>e+=null!=t?t.node.memory:0),this._nodeId2MetaReloading.forEach(t=>e+=null!=t?t.node.memory:0),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(xe(this.layer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new _e({view:this.view,layer:this.layer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});this._nodeId2Meta.forEach(t=>null!=t&&this._addMetaToLabeler(e,t)),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then(e=>(--this._asyncModuleLoading,e),e=>{throw--this._asyncModuleLoading,e})}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=pe().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()},()=>{}),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=e=>o.getLogger(this).error("set-modifications-error","Error when setting modifications:",e),t=this.uid,i=this.layer.spatialReference,s=i.isGeographic,r=Ce(this._layerClippingArea,this._modifications,i,this.view.state.isGlobal);this._workerHandle.setModifications(t,r,s).catch(e);try{ye({context:t,modifications:r,isGeodetic:s})}catch(a){e(a)}this._controller.modificationsChanged();const n=this.hasModifications?new l:null;this._nodeId2Meta.forEach((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=n&&n.push(e.node)}),this.notifyChange("elevationRange"),null!=n&&this._nodeId2MetaReloading.forEach(e=>n.push(e.node)),null!=n&&n.length>0&&(this.updateNodeModificationStatus(n),n.forAll(e=>{if(2!==e.imModificationImpact){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._updateFeatureIdCounts(t,-1),this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}})),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!ot.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.layer.spatialReference;const o=new ge({...t,color:e[s.type]});this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,(e,t)=>this._createAttributes(e,t))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule(()=>{this._nodeId2Meta.get(e)===s&&this._attributeValuesChanged(s)},i).catch(e=>{h(e)||o.getLogger(this).warn("Error while updating attribute values. Layer might not display correctly.",e)}))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,(e,t)=>this._createAttributes(e,t)),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear(),this._addTasks.forEach(e=>e.allowMemCache=!1)}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach(t=>null!=t&&e.push(t.node)),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach(t=>t&&e.push(this._collection.getComponentObb(t.objectHandle))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach((t,i)=>e.push(i)),this._nodeId2MetaReloading.forEach((t,i)=>e.push(i))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&2&this.supportedTextureEncodings&&this.layer.textureSetDefinitions?.some(e=>e.formats.some(e=>"basis"===e.format||"ktx2"===e.format))&&bt()}_getVertexBufferLayout(e,t){return ct(gt(this._getGeometryParameters({hasTexture:Dt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.layer.objectIdField||se}_getGlobalIdField(){return this.layer.globalIdField}_findGraphicNodeAndIndex(e){const t=tt(this.layer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.layer.fieldsIndex;for(const n of t){const e=tt(o,n.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this.getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this.getAABB(e.nodeIndex,e.componentIndex)}getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=je(t,this._collection,s,Y(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;return B(r,o,0,r,n,0)?W(r):null}whenGraphicAttributes(e,t){return Be(this.layer,e,this._getObjectIdField(),t,()=>this._nodeId2Meta.values().filter(r).toArray())}getGraphicFromIntersectorTarget(e,t){if(null==e.nodeIndex||null==e.componentIndex)return null;const i=this._nodeId2Meta.get(e.nodeIndex);if(null==i?.featureIds||e.componentIndex>=i.featureIds.length)return null;const s=this._createLayerGraphic(this._createAttributes(e.componentIndex,i));return s?this._meshUtilsImporterModule?(s.geometry=this._meshUtilsImporterModule.createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),s):t.defer?(t.defer(async()=>(s.geometry=(await this._meshUtilsImporter).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),s)),null):s:null}_getCacheKey(e){return`${this._layerUrl}/v${wt}/${e}${this._cacheKeySuffix}`}get _meshUtilsImporter(){return this._meshUtilsImporterPromise||(this._meshUtilsImporterPromise=import("./i3s/meshUtils.js"),this._meshUtilsImporterPromise.then(e=>this._meshUtilsImporterModule=e,()=>{})),this._meshUtilsImporterPromise}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return $t;if(e===k(e))return Wt;return this.layer.spatialReference.equals(e)?zt:null!=e.wkid?`@${e.wkid}`:null}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,i)}loadMissingTextures(e,t,i,s){const r=e?.filter((e,i)=>{if(0===(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=De(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)})??[];return 0===r.length?Promise.resolve(!1):i(r,s).then(i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0})}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then(s=>null==s?null:(s.globalTrafo=X(s.globalTrafo),s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=lt.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then(i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Nt(s.transformedGeometry,s.textureData),s.textureData.every(Ht)&&this._indexedDbSizeCheck(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch(t=>o.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),c(t),s))))):Promise.resolve(null)}addNode(e,t,i){return Tt(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,()=>this._transformNode(e,t,i).then(s=>this._safeReschedule(()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);const{obb:r,componentOffsets:n,featureIds:a,anchorIds:l,anchors:d,transformedGeometry:h,geometryMinElevation:c,geometryMaxElevation:u}=s;e.hasModifications=h.hasModifications;const g=X(s.globalTrafo),m=S(Lt,r.center.x,r.center.y,r.center.z);j(m,m,g);const _=new lt(m,[r.extents.x,r.extents.y,r.extents.z],O(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=_),t.geometryData.componentOffsets=n,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=l,t.geometryData.anchors=d;const f={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:h,globalTrafo:g,geometryObbData:_.data,geometryMinElevation:c,geometryMaxElevation:u,byteSize:Nt(h,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,f)){const t=null!=f.textureData?f.textureData.map(e=>Ht(e)?e:null):null;this._idbCache.put(this._getCacheKey(e.id),{...f,textureData:t}).catch(t=>o.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,f,i)},i))):Promise.reject()}getElevationRange(e){const t=new nt,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=i.viewportQueries,a=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=n.getAndUpdateVisibilityObbInRenderSR(i);let a=null;if(r){if(!r.intersectSphereWithMBS(e,r.radius))return!1}else if(a=n.calculateServiceMbsInRenderSRElevationAdjusted(i),a?.isValid&&!e.intersects(a))return!1;const l=o.get(i.index);if(l){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){const e=l.geometryElevationRange;e.elevationRangeValid&&!e.isEmpty&&t.expandElevationRange(e)}}return s-(l?1:0)>0};return s.traverse(r,a),t}computeVisibilityObb(e){return qe(e,this.view.renderSpatialReference,this._controller.crsIndex,this.layer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=this.layer.normalReferenceFrame,n=t.normalReferenceFrame??o??"none",a=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=Ue(a,l,n,d,c),g=q(d,h),m=q(h,c);if(null==g||null==m)return Promise.resolve(null);const _={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,geometryElevationOffset:l,mbs:a.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,planetRadiusInGlobalMode:this._planetRadiusInGlobalMode,needNormals:this._controller.isMeshPyramid||this._imVertexNormals,computeNormals:this._isIntegratedMesh&&this._imVertexNormals,normalReferenceFrame:n,indexToVertexProjector:g,vertexToRenderProjector:m};return this._workerHandle.invoke(_,i)}get _supportsNodeCrossFading(){return!this.view?.stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateElevationOffsets(t),null!=this._labeler&&this._addMetaToLabeler(this._labeler,t),this._updateMaterial(t),this._setNewNodeOpacity(t),0!==this.elevationInfo.mode&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights?.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,()=>this._addCachedNodeData(e,t,s))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter(e=>null!=e&&0!==(e.usage&this.rendererTextureUsage)):[];!has("disable-feature:i3s-basis")&&a.some(e=>null!=e&&(2===e.encoding||1===e.encoding))&&await bt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,g=this._collection,m=d[0],{layout:_,indices:f,interleavedVertexData:p,positionData:y,hasColors:O}=n,{material:S,geometryParameters:j}=this._materialParameters(m,_),A=p.byteLength/_[0].stride,D=l||new Uint32Array([0,f?f.length:A]),T=m.transformation?R(m.transformation):E(),N=X(t.globalTrafo);x(T,N,T);const U=w(H(),T),k=b(C(),T),L=this._isIntegratedMesh?this._imShading?2:0:1,B=j.textureCoordinateType,q=!v(k,M),$=new mt(_,L,B,q?1:0),W=new _t({interleavedVertexData:p,vertexCount:A,indexData:f},{positions:Z(y.data),indices:ee(y.indices)},D,$),K=this.view.renderSpatialReference,Q=this.view.basemapTerrain.spatialReference,J=lt.fromData(dt(t.geometryObbData)).getCenter(Xt),Y=[1,1,1];G(J,K,Y,Q)||o.getLogger(this).errorOnce("Unsupported coordinate system for IM overlay");const te=H();z(J,K,te,Q);const ie=C();I(ie,k);const se=H();V(se,F(se,J,U),ie);const re=te[0]-se[0]*Y[0],oe=te[1]-se[1]*Y[1],ne=2===j.textureCoordinateType,{textures:ae,texturePromise:le,materialParameters:de}=this._initMaterialAndTextures(S,a,ne,e),he=g.createObject(new ut(P(re,oe,Y[0],Y[1]),new pt(U,k),lt.fromData(dt(t.geometryObbData)),W,!this._isIntegratedMesh),de);e.memory+=this._memEstimateGeometryAdded(he),e.memory+=ae.reduce((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0),0);const ce=!!S.hasParametersFromSource,ue="blend"!==S.alphaMode&&S.metallicRoughness.baseColorFactor[3]>=1,ge=new xt(e,h,he,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:ce,isOpaque:ue},ae,c,u,t.geometryMinElevation,t.geometryMaxElevation);s.meta=ge,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(19&e))||!!e.resources.texture,this._hasData=!0,this._hasColors||=O,this.notifyChange("hasTexturesOrVertexColors");const me=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(ge),le]).then(([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(ge.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._safeReschedule(()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,ge),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);g.setObjectVisibility(he,!0),t?.updateObjectVisibility(ge.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),ge.attributeInfo=i.attributeInfo;const s=ge.cachedRendererVersion!==this._rendererVersion,r=me!==this.slicePlaneEnabled;this._updateElevationOffsets(ge);const o=ge.elevationOffsets;this._updateComponentData(ge);const n=this._applyFiltersToNode(ge);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(ge),null!=this._labeler&&this._addMetaToLabeler(this._labeler,ge),this._visibleGeometryChanged(ge,0),this._highlights?.objectCreated(ge),this._updateMaterial(ge),this._setNewNodeOpacity(ge),null!=this._treeDebugger&&this._treeDebugger.update()},i))).catch(e=>{const{meta:t,allowMemCache:i}=s;throw s.meta=null,t&&i?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e})}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){o.getLogger(this).error("Removing duplicated node");const t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&kt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;const{view:t,elevationInfo:i}=this,s=this._controller.crsIndex,{groundView:r,groundSpatialReference:o,renderSpatialReference:n}=t,a=i.mode;if(0===a)return e.elevationAlignmentOffset=i.offset,e.elevationOffsets=null,e.updateGeometryElevationRange(),void this.notifyChange("elevationRange");if(e.elevationAlignmentOffset=0,null==n||null==o)return e.elevationOffsets=null,e.updateGeometryElevationRange(),void this.notifyChange("elevationRange");const l=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const d=Lt,h=Bt,c=2===a,u=this.view.renderCoordsHelper,g=e.featureIds.length,m=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const t=Y(3*g);e.cachedElevationAnchors=t;const{center:i}=e.node.serviceMbsInIndexSR;for(let r=0;r<g;r++){const a=3*r,c=e.anchorIds?.indexOf(r)??-1;e.anchors&&c>=0?(S(d,e.anchors[3*c],e.anchors[3*c+1],e.anchors[3*c+2]),A(d,d,i),z(d,s,d,o),t[a]=d[0],t[a+1]=d[1],t[a+2]=u.getAltitude(d)):(this._collection.getComponentAabb(e.objectHandle,r,h,!0),S(d,(h[0]+h[3])/2,(h[1]+h[4])/2,h[2]),V(d,d,l.rotationScale),A(d,d,l.position),t[a+2]=u.getAltitude(d),z(d,n,d,o),t[a]=d[0],t[a+1]=d[1])}return t})(),_=i.offset,f=e.elevationOffsets,p=(e,t)=>{const i=c?m[3*e+2]:0;f[e]=_+(t??0)-i};r.getElevations(m,g,p),e.updateGeometryElevationRange(),this.notifyChange("elevationRange")}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Re(this.view.resourceController.scheduler,e=>this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference)?.filterInPlace(e=>null!=this._nodeId2Meta.get(e)),e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e)),()=>this.elevationInfo?.mode)),this._elevationTask}_elevationInfoChanged(e,t){const i=0!==e.mode,s=!!t&&t!==e&&0!==t.mode;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach(e=>this._nodeElevationAlignmentChanged(e))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return c(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Te(),s=t.some(({name:e})=>"uvRegion"===e),r=t.some(({name:e})=>"normalCompressed"===e),o=Dt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,s.memory-=e},n=t.map(t=>He(t,e,i,r,this._compressionTracker,o));this._stage.addTextures(n);const{materialParameters:a,texturePromise:l}=Ne(e,n,t,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference,applySSAO:this._applySSAO});return{textures:n,texturePromise:l,materialParameters:a}}_getGeometryParameters(e){return new ft(this._hasVertexColors,e.hasNormals,e.hasTexture?e.hasRegions?2:1:0)}_addData(e,t,i){let s=this._addTasks.get(e.index);if(s)s.attributeInfo=t;else{const r=Promise.withResolvers();s=new Ut(t,null,r.promise),this._addTasks.set(e.index,s),i().then(r.resolve,r.reject).then(()=>this._addTasks.delete(e.index)).catch(t=>{throw this._addTasks.delete(e.index),t})}return s.promise}_clearAddTasks(){this._addTasks.forEach(e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)}),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.layer.spatialReference,i=Q();this._renderClippingArea=at(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=at(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=Yt(this._nodeId2Meta.values()),this._filteredIdCounts=Yt(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=Yt(this._nodeId2Meta.values(),2),this.addHandles(g(()=>this._controller.updating,e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())},{sync:!0}),"updateFinished")):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles("updateFinished"),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,Jt(this._featureIdCounts,e.featureIds,t),Jt(this._filteredIdCounts,e.filteredIds,t),Jt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,Jt(this._filteredIdCounts,t,-1),Jt(this._filteredIdCounts,e.filteredIds,1),Jt(this._weaklyRemovedIdCounts,i,-1),Jt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","LayerView should have feature id node counts if and only if it has a geometry filter",{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;const t=Yt(this._nodeId2Meta.values());n(this._featureIdCounts,t)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=Yt(this._nodeId2Meta.values(),1);n(this._filteredIdCounts,i)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=Yt(this._nodeId2Meta.values(),2);n(this._weaklyRemovedIdCounts,s)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _weaklyRemovedIdCounts",{layerView:this,counts:this._weaklyRemovedIdCounts,expected:i})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(const[i,s]of this._filteredIdCounts){const r=this._featureIdCounts.get(i);if(r!==s){s+(this._weaklyRemovedIdCounts?.get(i)??0)===r?(e??=new Set,e.add(i)):(t??=new Set,t.add(i))}}_(e,this._mismatchShow)&&_(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;const t=Qt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach(e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,2))})}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push((e,i)=>this._boundingRectFilter(e,i,t)),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push((e,r)=>this._sqlFilter(e,r,t,s,i))}}_sqlFilter(e,t,i,s,r){const o={},n=this._createLayerGraphic(o);if(!n)return;const a=this.layer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every(e=>e===a||null!=d?.[e])&&ze(e,l,e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?Ee(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}})}_boundingRectNodeTest(e,t){return L(e.node.serviceMbsInIndexSR,this._controller.crsIndex,At,this.view.renderSpatialReference),$e(t,At)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Ot),K(Ot,St),J(i,St)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(3===r)return;if(0===r)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(jt,i,t.objectHandle);ze(e,t.featureIds,e=>this._boundingRectFeatureTest(t,e,n))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e);s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const o=this._edgeView;if(!o)return null;const n=o.hasObject(i);if(s){if(n){if(this.nodeCrossfadingEnabled){kt(r,this.getNodeOpacity(e))}return o.updateAllComponentMaterials(i,r,this.slicePlaneEnabled,t).catch(e=>this._logEdgeViewError(e,this.layer.title)),o.updateObjectVisibility(i,!0).catch(e=>this._logEdgeViewError(e,this.layer.title)),o.updateAllVerticalOffsets(i,e.elevationOffsets).catch(e=>this._logEdgeViewError(e,this.layer.title)),o}const s=await this._collection.addEdges(i,o,r,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,o}return n&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,o.removeObject(i)),null}_applyFiltersToNode(e){const{filteredIds:t,weaklyRemovedIds:i}=e,s=this._applyFiltersToNodeComponents(e);return this._updateFilteredIdCounts(e,t,i),s&&this._labeler?.applyFilterChange(e),s}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(null!=e.filteredIds&&e.appliedFilters===this._filters||(e.weaklyRemovedIds=null,e.filteredIds=Kt(e,this._filters),e.appliedFilters=this._filters),s&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every(e=>!this._mismatchHide?.has(e))))return!r;const o=Qt(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach((t,i)=>this._removeNodeStageData(i,e)),this._nodeId2MetaReloading.forEach((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading)),this._elevationTask=a(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.layer.title)),this._visibleGeometryChanged(s,1),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights?.objectDeleted(s),i===this._nodeId2Meta?(this._updateFeatureIdCounts(s,-1),this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.removeTexture(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&i.objectHandle.updateMaterial({polygonOffset:0===t?1:0})}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=We(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.layer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await ce()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:o.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.symbols)"mesh-3d"!==t.type&&o.getLogger(this).error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=i*e.cachedSymbologyStride;N(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255);const o=this._stage.renderView.olidRenderHelper;if(o){const t=e.featureIds[i],r=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,n=de(this.view,this.uid);o.setUidToObjectAndLayerId(t,t,this.layerId,r,this.layerPopupEnabledAndHasTemplate&&!n,e.node.resources.attributes,i,this.sublayerId),s.olidColor=o.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:r})}s.externalColorMixMode=15&t[r+4],s.castShadows=!!(16&t[r+4]),s.pickable=!!(32&t[r+4]),s.elevationOffset=e.elevationOffsets?.[i]??0,s.emissiveStrength=e.emissiveStrengths?.[i]??1,s.emissiveSource=e.emissiveSources?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ue))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=Ke(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?oe(this.layer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=e.featureIds?this.layer.objectIdField:null,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=ie(e.featureIds.length*e.cachedSymbologyStride));const d=new et,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,g=1,m=Qe,_=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=Ee(l[e],f);const r=s?this._getSymbolInfo(s,t):null;let h,p;if(d.pickable=!0,s&&"visualVariables"in s){if(this._colorVariable){const e=ae(this._colorVariable,t,{color:Ft,arcade:this._arcade});e&&(h=d.color,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,h[3]=e.a??1,this._opacityVariable||null===e.a||(p=e.a))}this._opacityVariable&&(p=le(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?Me(h,p,e.color,e.alpha,Mt,d.color):Me(h,p,null,null,Mt,d.color)}h??=N(d.color,1,1,1,1);const y=r?.material;if(d.colorMixMode=y?.colorMixMode??1,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=3),d.pickable&&=h[3]>=Ct,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||3===d.colorMixMode)?1:0;d.edgeMaterial===u&&t===g||(m={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,g=t),e.cachedEdgeMaterials[f]=m}else e.cachedEdgeMaterials[f]=Qe;e.cachedSymbology[_++]=Math.round(255*h[0]),e.cachedSymbology[_++]=Math.round(255*h[1]),e.cachedSymbology[_++]=Math.round(255*h[2]),e.cachedSymbology[_++]=Math.round(255*h[3]),e.cachedSymbology[_++]=d.colorMixMode|+d.castShadows<<4|+d.pickable<<5;const b=y?.emissive?.strength??yt;b===yt||e.emissiveStrengths||(e.emissiveStrengths=new Array(e.featureIds.length).fill(yt)),e.emissiveStrengths&&(e.emissiveStrengths[f]=b);const v=y?.emissive?.source||0;0===v||e.emissiveSources||(e.emissiveSources=new Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[f]=v)}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||kt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some(e=>e!==Qe),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map((t,o)=>e.featureIds[o]!==i[s]?Qe:(r=r||t!==Qe,s++,t));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const{objectHandle:t}=e,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach(t=>{null!=t&&(this._collection.updateObjectOpacity(t.objectHandle,e),kt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))})}_updateMaterial(e){e.objectHandle.updateMaterial({slicePlaneEnabled:this.slicePlaneEnabled,usePBR:this._usePBR})}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,2)}intersect(e,t,i,s){this._intersectionHandler.intersectRay(e,t,i,s,null,!1)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._foreachMeta(t=>{t.objectHandle.updateMaterial({slicePlaneEnabled:e}),this._updateEdgeRendering(t,!1)})}_updatePBR(e){this._foreachMeta(t=>t.objectHandle.updateMaterial({usePBR:e})),this._hasLoadedPBRTextures=!0}_foreachMeta(e){this._nodeId2Meta.forEach(t=>{null!=t&&e(t)})}get _usePBR(){return this._imShading&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?0:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values())if(!(null==s||t&&s.node.serviceMbsInIndexSR&&1===t(s.node.serviceMbsInIndexSR)))switch(i){case 1:this._forAllFeaturesOfNode(s,e);break;case 0:this._forAllVisibleFeaturesOfNode(s,e);break;case 2:this._forAllQueryableFeaturesOfNode(s,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((i,s)=>t(i,s,e))}_forAllVisibleFeaturesOfNode(e,t){const i=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,s=>0===t(i[s],s,e))}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(0===s)return;if(3===s)return this._forAllFeaturesOfNode(e,i);const r=e.featureIds,o=e.objectHandle,n=Je(this._renderClippingArea,this._collection.getObjectTransform(o));for(let a=0;a<r.length;a++)this._boundingRectFeatureTest(e,a,n)&&i(r[a],a,e)}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=Ee(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){const s=it(e);if(0===s.length)return st;const r=vt(t),o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return st;const n=this._ensureHighlights(),{set:a,handle:l}=n.acquireSet(r);return n.setFeatureIds(a,o),l}_featureIdsFromGraphics(e){const t=this.layer.fieldsIndex,i=this._getObjectIdField();return e.map(e=>tt(t,e.attributes,i))}_ensureHighlights(){return this._highlights??=new we({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=a(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=m(()=>{const{node:t}=e,i=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(null!=i){const e=$();i.toAaBoundingBox(e),this.emit("visible-geometry-changed",new me(e))}else this.emit("visible-geometry-changed");this._visibleGeometryChangedSchedulerHandle=null})),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}get performanceInfo(){return new fe(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}checkInvariants(){}get test(){}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getObjectOpacity(e.objectHandle):0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateObjectOpacity(e.objectHandle,t),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;kt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch(e=>this._logEdgeViewError(e,this.layer.title))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Pt(e);if(s){const t={context:i,buffer:s.buffer};be(t);const r=new Float64Array(s.buffer);e.forAll((e,t)=>{const i=r[t],s=ve(i);e.imModificationImpact=s,0!==s&&this._controller.invalidateGeometryVisibility(e.index)})}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.readyToRun||this._needFilterResolve||this._compressionTracker.compressing}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>s(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)}),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||0===this.elevationInfo.mode)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=H(),a=H(),l=(e,t)=>{A(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),A(e,e,D(a,a,t)),T(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)1!==t&&2!==t||r.events.remove(i),0!==t&&2!==t||r.events.add(i,s)}_logEdgeViewError(e,t){h(e)||o.getLogger(this).warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>Rt?(o.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([p()],te.prototype,"_hasLoadedPBRTextures",void 0),e([p()],te.prototype,"_asyncModuleLoading",void 0),e([p()],te.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([p()],te.prototype,"view",void 0),e([p()],te.prototype,"layer",void 0),e([p()],te.prototype,"_controller",void 0),e([p()],te.prototype,"_labeler",void 0),e([p()],te.prototype,"updating",void 0),e([p()],te.prototype,"suspended",void 0),e([p()],te.prototype,"contentVisible",null),e([p({readOnly:!0})],te.prototype,"legendEnabled",null),e([p(ht)],te.prototype,"updatingProgress",void 0),e([p()],te.prototype,"updatingProgressValue",null),e([p()],te.prototype,"hasTexturesOrVertexColors",null),e([p()],te.prototype,"rendererTextureUsage",null),e([p()],te.prototype,"elevationOffset",null),e([p()],te.prototype,"elevationInfo",null),e([p({type:Boolean})],te.prototype,"slicePlaneEnabled",void 0),e([p()],te.prototype,"supportedTextureEncodings",null),e([p({type:[ne]})],te.prototype,"_modifications",void 0),e([p({readOnly:!0})],te.prototype,"clientGeometry",null),e([p()],te.prototype,"elevationRange",null),e([p()],te.prototype,"fullExtent",null),e([p()],te.prototype,"_elevationTask",void 0),e([p({readOnly:!0})],te.prototype,"_usePBR",null),te=e([y("esri.views.3d.layers.I3SMeshView3D")],te),te},Ot=$(),St=Q(),jt=Q(),Vt=new lt,Ft=new t([0,0,0,0]),At=new te(0,0,0,0);function Dt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Tt(e){return"geometryData"in e}function Ht(e){return null!=e&&f(e.data)}function Nt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&f(s.data)&&(i+=s.data.byteLength);return i}function Pt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll(e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Vt,e.serviceMbsInIndexSR?(t.setCenter(e.serviceMbsInIndexSR.center),t.setHalfSizeFromValues(e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius)):t.invalidate());const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]}),i}class Ut{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function kt(e,t){e.forEach(e=>e.opacity=t)}class Gt{constructor(e,t){this.mode=e,this.offset=t}}const Lt=H(),Bt=$(),qt="elevation-change",zt="",$t="@null",Wt="@ECEF";function Kt(e,t){const i=e.featureIds.slice();for(const s of t)if(s(i,e),0===i.length)break;return i.length===e.featureIds.length?e.featureIds:i}function Qt(e,t,i){const s=new Array,r=e.filteredIds;if(null==r||t?.size||i?.size){if(null!=r){let o=0;e.featureIds.forEach((e,n)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(n)})}}else e.featureIds.forEach((e,t)=>{r[s.length]===e&&s.push(t)});return s}function Jt(e,t,i){if(e&&t)for(const s of t){const t=(e.get(s)??0)+i;t>0?e.set(s,t):e.delete(s)}}function Yt(e,t=0){const i=new Map;for(const s of e){Jt(i,0===t?s?.featureIds:1===t?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}const Xt=H();export{Et as I3SMeshView3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{intersectsSphere as e}from"../../../../geometry/support/frustum.js";import{I3sTarget as r}from"./Intersector.js";import{IntersectorResultRay as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as s}from"../../webgl-engine/lib/verticalOffsetUtils.js";class i{constructor(e,r){this.node=e,this.objectHandle=r}}class l{constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isGround=e.isGround}updateElevationAlignState(e,r){this._needVerticalOffset=e&&1===r}intersectRay(e,i,l,c,a,d){const u=2===e.options.store,b=e.ray.direction;let h=e=>e,f=e=>e;const y=s(e.verticalOffset??(this._needVerticalOffset?0:null));null!=e.verticalOffset&&null!=y&&(h=e=>y.applyToMbs(e),f=e=>y.applyToObb(e));const{results:R,tolerance:m}=e,p=new n(m,d,e.options.normalRequired),v=e=>{if(0===e.childrenLoaded)return!1;const r=e.serviceObbInRenderSR?.isValid?e.serviceObbInRenderSR:null;return!(r&&!f(r).intersectRay(l,b,m))};for(const{node:n,objectHandle:s}of this._traverseNodeHierarchy(v)){const a=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null,{serviceMbsInRenderSRElevationAdjusted:d}=n;!s||!a&&d.isValid&&!o(h(d),l,b,m)||null!=n.geometryObbInRenderSR&&!f(n.geometryObbInRenderSR).intersectRay(l,b,m)||this._collection.intersectRay(s,l,c,y,p,(s,o,a,d,b)=>{if(o<0||null!=i&&!i(l,c,o))return;const h=e=>{const t=new r(this.layerViewUid,this.sublayerId,n.index,b,d);e.set(this.type,t,s,o,a)};if(this.isGround&&(null==R.ground.renderDistance||o<R.ground.renderDistance)&&h(R.ground),!e.options.isFiltered&&((null==R.min.renderDistance||o<R.min.renderDistance)&&h(R.min),(null==R.max.renderDistance||s>R.max.renderDistance)&&h(R.max),u)){const r=new t(e.ray);h(r),e.results.all.push(r)}})}}*intersectScreenPolygon(t,n){if(null==t.camera)return;const i=s(this._needVerticalOffset?0:null),l=r=>{if(0===r.childrenLoaded)return!1;const t=r.serviceObbInRenderSR?.isValid?r.serviceObbInRenderSR:null;if(null!=t){if(!t.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))return!1}else{const t=r.serviceMbsInRenderSRElevationAdjusted;if(t.isValid&&!e(n.broadPhaseFrustum,t))return!1}return!0};for(const{node:e,objectHandle:s}of this._traverseNodeHierarchy(l))null!=s&&s.visible&&(null==e.geometryObbInRenderSR||e.geometryObbInRenderSR.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))&&(this._collection.intersectScreenPolygon(s,t,n,i,(n,s,i,l)=>{t.polygonResults.add(this.type,new r(this.layerViewUid,this.sublayerId,e.index,n,l),s)}),yield)}}function o(e,r,t,n=0){const s=e.radius+n,i=r[0]-e.center[0],l=r[1]-e.center[1],o=r[2]-e.center[2],[c,a,d]=t,u=c*i+a*l+d*o;return u*u-(c*c+a*a+d*d)*(i*i+l*l+o*o-s*s)>=0}export{l as I3SIntersectionHandler,i as TraversedIntersectionNode};
2
+ import{intersectsSphere as e}from"../../../../geometry/support/frustum.js";import{I3sTarget as r}from"./Intersector.js";import{IntersectorResultRay as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as s}from"../../webgl-engine/lib/verticalOffsetUtils.js";class i{constructor(e,r){this.node=e,this.objectHandle=r}}class l{constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isGround=e.isGround}updateElevationAlignState(e,r){this._needVerticalOffset=e&&1===r}intersectRay(e,i,l,c,a,d){const u=2===e.options.store,b=e.ray.direction;let h=e=>e,f=e=>e;const y=s(e.verticalOffset??(this._needVerticalOffset?0:null));null!=e.verticalOffset&&null!=y&&(h=e=>y.applyToMbs(e),f=e=>y.applyToObb(e));const{results:R,tolerance:m}=e,p=new n(m,d,e.options.normalRequired),v=e=>{if(0===e.childrenLoaded)return!1;const r=e.serviceObbInRenderSR?.isValid?e.serviceObbInRenderSR:null;return!(r&&!f(r).intersectRay(l,b,m))};for(const{node:n,objectHandle:s}of this._traverseNodeHierarchy(v)){const a=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null,{serviceMbsInRenderSRElevationAdjusted:d}=n;!s||!a&&d.isValid&&!o(h(d),l,b,m)||null!=n.geometryObbInRenderSR&&!f(n.geometryObbInRenderSR).intersectRay(l,b,m)||this._collection.intersectRay(s,l,c,y,p,(s,o,a,d,b)=>{if(o<0||null!=i&&!i(l,c,o))return;const h=e=>{const t=new r(this.layerViewUid,this.sublayerId,n.index,b,d);e.set(this.type,t,s,o,a)};if(this.isGround&&(null==R.ground.renderDistance||o<R.ground.renderDistance)&&h(R.ground),!e.options.isFiltered&&((null==R.min.renderDistance||o<R.min.renderDistance)&&h(R.min),(null==R.max.renderDistance||s>R.max.renderDistance)&&h(R.max),u)){const r=new t(e.ray);h(r),e.results.all.push(r)}})}}*intersectScreenPolygon(t,n){if(null==t.camera)return;const i=s(this._needVerticalOffset?0:null),l=r=>{if(0===r.childrenLoaded)return!1;const t=r.serviceObbInRenderSR?.isValid?r.serviceObbInRenderSR:null;if(null!=t){if(!t.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))return!1}else{const t=r.serviceMbsInRenderSRElevationAdjusted;if(t.isValid&&!e(n.broadPhaseFrustum,t))return!1}return!0};for(const{node:e,objectHandle:s}of this._traverseNodeHierarchy(l))null!=s&&s.visible&&(null==e.geometryObbInRenderSR||e.geometryObbInRenderSR.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))&&(yield*this._collection.intersectScreenPolygon(s,t,n,i,(n,s,i,l)=>{t.polygonResults.add(this.type,new r(this.layerViewUid,this.sublayerId,e.index,n,l),s)}))}}function o(e,r,t,n=0){const s=e.radius+n,i=r[0]-e.center[0],l=r[1]-e.center[1],o=r[2]-e.center[2],[c,a,d]=t,u=c*i+a*l+d*o;return u*u-(c*c+a*a+d*d)*(i*i+l*l+o*o-s*s)>=0}export{l as I3SIntersectionHandler,i as TraversedIntersectionNode};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{normalize as e,sub as t,dot as i,scaleAndAdd as s,set as n,equals as r,subtract as o,len as a,sqrDist as c,copy as u,scale as l,dist as d,distance as h,length as m,squaredLength as _,squaredDistance as f,add as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as R}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as S}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as b}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as g}from"../../../../geometry/projection/projectors.js";import{create as M,fromMatrix as x,intersectsSphere as I,createPoints as C}from"../../../../geometry/support/frustum.js";import{signedDistance as E,getNormal as D}from"../../../../geometry/support/plane.js";import{isPlateCarree as P}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as A}from"../../../../geometry/support/sphere.js";import{evaluateElevationAlignmentAtPoint as O}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as F}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as V,extractExpressionInfo as j}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as B}from"./I3SUtil.js";import{SphereCylinderLocal as w,SphereConeGlobal as L}from"./SphereCone.js";import{Obb as y,computeOffsetObb as U}from"../../support/orientedBoundingBox.js";const z=1e5;class q{get _frustumMbsCenter(){return this._frustumMbs.center}get _frustumMbsRadius(){return this._frustumMbs.radius}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=M(),this._frustumMbs=new A,this._viewDirection=v(),this._useFrustumCulling=!1,this._poi=v(),this._cameraPOIDirection=v(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=S(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||P(u)),this._indexSREllipsoidRadius=R(this._indexSR).radius,this._indexSRSphericalPCPF=S(e),this._projectorIndexSRToIndexSRSphericalPCPF=g(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=F.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(V(j(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,e(this._viewDirection,n.viewForward),r){x(n.viewMatrix,n.projectionMatrix,this._frustum,N);{const e=n.eye,r=T;t(r,N[4],e);const o=.5*i(r,r)/i(this._viewDirection,r),a=this._frustumMbs,c=a.center;s(c,e,this._viewDirection,o);const u=1+o;a.radius=u}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this._updateCameraPOIDirection(),this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground",r=this._elevationProvider;if(r.getSphereElevationRange){const e=r.getSphereElevationRange(s,this._indexSR,n);if(e)return void i.expandElevationRange(e)}const[o,a,c]=s.center,u=r.getElevation(o,a,c,this._indexSR,n);u&&i.expandElevationRangeValues(u,u);const l=t?null:r.getRootElevationRange?.();l&&i.expandElevationRange(l)}calculateServiceMbsInRenderSR(e){const{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e;if(!i?.isValid)return t;const s=ie;return b(i,this._indexSR,s,this._renderSR),e.updateServiceMbsInRenderSR(s)}calculateServiceMbsInRenderSRElevationAdjusted(e){const{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e,s=this.calculateServiceMbsInRenderSR(e);if(!s.isValid||!i?.isValid)return t;const n=ie;n.copyFrom(s);const{_elevationContext:r}=this;if(r){const{minElevation:t}=e,{_renderCoordsHelper:s}=this,o=i.center;let a=0;if(Number.isFinite(t)){let i=0,c=0;const{maxElevation:u}=e,l=o[2];switch(r.mode){case"relative-to-ground":case"relative-to-scene":i=r.geometryZWithOffset(l,s)+t-l,c=u-t;break;case"on-the-ground":i=t-l,c=u-t}a=i+.5*c,n.radius+=.5*c}else n.radius<z&&(a=O(o,this._elevationProvider,r,s)-o[2]);a&&ae(n,a,this._viewingMode)}return e.updateServiceMbsInRenderSRElevationAdjusted(n)}calculateMbsConeInRenderSR(e){const{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;const{minElevation:i,maxElevation:s}=e;if(!(Number.isFinite(i)&&i<s))return null;const n=this.calculateServiceMbsInRenderSR(e);if(!n.isValid)return null;const r=this._renderCoordsHelper.referenceEllipsoid.radius,o=2===this._viewingMode?new w(n,i,s):new L(n,r+i,r+s);return e.updateMbsConeInRenderSR(o)}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new y,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const r=i.radius;let o=0,a=0;const c=s.centerZ,u=this._renderCoordsHelper,l=this._elevationContext;if(l&&e.elevationRangeValid){const{minElevation:t,maxElevation:i}=e;switch(l.mode){case"relative-to-ground":case"relative-to-scene":o=l.geometryZWithOffset(c,u)+t-c,a=i-t;break;case"on-the-ground":o=t-c,a=i-t}}else if(l&&r<z){const e=n(Y,s.centerX,s.centerY,c);o=O(e,this._elevationProvider,l,u)-c}const d=a>0,h=d?X:t;return s.transform(h,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&U(h,0,a,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;if(!t)return null;const i=.2;return 2===this._viewingMode&&Math.max(t.halfSizeX,t.halfSizeY,t.halfSizeZ)>i*this._indexSREllipsoidRadius?null:(t.transform(X,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),X)}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){r(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(o(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),n=t.elevationAgnosticBoundingVolume;let r,o=-1;if(s){const t=Y;s.getCenter(t),e(t,t),r=t,s.getCorners(J);for(const s of J){e(s,s);const r=i(s,t);if(r<=0)return void n.invalidate();const a=Math.sqrt(Math.max(0,1-r*r));o=Math.max(o,a)}}else{const i=t.serviceMbsInRenderSR;if(!i.isValid)return void n.invalidate();const{center:s,radius:c}=i,u=a(s);if(u<c)return void n.invalidate();o=c/u,r=e(te,s)}n.set(r,o+ce)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(Y);e[2]=0;let s=0;const n=K;i.getCorners(J);for(const t of J){t[2]=0;const e=c(n,t);s=Math.max(s,e)}t.set(e,Math.sqrt(s))}else{const i=e.serviceMbsInRenderSR;if(i.isValid){const e=u(Y,i.center);e[2]=0,t.set(e,i.radius)}}}isNodeVisible(e){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling)return!0;const t=this.getAndUpdateVisibilityObbInRenderSR(e);return t?t.intersectsFrustumConservativeApproximation(this._frustum):I(this._frustum,this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||(1===this._viewingMode?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n)||!n.valid)return!1;const r=n.radius;if(r>.9)return!0;const o=this._frustumPlanes,a=this._frustumMbsCenter,c=n.getAxis(te),u=i(c,a),d=this._frustumMbsRadius,h=u-d,m=u+d;if(h<=0)return!0;const _=l(k,c,h),f=l(H,c,m),p=r/Math.sqrt(1-r*r);for(const v of o){const n=D(v),r=e(Z,n),o=i(r,c);if(Math.abs(1-o)<.01)continue;const a=Q;l(a,c,o),t(a,a,r),e(a,a);const u=$;s(u,_,a,h*p);if(E(v,u)<=0)continue;s(u,f,a,m*p);if(E(v,u)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e.radius;if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=a(n);if(r<=s)return!0;const o=e.getAxis(te),c=i(o,n);{const e=l(W,o,c);if(d(e,n)<s)return!0}const u=c/r;if(c<=0){return-u<s}const h=Math.sqrt(1-u*u);if(h<t)return!0;const m=s/r;return h*Math.sqrt(1-m*m)-m*u<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=J;if(t.getCorners(o),1===this._viewingMode){const t=e.getAxis(te),a=i(t,n),c=a-s,u=a+s;if(c<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=ee;if(l(o,n,c/r),E(e,o)<=0){s=!1;break}const a=ee;if(l(a,n,u/r),E(e,a)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=D(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=u(W,t);s[2]=0;const n=e.radius,r=e.getAxis(te);return d(s,r)<=n+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.intersectsFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==B(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.calcCameraDistanceAndUpdateMinmaxWithCone(e);return i<0?.5*Number.MAX_VALUE:t/i*this._screenSizeFactor}calcCameraDistanceAndUpdateMinmaxWithCone(e){const t=this.calculateMbsConeInRenderSR(e),i=t?.calculateSurfaceDistanceFromPoint(this._camPos)??this.calcCameraDistanceAndUpdateMinmax(e);return t&&this._updateMinMaxDistance(i),i}calcCameraDistanceAndUpdateMinmax(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),i=h(t.center,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const{center:s,radius:n}=this.calculateServiceMbsInRenderSRElevationAdjusted(e),r=t(K,s,this._camPos),o=(Math.abs(i(s,r))/m(s)+n)/m(r);return Math.min(1,o)}hasLOD(e){return 0!==e.lodMetric}_getDistanceGlobeMode(e,t){const s=m(t.center),n=m(e)-s;l(se,e,i(e,t.center)/_(e));const r=f(t.center,se),a=t.radius;if(r<=a*a)return Math.abs(n);{const r=l(se,t.center,1/s),c=l(ne,r,s-a*a/2/s),u=e,d=o(re,u,c),_=o(re,d,l(oe,r,i(r,d))),f=p(re,c,l(re,_,a/m(_)));let v=h(u,f);if(n>=2e5){const e=o(ne,u,f);let t=i(e,r)/m(e);t<.08&&(t=1e-4),v/=t}return v}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):G(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let i=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 2:{const i=this.calculateServiceMbsInRenderSRElevationAdjusted(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i.radius;return this._updateMinMaxDistance(r),e.maxError*t<=n}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case 4:return this.calcCameraDistanceAndUpdateMinmax(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(null==e)return 0;const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),s=t.center,n=i(s,this._cameraPOIDirection),r=n*n,o=_(s)-r;return Math.sqrt(o)-t.radius}distCameraToPOI(){return h(this._camPos,this._poi)}}function G(e,t){const i=e[0]-t.center[0],s=e[1]-t.center[1],n=e[2]-t.center[2],r=i*i+s*s,o=t.radius;if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const N=C(),T=v(),W=v(),k=v(),H=v(),Z=v(),X=new y,Y=v(),J=[v(),v(),v(),v(),v(),v(),v(),v()],K=v(),Q=v(),$=v(),ee=v(),te=v(),ie=new A,se=v(),ne=v(),re=v(),oe=v();function ae(e,t,i){if(2===i)e.center[2]+=t;else{const i=m(e.center);l(e.center,e.center,1+t/i)}}const ce=.001;export{q as default};
2
+ import{normalize as e,sub as t,dot as i,scaleAndAdd as n,length as s,set as r,equals as o,subtract as a,len as c,sqrDist as l,copy as u,scale as d,dist as h,distance as m,squaredLength as p,squaredDistance as _,add as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as S}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as R}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as g}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as C}from"../../../../geometry/projection/projectors.js";import{create as M,fromMatrix as b,intersectsSphere as x,createPoints as I}from"../../../../geometry/support/frustum.js";import{signedDistance as D,getNormal as P}from"../../../../geometry/support/plane.js";import{isPlateCarree as E}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as A}from"../../../../geometry/support/sphere.js";import{evaluateElevationAlignmentAtPoint as F}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as O}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as V,extractExpressionInfo as w}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as j}from"./I3SUtil.js";import{SweptSphereCylindricalVolume as L,SphereGlobal as B,SweptSphereConicalVolume as y}from"./SweptSphereVolume.js";import{Obb as T,computeOffsetObb as U}from"../../support/orientedBoundingBox.js";const H=1e5;class G{get _frustumMbsCenter(){return this._frustumMbs.center}get _frustumMbsRadius(){return this._frustumMbs.radius}get _frustumPlanes(){return this._frustum}constructor(e,t,i,n,s,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=s,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=M(),this._frustumMbs=new A,this._viewDirection=v(),this._useFrustumCulling=!1,this._poi=v(),this._cameraPOIDirection=v(),this._elevationContext=null,this.minCenterDistance=1/0,this.maxCenterDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,n);const l=this._renderCoordsHelper.spatialReference;this._renderSR=l,this._renderSRSphericalPCPF=R(l),this._isGlobalMode=l===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(l.isWebMercator||E(l)),this._indexSREllipsoidRadius=S(this._indexSR).radius,this._indexSRSphericalPCPF=R(e),this._projectorIndexSRToIndexSRSphericalPCPF=C(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=O.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(V(w(e,!1)))):this._elevationContext=null}updateCamera(s,r){if(this._useFrustumCulling=r,e(this._viewDirection,s.viewForward),r){b(s.viewMatrix,s.projectionMatrix,this._frustum,W);{const e=s.eye,r=q;t(r,W[4],e);const o=.5*i(r,r)/i(this._viewDirection,r),a=this._frustumMbs,c=a.center;n(c,e,this._viewDirection,o);const l=1+o;a.radius=l}}this._screenSizeFactor=1/(s.perScreenPixelRatio/2),this._camPos=s.eye,this._updateCameraPOIDirection(),this.minCenterDistance=1/0,this.maxCenterDistance=0}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const n=e.serviceMbsInIndexSR;if(!n)return;const s="relative-to-scene"===this._elevationContext.mode?"scene":"ground",r=this._elevationProvider;if(r.getSphereElevationRange){const e=r.getSphereElevationRange(n,this._indexSR,s);if(e)return void i.expandElevationRange(e)}const[o,a,c]=n.center,l=r.getElevation(o,a,c,this._indexSR,s);l&&i.expandElevationRangeValues(l,l);const u=t?null:r.getRootElevationRange?.();u&&i.expandElevationRange(u)}calculateServiceMbsInRenderSR(e){const{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e;if(!i?.isValid)return t;const n=ne;return g(i,this._indexSR,n,this._renderSR),e.updateServiceMbsInRenderSR(n)}calculateServiceMbsInRenderSRElevationAdjusted(e){const{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;const{serviceMbsInIndexSR:i}=e,n=this.calculateServiceMbsInRenderSR(e);if(!n.isValid||!i?.isValid)return t;const s=ne;s.copyFrom(n);const{_elevationContext:r}=this;if(r){const{minElevation:t}=e,{_renderCoordsHelper:n}=this,o=i.center;let a=0;if(Number.isFinite(t)){let i=0,c=0;const{maxElevation:l}=e,u=o[2];switch(r.mode){case"relative-to-ground":case"relative-to-scene":i=r.geometryZWithOffset(u,n)+t-u,c=l-t;break;case"on-the-ground":i=t-u,c=l-t}a=i+.5*c,s.radius+=.5*c}else s.radius<H&&(a=F(o,this._elevationProvider,r,n)-o[2]);a&&ce(s,a,this._viewingMode)}return e.updateServiceMbsInRenderSRElevationAdjusted(s)}_isGlobalMbsContainingPlanetCenter(e){return 1===this._viewingMode&&s(e.center)<=e.radius}calculateMbsConeInRenderSR(e){const{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;let{minElevation:i,maxElevation:n}=e;if(!(Number.isFinite(i)&&i<n))return null;const s=this.calculateServiceMbsInRenderSR(e);if(!s.isValid)return null;const r=this._elevationContext;if("relative-to-ground"===r?.mode||"relative-to-scene"===r?.mode){const t=e.serviceMbsInIndexSR;if(!t?.isValid)return null;const s=t.center[2],o=r.geometryZWithOffset(s,this._renderCoordsHelper);if(2===this._viewingMode)i+=o,n+=o;else{const e=o-s;i+=e,n+=e}}const o=this._renderCoordsHelper.referenceEllipsoid.radius,a=2===this._viewingMode?new L(s,i,n):this._isGlobalMbsContainingPlanetCenter(s)?new B(s,o+i,o+n):new y(s,o+i,o+n);return e.updateMbsConeInRenderSR(a)}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:n}=e;if(null==n||!i||!n.isValid||this._isECEFOBBInLocalMode&&(n.halfSizeX>t||n.halfSizeY>t||n.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new T,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const s=i.radius;let o=0,a=0;const c=n.centerZ,l=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const{minElevation:t,maxElevation:i}=e;switch(u.mode){case"relative-to-ground":case"relative-to-scene":o=u.geometryZWithOffset(c,l)+t-c,a=i-t;break;case"on-the-ground":o=t-c,a=i-t}}else if(u&&s<H){const e=r(J,n.centerX,n.centerY,c);o=F(e,this._elevationProvider,u,l)-c}const d=a>0,h=d?Y:t;return n.transform(h,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&U(h,0,a,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;if(!t)return null;const i=.2;return 2===this._viewingMode&&Math.max(t.halfSizeX,t.halfSizeY,t.halfSizeZ)>i*this._indexSREllipsoidRadius?null:(t.transform(Y,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),Y)}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(1===this._viewingMode?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){o(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(a(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){const n=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),s=t.elevationAgnosticBoundingVolume;let r,o=-1;if(n){const t=J;n.getCenter(t),e(t,t),r=t,n.getCorners(K);for(const n of K){e(n,n);const r=i(n,t);if(r<=0)return void s.invalidate();const a=Math.sqrt(Math.max(0,1-r*r));o=Math.max(o,a)}}else{const i=t.serviceMbsInRenderSR;if(!i.isValid)return void s.invalidate();const{center:n,radius:a}=i,l=c(n);if(l<a)return void s.invalidate();o=a/l,r=e(ie,n)}s.set(r,o+fe)}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(J);e[2]=0;let n=0;const s=Q;i.getCorners(K);for(const t of K){t[2]=0;const e=l(s,t);n=Math.max(n,e)}t.set(e,Math.sqrt(n))}else{const i=e.serviceMbsInRenderSR;if(i.isValid){const e=u(J,i.center);e[2]=0,t.set(e,i.radius)}}}isNodeVisible(e){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling)return!0;const t=this.getAndUpdateVisibilityObbInRenderSR(e);return t?t.intersectsFrustumConservativeApproximation(this._frustum):x(this._frustum,this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(!e.valid||(1===this._viewingMode?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(s){if(!this._isConeVisibleInFrustumMbs(s)||!s.valid)return!1;const r=s.radius;if(r>pe)return!0;const o=this._frustumPlanes,a=this._frustumMbsCenter,c=s.getAxis(ie),l=i(c,a),u=this._frustumMbsRadius,h=l-u,m=l+u;if(h<=0)return!0;const p=d(Z,c,h),_=d(k,c,m),f=r/Math.sqrt(1-r*r);for(const v of o){const s=P(v),r=e(X,s),o=i(r,c);if(Math.abs(1-o)<_e)continue;const a=$;d(a,c,o),t(a,a,r),e(a,a);const l=ee;n(l,p,a,h*f);if(D(v,l)<=0)continue;n(l,_,a,m*f);if(D(v,l)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e.radius;if(t>pe)return!0;const n=this._frustumMbsRadius,s=this._frustumMbsCenter,r=c(s);if(r<=n)return!0;const o=e.getAxis(ie),a=i(o,s);{const e=d(N,o,a);if(h(e,s)<n)return!0}const l=a/r;if(a<=0){return-l<n}const u=Math.sqrt(1-l*l);if(u<t)return!0;const m=n/r;return u*Math.sqrt(1-m*m)-m*l<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(!e.valid)return!0;const n=this._frustumMbsRadius,s=this._frustumMbsCenter,r=this._frustumPlanes,o=K;if(t.getCorners(o),1===this._viewingMode){const t=e.getAxis(ie),a=i(t,s),c=a-n,l=a+n;if(c<=0)return!0;for(const e of r){let n=!0;for(const s of o){const r=i(s,t),o=te;if(d(o,s,c/r),D(e,o)<=0){n=!1;break}const a=te;if(d(a,s,l/r),D(e,a)<=0){n=!1;break}}if(n)return!1}}else{const e=s[2]-n,t=s[2]+n;for(const i of r){let n=!0;const s=P(i),r=s[0],a=s[1],c=s[2],l=i[3];for(const i of o){const s=r*i[0]+a*i[1]+l;if(s+c*e<=0||s+c*t<=0){n=!1;break}}if(n)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,n=u(N,t);n[2]=0;const s=e.radius,r=e.getAxis(ie);return h(n,r)<=s+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.intersectsFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||0!==j(this._clippingArea,e)}_screenSpaceDiameterMbs(e,t){const i=this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e);return i<0?le:t/i*this._screenSizeFactor}calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e){const t=this.calculateMbsConeInRenderSR(e);if(null==t)return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e);const i=t.calculateSurfaceDistanceFromPoint(this._camPos),n=t.calculateCenterDistanceFromPoint(this._camPos);return this._updateMinMaxDistanceToCenter(n),i}calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),i=m(t.center,this._camPos);return this._updateMinMaxDistanceToCenter(i),i}_calculateAngleDependentLoDForSphere(e,n){const r=t(Q,e,this._camPos),o=s(e),a=s(r);if(0===o||0===a)return 1;const c=(Math.abs(i(e,r))/o+n)/a;return Math.min(1,c)}calcAngleDependentLoD(e){const t=this.calculateMbsConeInRenderSR(e);if(null==t){const{center:t,radius:i}=this.calculateServiceMbsInRenderSRElevationAdjusted(e);return this._calculateAngleDependentLoDForSphere(t,i)}const{center:n,radius:r}=this.calculateServiceMbsInRenderSR(e);if(2===this._viewingMode)u(se,n),se[2]=t.lowerCenterHeight,u(re,n),re[2]=t.upperCenterHeight;else{const e=s(n);if(0===e)return 1;d(se,n,t.lowerCenterHeight/e),d(re,n,t.upperCenterHeight/e)}const o=this._calculateAngleDependentLoDForSphere(se,r),a=this._calculateAngleDependentLoDForSphere(re,r);if(2===this._viewingMode)u(oe,n),oe[2]=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,this._camPos[2]));else{const e=s(n);if(0===e)return Math.max(o,a);const r=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,i(this._camPos,n)/e));d(oe,n,r/e)}return Math.max(o,a,this._calculateAngleDependentLoDForSphere(oe,r))}hasLOD(e){return 0!==e.lodMetric}_getDistanceToSurfaceGlobeMode(e,t){const n=s(t.center),r=s(e)-n;d(se,e,i(e,t.center)/p(e));const o=_(t.center,se),c=t.radius;if(o<=c*c)return Math.abs(r);const l=d(se,t.center,1/n),u=d(re,l,n-c*c/(2*n)),h=a(oe,e,u),v=a(oe,h,d(ae,l,i(l,h))),S=f(oe,u,d(oe,v,c/s(v)));let R=m(e,S);if(r>=de){const t=a(re,e,S);let n=i(t,l)/s(t);n<he&&(n=me),R/=n}return R}_getDistanceToSurface(e,t){return this._isGlobalMode?this._getDistanceToSurfaceGlobeMode(e,t):z(e,t)}_applyGlobalFlatAngleCorrectionToConeDistance(e,t){t.calculateClosestCenterToPoint(this._camPos,ae);const n=s(ae);if(0===n)return e;if(s(this._camPos)-n<de)return e;const r=a(oe,this._camPos,ae),o=s(r);if(0===o)return e;const c=i(r,ae)/(o*n);return e/(c<he?me:c)}calculateScreenSpaceRelativeSphere(e){const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),i=this._getDistanceToSurface(this._camPos,t),n=i+t.radius;return this._updateMinMaxDistanceToCenter(n),2*i/this._screenSizeFactor}calculateScreenSpaceRelativeCone(e){const t=e.calculateCenterDistanceFromPoint(this._camPos);this._updateMinMaxDistanceToCenter(t);const i=e.calculateSurfaceDistanceFromPoint(this._camPos);return 2*(this._isGlobalMode?this._applyGlobalFlatAngleCorrectionToConeDistance(i,e):i)/this._screenSizeFactor}_updateMinMaxDistanceToCenter(e){e>0?(this.minCenterDistance=Math.min(this.minCenterDistance,e),this.maxCenterDistance=Math.max(this.maxCenterDistance,e)):(this.minCenterDistance=0,this.maxCenterDistance=Math.max(this.maxCenterDistance,-e))}getLodLevel(e){if(0===e.lodMetric)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let i=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case 2:{const i=this.calculateMbsConeInRenderSR(e),n=i?this.calculateScreenSpaceRelativeCone(i):this.calculateScreenSpaceRelativeSphere(e);return e.maxError*t<=n}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<ue;case 4:return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(null==e)return 0;const t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=t.center,s=i(n,this._cameraPOIDirection),r=s*s,o=p(n)-r;return Math.sqrt(o)-t.radius}distCameraToPOI(){return m(this._camPos,this._poi)}}function z(e,t){const i=e[0]-t.center[0],n=e[1]-t.center[1],s=e[2]-t.center[2],r=i*i+n*n,o=t.radius;if(r<=o*o)return Math.abs(s);const a=Math.sqrt(r)-o;return Math.sqrt(s*s+a*a)}const W=I(),q=v(),N=v(),Z=v(),k=v(),X=v(),Y=new T,J=v(),K=[v(),v(),v(),v(),v(),v(),v(),v()],Q=v(),$=v(),ee=v(),te=v(),ie=v(),ne=new A,se=v(),re=v(),oe=v(),ae=v();function ce(e,t,i){if(2===i)e.center[2]+=t;else{const i=s(e.center);if(0===i)return void(e.radius+=Math.abs(t));d(e.center,e.center,1+t/i)}}const le=.5*Number.MAX_VALUE,ue=10,de=2e5,he=.08,me=1e-4,pe=.9,_e=.01,fe=.001;export{G as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../../core/maybe.js";import i from"../../../../core/PooledArray.js";import{createScreenPointArray as s}from"../../../../core/screenUtils.js";import{property as r,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{subtract as o,length as a,scale as l,negate as h,dot as c,squaredLength as d,distance as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as m}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as _,offset as f,contains as P,containsPoint as x,set as b,positiveInfinity as S,equals as w}from"../../../../geometry/support/aaBoundingBox.js";import{create as R}from"../../../../geometry/support/plane.js";import{fromPoints as y}from"../../../../geometry/support/ray.js";import{Sphere as z}from"../../../../geometry/support/sphere.js";import{PclTarget as v}from"./Intersector.js";import{PointCloudHighlights as j}from"./PointCloudHighlights.js";import{isColor as q,isHighlight as F,isDepth as H}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as O}from"../../webgl-engine/effects/RenderPlugin.js";import{IntersectorResultRay as A}from"../../webgl-engine/lib/IntersectorResult.js";import{screenPolygonIntersectsCircle as E}from"../../webgl-engine/lib/screenPolygonOverlapUtils.js";import{VertexArrayObject as I}from"../../webgl-engine/lib/VertexArrayObject.js";import{P as B,g as M}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as D,positionsLayout as V,colorsLayout as N}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as T}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{PrimitiveType as C}from"../../../webgl/enums.js";import{VertexBuffer as U}from"../../../webgl/VertexBuffer.js";let W=class extends O{constructor(e){super(e),this.type=6,this.isGround=!1,this._passParameters=new B,this._highlights=new j({forEachNode:e=>this.forEachNode(e),addHighlights:(e,t,i)=>this._addHighlights(e,t,i),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.produces=new Map([[2,e=>q(e)||F(e)&&!this._highlights.empty],[3,e=>H(e)]]),this.point=g(),this.intersectionRayDir=g(),this.intersectionPlane=R(),this.nodeOriginOffset=g(),this.nodeBoundingBox=_(),this.layerViewUid="",this._slicePlaneEnabled=!1,this._configuration=new T,this._nodes=new i,this._highlightsInOrder=null}destroy(){this._nodes.prune()}hasHighlight(e){return this._highlights.has(e)}initializeRenderContext(e){this._context=e,e.requestRender()}uninitializeRenderContext(){}intersectRay(e,t,i,s){const{point:r,intersectionRayDir:n,nodeOriginOffset:u,intersectionPlane:p,layerViewUid:b,nodeBoundingBox:S}=this,w=y(i,s),R=this._passParameters,j=e.camera.perScreenPixelRatio/2,q=e.camera.near;o(n,s,i);const F=1/a(n);l(n,n,F);const H=g();h(H,n),m(p,n[0],n[1],n[2],-c(n,i));const O=new Y,E=new Y,I=new Array,B=_(R.clipBox);f(B,-i[0],-i[1],-i[2],B);const M=new J;this._nodes.forAll(a=>{const{isLeaf:l,coordinates:h}=a,g=a.splatSize*R.scaleFactor;let{min:m,max:_}=a.obb.signedDistanceRangePlane(p);m-=L(g,m+q,R,j,l),_-=L(g,_+q,R,j,l);const y=_<0,v=null!=O.dist&&null!=E.dist&&O.dist<m*F&&E.dist>_*F;if(y||v)return;const A=G(g,_+q,R,j,l);if(!new z(a.obb.getCenter($),a.obb.radius+A).intersectRay(w))return;if(!a.obb.intersectRay(i,n,A))return;const D=A*A;a.obb.toAaBoundingBox(S),f(S,-i[0],-i[1],-i[2],S);const V=!P(B,S);o(u,a.origin,i);const N=h.length/3;for(let o=0;o<N;o++){const p=3*o;if(r[0]=u[0]+h[p],r[1]=u[1]+h[p+1],r[2]=u[2]+h[p+2],V&&!x(B,r))continue;const m=c(r,n),_=m*m,f=d(r)-_;if(f>D)continue;const{distance:P,radius:S}=K(M,g,m+q,R,j,l),w=P-q;if(w<0)continue;if(f>S*S)continue;const y=w*F,z=e=>(e.point=e.point?Q(a,o,e.point):Q(a,o),e.dist=y,e.normal=H,e.node=a,e.pointId=o,e.layerViewUid=b,e);if((null==O.dist||y<O.dist)&&(null==t||t(i,s,y))&&z(O),0!==e.options.store&&(null==E.dist||y>E.dist)&&(null==t||t(i,s,y))&&z(E),2===e.options.store&&(null==t||t(i,s,y))){const e=new Y;I.push(z(e))}}});const D=e=>{const{layerViewUid:t,node:i,pointId:s}=e;return new v(e.point,t,s,()=>this.createGraphic(i,s,e.point))},V=(e,t)=>{const i=D(t);e.set(this.type,i,t.dist,t.dist,t.normal)};if(Z(O)){const t=e.results.min;(null==t.renderDistance||O.dist<t.renderDistance)&&V(t,O)}if(Z(E)&&0!==e.options.store){const t=e.results.max;(null==t.renderDistance||E.dist>t.renderDistance)&&V(t,E)}if(2===e.options.store)for(const o of I){const t=new A(w);V(t,o),e.results.all.push(t)}}*intersectScreenPolygon(e,t){const i=e.camera,{screenPolygonPrimitiveProcessor:s}=e,{point:r,layerViewUid:n,_nodes:a}=this,l=this._passParameters,h=i.perScreenPixelRatio/2,{eye:d,near:g,viewForward:_}=i,f=m(ie,_[0],_[1],_[2],-c(_,d)),P=new J,{bounds:x,broadPhaseFrustum:b}=t,{scaleFactor:S}=l;for(let m=0;m<a.length;++m){const w=a.data[m],{isLeaf:R,obb:y}=w,z=w.splatSize*S,j=k(l,R),q=G(z,Math.max(y.signedDistanceRangePlane(f).max,g),l,h,R);if(!y.intersectsFrustumConservativeApproximationWithMargin(b,q))continue;const{coordinates:F}=w,H=F.length/3;for(let a=0;a<H;a++){if(!s.validatePoint(Q(w,a,r)))continue;if(!i.projectToScreen(r,ee))continue;if(!X(x,ee,j))continue;const m=c(o(te,r,d),_),{distance:f,radius:b}=K(P,z,m,l,h,R);if(f<g)continue;const S=b/i.computeScreenPixelSizeAtDist(f);E(t,ee,S)&&e.polygonResults.add(this.type,new v(p(r),n,null,()=>this.createGraphic(w,a,r)),u(d,r))}yield}}acquireTechniques(e){const t=10===e.output;return 0!==this._nodes.length&&(q(e.output)||H(e.output)&&3===e.bind.slot||t)?(this._nodes.forAll(t=>this._initNode(e,t)),this._configuration.drawScreenSize=this._passParameters.drawScreenSpace,this._configuration.useFixedSizes=this._passParameters.useFixedSizes,this._configuration.hasSlicePlane=this._slicePlaneEnabled,this._configuration.hasOccludees=e.bind.hasOccludees,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.hasHighlightMixTexture=t&&null!=e.bind.highlightMixTexture,this._configuration.output=e.output,this._configuration.hasEmission=e.bind.hasEmission,this._context.techniques.get(D,this._configuration)):null}render(e,t){const{rctx:i,bind:s,output:r}=e,n=i.bindTechnique(t,s,this._passParameters),o=10===r,a=s.highlight?.name??null;o&&!a||(o&&s.highlights!==this._highlightsInOrder&&this._updateResolvedHighlights(s.highlights),this._nodes.forAll(t=>{const r=o?t.resolvedHighlightRanges.get(a):null;0===t.coordinates.length||null==t.vao||o&&null==r||(n.assertCompatibleVertexAttributeLocations(t.vao),n.bindDraw(s,this._passParameters,t),i.bindVAO(t.vao),o?this._renderHighlightFragments(e,r):i.drawArrays(C.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(e,t){const{rctx:i}=e;for(let s=0;s<t.length;s+=2)i.drawArrays(C.POINTS,t[s],t[s+1])}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){b(this._passParameters.clipBox,e||S)}get _clippingEnabled(){return!w(this._passParameters.clipBox,S,(e,t)=>e===t)}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),e.clearHighlights(),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let i=null;return this._nodes.filterInPlace(s=>s.id!==e||(i=s,s.vao=t(s.vao),this._highlights.nodeRemoved(s),!1)),this._requestRender(),i}forEachNode(e){this._nodes.forEach(e)}removeAll(){this._nodes.forAll(e=>e.vao=t(e.vao)),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e,t){return this._highlights.add(e,t)}_addHighlights(e,t,i){for(const s of t)e.addHighlight(s,i);this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_removeHighlight(e,t){e.removeHighlight(t),this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_initNode(e,t){t.vao??=new I(e.rctx,new Map([["positions",new U(e.rctx,V,t.coordinates)],["colors",new U(e.rctx,N,t.rgb)]]))}_requestRender(){this._context&&this._context.requestRender()}_updateResolvedHighlights(e){this._highlightsInOrder=e,this._nodes.forAll(t=>t.updateResolvedHighlights(e))}};function G(e,t,i,s,r){if(i.drawScreenSpace)return i.fixedSize*t*s;const n=M(r)*t*s;return i.useFixedSizes?Math.min(i.fixedSize/2,n):i.screenMinSize>0?Math.min(Math.max(i.screenMinSize*t*s,e/2),n):Math.min(e/2,n)}function L(e,t,i,s,r){return i.drawScreenSpace?0:G(e,t,i,s,r)}function k(e,t){return e.drawScreenSpace?e.fixedSize/2:M(t)/2}e([r({constructOnly:!0})],W.prototype,"createGraphic",void 0),W=e([n("esri.views.3d.layers.i3s.PointCloudRenderer")],W);class J{constructor(){this.distance=0,this.radius=0}}function K(e,t,i,s,r,n){const o=i-L(t,i,s,r,n);return e.distance=o,e.radius=G(t,o,s,r,n),e}function Q(e,t,i=g()){return i[0]=e.origin[0]+e.coordinates[3*t],i[1]=e.origin[1]+e.coordinates[3*t+1],i[2]=e.origin[2]+e.coordinates[3*t+2],i}function X(e,t,i){return t[0]>=e[0]-i&&t[0]<=e[2]+i&&t[1]>=e[1]-i&&t[1]<=e[3]+i}class Y{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}function Z(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}const $=g(),ee=s(),te=g(),ie=R();export{W as PointCloudRenderer};
2
+ import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../../core/maybe.js";import i from"../../../../core/PooledArray.js";import{createScreenPointArray as s}from"../../../../core/screenUtils.js";import{property as r,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{subtract as o,length as a,scale as l,negate as h,dot as c,squaredLength as d,distance as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as m}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as _,offset as f,contains as P,containsPoint as x,set as b,positiveInfinity as S,equals as w}from"../../../../geometry/support/aaBoundingBox.js";import{create as R}from"../../../../geometry/support/plane.js";import{fromPoints as y}from"../../../../geometry/support/ray.js";import{Sphere as z}from"../../../../geometry/support/sphere.js";import{PclTarget as v}from"./Intersector.js";import{PointCloudHighlights as j}from"./PointCloudHighlights.js";import{isColor as q,isHighlight as F,isDepth as H}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as O}from"../../webgl-engine/effects/RenderPlugin.js";import{IntersectorResultRay as A}from"../../webgl-engine/lib/IntersectorResult.js";import{screenPolygonIntersectsCircle as E}from"../../webgl-engine/lib/screenPolygonOverlapUtils.js";import{VertexArrayObject as I}from"../../webgl-engine/lib/VertexArrayObject.js";import{P as B,g as M}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as D,positionsLayout as V,colorsLayout as N}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as T}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{PrimitiveType as C}from"../../../webgl/enums.js";import{VertexBuffer as U}from"../../../webgl/VertexBuffer.js";let W=class extends O{constructor(e){super(e),this.type=6,this.isGround=!1,this._passParameters=new B,this._highlights=new j({forEachNode:e=>this.forEachNode(e),addHighlights:(e,t,i)=>this._addHighlights(e,t,i),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.produces=new Map([[2,e=>q(e)||F(e)&&!this._highlights.empty],[3,e=>H(e)]]),this.point=g(),this.intersectionRayDir=g(),this.intersectionPlane=R(),this.nodeOriginOffset=g(),this.nodeBoundingBox=_(),this.layerViewUid="",this._slicePlaneEnabled=!1,this._configuration=new T,this._nodes=new i,this._highlightsInOrder=null}destroy(){this._nodes.prune()}hasHighlight(e){return this._highlights.has(e)}initializeRenderContext(e){this._context=e,e.requestRender()}uninitializeRenderContext(){}intersectRay(e,t,i,s){const{point:r,intersectionRayDir:n,nodeOriginOffset:u,intersectionPlane:p,layerViewUid:b,nodeBoundingBox:S}=this,w=y(i,s),R=this._passParameters,j=e.camera.perScreenPixelRatio/2,q=e.camera.near;o(n,s,i);const F=1/a(n);l(n,n,F);const H=g();h(H,n),m(p,n[0],n[1],n[2],-c(n,i));const O=new Y,E=new Y,I=new Array,B=_(R.clipBox);f(B,-i[0],-i[1],-i[2],B);const M=new J;this._nodes.forAll(a=>{const{isLeaf:l,coordinates:h}=a,g=a.splatSize*R.scaleFactor;let{min:m,max:_}=a.obb.signedDistanceRangePlane(p);m-=L(g,m+q,R,j,l),_-=L(g,_+q,R,j,l);const y=_<0,v=null!=O.dist&&null!=E.dist&&O.dist<m*F&&E.dist>_*F;if(y||v)return;const A=G(g,_+q,R,j,l);if(!new z(a.obb.getCenter($),a.obb.radius+A).intersectRay(w))return;if(!a.obb.intersectRay(i,n,A))return;const D=A*A;a.obb.toAaBoundingBox(S),f(S,-i[0],-i[1],-i[2],S);const V=!P(B,S);o(u,a.origin,i);const N=h.length/3;for(let o=0;o<N;o++){const p=3*o;if(r[0]=u[0]+h[p],r[1]=u[1]+h[p+1],r[2]=u[2]+h[p+2],V&&!x(B,r))continue;const m=c(r,n),_=m*m,f=d(r)-_;if(f>D)continue;const{distance:P,radius:S}=K(M,g,m+q,R,j,l),w=P-q;if(w<0)continue;if(f>S*S)continue;const y=w*F,z=e=>(e.point=e.point?Q(a,o,e.point):Q(a,o),e.dist=y,e.normal=H,e.node=a,e.pointId=o,e.layerViewUid=b,e);if((null==O.dist||y<O.dist)&&(null==t||t(i,s,y))&&z(O),0!==e.options.store&&(null==E.dist||y>E.dist)&&(null==t||t(i,s,y))&&z(E),2===e.options.store&&(null==t||t(i,s,y))){const e=new Y;I.push(z(e))}}});const D=e=>{const{layerViewUid:t,node:i,pointId:s}=e;return new v(e.point,t,s,()=>this.createGraphic(i,s,e.point))},V=(e,t)=>{const i=D(t);e.set(this.type,i,t.dist,t.dist,t.normal)};if(Z(O)){const t=e.results.min;(null==t.renderDistance||O.dist<t.renderDistance)&&V(t,O)}if(Z(E)&&0!==e.options.store){const t=e.results.max;(null==t.renderDistance||E.dist>t.renderDistance)&&V(t,E)}if(2===e.options.store)for(const o of I){const t=new A(w);V(t,o),e.results.all.push(t)}}*intersectScreenPolygon(e,t,i){const s=e.camera,{screenPolygonPrimitiveProcessor:r}=e,{point:n,layerViewUid:a,_nodes:l}=this,h=this._passParameters,d=s.perScreenPixelRatio/2,{eye:g,near:_,viewForward:f}=s,P=m(ie,f[0],f[1],f[2],-c(f,g)),x=new J,{bounds:b,broadPhaseFrustum:S}=t,{scaleFactor:w}=h;for(let m=0;m<l.length;++m){const R=l.data[m],{isLeaf:y,obb:z}=R,j=R.splatSize*w,q=k(h,y),F=G(j,Math.max(z.signedDistanceRangePlane(P).max,_),h,d,y);if(!z.intersectsFrustumConservativeApproximationWithMargin(S,F))continue;const{coordinates:H}=R,O=H.length/3;for(let l=0;l<O;l++){if(i.done&&(i=yield),!r.validatePoint(Q(R,l,n)))continue;if(!s.projectToScreen(n,ee))continue;if(!X(b,ee,q))continue;const m=c(o(te,n,g),f),{distance:P,radius:S}=K(x,j,m,h,d,y);if(P<_)continue;const w=S/s.computeScreenPixelSizeAtDist(P);E(t,ee,w)&&e.polygonResults.add(this.type,new v(p(n),a,null,()=>this.createGraphic(R,l,n)),u(g,n))}i=yield}}acquireTechniques(e){const t=10===e.output;return 0!==this._nodes.length&&(q(e.output)||H(e.output)&&3===e.bind.slot||t)?(this._nodes.forAll(t=>this._initNode(e,t)),this._configuration.drawScreenSize=this._passParameters.drawScreenSpace,this._configuration.useFixedSizes=this._passParameters.useFixedSizes,this._configuration.hasSlicePlane=this._slicePlaneEnabled,this._configuration.hasOccludees=e.bind.hasOccludees,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.hasHighlightMixTexture=t&&null!=e.bind.highlightMixTexture,this._configuration.output=e.output,this._configuration.hasEmission=e.bind.hasEmission,this._context.techniques.get(D,this._configuration)):null}render(e,t){const{rctx:i,bind:s,output:r}=e,n=i.bindTechnique(t,s,this._passParameters),o=10===r,a=s.highlight?.name??null;o&&!a||(o&&s.highlights!==this._highlightsInOrder&&this._updateResolvedHighlights(s.highlights),this._nodes.forAll(t=>{const r=o?t.resolvedHighlightRanges.get(a):null;0===t.coordinates.length||null==t.vao||o&&null==r||(n.assertCompatibleVertexAttributeLocations(t.vao),n.bindDraw(s,this._passParameters,t),i.bindVAO(t.vao),o?this._renderHighlightFragments(e,r):i.drawArrays(C.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(e,t){const{rctx:i}=e;for(let s=0;s<t.length;s+=2)i.drawArrays(C.POINTS,t[s],t[s+1])}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){b(this._passParameters.clipBox,e||S)}get _clippingEnabled(){return!w(this._passParameters.clipBox,S,(e,t)=>e===t)}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),e.clearHighlights(),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let i=null;return this._nodes.filterInPlace(s=>s.id!==e||(i=s,s.vao=t(s.vao),this._highlights.nodeRemoved(s),!1)),this._requestRender(),i}forEachNode(e){this._nodes.forEach(e)}removeAll(){this._nodes.forAll(e=>e.vao=t(e.vao)),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e,t){return this._highlights.add(e,t)}_addHighlights(e,t,i){for(const s of t)e.addHighlight(s,i);this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_removeHighlight(e,t){e.removeHighlight(t),this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_initNode(e,t){t.vao??=new I(e.rctx,new Map([["positions",new U(e.rctx,V,t.coordinates)],["colors",new U(e.rctx,N,t.rgb)]]))}_requestRender(){this._context&&this._context.requestRender()}_updateResolvedHighlights(e){this._highlightsInOrder=e,this._nodes.forAll(t=>t.updateResolvedHighlights(e))}};function G(e,t,i,s,r){if(i.drawScreenSpace)return i.fixedSize*t*s;const n=M(r)*t*s;return i.useFixedSizes?Math.min(i.fixedSize/2,n):i.screenMinSize>0?Math.min(Math.max(i.screenMinSize*t*s,e/2),n):Math.min(e/2,n)}function L(e,t,i,s,r){return i.drawScreenSpace?0:G(e,t,i,s,r)}function k(e,t){return e.drawScreenSpace?e.fixedSize/2:M(t)/2}e([r({constructOnly:!0})],W.prototype,"createGraphic",void 0),W=e([n("esri.views.3d.layers.i3s.PointCloudRenderer")],W);class J{constructor(){this.distance=0,this.radius=0}}function K(e,t,i,s,r,n){const o=i-L(t,i,s,r,n);return e.distance=o,e.radius=G(t,o,s,r,n),e}function Q(e,t,i=g()){return i[0]=e.origin[0]+e.coordinates[3*t],i[1]=e.origin[1]+e.coordinates[3*t+1],i[2]=e.origin[2]+e.coordinates[3*t+2],i}function X(e,t,i){return t[0]>=e[0]-i&&t[0]<=e[2]+i&&t[1]>=e[1]-i&&t[1]<=e[3]+i}class Y{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}function Z(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}const $=g(),ee=s(),te=g(),ie=R();export{W as PointCloudRenderer};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{distance as e,length as t,normalize as r,scale as s,dot as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as a,create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";class h{constructor(e,t){if(this.lowerCenterHeight=e,this.upperCenterHeight=t,!(e<t))throw new Error(`Invalid elevated sphere: ${e}..${t}`)}}class c extends h{constructor(e,i,h){if(super(i,h),this.baseSphere=e,i<=0)throw new Error(`Invalid elevated sphere: ${i}..${h}`);const c=t(e.center);if(this._radialAxis=0===c?a(0,0,1):r(n(),e.center),0===c)return this._surfaceCenter=a(0,0,0),void(this._surfaceRadius=h+e.radius);this._surfaceCenter=s(n(),this._radialAxis,h),this._surfaceRadius=e.radius*h/c}clone(){return new c(this.baseSphere,this.lowerCenterHeight,this.upperCenterHeight)}calculateSurfaceDistanceFromPoint(t){return Math.max(0,e(this._surfaceCenter,t)-this._surfaceRadius)}calculateCenterDistanceFromPoint(t){return this.calculateClosestCenterToPoint(t,u),e(t,u)}calculateClosestCenterToPoint(e,r){if(0===t(this.baseSphere.center))return r[0]=0,r[1]=0,r[2]=0,r;const a=i(this._radialAxis,e),n=Math.max(this.lowerCenterHeight,Math.min(this.upperCenterHeight,a));return s(r,this._radialAxis,n),r}}class o extends h{constructor(e,s,i){if(super(s,i),this.baseSphere=e,s<=0)throw new Error(`Invalid elevated sphere: ${s}..${i}`);const a=t(e.center),h=e.radius;if(a<=h)throw new Error("Invalid sphere cone: base sphere contains the planet center");const c=s-a,o=i-a,l=a+h+Math.max(Math.abs(c),Math.abs(o));this._radialAxis=r(n(),e.center);const u=h/a,p=Math.sqrt(1-u**2),C=a+Math.min(c/(1-u),c/p),d=a+Math.max(o/(1+u),o/p);if(C<=0||C>=d)return this._lowerEnvelopeCenterHeight=s,this._upperEnvelopeCenterHeight=i,void(this._enclosingSphereRadius=l);this._lowerEnvelopeCenterHeight=C,this._upperEnvelopeCenterHeight=d,this._enclosingSphereRadius=null}clone(){return new o(this.baseSphere,this.lowerCenterHeight,this.upperCenterHeight)}calculateSurfaceDistanceFromPoint(r){const a=t(this.baseSphere.center),h=this.baseSphere.radius;if(null!=this._enclosingSphereRadius)return Math.max(0,t(r)-this._enclosingSphereRadius);const c=this._lowerEnvelopeCenterHeight,o=this._upperEnvelopeCenterHeight,l=this._radialAxis,u=h*c/a,p=h*o/a,C=a**2-h**2,d=C/a,f=d*(c/a),_=d*(o/a),S=i(l,r);if(S<=f-u)return this._calculateCapSphereSurfaceDistance(r,c,u);if(S>=_)return this._calculateCapSphereSurfaceDistance(r,o,p);const g=Math.sqrt(C),m=h*g/a,x=s(n(),l,S),w=e(x,r),H=m*S/d;if(w<=H)return 0;const M=g*(o/a),b=g*(S/d);return b<=g*(c/a)?this._calculateCapSphereSurfaceDistance(r,c,u):b>=M?this._calculateCapSphereSurfaceDistance(r,o,p):(w-H)*d/g}calculateCenterDistanceFromPoint(t){return this.calculateClosestCenterToPoint(t,u),e(t,u)}calculateClosestCenterToPoint(e,r){if(0===t(this.baseSphere.center))return r[0]=0,r[1]=0,r[2]=0,r;const a=i(this._radialAxis,e),n=Math.max(this.lowerCenterHeight,Math.min(this.upperCenterHeight,a));return s(r,this._radialAxis,n),r}_calculateCapSphereSurfaceDistance(t,r,i){const a=s(n(),this._radialAxis,r),h=e(a,t);return h<i?0:h-i}}class l extends h{constructor(e,t,r){super(t,r),this.baseSphere=e}clone(){return new l(this.baseSphere,this.lowerCenterHeight,this.upperCenterHeight)}calculateSurfaceDistanceFromPoint(e){const{center:t,radius:r}=this.baseSphere,s=e[2],i=(e[0]-t[0])**2+(e[1]-t[1])**2,{lowerCenterHeight:a,upperCenterHeight:n}=this;return s<=a?Math.max(0,Math.sqrt(i+(s-a)**2)-r):s>=n?Math.max(0,Math.sqrt(i+(s-n)**2)-r):Math.max(0,Math.sqrt(i)-r)}calculateCenterDistanceFromPoint(t){return this.calculateClosestCenterToPoint(t,u),e(t,u)}calculateClosestCenterToPoint(e,t){const{center:r}=this.baseSphere,s=Math.max(this.lowerCenterHeight,Math.min(this.upperCenterHeight,e[2]));return t[0]=r[0],t[1]=r[1],t[2]=s,t}}const u=n();export{c as SphereGlobal,o as SweptSphereConicalVolume,l as SweptSphereCylindricalVolume,h as SweptSphereVolume};
@@ -10,7 +10,6 @@ export default class MediaLayerInteractionReshapeOptions extends Accessor {
10
10
  * Indicates if the source point should be edited
11
11
  * when moving a control point. Only applies if the selected media element has a
12
12
  * [ControlPointsGeoreference](https://developers.arcgis.com/javascript/latest/references/core/layers/support/ControlPointsGeoreference/).
13
- * Only supported in 3D.
14
13
  *
15
14
  * @default false
16
15
  * @since 5.0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{lerp as e}from"../../../../core/mathUtils.js";import t from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as r,createRenderScreenPointArray3 as n,createScreenPointArray as i}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as s}from"../../../../core/units.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{add as c,normalize as a,dot as u,distance as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as y,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as p,copy as m,negativeInfinity as g,expandWithNestedArray as f}from"../../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as _}from"../../../../geometry/support/normalizeUtils.js";import{create as P}from"../../../../geometry/support/ray.js";import{sv3d as w}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as R}from"../../../../support/elevationInfoUtils.js";import{g as I}from"../../../../chunks/cameraUtilsSpherical.js";import{computeMapPointFromVec3d as v}from"../../support/hitTest.js";import{fromRenderAtEye as b,fromScreen as S}from"../../support/geometryUtils/ray.js";import{defaultTolerance as U,Intersector as j,defaultScreenPolygonPrimitiveProcessor as H}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as L,DrapedScreenPolygonIntersectionQuery as F}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as T}from"../../webgl-engine/lib/IntersectorResult.js";import{SliceScreenPolygonPrimitiveProcessor as x,createSliceExtrusionHalfspacePlanes as M,clipPolygonAgainstSlicedAwayHalfspaces as V,sliceFilterPredicate as D}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as E}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";import{TaskPriority as k}from"../../../support/Scheduler.js";class C{constructor(e,r,n){this.viewingMode=e,this._forEachLayer=r,this._view=n,this._externalIntersectionHandlers=new t,this._tolerance=U,this._tmpRay=P(),this._tmpRegion=p(),this._validateHUDIntersector=new j(this.viewingMode),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(k.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this._tmpRay),N(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,N(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,n){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,n),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,n=.5){return e.getRenderCenter(X,r,n),X[0]+=.0466,X[1]-=.0123,b(e,X,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,r)}async intersectIntersectorScreenPolygon(e,t,r){t.polygonResults.init();const n=this._view.state.camera,i=await E(n,e);null!=i&&await this._screenPolygonIntersectionTask.scheduleGenerator(()=>this._intersectIntersectorScreenPolygon(n,t,i,r))}*_intersectIntersectorScreenPolygon(e,t,r,n){const i=new Q(n,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!n||!("include"in n||"exclude"in n),t.camera=e,t.point=null,t.screenPolygonPrimitiveProcessor=H,yield*t.intersectScreenPolygon(i.layers,r);const s=this._view.slice.plane,o=s?new x(s):null;t.screenPolygonPrimitiveProcessor=o??H,yield*t.intersectScreenPolygon(i.sliceableLayers,r),t.screenPolygonPrimitiveProcessor=H,yield*this._intersectPolygonHandlersGenerator(t,i,r,null,o),yield*this._intersectDrapedScreenPolygon(t,i,r,n),yield*t.intersectHUDScreenPolygon(i.layers,r),t.screenPolygonPrimitiveProcessor=o??H,yield*t.intersectHUDScreenPolygon(i.sliceableLayers,r),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,r){const n=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(n,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,r);const n=t.results.min;!!this._view.basemapTerrain&&this._view.basemapTerrain.opaque||T(n)&&7!==n.intersector||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,r))}setTolerance(e=U){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}removeIntersectionHandler(e){null!=this._externalIntersectionHandlers.removeUnordered(e)&&this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}_getPickRay(e,t){const r=this._view.state.camera;return S(r,e,t)}_intersectRayFreePointLocal(e,t){return 2!==this.viewingMode||null==e||c(t,e.origin,a(w.get(),e.direction)),!1}intersectElevationFromScreen(e,t,r=0,n=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,r,n)}_intersectElevation(e,t,n=0,i=null){if(null==e)return null;const o=this._view,{renderCoordsHelper:l}=o,c=s(o.spatialReference),d=null!=t?t.mode:"absolute-height",y=R(t)/c,h=("on-the-ground"===d?0:y+n)*c/l.unitInMeters,{camera:p}=o.state;if("absolute-height"===d){const t=l?.getAltitude(p.eye),r=u(a(B,e.direction),l.worldUpAtPosition(p.eye,Y));if(t<h&&r<0||t>=h&&r>0)return null;if(l.intersectInfiniteManifold(e,h,B)){const e=v(o,B);return e.z??=0,e.z-=y,e}return null}const m=p.projectToRenderScreen(e.origin,r(w.get())),g=new Q(null,this._forEachLayer),f=o.slice.plane,_=f?D(f):null,P=new j(this.viewingMode);P.options.store=0,P.options.verticalOffset=h,P.options.normalRequired=!1;const I=this._createRayIntersectionQuery(e,m,!1);P.reset(I.beginPoint,I.endPoint,p),P.point=m;let b=null;if(i&&"type"in i&&"graphics"===i.type){const e=o.allLayerViews.find(e=>e.layer===i)?.uid;b=e?t=>t.layerViewUid===e:null}else i&&(b=e=>e.graphicUid!==i.uid);switch(d){case"relative-to-scene":{const e=e=>(!b||b(e))&&!!e.lastValidElevationBB;P.intersect(g.layers,I.screenPoint,this._tolerance,null,e),this._intersectRayHandlers(P,g,I,_,!1,e=>2===e.type||7===e.type||8===e.type,!1);break}case"on-the-ground":case"relative-to-ground":this._intersectRayHandlers(P,g,I,_,!1,e=>e.isGround,!1)}if(P.results.min.getIntersectionPoint(B)){const e=v(o,B);return e.z=n,e}return null}computeIntersection(e,t,n,i){if(null==e)return;const s=this._view.state.camera,o=s.projectToRenderScreen(e.origin,r(w.get())),l=new Q(i,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!i||!("include"in i||"exclude"in i);const c=this._createRayIntersectionQuery(e,o,n);t.reset(c.beginPoint,c.endPoint,s),t.intersect(l.layers,c.screenPoint,this._tolerance);const a=this._view.slice.plane,u=a?D(a):null;t.intersect(l.sliceableLayers,c.screenPoint,this._tolerance,u);const d=i&&(i.requiresGroundFeedback||i.enableDraped);this._intersectRayHandlers(t,l,c,u,!!d);const y=w.get(),h=this._view,p=h.basemapTerrain;if(i&&i.enableDraped&&null!=p.spatialReference&&t.results.ground.getIntersectionPoint(y)){const e=h.overlayManager.renderer,r=h.renderCoordsHelper.spatialReference,n=w.get();h.renderCoordsHelper.fromRenderCoords(y,n,p.spatialReference),n[2]=h.elevationProvider?.getElevation(y[0],y[1],y[2],r,"ground")??0,e.intersectRay(t,n,t.results.ground,e=>l.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){const t=e.results.hud;m(this._tmpRegion,g);const r=new Array,n=this._tmpRegion,i=e=>{r.push(new O(e))};e.sortResults(t.all),null!=t.min.distance&&i(t.min);for(const c of t.all)t.min.target.object!==c.target.object&&t.max.target.object!==c.target.object&&i(c);if(null!=t.max.distance&&t.max.target.object!==t.min.target.object&&i(t.max),!r.length)return;n[0]===n[2]&&(n[2]+=1),n[1]===n[3]&&(n[3]+=1);let s=!0;const o=null==e.results.max.distance;let l=0;for(const c of r)s&&(e.results.min.copy(c.result),s=!1),o&&e.results.max.copy(c.result),2===e.options.store&&e.results.all.splice(l++,0,c.result)}_createRayIntersectionQuery(e,t,r){return new L(e.origin,c(y(),e.origin,e.direction),t,r)}_intersectRayHandlers(e,t,r,n,i,s=()=>!0,o=!0){const{options:l}=e,c=l.isFiltered,a=l.filteredLayerViewUids;for(const{handler:u,filterPredicate:d,isFiltered:y,filteredLayerViewUids:h}of this._getFilteredIntersectionHandlers(t,n,null,s,o))(!y||u.isGround&&i)&&(l.isFiltered=y,l.filteredLayerViewUids=h,u.intersectRay(e,d,e.rayBegin,e.rayEnd,r.screenPoint,r.isVerticalRay));l.isFiltered=c,l.filteredLayerViewUids=a}*_intersectPolygonHandlersGenerator(e,t,r,n,i,s=()=>!0,o=!0){const{options:l}=e,c=l.isFiltered,a=l.filteredLayerViewUids,u=e.screenPolygonPrimitiveProcessor;for(const{handler:d,screenPolygonPrimitiveProcessor:y,isFiltered:h,filteredLayerViewUids:p}of this._getFilteredIntersectionHandlers(t,n,i,s,o))h||null==d.intersectScreenPolygon||(l.isFiltered=h,l.filteredLayerViewUids=p,e.screenPolygonPrimitiveProcessor=y??H,yield*d.intersectScreenPolygon(e,r));l.isFiltered=c,l.filteredLayerViewUids=a,e.screenPolygonPrimitiveProcessor=u}*_intersectDrapedScreenPolygon(e,t,r,n){const{basemapTerrain:i,overlayManager:s}=this._view,o=null!=i.spatialReference&&!s.renderer.isEmpty;if(!e.options.selectionMode||!n?.enableDraped||!o)return;const l=yield*this._createDrapedPolygonIntersectionQueries(r,i.slicePlaneEnabled?this._view.slice.plane:null);null!=l&&(yield*this._view.overlayManager.renderer.intersectScreenPolygon(e,l,e=>t.filterRenderGeometry(e)))}*_createDrapedPolygonIntersectionQueries(t,r){const{state:{camera:{eye:n}},pointsOfInterest:i,basemapTerrain:s}=this._view,c=new Array,a=r?new Array:null,u=I(this._view,i.focus.renderLocation),y=_(s.spatialReference);let p=Number.POSITIVE_INFINITY,m=null;const g=B,f=Y,P=e=>{if(!this._intersectDrapedScreenPolygonPoint(g,f,e))return!1;const t=null!=m&&y?m+y.shortestSignedDiff(m,g[0]):g[0];return m=t,c.push(l(t,g[1])),a&&a.push(h(f)),p=Math.min(p,d(n,f)),!0},{points:w}=t,{length:R}=w;for(let l=0;l<R;l++){const t=w[l],r=w[(l+1)%R];for(let n=0;n<u;n++){const i=n/u;if(!P(0===n?t:o(J,e(t[0],r[0],i),e(t[1],r[1],i))))return null;yield}}if(!Number.isFinite(p))return null;if(null==r||!a)return[z(c,p)];const v=this._clipDrapedScreenPolygonIntersectionQueries(a,r,y,n);return v.length>0?v:null}_clipDrapedScreenPolygonIntersectionQueries(e,t,r,n){const i=new Array,s=M(t);for(const o of V(s,e)){const e=this._createDrapedQueryFromRenderPolygon(o,r,n);null!=e&&i.push(e)}return i.sort((e,t)=>e.distance-t.distance),i}_createDrapedQueryFromRenderPolygon(e,t,r){const{basemapTerrain:n,renderCoordsHelper:i}=this._view,s=new Array;let o=Number.POSITIVE_INFINITY,c=null;for(const a of e){if(!i.fromRenderCoords(a,K,n.spatialReference))return null;const e=null!=c&&t?c+t.shortestSignedDiff(c,K[0]):K[0];c=e,s.push(l(e,K[1])),o=Math.min(o,d(r,a))}return s.length>=3&&Number.isFinite(o)?z(s,o):null}_intersectDrapedScreenPolygonPoint(e,t,r){const n=this._getPickRay(r,this._tmpRay);if(null==n)return!1;const{renderCoordsHelper:i}=this._view;this._intersectGroundPoint(t,n,r)||i.intersectManifoldClosestSilhouette(n,0,t);const s=this._view.basemapTerrain;return!!i.fromRenderCoords(t,e,s.spatialReference)}_intersectGroundPoint(e,t,r){const n=this._view.state.camera,i=new Q(null,this._forEachLayer),s=new j(this.viewingMode);W[0]=r[0],W[1]=r[1],W[2]=0;const o=this._createRayIntersectionQuery(t,W,!1);return s.options.selectionMode=!0,s.options.store=0,s.options.normalRequired=!1,s.options.selectOpaqueTerrainOnly=!1,s.reset(o.beginPoint,o.endPoint,n),this._intersectRayHandlers(s,i,o,null,!0,e=>e.isGround,!1),s.results.ground.getIntersectionPoint(e)}*_getFilteredIntersectionHandlers(e,t,r,n=()=>!0,i=!0){for(const s of this._externalIntersectionHandlers){if(!n(s))continue;let o=!1;const l=[];if(i){const t=s.layerViewUid,r=s.sublayerId,n=Array.isArray(t),i=n?t:[t];let c=!1;for(const s of i)e.filterLayerViewUid(s,r)?c=!0:n&&l.push(s);o=!c}yield new G(s,s.slicePlaneEnabled?t:null,s.slicePlaneEnabled?r:null,o,l)}}}class O{constructor(e){this.result=e,this.screenPoint=n()}}class G{constructor(e,t,r,n,i){this.handler=e,this.filterPredicate=t,this.screenPolygonPrimitiveProcessor=r,this.isFiltered=n,this.filteredLayerViewUids=i}}let A;function N(e){return A&&A.viewingMode===e||(A=new j(e)),A}class Q{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){const{include:r,exclude:n}=this;if(null==e)return null==r&&null==n;const i=r instanceof Map?r.get(e)??!1:r?.has(e),s=n instanceof Map?n.get(e)??!1:n?.has(e);return(null==i||("boolean"==typeof i?i:null!=t&&i.has(t)))&&(null==s||!("boolean"==typeof s?s:null!=t&&s.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function q(e){return"object"==typeof e&&null!=e&&"intersectRay"in e}function z(e,t){return new F(e,f(p(g),e),t)}const B=y(),Y=y(),W=n(),J=i(),K=y(),X=n();export{C as SceneIntersectionHelper,q as isIntersectionHandler};
2
+ import{lerp as e}from"../../../../core/mathUtils.js";import t from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as r,createRenderScreenPointArray3 as n,createScreenPointArray as i}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as s}from"../../../../core/units.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{add as c,normalize as a,dot as u,distance as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as y,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as p,copy as g,negativeInfinity as m,expandWithNestedArray as f}from"../../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as _}from"../../../../geometry/support/normalizeUtils.js";import{create as P}from"../../../../geometry/support/ray.js";import{sv3d as w}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as R}from"../../../../support/elevationInfoUtils.js";import{g as I}from"../../../../chunks/cameraUtilsSpherical.js";import{computeMapPointFromVec3d as v}from"../../support/hitTest.js";import{fromRenderAtEye as b,fromScreen as S}from"../../support/geometryUtils/ray.js";import{defaultTolerance as U,Intersector as j,defaultScreenPolygonPrimitiveProcessor as H}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as L,DrapedScreenPolygonIntersectionQuery as T}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as F}from"../../webgl-engine/lib/IntersectorResult.js";import{SliceScreenPolygonPrimitiveProcessor as x,createSliceExtrusionHalfspacePlanes as M,clipPolygonAgainstSlicedAwayHalfspaces as V,sliceFilterPredicate as k}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as D}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";import{TaskPriority as E}from"../../../support/Scheduler.js";class C{constructor(e,r,n){this.viewingMode=e,this._forEachLayer=r,this._view=n,this._externalIntersectionHandlers=new t,this._tolerance=U,this._tmpRay=P(),this._tmpRegion=p(),this._validateHUDIntersector=new j(this.viewingMode),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(E.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}get screenPolygonIntersectionTask(){return this._screenPolygonIntersectionTask}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this._tmpRay),N(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,N(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,n){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,n),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,n=.5){return e.getRenderCenter(X,r,n),X[0]+=.0466,X[1]-=.0123,b(e,X,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,r)}async intersectIntersectorScreenPolygon(e,t,r){t.polygonResults.init();const n=this._view.state.camera,i=await D(n,e);null!=i&&await this._screenPolygonIntersectionTask.scheduleGenerator(e=>this._intersectIntersectorScreenPolygon(n,t,i,r,e))}*_intersectIntersectorScreenPolygon(e,t,r,n,i){const s=new Q(n,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!n||!("include"in n||"exclude"in n),t.camera=e,t.point=null,t.screenPolygonPrimitiveProcessor=H,yield*t.intersectScreenPolygon(s.layers,r);const o=this._view.slice.plane,l=o?new x(o):null;t.screenPolygonPrimitiveProcessor=l??H,yield*t.intersectScreenPolygon(s.sliceableLayers,r),t.screenPolygonPrimitiveProcessor=H,yield*this._intersectPolygonHandlersGenerator(t,s,r,null,l,void 0,!0,i),yield*this._intersectDrapedScreenPolygon(t,s,r,n),yield*t.intersectHUDScreenPolygon(s.layers,r),t.screenPolygonPrimitiveProcessor=l??H,yield*t.intersectHUDScreenPolygon(s.sliceableLayers,r),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,r){const n=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(n,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,r);const n=t.results.min;!!this._view.basemapTerrain&&this._view.basemapTerrain.opaque||F(n)&&7!==n.intersector||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,r))}setTolerance(e=U){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}removeIntersectionHandler(e){null!=this._externalIntersectionHandlers.removeUnordered(e)&&this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}_getPickRay(e,t){const r=this._view.state.camera;return S(r,e,t)}_intersectRayFreePointLocal(e,t){return 2!==this.viewingMode||null==e||c(t,e.origin,a(w.get(),e.direction)),!1}intersectElevationFromScreen(e,t,r=0,n=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,r,n)}_intersectElevation(e,t,n=0,i=null){if(null==e)return null;const o=this._view,{renderCoordsHelper:l}=o,c=s(o.spatialReference),d=null!=t?t.mode:"absolute-height",y=R(t)/c,h=("on-the-ground"===d?0:y+n)*c/l.unitInMeters,{camera:p}=o.state;if("absolute-height"===d){const t=l?.getAltitude(p.eye),r=u(a(B,e.direction),l.worldUpAtPosition(p.eye,Y));if(t<h&&r<0||t>=h&&r>0)return null;if(l.intersectInfiniteManifold(e,h,B)){const e=v(o,B);return e.z??=0,e.z-=y,e}return null}const g=p.projectToRenderScreen(e.origin,r(w.get())),m=new Q(null,this._forEachLayer),f=o.slice.plane,_=f?k(f):null,P=new j(this.viewingMode);P.options.store=0,P.options.verticalOffset=h,P.options.normalRequired=!1;const I=this._createRayIntersectionQuery(e,g,!1);P.reset(I.beginPoint,I.endPoint,p),P.point=g;let b=null;if(i&&"type"in i&&"graphics"===i.type){const e=o.allLayerViews.find(e=>e.layer===i)?.uid;b=e?t=>t.layerViewUid===e:null}else i&&(b=e=>e.graphicUid!==i.uid);switch(d){case"relative-to-scene":{const e=e=>(!b||b(e))&&!!e.lastValidElevationBB;P.intersect(m.layers,I.screenPoint,this._tolerance,null,e),this._intersectRayHandlers(P,m,I,_,!1,e=>2===e.type||7===e.type||8===e.type,!1);break}case"on-the-ground":case"relative-to-ground":this._intersectRayHandlers(P,m,I,_,!1,e=>e.isGround,!1)}if(P.results.min.getIntersectionPoint(B)){const e=v(o,B);return e.z=n,e}return null}computeIntersection(e,t,n,i){if(null==e)return;const s=this._view.state.camera,o=s.projectToRenderScreen(e.origin,r(w.get())),l=new Q(i,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!i||!("include"in i||"exclude"in i);const c=this._createRayIntersectionQuery(e,o,n);t.reset(c.beginPoint,c.endPoint,s),t.intersect(l.layers,c.screenPoint,this._tolerance);const a=this._view.slice.plane,u=a?k(a):null;t.intersect(l.sliceableLayers,c.screenPoint,this._tolerance,u);const d=i&&(i.requiresGroundFeedback||i.enableDraped);this._intersectRayHandlers(t,l,c,u,!!d);const y=w.get(),h=this._view,p=h.basemapTerrain;if(i&&i.enableDraped&&null!=p.spatialReference&&t.results.ground.getIntersectionPoint(y)){const e=h.overlayManager.renderer,r=h.renderCoordsHelper.spatialReference,n=w.get();h.renderCoordsHelper.fromRenderCoords(y,n,p.spatialReference),n[2]=h.elevationProvider?.getElevation(y[0],y[1],y[2],r,"ground")??0,e.intersectRay(t,n,t.results.ground,e=>l.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){const t=e.results.hud;g(this._tmpRegion,m);const r=new Array,n=this._tmpRegion,i=e=>{r.push(new O(e))};e.sortResults(t.all),null!=t.min.distance&&i(t.min);for(const c of t.all)t.min.target.object!==c.target.object&&t.max.target.object!==c.target.object&&i(c);if(null!=t.max.distance&&t.max.target.object!==t.min.target.object&&i(t.max),!r.length)return;n[0]===n[2]&&(n[2]+=1),n[1]===n[3]&&(n[3]+=1);let s=!0;const o=null==e.results.max.distance;let l=0;for(const c of r)s&&(e.results.min.copy(c.result),s=!1),o&&e.results.max.copy(c.result),2===e.options.store&&e.results.all.splice(l++,0,c.result)}_createRayIntersectionQuery(e,t,r){return new L(e.origin,c(y(),e.origin,e.direction),t,r)}_intersectRayHandlers(e,t,r,n,i,s=()=>!0,o=!0){const{options:l}=e,c=l.isFiltered,a=l.filteredLayerViewUids;for(const{handler:u,filterPredicate:d,isFiltered:y,filteredLayerViewUids:h}of this._getFilteredIntersectionHandlers(t,n,null,s,o))(!y||u.isGround&&i)&&(l.isFiltered=y,l.filteredLayerViewUids=h,u.intersectRay(e,d,e.rayBegin,e.rayEnd,r.screenPoint,r.isVerticalRay));l.isFiltered=c,l.filteredLayerViewUids=a}*_intersectPolygonHandlersGenerator(e,t,r,n,i,s=()=>!0,o=!0,l){const{options:c}=e,a=c.isFiltered,u=c.filteredLayerViewUids,d=e.screenPolygonPrimitiveProcessor;for(const{handler:y,screenPolygonPrimitiveProcessor:h,isFiltered:p,filteredLayerViewUids:g}of this._getFilteredIntersectionHandlers(t,n,i,s,o))p||null==y.intersectScreenPolygon||(c.isFiltered=p,c.filteredLayerViewUids=g,e.screenPolygonPrimitiveProcessor=h??H,yield*y.intersectScreenPolygon(e,r,l));c.isFiltered=a,c.filteredLayerViewUids=u,e.screenPolygonPrimitiveProcessor=d}*_intersectDrapedScreenPolygon(e,t,r,n){const{basemapTerrain:i,overlayManager:s}=this._view,o=null!=i.spatialReference&&!s.renderer.isEmpty;if(!e.options.selectionMode||!n?.enableDraped||!o)return;const l=yield*this._createDrapedPolygonIntersectionQueries(r,i.slicePlaneEnabled?this._view.slice.plane:null);null!=l&&(yield*this._view.overlayManager.renderer.intersectScreenPolygon(e,l,e=>t.filterRenderGeometry(e)))}*_createDrapedPolygonIntersectionQueries(t,r){const{state:{camera:{eye:n}},pointsOfInterest:i,basemapTerrain:s}=this._view,c=new Array,a=r?new Array:null,u=I(this._view,i.focus.renderLocation),y=_(s.spatialReference);let p=Number.POSITIVE_INFINITY,g=null;const m=B,f=Y,P=e=>{if(!this._intersectDrapedScreenPolygonPoint(m,f,e))return!1;const t=null!=g&&y?g+y.shortestSignedDiff(g,m[0]):m[0];return g=t,c.push(l(t,m[1])),a&&a.push(h(f)),p=Math.min(p,d(n,f)),!0},{points:w}=t,{length:R}=w;for(let l=0;l<R;l++){const t=w[l],r=w[(l+1)%R];for(let n=0;n<u;n++){const i=n/u;if(!P(0===n?t:o(J,e(t[0],r[0],i),e(t[1],r[1],i))))return null;yield}}if(!Number.isFinite(p))return null;if(null==r||!a)return[z(c,p)];const v=this._clipDrapedScreenPolygonIntersectionQueries(a,r,y,n);return v.length>0?v:null}_clipDrapedScreenPolygonIntersectionQueries(e,t,r,n){const i=new Array,s=M(t);for(const o of V(s,e)){const e=this._createDrapedQueryFromRenderPolygon(o,r,n);null!=e&&i.push(e)}return i.sort((e,t)=>e.distance-t.distance),i}_createDrapedQueryFromRenderPolygon(e,t,r){const{basemapTerrain:n,renderCoordsHelper:i}=this._view,s=new Array;let o=Number.POSITIVE_INFINITY,c=null;for(const a of e){if(!i.fromRenderCoords(a,K,n.spatialReference))return null;const e=null!=c&&t?c+t.shortestSignedDiff(c,K[0]):K[0];c=e,s.push(l(e,K[1])),o=Math.min(o,d(r,a))}return s.length>=3&&Number.isFinite(o)?z(s,o):null}_intersectDrapedScreenPolygonPoint(e,t,r){const n=this._getPickRay(r,this._tmpRay);if(null==n)return!1;const{renderCoordsHelper:i}=this._view;this._intersectGroundPoint(t,n,r)||i.intersectManifoldClosestSilhouette(n,0,t);const s=this._view.basemapTerrain;return!!i.fromRenderCoords(t,e,s.spatialReference)}_intersectGroundPoint(e,t,r){const n=this._view.state.camera,i=new Q(null,this._forEachLayer),s=new j(this.viewingMode);W[0]=r[0],W[1]=r[1],W[2]=0;const o=this._createRayIntersectionQuery(t,W,!1);return s.options.selectionMode=!0,s.options.store=0,s.options.normalRequired=!1,s.options.selectOpaqueTerrainOnly=!1,s.reset(o.beginPoint,o.endPoint,n),this._intersectRayHandlers(s,i,o,null,!0,e=>e.isGround,!1),s.results.ground.getIntersectionPoint(e)}*_getFilteredIntersectionHandlers(e,t,r,n=()=>!0,i=!0){for(const s of this._externalIntersectionHandlers){if(!n(s))continue;let o=!1;const l=[];if(i){const t=s.layerViewUid,r=s.sublayerId,n=Array.isArray(t),i=n?t:[t];let c=!1;for(const s of i)e.filterLayerViewUid(s,r)?c=!0:n&&l.push(s);o=!c}yield new G(s,s.slicePlaneEnabled?t:null,s.slicePlaneEnabled?r:null,o,l)}}}class O{constructor(e){this.result=e,this.screenPoint=n()}}class G{constructor(e,t,r,n,i){this.handler=e,this.filterPredicate=t,this.screenPolygonPrimitiveProcessor=r,this.isFiltered=n,this.filteredLayerViewUids=i}}let A;function N(e){return A&&A.viewingMode===e||(A=new j(e)),A}class Q{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){const{include:r,exclude:n}=this;if(null==e)return null==r&&null==n;const i=r instanceof Map?r.get(e)??!1:r?.has(e),s=n instanceof Map?n.get(e)??!1:n?.has(e);return(null==i||("boolean"==typeof i?i:null!=t&&i.has(t)))&&(null==s||!("boolean"==typeof s?s:null!=t&&s.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function q(e){return"object"==typeof e&&null!=e&&"intersectRay"in e}function z(e,t){return new T(e,f(p(m),e),t)}const B=y(),Y=y(),W=n(),J=i(),K=y(),X=n();export{C as SceneIntersectionHelper,q as isIntersectionHandler};