@arcgis/core 4.28.0-next.20231002 → 4.28.0-rc.0

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 (257) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/02120d192eafd7612475.js +1 -0
  3. package/assets/esri/core/workers/chunks/{4d967e98d229f18d61f5.js → 09e8babe75407c2e64c4.js} +1 -1
  4. package/assets/esri/core/workers/chunks/0beebbb0c6dad0e742d7.js +1 -0
  5. package/assets/esri/core/workers/chunks/0d8ca51043c7784aed96.js +1 -0
  6. package/assets/esri/core/workers/chunks/112e89da628bdea5355c.js +1 -0
  7. package/assets/esri/core/workers/chunks/{5e9edd06e624f385fa4b.js → 121a9e148509f2fe2210.js} +1 -1
  8. package/assets/esri/core/workers/chunks/1856d16d738f44f58084.js +1 -0
  9. package/assets/esri/core/workers/chunks/{0526d623d0b4c12929bd.js → 18ab9cc85a1a7988fdfd.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{7c960a2694c4c3123acf.js → 1a36703ebe934749646e.js} +1 -1
  11. package/assets/esri/core/workers/chunks/24a0cf405195421c0d06.js +1 -0
  12. package/assets/esri/core/workers/chunks/24ff267cf253feac22de.js +1 -0
  13. package/assets/esri/core/workers/chunks/{3c8613596659801fd6ab.js → 29cab345819ec02ed60a.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{169a61c6e128b8a16021.js → 2c560a075d9ef2069ed1.js} +1 -1
  15. package/assets/esri/core/workers/chunks/2f8e71dac98135bbc3e6.js +1 -0
  16. package/assets/esri/core/workers/chunks/341fb51b2165522963b3.js +1 -0
  17. package/assets/esri/core/workers/chunks/{ad8e0f82cb1feafa9e2f.js → 36ab90fb34b9716a9983.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{2688213bbff536da7917.js → 3ea0b872436fce84b927.js} +1 -1
  19. package/assets/esri/core/workers/chunks/40633064c290dc2af9ea.js +1 -0
  20. package/assets/esri/core/workers/chunks/42ec4c80b0c2944cd65c.js +1 -0
  21. package/assets/esri/core/workers/chunks/44b870cb53ba68b17c32.js +1 -0
  22. package/assets/esri/core/workers/chunks/{8a7fa4e8b0d14da7c9eb.js → 4cc680fe4c9c39d2f853.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{6730c9f0890191a95fdb.js → 4d81aa50d90f5701a343.js} +1 -1
  24. package/assets/esri/core/workers/chunks/4e0bf30da4281070e453.js +1 -0
  25. package/assets/esri/core/workers/chunks/4e6bf1efe3b0b474cbb4.js +1 -0
  26. package/assets/esri/core/workers/chunks/52cef7cd3aaaa4f45c94.js +1 -0
  27. package/assets/esri/core/workers/chunks/{4e04242e707c0eb3aa4a.js → 5a3ccc0a19ac8fa9e524.js} +1 -1
  28. package/assets/esri/core/workers/chunks/5e907ec0ee1565b5fbbc.js +1 -0
  29. package/assets/esri/core/workers/chunks/66ba749ab0a631bbfdec.js +1 -0
  30. package/assets/esri/core/workers/chunks/6b14d89d689a21014aec.js +1 -0
  31. package/assets/esri/core/workers/chunks/6b1856303d1562f05100.js +1 -0
  32. package/assets/esri/core/workers/chunks/{576269fd1f9049876aa1.js → 6b7b5544ed1f9a84623f.js} +1 -1
  33. package/assets/esri/core/workers/chunks/710a6268de62003af825.js +1 -0
  34. package/assets/esri/core/workers/chunks/77923afde29ae1ff10ca.js +1 -0
  35. package/assets/esri/core/workers/chunks/784ffd52315a4d55d683.js +1 -0
  36. package/assets/esri/core/workers/chunks/7cf7f2b991a7cbdad2ce.js +1 -0
  37. package/assets/esri/core/workers/chunks/{70dffbf49b0633b1a5f1.js → 8f3680fee85a05839489.js} +1 -1
  38. package/assets/esri/core/workers/chunks/97aecf210938015cc7a3.js +1 -0
  39. package/assets/esri/core/workers/chunks/{c7ebd5d431fb996bfcee.js → 9f8207c82a17508a87a8.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{557305b91f77569ce664.js → a01ffe03b1465c21b9e6.js} +1 -1
  41. package/assets/esri/core/workers/chunks/a298c9031962951e55a9.js +1 -0
  42. package/assets/esri/core/workers/chunks/{329669a9beda89b028dd.js → a5a7bbdd8298016535bc.js} +1 -1
  43. package/assets/esri/core/workers/chunks/a877a4826cd6a46ec99b.js +1 -0
  44. package/assets/esri/core/workers/chunks/ad38e456a7cee940a165.js +1 -0
  45. package/assets/esri/core/workers/chunks/adfbc168be8c49b51e1b.js +1 -0
  46. package/assets/esri/core/workers/chunks/b0526633a93ef69ec47b.js +1 -0
  47. package/assets/esri/core/workers/chunks/b99bc08a01e9250b0a31.js +1 -0
  48. package/assets/esri/core/workers/chunks/{36c4b4c3eca57417da2c.js → c260ad3434bb00ba64a7.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{39922ce232338de076ae.js → c459c8d8630eb4b955b1.js} +1 -1
  50. package/assets/esri/core/workers/chunks/c92e75b79aff7b505b31.js +1 -0
  51. package/assets/esri/core/workers/chunks/ca85e88dad30b5f2956b.js +1 -0
  52. package/assets/esri/core/workers/chunks/{8e56d40691b6bf75d7cc.js → ce409944221a784ddb61.js} +1 -1
  53. package/assets/esri/core/workers/chunks/d13f75f233cf313e5a1d.js +1 -0
  54. package/assets/esri/core/workers/chunks/d60d5f006375f7fcc88c.js +1 -0
  55. package/assets/esri/core/workers/chunks/{77958089748dc31757cf.js → d6ded127949160103f69.js} +1 -1
  56. package/assets/esri/core/workers/chunks/d8c696da42f8f8919b83.js +1 -0
  57. package/assets/esri/core/workers/chunks/{304c81f6297ecba3a324.js → d95eed98316e59f8f35d.js} +1 -1
  58. package/assets/esri/core/workers/chunks/df7267892b6e0493e1d7.js +1 -0
  59. package/assets/esri/core/workers/chunks/{52dca349e1a45555954d.js → e52d5a48e83d8df36f92.js} +1 -1
  60. package/assets/esri/core/workers/chunks/e8688b6cc3b3c1010b43.js +1 -0
  61. package/assets/esri/core/workers/chunks/e8c7cc974420c0b92d0e.js +1 -0
  62. package/assets/esri/core/workers/chunks/{b7ef554b1213307499fc.js → e93442c6d92229f3a4b0.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{ef5772ca1848d6d01b88.js → eda86faa708cfe4c9f9a.js} +1 -1
  64. package/assets/esri/core/workers/chunks/f2718e260f594537f7fd.js +1 -0
  65. package/assets/esri/core/workers/chunks/f6b7036114b1d754fdd9.js +1 -0
  66. package/assets/esri/core/workers/chunks/{c4631241dc777ca77aaa.js → f6c0680c535c5a3c73ee.js} +1 -1
  67. package/assets/esri/core/workers/chunks/{a0ea1d3e22d52b8a59a8.js → fa6103e3d4e857b0035b.js} +9 -9
  68. package/assets/esri/core/workers/chunks/fac3e57784d7f37053af.js +1 -0
  69. package/assets/esri/geometry/support/pe-wasm.wasm +0 -0
  70. package/assets/esri/t9n/common.json +1 -1
  71. package/assets/esri/t9n/common_ar.json +1 -1
  72. package/assets/esri/t9n/common_bg.json +1 -1
  73. package/assets/esri/t9n/common_bs.json +1 -1
  74. package/assets/esri/t9n/common_ca.json +1 -1
  75. package/assets/esri/t9n/common_cs.json +1 -1
  76. package/assets/esri/t9n/common_da.json +1 -1
  77. package/assets/esri/t9n/common_de.json +1 -1
  78. package/assets/esri/t9n/common_el.json +1 -1
  79. package/assets/esri/t9n/common_en.json +1 -1
  80. package/assets/esri/t9n/common_es.json +1 -1
  81. package/assets/esri/t9n/common_et.json +1 -1
  82. package/assets/esri/t9n/common_fi.json +1 -1
  83. package/assets/esri/t9n/common_fr.json +1 -1
  84. package/assets/esri/t9n/common_he.json +1 -1
  85. package/assets/esri/t9n/common_hr.json +1 -1
  86. package/assets/esri/t9n/common_hu.json +1 -1
  87. package/assets/esri/t9n/common_id.json +1 -1
  88. package/assets/esri/t9n/common_it.json +1 -1
  89. package/assets/esri/t9n/common_ja.json +1 -1
  90. package/assets/esri/t9n/common_ko.json +1 -1
  91. package/assets/esri/t9n/common_lt.json +1 -1
  92. package/assets/esri/t9n/common_lv.json +1 -1
  93. package/assets/esri/t9n/common_nb.json +1 -1
  94. package/assets/esri/t9n/common_nl.json +1 -1
  95. package/assets/esri/t9n/common_pl.json +1 -1
  96. package/assets/esri/t9n/common_pt-BR.json +1 -1
  97. package/assets/esri/t9n/common_pt-PT.json +1 -1
  98. package/assets/esri/t9n/common_ro.json +1 -1
  99. package/assets/esri/t9n/common_ru.json +1 -1
  100. package/assets/esri/t9n/common_sk.json +1 -1
  101. package/assets/esri/t9n/common_sl.json +1 -1
  102. package/assets/esri/t9n/common_sr.json +1 -1
  103. package/assets/esri/t9n/common_sv.json +1 -1
  104. package/assets/esri/t9n/common_th.json +1 -1
  105. package/assets/esri/t9n/common_tr.json +1 -1
  106. package/assets/esri/t9n/common_uk.json +1 -1
  107. package/assets/esri/t9n/common_vi.json +1 -1
  108. package/assets/esri/t9n/common_zh-CN.json +1 -1
  109. package/assets/esri/t9n/common_zh-HK.json +1 -1
  110. package/assets/esri/t9n/common_zh-TW.json +1 -1
  111. package/assets/esri/themes/base/widgets/_DirectionalPad.scss +2 -1
  112. package/assets/esri/themes/base/widgets/_FeatureForm.scss +0 -1
  113. package/assets/esri/themes/dark/main.css +1 -1
  114. package/assets/esri/themes/light/main.css +1 -1
  115. package/assets/esri/themes/light/view.css +1 -1
  116. package/chunks/pe-wasm.js +1 -1
  117. package/config.js +1 -1
  118. package/core/pbf.js +1 -1
  119. package/geometry/support/WKIDUnitConversion.js +1 -1
  120. package/geometry/support/plane.js +1 -1
  121. package/interfaces.d.ts +37 -39
  122. package/kernel.js +1 -1
  123. package/layers/GroupLayer.js +1 -1
  124. package/layers/SceneLayer.js +1 -1
  125. package/layers/graphics/data/QueryEngine.js +1 -1
  126. package/layers/graphics/data/QueryEngineResult.js +1 -1
  127. package/layers/graphics/editingSupport.js +1 -1
  128. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  129. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  130. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  131. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  132. package/layers/mixins/OperationalLayer.js +1 -1
  133. package/layers/save/featureLayerUtils.js +1 -1
  134. package/layers/save/groupLayerUtils.js +5 -0
  135. package/layers/save/utils.js +1 -1
  136. package/layers/support/LayerLoadContext.js +5 -0
  137. package/layers/support/featureLayerUtils.js +1 -1
  138. package/layers/support/labelFormatUtils.js +1 -1
  139. package/layers/support/layersCreator.js +1 -1
  140. package/layers/support/versionUtils.js +1 -1
  141. package/networks/UtilityNetwork.js +1 -1
  142. package/package.json +1 -1
  143. package/portal/schemas/definitions.js +1 -1
  144. package/portal/support/jsonContext.js +1 -1
  145. package/portal/support/layersLoader.js +1 -1
  146. package/portal/support/loadUtils.js +5 -0
  147. package/portal/support/portalItemUtils.js +1 -1
  148. package/portal/support/portalLayers.js +1 -1
  149. package/renderers/support/RasterSymbolizer.js +1 -1
  150. package/rest/print.js +1 -1
  151. package/support/basemapUtils.js +1 -1
  152. package/support/revision.js +1 -1
  153. package/symbols/PolygonSymbol3D.js +1 -1
  154. package/views/2d/engine/imagery/RasterBitmap.js +1 -1
  155. package/views/2d/engine/imagery/colorizer/shadedrelief.js +1 -1
  156. package/views/2d/engine/imagery/colorizer/stretch.js +1 -1
  157. package/views/2d/input/handlers/KeyPan.js +1 -1
  158. package/views/2d/input/handlers/KeyRotate.js +1 -1
  159. package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
  160. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  161. package/views/2d/layers/features/support/FeatureSetReaderPBFIndirect.js +1 -1
  162. package/views/3d/input/handlers/KeyboardNavigation.js +1 -1
  163. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  164. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  165. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  166. package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
  167. package/views/3d/layers/i3s/featureEditing.js +1 -1
  168. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  169. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  170. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  171. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  172. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  173. package/views/DOMContainer.js +1 -1
  174. package/views/draw/DrawGraphicTool.js +1 -1
  175. package/views/draw/DrawOperation.js +1 -1
  176. package/views/draw/support/Box.js +1 -1
  177. package/views/draw/support/Reshape.js +1 -1
  178. package/views/input/VisibilityChange.js +5 -0
  179. package/views/interactive/sketch/constraints.js +1 -1
  180. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  181. package/views/interactive/snapping/FeatureSnappingSourceInfo.js +5 -0
  182. package/views/interactive/snapping/SnappingContext.js +1 -1
  183. package/views/interactive/snapping/SnappingDragPipelineStep.js +1 -1
  184. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  185. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  186. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorkerHandle.js +1 -1
  187. package/views/interactive/snapping/snappingUtils.js +1 -1
  188. package/webdoc/support/saveUtils.js +1 -1
  189. package/webdoc/webdocSaveUtils.js +1 -1
  190. package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
  191. package/widgets/DirectionalPad/constants.js +1 -1
  192. package/widgets/DirectionalPad.js +1 -1
  193. package/widgets/Editor/Upload.js +1 -1
  194. package/widgets/Editor/workflowUtils.js +1 -1
  195. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  196. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  197. package/widgets/FeatureForm/FieldInput.js +1 -1
  198. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  199. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  200. package/widgets/FeatureForm.js +1 -1
  201. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  202. package/widgets/FeatureTable/FieldColumn.js +1 -1
  203. package/widgets/FeatureTable/Grid/Column.js +1 -1
  204. package/widgets/FeatureTable.js +1 -1
  205. package/widgets/ScaleRangeSlider.js +1 -1
  206. package/widgets/support/DatePicker.js +1 -1
  207. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  208. package/widgets/support/Selector2D/SelectionOperation2D.js +1 -1
  209. package/widgets/support/Selector2D.js +1 -1
  210. package/widgets/support/TimePicker.js +1 -1
  211. package/widgets/support/dateUtils.js +1 -1
  212. package/assets/esri/core/workers/chunks/027f8b57565c65fbccda.js +0 -1
  213. package/assets/esri/core/workers/chunks/048265fb5953350e3e33.js +0 -1
  214. package/assets/esri/core/workers/chunks/0b9cf14f8aafb76c578b.js +0 -1
  215. package/assets/esri/core/workers/chunks/0ebf58c927bfc4c9d4fe.js +0 -1
  216. package/assets/esri/core/workers/chunks/10fd951bd296b2beeeba.js +0 -1
  217. package/assets/esri/core/workers/chunks/1224475f3eefdfd59c76.js +0 -1
  218. package/assets/esri/core/workers/chunks/162b0220e24e9ba72655.js +0 -1
  219. package/assets/esri/core/workers/chunks/1e611cad53b745ee146f.js +0 -1
  220. package/assets/esri/core/workers/chunks/24b1bf1a5d80f43a6c9a.js +0 -1
  221. package/assets/esri/core/workers/chunks/29ed31fd4f9d5cf53686.js +0 -1
  222. package/assets/esri/core/workers/chunks/2b6d1c8e4ed759767827.js +0 -1
  223. package/assets/esri/core/workers/chunks/34b44b0fab88f838885c.js +0 -1
  224. package/assets/esri/core/workers/chunks/364f55294a1d7bf163d7.js +0 -1
  225. package/assets/esri/core/workers/chunks/3714ab435dd5ccf9e694.js +0 -1
  226. package/assets/esri/core/workers/chunks/3788009a5ece453011f3.js +0 -1
  227. package/assets/esri/core/workers/chunks/3aafe8160b3bfbaa6935.js +0 -1
  228. package/assets/esri/core/workers/chunks/41c002e4c42c581cda8d.js +0 -1
  229. package/assets/esri/core/workers/chunks/47be4c75dd6372b96fe4.js +0 -1
  230. package/assets/esri/core/workers/chunks/4e8d1e6051f6654a5e83.js +0 -1
  231. package/assets/esri/core/workers/chunks/53746e9976758630159b.js +0 -1
  232. package/assets/esri/core/workers/chunks/5449fdd69e12e5cbd12a.js +0 -1
  233. package/assets/esri/core/workers/chunks/57ce4ece0147afb0d43c.js +0 -1
  234. package/assets/esri/core/workers/chunks/5e83d21400a5dec05c81.js +0 -1
  235. package/assets/esri/core/workers/chunks/6047f4487dcd37cca98e.js +0 -1
  236. package/assets/esri/core/workers/chunks/6967d2b3721678b38774.js +0 -1
  237. package/assets/esri/core/workers/chunks/6ac5ca7de651e3d672a1.js +0 -1
  238. package/assets/esri/core/workers/chunks/6b7ee9164149428edb9e.js +0 -1
  239. package/assets/esri/core/workers/chunks/6c495077cc79e1898927.js +0 -1
  240. package/assets/esri/core/workers/chunks/6d43648d5326e01b4474.js +0 -1
  241. package/assets/esri/core/workers/chunks/74fb07de0f990d45af89.js +0 -1
  242. package/assets/esri/core/workers/chunks/8e9a52062ce059153a89.js +0 -1
  243. package/assets/esri/core/workers/chunks/919a57d372419785cd5e.js +0 -1
  244. package/assets/esri/core/workers/chunks/939f0a1a7d605e389e45.js +0 -1
  245. package/assets/esri/core/workers/chunks/9932f23ba6589df14a3d.js +0 -1
  246. package/assets/esri/core/workers/chunks/a25a38c9f338e0beffef.js +0 -1
  247. package/assets/esri/core/workers/chunks/a97581e584336b46ede7.js +0 -1
  248. package/assets/esri/core/workers/chunks/b1cb932cfadc4dc3f1e4.js +0 -1
  249. package/assets/esri/core/workers/chunks/be3fb6113b0b27b94537.js +0 -1
  250. package/assets/esri/core/workers/chunks/c37119f5692e19aa1ce2.js +0 -1
  251. package/assets/esri/core/workers/chunks/c685f16435d9861bbbd0.js +0 -1
  252. package/assets/esri/core/workers/chunks/d5dfc03673aec8aa57e2.js +0 -1
  253. package/assets/esri/core/workers/chunks/e6416a2684866d677b3e.js +0 -1
  254. package/assets/esri/core/workers/chunks/eb01f4cdb9b918cc61e7.js +0 -1
  255. package/assets/esri/core/workers/chunks/eb4aed4fdb44495a4fe6.js +0 -1
  256. package/assets/esri/core/workers/chunks/ec8258c9dc1491e97fc8.js +0 -1
  257. package/assets/esri/core/workers/chunks/eeac53da496de4cd4182.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{ViewingMode as e}from"../../../ViewingMode.js";import{GamepadKeyboardController as t}from"../../state/controllers/GamepadKeyboardController.js";import{InputHandler as r}from"../../../input/InputHandler.js";var a;!function(e){e[e.LEFT=0]="LEFT",e[e.RIGHT=1]="RIGHT",e[e.FORWARD=2]="FORWARD",e[e.BACKWARD=3]="BACKWARD",e[e.UP=4]="UP",e[e.DOWN=5]="DOWN",e[e.HEADINGLEFT=6]="HEADINGLEFT",e[e.HEADINGRIGHT=7]="HEADINGRIGHT",e[e.TILTUP=8]="TILTUP",e[e.TILTDOWN=9]="TILTDOWN",e[e.ZOOMIN=10]="ZOOMIN",e[e.ZOOMOUT=11]="ZOOMOUT"}(a||(a={}));class o extends r{constructor(t,r){super(!0),this._view=t,this._disableMovements={pan:!0,zoom:!1,ascend:!0,rotate:!1,mode:e.Local},this._keyToNumber={[r.left]:a.LEFT,[r.right]:a.RIGHT,[r.forward]:a.FORWARD,[r.backward]:a.BACKWARD,[r.up]:a.UP,[r.down]:a.DOWN,[r.headingLeft]:a.HEADINGLEFT,[r.headingRight]:a.HEADINGRIGHT,[r.tiltUp]:a.TILTUP,[r.tiltDown]:a.TILTDOWN,[r.zoomIn]:a.ZOOMIN,[r.zoomOut]:a.ZOOMOUT},this.registerIncoming("key-down",null,(e=>this._handleKeyDown(e))),this.registerIncoming("key-up",null,(e=>this._handleKeyUp(e))),this.registerIncoming("blur",null,(()=>this._handleBlur()))}_handleKeyDown(e){if(e.data.native.ctrlKey||e.data.native.metaKey)return;const r=this._keyToNumber[e.data.key];null!=r&&(this._cameraControllerKeyboard&&this._cameraControllerKeyboard.active||(this._cameraControllerKeyboard=new t({view:this._view,disableMovements:this._disableMovements}),this._view.state.switchCameraController(this._cameraControllerKeyboard)),this._cameraControllerKeyboard.active&&(this._cameraControllerKeyboard.activateDirection(r),e.stopPropagation()))}_handleBlur(){this._cameraControllerKeyboard&&this._cameraControllerKeyboard.active&&(this._cameraControllerKeyboard.finishController(),this._cameraControllerKeyboard=null)}_handleKeyUp(e){if(e.data.native.ctrlKey||e.data.native.metaKey)return;const t=this._keyToNumber[e.data.key];null!=t&&this._cameraControllerKeyboard&&this._cameraControllerKeyboard.active&&(this._cameraControllerKeyboard.deactivateDirection(t),e.stopPropagation())}}export{o as KeyboardNavigation};
5
+ import{ViewingMode as e}from"../../../ViewingMode.js";import{GamepadKeyboardController as t}from"../../state/controllers/GamepadKeyboardController.js";import{InputHandler as a}from"../../../input/InputHandler.js";import{onVisibilityChange as o}from"../../../input/VisibilityChange.js";var r;!function(e){e[e.LEFT=0]="LEFT",e[e.RIGHT=1]="RIGHT",e[e.FORWARD=2]="FORWARD",e[e.BACKWARD=3]="BACKWARD",e[e.UP=4]="UP",e[e.DOWN=5]="DOWN",e[e.HEADINGLEFT=6]="HEADINGLEFT",e[e.HEADINGRIGHT=7]="HEADINGRIGHT",e[e.TILTUP=8]="TILTUP",e[e.TILTDOWN=9]="TILTDOWN",e[e.ZOOMIN=10]="ZOOMIN",e[e.ZOOMOUT=11]="ZOOMOUT"}(r||(r={}));class i extends a{constructor(t,a){super(!0),this._view=t,this._disableMovements={pan:!0,zoom:!1,ascend:!0,rotate:!1,mode:e.Local},this._keyToNumber={[a.left]:r.LEFT,[a.right]:r.RIGHT,[a.forward]:r.FORWARD,[a.backward]:r.BACKWARD,[a.up]:r.UP,[a.down]:r.DOWN,[a.headingLeft]:r.HEADINGLEFT,[a.headingRight]:r.HEADINGRIGHT,[a.tiltUp]:r.TILTUP,[a.tiltDown]:r.TILTDOWN,[a.zoomIn]:r.ZOOMIN,[a.zoomOut]:r.ZOOMOUT},this.registerIncoming("key-down",null,(e=>this._handleKeyDown(e))),this.registerIncoming("key-up",null,(e=>this._handleKeyUp(e))),this.registerIncoming("blur",null,(()=>this._handleStop())),this._visibilityHandle=o((e=>e?null:this._handleStop()))}onUninstall(){this._visibilityHandle?.remove(),this._handleStop()}_handleKeyDown(e){if(e.data.native.ctrlKey||e.data.native.metaKey)return;const a=this._keyToNumber[e.data.key];null!=a&&(this._cameraControllerKeyboard&&this._cameraControllerKeyboard.active||(this._cameraControllerKeyboard=new t({view:this._view,disableMovements:this._disableMovements}),this._view.state.switchCameraController(this._cameraControllerKeyboard)),this._cameraControllerKeyboard.active&&(this._cameraControllerKeyboard.activateDirection(a),e.stopPropagation()))}_handleStop(){this._cameraControllerKeyboard?.active&&(this._cameraControllerKeyboard.finishController(),this._cameraControllerKeyboard=null)}_handleKeyUp(e){if(e.data.native.ctrlKey||e.data.native.metaKey)return;const t=this._keyToNumber[e.data.key];null!=t&&this._cameraControllerKeyboard&&this._cameraControllerKeyboard.active&&(this._cameraControllerKeyboard.deactivateDirection(t),e.stopPropagation())}}export{i as KeyboardNavigation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import{handlesGroup as i,makeHandle as s}from"../../../../../core/handleUtils.js";import{destroyMaybe as r}from"../../../../../core/maybe.js";import{watch as o,when as n,syncAndInitial as a,initial as l}from"../../../../../core/reactiveUtils.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{s as h}from"../../../../../chunks/vec3.js";import{c as m}from"../../../../../chunks/vec3f64.js";import{getEffectiveElevationInfo as u,getEffectiveElevationMode as d}from"../../../../../support/elevationInfoUtils.js";import v from"../../../../../symbols/support/ElevationInfo.js";import{SegmentLabels3D as f}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as y}from"../../SnappingVisualizer3D.js";import{meshTransformFastUpdateHandles as g}from"../meshFastUpdateUtils.js";import{Settings as w}from"../settings.js";import{ExtendedLineVisualElement as E}from"../../visualElements/ExtendedLineVisualElement.js";import{OutlineVisualElement as V}from"../../visualElements/OutlineVisualElement.js";import{VerticesVisualElement as _}from"../../visualElements/VerticesVisualElement.js";import{evaluateElevationAlignmentAtPoint as j}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as G}from"../../../layers/graphics/ElevationContext.js";import{GraphicState as S}from"../../../layers/graphics/GraphicState.js";import{RenderOccludedFlag as D}from"../../../webgl-engine/lib/Material.js";import{DrawGraphicTool as I,geometryTypeToDrawOperationGeometryType as L}from"../../../../draw/DrawGraphicTool.js";import{DrawOperation as O}from"../../../../draw/DrawOperation.js";import{SceneDrawSurface as T,ElevationDrawSurface as x}from"../../../../draw/drawSurfaces.js";import{getDrawMeshHelpMessage as C}from"../../../../draw/support/helpMessageUtils3d.js";let z=class extends I{constructor(e){super(e),this._activeVertexVisualElement=null,this._createGraphicState=null,this._outlineVisualElement=null,this._verticesVisualElement=null,this._verticalLineVisualElement=null,this._settings=new w({getTheme:()=>this.view.effectiveTheme}),this.geometryType=null,this.type="draw-3d"}initialize(){const{mode:e,offset:t}=this.elevationInfo;this.internalGraphicsLayer.elevationInfo=new v({mode:e,offset:t})}normalizeCtorArgs(e){if(!e.elevationInfo){const t=e.hasZ??!0;return{...e,elevationInfo:u(t)}}return e}initializeGraphic(e){const{view:t}=this,s=this._createGraphicState=new S({graphic:e});return i([t.maskOccludee(e),t.trackGraphicState(s),o((()=>({element:this._outlineVisualElement,isDraped:s.isDraped})),(({element:e,isDraped:t})=>{e&&(e.isDraped=t)}),a),this._setupLoadingIndicator(s),...g(s)])}updateDrawMeshTooltipInfo(e){const{graphic:t,tooltipOptions:i,view:s}=this;e.tooltipOptions=i,e.viewType=s.type,e.helpMessage=C(t,this.view),this.updateElevation(e.elevation)}makeDrawOperation(){const{geometryType:e}=this,t="circle"!==e&&"rectangle"!==e;return new O({view:this.view,manipulators:this.manipulators,geometryType:L(e),drawingMode:this.mode,hasZ:this.hasZ,defaultZ:this.defaultZ,snapToSceneEnabled:this.snapToScene,drawSurface:new T(this.view,this.elevationInfo,[this.internalGraphicsLayer]),elevationDrawSurface:new x(this.elevationInfo,this.defaultZ,this.view,this.internalGraphicsLayer),hasM:!1,elevationInfo:this.elevationInfo,snappingManager:this.snappingManager,snappingVisualizer:new y,segmentLabels:t?new f:null,labelOptions:this.labelOptions,tooltipOptions:this.tooltipOptions,isDraped:this._createGraphicState?this._createGraphicState.isDraped:"on-the-ground"===d(this.hasZ,this.elevationInfo)})}onActiveVertexChanged(e){const{view:n}=this;if(this._activeVertexVisualElement)return this._activeVertexVisualElement.vertices=[e],this._updateVerticalLineVisualElement(e),s();const a=this._settings,c=a.manipulators.vertex,p=new _({view:n,spatialReference:n.spatialReference,vertices:[e],elevationInfo:this.internalGraphicsLayer.elevationInfo,size:c.size,outlineSize:c.outlineSize,renderOccluded:c.renderOccluded,attached:!1,isDecoration:!0});this._activeVertexVisualElement=p;const h=a.visualElements.zVerticalLine,m=new E({view:n,extensionType:h.extensionType,innerWidth:1,attached:!1,writeDepthEnabled:!1,renderOccluded:D.OccludeAndTransparent,isDecoration:!0});this._verticalLineVisualElement=m;const u=i([o((()=>a.visualElements.zVerticalLine),(e=>e.apply(m)),l),o((()=>({selectedColor:t(a.colors.selected),outlineColor:t(a.manipulators.vertex.outlineColor)})),(({selectedColor:e,outlineColor:t})=>{p.color=e,p.outlineColor=t}),l),s((()=>{this._activeVertexVisualElement=r(this._activeVertexVisualElement),this._verticalLineVisualElement=r(this._verticalLineVisualElement)}))]);return p.attached=!0,u}_updateVerticalLineVisualElement(e){const t=this._verticalLineVisualElement;if(!t)return;const{renderCoordsHelper:i,elevationProvider:s}=this.view;h(M,e[0],e[1],e[2]),b.setFromElevationInfo(this.elevationInfo),M[2]=j(M,s,b,i);i.toRenderCoords(M,this.view.spatialReference,M)?(t.setStartEndFromWorldDownAtLocation(M),t.attached=!0):t.attached=!1}onOutlineChanged(e){if(this._outlineVisualElement)return this._outlineVisualElement.geometry=e,s();const t=this.internalGraphicsLayer.elevationInfo,{view:n}=this,a=this._settings,c=new V({view:n,geometry:e,elevationInfo:t,isDraped:this._createGraphicState?this._createGraphicState.isDraped:"on-the-ground"===d(this.hasZ,t),attached:!1,isDecoration:!0});this._outlineVisualElement=c;const p=i([o((()=>a.visualElements.lineGraphics.outline),(e=>e.apply(c)),l),o((()=>a.visualElements.lineGraphics.shadowStyle),(e=>e.apply(c)),l),s((()=>{this._outlineVisualElement=r(this._outlineVisualElement)}))]);return c.attached=!0,c.laserlineEnabled=!0,p}onRegularVerticesChanged(e){if(this._verticesVisualElement)return this._verticesVisualElement.vertices=e,s();const{view:n}=this,a=this._settings,c=a.manipulators.vertex,p=new _({view:n,spatialReference:n.spatialReference,vertices:e,elevationInfo:this.internalGraphicsLayer.elevationInfo,size:c.size,outlineSize:c.outlineSize,renderOccluded:c.renderOccluded,attached:!1,isDecoration:!0}),h=i([o((()=>({color:t(a.manipulators.vertex.color),outlineColor:t(a.manipulators.vertex.outlineColor)})),(({color:e,outlineColor:t})=>{p.color=e,p.outlineColor=t}),l),s((()=>{this._verticesVisualElement=r(this._verticesVisualElement)}))]);return p.attached=!0,this._verticesVisualElement=p,h}updateGraphicGeometry(e,t){if("mesh"===this.geometryType&&"point"===t?.type){const i=this.geometryToPlace;return i&&i.centerAt(t),void(i&&e.geometry===i?i.vertexSpace.isGeoreferenced?e.notifyGeometryChanged():e.notifyMeshTransformChanged():e.geometry=i)}super.updateGraphicGeometry(e,t)}_setupLoadingIndicator(e){const{drawOperation:t}=this;if(!this.geometryToPlace)return t.loading=!1,null;t.loading=!0;const r=s((()=>{t.loading=!1}));let o;const l=()=>o&&cancelAnimationFrame(o);return i([n((()=>e.displaying),(()=>{l(),o=requestAnimationFrame((()=>r.remove()))}),{...a,once:!0}),s(l),r])}};e([c({constructOnly:!0})],z.prototype,"elevationInfo",void 0),e([c({constructOnly:!0})],z.prototype,"geometryType",void 0),e([c()],z.prototype,"type",void 0),e([c({constructOnly:!0})],z.prototype,"view",void 0),z=e([p("esri.views.3d.interactive.editingTools.draw.DrawGraphicTool3D")],z);const b=new G,M=m();export{z as DrawGraphicTool3D};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import{handlesGroup as i,makeHandle as r}from"../../../../../core/handleUtils.js";import{destroyMaybe as s}from"../../../../../core/maybe.js";import{watch as o,when as n,syncAndInitial as a,initial as l}from"../../../../../core/reactiveUtils.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{s as h}from"../../../../../chunks/vec3.js";import{c as m}from"../../../../../chunks/vec3f64.js";import{getEffectiveElevationInfo as u,getEffectiveElevationMode as d}from"../../../../../support/elevationInfoUtils.js";import v from"../../../../../symbols/support/ElevationInfo.js";import{SegmentLabels3D as f}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as y}from"../../SnappingVisualizer3D.js";import{meshTransformFastUpdateHandles as g}from"../meshFastUpdateUtils.js";import{Settings as w}from"../settings.js";import{ExtendedLineVisualElement as E}from"../../visualElements/ExtendedLineVisualElement.js";import{OutlineVisualElement as V}from"../../visualElements/OutlineVisualElement.js";import{VerticesVisualElement as _}from"../../visualElements/VerticesVisualElement.js";import{evaluateElevationAlignmentAtPoint as j}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as G}from"../../../layers/graphics/ElevationContext.js";import{GraphicState as S}from"../../../layers/graphics/GraphicState.js";import{RenderOccludedFlag as D}from"../../../webgl-engine/lib/Material.js";import{DrawGraphicTool as I,geometryTypeToDrawOperationGeometryType as L}from"../../../../draw/DrawGraphicTool.js";import{DrawOperation as O}from"../../../../draw/DrawOperation.js";import{SceneDrawSurface as T,ElevationDrawSurface as x}from"../../../../draw/drawSurfaces.js";import{getDrawMeshHelpMessage as C}from"../../../../draw/support/helpMessageUtils3d.js";let z=class extends I{constructor(e){super(e),this._activeVertexVisualElement=null,this._createGraphicState=null,this._outlineVisualElement=null,this._verticesVisualElement=null,this._verticalLineVisualElement=null,this._settings=new w({getTheme:()=>this.view.effectiveTheme}),this.geometryType=null,this.type="draw-3d"}initialize(){const{mode:e,offset:t}=this.elevationInfo;this.internalGraphicsLayer.elevationInfo=new v({mode:e,offset:t})}normalizeCtorArgs(e){if(!e.elevationInfo){const t=e.hasZ??!0;return{...e,elevationInfo:u(t)}}return e}initializeGraphic(e){const{view:t}=this,r=this._createGraphicState=new S({graphic:e});return i([t.maskOccludee(e),t.trackGraphicState(r),o((()=>({element:this._outlineVisualElement,isDraped:r.isDraped})),(({element:e,isDraped:t})=>{e&&(e.isDraped=t)}),a),this._setupLoadingIndicator(r),...g(r)])}updateDrawMeshTooltipInfo(e){const{graphic:t,tooltipOptions:i,view:r}=this;e.tooltipOptions=i,e.viewType=r.type,e.helpMessage=C(t,this.view),this.updateElevation(e.elevation)}makeDrawOperation(){const{geometryType:e}=this,t="circle"!==e&&"rectangle"!==e;return new O({view:this.view,manipulators:this.manipulators,geometryType:L(e),drawingMode:this.mode,hasZ:this.hasZ,defaultZ:this.defaultZ,snapToSceneEnabled:this.snapToScene,drawSurface:new T(this.view,this.elevationInfo,[this.internalGraphicsLayer]),elevationDrawSurface:new x(this.elevationInfo,this.defaultZ,this.view,this.internalGraphicsLayer),hasM:!1,elevationInfo:this.elevationInfo,snappingManager:this.snappingManager,snappingVisualizer:new y,segmentLabels:t?new f:null,labelOptions:this.labelOptions,tooltipOptions:this.tooltipOptions,isDraped:this._createGraphicState?this._createGraphicState.isDraped:"on-the-ground"===d(this.hasZ,this.elevationInfo),cursor:this.cursor})}onActiveVertexChanged(e){const{view:n}=this;if(this._activeVertexVisualElement)return this._activeVertexVisualElement.vertices=[e],this._updateVerticalLineVisualElement(e),r();const a=this._settings,c=a.manipulators.vertex,p=new _({view:n,spatialReference:n.spatialReference,vertices:[e],elevationInfo:this.internalGraphicsLayer.elevationInfo,size:c.size,outlineSize:c.outlineSize,renderOccluded:c.renderOccluded,attached:!1,isDecoration:!0});this._activeVertexVisualElement=p;const h=a.visualElements.zVerticalLine,m=new E({view:n,extensionType:h.extensionType,innerWidth:1,attached:!1,writeDepthEnabled:!1,renderOccluded:D.OccludeAndTransparent,isDecoration:!0});this._verticalLineVisualElement=m;const u=i([o((()=>a.visualElements.zVerticalLine),(e=>e.apply(m)),l),o((()=>({selectedColor:t(a.colors.selected),outlineColor:t(a.manipulators.vertex.outlineColor)})),(({selectedColor:e,outlineColor:t})=>{p.color=e,p.outlineColor=t}),l),r((()=>{this._activeVertexVisualElement=s(this._activeVertexVisualElement),this._verticalLineVisualElement=s(this._verticalLineVisualElement)}))]);return p.attached=!0,u}_updateVerticalLineVisualElement(e){const t=this._verticalLineVisualElement;if(!t)return;const{renderCoordsHelper:i,elevationProvider:r}=this.view;h(M,e[0],e[1],e[2]),b.setFromElevationInfo(this.elevationInfo),M[2]=j(M,r,b,i);i.toRenderCoords(M,this.view.spatialReference,M)?(t.setStartEndFromWorldDownAtLocation(M),t.attached=!0):t.attached=!1}onOutlineChanged(e){if(this._outlineVisualElement)return this._outlineVisualElement.geometry=e,r();const t=this.internalGraphicsLayer.elevationInfo,{view:n}=this,a=this._settings,c=new V({view:n,geometry:e,elevationInfo:t,isDraped:this._createGraphicState?this._createGraphicState.isDraped:"on-the-ground"===d(this.hasZ,t),attached:!1,isDecoration:!0});this._outlineVisualElement=c;const p=i([o((()=>a.visualElements.lineGraphics.outline),(e=>e.apply(c)),l),o((()=>a.visualElements.lineGraphics.shadowStyle),(e=>e.apply(c)),l),r((()=>{this._outlineVisualElement=s(this._outlineVisualElement)}))]);return c.attached=!0,c.laserlineEnabled=!0,p}onRegularVerticesChanged(e){if(this._verticesVisualElement)return this._verticesVisualElement.vertices=e,r();const{view:n}=this,a=this._settings,c=a.manipulators.vertex,p=new _({view:n,spatialReference:n.spatialReference,vertices:e,elevationInfo:this.internalGraphicsLayer.elevationInfo,size:c.size,outlineSize:c.outlineSize,renderOccluded:c.renderOccluded,attached:!1,isDecoration:!0}),h=i([o((()=>({color:t(a.manipulators.vertex.color),outlineColor:t(a.manipulators.vertex.outlineColor)})),(({color:e,outlineColor:t})=>{p.color=e,p.outlineColor=t}),l),r((()=>{this._verticesVisualElement=s(this._verticesVisualElement)}))]);return p.attached=!0,this._verticesVisualElement=p,h}updateGraphicGeometry(e,t){if("mesh"===this.geometryType&&"point"===t?.type){const i=this.geometryToPlace;return i&&i.centerAt(t),void(i&&e.geometry===i?i.vertexSpace.isGeoreferenced?e.notifyGeometryChanged():e.notifyMeshTransformChanged():e.geometry=i)}super.updateGraphicGeometry(e,t)}_setupLoadingIndicator(e){const{drawOperation:t}=this;if(!this.geometryToPlace)return t.loading=!1,null;t.loading=!0;const s=r((()=>{t.loading=!1}));let o;const l=()=>o&&cancelAnimationFrame(o);return i([n((()=>e.displaying),(()=>{l(),o=requestAnimationFrame((()=>s.remove()))}),{...a,once:!0}),r(l),s])}};e([c({constructOnly:!0})],z.prototype,"elevationInfo",void 0),e([c({constructOnly:!0})],z.prototype,"geometryType",void 0),e([c()],z.prototype,"type",void 0),e([c({constructOnly:!0})],z.prototype,"view",void 0),z=e([p("esri.views.3d.interactive.editingTools.draw.DrawGraphicTool3D")],z);const b=new G,M=m();export{z as DrawGraphicTool3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{d as e}from"../../../../chunks/mat4.js";import{a as t}from"../../../../chunks/mat4f64.js";import{s as r,e as s}from"../../../../chunks/vec3.js";import{Z as o,c as i}from"../../../../chunks/vec3f64.js";import{f as a,d as n}from"../../../../chunks/vec4f64.js";import{Object3DVisualElement as l}from"./Object3DVisualElement.js";import{lineStripsToParameters as m,createGeometry as p}from"../../support/engineContent/line.js";import{RenderOccludedFlag as h}from"../../webgl-engine/lib/Material.js";import{RibbonLineMaterial as d}from"../../webgl-engine/materials/RibbonLineMaterial.js";class u extends l{constructor(e,t){super(e),this._hasExternalMaterial=!1,this._hasExternalMaterial=null!=t,this._material=null!=t?t:new d({width:1,color:a(1,0,1,1),stippleOffColor:null,stipplePattern:null,stipplePreferContinuous:!0,isClosed:!1,falloff:0,innerColor:null,innerWidth:1,hasPolygonOffset:!1,renderOccluded:h.OccludeAndTransparent,isDecoration:!!e.isDecoration,writeDepth:!0}),this.applyProperties(e)}setGeometryFromRenderSpacePoint(e,t=1e3){this.geometry=[[[e[0]-t,e[1],e[2]],[e[0]+t,e[1],e[2]]],[[e[0],e[1]-t,e[2]],[e[0],e[1]+t,e[2]]],[[e[0],e[1],e[2]-t],[e[0],e[1],e[2]+t]]]}setGeometryFromExtent(e){const t=this.view.spatialReference,s=i(),o=i(),a=100,n=[];r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[2],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[2],e[3],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[0],e[3],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),this.geometry=[n]}setGeometryFromFrustum(e){const t=[];e.lines.forEach((e=>{t.push([e.origin[0],e.origin[1],e.origin[2]]),t.push([e.endpoint[0],e.endpoint[1],e.endpoint[2]])})),this.geometry=[t]}setGeometryFromBoundedPlane(e){const t=[],r=e.origin,s=e.basis1,o=e.basis2,a=.5,n=i(),l=i(),m=i(),p=i();n[0]=r[0]-s[0]*a-o[0]*a,n[1]=r[1]-s[1]*a-o[1]*a,n[2]=r[2]-s[2]*a-o[2]*a,l[0]=r[0]-s[0]*a+o[0]*a,l[1]=r[1]-s[1]*a+o[1]*a,l[2]=r[2]-s[2]*a+o[2]*a,m[0]=r[0]+s[0]*a+o[0]*a,m[1]=r[1]+s[1]*a+o[1]*a,m[2]=r[2]+s[2]*a+o[2]*a,p[0]=r[0]+s[0]*a-o[0]*a,p[1]=r[1]+s[1]*a-o[1]*a,p[2]=r[2]+s[2]*a-o[2]*a,t.push([n[0],n[1],n[2]]),t.push([l[0],l[1],l[2]]),t.push([m[0],m[1],m[2]]),t.push([p[0],p[1],p[2]]),t.push([n[0],n[1],n[2]]),this.geometry=[t]}setGeometryFromSegment(t){const r=t.endRenderSpace;this.transform=e(f,r);const{points:s}=t.createRenderGeometry(r,this.view.renderCoordsHelper);this.geometry=[s]}setGeometryFromSegments(t,r=o){this.transform=e(f,r),this.geometry=t.map((e=>e.createRenderGeometry(r,this.view.renderCoordsHelper).points))}getTransformedGeometry(){return null==this._geometry?null:this._geometry.map((e=>e.map((e=>s(i(),e,this.transform)))))}get renderOccluded(){return this._material.parameters.renderOccluded}set renderOccluded(e){this._material.setParameters({renderOccluded:e})}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get width(){return this._material.parameters.width}set width(e){this._material.setParameters({width:e})}get color(){return this._material.parameters.color}set color(e){const t=1===e[3];this._material.setParameters({color:n(e),writeDepth:t})}get innerWidth(){return this._material.parameters.innerWidth}set innerWidth(e){this._material.setParameters({innerWidth:e})}get innerColor(){return this._material.parameters.innerColor}set innerColor(e){this._material.setParameters({innerColor:null!=e?n(e):null})}get stipplePattern(){return this._material.parameters.stipplePattern}set stipplePattern(e){null!=this._material&&this._material.setParameters({stipplePattern:e})}get stippleOffColor(){return this._material.parameters.stippleOffColor}set stippleOffColor(e){this._material.setParameters({stippleOffColor:null!=e?n(e):null})}get stipplePreferContinuous(){return this._material.parameters.stipplePreferContinuous}set stipplePreferContinuous(e){this._material.setParameters({stipplePreferContinuous:e})}get falloff(){return this._material.parameters.falloff}set falloff(e){this._material.setParameters({falloff:e})}get polygonOffset(){return this._material.parameters.hasPolygonOffset}set polygonOffset(e){this._material.setParameters({hasPolygonOffset:e})}createExternalResources(){}destroyExternalResources(){}createGeometries(e){for(const t of m(this.geometry)){const r=p(this._material,t);e.addGeometry(r)}}forEachExternalMaterial(e){this._hasExternalMaterial||e(this._material)}}const f=t();export{u as LineVisualElement};
5
+ import{d as e}from"../../../../chunks/mat4.js";import{a as t}from"../../../../chunks/mat4f64.js";import{s as r,e as s}from"../../../../chunks/vec3.js";import{Z as o,c as i}from"../../../../chunks/vec3f64.js";import{f as a,d as n}from"../../../../chunks/vec4f64.js";import{Object3DVisualElement as l}from"./Object3DVisualElement.js";import{lineStripsToParameters as m,createGeometry as p}from"../../support/engineContent/line.js";import{RenderOccludedFlag as h}from"../../webgl-engine/lib/Material.js";import{RibbonLineMaterial as d}from"../../webgl-engine/materials/RibbonLineMaterial.js";class u extends l{constructor(e,t){super(e),this._hasExternalMaterial=!1,this._hasExternalMaterial=null!=t,this._material=null!=t?t:new d({width:1,color:a(1,0,1,1),stippleOffColor:null,stipplePattern:null,stipplePreferContinuous:!0,isClosed:!1,falloff:0,innerColor:null,innerWidth:1,hasPolygonOffset:!1,renderOccluded:h.OccludeAndTransparent,isDecoration:!!e.isDecoration,writeDepth:!0,writeLinearDepth:!1}),this.applyProperties(e)}setGeometryFromRenderSpacePoint(e,t=1e3){this.geometry=[[[e[0]-t,e[1],e[2]],[e[0]+t,e[1],e[2]]],[[e[0],e[1]-t,e[2]],[e[0],e[1]+t,e[2]]],[[e[0],e[1],e[2]-t],[e[0],e[1],e[2]+t]]]}setGeometryFromExtent(e){const t=this.view.spatialReference,s=i(),o=i(),a=100,n=[];r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[2],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[2],e[3],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[0],e[3],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),this.geometry=[n]}setGeometryFromFrustum(e){const t=[];e.lines.forEach((e=>{t.push([e.origin[0],e.origin[1],e.origin[2]]),t.push([e.endpoint[0],e.endpoint[1],e.endpoint[2]])})),this.geometry=[t]}setGeometryFromBoundedPlane(e){const t=[],r=e.origin,s=e.basis1,o=e.basis2,a=.5,n=i(),l=i(),m=i(),p=i();n[0]=r[0]-s[0]*a-o[0]*a,n[1]=r[1]-s[1]*a-o[1]*a,n[2]=r[2]-s[2]*a-o[2]*a,l[0]=r[0]-s[0]*a+o[0]*a,l[1]=r[1]-s[1]*a+o[1]*a,l[2]=r[2]-s[2]*a+o[2]*a,m[0]=r[0]+s[0]*a+o[0]*a,m[1]=r[1]+s[1]*a+o[1]*a,m[2]=r[2]+s[2]*a+o[2]*a,p[0]=r[0]+s[0]*a-o[0]*a,p[1]=r[1]+s[1]*a-o[1]*a,p[2]=r[2]+s[2]*a-o[2]*a,t.push([n[0],n[1],n[2]]),t.push([l[0],l[1],l[2]]),t.push([m[0],m[1],m[2]]),t.push([p[0],p[1],p[2]]),t.push([n[0],n[1],n[2]]),this.geometry=[t]}setGeometryFromSegment(t){const r=t.endRenderSpace;this.transform=e(f,r);const{points:s}=t.createRenderGeometry(r,this.view.renderCoordsHelper);this.geometry=[s]}setGeometryFromSegments(t,r=o){this.transform=e(f,r),this.geometry=t.map((e=>e.createRenderGeometry(r,this.view.renderCoordsHelper).points))}getTransformedGeometry(){return null==this._geometry?null:this._geometry.map((e=>e.map((e=>s(i(),e,this.transform)))))}get renderOccluded(){return this._material.parameters.renderOccluded}set renderOccluded(e){this._material.setParameters({renderOccluded:e})}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get width(){return this._material.parameters.width}set width(e){this._material.setParameters({width:e})}get color(){return this._material.parameters.color}set color(e){const t=1===e[3];this._material.setParameters({color:n(e),writeDepth:t})}get innerWidth(){return this._material.parameters.innerWidth}set innerWidth(e){this._material.setParameters({innerWidth:e})}get innerColor(){return this._material.parameters.innerColor}set innerColor(e){this._material.setParameters({innerColor:null!=e?n(e):null})}get stipplePattern(){return this._material.parameters.stipplePattern}set stipplePattern(e){null!=this._material&&this._material.setParameters({stipplePattern:e})}get stippleOffColor(){return this._material.parameters.stippleOffColor}set stippleOffColor(e){this._material.setParameters({stippleOffColor:null!=e?n(e):null})}get stipplePreferContinuous(){return this._material.parameters.stipplePreferContinuous}set stipplePreferContinuous(e){this._material.setParameters({stipplePreferContinuous:e})}get falloff(){return this._material.parameters.falloff}set falloff(e){this._material.setParameters({falloff:e})}get polygonOffset(){return this._material.parameters.hasPolygonOffset}set polygonOffset(e){this._material.setParameters({hasPolygonOffset:e})}createExternalResources(){}destroyExternalResources(){}createGeometries(e){for(const t of m(this.geometry)){const r=p(this._material,t);e.addGeometry(r)}}forEachExternalMaterial(e){this._hasExternalMaterial||e(this._material)}}const f=t();export{u as LineVisualElement};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{a}from"../../../../chunks/mat3f64.js";import{d as s,m as n,i}from"../../../../chunks/mat4.js";import{a as l,I as c,b as u}from"../../../../chunks/mat4f64.js";import{s as m,g as h,i as f,j as p,n as d,f as g,b as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as y}from"../../../../chunks/vec3f64.js";import{O as b}from"../../../../chunks/vec4f64.js";import{canProjectWithoutEngine as v}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as w}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToDehydratedPoint as j}from"../../../../geometry/projection/projectVectorToDehydratedPoint.js";import{create as M,empty as O,expandWithBuffer as P,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as A}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as E,getZeroIndexArray as I}from"../../../../geometry/support/Indices.js";import N from"../../../../geometry/support/MeshComponent.js";import B from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import F from"../../../../geometry/support/MeshTextureTransform.js";import{t as S,a as U}from"../../../../chunks/vec32.js";import{project as L}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as $,projectNormalToPCPF as G,transformTangent as V,projectTangentToPCPF as D}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as k}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as H}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as q}from"../../../ViewingMode.js";import{isEncodedMeshTexture as W}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as z}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as Y}from"./ElevationAligners.js";import{needsElevationUpdates3D as Z,evaluateElevationInfoAtPoint as J}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as K}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Q}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as X}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ee,MeshFastUpdateProcessor as te}from"./MeshFastUpdateProcessor.js";import{createMaterial as re}from"../support/edgeUtils.js";import{parseColorMixMode as oe,encodeSymbolColor as ae}from"../support/symbolColorUtils.js";import{debugFlags as se}from"../../support/debugFlags.js";import{Attribute as ne}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ie,CullFaceOptions as le}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ce}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ue}from"../../webgl-engine/lib/Geometry.js";import{Object3D as me}from"../../webgl-engine/lib/Object3D.js";import{Texture as he}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as fe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as de}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as ge,defaultSchematicMRRFactors as xe,defaultAdvancedMRRFactors as _e}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Te}from"../../../webgl/enums.js";const ye=["mesh"];class be extends X{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ee,this._fastUpdateProcessor=new te,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){se.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new de({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new de({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,ye,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Z)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,s=Ae,{origin:n,transform:i}=r;switch(C(t,m(we,n.x,n.y,n.z??0),s,a),o){case H.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case H.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case H.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:c,renderCoordsHelper:u}=this._context,h=(e,t)=>J(e,c,l,u,t);return e.alignedSampledElevation=Y(e,l,c.spatialReference,h,u,s),e.updateTransform(s,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Ne;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:s,colorTextureTransform:n,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(s),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=s,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof B){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(c),x=this._textureTransformUid(u),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(n),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(s),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data??e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ie.Opaque);return t?.id}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);if(!a){let s=null;const n=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,maxAnisotropy:n,mipmap:n>1};W(r)?(s=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(s=r,i.preMultiplyAlpha=t!==ie.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),a=new he(s,i),this._textures.set(o,a),a.load(this._context.stage.renderView.renderingContext),this._context.stage.add(a)}return a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return Te.CLAMP_TO_EDGE;case"mirror":return Te.MIRRORED_REPEAT;default:return Te.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=z(t.colorTextureTransform),r.normalTextureTransformMatrix=z(t.normalTextureTransform),r.occlusionTextureTransformMatrix=z(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=z(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=z(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=b;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=b)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||a?.transparent||n),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=ge({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:le.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...xe]:[l.metallic,l.roughness,_e[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?le.None:le.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new pe(h);return u.material=f,this._materialInfoCache.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ie.MaskBlend:ie.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ie.Opaque:"mask"===t.alphaMode?ie.Mask:ie.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],n=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.attributes.get(fe.POSITION),o=e.attributes.get(fe.NORMAL),c=r.data,u=r.indices,m=o.data,d=o.indices;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*d[t];for(let t=0;t<3;t++)s.push(c[e+t]);for(let t=0;t<3;t++)s.push(c[e+t]+m[r+t]*a);if(n.push(n.length),n.push(n.length),t%3==0){this._calculateFaceNormal(c,u,t,Oe),this._getFaceVertices(c,u,t,we,je,Me),h(we,we,je),h(we,we,Me),f(we,we,1/3);for(let e=0;e<3;e++)i.push(we[e]);for(let e=0;e<3;e++)i.push(we[e]+Oe[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new ue(this._debugVertexNormalMaterial,[[fe.POSITION,new ne(s,n,3,!0)]],null,ce.Line);t.push(u),u.transformation=c;const m=new ue(this._debugFaceNormalMaterial,[[fe.POSITION,new ne(i,l,3,!0)]],null,ce.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const s=this._createGeometryInfo(a,t,o);if(null==s)return null;const{geometries:n,objectTransformation:i}=s;se.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new me({geometries:n,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const c=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new Q(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,n,null,null,Y,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Z(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>J(e,h,r,f,t);return m.alignedSampledElevation=Y(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=k(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return j([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let s=0;s<o.length;s+=3){this._calculateFaceNormal(e,o,s,Oe);for(let e=0;e<3;e++){const r=3*o[s+e];we[0]=t[r],we[1]=t[r+1],we[2]=t[r+2],p(Oe,we)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new ve(t,o,a)}_createComponentNormalsFlat(e,t){const r=A(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,Oe);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new ve(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Oe);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:y(),count:0},r[a]=n),h(n.normal,n.normal,o),n.count++}}const o=A(3*t.length),a=new Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return new ve(o,a,!1)}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[n],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,we,je,Me),g(je,je,we),g(Me,Me,we),x(we,je,Me),d(o,we),o}_getOrCreateComponents(e){return e.components??Ie}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Be.ECEF?t.transformBeforeProject:null;if(o&&(r=S(new Float64Array(r.length),r,o)),t.reprojection===Be.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=o?r:new Float64Array(r.length);return w(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Be.ECEF?r.transformBeforeProject:null;a&&(o=$(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Be.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return G(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Be.ECEF?r.transformBeforeProject:null;a&&(o=V(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Be.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return D(o,s,t,e.spatialReference,n)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=oe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ae(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(s&&s.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const n=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,n),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,n),h=this._createTangentBuffer(e,i,n);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:c,symbolColorBuffer:u,objectTransformation:n.reprojection===Be.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===Be.NONE&&n.geometryTransformation?n.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===q.Local?Be.NONE:Be.ECEF:Be.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??c;if(o===Be.NONE){C(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:u(i),needsBufferCopy:!1}}const m=s(l(),r);return n(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,c=e.anchor;Ce[0]=c.x,Ce[1]=c.y,Ce[2]=c.z??0;const u=l();return C(e.spatialReference,Ce,u,n),i(Pe,u),S(t,t,Pe),(a||s)&&(r(Re,u),o(Re,Re),a&&U(a,a,Re),s&&U(s,s,Re,4)),u}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??E(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=L({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference}),a=o.length/3;return O(Ee),P(Ee,o,0,a),!R(Ee,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!v(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:s,colorBuffer:n,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const u=[[fe.POSITION,new ne(a,t,3,!0)],[fe.NORMAL,new ne(o.normals,o.indices,3,!0)]];n&&u.push([fe.COLOR,new ne(n,t,4,!0)]),i&&u.push([fe.SYMBOLCOLOR,new ne(i,I(t.length),4,!0)]),s&&u.push([fe.UV0,new ne(s,t,2,!0)]),c&&u.push([fe.TANGENT,new ne(c,t,4,!0)]);const h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,d),x=new ue(g,u,null,ce.Mesh,h);x.transformation=m,f.push(x)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class ve{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Ce=y(),we=y(),je=y(),Me=y(),Oe=y(),Pe=l(),Re=a(),Ae=l(),Ee=M(),Ie=[new N],Ne=new F;var Be;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Be||(Be={}));export{be as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{a}from"../../../../chunks/mat3f64.js";import{d as s,m as n,i,B as l}from"../../../../chunks/mat4.js";import{a as c,I as u,b as m}from"../../../../chunks/mat4f64.js";import{s as h,g as f,i as p,j as d,n as g,f as x,b as _}from"../../../../chunks/vec3.js";import{Z as T,O as y,c as b}from"../../../../chunks/vec3f64.js";import{O as v}from"../../../../chunks/vec4f64.js";import{canProjectWithoutEngine as C}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as w}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as j}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToDehydratedPoint as O}from"../../../../geometry/projection/projectVectorToDehydratedPoint.js";import{create as M,empty as P,expandWithBuffer as R,intersectsClippingArea as A}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as E}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as I,getZeroIndexArray as N}from"../../../../geometry/support/Indices.js";import B from"../../../../geometry/support/MeshComponent.js";import F from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import S from"../../../../geometry/support/MeshTextureTransform.js";import{t as U,a as L}from"../../../../chunks/vec32.js";import{project as $}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as G,projectNormalToPCPF as V,transformTangent as D,projectTangentToPCPF as k}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as H}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as q}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as W}from"../../../ViewingMode.js";import{isEncodedMeshTexture as z}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as Y}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as Z}from"./ElevationAligners.js";import{needsElevationUpdates3D as J,evaluateElevationInfoAtPoint as K}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as Q}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as X}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ee}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as te,MeshFastUpdateProcessor as re}from"./MeshFastUpdateProcessor.js";import{createMaterial as oe}from"../support/edgeUtils.js";import{parseColorMixMode as ae,encodeSymbolColor as se}from"../support/symbolColorUtils.js";import{debugFlags as ne}from"../../support/debugFlags.js";import{Attribute as ie}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as le,CullFaceOptions as ce}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ue}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as me}from"../../webgl-engine/lib/Geometry.js";import{Object3D as he}from"../../webgl-engine/lib/Object3D.js";import{Texture as fe}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as pe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as de}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as ge}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as xe,defaultSchematicMRRFactors as _e,defaultAdvancedMRRFactors as Te}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as ye}from"../../../webgl/enums.js";const be=["mesh"];class ve extends ee{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new te,this._fastUpdateProcessor=new re,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ne.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new ge({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new ge({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,be,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,J)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,s=Ee,{origin:n,transform:i}=r;switch(w(t,h(je,n.x,n.y,n.z??0),s,a),o){case q.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case q.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case q.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:c,renderCoordsHelper:u}=this._context,m=(e,t)=>K(e,c,l,u,t);return e.alignedSampledElevation=Z(e,l,c.spatialReference,m,u,s),e.updateTransform(s,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Be;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:s,colorTextureTransform:n,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(s),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=s,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof F){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(c),x=this._textureTransformUid(u),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(n),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(s),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data??e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,le.Opaque);return t?.id}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);if(!a){let s=null;const n=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,maxAnisotropy:n,mipmap:n>1};z(r)?(s=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(s=r,i.preMultiplyAlpha=t!==le.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),a=new fe(s,i),this._textures.set(o,a),a.load(this._context.stage.renderView.renderingContext),this._context.stage.add(a)}return a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return ye.CLAMP_TO_EDGE;case"mirror":return ye.MIRRORED_REPEAT;default:return ye.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=Y(t.colorTextureTransform),r.normalTextureTransformMatrix=Y(t.normalTextureTransform),r.occlusionTextureTransformMatrix=Y(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=Y(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=Y(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=v;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=v)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||a?.transparent||n),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=xe({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:T,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ce.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[..._e]:[l.metallic,l.roughness,Te[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?ce.None:ce.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new de(h);return u.material=f,this._materialInfoCache.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?le.MaskBlend:le.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?le.Opaque:"mask"===t.alphaMode?le.Mask:le.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],n=[],i=[],l=[];for(let h=0;h<r;h++){const e=t[h],r=e.attributes.get(pe.POSITION),o=e.attributes.get(pe.NORMAL),c=r.data,u=r.indices,m=o.data,d=o.indices;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*d[t];for(let t=0;t<3;t++)s.push(c[e+t]);for(let t=0;t<3;t++)s.push(c[e+t]+m[r+t]*a);if(n.push(n.length),n.push(n.length),t%3==0){this._calculateFaceNormal(c,u,t,Pe),this._getFaceVertices(c,u,t,je,Oe,Me),f(je,je,Oe),f(je,je,Me),p(je,je,1/3);for(let e=0;e<3;e++)i.push(je[e]);for(let e=0;e<3;e++)i.push(je[e]+Pe[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new me(this._debugVertexNormalMaterial,[[pe.POSITION,new ie(s,n,3,!0)]],null,ue.Line);t.push(u),u.transformation=c;const m=new me(this._debugFaceNormalMaterial,[[pe.POSITION,new ie(i,l,3,!0)]],null,ue.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const s=this._createGeometryInfo(a,t,o);if(null==s)return null;const{geometries:n,objectTransformation:i}=s;ne.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new he({geometries:n,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const c=oe(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new X(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new Q(this,l,n,null,null,Z,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=J(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>K(e,h,r,f,t);return m.alignedSampledElevation=Z(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=H(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return O([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let s=0;s<o.length;s+=3){this._calculateFaceNormal(e,o,s,Pe);for(let e=0;e<3;e++){const r=3*o[s+e];je[0]=t[r],je[1]=t[r+1],je[2]=t[r+2],d(Pe,je)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Ce(t,o,a)}_createComponentNormalsFlat(e,t){const r=E(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,Pe);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new Ce(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Pe);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:b(),count:0},r[a]=n),f(n.normal,n.normal,o),n.count++}}const o=E(3*t.length),a=new Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(g(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return new Ce(o,a,!1)}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[n],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,je,Oe,Me),x(Oe,Oe,je),x(Me,Me,je),_(je,Oe,Me),g(o,je),o}_getOrCreateComponents(e){return e.components??Ne}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Fe.ECEF?t.transformBeforeProject:null;if(o&&(r=U(new Float64Array(r.length),r,o)),t.reprojection===Fe.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=o?r:new Float64Array(r.length);return j(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Fe.ECEF?r.transformBeforeProject:null;a&&(o=G(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Fe.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return V(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Fe.ECEF?r.transformBeforeProject:null;a&&(o=D(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Fe.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return k(o,s,t,e.spatialReference,n)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=ae(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return se(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(s&&s.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const n=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,n),l=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,n),h=this._createTangentBuffer(e,i,n);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:l,symbolColorBuffer:u,objectTransformation:n.reprojection===Fe.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===Fe.NONE&&n.geometryTransformation?n.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===W.Local?Fe.NONE:Fe.ECEF:Fe.NONE;if(r){const{origin:r}=t,a=c(),i=e.transform?.localMatrix??u;if(o===Fe.NONE){w(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:m(i),needsBufferCopy:!1}}const l=s(c(),r);return n(l,l,i),{reprojection:o,transformBeforeProject:l,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,l=e.anchor;we[0]=l.x,we[1]=l.y,we[2]=l.z??0;const u=c();return w(e.spatialReference,we,u,n),i(Re,u),U(t,t,Re),(a||s)&&(r(Ae,u),o(Ae,Ae),a&&L(a,a,Ae),s&&L(s,s,Ae,4)),u}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??I(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=$({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference}),a=o.length/3;return P(Ie),R(Ie,o,0,a),!A(Ie,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!C(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:s,colorBuffer:n,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:h}=o,f=this._getOrCreateComponents(e),p=new Array;let d=!1;const g=l(je,m),x=this._context.localOriginFactory.getOrigin(g);for(const l of f){if(!this._validateFaces(e,l))return null;const t=this._getOrCreateFaces(e,l);if(0===t.length)continue;const o=this._createComponentNormals(a,c,l,t);o.didFlipNormals&&(d=!0);const m=[[pe.POSITION,new ie(a,t,3,!0)],[pe.NORMAL,new ie(o.normals,o.indices,3,!0)]];n&&m.push([pe.COLOR,new ie(n,t,4,!0)]),i&&m.push([pe.SYMBOLCOLOR,new ie(i,N(t.length),4,!0)]),s&&m.push([pe.UV0,new ie(s,t,2,!0)]),u&&m.push([pe.TANGENT,new ie(u,t,4,!0)]);const f=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,l),_=new me(g,m,null,ue.Mesh,f);_.transformation=h,_.localOrigin=x,p.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:p,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Ce{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const we=b(),je=b(),Oe=b(),Me=b(),Pe=b(),Re=c(),Ae=a(),Ee=c(),Ie=M(),Ne=[new B],Be=new S;var Fe;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Fe||(Fe={}));export{ve as Graphics3DMeshFillSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{B as t,m as e,i as a,h as s,d as r}from"../../../../chunks/mat4.js";import{I as i,a as o}from"../../../../chunks/mat4f64.js";import{i as n}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{perObjectElevationAligner as f}from"./ElevationAligners.js";import{evaluateElevationInfoAtPoint as l}from"./elevationAlignmentUtils.js";import{setContextFeature as d}from"./featureExpressionInfoUtils.js";import{Graphics3DObject3DGraphicLayer as c}from"./Graphics3DObject3DGraphicLayer.js";class g extends c{constructor(){super(...arguments),this._originalGeometries=[],this._fastTransformUpdatesEnabled=!1}get fastTransformUpdatesEnabled(){return this._fastTransformUpdatesEnabled}enableFastTransformUpdates(e,a){if(this._fastTransformUpdatesEnabled)return;this._fastTransformUpdatesEnabled=!0;const{stageObject:s}=this,r=s.geometries.slice();s.removeAllGeometries();const i=t(h,s.transformation),o=a.getOrigin(i);for(const t of r){const a=e(t.material),r=t.instantiate({material:a});r.localOrigin=o,s.addGeometry(r)}this._originalGeometries=r}disableFastTransformUpdates(t){if(!this._fastTransformUpdatesEnabled)return;this._fastTransformUpdatesEnabled=!1;const{stageObject:e}=this,a=e.geometries.map((e=>t(e.material)));e.removeAllGeometries();for(let s=0;s<this._originalGeometries.length;s++){const t=this._originalGeometries[s],r=a[s];r.setParameters({modelTransformation:null}),r===t.material?e.addGeometry(t):e.addGeometry(t.instantiate({material:r}))}this._originalGeometries.length=0}updateFastLocalOrigin(e,a,s){if(!this._fastTransformUpdatesEnabled)return;const{stageObject:r}=this;if(0===r.geometries.length)return;const o=r.geometries[0].localOrigin,n=t(h,e),m=s.getOrigin(n);if(m===o)return;const f=a?.localMatrix??i;r.shaderTransformation=null,r.transformation=e,r.geometries.forEach((t=>{t.transformation=f,t.localOrigin=m}))}updateTransform(t,s,r){const{stageObject:o}=this,n=s?.localMatrix??i;if(!this._fastTransformUpdatesEnabled)return o.shaderTransformation=null,o.transformation=t,o.geometries.forEach((t=>{t.transformation=n})),void this.resetEdgeObject(r);const m=o.transformation,f=o.geometries[0].transformation,l=t,d=n,c=e(p,m,f),g=e(T,l,d),h=e(E,g,a(E,f));o.shaderTransformation=h,this._setFastMaterialTransformation({matA:c,matB:g}),this._fastUpdateEdgeTransform()||this.resetEdgeObject(r)}alignWithElevation(t,a,r,i){if(!this._fastTransformUpdatesEnabled)return void super.alignWithElevation(t,a,r,i);null!=r&&d(this.elevationContext.featureExpressionInfoContext,r);const o=(e,s)=>l(e,t,this.elevationContext,a,s),{stageObject:n}=this;if(!n.geometries[0].material.parameters.modelTransformation)return;const m=n.transformation,c=n.geometries[0].transformation,g=e(p,m,c),h=n.effectiveTransformation,E=s(u,h);this.alignedSampledElevation=f(this,this.elevationContext,t.spatialReference,o,a,E),n.shaderTransformation=E;const b=n.geometries[0].transformation,_=e(T,E,b);this._setFastMaterialTransformation({matA:g,matB:_}),this._fastUpdateEdgeTransform()||this.resetEdgeObject(i)}_setFastMaterialTransformation({matA:t,matB:s}){const{stageObject:i}=this;if(0===i.geometries.length)return;const o=i.geometries[0].localOrigin,m=r(j,n(h,o.vec3,-1)),f=e(b,m,t),l=e(_,m,s),d=a(b,f),c=e(_,l,d);for(const e of i.geometries)e.material.setParameters({modelTransformation:c})}_fastUpdateEdgeTransform(){return this._stageLayer.stage.renderer.ensureEdgeView().fastUpdateObject3DEdgesTransform(this.stageObject)}}const h=m(),p=o(),T=o(),u=o(),E=o(),b=o(),_=o(),j=o();export{g as Graphics3DMeshObject3DGraphicLayer};
5
+ import{B as t,m as e,i as a,h as s,d as r}from"../../../../chunks/mat4.js";import{I as i,a as o}from"../../../../chunks/mat4f64.js";import{i as n}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{perObjectElevationAligner as f}from"./ElevationAligners.js";import{evaluateElevationInfoAtPoint as l}from"./elevationAlignmentUtils.js";import{setContextFeature as d}from"./featureExpressionInfoUtils.js";import{Graphics3DObject3DGraphicLayer as c}from"./Graphics3DObject3DGraphicLayer.js";class g extends c{constructor(){super(...arguments),this._originalGeometries=[],this._fastTransformUpdatesEnabled=!1}get fastTransformUpdatesEnabled(){return this._fastTransformUpdatesEnabled}enableFastTransformUpdates(e,a){if(this._fastTransformUpdatesEnabled)return;this._fastTransformUpdatesEnabled=!0;const{stageObject:s}=this,r=s.geometries.slice();s.removeAllGeometries();const i=t(h,s.transformation),o=a.getOrigin(i);for(const t of r){const a=e(t.material),r=t.instantiate({material:a});r.localOrigin=o,s.addGeometry(r)}this._originalGeometries=r}disableFastTransformUpdates(t){if(!this._fastTransformUpdatesEnabled)return;this._fastTransformUpdatesEnabled=!1;const{stageObject:e}=this,a=e.geometries.map((e=>t(e.material)));e.removeAllGeometries();for(let s=0;s<this._originalGeometries.length;s++){const t=this._originalGeometries[s],r=a[s];r.setParameters({modelTransformation:null}),r===t.material?e.addGeometry(t):e.addGeometry(t.instantiate({material:r}))}this._originalGeometries.length=0}updateFastLocalOrigin(e,a,s){if(!this._fastTransformUpdatesEnabled)return;const{stageObject:r}=this;if(0===r.geometries.length)return;const o=r.geometries[0].localOrigin,n=t(h,e),m=s.getOrigin(n);if(m===o)return;const f=a?.localMatrix??i;r.shaderTransformation=null,r.transformation=e,r.geometries.forEach((t=>{t.transformation=f,t.localOrigin=m}))}updateTransform(t,s,r){const{stageObject:o}=this,n=s?.localMatrix??i;if(!this._fastTransformUpdatesEnabled)return o.shaderTransformation=null,o.transformation=t,o.geometries.forEach((t=>{t.transformation=n})),void(this._fastUpdateEdgeTransform()||this.resetEdgeObject(r));const m=o.transformation,f=o.geometries[0].transformation,l=t,d=n,c=e(p,m,f),g=e(T,l,d),h=e(E,g,a(E,f));o.shaderTransformation=h,this._setFastMaterialTransformation({matA:c,matB:g}),this._fastUpdateEdgeTransform()||this.resetEdgeObject(r)}alignWithElevation(t,a,r,i){if(!this._fastTransformUpdatesEnabled)return void super.alignWithElevation(t,a,r,i);null!=r&&d(this.elevationContext.featureExpressionInfoContext,r);const o=(e,s)=>l(e,t,this.elevationContext,a,s),{stageObject:n}=this;if(!n.geometries[0].material.parameters.modelTransformation)return;const m=n.transformation,c=n.geometries[0].transformation,g=e(p,m,c),h=n.effectiveTransformation,E=s(u,h);this.alignedSampledElevation=f(this,this.elevationContext,t.spatialReference,o,a,E),n.shaderTransformation=E;const b=n.geometries[0].transformation,_=e(T,E,b);this._setFastMaterialTransformation({matA:g,matB:_}),this._fastUpdateEdgeTransform()||this.resetEdgeObject(i)}_setFastMaterialTransformation({matA:t,matB:s}){const{stageObject:i}=this;if(0===i.geometries.length)return;const o=i.geometries[0].localOrigin,m=r(j,n(h,o.vec3,-1)),f=e(b,m,t),l=e(_,m,s),d=a(b,f),c=e(_,l,d);for(const e of i.geometries)e.material.setParameters({modelTransformation:c})}_fastUpdateEdgeTransform(){return this._stageLayer.stage.renderer.ensureEdgeView().fastUpdateObject3DEdgesTransform(this.stageObject)}}const h=m(),p=o(),T=o(),u=o(),E=o(),b=o(),_=o(),j=o();export{g as Graphics3DMeshObject3DGraphicLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{resultOrAbort as e}from"../../../../core/asyncUtils.js";import{clone as t}from"../../../../core/lang.js";import{queryAllJSON as n}from"../../../../layers/support/featureQueryAll.js";const o={setAttribute(){},rollback(){},commit(){}};var r;function i(e,n){const i=n.attributes[e.objectIdField];if(null==i)return o;const s=e.sessions.get(i);if(s)return s;const l=t(n.attributes),a=new Set,u=e.i3sOverrides.createInteractiveEditSession(i),d=new Map,f=(e,t)=>{const n=d.get(e);if(null==n){const n=t.indexOf(i);return d.set(e,n),n}return n};let c=r.EDITING;const I={setAttribute(t,o){if(c!==r.EDITING)return;const i=e.fieldsIndex.get(t);if(!i)return;const s=e.attributeStorageInfo.findIndex((e=>e.name===i.name));if(s<0)return;if(!(t in l))throw new Error(`Attribute "${t}" is not an attribute of the edited feature.`);u.setAttribute(s,o);const d=e.attributeStorageInfo[s];let I=!1;a.add(t),e.forEachNode(((t,r)=>{const i=f(t,r);if(-1===i)return;const s=e.getAttributeData(t.index);if(s){const r=s[d.name];r&&(r[i]=o,e.setAttributeData(t.index,s,n),I=!0)}})),I&&e.clearMemCache()},rollback(){if(c===r.EDITING){for(const e of a)this.setAttribute(e,l[e]);u.remove(),c=r.ROLLED_BACK,e.sessions.delete(i)}},commit(){c===r.EDITING&&(u.remove(),c=r.COMMITTED,e.sessions.delete(i))}};return e.sessions.set(i,I),I}function s(e,t,n){const{gidToFeatureInfo:o,oidToFeatureInfo:r,fieldsIndex:i,objectIdField:s,globalIdField:l,featureOrIdentifierList:a}=n;if(!n.featuresResolved&&null!=a){for(const e of a){const t={feature:null,oid:-1,gid:null};if("attributes"in e){t.feature=e;const n=e.attributes;if(null!=n)for(const e in n){if(-1!==t.oid&&null!=t.gid)break;const o=i.normalizeFieldName(e);o===s&&(t.oid=n[e]??-1),o===l&&(t.gid=n[e])}}else t.oid=e.objectId??-1,t.gid=e.globalId;null!=t.gid&&o.set(t.gid,t),-1!==t.oid&&r.set(t.oid,t)}n.featuresResolved=!0}return(-1!==e?r.get(e):null)??(null!=t?o.get(t):null)}function l(e,t,n,o,r=!0){const i=[],l={gidToFeatureInfo:new Map,oidToFeatureInfo:new Map,featuresResolved:null==n,fieldsIndex:e.fieldsIndex,objectIdField:e.objectIdField,globalIdField:e.globalIdField,featureOrIdentifierList:n};for(const a of t){if(null!=a.error)continue;const e=a.objectId??-1,t=a.globalId,n=(-1===e||r?s(e,t,l):null)??{feature:null,oid:e,gid:t},u={oid:-1===e?n.oid:e,gid:t??n.gid,feature:n.feature,result:a};if(i.push(u),-1===u.oid&&null!=u.gid){let e=o.get(u.gid);null==e&&(e=[],o.set(u.gid,e)),e.push(u)}}return i}async function a(e,t){const n=new Map,o=l(e,t.addedFeatures,t.edits?.addFeatures,n),r=l(e,t.updatedFeatures,t.edits?.updateFeatures,n),i=l(e,t.deletedFeatures,t.edits?.deleteFeatures,n,!1);return n.size>0&&await u(e,n),{adds:o.filter((e=>-1!==e.oid)),updates:r.filter((e=>-1!==e.oid)),deletes:i.filter((e=>-1!==e.oid))}}async function u(t,o){const r=t.i3sOverrides.layer.associatedLayer;if(null==r?.globalIdField)return;const i=r.createQuery(),{objectIdField:s,globalIdField:l}=r;i.where=Array.from(o.keys()).map((e=>`${l}='${e}'`)).join(" OR "),i.returnGeometry=!1,i.outFields=[s,l],i.cacheHint=!1;const a=await e(n(r,i));if(!a.ok)return;const u=a.value.features;for(const e of u){const t=e.attributes[l],n=e.attributes[s];if(null==t||null==n||-1===n)continue;const r=o.get(t);if(null!=r)for(const e of r)e.oid=n}}function d(e,t){const n=new Map,o=t.adds,r=t.updates,i=t.deletes;if(o.length>0)for(const s of o){const e=s.oid,t=s.feature;"mesh"===t?.geometry?.type&&n.set(e,t.geometry)}if(r.length>0)for(const s of r){const e=s.oid,t=s.feature;"mesh"===t?.geometry?.type&&n.set(e,t.geometry)}if(i.length>0)for(const s of i)n.set(s.oid,null);for(const[s,l]of n)e.i3sOverrides.updateGeometry(s,l)}function f(e,t){const n=I(e,t),o=c(e,t);if(0===n.size&&0===o.size)return;const r=new Map;for(let c=0;c<e.attributeStorageInfo.length;c++)r.set(e.attributeStorageInfo[c].name,c);let i=!1;n.forEach(((t,n)=>{const o=e.getAttributeData(n);let s=!1;t.forEach(((t,n)=>{const l=null!=o?o[n]:null,a=r.get(n);for(const{featureIndex:o,value:r,featureId:u}of t)l&&(l[o]=r,s=!0,i=!0),e.i3sOverrides.updateAttributeValue(u,a,r)})),s&&e.setAttributeData(n,o,null)})),i&&e.clearMemCache();const{fieldsIndex:s,i3sOverrides:l,objectIdField:a,globalIdField:u}=e,d=l.layer.associatedLayer?.infoFor3D,f=new Set(d?[...Object.values(d.assetMapFieldRoles),...Object.values(d.transformFieldRoles)]:[]);for(const[c,I]of o){l.featureAdded(c);const{attributes:e}=I;for(const t in e){if(t!==a&&t!==u&&f.has(t))continue;const n=s.normalizeFieldName(t),o=null!=n?r.get(n):null;if(null==o)continue;const i=e[t];l.updateAttributeValue(c,o,i)}}}function c(e,t){const n=new Map,o=t.adds;if(!o||0===o.length||null==e.globalIdField)return n;for(const r of o){const e=r.oid,t=r.feature;"mesh"===t?.geometry?.type&&n.set(e,t)}return n}function I(e,t){const n=t.updates;if(!n||0===n.length)return new p;const o=new p,r=new Map;for(let i=0;i<e.attributeStorageInfo.length;i++)r.set(e.attributeStorageInfo[i].name,i);return e.forEachNode(((t,r)=>{for(const i of n){if(null==i.feature)continue;const n=i.feature,s=i.oid,l=r.indexOf(s);for(const r in n.attributes){const i=e.fieldsIndex.normalizeFieldName(r),a=g(o,t.index,i),u=n.attributes[r];a.push({featureIndex:l,featureId:s,value:u})}}})),o}function g(e,t,n){const o=b(e,t),r=null!=n&&o.get(n);if(r)return r;const i=new Array;return o.set(n,i),i}function b(e,t){const n=e.get(t);if(n)return n;const o=new m;return e.set(t,o),o}!function(e){e[e.EDITING=0]="EDITING",e[e.ROLLED_BACK=1]="ROLLED_BACK",e[e.COMMITTED=2]="COMMITTED"}(r||(r={}));const m=Map,p=Map;export{i as createInteractiveEditSession,a as normalizeEditResultsEvent,f as processAttributeEdits,d as processGeometryEdits};
5
+ import{resultOrAbort as e}from"../../../../core/asyncUtils.js";import{clone as t}from"../../../../core/lang.js";import{queryAllJSON as n}from"../../../../layers/support/featureQueryAll.js";const o={setAttribute(){},rollback(){},commit(){}};var r;function i(e,n){const i=n.attributes[e.objectIdField];if(null==i)return o;const s=e.sessions.get(i);if(s)return s;const l=t(n.attributes),u=new Set,a=e.i3sOverrides.createInteractiveEditSession(i),d=new Map,f=(e,t)=>{const n=d.get(e);if(null==n){const n=t.indexOf(i);return d.set(e,n),n}return n};let c=r.EDITING;const g={setAttribute(t,o){if(c!==r.EDITING)return;const i=e.fieldsIndex.get(t);if(!i)return;const s=e.attributeStorageInfo.findIndex((e=>e.name===i.name));if(s<0)return;if(!(t in l))throw new Error(`Attribute "${t}" is not an attribute of the edited feature.`);a.setAttribute(s,o);const d=e.attributeStorageInfo[s];let g=!1;u.add(t),e.forEachNode(((t,r)=>{const i=f(t,r);if(-1===i)return;const s=e.getAttributeData(t.index);if(s){const r=s[d.name];r&&(r[i]=o,e.setAttributeData(t.index,s,n),g=!0)}})),g&&e.clearMemCache()},rollback(){if(c===r.EDITING){for(const e of u)this.setAttribute(e,l[e]);a.remove(),c=r.ROLLED_BACK,e.sessions.delete(i)}},commit(){c===r.EDITING&&(a.remove(),c=r.COMMITTED,e.sessions.delete(i))}};return e.sessions.set(i,g),g}function s(e,t,n){const{gidToFeatureInfo:o,oidToFeatureInfo:r,fieldsIndex:i,objectIdField:s,globalIdField:l,featureOrIdentifierList:u}=n;if(!n.featuresResolved&&null!=u){for(const e of u){const t={feature:null,oid:-1,gid:null};if("attributes"in e){t.feature=e;const n=e.attributes;if(null!=n)for(const e in n){if(-1!==t.oid&&null!=t.gid)break;const o=i.normalizeFieldName(e);o===s&&(t.oid=n[e]??-1),o===l&&(t.gid=n[e])}}else t.oid=e.objectId??-1,t.gid=e.globalId;null!=t.gid&&o.set(t.gid,t),-1!==t.oid&&r.set(t.oid,t)}n.featuresResolved=!0}return(-1!==e?r.get(e):null)??(null!=t?o.get(t):null)}function l(e,t,n,o,r=null,i=!0){const l=[],u={gidToFeatureInfo:new Map,oidToFeatureInfo:new Map,featuresResolved:null==n,fieldsIndex:e.fieldsIndex,objectIdField:e.objectIdField,globalIdField:e.globalIdField,featureOrIdentifierList:n};for(const a of t){if(null!=a.error)continue;const e=a.objectId??-1,t=a.globalId,n=(-1===e||i?s(e,t,u):null)??{feature:null,oid:e,gid:t},d={oid:-1===e?n.oid:e,gid:t??n.gid,feature:n.feature,result:a};if(l.push(d),-1===d.oid&&null!=d.gid&&null!=r&&(d.oid=r.get(d.gid)??-1),-1===d.oid&&null!=d.gid){let e=o.get(d.gid);null==e&&(e=[],o.set(d.gid,e)),e.push(d)}}return l}async function u(e,t){const n=new Map,o=l(e,t.addedFeatures,t.edits?.addFeatures,n),r=l(e,t.updatedFeatures,t.edits?.updateFeatures,n),i=l(e,t.deletedFeatures,t.edits?.deleteFeatures,n,t.globalIdToObjectId,!1);return n.size>0&&await a(e,n),{adds:o.filter((e=>-1!==e.oid)),updates:r.filter((e=>-1!==e.oid)),deletes:i.filter((e=>-1!==e.oid))}}async function a(t,o){const r=t.i3sOverrides.layer.associatedLayer;if(null==r?.globalIdField)return;const i=r.createQuery(),{objectIdField:s,globalIdField:l}=r;i.where=Array.from(o.keys()).map((e=>`${l}='${e}'`)).join(" OR "),i.returnGeometry=!1,i.outFields=[s,l],i.cacheHint=!1;const u=await e(n(r,i));if(!u.ok)return;const a=u.value.features;for(const e of a){const t=e.attributes[l],n=e.attributes[s];if(null==t||null==n||-1===n)continue;const r=o.get(t);if(null!=r)for(const e of r)e.oid=n}}function d(e,t){const n=new Map,o=t.adds,r=t.updates,i=t.deletes;if(o.length>0)for(const s of o){const e=s.oid,t=s.feature;"mesh"===t?.geometry?.type&&n.set(e,t.geometry)}if(r.length>0)for(const s of r){const e=s.oid,t=s.feature;"mesh"===t?.geometry?.type&&n.set(e,t.geometry)}if(i.length>0)for(const s of i)n.set(s.oid,null);for(const[s,l]of n)e.i3sOverrides.updateGeometry(s,l)}function f(e,t){const n=g(e,t),o=c(e,t);if(0===n.size&&0===o.size)return;const r=new Map;for(let c=0;c<e.attributeStorageInfo.length;c++)r.set(e.attributeStorageInfo[c].name,c);let i=!1;n.forEach(((t,n)=>{const o=e.getAttributeData(n);let s=!1;t.forEach(((t,n)=>{const l=null!=o?o[n]:null,u=r.get(n);for(const{featureIndex:o,value:r,featureId:a}of t)l&&(l[o]=r,s=!0,i=!0),e.i3sOverrides.updateAttributeValue(a,u,r)})),s&&e.setAttributeData(n,o,null)})),i&&e.clearMemCache();const{fieldsIndex:s,i3sOverrides:l,objectIdField:u,globalIdField:a}=e,d=l.layer.associatedLayer?.infoFor3D,f=new Set(d?[...Object.values(d.assetMapFieldRoles),...Object.values(d.transformFieldRoles)]:[]);for(const[c,g]of o){l.featureAdded(c);const{attributes:e}=g;for(const t in e){if(t!==u&&t!==a&&f.has(t))continue;const n=s.normalizeFieldName(t),o=null!=n?r.get(n):null;if(null==o)continue;const i=e[t];l.updateAttributeValue(c,o,i)}}}function c(e,t){const n=new Map,o=t.adds;if(!o||0===o.length||null==e.globalIdField)return n;for(const r of o){const e=r.oid,t=r.feature;"mesh"===t?.geometry?.type&&n.set(e,t)}return n}function g(e,t){const n=t.updates;if(!n||0===n.length)return new p;const o=new p,r=new Map;for(let i=0;i<e.attributeStorageInfo.length;i++)r.set(e.attributeStorageInfo[i].name,i);return e.forEachNode(((t,r)=>{for(const i of n){if(null==i.feature)continue;const n=i.feature,s=i.oid,l=r.indexOf(s);for(const r in n.attributes){const i=e.fieldsIndex.normalizeFieldName(r),u=I(o,t.index,i),a=n.attributes[r];u.push({featureIndex:l,featureId:s,value:a})}}})),o}function I(e,t,n){const o=b(e,t),r=null!=n&&o.get(n);if(r)return r;const i=new Array;return o.set(n,i),i}function b(e,t){const n=e.get(t);if(n)return n;const o=new m;return e.set(t,o),o}!function(e){e[e.EDITING=0]="EDITING",e[e.ROLLED_BACK=1]="ROLLED_BACK",e[e.COMMITTED=2]="COMMITTED"}(r||(r={}));const m=Map,p=Map;export{i as createInteractiveEditSession,u as normalizeEditResultsEvent,f as processAttributeEdits,d as processGeometryEdits};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e}from"../../../../core/maybe.js";import{MemCachePool as t}from"../../../../core/MemCachePool.js";import{PixelFormat as r,SizedPixelFormat as o,TextureWrapMode as a,PixelType as s,TextureSamplingMode as h,RenderbufferFormat as c,ColorAttachment as i}from"../../../webgl/enums.js";import{FramebufferObject as n}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as l}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as p}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as _}from"../../../webgl/Texture.js";import{TextureDescriptor as m}from"../../../webgl/TextureDescriptor.js";class d{constructor(e){this.rctx=e,this._peakMemoryUsage=0,this._allocatedMemory=new Set,this._cache=new t(e.newCache,"FBOCache"),this._depthCache=new t(e.newCache,"DepthAttachmentCache"),this._colorCache=new t(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}resetPeakMemoryUsage(){this._peakMemoryUsage=this._accumulateMemory()}get peakMemoryUsage(){return this._peakMemoryUsage}acquire(e,t,r){const o=R(e,t,r),a=this._cache.pop(o)||new u(new n(this.rctx,{...x[e],width:t,height:r}),(e=>(a.releaseDepth(),a.depth=this._acquireDepth(e,a.fbo.width,a.fbo.height),a.fbo.attachDepthStencil(a.depth.attachment),a)),((e,o)=>{const s=this._acquireColor(e,t,r);return a.colors??=new Map,a.colors.set(o,s),a.fbo.attachColorTexture(s.attachment,o),a}));return a.release=()=>{this._allocatedMemory.delete(a),a.releaseDepth(),this._cache.put(o,a),a.release=()=>console.log(`Double FBO release in ${(new Error).stack}`)},this.rctx.unbindTexture(a.fbo.colorTexture),this._trackHandle(a)}acquireDepth(e,t,r){return this._acquireDepth(e,t,r)}_acquireDepth(e,t,r){const o=R(e,t,r),a=this._depthCache.pop(o);if(a)return this._trackHandle(a);const s=e===P.DEPTH_STENCIL_TEXTURE?new T(new _(this.rctx,{...G[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(s),this._depthCache.put(o,s)})):new T(new l(this.rctx,{...G[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(s),this._depthCache.put(o,s)}));return this._trackHandle(s)}_acquireColor(e,t,r){const o=R(e,t,r),a=this._colorCache.pop(o);if(a)return this._trackHandle(a);const s=new M(new _(this.rctx,{...x[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(s),this._colorCache.put(o,s)}));return this._trackHandle(s)}_trackHandle(e){return this._allocatedMemory.add(e),this._peakMemoryUsage=Math.max(this._peakMemoryUsage,this._accumulateMemory()),e}_accumulateMemory(){return Array.from(this._allocatedMemory.values()).reduce(((e,t)=>e+("colorTexture"in t?t.colorTexture?.gpuMemoryUsage??0:t.memoryUsage)),0)}}class u{constructor(e,t,r){this.fbo=e,this.acquireDepth=t,this.acquireColor=r,this.release=()=>{}}dispose(){this.fbo.dispose()}releaseDepth(){this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),this.depth=e(this.depth)}detachDepth(){const e=this.depth;return this.depth=void 0,this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),e}attachDepth(e){return this.releaseDepth(),e&&(this.fbo.attachDepthStencil(e.attachment),this.depth=e),this}releaseColor(t){this.fbo.detachColorTexture(t);const r=this.colors?.get(t);this.colors?.delete(t),e(r)}get colorTexture(){return this.fbo?.colorTexture}getColorTexture(e=i.COLOR_ATTACHMENT0){return this.fbo?.getColorTexture(e)}get memoryUsage(){return this.fbo.gpuMemoryUsage}}class E{constructor(e,t){this.attachment=e,this.release=t}dispose(){this.attachment.dispose()}get memoryUsage(){return this.attachment.gpuMemoryUsage}}class T extends E{}class M extends E{constructor(e,t){super(e,t),this.attachment=e,this.release=t}}function R(e,t,r){return`${e}x${t}x${r}`}var D;!function(e){e[e.RED=0]="RED",e[e.RG=1]="RG",e[e.RGBA4=2]="RGBA4",e[e.RGBA=3]="RGBA",e[e.RGBA_MIPMAP=4]="RGBA_MIPMAP",e[e.R16F=5]="R16F",e[e.RGBA16F=6]="RGBA16F"}(D||(D={}));const w=new m;w.pixelFormat=r.RED,w.internalFormat=o.R8,w.wrapMode=a.CLAMP_TO_EDGE;const f=new m;f.pixelFormat=r.RG,f.internalFormat=o.RG8,f.wrapMode=a.CLAMP_TO_EDGE;const C=new m;C.internalFormat=o.RGBA4,C.dataType=s.UNSIGNED_SHORT_4_4_4_4,C.wrapMode=a.CLAMP_TO_EDGE;const g=new m;g.wrapMode=a.CLAMP_TO_EDGE;const A=new m;A.wrapMode=a.CLAMP_TO_EDGE,A.samplingMode=h.LINEAR_MIPMAP_LINEAR,A.hasMipmap=!0,A.maxAnisotropy=8;const F=new m;F.pixelFormat=r.RED,F.dataType=s.HALF_FLOAT,F.internalFormat=o.R16F,F.samplingMode=h.NEAREST;const y=new m;y.dataType=s.HALF_FLOAT,y.internalFormat=o.RGBA16F,y.samplingMode=h.NEAREST;const x={[D.RED]:w,[D.RG]:f,[D.RGBA4]:C,[D.RGBA]:g,[D.RGBA_MIPMAP]:A,[D.R16F]:F,[D.RGBA16F]:y};var P;!function(e){e[e.DEPTH_STENCIL_TEXTURE=0]="DEPTH_STENCIL_TEXTURE",e[e.DEPTH24_BUFFER=1]="DEPTH24_BUFFER",e[e.DEPTH16_BUFFER=2]="DEPTH16_BUFFER"}(P||(P={}));const b=new m;b.pixelFormat=r.DEPTH_STENCIL,b.dataType=s.UNSIGNED_INT_24_8,b.samplingMode=h.NEAREST,b.wrapMode=a.CLAMP_TO_EDGE;const G={[P.DEPTH_STENCIL_TEXTURE]:b,[P.DEPTH24_BUFFER]:new p(c.DEPTH_COMPONENT24,4),[P.DEPTH16_BUFFER]:new p(c.DEPTH_COMPONENT16,4)};export{D as ColorFormat,P as DepthFormat,d as FBOCache};
5
+ import{releaseMaybe as e}from"../../../../core/maybe.js";import{MemCachePool as t}from"../../../../core/MemCachePool.js";import{PixelFormat as r,SizedPixelFormat as o,TextureWrapMode as a,PixelType as s,TextureSamplingMode as h,RenderbufferFormat as c,ColorAttachment as i}from"../../../webgl/enums.js";import{FramebufferObject as n}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as l}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as _}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as p}from"../../../webgl/Texture.js";import{TextureDescriptor as m}from"../../../webgl/TextureDescriptor.js";class E{constructor(e){this.rctx=e,this._peakMemoryUsage=0,this._allocatedMemory=new Set,this._cache=new t(e.newCache,"FBOCache"),this._depthCache=new t(e.newCache,"DepthAttachmentCache"),this._colorCache=new t(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}resetPeakMemoryUsage(){this._peakMemoryUsage=this._accumulateMemory()}get peakMemoryUsage(){return this._peakMemoryUsage}acquire(e,t,r){const o=M(e,t,r),a=this._cache.pop(o)||new d(new n(this.rctx,{...y[e],width:t,height:r}),(e=>(a.releaseDepth(),a.depth=this._acquireDepth(e,a.fbo.width,a.fbo.height),a.fbo.attachDepthStencil(a.depth.attachment),a)),((e,o)=>{const s=this._acquireColor(e,t,r);return a.colors??=new Map,a.colors.set(o,s),a.fbo.attachColorTexture(s.attachment,o),a}));return a.release=()=>{this._allocatedMemory.delete(a),a.releaseDepth(),this._cache.put(o,a),a.release=()=>console.log(`Double FBO release in ${(new Error).stack}`)},this.rctx.unbindTexture(a.fbo.colorTexture),this._trackHandle(a)}acquireDepth(e,t,r){return this._acquireDepth(e,t,r)}_acquireDepth(e,t,r){const o=M(e,t,r),a=this._depthCache.pop(o);if(a)return this._trackHandle(a);const s=e===x.DEPTH_STENCIL_TEXTURE?new T(new p(this.rctx,{...U[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(s),this._depthCache.put(o,s)})):new T(new l(this.rctx,{...U[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(s),this._depthCache.put(o,s)}));return this._trackHandle(s)}_acquireColor(e,t,r){const o=M(e,t,r),a=this._colorCache.pop(o);if(a)return this._trackHandle(a);const s=new D(new p(this.rctx,{...y[e],width:t,height:r}),(()=>{this._allocatedMemory.delete(s),this._colorCache.put(o,s)}));return this._trackHandle(s)}_trackHandle(e){return this._allocatedMemory.add(e),this._peakMemoryUsage=Math.max(this._peakMemoryUsage,this._accumulateMemory()),e}_accumulateMemory(){return Array.from(this._allocatedMemory.values()).reduce(((e,t)=>e+("colorTexture"in t?t.colorTexture?.gpuMemoryUsage??0:t.memoryUsage)),0)}}class d{constructor(e,t,r){this.fbo=e,this.acquireDepth=t,this.acquireColor=r,this.release=()=>{}}dispose(){this.fbo.dispose()}releaseDepth(){this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),this.depth=e(this.depth)}detachDepth(){const e=this.depth;return this.depth=void 0,this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),e}attachDepth(e){return this.releaseDepth(),e&&(this.fbo.attachDepthStencil(e.attachment),this.depth=e),this}releaseColor(t){this.fbo.detachColorTexture(t);const r=this.colors?.get(t);this.colors?.delete(t),e(r)}get colorTexture(){return this.fbo?.colorTexture}getColorTexture(e=i.COLOR_ATTACHMENT0){return this.fbo?.getColorTexture(e)}get memoryUsage(){return this.fbo.gpuMemoryUsage}}class u{constructor(e,t){this.attachment=e,this.release=t}dispose(){this.attachment.dispose()}get memoryUsage(){return this.attachment.gpuMemoryUsage}}class T extends u{}class D extends u{constructor(e,t){super(e,t),this.attachment=e,this.release=t}}function M(e,t,r){return`${e}x${t}x${r}`}var R;!function(e){e[e.RED=0]="RED",e[e.RG=1]="RG",e[e.RGBA4=2]="RGBA4",e[e.RGBA=3]="RGBA",e[e.RGBA_MIPMAP=4]="RGBA_MIPMAP",e[e.R16F=5]="R16F",e[e.RGBA16F=6]="RGBA16F"}(R||(R={}));const w=new m;w.pixelFormat=r.RED,w.internalFormat=o.R8,w.wrapMode=a.CLAMP_TO_EDGE;const C=new m;C.pixelFormat=r.RG,C.internalFormat=o.RG8,C.wrapMode=a.CLAMP_TO_EDGE;const F=new m;F.internalFormat=o.RGBA4,F.dataType=s.UNSIGNED_SHORT_4_4_4_4,F.wrapMode=a.CLAMP_TO_EDGE;const f=new m;f.wrapMode=a.CLAMP_TO_EDGE;const g=new m;g.wrapMode=a.CLAMP_TO_EDGE,g.samplingMode=h.LINEAR_MIPMAP_LINEAR,g.hasMipmap=!0,g.maxAnisotropy=8;const A=new m;A.pixelFormat=r.RED,A.dataType=s.HALF_FLOAT,A.internalFormat=o.R16F,A.samplingMode=h.NEAREST;const P=new m;P.dataType=s.HALF_FLOAT,P.internalFormat=o.RGBA16F,P.samplingMode=h.NEAREST;const y={[R.RED]:w,[R.RG]:C,[R.RGBA4]:F,[R.RGBA]:f,[R.RGBA_MIPMAP]:g,[R.R16F]:A,[R.RGBA16F]:P};var x;!function(e){e[e.DEPTH_STENCIL_TEXTURE=0]="DEPTH_STENCIL_TEXTURE",e[e.DEPTH_STENCIL_BUFFER=1]="DEPTH_STENCIL_BUFFER",e[e.DEPTH24_BUFFER=2]="DEPTH24_BUFFER",e[e.DEPTH16_BUFFER=3]="DEPTH16_BUFFER"}(x||(x={}));const b=new m;b.pixelFormat=r.DEPTH_STENCIL,b.dataType=s.UNSIGNED_INT_24_8,b.samplingMode=h.NEAREST,b.wrapMode=a.CLAMP_TO_EDGE;const U={[x.DEPTH_STENCIL_TEXTURE]:b,[x.DEPTH_STENCIL_BUFFER]:new _(c.DEPTH24_STENCIL8,4),[x.DEPTH24_BUFFER]:new _(c.DEPTH_COMPONENT24,4),[x.DEPTH16_BUFFER]:new _(c.DEPTH_COMPONENT16,4)};export{R as ColorFormat,x as DepthFormat,E as FBOCache};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import h from"../../../../core/PooledArray.js";import{watch as o,syncAndInitial as d,initial as l,sync as _}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{a as c,i as m,m as f}from"../../../../chunks/mat4.js";import{I as g,a as T}from"../../../../chunks/mat4f64.js";import{s as A}from"../../../../chunks/vec4.js";import{f as P,Z as R}from"../../../../chunks/vec4f64.js";import{a as E}from"../../../../chunks/boundedPlane.js";import{debugFlags as b}from"../../support/debugFlags.js";import{TransparencyMode as S}from"../../terrain/TerrainRenderer.js";import{FBOCache as I,ColorFormat as y,DepthFormat as C}from"../core/FBOCache.js";import{RenderPassManager as w}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as O}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as D}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{RenderPluginInput as N}from"../effects/RenderPluginInput.js";import{RenderPluginManager as M}from"../effects/RenderPluginManager.js";import{Blit as L}from"../effects/blit/Blit.js";import{Highlight as H}from"../effects/highlight/Highlight.js";import{ShadowHighlight as x}from"../effects/highlight/ShadowHighlight.js";import{SMAA as F}from"../effects/smaa/SMAA.js";import{SSAO as v}from"../effects/ssao/SSAO.js";import{AnimationTimeStep as U}from"./AnimationTimeStep.js";import{Decorations as B,RenderRequestType as G,StencilBits as j}from"./basicInterfaces.js";import{BoundingInfo as q}from"./BoundingInfo.js";import{zero as V,union as Q}from"./depthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{RenderOccludedFlag as k}from"./Material.js";import{OffscreenRendering as X}from"./OffscreenRendering.js";import{RenderContext as Y}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as z}from"./rendererUtils.js";import{setupFeatureDefaults as J,RenderFeature as K}from"./RenderFeature.js";import{RenderSlot as Z}from"./RenderSlot.js";import{ShadowAccumulator as $}from"./ShadowAccumulator.js";import{ShadowMap as ee,SnapshotSlot as re}from"./ShadowMap.js";import te from"./SliceHelper.js";import{TransparencyPassType as se}from"./TransparencyPassType.js";import{EdgeView as ie}from"./edgeRendering/EdgeView.js";import{Transparency as ae}from"./edgeRendering/interfaces.js";import{MergedRenderer as ne}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as he}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as oe,PerformanceCategory as de}from"../statistics/RendererPerformanceInfo.js";import{RenderState as le}from"../../../support/RenderState.js";import{PixelFormat as _e,PixelType as pe,ClearBufferBit as ue}from"../../../webgl/enums.js";let ce=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=J(r,e),this.notifyChange("_renderStateFeatures"),this._renderPlugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(K.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(K.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces(Z.OPAQUE_MATERIAL,O.Highlight)||this._renderPlugins.produces(Z.DRAPED_MATERIAL,O.Highlight)}get hasShadowHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces(Z.OPAQUE_MATERIAL,O.ShadowHighlight)}get _magnifierEnabled(){return this._bindParameters.decorations===B.ON&&this._magnifierHelper.enabled}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(K.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,i,a,n,_,p){super({}),this._stage=e,this._techniqueRepository=i,this._rctx=a,this._compositingHelper=n,this._magnifierHelper=_,this._requestRender=p,this._materialRenderers=new h,this._needsTransparentPass=!1,this._materialRenderersHas={hudElements:!1,highlights:!1,water:!1,decorations:!1,occludees:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._backgroundColor=P(0,0,0,1),this._sliceHelper=new te,this._state=le.IDLE,this._highQualityTransparencyEnabled=!0,this._terrainTransparency=S.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new U,this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new N,this.fboCache=new I(a),this._renderStateFeatures=J(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._offscreen=new X(this.fboCache,this._compositingHelper),this.performanceInfo=new oe(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._highlight=new H({view:e.view}),this._shadowHighlight=new x({view:e.view,viewingMode:e.viewingMode}),this._shadowAccumulator=new $(this.fboCache,i,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t,!0,this._stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(O.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),p),this._ssao=new v({view:this._stage.view}),this._renderContext=new Y(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._renderPlugins=new M({renderContext:this._renderContext,techniqueRepository:i,textureRepository:t,materialRepository:r,requestRender:p,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new w,this._renderPlugins.add(this.renderPassManager),this._smaa=new F({view:this._stage.view}),this._renderPlugins.add(this._smaa),this._blit=new L({opacity:1,alphaMode:he.None}),this._renderPlugins.add(this._blit),this._renderPlugins.add(this._ssao),this._renderPlugins.add(this._highlight),this._renderPlugins.add(this._shadowHighlight),this.addHandles([o((()=>this._stage.view.state.camera),(()=>p()),d),o((()=>b.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(ae.TRANSPARENT):()=>{},p()}),l),o((()=>this._stage.view.environment.background?.color),(e=>{const r=e?s(e):R;A(this._backgroundColor,r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),p()}),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaa.destroy(),this._blit.destroy(),this._gpuTimerHandle=i(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._shadowMap.dispose(),this._ssao.destroy(),this._highlight.dispose(),this._shadowHighlight.destroy(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),q.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}disposeOffscreenBuffers(){this._releaseFBOs(),this._disposeOffscreenBuffers()}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}get updating(){return this._smaa.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._renderPlugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new ie({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:Ee(e)}),this.addHandles(o((()=>this._edgeView?.updating),(()=>this._requestRender()),_)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return c(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=z(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));if(null==i&&t.adds.length>0){const e=new ne({material:s});e.initializeRenderContext(this._renderPlugins._context),i=e,this._materialRenderers.push(i)}i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._materialRenderersHas;has.decorations=!1,has.highlights=!1,has.hudElements=!1,has.water=!1,has.occludees=!1,this._materialRenderers.forAll((e=>{has.highlights||=e.hasHighlights,has.occludees||=e.hasOccludees,has.water||=e.hasWater,has.decorations||=e.isDecoration,has.hudElements||=e.material.produces(Z.LINE_CALLOUTS_HUD_DEPTH,O.Color)||e.material.produces(Z.HUD_MATERIAL,O.Color)||e.material.produces(Z.LABEL_MATERIAL,O.Color)})),this._bindParameters.hasOccludees=has.occludees}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}render(e,r,t,s,i){this._isRendering=!0,this.performanceInfo.startFrame(),this._disposeBindBuffers(),this.fboCache.resetPeakMemoryUsage();const a=this._offscreen,{camera:h,contentCamera:o,mode:d,alignPixelEnabled:l}=t;this._state=d,this._bindParameters.overlay=this.renderOverlay(i),this.performanceInfo.advance(de.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=se.NONE,this._bindParameters.alignPixelEnabled=l,this._bindParameters.decorations=s;const _=E(this._sliceHelper.plane);s===B.OFF&&(this._sliceHelper.plane=null),h.setGLViewport(this._rctx);const p=a.initializeFrame(h,this._backgroundColor);this.hasReflections?this._bindParameters.ssr.lastFrameColor=p:p?.release(),this._prepare(h,o),this._renderPlugins.prepareRender(),this.performanceInfo.advance(de.PREPARE);const u=this._computeDepthRange(h);this._renderShadowMap(h,this._bindParameters.lighting.mainLight.direction,u),this.performanceInfo.advance(de.SHADOW_MAP),this._ensureBindParameters(h,o);const c=this._renderPlugins.produces(Z.OPAQUE_TERRAIN)&&(this._terrainTransparency===S.Semitransparent||this._terrainTransparency===S.TransparentWithDraped),m=this._highQualityTransparency&&c,f=this._needsTransparentPass||this._renderPlugins.produces(Z.TRANSPARENT_MATERIAL);this._prepareShaders(m,f),this._renderLinearDepth(),this.performanceInfo.advance(de.LINEAR_DEPTH),this._renderShadowAccumulation(u,h,o),this.performanceInfo.advance(de.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(),this.performanceInfo.advance(de.SSAO),this._renderContext.output=O.Color,a.bindFbo(),this._renderOpaqueGeometry(),this._renderPlugins.render(Z.ENVIRONMENT_OPAQUE),this.performanceInfo.advance(de.OPAQUE),this._renderTerrainLinearDepth(m),this._setMultipassTerrain(m),this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(de.OPAQUE_EDGES),a.bindFbo(),this._renderPlugins.render(Z.VOXEL),this.performanceInfo.advance(de.VOXEL),this._renderHiddenTransparentEdges(),f&&(this._oitEnabled?this._renderOITPass(me.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(de.TRANSPARENT);const g=this._renderGeometryLinearDepth(m);this._renderHUDVisibility(g),m||this._renderInternalSlot(Z.LINE_CALLOUTS),this.performanceInfo.advance(de.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(de.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(ae.TRANSPARENT,g),g?.release(),this.performanceInfo.advance(de.TRANSPARENT_EDGES);const T=c?this._renderTransparentTerrain():null;T&&this._bindParameters.hudVisibility&&(m?this._renderLineCallouts(D.Occluded):a.compositeToHUDVisibility(this._bindParameters,T.colorTexture),this._renderHUD(D.Occluded,a.color),this.performanceInfo.advance(de.HUD_OCCLUDED)),this.performanceInfo.advance(de.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),T&&(a.compositeToFramebuffer(this._bindParameters,T.colorTexture,he.PremultipliedAlpha,1),T.release(),m&&(this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(de.OPAQUE_EDGES),f&&(this._oitEnabled?this._renderOITPass(me.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(de.TRANSPARENT),this._renderEdges(ae.TRANSPARENT),this.performanceInfo.advance(de.TRANSPARENT_EDGES))),this._bindParameters.ssao=n(this._bindParameters.ssao),m&&this._renderLineCallouts(D.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),a.bindFbo(),this._renderInternalSlot(Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.render(Z.ENVIRONMENT_TRANSPARENT),this.performanceInfo.advance(de.ENVIRONMENT),this._renderLaserlines(),this.performanceInfo.advance(de.LASER_LINES),this._renderOccluded(),this.performanceInfo.advance(de.OCCLUDED);const A=this._magnifierEnabled&&null==e?this.fboCache.acquire(y.RGBA,this._offscreen.width,this._offscreen.height).acquireDepth(C.DEPTH16_BUFFER):null,P=this._renderComposite(A??e,this._offscreen.color)??e;this.performanceInfo.advance(de.ANTIALIASING),this._renderHUD(D.NotOccluded,P),this.performanceInfo.advance(de.HUD),this._renderHighlights(P,this._bindParameters),this.performanceInfo.advance(de.HIGHLIGHTS),this._magnifierEnabled&&this._magnifierHelper.render(this._rctx,this._bindParameters),P!==e&&(this._rctx.bindFramebuffer(e?.fbo),this._compositingHelper.composite(this._bindParameters,A?.colorTexture,he.None)),A!==e&&A?.release(),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=_,this._isRendering=!1,this.performanceInfo.finishFrame()}_prepareShaders(e,r){this._renderContext.output=O.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._renderPlugins.prepare(Z.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,Z.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.prepare(Z.ENVIRONMENT_TRANSPARENT),this._renderPlugins.prepare(Z.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(e){if(null==e||!has("enable-feature:objectAndLayerId-rendering"))return;const r=this._renderContext.output;this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>this._renderAllGeometry(O.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=D.NotOccluded,this._renderInternalSlot(Z.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===G.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._bindParameters.linearDepth?.fbo;if(s?.colorTexture)return void s.readPixels(r[0],r[1],r[2],r[3],_e.RGBA,pe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(y.RGBA,this._offscreen.width,this._offscreen.height).acquireDepth(C.DEPTH16_BUFFER);this._rctx.bindFramebuffer(i.fbo),this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const a=ue.COLOR_BUFFER_BIT|ue.DEPTH_BUFFER_BIT|ue.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderAllGeometry(O.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],_e.RGBA,pe.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,_e.RGBA,pe.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(y.RGBA,s,i),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,ge),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,he.Alpha,1),n.release()}}_renderShadowMap(e,r,t){const s=this._shadowMap;s.enabled&&(s.start(e,r,t,this.isFeatureEnabled(K.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(e,r),this._needsShadowHighlight?(this._renderShadowCascades(O.ShadowHighlight,this._shadowMap),s.moveSnapshot(re.Highlight),s.clear(),this._renderShadowCascades(O.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(re.Default),this._renderShadowCascades(O.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(O.Shadow),s.finish(),e.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap){for(const t of r.cascades)t.camera.setGLViewport(this._rctx),this._prepare(t.camera,t.camera),this._renderAllGeometry(e)}get _needsLinearDepth(){return this._renderPlugins.consumes(O.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,(()=>this._renderAllGeometry(O.Depth)),[0,0,0,0],y.RGBA,C.DEPTH_STENCIL_TEXTURE),this._bindParameters.linearDepth.releaseDepth(),this._offscreen.bindFbo()):this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=O.Depth,this._bindParameters.multipassTerrain.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassTerrain.linearDepth,(()=>this._renderTransparentTerrain()),[-1e10,-1e10,-1e10,1]),this._bindParameters.multipassTerrain.linearDepth.releaseDepth(),this._renderContext.output=e}else this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth)}_renderGeometryLinearDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth));const r=this._renderContext.output;return this._bindParameters.multipassGeometry.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassGeometry.linearDepth,(()=>this._renderOpaqueGeometryAndTransparentMaterial(O.Depth)),[1,1,1,1]),this._renderContext.output=r,this._bindParameters.multipassGeometry.linearDepth.detachDepth()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return V;const r=W(e,this._materialRenderers,this._stage.layers);return Q(r,this._renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderAllGeometry(e){this._renderContext.output=e,this._renderPlugins.prepare(Z.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderSSAO(){if(!this._renderPlugins.produces(Z.SSAO))return;const e=this._offscreen.renderToCachedFBO(null,(()=>this._renderAllGeometry(O.Normal)),[0,0,0,0],y.RGBA4,C.DEPTH24_BUFFER);e.releaseDepth(),this._offscreen.bindFbo(),this._pluginInput.normal=e,this._bindParameters.ssao=this._renderPlugins.render(Z.SSAO,this._pluginInput),e.release()}_prepareOpaqueGeometrySlots(){this._renderPlugins.prepare(Z.INTEGRATED_MESH),this._renderPlugins.prepare(Z.OPAQUE_TERRAIN),this._renderPlugins.prepare(Z.OPAQUE_MATERIAL),this._renderPlugins.prepare(Z.ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,Z.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderPlugins.render(Z.INTEGRATED_MESH),this._renderPlugins.render(Z.OPAQUE_TERRAIN),this._renderInternalSlot(Z.OPAQUE_MATERIAL),this._renderPlugins.render(Z.OPAQUE_MATERIAL)}_renderTransparentMaterial(){this._renderInternalSlot(Z.TRANSPARENT_MATERIAL),this._renderPlugins.render(Z.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){if(!this._renderPlugins.produces(Z.TRANSPARENT_TERRAIN))return;const e=()=>this._renderPlugins.render(Z.TRANSPARENT_TERRAIN,null);if(this._renderContext.output!==O.Color)return void e();const{width:r,height:t,depth:s}=this._offscreen,i=this.fboCache.acquire(y.RGBA,r,t);return this._offscreen.renderToTargets(e,i,s,[0,0,0,0]),i}_renderHUDVisibility(e){this._shouldRenderInternalSlot(this._materialRenderers,Z.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._renderInternalSlot(Z.OCCLUSION_PIXELS)),e),this._offscreen.bindFbo()):this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===D.Occluded){const e=()=>this._renderInternalSlot(Z.LINE_CALLOUTS),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(C.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderInternalSlot(Z.LINE_CALLOUTS)}_renderLaserlines(){if(this._renderPlugins.render(Z.LASERLINES),this._renderPlugins.produces(Z.LASERLINES_CONTRAST_CONTROL)){const e=this._offscreen,{width:r,height:t,depth:s}=e,i=this.fboCache.acquire(y.RGBA,r,t),a=()=>this._renderPlugins.render(Z.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,ge),e.compositeToFramebuffer(this._bindParameters,i.colorTexture,he.PremultipliedAlpha,1),i.release()}}_renderHUD(e,r){if(this._materialRenderersHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(me.HUD,e);this._rctx.bindFramebuffer(r?.fbo),this._compositingHelper.composite(this._bindParameters,t.colorTexture,he.PremultipliedAlpha),t.release()}else if(e===D.Occluded){const r=()=>this._renderHUDElements(e),{width:t,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(C.DEPTH16_BUFFER,t,s);this._offscreen.renderToTargets(r,i,a,void 0,!0,!0),a.release()}else this._renderHUDElements(e)}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,Z.LINE_CALLOUTS_HUD_DEPTH,Z.HUD_MATERIAL,Z.LABEL_MATERIAL),this._renderInternalSlot(Z.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(Z.HUD_MATERIAL),this._renderInternalSlot(Z.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._renderPlugins.produces(Z.SHADOW_HIGHLIGHT)&&this.hasShadowHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===B.OFF)return;const t=()=>{this._renderAllGeometry(O.Highlight),this._rctx.clearSafe(ue.DEPTH_BUFFER_BIT),this._renderHUDElements(D.Both)},s=this._offscreen.renderToCachedFBO(null,t,[0,0,0,0],y.RGBA4,C.DEPTH_STENCIL_TEXTURE);this._needsShadowHighlight&&(this._pluginInput.highlight=s,this._renderPlugins.render(Z.SHADOW_HIGHLIGHT,this._pluginInput,e)),s.releaseDepth(),this._renderPlugins.produces(Z.HIGHLIGHT)&&(this._pluginInput.composite=null,this._pluginInput.normal=null,this._pluginInput.highlight=s,this._renderPlugins.render(Z.HIGHLIGHT,this._pluginInput,e)),s.release()}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=O.Alpha,this._bindParameters.transparencyPassType=se.Alpha,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._renderContext.output=O.Color,this._bindParameters.transparencyPassType=se.Color,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=se.FrontFace,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=se.NONE}_renderOITPass(e,r=D.Both){const t=e===me.HUD,s=t?this.fboCache.acquire(y.RGBA,this._offscreen.width,this._offscreen.height):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentMaterial(),a=this._renderContext.output;this._renderContext.output=O.Alpha,this._bindParameters.transparencyPassType=se.Alpha;const n=this._offscreen.renderOITPass(i,se.Alpha,t);this._renderContext.output=O.Color,this._bindParameters.transparencyPassType=se.Color;const h=this._offscreen.renderOITPass(i,se.Color,t);this._bindParameters.transparencyPassType=se.FrontFace;const o=this._offscreen.renderOITPass(i,se.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=se.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;Te.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.parameters.renderOccluded===k.OccludeAndTransparentStencil&&(e|=r.material.parameters.renderOccluded,Te.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{if(0==(e&s))return;const{width:h,height:o,depth:d}=r,l=this.fboCache.acquire(y.RGBA,h,o);r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,he.PremultipliedAlpha,t),l.release()};0!==Te.length&&(this._prepareInternalSlots(Te,Z.OCCLUDER_MATERIAL,Z.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(Z.OCCLUDER_MATERIAL,Te),t(.5,k.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(Z.TRANSPARENT_OCCLUDER_MATERIAL,Te)),!1,!1)),Te.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.parameters.renderOccluded===k.OccludeAndTransparent||r.material.parameters.renderOccluded===k.Transparent||r.material.parameters.renderOccluded===k.Opaque)&&(e|=r.material.parameters.renderOccluded,Te.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(Te,Z.OPAQUE_MATERIAL,Z.TRANSPARENT_MATERIAL,Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>k.Occlude&&this._renderPlugins.render(Z.OCCLUDED_TERRAIN),this._renderInternalSlot(Z.OPAQUE_MATERIAL,Te),this._renderInternalSlot(Z.TRANSPARENT_MATERIAL,Te),this._renderInternalSlot(Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Te),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=O.Color,t(.5,k.OccludeAndTransparent,(()=>i(k.OccludeAndTransparent)),!0,j.OutlineVisualElementMask),t(.5,k.Transparent,(()=>i(k.Transparent)),!0,j.OutlineVisualElementMask),t(1,k.Opaque,(()=>i(k.Opaque)),!0,j.OutlineVisualElementMask),Te.clear()}_renderComposite(e,r){this._renderPlugins.consumes(O.CompositeColor)&&(this._pluginInput.composite=r);let t=null;const s=this._renderPlugins.produces(Z.COMPOSITE);s&&(t=this._renderPlugins.renderComposition(Z.COMPOSITE,this._pluginInput),this._pluginInput.composite=t);const i=this._renderPlugins.produces(Z.ANTIALIASING),a=this._renderPlugins.render(i?Z.ANTIALIASING:Z.BLIT,this._pluginInput,e);return s&&t?.release(),a}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.material.produces(Z.TRANSPARENT_MATERIAL,O.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.mainColor=t.colorTexture,this._bindParameters.mainDepth=t.depthTexture}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(m(Pe,this._bindParameters.camera.viewMatrix),m(Ae,this._bindParameters.camera.projectionMatrix),f(Re,Pe,Ae),f(Re,this._renderContext.lastFrameCamera.viewMatrix,Re),f(Re,this._renderContext.lastFrameCamera.projectionMatrix,Re),this._reprojectionMatrix=Re);const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._ssrEnableTime=null}_shouldRenderInternalSlot(e,r){return this._bindParameters.slot=r,e.some((e=>null!=e.prepareTechnique(this._renderContext)))}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>null!=e.prepareTechnique(this._renderContext)))}_renderInternalSlot(e,r=this._materialRenderers){this._bindParameters.slot=e,r.forAll((e=>{const r=e.prepareTechnique(this._renderContext);r&&e.renderNode(this._renderContext,r)}))}get memoryInfo(){return{fbos:this.fboCache.peakMemoryUsage,vaos:this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0),plugins:this._renderPlugins.usedMemory}}getMemoryForMaterial(e){if(null==e)return 0;const r=this._materialRenderers.find((r=>r.material===e));return r?.usedMemory??0}get usedMemory(){return this.fboCache.peakMemoryUsage+(this.edgeView?.usedMemory??0)+this._renderPlugins.usedMemory}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=J(),this._renderPlugins.renderFeatureChanged(),this._requestRender()},getFramebufferTexture:r=>{switch(r){case fe.Color:return e._offscreen.colorTexture;case fe.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case fe.ShadowMap:return e._shadowMap.depthTexture;case fe.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var me,fe;e([p()],ce.prototype,"_renderPlugins",void 0),e([p()],ce.prototype,"_shadowAccumulator",void 0),e([p()],ce.prototype,"_state",void 0),e([p()],ce.prototype,"_renderStateFeatures",void 0),e([p({readOnly:!0})],ce.prototype,"fullResolutionAtmosphere",null),e([p()],ce.prototype,"_smaa",void 0),e([p()],ce.prototype,"_blit",void 0),e([p({autoDestroy:!0})],ce.prototype,"_edgeView",void 0),e([p()],ce.prototype,"updating",null),e([p()],ce.prototype,"isCameraFinal",null),ce=e([u("esri.views.3d.webgl-engine.lib.Renderer")],ce),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(me||(me={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(fe||(fe={}));const ge=[0,0,0,0],Te=new h,Ae=T(),Pe=T(),Re=T();function Ee(e){return r=>e.immediate.schedule(r)}export{fe as FramebufferId,ce as Renderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import h from"../../../../core/PooledArray.js";import{watch as o,syncAndInitial as d,initial as l,sync as _}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{a as c,i as m,m as f}from"../../../../chunks/mat4.js";import{I as g,a as T}from"../../../../chunks/mat4f64.js";import{s as A}from"../../../../chunks/vec4.js";import{f as P,Z as R}from"../../../../chunks/vec4f64.js";import{a as E}from"../../../../chunks/boundedPlane.js";import{debugFlags as b}from"../../support/debugFlags.js";import{TransparencyMode as S}from"../../terrain/TerrainRenderer.js";import{FBOCache as I,ColorFormat as y,DepthFormat as C}from"../core/FBOCache.js";import{RenderPassManager as w}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as O}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as D}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{RenderPluginInput as N}from"../effects/RenderPluginInput.js";import{RenderPluginManager as M}from"../effects/RenderPluginManager.js";import{Blit as L}from"../effects/blit/Blit.js";import{Highlight as H}from"../effects/highlight/Highlight.js";import{ShadowHighlight as F}from"../effects/highlight/ShadowHighlight.js";import{SMAA as x}from"../effects/smaa/SMAA.js";import{SSAO as v}from"../effects/ssao/SSAO.js";import{AnimationTimeStep as U}from"./AnimationTimeStep.js";import{Decorations as B,RenderRequestType as G,StencilBits as j}from"./basicInterfaces.js";import{BoundingInfo as q}from"./BoundingInfo.js";import{zero as V,union as Q}from"./depthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{RenderOccludedFlag as k}from"./Material.js";import{OffscreenRendering as Y}from"./OffscreenRendering.js";import{RenderContext as X}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as z}from"./rendererUtils.js";import{setupFeatureDefaults as J,RenderFeature as K}from"./RenderFeature.js";import{RenderSlot as Z}from"./RenderSlot.js";import{ShadowAccumulator as $}from"./ShadowAccumulator.js";import{ShadowMap as ee,SnapshotSlot as re}from"./ShadowMap.js";import te from"./SliceHelper.js";import{TransparencyPassType as se}from"./TransparencyPassType.js";import{EdgeView as ie}from"./edgeRendering/EdgeView.js";import{Transparency as ae}from"./edgeRendering/interfaces.js";import{MergedRenderer as ne}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as he}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as oe,PerformanceCategory as de}from"../statistics/RendererPerformanceInfo.js";import{RenderState as le}from"../../../support/RenderState.js";import{PixelFormat as _e,PixelType as pe,ClearBufferBit as ue}from"../../../webgl/enums.js";let ce=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=J(r,e),this.notifyChange("_renderStateFeatures"),this._renderPlugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(K.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(K.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces(Z.OPAQUE_MATERIAL,O.Highlight)||this._renderPlugins.produces(Z.DRAPED_MATERIAL,O.Highlight)}get hasShadowHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces(Z.OPAQUE_MATERIAL,O.ShadowHighlight)}get _magnifierEnabled(){return this._bindParameters.decorations===B.ON&&this._magnifierHelper.enabled}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(K.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,i,a,n,_,p){super({}),this._stage=e,this._techniqueRepository=i,this._rctx=a,this._compositingHelper=n,this._magnifierHelper=_,this._requestRender=p,this._materialRenderers=new h,this._needsTransparentPass=!1,this._materialRenderersHas={hudElements:!1,highlights:!1,water:!1,decorations:!1,occludees:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._backgroundColor=P(0,0,0,1),this._sliceHelper=new te,this._state=le.IDLE,this._highQualityTransparencyEnabled=!0,this._terrainTransparency=S.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new U,this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new N,this.fboCache=new I(a),this._renderStateFeatures=J(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._offscreen=new Y(this.fboCache,this._compositingHelper),this.performanceInfo=new oe(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._highlight=new H({view:e.view}),this._shadowHighlight=new F({view:e.view,viewingMode:e.viewingMode}),this._shadowAccumulator=new $(this.fboCache,i,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t,!0,this._stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(O.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),p),this._ssao=new v({view:this._stage.view}),this._renderContext=new X(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._renderPlugins=new M({renderContext:this._renderContext,techniqueRepository:i,textureRepository:t,materialRepository:r,requestRender:p,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new w,this._renderPlugins.add(this.renderPassManager),this._smaa=new x({view:this._stage.view}),this._renderPlugins.add(this._smaa),this._blit=new L({opacity:1,alphaMode:he.None}),this._renderPlugins.add(this._blit),this._renderPlugins.add(this._ssao),this._renderPlugins.add(this._highlight),this._renderPlugins.add(this._shadowHighlight),this.addHandles([o((()=>this._stage.view.state.camera),(()=>p()),d),o((()=>b.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(ae.TRANSPARENT):()=>{},p()}),l),o((()=>this._stage.view.environment.background?.color),(e=>{const r=e?s(e):R;A(this._backgroundColor,r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),p()}),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaa.destroy(),this._blit.destroy(),this._gpuTimerHandle=i(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._shadowMap.dispose(),this._ssao.destroy(),this._highlight.dispose(),this._shadowHighlight.destroy(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),q.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}disposeOffscreenBuffers(){this._releaseFBOs(),this._disposeOffscreenBuffers()}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}get updating(){return this._smaa.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._renderPlugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new ie({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:Ee(e)}),this.addHandles(o((()=>this._edgeView?.updating),(()=>this._requestRender()),_)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return c(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=z(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));if(null==i&&t.adds.length>0){const e=new ne({material:s});e.initializeRenderContext(this._renderPlugins._context),i=e,this._materialRenderers.push(i)}i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._materialRenderersHas;has.decorations=!1,has.highlights=!1,has.hudElements=!1,has.water=!1,has.occludees=!1,this._materialRenderers.forAll((e=>{has.highlights||=e.hasHighlights,has.occludees||=e.hasOccludees,has.water||=e.hasWater,has.decorations||=e.isDecoration,has.hudElements||=e.material.produces(Z.LINE_CALLOUTS_HUD_DEPTH,O.Color)||e.material.produces(Z.HUD_MATERIAL,O.Color)||e.material.produces(Z.LABEL_MATERIAL,O.Color)})),this._bindParameters.hasOccludees=has.occludees}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}render(e,r,t,s,i){this._isRendering=!0,this.performanceInfo.startFrame(),this._disposeBindBuffers(),this.fboCache.resetPeakMemoryUsage();const a=this._offscreen,{camera:h,contentCamera:o,mode:d,alignPixelEnabled:l}=t;this._state=d,this._bindParameters.overlay=this.renderOverlay(i),this.performanceInfo.advance(de.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=se.NONE,this._bindParameters.alignPixelEnabled=l,this._bindParameters.decorations=s;const _=E(this._sliceHelper.plane);s===B.OFF&&(this._sliceHelper.plane=null),h.setGLViewport(this._rctx);const p=a.initializeFrame(h,this._backgroundColor);this.hasReflections?this._bindParameters.ssr.lastFrameColor=p:p?.release(),this._prepare(h,o),this._renderPlugins.prepareRender(),this.performanceInfo.advance(de.PREPARE);const u=this._computeDepthRange(h);this._renderShadowMap(h,this._bindParameters.lighting.mainLight.direction,u),this.performanceInfo.advance(de.SHADOW_MAP),this._ensureBindParameters(h,o);const c=this._renderPlugins.produces(Z.OPAQUE_TERRAIN)&&(this._terrainTransparency===S.Semitransparent||this._terrainTransparency===S.TransparentWithDraped),m=this._highQualityTransparency&&c,f=this._needsTransparentPass||this._renderPlugins.produces(Z.TRANSPARENT_MATERIAL);this._prepareShaders(m,f),this._renderLinearDepth(),this.performanceInfo.advance(de.LINEAR_DEPTH),this._renderShadowAccumulation(u,h,o),this.performanceInfo.advance(de.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(),this.performanceInfo.advance(de.SSAO),this._renderContext.output=O.Color,a.bindFbo(),this._renderOpaqueGeometry(),this._renderPlugins.render(Z.ENVIRONMENT_OPAQUE),this.performanceInfo.advance(de.OPAQUE),this._renderTerrainLinearDepth(m),this._setMultipassTerrain(m),this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(de.OPAQUE_EDGES),a.bindFbo(),this._renderPlugins.render(Z.VOXEL),this.performanceInfo.advance(de.VOXEL),this._renderHiddenTransparentEdges(),f&&(this._oitEnabled?this._renderOITPass(me.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(de.TRANSPARENT);const g=this._renderGeometryLinearDepth(m);this._renderHUDVisibility(g),m||this._renderInternalSlot(Z.LINE_CALLOUTS),this.performanceInfo.advance(de.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(de.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(ae.TRANSPARENT,g),g?.release(),this.performanceInfo.advance(de.TRANSPARENT_EDGES);const T=c?this._renderTransparentTerrain():null;T&&this._bindParameters.hudVisibility&&(m?this._renderLineCallouts(D.Occluded):a.compositeToHUDVisibility(this._bindParameters,T.colorTexture),this._renderHUD(D.Occluded,a.color),this.performanceInfo.advance(de.HUD_OCCLUDED)),this.performanceInfo.advance(de.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),T&&(a.compositeToFramebuffer(this._bindParameters,T.colorTexture,he.PremultipliedAlpha,1),T.release(),m&&(this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(de.OPAQUE_EDGES),f&&(this._oitEnabled?this._renderOITPass(me.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(de.TRANSPARENT),this._renderEdges(ae.TRANSPARENT),this.performanceInfo.advance(de.TRANSPARENT_EDGES))),this._bindParameters.ssao=n(this._bindParameters.ssao),m&&this._renderLineCallouts(D.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),a.bindFbo(),this._renderInternalSlot(Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.render(Z.ENVIRONMENT_TRANSPARENT),this.performanceInfo.advance(de.ENVIRONMENT),this._renderLaserlines(),this.performanceInfo.advance(de.LASER_LINES),this._renderOccluded(),this.performanceInfo.advance(de.OCCLUDED);const A=this._magnifierEnabled&&null==e?this.fboCache.acquire(y.RGBA,this._offscreen.width,this._offscreen.height):null,P=this._renderComposite(A??e,this._offscreen.color)??e;this.performanceInfo.advance(de.ANTIALIASING),this._renderHUD(D.NotOccluded,P),this.performanceInfo.advance(de.HUD),this._renderHighlights(P,this._bindParameters),this.performanceInfo.advance(de.HIGHLIGHTS),this._magnifierEnabled&&this._magnifierHelper.render(this._rctx,this._bindParameters),P!==e&&(this._rctx.bindFramebuffer(e?.fbo),this._compositingHelper.composite(this._bindParameters,A?.colorTexture,he.None)),A!==e&&A?.release(),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=_,this._isRendering=!1,this.performanceInfo.finishFrame()}_prepareShaders(e,r){this._renderContext.output=O.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._renderPlugins.prepare(Z.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,Z.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.prepare(Z.ENVIRONMENT_TRANSPARENT),this._renderPlugins.prepare(Z.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(e){if(null==e||!has("enable-feature:objectAndLayerId-rendering"))return;const r=this._renderContext.output;this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>this._renderAllGeometry(O.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=D.NotOccluded,this._renderInternalSlot(Z.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===G.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._bindParameters.linearDepth?.fbo;if(s?.colorTexture)return void s.readPixels(r[0],r[1],r[2],r[3],_e.RGBA,pe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(y.RGBA,this._offscreen.width,this._offscreen.height).acquireDepth(C.DEPTH16_BUFFER);this._rctx.bindFramebuffer(i.fbo),this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const a=ue.COLOR_BUFFER_BIT|ue.DEPTH_BUFFER_BIT|ue.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderAllGeometry(O.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],_e.RGBA,pe.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,_e.RGBA,pe.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(y.RGBA,s,i),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,ge),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,he.Alpha,1),n.release()}}_renderShadowMap(e,r,t){const s=this._shadowMap;s.enabled&&(s.start(e,r,t,this.isFeatureEnabled(K.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(e,r),this._needsShadowHighlight?(this._renderShadowCascades(O.ShadowHighlight,this._shadowMap),s.moveSnapshot(re.Highlight),s.clear(),this._renderShadowCascades(O.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(re.Default),this._renderShadowCascades(O.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(O.Shadow),s.finish(),e.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap){for(const t of r.cascades)t.camera.setGLViewport(this._rctx),this._prepare(t.camera,t.camera),this._renderAllGeometry(e)}get _needsLinearDepth(){return this._renderPlugins.consumes(O.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,(()=>this._renderAllGeometry(O.Depth)),[0,0,0,0],y.RGBA,C.DEPTH_STENCIL_BUFFER),this._bindParameters.linearDepth.releaseDepth(),this._offscreen.bindFbo()):this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=O.Depth,this._bindParameters.multipassTerrain.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassTerrain.linearDepth,(()=>this._renderTransparentTerrain()),[-1e10,-1e10,-1e10,1]),this._bindParameters.multipassTerrain.linearDepth.releaseDepth(),this._renderContext.output=e}else this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth)}_renderGeometryLinearDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth));const r=this._renderContext.output;return this._bindParameters.multipassGeometry.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassGeometry.linearDepth,(()=>this._renderOpaqueGeometryAndTransparentMaterial(O.Depth)),[1,1,1,1]),this._renderContext.output=r,this._bindParameters.multipassGeometry.linearDepth.detachDepth()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return V;const r=W(e,this._materialRenderers,this._stage.layers);return Q(r,this._renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderAllGeometry(e){this._renderContext.output=e,this._renderPlugins.prepare(Z.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderSSAO(){if(!this._renderPlugins.produces(Z.SSAO))return;const e=this._offscreen.renderToCachedFBO(null,(()=>this._renderAllGeometry(O.Normal)),[0,0,0,0],y.RGBA4,C.DEPTH24_BUFFER);e.releaseDepth(),this._offscreen.bindFbo(),this._pluginInput.normal=e,this._bindParameters.ssao=this._renderPlugins.render(Z.SSAO,this._pluginInput),e.release()}_prepareOpaqueGeometrySlots(){this._renderPlugins.prepare(Z.INTEGRATED_MESH),this._renderPlugins.prepare(Z.OPAQUE_TERRAIN),this._renderPlugins.prepare(Z.OPAQUE_MATERIAL),this._renderPlugins.prepare(Z.ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,Z.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderPlugins.render(Z.INTEGRATED_MESH),this._renderPlugins.render(Z.OPAQUE_TERRAIN),this._renderInternalSlot(Z.OPAQUE_MATERIAL),this._renderPlugins.render(Z.OPAQUE_MATERIAL)}_renderTransparentMaterial(){this._renderInternalSlot(Z.TRANSPARENT_MATERIAL),this._renderPlugins.render(Z.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){if(!this._renderPlugins.produces(Z.TRANSPARENT_TERRAIN))return;const e=()=>this._renderPlugins.render(Z.TRANSPARENT_TERRAIN,null);if(this._renderContext.output!==O.Color)return void e();const{width:r,height:t,depth:s}=this._offscreen,i=this.fboCache.acquire(y.RGBA,r,t);return this._offscreen.renderToTargets(e,i,s,[0,0,0,0]),i}_renderHUDVisibility(e){this._shouldRenderInternalSlot(this._materialRenderers,Z.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._renderInternalSlot(Z.OCCLUSION_PIXELS)),e),this._offscreen.bindFbo()):this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===D.Occluded){const e=()=>this._renderInternalSlot(Z.LINE_CALLOUTS),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(C.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderInternalSlot(Z.LINE_CALLOUTS)}_renderLaserlines(){if(this._renderPlugins.render(Z.LASERLINES),this._renderPlugins.produces(Z.LASERLINES_CONTRAST_CONTROL)){const e=this._offscreen,{width:r,height:t,depth:s}=e,i=this.fboCache.acquire(y.RGBA,r,t),a=()=>this._renderPlugins.render(Z.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,ge),e.compositeToFramebuffer(this._bindParameters,i.colorTexture,he.PremultipliedAlpha,1),i.release()}}_renderHUD(e,r){if(this._materialRenderersHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(me.HUD,e);this._rctx.bindFramebuffer(r?.fbo),this._compositingHelper.composite(this._bindParameters,t.colorTexture,he.PremultipliedAlpha),t.release()}else if(e===D.Occluded){const r=()=>this._renderHUDElements(e),{width:t,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(C.DEPTH16_BUFFER,t,s);this._offscreen.renderToTargets(r,i,a,void 0,!0,!0),a.release()}else this._rctx.bindFramebuffer(null),r?.acquireDepth(C.DEPTH16_BUFFER),this._rctx.bindFramebuffer(r?.fbo),this._renderHUDElements(e),r?.releaseDepth()}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,Z.LINE_CALLOUTS_HUD_DEPTH,Z.HUD_MATERIAL,Z.LABEL_MATERIAL),this._renderInternalSlot(Z.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(Z.HUD_MATERIAL),this._renderInternalSlot(Z.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._renderPlugins.produces(Z.SHADOW_HIGHLIGHT)&&this.hasShadowHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===B.OFF)return;const t=()=>{this._renderAllGeometry(O.Highlight),this._rctx.clearSafe(ue.DEPTH_BUFFER_BIT),this._renderHUDElements(D.Both)},s=this._offscreen.renderToCachedFBO(null,t,[0,0,0,0],y.RGBA4,C.DEPTH_STENCIL_BUFFER);s.releaseDepth(),this._needsShadowHighlight&&(this._pluginInput.highlight=s,this._renderPlugins.render(Z.SHADOW_HIGHLIGHT,this._pluginInput,e)),this._renderPlugins.produces(Z.HIGHLIGHT)&&(this._pluginInput.composite=null,this._pluginInput.normal=null,this._pluginInput.highlight=s,this._renderPlugins.render(Z.HIGHLIGHT,this._pluginInput,e)),s.release()}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=O.Alpha,this._bindParameters.transparencyPassType=se.Alpha,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._renderContext.output=O.Color,this._bindParameters.transparencyPassType=se.Color,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=se.FrontFace,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=se.NONE}_renderOITPass(e,r=D.Both){const t=e===me.HUD,s=t?this.fboCache.acquire(y.RGBA,this._offscreen.width,this._offscreen.height):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentMaterial(),a=this._renderContext.output;this._renderContext.output=O.Alpha,this._bindParameters.transparencyPassType=se.Alpha;const n=this._offscreen.renderOITPass(i,se.Alpha,t);this._renderContext.output=O.Color,this._bindParameters.transparencyPassType=se.Color;const h=this._offscreen.renderOITPass(i,se.Color,t);this._bindParameters.transparencyPassType=se.FrontFace;const o=this._offscreen.renderOITPass(i,se.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=se.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;Te.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.parameters.renderOccluded===k.OccludeAndTransparentStencil&&(e|=r.material.parameters.renderOccluded,Te.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{if(0==(e&s))return;const{width:h,height:o,depth:d}=r,l=this.fboCache.acquire(y.RGBA,h,o);r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,he.PremultipliedAlpha,t),l.release()};0!==Te.length&&(this._prepareInternalSlots(Te,Z.OCCLUDER_MATERIAL,Z.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(Z.OCCLUDER_MATERIAL,Te),t(.5,k.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(Z.TRANSPARENT_OCCLUDER_MATERIAL,Te)),!1,!1)),Te.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.parameters.renderOccluded===k.OccludeAndTransparent||r.material.parameters.renderOccluded===k.Transparent||r.material.parameters.renderOccluded===k.Opaque)&&(e|=r.material.parameters.renderOccluded,Te.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(Te,Z.OPAQUE_MATERIAL,Z.TRANSPARENT_MATERIAL,Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>k.Occlude&&this._renderPlugins.render(Z.OCCLUDED_TERRAIN),this._renderInternalSlot(Z.OPAQUE_MATERIAL,Te),this._renderInternalSlot(Z.TRANSPARENT_MATERIAL,Te),this._renderInternalSlot(Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Te),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=O.Color,t(.5,k.OccludeAndTransparent,(()=>i(k.OccludeAndTransparent)),!0,j.OutlineVisualElementMask),t(.5,k.Transparent,(()=>i(k.Transparent)),!0,j.OutlineVisualElementMask),t(1,k.Opaque,(()=>i(k.Opaque)),!0,j.OutlineVisualElementMask),Te.clear()}_renderComposite(e,r){this._renderPlugins.consumes(O.CompositeColor)&&(this._pluginInput.composite=r);let t=null;const s=this._renderPlugins.produces(Z.COMPOSITE);s&&(t=this._renderPlugins.renderComposition(Z.COMPOSITE,this._pluginInput),this._pluginInput.composite=t);const i=this._renderPlugins.produces(Z.ANTIALIASING),a=this._renderPlugins.render(i?Z.ANTIALIASING:Z.BLIT,this._pluginInput,e);return s&&t?.release(),a}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.material.produces(Z.TRANSPARENT_MATERIAL,O.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.mainColor=t.colorTexture,this._bindParameters.mainDepth=t.depthTexture}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(m(Pe,this._bindParameters.camera.viewMatrix),m(Ae,this._bindParameters.camera.projectionMatrix),f(Re,Pe,Ae),f(Re,this._renderContext.lastFrameCamera.viewMatrix,Re),f(Re,this._renderContext.lastFrameCamera.projectionMatrix,Re),this._reprojectionMatrix=Re);const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._ssrEnableTime=null}_shouldRenderInternalSlot(e,r){return this._bindParameters.slot=r,e.some((e=>null!=e.prepareTechnique(this._renderContext)))}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>null!=e.prepareTechnique(this._renderContext)))}_renderInternalSlot(e,r=this._materialRenderers){this._bindParameters.slot=e,r.forAll((e=>{const r=e.prepareTechnique(this._renderContext);r&&e.renderNode(this._renderContext,r)}))}get memoryInfo(){return{fbos:this.fboCache.peakMemoryUsage,vaos:this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0),plugins:this._renderPlugins.usedMemory}}getMemoryForMaterial(e){if(null==e)return 0;const r=this._materialRenderers.find((r=>r.material===e));return r?.usedMemory??0}get usedMemory(){return this.fboCache.peakMemoryUsage+(this.edgeView?.usedMemory??0)+this._renderPlugins.usedMemory}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=J(),this._renderPlugins.renderFeatureChanged(),this._requestRender()},getFramebufferTexture:r=>{switch(r){case fe.Color:return e._offscreen.colorTexture;case fe.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case fe.ShadowMap:return e._shadowMap.depthTexture;case fe.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var me,fe;e([p()],ce.prototype,"_renderPlugins",void 0),e([p()],ce.prototype,"_shadowAccumulator",void 0),e([p()],ce.prototype,"_state",void 0),e([p()],ce.prototype,"_renderStateFeatures",void 0),e([p({readOnly:!0})],ce.prototype,"fullResolutionAtmosphere",null),e([p()],ce.prototype,"_smaa",void 0),e([p()],ce.prototype,"_blit",void 0),e([p({autoDestroy:!0})],ce.prototype,"_edgeView",void 0),e([p()],ce.prototype,"updating",null),e([p()],ce.prototype,"isCameraFinal",null),ce=e([u("esri.views.3d.webgl-engine.lib.Renderer")],ce),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(me||(me={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(fe||(fe={}));const ge=[0,0,0,0],Te=new h,Ae=T(),Pe=T(),Re=T();function Ee(e){return r=>e.immediate.schedule(r)}export{fe as FramebufferId,ce as Renderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as a}from"../../../../../core/maybe.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{f as d,t as u,d as h}from"../../../../../chunks/mat3.js";import{a as m}from"../../../../../chunks/mat3f64.js";import{a as g}from"../../../../../chunks/mat4f64.js";import{h as p,s as f,c as _,u as b,j as y}from"../../../../../chunks/vec3.js";import{c as j}from"../../../../../chunks/vec3f64.js";import{UpdatingHandles as O}from"../../../../../core/support/UpdatingHandles.js";import{g as w,a as E}from"../../../../../chunks/sphere.js";import{c as v}from"../../../../../chunks/vec33.js";import{ViewingMode as R}from"../../../../ViewingMode.js";import{encodeElevationOffset as x}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as T}from"../../core/util/TwoVectorPosition.js";import{Attribute as M}from"../Attribute.js";import{GridLocalOriginFactory as C}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as D}from"../localOriginHelper.js";import{LocalOriginManager as P}from"../LocalOriginManager.js";import{Object3D as S}from"../Object3D.js";import{VertexArrayObject as A}from"../VertexArrayObject.js";import{VertexAttribute as U}from"../VertexAttribute.js";import{VertexLayout as B,EdgeInputBufferLayout as L,EdgeShaderAttributeLocations as k,glVertexLayout as I}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as H,SilhouetteEdgeBufferWriter as V}from"./edgeBufferWriters.js";import{EdgeType as N}from"./edgePreprocessing.js";import{EdgeRenderer as G,lineWidthFractionFactor as W,extensionLengthOffset as q}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import{Transparency as F}from"./interfaces.js";import{generateStrokesTexture as Q}from"./strokes.js";import{determineRendererType as J,determineEdgeTransparency as X,determineObjectTransparency as Y,fillComponenBufferIndices as Z}from"./util.js";import{BufferManager as $}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as ee}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as te}from"../../../../webgl/BufferObject.js";import{Usage as re}from"../../../../webgl/enums.js";let se=class extends t{constructor(e){super(e),this._updatingHandles=new O,this._perObjectData=new Map,this._perObjectDataEvictionCache=new Set,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=j(),this._localOrigins=new P(new C(e.renderSR))}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new $(this.rctx,3);const e=B.createBuffer(4);for(let t=0;t<4;t++)e.sideness.set(t,0,0===t||3===t?0:1),e.sideness.set(t,1,0===t||1===t?0:1);this._verticesBufferObject=te.createVertex(this.rctx,re.STATIC_DRAW,e.buffer)}destroy(){this.destroyed||(this._perObjectData.forEach((e=>this._discardObjectEntry(e))),this._perObjectData.clear(),this._strokesTexture=i(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject=i(this._verticesBufferObject),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",be))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o,i,a){if(this.hasObject(e))return this.getObjectMemoryUsage(e);let c;const l=new ie(new Promise((e=>c=e)),r.center,r.radius);this._perObjectData.set(e,l);const d=await this._updatingHandles.addPromise(this._addComponentGeometry(t,l,s,n,o,i,a));return this.setNeedsRender(),c(),d}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const o=this._perObjectData.get(e);let i;o?.renderables.length>0&&this._perObjectDataEvictionCache.add(o);const a=e.boundingVolumeWorldSpace.bounds,c=new ie(new Promise((e=>i=e)),w(a),E(a));this._perObjectData.set(e,c);const l=new Array;if(r.mergeGeometries&&e.geometries.length>1&&oe(e))l.push(this._addObjectMergedGeometries(e,c,t,r,s));else for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];o.material.supportsEdges&&l.push(this._addGeometry(e,c,o,t[0],r,s))}await this._updatingHandles.addPromise(Promise.all(l)),this._perObjectDataEvictionCache.delete(c),this._discardObjectEntry(o),this.setNeedsRender(),i()}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._perObjectData.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,o=n.transform;if(!(o instanceof le))return!1;const[i]=r,a=o.origin.origin.vec3,c=i.localOrigin?.vec3;if(null==c||!p(a,c))return!1;const l=g(),d=this._computeModelTransformWithLocalOrigin(e,i,l);return n.transform=new le(l,d),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._perObjectData.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=t instanceof Array?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return null!=t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof S,o=!!r.hasSlicePlane,i=J(t),a=G.getKey(i,o,n),c=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=c&&(c.renderables.forEach((e=>{if(a!==e.rendererKey){const t=this._renderers.get(e.rendererKey),r=this._acquireRenderer(i,o,n);t.removeRenderable(e),--t.refCount,e.rendererKey=a,r.addRenderable(e)}for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];s&&this._updateComponentBuffer(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;this._updateComponentBuffer(e.components)})),this.setNeedsRender())}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}removeObject(e){const t=this._perObjectData.get(e);t&&(this._perObjectData.delete(e),this._discardObjectEntry(t))}async _getObjectEntry(e){const t=this._perObjectData.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=j(),n=new T;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)this._renderers.delete(r.key),r.dispose();else{let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)}})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new z(40*o/i,t);f(s,r[3],r[7],r[11]),n.set(s),_(a.transformWorldFromViewTH,n.high),_(a.transformWorldFromViewTL,n.low),d(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),u(_e,a.transformViewFromCameraRelativeRS),h(a.transformNormalViewFromGlobal,_e),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{this._renderRegularEdges(t,e,a),this._renderSilhouetteEdges(t,e,a)}))}_updateTransparency(e){const t=X(e.components.meta),r=Y(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(f(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,D(s.origin.vec3,r),s}_updateComponentBuffer(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*W),0,255),c=o(e.extensionLength,-q,255-q)+q,l="solid"===e.type?N.SOLID:N.SKETCH,d=255*e.opacity,u=e.color,h=255*u[0],m=255*u[1],g=255*u[2],p=255*u[3];r.textureBuffer.setData(i,0,h,m,g,p),r.textureBuffer.setData(i,1,a,c,l,d),x(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new ae(r,t);return this._updateComponentBuffer(s),s}_extractEdges(e,t,r,s,n,o=n.length){return this._worker.process({data:t,indices:n,indicesLength:o,writerSettings:e,skipDeduplicate:r},this._workerAbort.signal,s)}_createRenderable(e,t,r,s,n){const o=t=>null!=this._verticesBufferObject?new ce(new A(this.rctx,k,{vertices:I,instances:t===ee.REGULAR?H.glLayout:V.glLayout},{vertices:this._verticesBufferObject,instances:te.createVertex(this.rctx,re.STATIC_DRAW,t===ee.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===ee.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo):null,i=e.regular.lodInfo.lengths.length>0?o(ee.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(ee.SILHOUETTE):null,c=(i?.vao.memoryUsage??0)+(a?.vao.memoryUsage??0);return new de(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,X(t.meta),Y(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(U.POSITION),a=g(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new fe(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,u=t.position,h=u.data.length/u.size,m=L.createBuffer(h);for(let f=0;f<h;f++)m.position.set(f,0,u.data[f*u.size]),m.position.set(f,1,u.data[f*u.size+1]),m.position.set(f,2,u.data[f*u.size+2]);Z(i.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(a.writerSettings,m,!1,o,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,i,new le(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i){if(null==t.loaded)return 0;const a=this._createComponentBuffers(o);if(null==a)return 0;const c=J(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=L.createBuffer(r.length/3);v(d.position.typedBuffer,r,d.position.typedBufferStride,3),Z(a.meta,n,d.componentIndex,s);const u=!0,h=l.writerSettings,m=await this._updatingHandles.addPromise(this._extractEdges(h,d,u,!1,s));if(null==t.loaded)return 0;const g=this._createRenderable(m,a,e,l.key,!0);return t.renderables.push(g),l.addRenderable(g),g.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=0,a=null,c=0;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!a&&e.localOrigin&&(a=e);const t=e.attributes.get(U.POSITION);return c+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=c>=65536?Uint32Array:Uint16Array,u=i?new d(i):null,h=[];let m=0;l.forEach((e=>{const t=e.attributes.get(U.POSITION),r=t.indices;let s=o.get(t.data);if(null==s){s=h.length/3;for(let e=0;e<t.data.length;e+=t.size)h.push(t.data[e]),h.push(t.data[e+1]),h.push(t.data[e+2]);o.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)u[m++]=s+r[n]}));const p=a||e.geometries[0],f=g(),_=this._computeModelTransformWithLocalOrigin(e,p,f);for(let g=0;g<e.geometries.length;g++)e.geometries[g].localOrigin=_.origin;const b=new fe(new M(h,u,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,u.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=G.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=Q(this.rctx)),n||(n=new G(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===R.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ne(e.regular),ne(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,"origin"in e.transform&&this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=j(),n=e=>{b(s,e.center,t);const n=y(s,r),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._perObjectData.forEach(n),this._perObjectDataEvictionCache.forEach(n)}_renderRegularEdges(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!he(n)||!n.visible)return;const i=pe(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}_renderSilhouetteEdges(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!ge(n)||!n.visible)return;const i=pe(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}get test(){return{hasRenderedPrimitives:e=>{let t=!1;const r=e.perScreenPixelRatio,s=(e,s)=>e.forEachRenderable((e=>{e.visible&&!t&&(he(e)&&(t=pe(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&ge(e)&&(t=pe(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,F.OPAQUE),s(e,F.TRANSPARENT))})),t},getObjectData:e=>this._perObjectData.get(e)}}};function ne(e){null!=e&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function oe(e){let t=null,s=null;for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];if(o.material.supportsEdges){if(t){if(!r(t,o.transformation))return!1}else t=o.transformation;if(s||null==o.localOrigin){if(null!=s?.localOrigin&&null!=o.localOrigin&&s.localOrigin.id!==o.localOrigin.id)return!1}else s=o}}return!0}e([c({constructOnly:!0})],se.prototype,"rctx",void 0),e([c({constructOnly:!0})],se.prototype,"renderSR",void 0),e([c({constructOnly:!0})],se.prototype,"viewingMode",void 0),e([c({constructOnly:!0})],se.prototype,"techniqueRepository",void 0),e([c({constructOnly:!0})],se.prototype,"setNeedsRender",void 0),e([c({constructOnly:!0})],se.prototype,"schedule",void 0),e([c({readOnly:!0})],se.prototype,"_updatingHandles",void 0),e([c({readOnly:!0})],se.prototype,"updating",null),se=e([l("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],se);class ie{constructor(e,t,r){this.center=t,this.radius=r,this.renderables=new Array,this.loaded=e,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0)}))}}class ae{constructor(e,t){this.buffer=e,this.meta=t}}class ce{constructor(e,t){this.vao=e,this.lod=t}}class le{constructor(e,t){this.modelMatrix=e,this.origin=t}}class de{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ue extends de{}function he(e){return null!=e.regular}class me extends de{}function ge(e){return null!=e.silhouette}function pe(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class fe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const _e=m(),be=()=>Promise.reject();export{se as EdgeView,le as LegacyTransform,ue as RegularRenderable,de as Renderable,me as SilhouetteRenderable};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as a}from"../../../../../core/maybe.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{f as d,t as u,d as h}from"../../../../../chunks/mat3.js";import{a as m}from"../../../../../chunks/mat3f64.js";import{a as g}from"../../../../../chunks/mat4f64.js";import{s as p,c as f,u as _,j as b}from"../../../../../chunks/vec3.js";import{c as y}from"../../../../../chunks/vec3f64.js";import{UpdatingHandles as j}from"../../../../../core/support/UpdatingHandles.js";import{g as O,a as w}from"../../../../../chunks/sphere.js";import{c as E}from"../../../../../chunks/vec33.js";import{ViewingMode as R}from"../../../../ViewingMode.js";import{encodeElevationOffset as v}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as x}from"../../core/util/TwoVectorPosition.js";import{Attribute as T}from"../Attribute.js";import{GridLocalOriginFactory as M}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as C}from"../localOriginHelper.js";import{LocalOriginManager as D}from"../LocalOriginManager.js";import{Object3D as P}from"../Object3D.js";import{VertexArrayObject as S}from"../VertexArrayObject.js";import{VertexAttribute as A}from"../VertexAttribute.js";import{VertexLayout as U,EdgeInputBufferLayout as B,EdgeShaderAttributeLocations as L,glVertexLayout as k}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as I,SilhouetteEdgeBufferWriter as H}from"./edgeBufferWriters.js";import{EdgeType as V}from"./edgePreprocessing.js";import{EdgeRenderer as N,lineWidthFractionFactor as G,extensionLengthOffset as W}from"./EdgeRenderer.js";import{EdgePassParameters as q}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as z}from"./EdgeWorkerHandle.js";import{Transparency as K}from"./interfaces.js";import{generateStrokesTexture as F}from"./strokes.js";import{determineRendererType as Q,determineEdgeTransparency as J,determineObjectTransparency as X,fillComponenBufferIndices as Y}from"./util.js";import{BufferManager as Z}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as $}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as ee}from"../../../../webgl/BufferObject.js";import{Usage as te}from"../../../../webgl/enums.js";let re=class extends t{constructor(e){super(e),this._updatingHandles=new j,this._perObjectData=new Map,this._perObjectDataEvictionCache=new Set,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=y(),this._localOrigins=new D(new M(e.renderSR))}initialize(){this._worker=new z(this.schedule),this._componentColorManager=new Z(this.rctx,3);const e=U.createBuffer(4);for(let t=0;t<4;t++)e.sideness.set(t,0,0===t||3===t?0:1),e.sideness.set(t,1,0===t||1===t?0:1);this._verticesBufferObject=ee.createVertex(this.rctx,te.STATIC_DRAW,e.buffer)}destroy(){this.destroyed||(this._perObjectData.forEach((e=>this._discardObjectEntry(e))),this._perObjectData.clear(),this._strokesTexture=i(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject=i(this._verticesBufferObject),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",_e))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o,i,a){if(this.hasObject(e))return this.getObjectMemoryUsage(e);let c;const l=new oe(new Promise((e=>c=e)),r.center,r.radius);this._perObjectData.set(e,l);const d=await this._updatingHandles.addPromise(this._addComponentGeometry(t,l,s,n,o,i,a));return this.setNeedsRender(),c(),d}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const o=this._perObjectData.get(e);let i;o?.renderables.length>0&&this._perObjectDataEvictionCache.add(o);const a=e.boundingVolumeWorldSpace.bounds,c=new oe(new Promise((e=>i=e)),O(a),w(a));this._perObjectData.set(e,c);const l=new Array;if(r.mergeGeometries&&e.geometries.length>1&&ne(e))l.push(this._addObjectMergedGeometries(e,c,t,r,s));else for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];o.material.supportsEdges&&l.push(this._addGeometry(e,c,o,t[0],r,s))}await this._updatingHandles.addPromise(Promise.all(l)),this._perObjectDataEvictionCache.delete(c),this._discardObjectEntry(o),this.setNeedsRender(),i()}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._perObjectData.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,o=n.transform;if(!(o instanceof ce))return!1;const[i]=r;if(i.localOrigin!==o.origin.origin)return!1;const a=g(),c=this._computeModelTransformWithLocalOrigin(e,i,a);return n.transform=new ce(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._perObjectData.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=t instanceof Array?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return null!=t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof P,o=!!r.hasSlicePlane,i=Q(t),a=N.getKey(i,o,n),c=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=c&&(c.renderables.forEach((e=>{if(a!==e.rendererKey){const t=this._renderers.get(e.rendererKey),r=this._acquireRenderer(i,o,n);t.removeRenderable(e),--t.refCount,e.rendererKey=a,r.addRenderable(e)}for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];s&&this._updateComponentBuffer(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;this._updateComponentBuffer(e.components)})),this.setNeedsRender())}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}removeObject(e){const t=this._perObjectData.get(e);t&&(this._perObjectData.delete(e),this._discardObjectEntry(t))}async _getObjectEntry(e){const t=this._perObjectData.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=y(),n=new x;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)this._renderers.delete(r.key),r.dispose();else{let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)}})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new q(40*o/i,t);p(s,r[3],r[7],r[11]),n.set(s),f(a.transformWorldFromViewTH,n.high),f(a.transformWorldFromViewTL,n.low),d(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),u(fe,a.transformViewFromCameraRelativeRS),h(a.transformNormalViewFromGlobal,fe),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{this._renderRegularEdges(t,e,a),this._renderSilhouetteEdges(t,e,a)}))}_updateTransparency(e){const t=J(e.components.meta),r=X(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(p(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,C(s.origin.vec3,r),s}_updateComponentBuffer(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*G),0,255),c=o(e.extensionLength,-W,255-W)+W,l="solid"===e.type?V.SOLID:V.SKETCH,d=255*e.opacity,u=e.color,h=255*u[0],m=255*u[1],g=255*u[2],p=255*u[3];r.textureBuffer.setData(i,0,h,m,g,p),r.textureBuffer.setData(i,1,a,c,l,d),v(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new ie(r,t);return this._updateComponentBuffer(s),s}_extractEdges(e,t,r,s,n,o=n.length){return this._worker.process({data:t,indices:n,indicesLength:o,writerSettings:e,skipDeduplicate:r},this._workerAbort.signal,s)}_createRenderable(e,t,r,s,n){const o=t=>null!=this._verticesBufferObject?new ae(new S(this.rctx,L,{vertices:k,instances:t===$.REGULAR?I.glLayout:H.glLayout},{vertices:this._verticesBufferObject,instances:ee.createVertex(this.rctx,te.STATIC_DRAW,t===$.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===$.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo):null,i=e.regular.lodInfo.lengths.length>0?o($.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o($.SILHOUETTE):null,c=(i?.vao.memoryUsage??0)+(a?.vao.memoryUsage??0);return new le(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,J(t.meta),X(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(A.POSITION),a=g(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new pe(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,u=t.position,h=u.data.length/u.size,m=B.createBuffer(h);for(let f=0;f<h;f++)m.position.set(f,0,u.data[f*u.size]),m.position.set(f,1,u.data[f*u.size+1]),m.position.set(f,2,u.data[f*u.size+2]);Y(i.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(a.writerSettings,m,!1,o,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,i,new ce(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i){if(null==t.loaded)return 0;const a=this._createComponentBuffers(o);if(null==a)return 0;const c=Q(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=B.createBuffer(r.length/3);E(d.position.typedBuffer,r,d.position.typedBufferStride,3),Y(a.meta,n,d.componentIndex,s);const u=!0,h=l.writerSettings,m=await this._updatingHandles.addPromise(this._extractEdges(h,d,u,!1,s));if(null==t.loaded)return 0;const g=this._createRenderable(m,a,e,l.key,!0);return t.renderables.push(g),l.addRenderable(g),g.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=0,a=null,c=0;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!a&&e.localOrigin&&(a=e);const t=e.attributes.get(A.POSITION);return c+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=c>=65536?Uint32Array:Uint16Array,u=i?new d(i):null,h=[];let m=0;l.forEach((e=>{const t=e.attributes.get(A.POSITION),r=t.indices;let s=o.get(t.data);if(null==s){s=h.length/3;for(let e=0;e<t.data.length;e+=t.size)h.push(t.data[e]),h.push(t.data[e+1]),h.push(t.data[e+2]);o.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)u[m++]=s+r[n]}));const p=a||e.geometries[0],f=g(),_=this._computeModelTransformWithLocalOrigin(e,p,f);for(let g=0;g<e.geometries.length;g++)e.geometries[g].localOrigin=_.origin;const b=new pe(new T(h,u,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,u.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=N.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=F(this.rctx)),n||(n=new N(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===R.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){se(e.regular),se(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,"origin"in e.transform&&this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=y(),n=e=>{_(s,e.center,t);const n=b(s,r),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._perObjectData.forEach(n),this._perObjectDataEvictionCache.forEach(n)}_renderRegularEdges(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!ue(n)||!n.visible)return;const i=ge(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}_renderSilhouetteEdges(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!me(n)||!n.visible)return;const i=ge(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}get test(){return{hasRenderedPrimitives:e=>{let t=!1;const r=e.perScreenPixelRatio,s=(e,s)=>e.forEachRenderable((e=>{e.visible&&!t&&(ue(e)&&(t=ge(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&me(e)&&(t=ge(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,K.OPAQUE),s(e,K.TRANSPARENT))})),t},getObjectData:e=>this._perObjectData.get(e)}}};function se(e){null!=e&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function ne(e){let t=null,s=null;for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];if(o.material.supportsEdges){if(t){if(!r(t,o.transformation))return!1}else t=o.transformation;if(s||null==o.localOrigin){if(null!=s?.localOrigin&&null!=o.localOrigin&&s.localOrigin.id!==o.localOrigin.id)return!1}else s=o}}return!0}e([c({constructOnly:!0})],re.prototype,"rctx",void 0),e([c({constructOnly:!0})],re.prototype,"renderSR",void 0),e([c({constructOnly:!0})],re.prototype,"viewingMode",void 0),e([c({constructOnly:!0})],re.prototype,"techniqueRepository",void 0),e([c({constructOnly:!0})],re.prototype,"setNeedsRender",void 0),e([c({constructOnly:!0})],re.prototype,"schedule",void 0),e([c({readOnly:!0})],re.prototype,"_updatingHandles",void 0),e([c({readOnly:!0})],re.prototype,"updating",null),re=e([l("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],re);class oe{constructor(e,t,r){this.center=t,this.radius=r,this.renderables=new Array,this.loaded=e,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0)}))}}class ie{constructor(e,t){this.buffer=e,this.meta=t}}class ae{constructor(e,t){this.vao=e,this.lod=t}}class ce{constructor(e,t){this.modelMatrix=e,this.origin=t}}class le{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class de extends le{}function ue(e){return null!=e.regular}class he extends le{}function me(e){return null!=e.silhouette}function ge(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class pe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const fe=m(),_e=()=>Promise.reject();export{re as EdgeView,ce as LegacyTransform,de as RegularRenderable,le as Renderable,he as SilhouetteRenderable};