@arcgis/core 4.28.0-next.20230621 → 4.28.0-next.20230623

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 (249) hide show
  1. package/Basemap.js +1 -1
  2. package/arcade/ArcadeModuleResolver.js +1 -1
  3. package/arcade/Feature.js +1 -1
  4. package/arcade/arcadeCompiler.js +1 -1
  5. package/arcade/arcadeTimeUtils.js +1 -1
  6. package/arcade/featureset/actions/GroupBy.js +1 -1
  7. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  8. package/arcade/featureset/support/sqlUtils.js +1 -1
  9. package/arcade/functions/date.js +1 -1
  10. package/arcade/functions/geomasync.js +1 -1
  11. package/arcade/functions/geometry.js +1 -1
  12. package/arcade/functions/geomsync.js +1 -1
  13. package/arcade/functions/string.js +1 -1
  14. package/arcade/languageUtils.js +1 -1
  15. package/assets/esri/core/workers/RemoteClient.js +1 -1
  16. package/assets/esri/core/workers/chunks/0380e9f61b6f3ca85139.js +1 -0
  17. package/assets/esri/core/workers/chunks/0bd95f46a0a9005a19f9.js +1 -0
  18. package/assets/esri/core/workers/chunks/0c621046b7211cdde980.js +1 -0
  19. package/assets/esri/core/workers/chunks/0e0267739728e5413f1d.js +1 -0
  20. package/assets/esri/core/workers/chunks/{39079bcfd35ed73c4e34.js → 156e801a3262f0ac79c0.js} +1 -1
  21. package/assets/esri/core/workers/chunks/19b4f02fb2392d964582.js +1 -0
  22. package/assets/esri/core/workers/chunks/1ae75f5282e983f6d768.js +1 -0
  23. package/assets/esri/core/workers/chunks/2179b3e9e532ca8ef982.js +1 -0
  24. package/assets/esri/core/workers/chunks/21aaa7fa0e5482670010.js +1 -0
  25. package/assets/esri/core/workers/chunks/26212a08ea383547335b.js +1 -0
  26. package/assets/esri/core/workers/chunks/{2420ec029236ab31d908.js → 2882a55a971af1f7858b.js} +1 -1
  27. package/assets/esri/core/workers/chunks/294285f2822c101326ec.js +1 -0
  28. package/assets/esri/core/workers/chunks/29f9a380610e4fd98a7c.js +1 -0
  29. package/assets/esri/core/workers/chunks/303238fc2fcdbb277981.js +1 -0
  30. package/assets/esri/core/workers/chunks/{3db8ae98799c752afe60.js → 34958516e604d487c625.js} +1 -1
  31. package/assets/esri/core/workers/chunks/3bee743f4c9370045a5d.js +1 -0
  32. package/assets/esri/core/workers/chunks/{8e08968505483dc58e00.js → 40ee4e0a5000a08c3abd.js} +1 -1
  33. package/assets/esri/core/workers/chunks/4128e45e17c9e5280e11.js +1 -0
  34. package/assets/esri/core/workers/chunks/4f88c4d1d2103843aca8.js +1 -0
  35. package/assets/esri/core/workers/chunks/505792ce8cbbddd2e815.js +1 -0
  36. package/assets/esri/core/workers/chunks/{3d42fa4ab5f8632d690a.js → 5237b3938be0d4bc6045.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{57077e608f20d3a931e8.js → 570e94f4fbefc856d303.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{4b235d1b6a72773cd4f4.js → 57bb8516fa998a0fba78.js} +1 -1
  39. package/assets/esri/core/workers/chunks/57bf3ff01d738cedc292.js +1 -0
  40. package/assets/esri/core/workers/chunks/{1e9e68312cd865358260.js → 60486acc5dacf73f851a.js} +1 -1
  41. package/assets/esri/core/workers/chunks/6208f2dfa9dfd3bca000.js +1 -0
  42. package/assets/esri/core/workers/chunks/64008bde5d3ffd9f2499.js +1 -0
  43. package/assets/esri/core/workers/chunks/69f51a7768bf51c9e346.js +1 -0
  44. package/assets/esri/core/workers/chunks/719f741a0e45c3e694ba.js +1 -0
  45. package/assets/esri/core/workers/chunks/{cfe379a78a983373b3ac.js → 7304f45f5622a68253e4.js} +1 -1
  46. package/assets/esri/core/workers/chunks/733b70d6e5c466a67e9c.js +1 -0
  47. package/assets/esri/core/workers/chunks/7694521b44681d52b713.js +1 -0
  48. package/assets/esri/core/workers/chunks/840fd05ceaa038c476d6.js +1 -0
  49. package/assets/esri/core/workers/chunks/89f7fd2ab92aa14fe0c0.js +1 -0
  50. package/assets/esri/core/workers/chunks/8a6f29f2ebd59783bb1b.js +1 -0
  51. package/assets/esri/core/workers/chunks/9d487b7817ccf5bceff6.js +1 -0
  52. package/assets/esri/core/workers/chunks/{42b6315e21c4c1345ba5.js → 9f5337a80963e0b3c009.js} +1 -1
  53. package/assets/esri/core/workers/chunks/a0face18b3ea567999ef.js +1 -0
  54. package/assets/esri/core/workers/chunks/b773c8854e98384ac8ac.js +1 -0
  55. package/assets/esri/core/workers/chunks/{fb44d872b9dbadcf8ccf.js → b9ef05c22bc3e395bcb3.js} +1 -1
  56. package/assets/esri/core/workers/chunks/bc5e34200776cfc83d5b.js +1 -0
  57. package/assets/esri/core/workers/chunks/{cfc3dcca2b69d20d5375.js → c0b9cc091efd5db827de.js} +1 -1
  58. package/assets/esri/core/workers/chunks/c9f5e949830196ad9458.js +1 -0
  59. package/assets/esri/core/workers/chunks/{036301f545aba2b8e485.js → cc15e28a99694120556d.js} +1 -1
  60. package/assets/esri/core/workers/chunks/ce7f575a6c2053c7ca17.js +1 -0
  61. package/assets/esri/core/workers/chunks/ce9c99cee3d1a3963e7c.js +1 -0
  62. package/assets/esri/core/workers/chunks/cf9a87b53ea74bae6a37.js +1 -0
  63. package/assets/esri/core/workers/chunks/d16850b98a53ade0de10.js +1 -0
  64. package/assets/esri/core/workers/chunks/d24f7ef6eca8c91b90b4.js +1 -0
  65. package/assets/esri/core/workers/chunks/dbd86e4b7983873cbe7c.js +1 -0
  66. package/assets/esri/core/workers/chunks/{3c3f65913006b84b2289.js → de20572d334abd4a7d82.js} +1 -1
  67. package/assets/esri/core/workers/chunks/e009e7f074a572894f48.js +1 -0
  68. package/assets/esri/core/workers/chunks/{cb004c492e22c50f9bfa.js → f3eb89cff63e00f036c6.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{b2a423d9ce8bb784267c.js → f53f20c7100092823487.js} +1 -1
  70. package/assets/esri/core/workers/chunks/f6040205c50e2795a1a0.js +1 -0
  71. package/assets/esri/core/workers/chunks/{915734255a79bff3ef0f.js → fcd54e9e64c2864f183c.js} +1 -1
  72. package/assets/esri/t9n/common.json +1 -1
  73. package/assets/esri/t9n/common_en.json +1 -1
  74. package/assets/esri/themes/base/_core.scss +6 -2
  75. package/assets/esri/themes/base/_mixins.scss +0 -147
  76. package/assets/esri/themes/base/widgets/_AreaMeasurement2D.scss +0 -8
  77. package/assets/esri/themes/base/widgets/_AreaMeasurement3D.scss +0 -8
  78. package/assets/esri/themes/base/widgets/_DirectLineMeasurement3D.scss +0 -1
  79. package/assets/esri/themes/base/widgets/_DistanceMeasurement2D.scss +0 -1
  80. package/assets/esri/themes/base/widgets/_MeasurementWidgetContent.scss +67 -0
  81. package/assets/esri/themes/base/widgets/_Slice.scss +17 -54
  82. package/assets/esri/themes/base/widgets/_UnitSelect.scss +14 -0
  83. package/assets/esri/themes/dark/main.css +1 -1
  84. package/assets/esri/themes/light/main.css +1 -1
  85. package/assets/esri/themes/light/view.css +1 -1
  86. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D.json +1 -1
  87. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D_en.json +1 -1
  88. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D.json +1 -1
  89. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D_en.json +1 -1
  90. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D.json +1 -1
  91. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D_en.json +1 -1
  92. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D.json +1 -1
  93. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D_en.json +1 -1
  94. package/chunks/HUDMaterial.glsl.js +39 -39
  95. package/chunks/HighlightBlur.glsl.js +2 -2
  96. package/chunks/ShadowHighlight.glsl.js +1 -1
  97. package/chunks/arcade.js +1 -1
  98. package/chunks/languageUtils.js +1 -1
  99. package/core/HandleOwner.js +1 -1
  100. package/core/promiseUtils.js +1 -1
  101. package/core/support/{WatchUpdatingTracking.js → UpdatingHandles.js} +1 -1
  102. package/core/workers/workerFactory.js +1 -1
  103. package/geometry/projection.js +1 -1
  104. package/interfaces.d.ts +270 -5
  105. package/kernel.js +1 -1
  106. package/layers/Layer.js +1 -1
  107. package/layers/LinkChartLayer.d.ts +4 -0
  108. package/layers/LinkChartLayer.js +1 -1
  109. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  110. package/layers/mixins/PortalLayer.js +1 -1
  111. package/layers/support/TileInfoTilemapCache.js +1 -1
  112. package/package.json +1 -1
  113. package/support/revision.js +1 -1
  114. package/symbols/cim/cimAnalyzer.js +1 -1
  115. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  116. package/views/2d/layers/features/sources/DataTileSource.js +1 -1
  117. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  118. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  119. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  120. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  121. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  122. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  123. package/views/3d/analysis/LineOfSight/LineOfSightVisualization.js +1 -1
  124. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  125. package/views/3d/environment/CloudsGenerator.js +1 -1
  126. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  127. package/views/3d/environment/Precipitation.js +1 -1
  128. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  129. package/views/3d/environment/Stars.js +1 -1
  130. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  131. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  132. package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
  133. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  134. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  135. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  136. package/views/3d/layers/I3SMeshView3D.js +1 -1
  137. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  138. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  139. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  140. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  141. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  142. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  143. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  144. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  145. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  146. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  147. package/views/3d/layers/graphics/Graphics3DScaleVisibility.js +1 -1
  148. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  149. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  150. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  151. package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
  152. package/views/3d/layers/graphics/Labeler.js +1 -1
  153. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  154. package/views/3d/layers/support/FeatureTileTree3DDebugger.js +1 -1
  155. package/views/3d/layers/support/FeatureVisibilityFilter.js +1 -1
  156. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  157. package/views/3d/state/ViewState.js +1 -1
  158. package/views/3d/state/ViewStateManager.js +1 -1
  159. package/views/3d/support/DisplayQualityProfile.js +1 -1
  160. package/views/3d/support/MemoryController.js +1 -1
  161. package/views/3d/support/SceneViewPerformanceInfo.js +1 -1
  162. package/views/3d/support/cameraUtils.js +1 -1
  163. package/views/3d/support/viewpointUtils.js +1 -1
  164. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  165. package/views/3d/terrain/OverlayManager.js +1 -1
  166. package/views/3d/terrain/OverlayRenderer.js +1 -1
  167. package/views/3d/terrain/TerrainSurface.js +1 -1
  168. package/views/3d/webgl-engine/Stage.js +1 -1
  169. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  170. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +6 -7
  171. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +1 -1
  172. package/views/3d/webgl-engine/lib/Highlight.js +1 -1
  173. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  174. package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
  175. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  176. package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
  177. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  178. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  179. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  180. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  181. package/views/LayerViewManager.js +1 -1
  182. package/views/ToolViewManager.js +1 -1
  183. package/views/draw/DrawOperation.js +1 -1
  184. package/views/draw/PointDrawAction.js +1 -1
  185. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  186. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  187. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  188. package/views/interactive/snapping/featureSources/I3SSnappingSource.js +1 -1
  189. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  190. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  191. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  192. package/views/layers/LayerView.js +1 -1
  193. package/views/overlay/ViewOverlay.js +1 -1
  194. package/views/webgl/Texture.js +1 -1
  195. package/widgets/AreaMeasurement2D.js +1 -1
  196. package/widgets/AreaMeasurement3D.js +1 -1
  197. package/widgets/DirectLineMeasurement3D.js +1 -1
  198. package/widgets/DistanceMeasurement2D.js +1 -1
  199. package/widgets/Editor/EditorViewModel.js +1 -1
  200. package/widgets/Editor/Workflow.js +1 -1
  201. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  202. package/widgets/FeatureForm/FieldInput.js +1 -1
  203. package/widgets/FeatureForm/FormExpressionArcadeExecutor.js +1 -1
  204. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  205. package/widgets/OrientedImageryViewer.js +1 -1
  206. package/widgets/Slice.js +1 -1
  207. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  208. package/widgets/support/MeasurementWidgetContent.js +5 -0
  209. package/widgets/support/UnitSelect.js +5 -0
  210. package/assets/esri/core/workers/chunks/0254165377538522c830.js +0 -1
  211. package/assets/esri/core/workers/chunks/07f16ea775b39a1a4a7b.js +0 -1
  212. package/assets/esri/core/workers/chunks/170c72126d10b1fdb2b0.js +0 -1
  213. package/assets/esri/core/workers/chunks/1bbc868d2430103951eb.js +0 -1
  214. package/assets/esri/core/workers/chunks/1d2ef88a8d028adef102.js +0 -1
  215. package/assets/esri/core/workers/chunks/2ef70c9b2484a11b7435.js +0 -1
  216. package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +0 -1
  217. package/assets/esri/core/workers/chunks/3b3d676b609c47a77164.js +0 -1
  218. package/assets/esri/core/workers/chunks/3d9a8cb638cf9b8ca4b3.js +0 -1
  219. package/assets/esri/core/workers/chunks/42f3421740a5479559dc.js +0 -1
  220. package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +0 -1
  221. package/assets/esri/core/workers/chunks/52315f93a6f0ad59bd90.js +0 -1
  222. package/assets/esri/core/workers/chunks/5bb96e602d7cecbecf54.js +0 -1
  223. package/assets/esri/core/workers/chunks/63322229183f1d4eaa70.js +0 -1
  224. package/assets/esri/core/workers/chunks/642510b0371311ff8e16.js +0 -1
  225. package/assets/esri/core/workers/chunks/6995ace1d25d67c98d0e.js +0 -1
  226. package/assets/esri/core/workers/chunks/7e4013f8c31c9a9438c6.js +0 -1
  227. package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +0 -1
  228. package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +0 -1
  229. package/assets/esri/core/workers/chunks/95ff92d7caa34664d58f.js +0 -1
  230. package/assets/esri/core/workers/chunks/9e570cd4a48c30c83ae6.js +0 -1
  231. package/assets/esri/core/workers/chunks/a9e9297267614c4c4f3b.js +0 -1
  232. package/assets/esri/core/workers/chunks/b052463ffb7cb32306dc.js +0 -1
  233. package/assets/esri/core/workers/chunks/b31974524932e638df8c.js +0 -1
  234. package/assets/esri/core/workers/chunks/b75b4b132dbd9cb9d372.js +0 -1
  235. package/assets/esri/core/workers/chunks/c1dfbda75abc748a6ca4.js +0 -1
  236. package/assets/esri/core/workers/chunks/c8702e53a8ad6cf6ab85.js +0 -1
  237. package/assets/esri/core/workers/chunks/c90416e7bf29eb1d4536.js +0 -1
  238. package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +0 -1
  239. package/assets/esri/core/workers/chunks/d0e2b42dca51711f2c6f.js +0 -1
  240. package/assets/esri/core/workers/chunks/d2a127f7bb0e2ba14a13.js +0 -1
  241. package/assets/esri/core/workers/chunks/df96824a6f76bad1370c.js +0 -1
  242. package/assets/esri/core/workers/chunks/e097f41bbfac00250477.js +0 -1
  243. package/assets/esri/core/workers/chunks/e3243d120a23a9b48392.js +0 -1
  244. package/assets/esri/core/workers/chunks/e55f80b774e090a0aa04.js +0 -1
  245. package/assets/esri/core/workers/chunks/e668c7e2e61aae6ca6e0.js +0 -1
  246. package/assets/esri/core/workers/chunks/ef900614353505afb210.js +0 -1
  247. package/assets/esri/core/workers/chunks/f0299d93a95f40ea7cf7.js +0 -1
  248. package/assets/esri/core/workers/chunks/f23b95d7e51a144ad065.js +0 -1
  249. package/assets/esri/core/workers/chunks/f263e73a25fae4beffae.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{releaseMaybe as e}from"../../../../core/maybe.js";import{s as r}from"../../../../chunks/vec2.js";import{c as i}from"../../../../chunks/vec4.js";import{c as t}from"../../../../chunks/vec4f64.js";import{ColorFormat as s}from"../core/FBOCache.js";import{Default3D as a}from"./DefaultVertexAttributeLocations.js";import{Pos2Tex as o}from"./DefaultVertexBufferLayouts.js";import{createQuadVAO as h}from"./glUtil3D.js";import{VertexArrayObject as p}from"./VertexArrayObject.js";import{HighlightApplyTechnique as l}from"../shaders/HighlightApplyTechnique.js";import{H as m}from"../../../../chunks/HighlightBlur.glsl.js";import{HighlightBlurTechnique as u}from"../shaders/HighlightBlurTechnique.js";import{H as c}from"../../../../chunks/HighlightDownsample.glsl.js";import{HighlightDownsampleTechnique as n}from"../shaders/HighlightDownsampleTechnique.js";import{HighlightPassParameters as _}from"../shaders/HighlightPassParameters.js";import{BufferObject as g}from"../../../webgl/BufferObject.js";import{ClearBufferBit as d,PixelFormat as w,PixelType as f,TextureWrapMode as b,Usage as v,PrimitiveType as T}from"../../../webgl/enums.js";import{FramebufferObject as q}from"../../../webgl/FramebufferObject.js";import{TextureDescriptor as M}from"../../../webgl/TextureDescriptor.js";import{vertexCount as P}from"../../../webgl/Util.js";const x=32;class A{constructor(e,r){this._techniqueRep=e,this._fbos=r,this._viewportToRestore=t(),this._passParameters=new _,this._downsampleDrawParameters=new c,this._blurDrawParameters=new m,this._grid={coverageMipmap:null,vao:null,verticalCellCount:0,horizontalCellCount:0,cellPixelSize:0,mipmapLevels:0,viewportWidth:0,viewportHeight:0}}_ensureResources(){this._quadVAO||(this._quadVAO=h(this._fbos.rctx),this._blurTechnique=this._techniqueRep.acquire(u),this._downsampleTechnique=this._techniqueRep.acquire(n),this._applyTechnique=this._techniqueRep.acquire(l))}dispose(){if(this._blurTechnique=e(this._blurTechnique),this._downsampleTechnique=e(this._downsampleTechnique),this._applyTechnique=e(this._applyTechnique),this._grid.coverageMipmap)for(let e=1;e<this._grid.coverageMipmap.length;e++)this._grid.coverageMipmap[e].dispose();this._grid.vao&&this._grid.vao.dispose(),this._quadVAO&&(this._quadVAO.dispose(),this._quadVAO=null)}setDefaultOptions(e){this._passParameters={...new _,...e}}render(e,t,a){this._ensureResources();const o=e.camera;i(this._viewportToRestore,o.fullViewport);const h=o.fullWidth,p=o.fullHeight,l=o.pixelRatio,m=Math.ceil(h/l),u=Math.ceil(p/l),c=this._fbos.rctx;c.bindVAO(this._quadVAO),this._gridUpdateResources(t,x),this._gridComputeMipmap(e),this._passParameters.highlightTexture=t.colorTexture,this._passParameters.coverageTexture=this._grid.coverageMipmap[this._grid.mipmapLevels].colorTexture;const n=c.bindTechnique(this._blurTechnique,this._passParameters,e),_=this._grid.vao;c.bindVAO(_);const g=this._fbos.acquire(s.RGBA_CLAMPED,m,u);c.bindFramebuffer(g.fbo),c.setViewport(0,0,m,u),c.setClearColor(0,0,0,0),c.clear(d.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=t.colorTexture,r(this._blurDrawParameters.blurSize,1/m,0),n.bindDraw(this._blurDrawParameters,e,this._passParameters),c.drawArrays(this._blurTechnique.primitiveType,0,P(_,"geometry"));const w=this._fbos.acquire(s.RGBA_CLAMPED,m,u);c.bindFramebuffer(w.fbo),c.clear(d.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=g.colorTexture,r(this._blurDrawParameters.blurSize,0,1/u),n.bindDraw(this._blurDrawParameters,e,this._passParameters),c.drawArrays(this._blurTechnique.primitiveType,0,P(_,"geometry")),c.bindFramebuffer(a),c.setViewport(this._viewportToRestore[0],this._viewportToRestore[1],this._viewportToRestore[2],this._viewportToRestore[3]),this._passParameters.blurTexture=w.colorTexture,c.bindTechnique(this._applyTechnique,this._passParameters,e),c.drawArrays(this._applyTechnique.primitiveType,0,P(_,"geometry")),w.release(),g.release(),c.bindVAO(null)}_gridUpdateResources(e,r){const i=this._fbos.rctx,t=this._grid;let s=!1;if(null===t.coverageMipmap&&(t.coverageMipmap=[e],s=!0),t.viewportWidth===e.width&&t.viewportHeight===e.height||(s=!0,t.viewportWidth=e.width,t.viewportHeight=e.height),t.coverageMipmap[0]=e,t.cellPixelSize!==r&&(t.cellPixelSize=r,s=!0),s){for(let e=1;e<t.coverageMipmap.length;e++)t.coverageMipmap[e].dispose();t.mipmapLevels=Math.ceil(Math.log(t.cellPixelSize)*Math.LOG2E),t.coverageMipmap.length=t.mipmapLevels+1;for(let e=0;e<t.mipmapLevels;e++){const r=t.coverageMipmap[e],s=new M(Math.ceil(r.width/2),Math.ceil(r.height/2));s.pixelFormat=w.RGB,s.dataType=f.UNSIGNED_SHORT_5_6_5,s.wrapMode=b.CLAMP_TO_EDGE,t.coverageMipmap[e+1]=new q(i,s)}}const h=Math.ceil(e.height/t.cellPixelSize),l=Math.ceil(e.width/t.cellPixelSize);if(!t.vao||t.verticalCellCount!==h||t.horizontalCellCount!==l){t.verticalCellCount=h,t.horizontalCellCount=l;const e=h+1,r=l+1,s=1/h,m=1/l,u=6,c=4,n=new Float32Array(u*c*e*r);let _=0;for(let i=0;i<e;i++)for(let e=0;e<r;e++)n[_]=(e-.5)*m*2-1,n[_+1]=(i-.5)*s*2-1,n[_+2]=e*m,n[_+3]=i*s,n[_+4]=(e+.5)*m*2-1,n[_+5]=(i-.5)*s*2-1,n[_+6]=e*m,n[_+7]=i*s,n[_+8]=(e-.5)*m*2-1,n[_+9]=(i+.5)*s*2-1,n[_+10]=e*m,n[_+11]=i*s,n[_+12]=(e-.5)*m*2-1,n[_+13]=(i+.5)*s*2-1,n[_+14]=e*m,n[_+15]=i*s,n[_+16]=(e+.5)*m*2-1,n[_+17]=(i-.5)*s*2-1,n[_+18]=e*m,n[_+19]=i*s,n[_+20]=(e+.5)*m*2-1,n[_+21]=(i+.5)*s*2-1,n[_+22]=e*m,n[_+23]=i*s,_+=u*c;t.vao&&t.vao.dispose(),t.vao=new p(i,a,{geometry:o},{geometry:g.createVertex(i,v.STATIC_DRAW,n)})}}_gridComputeMipmap(e){const i=this._fbos.rctx,t=this._grid,s=i.bindTechnique(this._downsampleTechnique,this._passParameters,e);i.bindVAO(this._quadVAO);for(let a=0;a<t.mipmapLevels;a++){i.bindFramebuffer(t.coverageMipmap[a+1]);const o=t.coverageMipmap[a+1].width,h=t.coverageMipmap[a+1].height;this._downsampleDrawParameters.inputTexture=t.coverageMipmap[a].colorTexture,r(this._downsampleDrawParameters.invFramebufferDim,1/o,1/h),s.bindDraw(this._downsampleDrawParameters,e,this._passParameters),i.setViewport(0,0,o,h),i.drawArrays(T.TRIANGLE_STRIP,0,P(this._quadVAO,"geometry"))}}get gpuMemoryUsage(){return this._grid.coverageMipmap?.reduce(((e,r)=>e+r.gpuMemoryUsage),0)??0}get test(){return{coverage:this._grid.coverageMipmap}}}export{A as Highlight};
5
+ import{releaseMaybe as e}from"../../../../core/maybe.js";import{s as r}from"../../../../chunks/vec2.js";import{c as i}from"../../../../chunks/vec4.js";import{c as t}from"../../../../chunks/vec4f64.js";import{ColorFormat as s}from"../core/FBOCache.js";import{Default3D as a}from"./DefaultVertexAttributeLocations.js";import{Pos2Tex as o}from"./DefaultVertexBufferLayouts.js";import{createQuadVAO as h}from"./glUtil3D.js";import{VertexArrayObject as p}from"./VertexArrayObject.js";import{HighlightApplyTechnique as l}from"../shaders/HighlightApplyTechnique.js";import{H as m}from"../../../../chunks/HighlightBlur.glsl.js";import{HighlightBlurTechnique as u}from"../shaders/HighlightBlurTechnique.js";import{H as c}from"../../../../chunks/HighlightDownsample.glsl.js";import{HighlightDownsampleTechnique as n}from"../shaders/HighlightDownsampleTechnique.js";import{HighlightPassParameters as _}from"../shaders/HighlightPassParameters.js";import{BufferObject as g}from"../../../webgl/BufferObject.js";import{ClearBufferBit as d,PixelFormat as w,PixelType as f,TextureWrapMode as b,Usage as v,PrimitiveType as T}from"../../../webgl/enums.js";import{FramebufferObject as q}from"../../../webgl/FramebufferObject.js";import{TextureDescriptor as M}from"../../../webgl/TextureDescriptor.js";import{vertexCount as P}from"../../../webgl/Util.js";const x=32;class y{constructor(e,r){this._techniqueRep=e,this._fbos=r,this._viewportToRestore=t(),this._passParameters=new _,this._downsampleDrawParameters=new c,this._blurDrawParameters=new m,this._grid={coverageMipmap:null,vao:null,verticalCellCount:0,horizontalCellCount:0,cellPixelSize:0,mipmapLevels:0,viewportWidth:0,viewportHeight:0}}_ensureResources(){this._quadVAO||(this._quadVAO=h(this._fbos.rctx),this._blurTechnique=this._techniqueRep.acquire(u),this._downsampleTechnique=this._techniqueRep.acquire(n),this._applyTechnique=this._techniqueRep.acquire(l))}dispose(){if(this._blurTechnique=e(this._blurTechnique),this._downsampleTechnique=e(this._downsampleTechnique),this._applyTechnique=e(this._applyTechnique),this._grid.coverageMipmap)for(let e=1;e<this._grid.coverageMipmap.length;e++)this._grid.coverageMipmap[e].dispose();this._grid.vao&&this._grid.vao.dispose(),this._quadVAO&&(this._quadVAO.dispose(),this._quadVAO=null)}setDefaultOptions(e){this._passParameters={...new _,...e}}render(e,t,a){this._ensureResources();const o=e.camera;i(this._viewportToRestore,o.fullViewport);const h=o.fullWidth,p=o.fullHeight,l=o.pixelRatio,m=Math.ceil(h/l),u=Math.ceil(p/l),c=this._fbos.rctx;c.bindVAO(this._quadVAO),this._gridUpdateResources(t,x),this._gridComputeMipmap(e),this._passParameters.highlightTexture=t.colorTexture,this._passParameters.coverageTexture=this._grid.coverageMipmap[this._grid.mipmapLevels].colorTexture;const n=c.bindTechnique(this._blurTechnique,this._passParameters,e),_=this._grid.vao;c.bindVAO(_);const g=this._fbos.acquire(s.RGBA4,m,u);c.bindFramebuffer(g.fbo),c.setViewport(0,0,m,u),c.setClearColor(0,0,0,0),c.clear(d.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=t.colorTexture,r(this._blurDrawParameters.blurSize,1/m,0),n.bindDraw(this._blurDrawParameters,e,this._passParameters),c.drawArrays(this._blurTechnique.primitiveType,0,P(_,"geometry"));const w=this._fbos.acquire(s.RGBA4,m,u);c.bindFramebuffer(w.fbo),c.clear(d.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=g.colorTexture,r(this._blurDrawParameters.blurSize,0,1/u),n.bindDraw(this._blurDrawParameters,e,this._passParameters),c.drawArrays(this._blurTechnique.primitiveType,0,P(_,"geometry")),c.bindFramebuffer(a),c.setViewport(this._viewportToRestore[0],this._viewportToRestore[1],this._viewportToRestore[2],this._viewportToRestore[3]),this._passParameters.blurTexture=w.colorTexture,c.bindTechnique(this._applyTechnique,this._passParameters,e),c.drawArrays(this._applyTechnique.primitiveType,0,P(_,"geometry")),w.release(),g.release(),c.bindVAO(null)}_gridUpdateResources(e,r){const i=this._fbos.rctx,t=this._grid;let s=!1;if(null===t.coverageMipmap&&(t.coverageMipmap=[e],s=!0),t.viewportWidth===e.width&&t.viewportHeight===e.height||(s=!0,t.viewportWidth=e.width,t.viewportHeight=e.height),t.coverageMipmap[0]=e,t.cellPixelSize!==r&&(t.cellPixelSize=r,s=!0),s){for(let e=1;e<t.coverageMipmap.length;e++)t.coverageMipmap[e].dispose();t.mipmapLevels=Math.ceil(Math.log(t.cellPixelSize)*Math.LOG2E),t.coverageMipmap.length=t.mipmapLevels+1;for(let e=0;e<t.mipmapLevels;e++){const r=t.coverageMipmap[e],s=new M(Math.ceil(r.width/2),Math.ceil(r.height/2));s.pixelFormat=w.RGB,s.dataType=f.UNSIGNED_SHORT_5_6_5,s.wrapMode=b.CLAMP_TO_EDGE,t.coverageMipmap[e+1]=new q(i,s)}}const h=Math.ceil(e.height/t.cellPixelSize),l=Math.ceil(e.width/t.cellPixelSize);if(!t.vao||t.verticalCellCount!==h||t.horizontalCellCount!==l){t.verticalCellCount=h,t.horizontalCellCount=l;const e=h+1,r=l+1,s=1/h,m=1/l,u=6,c=4,n=new Float32Array(u*c*e*r);let _=0;for(let i=0;i<e;i++)for(let e=0;e<r;e++)n[_]=(e-.5)*m*2-1,n[_+1]=(i-.5)*s*2-1,n[_+2]=e*m,n[_+3]=i*s,n[_+4]=(e+.5)*m*2-1,n[_+5]=(i-.5)*s*2-1,n[_+6]=e*m,n[_+7]=i*s,n[_+8]=(e-.5)*m*2-1,n[_+9]=(i+.5)*s*2-1,n[_+10]=e*m,n[_+11]=i*s,n[_+12]=(e-.5)*m*2-1,n[_+13]=(i+.5)*s*2-1,n[_+14]=e*m,n[_+15]=i*s,n[_+16]=(e+.5)*m*2-1,n[_+17]=(i-.5)*s*2-1,n[_+18]=e*m,n[_+19]=i*s,n[_+20]=(e+.5)*m*2-1,n[_+21]=(i+.5)*s*2-1,n[_+22]=e*m,n[_+23]=i*s,_+=u*c;t.vao&&t.vao.dispose(),t.vao=new p(i,a,{geometry:o},{geometry:g.createVertex(i,v.STATIC_DRAW,n)})}}_gridComputeMipmap(e){const i=this._fbos.rctx,t=this._grid,s=i.bindTechnique(this._downsampleTechnique,this._passParameters,e);i.bindVAO(this._quadVAO);for(let a=0;a<t.mipmapLevels;a++){i.bindFramebuffer(t.coverageMipmap[a+1]);const o=t.coverageMipmap[a+1].width,h=t.coverageMipmap[a+1].height;this._downsampleDrawParameters.inputTexture=t.coverageMipmap[a].colorTexture,r(this._downsampleDrawParameters.invFramebufferDim,1/o,1/h),s.bindDraw(this._downsampleDrawParameters,e,this._passParameters),i.setViewport(0,0,o,h),i.drawArrays(T.TRIANGLE_STRIP,0,P(this._quadVAO,"geometry"))}}get gpuMemoryUsage(){return this._grid.coverageMipmap?.reduce(((e,r)=>e+r.gpuMemoryUsage),0)??0}get test(){return{coverage:this._grid.coverageMipmap}}}export{y as Highlight};
@@ -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"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{c as e}from"../../../../chunks/vec4.js";import{f as r}from"../../../../chunks/vec4f64.js";import{ColorFormat as i,DepthFormat as h}from"../core/FBOCache.js";import{TransparencyPassType as s}from"./TransparencyPassType.js";import{ClearBufferBit as o}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as c}from"../../../webgl/FramebufferObject.js";class a{constructor(t,e){this._fbos=t,this._compositingHelper=e,this.width=4,this.height=4,this._backgroundColor=r(0,0,0,1)}dispose(){this.releaseBuffers()}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){e(this._backgroundColor,t)}get framebuffer(){return this.color.detachDepth(),this.color.attachDepth(this.depth),this.color.fbo}get colorTexture(){return this.color.colorTexture}get depthTexture(){return this.depth.attachment}swapColorBuffer(){const t=this.color;return this._color=null,t}initializeFrame(t){const e=this._fbos.rctx;this.width=t.fullWidth,this.height=t.fullHeight,c(this,e.parameters.maxTextureSize),this.releaseBuffers(),this.bindFbo(),e.setClearStencil(0);const r=this._backgroundColor;e.setClearColor(r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),e.clearSafe(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT|o.STENCIL_BUFFER_BIT)}releaseBuffers(){this._color?.detachDepth(),this._color=t(this._color),this._depth=t(this._depth)}compositeAtmosphereToMain(t,e,r,i){this._bindTarget(this.color),this._compositingHelper.compositeAtmosphere(t,r,i,e),this._bindTarget(this.color,this.depth)}renderHUDVisibility(t,e,r){return t?.fbo.width===this.width&&t?.fbo.height===this.height||(t?.release(),t=this._fbos.acquire(i.RGBA_CLAMPED,this.width,this.height)),t.attachDepth(r||this.depth),this._fbos.rctx.bindFramebuffer(t.fbo),this.renderToFBO(e,b),t.detachDepth(),t}compositeToHUDVisibility(t,e){this._fbos.rctx.bindFramebuffer(t.hudVisibility?.fbo),this._compositingHelper.compositeHUD(t,e)}renderOITPass(t,e,r){let o,c;switch(e){case s.Color:o=this._fbos.acquire(i.RGBA16F,this.width,this.height),c=[0,0,0,0];break;case s.Alpha:o=this._fbos.acquire(i.R16F,this.width,this.height),c=[1,1,1,1];break;case s.FrontFace:o=this._fbos.acquire(i.RGBA_CLAMPED,this.width,this.height),c=[0,0,0,0]}return r?(o.acquireDepth(h.DEPTH16_BUFFER),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c,!0,!0),o.releaseDepth()):(o.attachDepth(this.depth),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c),o.detachDepth()),o}compositeToFramebuffer(t,e,r,i){this.bindFbo(),this._compositingHelper.composite(t,e,r,i)}compositeTransparentOntoOpaque(t,e,r,i,h){h?(this._fbos.rctx.bindFramebuffer(h.fbo),this._fbos.rctx.setClearColor(0,0,0,1e-13),this._fbos.rctx.clearSafe(o.COLOR_BUFFER_BIT)):this.bindFbo(),this._compositingHelper.compositeOIT(t,e.colorTexture,r.colorTexture,i.colorTexture)}renderDepthDetached(t){this._bindTarget(this.color),t(),this._bindTarget(this.color,this.depth)}renderToCachedFBO(e,r,s,o=h.DEPTH16_BUFFER,c=this.width,a=this.height){return e?.fbo.width===c&&e?.fbo.height===a||(e=t(e)),e=e??this._fbos.acquire(i.RGBA_CLAMPED,c,a),null!=o&&e.acquireDepth(o),this._fbos.rctx.bindFramebuffer(e.fbo),this.renderToFBO(r,s,!0,!0),e}renderToFBO(t,e,r=!1,i=!1){const h=this._fbos.rctx;let s=0;if(e){const t=1e-13,r=Math.max(t,e[3]);h.setClearColor(e[0],e[1],e[2],r),s|=o.COLOR_BUFFER_BIT}r&&(s|=o.DEPTH_BUFFER_BIT),!1===i?i=0:(!0===i&&(i=255),s|=o.STENCIL_BUFFER_BIT),s&&h.clearSafe(s,i),t(),h.gl.flush()}renderToTargets(t,e,r,i,h=!1,s=!1){this._bindTarget(e,r),this.renderToFBO(t,i,h,s),e.detachDepth()}bindFbo(){this._bindTarget(this.color,this.depth)}_bindTarget(t,e){t.detachDepth(),t.attachDepth(e),this._fbos.rctx.bindFramebuffer(t.fbo)}get gpuMemoryUsage(){return(this._color?.colorTexture?.gpuMemoryUsage??0)+(this._depth?.memoryUsage??0)}get color(){return this._color||(this._color=this._fbos.acquire(i.RGBA_CLAMPED,this.width,this.height)),this._color}get depth(){return this._depth||(this._depth=this._fbos.acquireDepth(h.DEPTH_STENCIL_TEXTURE,this.width,this.height)),this._depth}}const b=[0,1,0,1];export{a as OffscreenRendering};
5
+ import"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{c as e}from"../../../../chunks/vec4.js";import{f as r}from"../../../../chunks/vec4f64.js";import{ColorFormat as i,DepthFormat as h}from"../core/FBOCache.js";import{TransparencyPassType as s}from"./TransparencyPassType.js";import{ClearBufferBit as o}from"../../../webgl/enums.js";import{ensureAttachmentMaxSize as c}from"../../../webgl/FramebufferObject.js";class a{constructor(t,e){this._fbos=t,this._compositingHelper=e,this.width=4,this.height=4,this._backgroundColor=r(0,0,0,1)}dispose(){this.releaseBuffers()}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){e(this._backgroundColor,t)}get framebuffer(){return this.color.detachDepth(),this.color.attachDepth(this.depth),this.color.fbo}get colorTexture(){return this.color.colorTexture}get depthTexture(){return this.depth.attachment}swapColorBuffer(){const t=this.color;return this._color=null,t}initializeFrame(t){const e=this._fbos.rctx;this.width=t.fullWidth,this.height=t.fullHeight,c(this,e.parameters.maxTextureSize),this.releaseBuffers(),this.bindFbo(),e.setClearStencil(0);const r=this._backgroundColor;e.setClearColor(r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),e.clearSafe(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT|o.STENCIL_BUFFER_BIT)}releaseBuffers(){this._color?.detachDepth(),this._color=t(this._color),this._depth=t(this._depth)}compositeAtmosphereToMain(t,e,r,i){this._bindTarget(this.color),this._compositingHelper.compositeAtmosphere(t,r,i,e),this._bindTarget(this.color,this.depth)}renderHUDVisibility(t,e,r){return t?.fbo.width===this.width&&t?.fbo.height===this.height||(t?.release(),t=this._fbos.acquire(i.RGBA4,this.width,this.height)),t.attachDepth(r||this.depth),this._fbos.rctx.bindFramebuffer(t.fbo),this.renderToFBO(e,b),t.detachDepth(),t}compositeToHUDVisibility(t,e){this._fbos.rctx.bindFramebuffer(t.hudVisibility?.fbo),this._compositingHelper.compositeHUD(t,e)}renderOITPass(t,e,r){let o,c;switch(e){case s.Color:o=this._fbos.acquire(i.RGBA16F,this.width,this.height),c=[0,0,0,0];break;case s.Alpha:o=this._fbos.acquire(i.R16F,this.width,this.height),c=[1,1,1,1];break;case s.FrontFace:o=this._fbos.acquire(i.RGBA,this.width,this.height),c=[0,0,0,0]}return r?(o.acquireDepth(h.DEPTH16_BUFFER),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c,!0,!0),o.releaseDepth()):(o.attachDepth(this.depth),this._fbos.rctx.bindFramebuffer(o.fbo),this.renderToFBO(t,c),o.detachDepth()),o}compositeToFramebuffer(t,e,r,i){this.bindFbo(),this._compositingHelper.composite(t,e,r,i)}compositeTransparentOntoOpaque(t,e,r,i,h){h?(this._fbos.rctx.bindFramebuffer(h.fbo),this._fbos.rctx.setClearColor(0,0,0,1e-13),this._fbos.rctx.clearSafe(o.COLOR_BUFFER_BIT)):this.bindFbo(),this._compositingHelper.compositeOIT(t,e.colorTexture,r.colorTexture,i.colorTexture)}renderDepthDetached(t){this._bindTarget(this.color),t(),this._bindTarget(this.color,this.depth)}renderToCachedFBO(e,r,s,o=i.RGBA,c=h.DEPTH16_BUFFER,a=this.width,b=this.height){return e?.fbo.width===a&&e?.fbo.height===b||(e=t(e)),e=e??this._fbos.acquire(o,a,b),null!=c&&e.acquireDepth(c),this._fbos.rctx.bindFramebuffer(e.fbo),this.renderToFBO(r,s,!0,!0),e}renderToFBO(t,e,r=!1,i=!1){const h=this._fbos.rctx;let s=0;if(e){const t=1e-13,r=Math.max(t,e[3]);h.setClearColor(e[0],e[1],e[2],r),s|=o.COLOR_BUFFER_BIT}r&&(s|=o.DEPTH_BUFFER_BIT),!1===i?i=0:(!0===i&&(i=255),s|=o.STENCIL_BUFFER_BIT),s&&h.clearSafe(s,i),t(),h.gl.flush()}renderToTargets(t,e,r,i,h=!1,s=!1){this._bindTarget(e,r),this.renderToFBO(t,i,h,s),e.detachDepth()}bindFbo(){this._bindTarget(this.color,this.depth)}_bindTarget(t,e){t.detachDepth(),t.attachDepth(e),this._fbos.rctx.bindFramebuffer(t.fbo)}get gpuMemoryUsage(){return(this._color?.colorTexture?.gpuMemoryUsage??0)+(this._depth?.memoryUsage??0)}get color(){return this._color||(this._color=this._fbos.acquire(i.RGBA,this.width,this.height)),this._color}get depth(){return this._depth||(this._depth=this._fbos.acquireDepth(h.DEPTH_STENCIL_TEXTURE,this.width,this.height)),this._depth}}const b=[0,1,0,1];export{a as OffscreenRendering};
@@ -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 t from"../../../../core/PooledArray.js";import{isPromiseLike as n,createAbortError as s}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{Decorations as a}from"./basicInterfaces.js";import{union as l}from"./depthRange.js";import{RenderOccludedFlag as d}from"./Material.js";import{RenderSlot as c}from"./RenderSlot.js";let u=class extends r{constructor(e){super({}),this._context=e,this._renderPlugins=new t,this._slots=new Array;for(let r=0;r<c.MAX_SLOTS;++r)this._slots[r]=[]}normalizeCtorArgs(){return{}}add(e,r,t){const o=()=>{if(t?.aborted)throw r.uninitializeRenderContext(),s();this._renderPlugins.push(r);for(const t of e)this._slots[t].push(r);this._context.requestRender()},i=r.initializeRenderContext(this._context,t);if(n(i))return i.then(o);o(),this.notifyChange("_renderPlugins")}remove(e){if(null!=this._renderPlugins.removeUnordered(e)){for(let r=0;r<this._slots.length;++r)this._slots[r]=this._slots[r].filter((r=>r!==e));e.uninitializeRenderContext(),this._context.requestRender(),this.notifyChange("_renderPlugins")}}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this._context.renderContext)}))}updateAnimation(e){let r=!1;return this._renderPlugins.forAll((t=>{t.updateAnimation&&(r=t.updateAnimation(e)||r)})),r}prepareSlots(e){for(const r of e)this._context.renderContext.bindParameters.slot=r,this._slots[r].filter((e=>{e.canRender&&(p(e)&&e.prepareTechnique(this._context.renderContext),h(e)&&e.prepareTechniques(this._context.renderContext))}))}prepare(e){this._context.renderContext.bindParameters.slot=e;const r=this._slots[e],t=new Map;return r.forEach((e=>{if(e.canRender&&(!e.isDecoration||this._context.renderContext.bindParameters.decorations!==a.OFF))if(p(e)){const r=e.prepareTechnique(this._context.renderContext);null!=r&&t.set(e,r)}else if(h(e)){const r=e.prepareTechniques(this._context.renderContext);null!=r&&t.set(e,r)}else t.set(e,null)})),t}render(e){e.forEach(((e,r)=>r.render(this._context.renderContext,e)))}queryDepthRange(e){const r=g;return r.near=1/0,r.far=-1/0,this._renderPlugins.forAll((t=>{if(t.queryDepthRange){const n=t.queryDepthRange(e);n&&l(r,n,r)}})),r}get updating(){return this._renderPlugins.some((e=>e.running))}get needsTransparentPass(){return this._renderPlugins.some((e=>e.needsTransparentPass))}get needsHighlight(){return this._renderPlugins.some((e=>e.needsHighlight))}get hasDecorations(){return this._renderPlugins.some((e=>e.isDecoration))}get needsLinearDepth(){return this._renderPlugins.some((e=>e.needsLinearDepth))}get needsLaserlineWithContrastControl(){const e=this._slots[c.LASERLINES_CONTRAST_CONTROL];return!!e&&e.length>0}get renderOccludedFlags(){return this._renderPlugins.reduce(((e,r)=>e|r.renderOccludedFlags),d.None)}};function p(e){return"prepareTechnique"in e}function h(e){return"prepareTechniques"in e}e([o()],u.prototype,"_renderPlugins",void 0),e([o({readOnly:!0})],u.prototype,"updating",null),u=e([i("esri.views.3d.webgl-engine.lib.RenderPluginManager")],u);const g={near:0,far:0};export{u as RenderPluginManager};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/PooledArray.js";import{isPromiseLike as n,createAbortError as s}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{Decorations as a}from"./basicInterfaces.js";import{union as l}from"./depthRange.js";import{RenderOccludedFlag as d}from"./Material.js";import{RenderSlot as c}from"./RenderSlot.js";let u=class extends r{constructor(e){super({}),this._context=e,this._renderPlugins=new t,this._slots=new Array;for(let r=0;r<c.MAX_SLOTS;++r)this._slots[r]=[]}normalizeCtorArgs(){return{}}add(e,r,t){const o=()=>{if(t?.aborted)throw r.uninitializeRenderContext(),s();this._renderPlugins.push(r);for(const t of e)this._slots[t].push(r);this._context.requestRender(),this.notifyChange("updating")},i=r.initializeRenderContext(this._context,t);if(n(i))return i.then(o);o()}remove(e){if(null!=this._renderPlugins.removeUnordered(e)){for(let r=0;r<this._slots.length;++r)this._slots[r]=this._slots[r].filter((r=>r!==e));e.uninitializeRenderContext(),this._context.requestRender(),this.notifyChange("updating")}}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this._context.renderContext)}))}updateAnimation(e){let r=!1;return this._renderPlugins.forAll((t=>{t.updateAnimation&&(r=t.updateAnimation(e)||r)})),r}prepareSlots(e){for(const r of e)this._context.renderContext.bindParameters.slot=r,this._slots[r].filter((e=>{e.canRender&&(p(e)&&e.prepareTechnique(this._context.renderContext),h(e)&&e.prepareTechniques(this._context.renderContext))}))}prepare(e){this._context.renderContext.bindParameters.slot=e;const r=this._slots[e],t=new Map;return r.forEach((e=>{if(e.canRender&&(!e.isDecoration||this._context.renderContext.bindParameters.decorations!==a.OFF))if(p(e)){const r=e.prepareTechnique(this._context.renderContext);null!=r&&t.set(e,r)}else if(h(e)){const r=e.prepareTechniques(this._context.renderContext);null!=r&&t.set(e,r)}else t.set(e,null)})),t}render(e){e.forEach(((e,r)=>r.render(this._context.renderContext,e)))}queryDepthRange(e){const r=g;return r.near=1/0,r.far=-1/0,this._renderPlugins.forAll((t=>{if(t.queryDepthRange){const n=t.queryDepthRange(e);n&&l(r,n,r)}})),r}get updating(){return this._renderPlugins.some((e=>e.running))}get needsTransparentPass(){return this._renderPlugins.some((e=>e.needsTransparentPass))}get needsHighlight(){return this._renderPlugins.some((e=>e.needsHighlight))}get hasDecorations(){return this._renderPlugins.some((e=>e.isDecoration))}get needsLinearDepth(){return this._renderPlugins.some((e=>e.needsLinearDepth))}get needsLaserlineWithContrastControl(){const e=this._slots[c.LASERLINES_CONTRAST_CONTROL];return!!e&&e.length>0}get renderOccludedFlags(){return this._renderPlugins.reduce(((e,r)=>e|r.renderOccludedFlags),d.None)}};function p(e){return"prepareTechnique"in e}function h(e){return"prepareTechniques"in e}e([o({readOnly:!0})],u.prototype,"updating",null),u=e([i("esri.views.3d.webgl-engine.lib.RenderPluginManager")],u);const g={near:0,far:0};export{u as RenderPluginManager};
@@ -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 has from"../../../../core/has.js";import{removeMaybe as s,disposeMaybe 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 c}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as m,a as u,m as f}from"../../../../chunks/mat4.js";import{I as g,c as T}from"../../../../chunks/mat4f64.js";import{h as E}from"../../../../chunks/vec4.js";import{a as R}from"../../../../chunks/boundedPlane.js";import A from"../../support/debugFlags.js";import{TransparencyMode as P}from"../../terrain/TerrainRenderer.js";import{FBOCache as b,ColorFormat as S,DepthFormat as y}from"../core/FBOCache.js";import{RenderPassManager as C}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as I}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as O}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{AnimationTimeStep as w}from"./AnimationTimeStep.js";import{Decorations as D,RenderRequestType as N,StencilBits as L}from"./basicInterfaces.js";import{BoundingInfo as M}from"./BoundingInfo.js";import{ZERO as H,union as x}from"./depthRange.js";import{depthRangeFromScene as v}from"./depthRangeUtils.js";import{Highlight as F}from"./Highlight.js";import{RenderOccludedFlag as U}from"./Material.js";import{OffscreenRendering as q}from"./OffscreenRendering.js";import{RenderContext as G}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as B}from"./rendererUtils.js";import{setupFeatureDefaults as j,RenderFeature as V}from"./RenderFeature.js";import{RenderPluginManager as Q}from"./RenderPluginManager.js";import{RenderSlot as k}from"./RenderSlot.js";import{ShadowAccumulator as W}from"./ShadowAccumulator.js";import{ShadowHighlight as Y}from"./ShadowHighlight.js";import{ShadowMap as X,SnapshotSlot as z}from"./ShadowMap.js";import J from"./SliceHelper.js";import{SmaaRenderPass as K}from"./SmaaRenderPass.js";import{SSAOHelper as Z}from"./SSAOHelper.js";import{TransparencyPassType as $}from"./TransparencyPassType.js";import{EdgeView as ee}from"./edgeRendering/EdgeView.js";import{Transparency as re}from"./edgeRendering/interfaces.js";import{MergedRenderer as te}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as se}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ne}from"../../../support/RenderState.js";import{PixelFormat as he,PixelType as oe,ClearBufferBit as de}from"../../../webgl/enums.js";let le=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._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 _antialiasing(){return this._antialiasingEnabled||this.isFeatureEnabled(V.Antialiasing)}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(V.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(V.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.needsHighlight}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(V.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,s,i,a,n,_){super({}),this._stage=e,this._materialRepository=r,this._techniqueRepository=s,this._rctx=i,this._compositingHelper=a,this._magnifierHelper=n,this._requestRender=_,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._fallbackDepthStencilTexture=null,this._sliceHelper=new J,this._state=ne.IDLE,this._antialiasingEnabled=!0,this._highQualityTransparencyEnabled=!0,this._terrainRenderingEnabled=!0,this._terrainTransparency=P.Opaque,this._ssrEnabled=!1,this._ssaoEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new w,this._renderHiddenTransparentEdges=()=>{},this.fboCache=new b(i),this._renderStateFeatures=j(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._smaaPass=new K(this.fboCache,s),_(),this._offscreen=new q(this.fboCache,this._compositingHelper),this.performanceInfo=new ie(this._rctx),this._shadowMap=new X(this.fboCache,e.viewingMode),this._ssaoHelper=new Z(e.view,this.fboCache,s,_),this._highlight=new F(s,this.fboCache),this._shadowHighlight=new Y(this._rctx,e.viewingMode),this._shadowAccumulator=new W(this.fboCache,s,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(I.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),_),this._renderContext=new G(this._rctx,this._offscreen,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new Q({renderContext:this._renderContext,techniqueRepository:s,textureRepository:t,materialRepository:this._materialRepository,requestRender:_,controller:e}),this.renderPassManager=new C(this._rctx,this._techniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this.own([o((()=>this._stage.view.state.camera),(()=>_()),d),o((()=>A.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(re.TRANSPARENT):()=>{},_()}),l),o((()=>this._ssaoEnabled||this.isFeatureEnabled(V.SSAO)),(e=>this._ssaoHelper.enabled=e),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaaPass.dispose(),this._gpuTimerHandle=s(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._fallbackDepthStencilTexture=i(this._fallbackDepthStencilTexture),this._shadowMap.dispose(),this._ssaoHelper.destroy(),this._highlight.dispose(),this._shadowHighlight.dispose(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.destroy(),this._releaseFBOs(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility),this.fboCache.destroy(),M.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._offscreen.dispose(),this._shadowMap.disposeOffscreenBuffers(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing&&this._smaaPass.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 ee({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:Te(e)}),this.addHandles(o((()=>this._edgeView?.updating),(()=>this._requestRender()),_)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return m(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.qualitySettings?.ambientOcclusion&&this._ssaoEnabled!==e.qualitySettings.ambientOcclusion&&(this._ssaoEnabled=e.qualitySettings.ambientOcclusion,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())}e.backgroundColor&&!E(this._offscreen.backgroundColor,e.backgroundColor)&&(this._offscreen.backgroundColor=e.backgroundColor,this._requestRender()),void 0!==e.antialiasingEnabled&&this._antialiasingEnabled!==e.antialiasingEnabled&&(this._antialiasingEnabled=e.antialiasingEnabled,this._requestRender()),void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlight.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlight.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.overlays&&this._bindParameters.overlays!==e.overlays&&(this._bindParameters.overlays=e.overlays,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.renderOverlay&&this._renderOverlay!==e.renderOverlay&&(this._renderOverlay=e.renderOverlay,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainRenderingEnabled&&this._terrainRenderingEnabled!==e.terrainRenderingEnabled&&(this._terrainRenderingEnabled=e.terrainRenderingEnabled,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=B(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));null==i&&t.adds.length>0&&(i=new te(this._rctx,this._materialRepository,s),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.requiresSlot(k.LINE_CALLOUTS_HUD_DEPTH,I.Color)||e.requiresSlot(k.HUD_MATERIAL,I.Color)||e.requiresSlot(k.LABEL_MATERIAL,I.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?s(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.fboCache.resetPeakMemoryUsage();const a=this._offscreen,{camera:h,contentCamera:o,mode:d,alignPixelEnabled:l}=t;this._state=d,this._renderOverlay(i),this.performanceInfo.advance(ae.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=$.NONE,this._bindParameters.alignPixelEnabled=l,this._bindParameters.decorations=s,this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this.hasReflections?this._bindParameters.ssr.lastFrameColor=a.swapColorBuffer():a.swapColorBuffer().release();const _=R(this._sliceHelper.plane);s===D.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),h.setGLViewport(this._rctx),this._prepare(h,o),this._renderPlugins.prepareRender(),this.performanceInfo.advance(ae.PREPARE);const p=this._computeDepthRange(h);this._renderShadowMap(e,h,this._bindParameters.lighting.mainLight.direction,p),this.performanceInfo.advance(ae.SHADOW_MAP),a.initializeFrame(h),this._ensureBindParameters(h,o);const c=this._terrainRenderingEnabled&&(this._terrainTransparency===P.Semitransparent||this._terrainTransparency===P.TransparentWithDraped),m=this._highQualityTransparency&&c,u=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;this._prepareShaders(m,u),this._renderLinearDepth(),this.performanceInfo.advance(ae.LINEAR_DEPTH),this._accumulateShadows(p,h,o),this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(i),this.performanceInfo.advance(ae.SSAO),this._renderContext.output=I.Color,a.bindFbo(),this._renderOpaqueGeometry(),this.performanceInfo.advance(ae.OPAQUE),this._renderTerrainLinearDepth(m),this._setMultipassTerrain(m),this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),a.bindFbo(),this._renderSlot(k.VOXEL),this.performanceInfo.advance(ae.VOXEL),this._renderHiddenTransparentEdges(),u&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT);const f=this._renderGeometryLinearDepth(m);this._renderHUDVisibility(f),m||this._renderInternalSlot(k.LINE_CALLOUTS),this.performanceInfo.advance(ae.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(re.TRANSPARENT,f),f?.release(),this.performanceInfo.advance(ae.TRANSPARENT_EDGES);const g=c?this._renderTransparentTerrain():null;if(g&&this._bindParameters.hudVisibility&&(m?this._renderLineCallouts(O.Occluded):a.compositeToHUDVisibility(this._bindParameters,g.colorTexture),this._renderHUD(O.Occluded,a.framebuffer),this.performanceInfo.advance(ae.HUD_OCCLUDED)),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),g&&(a.compositeToFramebuffer(this._bindParameters,g.colorTexture,se.PremultipliedAlpha,1),g.release(),m&&(this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),u&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT),this._renderEdges(re.TRANSPARENT),this.performanceInfo.advance(ae.TRANSPARENT_EDGES))),m&&this._renderLineCallouts(O.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),a.bindFbo(),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(k.LASERLINES),this.performanceInfo.advance(ae.ENVIRONMENT),this._renderPlugins.needsLaserlineWithContrastControl){const e=()=>this._renderSlot(k.LASERLINES_CONTRAST_CONTROL),{width:r,height:t,depth:s}=a,i=this.fboCache.acquire(S.RGBA_CLAMPED,r,t);a.renderToTargets(e,i,s,ce),a.compositeToFramebuffer(this._bindParameters,i.colorTexture,se.PremultipliedAlpha,1),i.release()}this.performanceInfo.advance(ae.LASER_LINE),this._renderOccluded(),this.performanceInfo.advance(ae.OCCLUDED);const T=s===D.ON&&this._magnifierHelper.enabled,E=T&&null==e?this.fboCache.acquire(S.RGBA_CLAMPED,a.width,a.height).acquireDepth(y.DEPTH16_BUFFER):null,A=E?.fbo??e;this._rctx.bindFramebuffer(A);const b=this._offscreen.colorTexture;this._renderAntiAliasing(b,A)||null==b||this._compositingHelper.composite(this._bindParameters,b,se.None),this.performanceInfo.advance(ae.ANTIALIASING),this._renderHUD(O.NotOccluded,A),this.performanceInfo.advance(ae.HUD),this._renderHighlights(A,this._bindParameters),this.performanceInfo.advance(ae.HIGHLIGHTS),T&&this._magnifierHelper.render(this._rctx,this._bindParameters),A!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._bindParameters,E?.colorTexture,se.None)),E?.release(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=_,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.finishFrame()}_prepareShaders(e,r){this._renderContext.output=I.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._prepareSlots(k.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,k.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._prepareSlots(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT,k.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),this._offscreen.renderToFBO((()=>this._renderGeometryAndTransparentTerrainPass(I.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=O.NotOccluded,this._renderInternalSlot(k.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===N.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],he.RGBA,oe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(S.RGBA_CLAMPED,this._offscreen.width,this._offscreen.height).acquireDepth(y.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=de.COLOR_BUFFER_BIT|de.DEPTH_BUFFER_BIT|de.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderGeometryAndTransparentTerrainPass(I.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],he.RGBA,oe.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,he.RGBA,oe.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}_prepareSlots(...e){this._renderPlugins.prepareSlots(e)}_renderSlot(e){this._renderPlugins.render(this._renderPlugins.prepare(e))}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(S.RGBA_CLAMPED,s,i),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,ce),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,se.Alpha,1),n.release()}}_renderShadowMap(e,r,t,s){const i=this._shadowMap;i.enabled&&(i.start(r,t,s,this.isFeatureEnabled(V.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(I.ShadowHighlight,this._shadowMap),i.moveSnapshot(z.Highlight),i.clear(),this._renderShadowCascades(I.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(z.Default),this._renderShadowCascades(I.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(I.Shadow),i.finish(),this._rctx.bindFramebuffer(e),r.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._renderGeometryAndTransparentTerrainPass(e)}get _needsLinearDepth(){return this._ssaoHelper.active||this._renderPlugins.needsLinearDepth||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,(()=>this._renderGeometryAndTransparentTerrainPass(I.Depth)),[0,0,0,0]),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=I.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._renderGeometryPass(I.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 H;const r=v(e,this._materialRenderers,this._stage.layers);return x(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.output=e,this._prepareSlots(k.TRANSPARENT_TERRAIN),this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._prepareSlots(k.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderSSAO(e){if(!this._ssaoHelper.active)return;const r=this._offscreen.renderToCachedFBO(null,(()=>this._renderGeometryAndTransparentTerrainPass(I.Normal)),[0,0,0,0]);r.releaseDepth(),this._offscreen.bindFbo(),this._ssaoHelper.render(this._bindParameters,e,r.colorTexture),r.release()}_prepareOpaqueGeometrySlots(){this._prepareSlots(k.INTEGRATED_MESH,k.OPAQUE_TERRAIN,k.OPAQUE_MATERIAL,k.POSTPROCESSING_ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,k.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderSlot(k.INTEGRATED_MESH),this._renderSlot(k.OPAQUE_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(k.TRANSPARENT_MATERIAL),this._renderSlot(k.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){const e=this._renderPlugins.prepare(k.TRANSPARENT_TERRAIN);if(0===e.size)return;const r=()=>this._renderPlugins.render(e);if(this._renderContext.output!==I.Color)return void r();const{width:t,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(S.RGBA_CLAMPED,t,s);return this._offscreen.renderToTargets(r,a,i,[0,0,0,0]),a}_renderHUDVisibility(e){let r=!1;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibility=t.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>r=this._renderInternalSlot(k.OCCLUSION_PIXELS)),e),t.bindFbo(),r||(this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility))}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===O.Occluded){const e=()=>this._renderInternalSlot(k.LINE_CALLOUTS),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderInternalSlot(k.LINE_CALLOUTS)}_renderHUD(e,r){if(this._materialRenderersHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(_e.HUD,e);this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._bindParameters,t.colorTexture,se.PremultipliedAlpha),t.release()}else if(e===O.Occluded){const e=()=>this._renderHUDElements(O.Occluded),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderHUDElements(e)}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,k.LINE_CALLOUTS_HUD_DEPTH,k.HUD_MATERIAL,k.LABEL_MATERIAL),this._renderInternalSlot(k.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(k.HUD_MATERIAL),this._renderInternalSlot(k.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this.hasHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===D.OFF)return;const t=this._offscreen.renderToCachedFBO(null,(()=>{this._renderGeometryAndTransparentTerrainPass(I.Highlight),this._rctx.clearSafe(de.DEPTH_BUFFER_BIT),this._renderHUDElements(O.Both)}),[0,0,0,0],y.DEPTH_STENCIL_TEXTURE);this._needsShadowHighlight&&this._shadowHighlight.render(r,t.fbo.colorTexture,e),t.releaseDepth(),this._highlight.render(this._bindParameters,t.fbo,e),t.release()}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=$.Alpha,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=$.Color,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.FrontFace,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.NONE}_renderOITPass(e,r=O.Both){const t=e===_e.HUD,s=t?this.fboCache.acquire(S.RGBA_CLAMPED,this._offscreen.width,this._offscreen.height):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),a=this._renderContext.output;this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=$.Alpha;const n=this._offscreen.renderOITPass(i,$.Alpha,t);this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=$.Color;const h=this._offscreen.renderOITPass(i,$.Color,t);this._bindParameters.transparencyPassType=$.FrontFace;const o=this._offscreen.renderOITPass(i,$.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=$.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;me.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.renderOccluded===U.OccludeAndTransparentStencil&&(e|=r.material.renderOccluded,me.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(S.RGBA_CLAMPED,h,o);r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,se.PremultipliedAlpha,t),l.release()};0!==me.length&&(this._prepareInternalSlots(me,k.OCCLUDER_MATERIAL,k.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(k.OCCLUDER_MATERIAL,me),t(.5,U.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(k.TRANSPARENT_OCCLUDER_MATERIAL,me)),!1,!1)),me.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.renderOccluded===U.OccludeAndTransparent||r.material.renderOccluded===U.Transparent||r.material.renderOccluded===U.Opaque)&&(e|=r.material.renderOccluded,me.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(me,k.OPAQUE_MATERIAL,k.TRANSPARENT_MATERIAL,k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>U.Occlude&&this._renderSlot(k.OCCLUDED_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL,me),this._renderInternalSlot(k.TRANSPARENT_MATERIAL,me),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,me),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=I.Color,t(.5,U.OccludeAndTransparent,(()=>i(U.OccludeAndTransparent)),!0,L.OutlineVisualElementMask),t(.5,U.Transparent,(()=>i(U.Transparent)),!0,L.OutlineVisualElementMask),t(1,U.Opaque,(()=>i(U.Opaque)),!0,L.OutlineVisualElementMask),me.clear()}_renderAntiAliasing(e,r){if(this._antialiasing){if(this._smaaPass.enable((()=>this._requestRender()))&&null!=e)return this._smaaPass.render(e,r),!0}else this._smaaPass.disable();return!1}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.requiresSlot(k.TRANSPARENT_MATERIAL,I.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:(u(fe,this._bindParameters.camera.viewMatrix),u(ue,this._bindParameters.camera.projectionMatrix),f(ge,fe,ue),f(ge,this._renderContext.lastFrameCamera.viewMatrix,ge),f(ge,this._renderContext.lastFrameCamera.projectionMatrix,ge),this._reprojectionMatrix=ge);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}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>{e.material.shouldRender(this._renderContext)&&e.prepareTechnique(this._renderContext)}))}_renderInternalSlot(e,r=this._materialRenderers){let t=!1;return this._bindParameters.slot=e,r.forAll((e=>{if(e.material.shouldRender(this._renderContext)){const r=e.prepareTechnique(this._renderContext);null!=r&&(e.render(this._renderContext,r),t=!0)}})),t}get gpuMemoryUsage(){return{fbo:(this._offscreen?.gpuMemoryUsage??0)+(this._bindParameters.ssr.lastFrameColor?.memoryUsage??0)+(this._bindParameters.linearDepth?.memoryUsage??0)+(this._bindParameters.hudVisibility?.memoryUsage??0)+this.fboCache.peakMemoryUsage,highlights:this._highlight?.gpuMemoryUsage??0,shadows:this._shadowMap?.gpuMemoryUsage??0,ssao:this._ssaoHelper?.gpuMemoryUsage??0}}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=j()},getFramebufferTexture:r=>{switch(r){case pe.Color:return e._offscreen.colorTexture;case pe.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case pe.ShadowMap:return e._shadowMap.depthTexture;case pe.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var _e,pe;e([p()],le.prototype,"_renderPlugins",void 0),e([p()],le.prototype,"_shadowAccumulator",void 0),e([p()],le.prototype,"_state",void 0),e([p()],le.prototype,"_renderStateFeatures",void 0),e([p()],le.prototype,"_antialiasingEnabled",void 0),e([p({readOnly:!0})],le.prototype,"_antialiasing",null),e([p()],le.prototype,"_ssaoEnabled",void 0),e([p({readOnly:!0})],le.prototype,"fullResolutionAtmosphere",null),e([p()],le.prototype,"_smaaPass",void 0),e([p({autoDestroy:!0})],le.prototype,"_edgeView",void 0),e([p()],le.prototype,"updating",null),e([p()],le.prototype,"isCameraFinal",null),le=e([c("esri.views.3d.webgl-engine.lib.Renderer")],le),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(_e||(_e={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(pe||(pe={}));const ce=[0,0,0,0],me=new h,ue=T(),fe=T(),ge=T();function Te(e){return r=>e.immediate.schedule(r)}export{pe as FramebufferId,le 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 has from"../../../../core/has.js";import{removeMaybe as s,disposeMaybe 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 m}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as c,a as u,m as f}from"../../../../chunks/mat4.js";import{I as g,c as T}from"../../../../chunks/mat4f64.js";import{h as R}from"../../../../chunks/vec4.js";import{a as b}from"../../../../chunks/boundedPlane.js";import E from"../../support/debugFlags.js";import{TransparencyMode as A}from"../../terrain/TerrainRenderer.js";import{FBOCache as P,ColorFormat as S,DepthFormat as y}from"../core/FBOCache.js";import{RenderPassManager as C}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as I}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as O}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{AnimationTimeStep as w}from"./AnimationTimeStep.js";import{Decorations as D,RenderRequestType as M,StencilBits as N}from"./basicInterfaces.js";import{BoundingInfo as H}from"./BoundingInfo.js";import{ZERO as L,union as x}from"./depthRange.js";import{depthRangeFromScene as v}from"./depthRangeUtils.js";import{Highlight as F}from"./Highlight.js";import{RenderOccludedFlag as U}from"./Material.js";import{OffscreenRendering as q}from"./OffscreenRendering.js";import{RenderContext as G}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as B}from"./rendererUtils.js";import{setupFeatureDefaults as j,RenderFeature as V}from"./RenderFeature.js";import{RenderPluginManager as Q}from"./RenderPluginManager.js";import{RenderSlot as k}from"./RenderSlot.js";import{ShadowAccumulator as W}from"./ShadowAccumulator.js";import{ShadowHighlight as Y}from"./ShadowHighlight.js";import{ShadowMap as X,SnapshotSlot as z}from"./ShadowMap.js";import J from"./SliceHelper.js";import{SmaaRenderPass as K}from"./SmaaRenderPass.js";import{SSAOHelper as Z}from"./SSAOHelper.js";import{TransparencyPassType as $}from"./TransparencyPassType.js";import{EdgeView as ee}from"./edgeRendering/EdgeView.js";import{Transparency as re}from"./edgeRendering/interfaces.js";import{MergedRenderer as te}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as se}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{RenderState as ne}from"../../../support/RenderState.js";import{PixelFormat as he,PixelType as oe,ClearBufferBit as de}from"../../../webgl/enums.js";let le=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._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 _antialiasing(){return this._antialiasingEnabled||this.isFeatureEnabled(V.Antialiasing)}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(V.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(V.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.needsHighlight}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(V.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,s,i,a,n,_){super({}),this._stage=e,this._materialRepository=r,this._techniqueRepository=s,this._rctx=i,this._compositingHelper=a,this._magnifierHelper=n,this._requestRender=_,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._fallbackDepthStencilTexture=null,this._sliceHelper=new J,this._state=ne.IDLE,this._antialiasingEnabled=!0,this._highQualityTransparencyEnabled=!0,this._terrainRenderingEnabled=!0,this._terrainTransparency=A.Opaque,this._ssrEnabled=!1,this._ssaoEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new w,this._renderHiddenTransparentEdges=()=>{},this.fboCache=new P(i),this._renderStateFeatures=j(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._smaaPass=new K(this.fboCache,s),_(),this._offscreen=new q(this.fboCache,this._compositingHelper),this.performanceInfo=new ie(this._rctx),this._shadowMap=new X(this.fboCache,e.viewingMode),this._ssaoHelper=new Z(e.view,this.fboCache,s,_),this._highlight=new F(s,this.fboCache),this._shadowHighlight=new Y(this._rctx,e.viewingMode),this._shadowAccumulator=new W(this.fboCache,s,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(I.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),_),this._renderContext=new G(this._rctx,this._offscreen,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new Q({renderContext:this._renderContext,techniqueRepository:s,textureRepository:t,materialRepository:this._materialRepository,requestRender:_,controller:e}),this.renderPassManager=new C(this._rctx,this._techniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this.own([o((()=>this._stage.view.state.camera),(()=>_()),d),o((()=>E.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(re.TRANSPARENT):()=>{},_()}),l),o((()=>this._ssaoEnabled||this.isFeatureEnabled(V.SSAO)),(e=>this._ssaoHelper.enabled=e),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaaPass.dispose(),this._gpuTimerHandle=s(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._fallbackDepthStencilTexture=i(this._fallbackDepthStencilTexture),this._shadowMap.dispose(),this._ssaoHelper.destroy(),this._highlight.dispose(),this._shadowHighlight.dispose(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.destroy(),this._releaseFBOs(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility),this.fboCache.destroy(),H.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._offscreen.dispose(),this._shadowMap.disposeOffscreenBuffers(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing&&this._smaaPass.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 ee({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:Te(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.qualitySettings?.ambientOcclusion&&this._ssaoEnabled!==e.qualitySettings.ambientOcclusion&&(this._ssaoEnabled=e.qualitySettings.ambientOcclusion,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())}e.backgroundColor&&!R(this._offscreen.backgroundColor,e.backgroundColor)&&(this._offscreen.backgroundColor=e.backgroundColor,this._requestRender()),void 0!==e.antialiasingEnabled&&this._antialiasingEnabled!==e.antialiasingEnabled&&(this._antialiasingEnabled=e.antialiasingEnabled,this._requestRender()),void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlight.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlight.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.overlays&&this._bindParameters.overlays!==e.overlays&&(this._bindParameters.overlays=e.overlays,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.renderOverlay&&this._renderOverlay!==e.renderOverlay&&(this._renderOverlay=e.renderOverlay,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainRenderingEnabled&&this._terrainRenderingEnabled!==e.terrainRenderingEnabled&&(this._terrainRenderingEnabled=e.terrainRenderingEnabled,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=B(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));null==i&&t.adds.length>0&&(i=new te(this._rctx,this._materialRepository,s),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.requiresSlot(k.LINE_CALLOUTS_HUD_DEPTH,I.Color)||e.requiresSlot(k.HUD_MATERIAL,I.Color)||e.requiresSlot(k.LABEL_MATERIAL,I.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?s(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.fboCache.resetPeakMemoryUsage();const a=this._offscreen,{camera:h,contentCamera:o,mode:d,alignPixelEnabled:l}=t;this._state=d,this._renderOverlay(i),this.performanceInfo.advance(ae.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=$.NONE,this._bindParameters.alignPixelEnabled=l,this._bindParameters.decorations=s,this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this.hasReflections?this._bindParameters.ssr.lastFrameColor=a.swapColorBuffer():a.swapColorBuffer().release();const _=b(this._sliceHelper.plane);s===D.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),h.setGLViewport(this._rctx),this._prepare(h,o),this._renderPlugins.prepareRender(),this.performanceInfo.advance(ae.PREPARE);const p=this._computeDepthRange(h);this._renderShadowMap(e,h,this._bindParameters.lighting.mainLight.direction,p),this.performanceInfo.advance(ae.SHADOW_MAP),a.initializeFrame(h),this._ensureBindParameters(h,o);const m=this._terrainRenderingEnabled&&(this._terrainTransparency===A.Semitransparent||this._terrainTransparency===A.TransparentWithDraped),c=this._highQualityTransparency&&m,u=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;this._prepareShaders(c,u),this._renderLinearDepth(),this.performanceInfo.advance(ae.LINEAR_DEPTH),this._accumulateShadows(p,h,o),this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(i),this.performanceInfo.advance(ae.SSAO),this._renderContext.output=I.Color,a.bindFbo(),this._renderOpaqueGeometry(),this.performanceInfo.advance(ae.OPAQUE),this._renderTerrainLinearDepth(c),this._setMultipassTerrain(c),this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),a.bindFbo(),this._renderSlot(k.VOXEL),this.performanceInfo.advance(ae.VOXEL),this._renderHiddenTransparentEdges(),u&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT);const f=this._renderGeometryLinearDepth(c);this._renderHUDVisibility(f),c||this._renderInternalSlot(k.LINE_CALLOUTS),this.performanceInfo.advance(ae.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(re.TRANSPARENT,f),f?.release(),this.performanceInfo.advance(ae.TRANSPARENT_EDGES);const g=m?this._renderTransparentTerrain():null;if(g&&this._bindParameters.hudVisibility&&(c?this._renderLineCallouts(O.Occluded):a.compositeToHUDVisibility(this._bindParameters,g.colorTexture),this._renderHUD(O.Occluded,a.framebuffer),this.performanceInfo.advance(ae.HUD_OCCLUDED)),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),g&&(a.compositeToFramebuffer(this._bindParameters,g.colorTexture,se.PremultipliedAlpha,1),g.release(),c&&(this._renderEdges(re.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),u&&(this._oitEnabled?this._renderOITPass(_e.Geometry):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT),this._renderEdges(re.TRANSPARENT),this.performanceInfo.advance(ae.TRANSPARENT_EDGES))),c&&this._renderLineCallouts(O.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),a.bindFbo(),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(k.LASERLINES),this.performanceInfo.advance(ae.ENVIRONMENT),this._renderPlugins.needsLaserlineWithContrastControl){const e=()=>this._renderSlot(k.LASERLINES_CONTRAST_CONTROL),{width:r,height:t,depth:s}=a,i=this.fboCache.acquire(S.RGBA,r,t);a.renderToTargets(e,i,s,me),a.compositeToFramebuffer(this._bindParameters,i.colorTexture,se.PremultipliedAlpha,1),i.release()}this.performanceInfo.advance(ae.LASER_LINE),this._renderOccluded(),this.performanceInfo.advance(ae.OCCLUDED);const T=s===D.ON&&this._magnifierHelper.enabled,R=T&&null==e?this.fboCache.acquire(S.RGBA,a.width,a.height).acquireDepth(y.DEPTH16_BUFFER):null,E=R?.fbo??e;this._rctx.bindFramebuffer(E);const P=this._offscreen.colorTexture;this._renderAntiAliasing(P,E)||null==P||this._compositingHelper.composite(this._bindParameters,P,se.None),this.performanceInfo.advance(ae.ANTIALIASING),this._renderHUD(O.NotOccluded,E),this.performanceInfo.advance(ae.HUD),this._renderHighlights(E,this._bindParameters),this.performanceInfo.advance(ae.HIGHLIGHTS),T&&this._magnifierHelper.render(this._rctx,this._bindParameters),E!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._bindParameters,R?.colorTexture,se.None)),R?.release(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=_,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.finishFrame()}_prepareShaders(e,r){this._renderContext.output=I.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._prepareSlots(k.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,k.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._prepareSlots(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT,k.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),this._offscreen.renderToFBO((()=>this._renderGeometryAndTransparentTerrainPass(I.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=O.NotOccluded,this._renderInternalSlot(k.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===M.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],he.RGBA,oe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(S.RGBA,this._offscreen.width,this._offscreen.height).acquireDepth(y.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=de.COLOR_BUFFER_BIT|de.DEPTH_BUFFER_BIT|de.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderGeometryAndTransparentTerrainPass(I.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],he.RGBA,oe.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,he.RGBA,oe.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}_prepareSlots(...e){this._renderPlugins.prepareSlots(e)}_renderSlot(e){this._renderPlugins.render(this._renderPlugins.prepare(e))}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(S.RGBA,s,i),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,me),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,se.Alpha,1),n.release()}}_renderShadowMap(e,r,t,s){const i=this._shadowMap;i.enabled&&(i.start(r,t,s,this.isFeatureEnabled(V.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(I.ShadowHighlight,this._shadowMap),i.moveSnapshot(z.Highlight),i.clear(),this._renderShadowCascades(I.ShadowExcludeHighlight,this._shadowMap),i.copySnapshot(z.Default),this._renderShadowCascades(I.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(I.Shadow),i.finish(),this._rctx.bindFramebuffer(e),r.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._renderGeometryAndTransparentTerrainPass(e)}get _needsLinearDepth(){return this._ssaoHelper.active||this._renderPlugins.needsLinearDepth||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,(()=>this._renderGeometryAndTransparentTerrainPass(I.Depth)),[0,0,0,0]),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=I.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._renderGeometryPass(I.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 L;const r=v(e,this._materialRenderers,this._stage.layers);return x(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.output=e,this._prepareSlots(k.TRANSPARENT_TERRAIN),this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._prepareSlots(k.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderSSAO(e){if(!this._ssaoHelper.active)return;const r=this._offscreen.renderToCachedFBO(null,(()=>this._renderGeometryAndTransparentTerrainPass(I.Normal)),[0,0,0,0],S.RGBA4);r.releaseDepth(),this._offscreen.bindFbo(),this._ssaoHelper.render(this._bindParameters,e,r.colorTexture),r.release()}_prepareOpaqueGeometrySlots(){this._prepareSlots(k.INTEGRATED_MESH,k.OPAQUE_TERRAIN,k.OPAQUE_MATERIAL,k.POSTPROCESSING_ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,k.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderSlot(k.INTEGRATED_MESH),this._renderSlot(k.OPAQUE_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(k.TRANSPARENT_MATERIAL),this._renderSlot(k.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){const e=this._renderPlugins.prepare(k.TRANSPARENT_TERRAIN);if(0===e.size)return;const r=()=>this._renderPlugins.render(e);if(this._renderContext.output!==I.Color)return void r();const{width:t,height:s,depth:i}=this._offscreen,a=this.fboCache.acquire(S.RGBA,t,s);return this._offscreen.renderToTargets(r,a,i,[0,0,0,0]),a}_renderHUDVisibility(e){let r=!1;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibility=t.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>r=this._renderInternalSlot(k.OCCLUSION_PIXELS)),e),t.bindFbo(),r||(this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility))}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===O.Occluded){const e=()=>this._renderInternalSlot(k.LINE_CALLOUTS),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderInternalSlot(k.LINE_CALLOUTS)}_renderHUD(e,r){if(this._materialRenderersHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(_e.HUD,e);this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._bindParameters,t.colorTexture,se.PremultipliedAlpha),t.release()}else if(e===O.Occluded){const e=()=>this._renderHUDElements(O.Occluded),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(y.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderHUDElements(e)}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,k.LINE_CALLOUTS_HUD_DEPTH,k.HUD_MATERIAL,k.LABEL_MATERIAL),this._renderInternalSlot(k.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(k.HUD_MATERIAL),this._renderInternalSlot(k.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this.hasHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===D.OFF)return;const t=()=>{this._renderGeometryAndTransparentTerrainPass(I.Highlight),this._rctx.clearSafe(de.DEPTH_BUFFER_BIT),this._renderHUDElements(O.Both)},s=this._offscreen.renderToCachedFBO(null,t,[0,0,0,0],S.RGBA4,y.DEPTH_STENCIL_TEXTURE);this._needsShadowHighlight&&this._shadowHighlight.render(r,s.fbo.colorTexture,e),s.releaseDepth(),this._highlight.render(this._bindParameters,s.fbo,e),s.release()}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=$.Alpha,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=$.Color,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.FrontFace,this._prepareInternalSlots(this._materialRenderers,k.TRANSPARENT_MATERIAL),this._prepareSlots(k.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=$.NONE}_renderOITPass(e,r=O.Both){const t=e===_e.HUD,s=t?this.fboCache.acquire(S.RGBA,this._offscreen.width,this._offscreen.height):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentGeometry(),a=this._renderContext.output;this._renderContext.output=I.Alpha,this._bindParameters.transparencyPassType=$.Alpha;const n=this._offscreen.renderOITPass(i,$.Alpha,t);this._renderContext.output=I.Color,this._bindParameters.transparencyPassType=$.Color;const h=this._offscreen.renderOITPass(i,$.Color,t);this._bindParameters.transparencyPassType=$.FrontFace;const o=this._offscreen.renderOITPass(i,$.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=$.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;ce.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.renderOccluded===U.OccludeAndTransparentStencil&&(e|=r.material.renderOccluded,ce.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(S.RGBA,h,o);r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,se.PremultipliedAlpha,t),l.release()};0!==ce.length&&(this._prepareInternalSlots(ce,k.OCCLUDER_MATERIAL,k.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(k.OCCLUDER_MATERIAL,ce),t(.5,U.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(k.TRANSPARENT_OCCLUDER_MATERIAL,ce)),!1,!1)),ce.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.renderOccluded===U.OccludeAndTransparent||r.material.renderOccluded===U.Transparent||r.material.renderOccluded===U.Opaque)&&(e|=r.material.renderOccluded,ce.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(ce,k.OPAQUE_MATERIAL,k.TRANSPARENT_MATERIAL,k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>U.Occlude&&this._renderSlot(k.OCCLUDED_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL,ce),this._renderInternalSlot(k.TRANSPARENT_MATERIAL,ce),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,ce),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=I.Color,t(.5,U.OccludeAndTransparent,(()=>i(U.OccludeAndTransparent)),!0,N.OutlineVisualElementMask),t(.5,U.Transparent,(()=>i(U.Transparent)),!0,N.OutlineVisualElementMask),t(1,U.Opaque,(()=>i(U.Opaque)),!0,N.OutlineVisualElementMask),ce.clear()}_renderAntiAliasing(e,r){if(this._antialiasing){if(this._smaaPass.enable((()=>this._requestRender()))&&null!=e)return this._smaaPass.render(e,r),!0}else this._smaaPass.disable();return!1}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.requiresSlot(k.TRANSPARENT_MATERIAL,I.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:(u(fe,this._bindParameters.camera.viewMatrix),u(ue,this._bindParameters.camera.projectionMatrix),f(ge,fe,ue),f(ge,this._renderContext.lastFrameCamera.viewMatrix,ge),f(ge,this._renderContext.lastFrameCamera.projectionMatrix,ge),this._reprojectionMatrix=ge);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}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>{e.material.shouldRender(this._renderContext)&&e.prepareTechnique(this._renderContext)}))}_renderInternalSlot(e,r=this._materialRenderers){let t=!1;return this._bindParameters.slot=e,r.forAll((e=>{if(e.material.shouldRender(this._renderContext)){const r=e.prepareTechnique(this._renderContext);null!=r&&(e.render(this._renderContext,r),t=!0)}})),t}get memoryInfo(){return{fbo:(this._offscreen?.gpuMemoryUsage??0)+(this._bindParameters.ssr.lastFrameColor?.memoryUsage??0)+(this._bindParameters.linearDepth?.memoryUsage??0)+(this._bindParameters.hudVisibility?.memoryUsage??0)+this.fboCache.peakMemoryUsage,highlights:this._highlight?.gpuMemoryUsage??0,shadows:this._shadowMap?.gpuMemoryUsage??0,ssao:this._ssaoHelper?.gpuMemoryUsage??0}}get usedMemory(){return this.fboCache.peakMemoryUsage+(this._offscreen?.gpuMemoryUsage??0)+(this._bindParameters.linearDepth?.memoryUsage??0)+(this._bindParameters.hudVisibility?.memoryUsage??0)+(this._highlight?.gpuMemoryUsage??0)+(this._shadowMap?.gpuMemoryUsage??0)+(this._ssaoHelper?.gpuMemoryUsage??0)+(this.edgeView?.usedMemory??0)+this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0)}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=j()},getFramebufferTexture:r=>{switch(r){case pe.Color:return e._offscreen.colorTexture;case pe.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case pe.ShadowMap:return e._shadowMap.depthTexture;case pe.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var _e,pe;e([p()],le.prototype,"_renderPlugins",void 0),e([p()],le.prototype,"_shadowAccumulator",void 0),e([p()],le.prototype,"_state",void 0),e([p()],le.prototype,"_renderStateFeatures",void 0),e([p()],le.prototype,"_antialiasingEnabled",void 0),e([p({readOnly:!0})],le.prototype,"_antialiasing",null),e([p()],le.prototype,"_ssaoEnabled",void 0),e([p({readOnly:!0})],le.prototype,"fullResolutionAtmosphere",null),e([p()],le.prototype,"_smaaPass",void 0),e([p({autoDestroy:!0})],le.prototype,"_edgeView",void 0),e([p()],le.prototype,"updating",null),e([p()],le.prototype,"isCameraFinal",null),le=e([m("esri.views.3d.webgl-engine.lib.Renderer")],le),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(_e||(_e={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(pe||(pe={}));const me=[0,0,0,0],ce=new h,ue=T(),fe=T(),ge=T();function Te(e){return r=>e.immediate.schedule(r)}export{pe as FramebufferId,le 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{disposeMaybe as e,releaseMaybe as s}from"../../../../core/maybe.js";import{Milliseconds as t}from"../../../../core/time.js";import{s as r}from"../../../../chunks/vec2.js";import{ColorFormat as i}from"../core/FBOCache.js";import{createQuadVAO as a}from"./glUtil3D.js";import{SSAOBlurTechnique as o}from"./SSAOBlurTechnique.js";import{noiseData as h}from"./SSAONoiseData.js";import{SSAOTechnique as n}from"./SSAOTechnique.js";import{g as u}from"../../../../chunks/SSAO.glsl.js";import{SSAOPassParameters as _,BlurDrawParameters as l}from"../shaders/SSAOParameters.js";import{PrimitiveType as m,ClearBufferBit as c,TextureWrapMode as d,PixelFormat as p}from"../../../webgl/enums.js";import{Texture as b}from"../../../webgl/Texture.js";import{TextureDescriptor as T}from"../../../webgl/TextureDescriptor.js";import{vertexCount as f}from"../../../webgl/Util.js";const w=2;class q{constructor(e,s,t,r){this._view=e,this._fbos=s,this._techniques=t,this._requestRender=r,this._quadVAO=null,this._passParameters=new _,this._drawParameters=new l}dispose(){this.enabled=!1,this._quadVAO=e(this._quadVAO)}destroy(){this.dispose()}disposeOffscreenBuffers(){this._ssaoFBO=s(this._ssaoFBO)}set enabled(e){e?this._enable():this._disable()}get enabled(){return null!=this._enableTime}get active(){return this.enabled&&this._ssaoTechnique.compiled&&this._blurTechnique.compiled}get colorTexture(){return this._ssaoFBO?.colorTexture}render(e,t,o){if(null==this._enableTime||null==e.linearDepth?.colorTexture||null==o)return;if(!this.active)return this._enableTime=t,void this._requestRender();0===this._enableTime&&(this._enableTime=t),this._ssaoFBO=s(this._ssaoFBO);const h=this._fbos.rctx,n=e.camera,_=this._view.qualitySettings.fadeDuration,l=_>0?Math.min(_,t-this._enableTime)/_:1;this._passParameters.normalTexture=o,this._passParameters.depthTexture=e.linearDepth?.colorTexture,this._passParameters.projScale=1/n.computeRenderPixelSizeAtDist(1),this._passParameters.intensity=4*P/u(n)**6*l;const d=n.fullViewport,p=d[2],b=d[3],T=p/w,q=b/w,A=this._fbos.acquire(i.RGBA_CLAMPED,p,b);null==this._quadVAO&&(this._quadVAO=a(this._fbos.rctx)),h.bindFramebuffer(A.fbo),h.setViewport(0,0,p,b);h.bindTechnique(this._ssaoTechnique,this._passParameters,e).bindDraw(this._drawParameters,e,this._passParameters),h.bindVAO(this._quadVAO);const O=f(this._quadVAO,"geometry");h.drawArrays(m.TRIANGLE_STRIP,0,O);const x=h.bindTechnique(this._blurTechnique,this._passParameters,e);h.setViewport(0,0,T,q);const B=this._fbos.acquire(i.RGBA_CLAMPED,T,q);h.bindFramebuffer(B.fbo),this._drawParameters.colorTexture=A.colorTexture,r(this._drawParameters.blurSize,0,w/b),x.bindDraw(this._drawParameters,e,this._passParameters),h.setViewport(0,0,T,q),h.drawArrays(m.TRIANGLE_STRIP,0,O),A.release(),this._ssaoFBO=this._fbos.acquire(i.RGBA_CLAMPED,T,q),h.bindFramebuffer(this._ssaoFBO.fbo),h.setViewport(0,0,p,b),h.setClearColor(1,1,1,0),h.clear(c.COLOR_BUFFER_BIT),h.setViewport(0,0,T,q),this._drawParameters.colorTexture=B.colorTexture,r(this._drawParameters.blurSize,w/p,0),x.bindDraw(this._drawParameters,e,this._passParameters),h.drawArrays(m.TRIANGLE_STRIP,0,O),h.setViewport(d[0],d[1],d[2],d[3]),B.release(),l<1&&this._requestRender()}_enable(){if(null!=this._enableTime)return;const e=Uint8Array.from(atob(h),(e=>e.charCodeAt(0))),s=new T;s.wrapMode=d.CLAMP_TO_EDGE,s.pixelFormat=p.RGB,s.wrapMode=d.REPEAT,s.hasMipmap=!0,s.width=32,s.height=32,this._passParameters.noiseTexture=new b(this._fbos.rctx,s,e),null==this._ssaoTechnique&&(this._ssaoTechnique=this._techniques.acquire(n)),null==this._blurTechnique&&(this._blurTechnique=this._techniques.acquire(o)),this._enableTime=t(0),this._requestRender()}_disable(){this._enableTime=null,this._passParameters.noiseTexture=e(this._passParameters.noiseTexture),this._ssaoFBO=s(this._ssaoFBO)}get gpuMemoryUsage(){return this._ssaoFBO?.fbo.gpuMemoryUsage??0}}const P=.5;export{q as SSAOHelper,w as blurSizePixels};
5
+ import{disposeMaybe as e,releaseMaybe as s}from"../../../../core/maybe.js";import{Milliseconds as t}from"../../../../core/time.js";import{s as r}from"../../../../chunks/vec2.js";import{ColorFormat as i}from"../core/FBOCache.js";import{createQuadVAO as a}from"./glUtil3D.js";import{SSAOBlurTechnique as o}from"./SSAOBlurTechnique.js";import{noiseData as h}from"./SSAONoiseData.js";import{SSAOTechnique as n}from"./SSAOTechnique.js";import{g as u}from"../../../../chunks/SSAO.glsl.js";import{SSAOPassParameters as _,BlurDrawParameters as l}from"../shaders/SSAOParameters.js";import{PrimitiveType as m,ClearBufferBit as c,TextureWrapMode as d,PixelFormat as p}from"../../../webgl/enums.js";import{Texture as b}from"../../../webgl/Texture.js";import{TextureDescriptor as T}from"../../../webgl/TextureDescriptor.js";import{vertexCount as f}from"../../../webgl/Util.js";const w=2;class q{constructor(e,s,t,r){this._view=e,this._fbos=s,this._techniques=t,this._requestRender=r,this._quadVAO=null,this._passParameters=new _,this._drawParameters=new l}dispose(){this.enabled=!1,this._quadVAO=e(this._quadVAO)}destroy(){this.dispose()}disposeOffscreenBuffers(){this._ssaoFBO=s(this._ssaoFBO)}set enabled(e){e?this._enable():this._disable()}get enabled(){return null!=this._enableTime}get active(){return this.enabled&&this._ssaoTechnique.compiled&&this._blurTechnique.compiled}get colorTexture(){return this._ssaoFBO?.colorTexture}render(e,t,o){if(null==this._enableTime||null==e.linearDepth?.colorTexture||null==o)return;if(!this.active)return this._enableTime=t,void this._requestRender();0===this._enableTime&&(this._enableTime=t),this._ssaoFBO=s(this._ssaoFBO);const h=this._fbos.rctx,n=e.camera,_=this._view.qualitySettings.fadeDuration,l=_>0?Math.min(_,t-this._enableTime)/_:1;this._passParameters.normalTexture=o,this._passParameters.depthTexture=e.linearDepth?.colorTexture,this._passParameters.projScale=1/n.computeRenderPixelSizeAtDist(1),this._passParameters.intensity=4*O/u(n)**6*l;const d=n.fullViewport,p=d[2],b=d[3],T=p/w,q=b/w,P=this._fbos.acquire(i.RGBA,p,b);null==this._quadVAO&&(this._quadVAO=a(this._fbos.rctx)),h.bindFramebuffer(P.fbo),h.setViewport(0,0,p,b);h.bindTechnique(this._ssaoTechnique,this._passParameters,e).bindDraw(this._drawParameters,e,this._passParameters),h.bindVAO(this._quadVAO);const A=f(this._quadVAO,"geometry");h.drawArrays(m.TRIANGLE_STRIP,0,A);const x=h.bindTechnique(this._blurTechnique,this._passParameters,e);h.setViewport(0,0,T,q);const B=this._fbos.acquire(i.RGBA,T,q);h.bindFramebuffer(B.fbo),this._drawParameters.colorTexture=P.colorTexture,r(this._drawParameters.blurSize,0,w/b),x.bindDraw(this._drawParameters,e,this._passParameters),h.setViewport(0,0,T,q),h.drawArrays(m.TRIANGLE_STRIP,0,A),P.release(),this._ssaoFBO=this._fbos.acquire(i.RGBA,T,q),h.bindFramebuffer(this._ssaoFBO.fbo),h.setViewport(0,0,p,b),h.setClearColor(1,1,1,0),h.clear(c.COLOR_BUFFER_BIT),h.setViewport(0,0,T,q),this._drawParameters.colorTexture=B.colorTexture,r(this._drawParameters.blurSize,w/p,0),x.bindDraw(this._drawParameters,e,this._passParameters),h.drawArrays(m.TRIANGLE_STRIP,0,A),h.setViewport(d[0],d[1],d[2],d[3]),B.release(),l<1&&this._requestRender()}_enable(){if(null!=this._enableTime)return;const e=Uint8Array.from(atob(h),(e=>e.charCodeAt(0))),s=new T;s.wrapMode=d.CLAMP_TO_EDGE,s.pixelFormat=p.RGB,s.wrapMode=d.REPEAT,s.hasMipmap=!0,s.width=32,s.height=32,this._passParameters.noiseTexture=new b(this._fbos.rctx,s,e),null==this._ssaoTechnique&&(this._ssaoTechnique=this._techniques.acquire(n)),null==this._blurTechnique&&(this._blurTechnique=this._techniques.acquire(o)),this._enableTime=t(0),this._requestRender()}_disable(){this._enableTime=null,this._passParameters.noiseTexture=e(this._passParameters.noiseTexture),this._ssaoFBO=s(this._ssaoFBO)}get gpuMemoryUsage(){return this._ssaoFBO?.fbo.gpuMemoryUsage??0}}const O=.5;export{q as SSAOHelper,w as blurSizePixels};
@@ -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{abortMaybe as s,disposeMaybe as t}from"../../../../core/maybe.js";import{throwIfAborted as i,isAborted as o}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as h}from"../../../../support/requestImageUtils.js";import{ColorFormat as l}from"../core/FBOCache.js";import{ShaderTechniqueConfiguration as u}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{BlendWeightsTechnique as c}from"./BlendWeightsTechnique.js";import{BlurTechnique as _}from"./BlurTechnique.js";import{EdgeDetectTechnique as m}from"./EdgeDetectTechnique.js";import{createScreenSizeTriangleVAO as d}from"./glUtil3D.js";import{SMAAPassParameters as p}from"../shaders/SMAAPassParameters.js";import{TextureSamplingMode as b,PixelFormat as T,ClearBufferBit as f,PrimitiveType as q,TextureWrapMode as g}from"../../../webgl/enums.js";import{Texture as x}from"../../../webgl/Texture.js";import{TextureDescriptor as A}from"../../../webgl/TextureDescriptor.js";let C=class extends r{constructor(e,r){super({}),this._fbos=e,this._techniques=r,this._passParameters=new p,this._isEnabled=!1}normalizeCtorArgs(){return{}}dispose(){this._abortController=s(this._abortController),this.disable()}_loadResources(e){if(this._abortController)return!1;if(this._passParameters.searchTexture)return!0;this._abortController=new AbortController;const r=this._abortController.signal;return import("./SmaaRenderPassData.js").then((e=>this._loadTextures(e,r))).then((()=>e())).finally((()=>this._abortController=null)),!1}_loadTextures(e,r){return i(r),Promise.all([this._loadTextureFromBase64(e.areaTexture,b.LINEAR,T.RGB),this._loadTextureFromBase64(e.searchTexure,b.NEAREST,T.LUMINANCE)]).then((([e,s])=>{o(r)?(e.dispose(),s.dispose(),i(r)):(this._passParameters.areaTexture=e,this._passParameters.searchTexture=s)}))}get updating(){return null!=this._abortController}enable(e){if(this._isEnabled)return!0;if(!this._edgeDetectTechnique||!this._blendWeightsTechnique||!this._blurTechnique){const e=new u;this._edgeDetectTechnique=this._techniques.releaseAndAcquire(m,e,this._edgeDetectTechnique),this._blendWeightsTechnique=this._techniques.releaseAndAcquire(c,e,this._blendWeightsTechnique),this._blurTechnique=this._techniques.releaseAndAcquire(_,e,this._blurTechnique)}return!!this._loadResources(e)&&(this._vao=d(this._fbos.rctx),this._isEnabled=!0,!0)}disable(){this._isEnabled&&(this._vao=t(this._vao),this._passParameters.areaTexture=t(this._passParameters.areaTexture),this._passParameters.searchTexture=t(this._passParameters.searchTexture),this._isEnabled=!1)}render(e,r){const s=e.descriptor.width,t=e.descriptor.height;if(!this._isEnabled)return;const i=this._passParameters;i.color=e;const o=this._fbos.rctx;o.bindVAO(this._vao),o.setViewport(0,0,s,t);const a=this._fbos.acquire(l.RG_CLAMPED,s,t);o.bindFramebuffer(a.fbo),o.setClearColor(0,0,0,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._edgeDetectTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3);const n=this._fbos.acquire(l.RGBA_CLAMPED,s,t);o.bindFramebuffer(n.fbo),i.inputTexture=a.colorTexture,o.setClearColor(0,0,1,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._blendWeightsTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3),o.bindFramebuffer(r),i.inputTexture=n.colorTexture,a.release(),o.setClearColor(0,1,0,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._blurTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3),n.release()}_loadTextureFromBase64(e,r,s){return h(e).then((e=>{const t=new A;return t.pixelFormat=s,t.wrapMode=g.CLAMP_TO_EDGE,t.width=e.width,t.height=e.height,t.samplingMode=r,new x(this._fbos.rctx,t,e)}))}};e([a()],C.prototype,"_abortController",void 0),e([a({readOnly:!0})],C.prototype,"updating",null),C=e([n("esri.views.3d.webgl-engine.lib.SmaaRenderPass")],C);export{C as SmaaRenderPass};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{abortMaybe as s,disposeMaybe as t}from"../../../../core/maybe.js";import{throwIfAborted as i,isAborted as o}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as h}from"../../../../support/requestImageUtils.js";import{ColorFormat as l}from"../core/FBOCache.js";import{ShaderTechniqueConfiguration as u}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{BlendWeightsTechnique as c}from"./BlendWeightsTechnique.js";import{BlurTechnique as _}from"./BlurTechnique.js";import{EdgeDetectTechnique as m}from"./EdgeDetectTechnique.js";import{createScreenSizeTriangleVAO as d}from"./glUtil3D.js";import{SMAAPassParameters as p}from"../shaders/SMAAPassParameters.js";import{TextureSamplingMode as b,PixelFormat as T,ClearBufferBit as f,PrimitiveType as q,TextureWrapMode as g}from"../../../webgl/enums.js";import{Texture as x}from"../../../webgl/Texture.js";import{TextureDescriptor as A}from"../../../webgl/TextureDescriptor.js";let C=class extends r{constructor(e,r){super({}),this._fbos=e,this._techniques=r,this._passParameters=new p,this._isEnabled=!1}normalizeCtorArgs(){return{}}dispose(){this._abortController=s(this._abortController),this.disable()}_loadResources(e){if(this._abortController)return!1;if(this._passParameters.searchTexture)return!0;this._abortController=new AbortController;const r=this._abortController.signal;return import("./SmaaRenderPassData.js").then((e=>this._loadTextures(e,r))).then((()=>e())).finally((()=>this._abortController=null)),!1}_loadTextures(e,r){return i(r),Promise.all([this._loadTextureFromBase64(e.areaTexture,b.LINEAR,T.RGB),this._loadTextureFromBase64(e.searchTexure,b.NEAREST,T.LUMINANCE)]).then((([e,s])=>{o(r)?(e.dispose(),s.dispose(),i(r)):(this._passParameters.areaTexture=e,this._passParameters.searchTexture=s)}))}get updating(){return null!=this._abortController}enable(e){if(this._isEnabled)return!0;if(!this._edgeDetectTechnique||!this._blendWeightsTechnique||!this._blurTechnique){const e=new u;this._edgeDetectTechnique=this._techniques.releaseAndAcquire(m,e,this._edgeDetectTechnique),this._blendWeightsTechnique=this._techniques.releaseAndAcquire(c,e,this._blendWeightsTechnique),this._blurTechnique=this._techniques.releaseAndAcquire(_,e,this._blurTechnique)}return!!this._loadResources(e)&&(this._vao=d(this._fbos.rctx),this._isEnabled=!0,!0)}disable(){this._isEnabled&&(this._vao=t(this._vao),this._passParameters.areaTexture=t(this._passParameters.areaTexture),this._passParameters.searchTexture=t(this._passParameters.searchTexture),this._isEnabled=!1)}render(e,r){const s=e.descriptor.width,t=e.descriptor.height;if(!this._isEnabled)return;const i=this._passParameters;i.color=e;const o=this._fbos.rctx;o.bindVAO(this._vao),o.setViewport(0,0,s,t);const a=this._fbos.acquire(l.RG,s,t);o.bindFramebuffer(a.fbo),o.setClearColor(0,0,0,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._edgeDetectTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3);const n=this._fbos.acquire(l.RGBA,s,t);o.bindFramebuffer(n.fbo),i.inputTexture=a.colorTexture,o.setClearColor(0,0,1,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._blendWeightsTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3),o.bindFramebuffer(r),i.inputTexture=n.colorTexture,a.release(),o.setClearColor(0,1,0,1),o.clear(f.COLOR_BUFFER_BIT),o.bindTechnique(this._blurTechnique,i,null),o.drawArrays(q.TRIANGLES,0,3),n.release()}_loadTextureFromBase64(e,r,s){return h(e).then((e=>{const t=new A;return t.pixelFormat=s,t.wrapMode=g.CLAMP_TO_EDGE,t.width=e.width,t.height=e.height,t.samplingMode=r,new x(this._fbos.rctx,t,e)}))}};e([a()],C.prototype,"_abortController",void 0),e([a({readOnly:!0})],C.prototype,"updating",null),C=e([n("esri.views.3d.webgl-engine.lib.SmaaRenderPass")],C);export{C as SmaaRenderPass};
@@ -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{someMap as t}from"../../../../core/MapUtils.js";import s from"../../../../core/PooledArray.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{a}from"../../../../chunks/vec2f64.js";import{OverlayTarget as o}from"../../terrain/Intersector.js";import{ChangeSet as d}from"./ChangeSet.js";import{newIntersectorResult as h}from"./Intersector.js";import{StoreResults as l,IntersectorType as c}from"./IntersectorInterfaces.js";import{DirtyOperation as p,DirtyState as m}from"./ModelDirtyTypes.js";import{splitRenderGeometryChangeSetByMaterial as g}from"./rendererUtils.js";import{MergedRenderer as u}from"../materials/renderers/MergedRenderer.js";let _=class extends r{constructor(e){super(e),this._pending=new y,this._changes=new d,this._materialRenderers=new Map,this._sortedMaterialRenderers=new s,this._geometries=new Map,this._hasHighlights=!1,this._hasWater=!1}destroy(){this._changes.prune(),this._materialRenderers.forEach((e=>e.dispose())),this._materialRenderers.clear(),this._sortedMaterialRenderers.clear(),this._geometries.clear(),this._pending.clear()}get updating(){return!this._pending.empty||this._changes.updates.length>0}get rctx(){return this.rendererContext.rctx}get _materialRepository(){return this.rendererContext.materialRepository}get _localOriginFactory(){return this.rendererContext.localOriginFactory}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccluded(){return t(this._materialRenderers,(e=>e.rendersOccluded))}get isEmpty(){return!this.updating&&0===this._materialRenderers.size&&0===this._geometries.size}commitChanges(){if(!this.updating)return!1;this._processAddsRemoves();const e=g(this._changes);let r=!1,s=!1,i=!1;return e.forEach(((e,t)=>{let n=this._materialRenderers.get(t);if(!n&&e.adds.length>0&&(n=new u(this.rctx,this._materialRepository,t),this._materialRenderers.set(t,n),r=!0,s=!0,i=!0),!n)return;const a=s||n.hasHighlights,o=i||n.hasWater;n.modify(e),s=s||a!==n.hasHighlights,i=i||o!==n.hasWater,n.isEmpty&&(this._materialRenderers.delete(t),n.dispose(),r=!0)})),this._changes.clear(),r&&this._updateSortedMaterialRenderers(),s&&(this._hasHighlights=t(this._materialRenderers,(e=>e.hasHighlights))),i&&(this._hasWater=t(this._materialRenderers,(e=>e.hasWater))),this.notifyChange("updating"),!0}addGeometries(e,r){if(0===e.length)return;const t=this._validateRenderGeometries(e);for(const i of t)this._geometries.set(i.id,i);const s=this._pending.empty;for(const i of t)this._pending.adds.add(i);s&&this.notifyChange("updating"),r===p.UPDATE&&this._notifyGraphicGeometryChanged(e)}removeGeometries(e,r){const t=this._pending.empty,s=this._pending.adds;for(const i of e)s.has(i)?(this._pending.removed.add(i),s.delete(i)):this._pending.removed.has(i)||this._pending.removes.add(i),this._geometries.delete(i.id);t&&!this._pending.empty&&this.notifyChange("updating"),r===p.UPDATE&&this._notifyGraphicGeometryChanged(e)}modifyGeometries(e,r){const t=0===this._changes.updates.length;for(const s of e){const e=this._changes.updates.pushNew();e.renderGeometry=this._validateRenderGeometry(s),e.updateType=r}switch(t&&this._changes.updates.length>0&&this.notifyChange("updating"),r){case m.TRANSFORMATION:case m.GEOMETRY:return this._notifyGraphicGeometryChanged(e);case m.VISIBILITY:return this._notifyGraphicVisibilityChanged(e)}}updateAnimation(e){let r=!1;return this._sortedMaterialRenderers.forAll((t=>r=t.updateAnimation(e)||r)),r}render(e){this._sortedMaterialRenderers.forAll((r=>{if(r.material.shouldRender(e)){const t=r.prepareTechnique(e);null!=t&&r.render(e,t)}}))}intersect(e,r,t,s,i){return this._geometries.forEach((n=>{if(s&&!s(n))return;this._intersectRenderGeometry(n,t,r,0,e,i);const a=this.rendererContext.longitudeCyclical;a&&(n.boundingSphere[0]-n.boundingSphere[3]<a.min&&this._intersectRenderGeometry(n,t,r,a.range,e,i),n.boundingSphere[0]+n.boundingSphere[3]>a.max&&this._intersectRenderGeometry(n,t,r,-a.range,e,i)),i++})),i}_updateSortedMaterialRenderers(){this._sortedMaterialRenderers.clear();let e=0;this._materialRenderers.forEach(((r,t)=>{t.insertOrder=e++,this._sortedMaterialRenderers.push(r)})),this._sortedMaterialRenderers.sort(((e,r)=>{const t=r.material.renderPriority-e.material.renderPriority;return 0!==t?t:e.material.insertOrder-r.material.insertOrder}))}_processAddsRemoves(){this._changes.adds.clear(),this._changes.removes.clear(),this._changes.adds.pushArray(Array.from(this._pending.adds)),this._changes.removes.pushArray(Array.from(this._pending.removes));for(let e=0;e<this._changes.updates.length;){const r=this._changes.updates.data[e];this._pending.has(r.renderGeometry)?this._changes.updates.removeUnorderedIndex(e):e++}this._pending.clear()}_intersectRenderGeometry(e,r,t,s,i,n){if(!e.visible)return;let a=0;s+=e.transformation[12],a=e.transformation[13],R[0]=t[0]-s,R[1]=t[1]-a,e.screenToWorldRatio=this.rendererContext.screenToWorldRatio,e.material.intersectDraped(e,null,i,R,((t,s,a)=>{f(r,a,e.material.renderPriority,n,i,e.layerUid,e.graphicUid)}),r)}_notifyGraphicGeometryChanged(e){if(null==this.drapeSource.notifyGraphicGeometryChanged)return;let r;for(const t of e){const e=t.graphicUid;null!=e&&e!==r&&(this.drapeSource.notifyGraphicGeometryChanged(e),r=e)}}_notifyGraphicVisibilityChanged(e){if(null==this.drapeSource.notifyGraphicVisibilityChanged)return;let r;for(const t of e){const e=t.graphicUid;null!=e&&e!==r&&(this.drapeSource.notifyGraphicVisibilityChanged(e),r=e)}}_validateRenderGeometries(e){for(const r of e)this._validateRenderGeometry(r);return e}_validateRenderGeometry(e){return null==e.localOrigin&&(e.localOrigin=this._localOriginFactory.getOrigin(e.boundingSphere)),e}get test(){return{sortedMaterialRenderers:this._sortedMaterialRenderers}}};e([i()],_.prototype,"drapeSource",void 0),e([i()],_.prototype,"updating",null),e([i()],_.prototype,"rctx",null),e([i()],_.prototype,"rendererContext",void 0),e([i()],_.prototype,"_materialRepository",null),e([i()],_.prototype,"_localOriginFactory",null),e([i({readOnly:!0})],_.prototype,"isEmpty",null),e([i()],_.prototype,"_materialRenderers",void 0),e([i()],_.prototype,"_geometries",void 0),_=e([n("esri.views.3d.webgl-engine.lib.SortedRenderGeometryRenderer")],_);class y{constructor(){this.adds=new Set,this.removes=new Set,this.removed=new Set}get empty(){return 0===this.adds.size&&0===this.removes.size&&0===this.removed.size}has(e){return this.adds.has(e)||this.removes.has(e)||this.removed.has(e)}clear(){this.adds.clear(),this.removes.clear(),this.removed.clear()}}function f(e,r,t,s,i,n,a){const d=new o(n,a,r),p=r=>{r.set(c.OVERLAY,d,e.dist,e.normal,e.transformation,t,s)};if((null==i.results.min.drapedLayerOrder||t>=i.results.min.drapedLayerOrder)&&(null==i.results.min.dist||i.results.ground.dist<=i.results.min.dist)&&p(i.results.min),i.options.store!==l.MIN&&(null==i.results.max.drapedLayerOrder||t<i.results.max.drapedLayerOrder)&&(null==i.results.max.dist||i.results.ground.dist>i.results.max.dist)&&p(i.results.max),i.options.store===l.ALL){const e=h(i.ray);p(e),i.results.all.push(e)}}const R=a();export{_ as SortedRenderGeometryRenderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/PooledArray.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{a as n}from"../../../../chunks/vec2f64.js";import{OverlayTarget as a}from"../../terrain/Intersector.js";import{ChangeSet as o}from"./ChangeSet.js";import{newIntersectorResult as d}from"./Intersector.js";import{StoreResults as h,IntersectorType as l}from"./IntersectorInterfaces.js";import{DirtyOperation as c,DirtyState as m}from"./ModelDirtyTypes.js";import{splitRenderGeometryChangeSetByMaterial as p}from"./rendererUtils.js";import{MergedRenderer as g}from"../materials/renderers/MergedRenderer.js";let u=class extends r{constructor(e){super(e),this._pending=new _,this._changes=new o,this._materialRenderers=new t,this._sortedMaterialRenderers=new t,this._geometries=new Map,this._hasHighlights=!1,this._hasWater=!1}destroy(){this._changes.prune(),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._sortedMaterialRenderers.clear(),this._geometries.clear(),this._pending.clear()}get updating(){return!this._pending.empty||this._changes.updates.length>0}get rctx(){return this.rendererContext.rctx}get _materialRepository(){return this.rendererContext.materialRepository}get _localOriginFactory(){return this.rendererContext.localOriginFactory}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccluded(){return this._materialRenderers.some((e=>e.rendersOccluded))}get isEmpty(){return!this.updating&&0===this._materialRenderers.length&&0===this._geometries.size}get usedMemory(){return this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0)}commitChanges(){if(!this.updating)return!1;this._processAddsRemoves();const e=p(this._changes);let r=!1,t=!1,s=!1;return e.forEach(((e,i)=>{let n=this._materialRenderers.find((e=>e.material===i));if(!n&&e.adds.length>0&&(n=new g(this.rctx,this._materialRepository,i),this._materialRenderers.push(n),r=!0,t=!0,s=!0),!n)return;const a=t||n.hasHighlights,o=s||n.hasWater;n.modify(e),t=t||a!==n.hasHighlights,s=s||o!==n.hasWater,n.isEmpty&&(this._materialRenderers.removeUnordered(n),n.dispose(),r=!0)})),this._changes.clear(),r&&this._updateSortedMaterialRenderers(),t&&(this._hasHighlights=this._materialRenderers.some((e=>e.hasHighlights))),s&&(this._hasWater=this._materialRenderers.some((e=>e.hasWater))),this.notifyChange("updating"),!0}addGeometries(e,r){if(0===e.length)return;const t=this._validateRenderGeometries(e);for(const i of t)this._geometries.set(i.id,i);const s=this._pending.empty;for(const i of t)this._pending.adds.add(i);s&&this.notifyChange("updating"),r===c.UPDATE&&this._notifyGraphicGeometryChanged(e)}removeGeometries(e,r){const t=this._pending.empty,s=this._pending.adds;for(const i of e)s.has(i)?(this._pending.removed.add(i),s.delete(i)):this._pending.removed.has(i)||this._pending.removes.add(i),this._geometries.delete(i.id);t&&!this._pending.empty&&this.notifyChange("updating"),r===c.UPDATE&&this._notifyGraphicGeometryChanged(e)}modifyGeometries(e,r){const t=0===this._changes.updates.length;for(const s of e){const e=this._changes.updates.pushNew();e.renderGeometry=this._validateRenderGeometry(s),e.updateType=r}switch(t&&this._changes.updates.length>0&&this.notifyChange("updating"),r){case m.TRANSFORMATION:case m.GEOMETRY:return this._notifyGraphicGeometryChanged(e);case m.VISIBILITY:return this._notifyGraphicVisibilityChanged(e)}}updateAnimation(e){let r=!1;return this._sortedMaterialRenderers.forAll((t=>r=t.updateAnimation(e)||r)),r}render(e){this._sortedMaterialRenderers.forAll((r=>{if(r.material.shouldRender(e)){const t=r.prepareTechnique(e);null!=t&&r.render(e,t)}}))}intersect(e,r,t,s,i){return this._geometries.forEach((n=>{if(s&&!s(n))return;this._intersectRenderGeometry(n,t,r,0,e,i);const a=this.rendererContext.longitudeCyclical;a&&(n.boundingSphere[0]-n.boundingSphere[3]<a.min&&this._intersectRenderGeometry(n,t,r,a.range,e,i),n.boundingSphere[0]+n.boundingSphere[3]>a.max&&this._intersectRenderGeometry(n,t,r,-a.range,e,i)),i++})),i}_updateSortedMaterialRenderers(){this._sortedMaterialRenderers.clear();let e=0;this._materialRenderers.forAll((r=>{r.material.insertOrder=e++,this._sortedMaterialRenderers.push(r)})),this._sortedMaterialRenderers.sort(((e,r)=>{const t=r.material.renderPriority-e.material.renderPriority;return 0!==t?t:e.material.insertOrder-r.material.insertOrder}))}_processAddsRemoves(){this._changes.adds.clear(),this._changes.removes.clear(),this._changes.adds.pushArray(Array.from(this._pending.adds)),this._changes.removes.pushArray(Array.from(this._pending.removes));for(let e=0;e<this._changes.updates.length;){const r=this._changes.updates.data[e];this._pending.has(r.renderGeometry)?this._changes.updates.removeUnorderedIndex(e):e++}this._pending.clear()}_intersectRenderGeometry(e,r,t,s,i,n){if(!e.visible)return;let a=0;s+=e.transformation[12],a=e.transformation[13],f[0]=t[0]-s,f[1]=t[1]-a,e.screenToWorldRatio=this.rendererContext.screenToWorldRatio,e.material.intersectDraped(e,null,i,f,((t,s,a)=>{y(r,a,e.material.renderPriority,n,i,e.layerUid,e.graphicUid)}),r)}_notifyGraphicGeometryChanged(e){if(null==this.drapeSource.notifyGraphicGeometryChanged)return;let r;for(const t of e){const e=t.graphicUid;null!=e&&e!==r&&(this.drapeSource.notifyGraphicGeometryChanged(e),r=e)}}_notifyGraphicVisibilityChanged(e){if(null==this.drapeSource.notifyGraphicVisibilityChanged)return;let r;for(const t of e){const e=t.graphicUid;null!=e&&e!==r&&(this.drapeSource.notifyGraphicVisibilityChanged(e),r=e)}}_validateRenderGeometries(e){for(const r of e)this._validateRenderGeometry(r);return e}_validateRenderGeometry(e){return null==e.localOrigin&&(e.localOrigin=this._localOriginFactory.getOrigin(e.boundingSphere)),e}get test(){return{sortedMaterialRenderers:this._sortedMaterialRenderers}}};e([s()],u.prototype,"drapeSource",void 0),e([s()],u.prototype,"updating",null),e([s()],u.prototype,"rctx",null),e([s()],u.prototype,"rendererContext",void 0),e([s()],u.prototype,"_materialRepository",null),e([s()],u.prototype,"_localOriginFactory",null),e([s({readOnly:!0})],u.prototype,"isEmpty",null),e([s()],u.prototype,"_materialRenderers",void 0),e([s()],u.prototype,"_geometries",void 0),u=e([i("esri.views.3d.webgl-engine.lib.SortedRenderGeometryRenderer")],u);class _{constructor(){this.adds=new Set,this.removes=new Set,this.removed=new Set}get empty(){return 0===this.adds.size&&0===this.removes.size&&0===this.removed.size}has(e){return this.adds.has(e)||this.removes.has(e)||this.removed.has(e)}clear(){this.adds.clear(),this.removes.clear(),this.removed.clear()}}function y(e,r,t,s,i,n,o){const c=new a(n,o,r),m=r=>{r.set(l.OVERLAY,c,e.dist,e.normal,e.transformation,t,s)};if((null==i.results.min.drapedLayerOrder||t>=i.results.min.drapedLayerOrder)&&(null==i.results.min.dist||i.results.ground.dist<=i.results.min.dist)&&m(i.results.min),i.options.store!==h.MIN&&(null==i.results.max.drapedLayerOrder||t<i.results.max.drapedLayerOrder)&&(null==i.results.max.dist||i.results.ground.dist>i.results.max.dist)&&m(i.results.max),i.options.store===h.ALL){const e=d(i.ray);m(e),i.results.all.push(e)}}const f=n();export{u as SortedRenderGeometryRenderer};
@@ -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,e as h}from"../../../../../chunks/mat3.js";import{c as m}from"../../../../../chunks/mat3f64.js";import{c as g}from"../../../../../chunks/mat4f64.js";import{s as p,c as f,A as _,e as b}from"../../../../../chunks/vec3.js";import{c as y}from"../../../../../chunks/vec3f64.js";import{WatchUpdatingTracking as O}from"../../../../../core/support/WatchUpdatingTracking.js";import{g as j,a as w}from"../../../../../chunks/sphere.js";import{c as E}from"../../../../../chunks/vec33.js";import{ViewingMode as v}from"../../../../ViewingMode.js";import{encodeElevationOffset as R}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as x}from"../../core/util/TwoVectorPosition.js";import{GridLocalOriginFactory as T}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as C}from"../localOriginHelper.js";import{LocalOriginManager as M}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 D,EdgeInputBufferLayout as U,EdgeShaderAttributeLocations as k,glVertexLayout as B}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as I,SilhouetteEdgeBufferWriter as L}from"./edgeBufferWriters.js";import{EdgeType as H}from"./edgePreprocessing.js";import{EdgeRenderer as V,LINE_WIDTH_FRACTION_FACTOR as N,EXTENSION_LENGTH_OFFSET as G}from"./EdgeRenderer.js";import{EdgePassParameters as W}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as q}from"./EdgeWorkerHandle.js";import{Transparency as z}from"./interfaces.js";import{generateStrokesTexture as K}from"./strokes.js";import{determineRendererType as F,determineEdgeTransparency as Q,determineObjectTransparency as J,fillComponenBufferIndices as X}from"./util.js";import{BufferManager as Y}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as Z}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as $}from"../../../../webgl/BufferObject.js";import{Usage as ee}from"../../../../webgl/enums.js";let te=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=y(),this._localOrigins=new M(new T(e.renderSR))}initialize(){this._worker=new q(this.schedule),this._componentColorManager=new Y(this.rctx,3);const e=D.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=$.createVertex(this.rctx,ee.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",fe))}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 ne(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 ne(new Promise((e=>i=e)),j(a),w(a));this._perObjectData.set(e,c);const l=new Array;if(r.mergeGeometries&&e.geometries.length>1&&se(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()}_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=F(t),a=V.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 W(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(pe,a.transformViewFromCameraRelativeRS),h(a.transformNormalViewFromGlobal,pe),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=Q(e.components.meta),r=J(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*N),0,255),c=o(e.extensionLength,-G,255-G)+G,l="solid"===e.type?H.SOLID:H.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),R(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 oe(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 ie(new S(this.rctx,k,{vertices:B,instances:t===Z.REGULAR?I.glLayout:L.glLayout},{vertices:this._verticesBufferObject,instances:$.createVertex(this.rctx,ee.STATIC_DRAW,t===Z.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===Z.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo):null,i=e.regular.lodInfo.lengths.length>0?o(Z.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(Z.SILHOUETTE):null,c=(i?.vao.memoryUsage??0)+(a?.vao.memoryUsage??0);return new ce(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,Q(t.meta),J(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){const i=r.vertexAttributes.get(A.POSITION),a=r.indices.get(A.POSITION),c=g(),l=this._computeModelTransformWithLocalOrigin(e,r,c),d=new ge(i,a,c,l);return this._addPositionData(t,d,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||r<=0)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!0),{modelTransform:c,origin:l}=t,d=t.indices,u=t.position,h=u.data.length/u.size,m=U.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]);X(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 ae(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=F(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=U.createBuffer(r.length/3);E(d.position.typedBuffer,r,d.position.typedBufferStride,3),X(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;for(let g=0;g<e.geometries.length;g++){const t=e.geometries[g];if(!t.material.supportsEdges)continue;!a&&t.localOrigin&&(a=t);const r=t.vertexAttributes.get(A.POSITION);c+=r.data.length/r.size,i+=t.edgeIndicesLength}const l=c>=65536?Uint32Array:Uint16Array,d=i?new l(i):null,u=[];let h=0;for(let g=0;g<e.geometries.length;g++){const t=e.geometries[g];if(!t.material.supportsEdges)continue;const r=t.vertexAttributes.get(A.POSITION),s=t.indices.get(A.POSITION);let n=o.get(r.data);if(null==n){n=u.length/3;for(let e=0;e<r.data.length;e+=r.size)u.push(r.data[e]),u.push(r.data[e+1]),u.push(r.data[e+2]);o.set(r.data,n)}if(s)for(let e=0;e<t.edgeIndicesLength;e++)d[h++]=n+s[e]}const m=a||e.geometries[0],p=g(),f=this._computeModelTransformWithLocalOrigin(e,m,p);for(let g=0;g<e.geometries.length;g++)e.geometries[g].localOrigin=f.origin;const _=new ge({data:u,size:3},d,p,f);await this._updatingHandles.addPromise(this._addPositionData(t,_,d.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=V.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=K(this.rctx)),n||(n=new V(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===v.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){re(e.regular),re(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(!de(n)||!n.visible)return;const i=me(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(!he(n)||!n.visible)return;const i=me(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&&(de(e)&&(t=me(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&he(e)&&(t=me(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,z.OPAQUE),s(e,z.TRANSPARENT))})),t}}}};function re(e){null!=e&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function se(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(s&&null!=s.localOrigin&&null!=o.localOrigin&&s.localOrigin.id!==o.localOrigin.id)return!1}else s=o}}return!0}e([c({constructOnly:!0})],te.prototype,"rctx",void 0),e([c({constructOnly:!0})],te.prototype,"renderSR",void 0),e([c({constructOnly:!0})],te.prototype,"viewingMode",void 0),e([c({constructOnly:!0})],te.prototype,"techniqueRepository",void 0),e([c({constructOnly:!0})],te.prototype,"setNeedsRender",void 0),e([c({constructOnly:!0})],te.prototype,"schedule",void 0),e([c({readOnly:!0})],te.prototype,"_updatingHandles",void 0),e([c({readOnly:!0})],te.prototype,"updating",null),te=e([l("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],te);class ne{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 oe{constructor(e,t){this.buffer=e,this.meta=t}}class ie{constructor(e,t){this.vao=e,this.lod=t}}class ae{constructor(e,t){this.modelMatrix=e,this.origin=t}}class ce{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 le extends ce{}function de(e){return null!=e.regular}class ue extends ce{}function he(e){return null!=e.silhouette}function me(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 ge{constructor(e,t,r,s){this.position=e,this.indices=t,this.modelTransform=r,this.origin=s}}const pe=m(),fe=()=>Promise.reject();export{te as EdgeView,ae as LegacyTransform,le as RegularRenderable,ce as Renderable,ue 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,e as h}from"../../../../../chunks/mat3.js";import{c as m}from"../../../../../chunks/mat3f64.js";import{c as g}from"../../../../../chunks/mat4f64.js";import{s as p,c as f,A as _,e as b}from"../../../../../chunks/vec3.js";import{c as y}from"../../../../../chunks/vec3f64.js";import{UpdatingHandles as O}from"../../../../../core/support/UpdatingHandles.js";import{g as j,a as w}from"../../../../../chunks/sphere.js";import{c as E}from"../../../../../chunks/vec33.js";import{ViewingMode as v}from"../../../../ViewingMode.js";import{encodeElevationOffset as R}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as x}from"../../core/util/TwoVectorPosition.js";import{GridLocalOriginFactory as T}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as C}from"../localOriginHelper.js";import{LocalOriginManager as M}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 D,EdgeInputBufferLayout as U,EdgeShaderAttributeLocations as B,glVertexLayout as k}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as I,SilhouetteEdgeBufferWriter as L}from"./edgeBufferWriters.js";import{EdgeType as H}from"./edgePreprocessing.js";import{EdgeRenderer as V,LINE_WIDTH_FRACTION_FACTOR as N,EXTENSION_LENGTH_OFFSET as G}from"./EdgeRenderer.js";import{EdgePassParameters as q}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as z}from"./EdgeWorkerHandle.js";import{Transparency as W}from"./interfaces.js";import{generateStrokesTexture as K}from"./strokes.js";import{determineRendererType as F,determineEdgeTransparency as Q,determineObjectTransparency as J,fillComponenBufferIndices as X}from"./util.js";import{BufferManager as Y}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as Z}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as $}from"../../../../webgl/BufferObject.js";import{Usage as ee}from"../../../../webgl/enums.js";let te=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=y(),this._localOrigins=new M(new T(e.renderSR))}initialize(){this._worker=new z(this.schedule),this._componentColorManager=new Y(this.rctx,3);const e=D.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=$.createVertex(this.rctx,ee.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",fe))}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 ne(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 ne(new Promise((e=>i=e)),j(a),w(a));this._perObjectData.set(e,c);const l=new Array;if(r.mergeGeometries&&e.geometries.length>1&&se(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()}_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=F(t),a=V.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(pe,a.transformViewFromCameraRelativeRS),h(a.transformNormalViewFromGlobal,pe),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=Q(e.components.meta),r=J(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*N),0,255),c=o(e.extensionLength,-G,255-G)+G,l="solid"===e.type?H.SOLID:H.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),R(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 oe(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 ie(new S(this.rctx,B,{vertices:k,instances:t===Z.REGULAR?I.glLayout:L.glLayout},{vertices:this._verticesBufferObject,instances:$.createVertex(this.rctx,ee.STATIC_DRAW,t===Z.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===Z.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo):null,i=e.regular.lodInfo.lengths.length>0?o(Z.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(Z.SILHOUETTE):null,c=(i?.vao.memoryUsage??0)+(a?.vao.memoryUsage??0);return new ce(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,Q(t.meta),J(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){const i=r.vertexAttributes.get(A.POSITION),a=r.indices.get(A.POSITION),c=g(),l=this._computeModelTransformWithLocalOrigin(e,r,c),d=new ge(i,a,c,l);return this._addPositionData(t,d,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||r<=0)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!0),{modelTransform:c,origin:l}=t,d=t.indices,u=t.position,h=u.data.length/u.size,m=U.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]);X(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 ae(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=F(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=U.createBuffer(r.length/3);E(d.position.typedBuffer,r,d.position.typedBufferStride,3),X(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;for(let g=0;g<e.geometries.length;g++){const t=e.geometries[g];if(!t.material.supportsEdges)continue;!a&&t.localOrigin&&(a=t);const r=t.vertexAttributes.get(A.POSITION);c+=r.data.length/r.size,i+=t.edgeIndicesLength}const l=c>=65536?Uint32Array:Uint16Array,d=i?new l(i):null,u=[];let h=0;for(let g=0;g<e.geometries.length;g++){const t=e.geometries[g];if(!t.material.supportsEdges)continue;const r=t.vertexAttributes.get(A.POSITION),s=t.indices.get(A.POSITION);let n=o.get(r.data);if(null==n){n=u.length/3;for(let e=0;e<r.data.length;e+=r.size)u.push(r.data[e]),u.push(r.data[e+1]),u.push(r.data[e+2]);o.set(r.data,n)}if(s)for(let e=0;e<t.edgeIndicesLength;e++)d[h++]=n+s[e]}const m=a||e.geometries[0],p=g(),f=this._computeModelTransformWithLocalOrigin(e,m,p);for(let g=0;g<e.geometries.length;g++)e.geometries[g].localOrigin=f.origin;const _=new ge({data:u,size:3},d,p,f);await this._updatingHandles.addPromise(this._addPositionData(t,_,d.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=V.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=K(this.rctx)),n||(n=new V(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===v.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){re(e.regular),re(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(!de(n)||!n.visible)return;const i=me(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(!he(n)||!n.visible)return;const i=me(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&&(de(e)&&(t=me(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&he(e)&&(t=me(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,W.OPAQUE),s(e,W.TRANSPARENT))})),t}}}};function re(e){null!=e&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function se(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(s&&null!=s.localOrigin&&null!=o.localOrigin&&s.localOrigin.id!==o.localOrigin.id)return!1}else s=o}}return!0}e([c({constructOnly:!0})],te.prototype,"rctx",void 0),e([c({constructOnly:!0})],te.prototype,"renderSR",void 0),e([c({constructOnly:!0})],te.prototype,"viewingMode",void 0),e([c({constructOnly:!0})],te.prototype,"techniqueRepository",void 0),e([c({constructOnly:!0})],te.prototype,"setNeedsRender",void 0),e([c({constructOnly:!0})],te.prototype,"schedule",void 0),e([c({readOnly:!0})],te.prototype,"_updatingHandles",void 0),e([c({readOnly:!0})],te.prototype,"updating",null),te=e([l("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],te);class ne{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 oe{constructor(e,t){this.buffer=e,this.meta=t}}class ie{constructor(e,t){this.vao=e,this.lod=t}}class ae{constructor(e,t){this.modelMatrix=e,this.origin=t}}class ce{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 le extends ce{}function de(e){return null!=e.regular}class ue extends ce{}function he(e){return null!=e.silhouette}function me(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 ge{constructor(e,t,r,s){this.position=e,this.indices=t,this.modelTransform=r,this.origin=s}}const pe=m(),fe=()=>Promise.reject();export{te as EdgeView,ae as LegacyTransform,le as RegularRenderable,ce as Renderable,ue as SilhouetteRenderable};
@@ -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{removeUnordered as e,filterInPlace as t}from"../../../../../core/arrayUtils.js";import{someMap as r}from"../../../../../core/MapUtils.js";import{NestedMap as s}from"../../../../../core/NestedMap.js";import i from"../../../../../core/PooledArray.js";import{m as a,a as n,t as o}from"../../../../../chunks/mat4.js";import{c as l}from"../../../../../chunks/mat4f64.js";import{glLayout as h}from"../../../support/buffer/glUtil.js";import{ShaderOutput as u}from"../../core/shaderLibrary/ShaderOutput.js";import{GLMaterials as c}from"../../lib/GLMaterials.js";import{RenderOccludedFlag as f}from"../../lib/Material.js";import{DirtyState as d}from"../../lib/ModelDirtyTypes.js";import{assert as m,setMatrixTranslation3 as g}from"../../lib/Util.js";import{DrawParameters as p}from"../DrawParameters.js";import{WaterMaterial as y}from"../WaterMaterial.js";import{BufferRange as _,mergeAdjacentRanges as w}from"./BufferRange.js";import{Instance as b}from"./Instance.js";import{PerBufferData as v,hasVao as O}from"./PerBufferData.js";import{PerOriginData as C}from"./PerOriginData.js";import{VaoCache as B}from"./VaoCache.js";class E{constructor(e,t,r){this._rctx=e,this.material=r,this._dataByOrigin=new Map,this._hasHighlights=!1,this._hasOccludees=!1,this._glMaterials=new c(this.material,t),this._bufferWriter=r.createBufferWriter(),this._vaoCache=new B(e,r.vertexAttributeLocations,h(this._bufferWriter.vertexBufferLayout))}dispose(){this._glMaterials.destroy(),this._dataByOrigin.forEach((e=>e.dispose())),this._dataByOrigin.clear(),this._vaoCache.dispose()}get isEmpty(){return 0===this._dataByOrigin.size}get hasHighlights(){return this._hasHighlights}get hasOccludees(){return this._hasOccludees}get hasWater(){return!this.isEmpty&&this.material instanceof y}get isDecoration(){return this.material.isDecoration}get rendersOccluded(){return!this.isEmpty&&this.material.renderOccluded!==f.Occlude}get numGeometries(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.instances.size),0))),e}forEachGeometry(e){this._dataByOrigin.forEach((t=>t.buffers.forEach((t=>t.instances.forEach((t=>e(t.geometry)))))))}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateDrawCommands()}_updateGeometries(e){const t=this._bufferWriter,r=t.vertexBufferLayout.stride/4;for(const s of e){const e=s.renderGeometry,i=this._dataByOrigin.get(e.localOrigin.id),a=i?.findBuffer(e.id);if(null==a)return;const n=a.instances.get(e.id);if(s.updateType&(d.GEOMETRY|d.TRANSFORMATION)){const s=W(t.elementCount(n.geometry.geometry)*r),i=t.vertexBufferLayout.createView(s.buffer);this._writeGeometry(e,i,0),a.vao.vertexBuffers.geometry.setSubData(s,n.from*r,0,n.numElements*r),P()}s.updateType&(d.HIGHLIGHT|d.OCCLUDEE|d.VISIBILITY)&&(a.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new s;for(const s of e){const e=s.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new A(e.vec3),r.set(e.id,null,t)),t.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),i=t?.findBuffer(s.id);if(null==i)continue;let a=r.get(e.id,i);null==a&&(a=new A(e.vec3),r.set(e.id,i,a)),a.changes.push(s)}return r}_addAndRemoveGeometries(t,r){const{_bufferWriter:s,_dataByOrigin:i}=this,a=s.vertexBufferLayout.stride/4,n=this._computeDeltas(t,r);n.forEach(((t,r)=>{const o=t.get(null),l=null!=o?o.changes:[];n.delete(r,null);let h=i.get(r);if(t.forEach(((t,o)=>{if(n.delete(r,o),null==o)return void m(!1,"No VAO for removed geometries");if(o.instances.size===t.changes.length)return this._vaoCache.deleteVao(o.vao),e(h.buffers,o),void(0===h.buffers.length&&0===l.length&&i.delete(r));const u=o.numElements,c=o.vao.byteSize/4,f=l.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),d=t.changes.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),g=Math.min((u+f-d)*a,R),p=g>c;g>j&&g<c/2?(t.changes.forEach((({id:e})=>o.deleteInstance(e))),o.instances.forEach((({geometry:e})=>l.push(e))),this._vaoCache.deleteVao(o.vao),e(h.buffers,o)):p?this._applyAndRebuild(o,l,t):this._applyRemoves(o,t)})),l.length>0)for(null==h&&(h=new C(o.origin),i.set(r,h)),h.buffers.forEach((e=>this._applyAdds(e,l)));l.length>0;)h.buffers.push(this._applyAndRebuild(new v,l,null))}))}_updateDrawCommands(){this._hasHighlights=!1,this._hasOccludees=!1,this._dataByOrigin.forEach((e=>{e.buffers.forEach((e=>{e.drawCommandsDirty&&(e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,r(e.instances,(t=>(e.updateDrawState(t),e.hasHiddenInstances&&e.hasHighlights&&e.hasOccludees))),e.updateDrawCommands(this._bufferWriter.vertexBufferLayout.stride)),this._hasHighlights=this._hasHighlights||e.hasHighlights,this._hasOccludees=this._hasOccludees||e.hasOccludees}))}))}_applyAndRebuild(e,t,r){if(null!=r)for(const d of r.changes)e.deleteInstance(d.id);const s=this._bufferWriter,i=s.vertexBufferLayout.stride,a=i/4,n=Math.floor(R/a);let o=e.numElements;for(;t.length>0;){const r=t.pop(),i=s.elementCount(r.geometry);if(o+i>n&&o>0){t.push(r);break}o+=i;const a=new b(r,0,0);m(null==e.instances.get(r.id)),e.addInstance(r.id,a)}const l=o*a,h=W(l),u=s.vertexBufferLayout.createView(h.buffer);let c=0;e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,e.instances.forEach(((t,r)=>{this._writeGeometry(t.geometry,u,c);const i=c;c+=s.elementCount(t.geometry.geometry),e.updateInstance(r,i,c),e.updateDrawState(t)})),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(V(l)),e.vao.vertexBuffers.geometry.setSubData(h,0,0,c*a),P(),e.holes.clear();const f=e.holes.pushNew();return f.from=c,f.to=Math.floor(e.vao.byteSize/i),e.updateDrawCommands(i),e}_applyRemoves(e,t){if(0===t.changes.length)return;for(const n of t.changes){const t=n.id,r=e.instances.get(t);if(!r)continue;e.deleteInstance(t);const s=x.back();if(s){if(s.to===r.from){s.to=r.to;continue}if(s.from===r.to){s.from=r.from;continue}}const i=x.pushNew();i.from=r.from,i.to=r.to}w(x);const r=this._bufferWriter.vertexBufferLayout.stride/4,s=x.reduce(((e,t)=>Math.max(e,t.numElements)),0)*r,i=W(s);i.fill(0,0,s);const a=e.vao.vertexBuffers.geometry;x.forAll((e=>a.setSubData(i,e.from*r,0,e.numElements*r))),P(),e.holes.pushArray(x.data,x.length),x.forAll(((e,t)=>x.data[t]=null)),x.clear(),e.drawCommandsDirty=!0}_applyAdds(e,r){if(0===r.length)return;if(!O(e))return void this._applyAndRebuild(e,r,null);const s=this._bufferWriter,i=s.vertexBufferLayout.stride/4,a=e.numElements,n=r.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),o=Math.min((a+n)*i,R),l=4*o;if(e.vao.byteSize<V(R-j)&&l>e.vao.byteSize)return void this._applyAndRebuild(e,r,null);w(e.holes);const h=new Array;for(const t of r){const r=s.elementCount(t.geometry),i=H(e.holes,r);h.push(i)}const u=e.vao.vertexBuffers.geometry;let c=0,f=0,d=0;const g=W(o),p=s.vertexBufferLayout.createView(g.buffer);r.forEach(((t,r)=>{const a=h[r];if(null==a)return;if(!(d===a)){const e=d-f;e>0&&u.setSubData(g,f*i,0,e*i),f=a,c=0}const n=s.elementCount(t.geometry);this._writeGeometry(t,p,c),c+=n,d=a+n;const o=new b(t,a,a+n);m(null==e.instances.get(t.id)),e.addInstance(t.id,o),e.drawCommandsDirty=!0}));const y=d-f;y>0&&u.setSubData(g,f*i,0,y*i),t(r,((e,t)=>null==h[t])),P()}_writeGeometry(e,t,r){const s=e.localOrigin.vec3;g(D,-s[0],-s[1],-s[2]);const i=a(S,D,e.transformation);n(M,i),o(M,M),this._bufferWriter.write(i,M,e.geometry,t,r)}updateAnimation(e){return this.material.update(e)}requiresSlot(e,t){return this.material.requiresSlot(e,t)}prepareTechnique(e){const{output:t,bindParameters:r}=e;if(!this.requiresSlot(r.slot,t))return null;const s=t===u.Highlight||t===u.ShadowHighlight;if(s&&!this._hasHighlights)return null;const i=t===u.ShadowExcludeHighlight,a=!(s||i);for(const n of this._dataByOrigin.values())for(const o of n.buffers){if(s&&!o.hasHighlights)continue;const n=(s?o.drawCommandsHighlight:i&&o.needsMultipleCommands()?o.drawCommandsShadowHighlightRest:o.drawCommandsDefault)||null,l=a&&o.drawCommandsOccludees||null;if(n?.length||l?.length){const s=this._glMaterials.load(e.rctx,r.slot,t),i=null!=s?s.beginSlot(r):null;if(null!=i)return i}}return null}render(e,t){const{output:r,bindParameters:s}=e,i=r===u.Highlight||r===u.ShadowHighlight,a=r===u.ShadowExcludeHighlight,n=!(i||a),o=this._rctx;o.appleAmdDriverHelper?.resetIndicesType(),o.bindTechnique(t,this.material.parameters,s);for(const l of this._dataByOrigin.values())for(const e of l.buffers){if(i&&!e.hasHighlights)continue;const r=(i?e.drawCommandsHighlight:a&&e.needsMultipleCommands()?e.drawCommandsShadowHighlightRest:e.drawCommandsDefault)||null,h=n&&e.drawCommandsOccludees||null;if(r?.length||h?.length){t.program.bindDraw(new p(l.origin),s,this.material.parameters),t.ensureAttributeLocations(e.vao),o.bindVAO(e.vao),r?.length&&(t.bindPipelineState(o,s.slot,!1),r.forAll((e=>o.drawArrays(t.primitiveType,e.first,e.count)))),h?.length&&(t.bindPipelineState(o,s.slot,!0),h.forAll((e=>o.drawArrays(t.primitiveType,e.first,e.count))))}}}get test(){return{material:this.material,glMaterials:this._glMaterials,dataByOrigin:this._dataByOrigin}}}class A{constructor(e){this.origin=e,this.changes=new Array}}function H(e,t){let r;if(!e.some((e=>!(e.numElements<t)&&(r=e,!0))))return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}const D=l(),S=l(),M=l(),x=new i({allocator:e=>e||new _,deallocator:null}),j=65536,I=4*j,L=1024,G=16777216,R=G/4;let T=new Float32Array(j);function W(e){return T.length<e&&(T=new Float32Array(e)),T}function V(e){const t=4*e;return t<=L?L:t<I?I:Math.max(Math.min(Math.ceil(1.5*t/I)*I,G),t)}function P(){T=new Float32Array(2)}export{E as MergedRenderer};
5
+ import{removeUnordered as e,filterInPlace as t}from"../../../../../core/arrayUtils.js";import{someMap as r}from"../../../../../core/MapUtils.js";import{NestedMap as s}from"../../../../../core/NestedMap.js";import i from"../../../../../core/PooledArray.js";import{m as a,a as o,t as n}from"../../../../../chunks/mat4.js";import{c as l}from"../../../../../chunks/mat4f64.js";import{glLayout as u}from"../../../support/buffer/glUtil.js";import{ShaderOutput as h}from"../../core/shaderLibrary/ShaderOutput.js";import{GLMaterials as f}from"../../lib/GLMaterials.js";import{RenderOccludedFlag as c}from"../../lib/Material.js";import{DirtyState as d}from"../../lib/ModelDirtyTypes.js";import{assert as m,setMatrixTranslation3 as g}from"../../lib/Util.js";import{DrawParameters as p}from"../DrawParameters.js";import{WaterMaterial as y}from"../WaterMaterial.js";import{BufferRange as _,mergeAdjacentRanges as w}from"./BufferRange.js";import{Instance as b}from"./Instance.js";import{PerBufferData as v,hasVao as O}from"./PerBufferData.js";import{PerOriginData as B}from"./PerOriginData.js";import{VaoCache as C}from"./VaoCache.js";class E{constructor(e,t,r){this._rctx=e,this.material=r,this._dataByOrigin=new Map,this._hasHighlights=!1,this._hasOccludees=!1,this._glMaterials=new f(this.material,t),this._bufferWriter=r.createBufferWriter(),this._vaoCache=new C(e,r.vertexAttributeLocations,u(this._bufferWriter.vertexBufferLayout))}dispose(){this._glMaterials.destroy(),this._dataByOrigin.forEach((e=>e.dispose())),this._dataByOrigin.clear(),this._vaoCache.dispose()}get isEmpty(){return 0===this._dataByOrigin.size}get hasHighlights(){return this._hasHighlights}get hasOccludees(){return this._hasOccludees}get hasWater(){return!this.isEmpty&&this.material instanceof y}get isDecoration(){return this.material.isDecoration}get rendersOccluded(){return!this.isEmpty&&this.material.renderOccluded!==c.Occlude}get numGeometries(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.instances.size),0))),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.vao.memoryUsage),0))),e}forEachGeometry(e){this._dataByOrigin.forEach((t=>t.buffers.forEach((t=>t.instances.forEach((t=>e(t.geometry)))))))}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateDrawCommands()}_updateGeometries(e){const t=this._bufferWriter,r=t.vertexBufferLayout.stride/4;for(const s of e){const e=s.renderGeometry,i=this._dataByOrigin.get(e.localOrigin.id),a=i?.findBuffer(e.id);if(null==a)return;const o=a.instances.get(e.id);if(s.updateType&(d.GEOMETRY|d.TRANSFORMATION)){const s=W(t.elementCount(o.geometry.geometry)*r),i=t.vertexBufferLayout.createView(s.buffer);this._writeGeometry(e,i,0),a.vao.vertexBuffers.geometry.setSubData(s,o.from*r,0,o.numElements*r),P()}s.updateType&(d.HIGHLIGHT|d.OCCLUDEE|d.VISIBILITY)&&(a.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new s;for(const s of e){const e=s.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new A(e.vec3),r.set(e.id,null,t)),t.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),i=t?.findBuffer(s.id);if(null==i)continue;let a=r.get(e.id,i);null==a&&(a=new A(e.vec3),r.set(e.id,i,a)),a.changes.push(s)}return r}_addAndRemoveGeometries(t,r){const{_bufferWriter:s,_dataByOrigin:i}=this,a=s.vertexBufferLayout.stride/4,o=this._computeDeltas(t,r);o.forEach(((t,r)=>{const n=t.get(null),l=null!=n?n.changes:[];o.delete(r,null);let u=i.get(r);if(t.forEach(((t,n)=>{if(o.delete(r,n),null==n)return void m(!1,"No VAO for removed geometries");if(n.instances.size===t.changes.length)return this._vaoCache.deleteVao(n.vao),e(u.buffers,n),void(0===u.buffers.length&&0===l.length&&i.delete(r));const h=n.numElements,f=n.vao.byteSize/4,c=l.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),d=t.changes.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),g=Math.min((h+c-d)*a,R),p=g>f;g>j&&g<f/2?(t.changes.forEach((({id:e})=>n.deleteInstance(e))),n.instances.forEach((({geometry:e})=>l.push(e))),this._vaoCache.deleteVao(n.vao),e(u.buffers,n)):p?this._applyAndRebuild(n,l,t):this._applyRemoves(n,t)})),l.length>0)for(null==u&&(u=new B(n.origin),i.set(r,u)),u.buffers.forEach((e=>this._applyAdds(e,l)));l.length>0;)u.buffers.push(this._applyAndRebuild(new v,l,null))}))}_updateDrawCommands(){this._hasHighlights=!1,this._hasOccludees=!1,this._dataByOrigin.forEach((e=>{e.buffers.forEach((e=>{e.drawCommandsDirty&&(e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,r(e.instances,(t=>(e.updateDrawState(t),e.hasHiddenInstances&&e.hasHighlights&&e.hasOccludees))),e.updateDrawCommands(this._bufferWriter.vertexBufferLayout.stride)),this._hasHighlights=this._hasHighlights||e.hasHighlights,this._hasOccludees=this._hasOccludees||e.hasOccludees}))}))}_applyAndRebuild(e,t,r){if(null!=r)for(const d of r.changes)e.deleteInstance(d.id);const s=this._bufferWriter,i=s.vertexBufferLayout.stride,a=i/4,o=Math.floor(R/a);let n=e.numElements;for(;t.length>0;){const r=t.pop(),i=s.elementCount(r.geometry);if(n+i>o&&n>0){t.push(r);break}n+=i;const a=new b(r,0,0);m(null==e.instances.get(r.id)),e.addInstance(r.id,a)}const l=n*a,u=W(l),h=s.vertexBufferLayout.createView(u.buffer);let f=0;e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,e.instances.forEach(((t,r)=>{this._writeGeometry(t.geometry,h,f);const i=f;f+=s.elementCount(t.geometry.geometry),e.updateInstance(r,i,f),e.updateDrawState(t)})),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(V(l)),e.vao.vertexBuffers.geometry.setSubData(u,0,0,f*a),P(),e.holes.clear();const c=e.holes.pushNew();return c.from=f,c.to=Math.floor(e.vao.byteSize/i),e.updateDrawCommands(i),e}_applyRemoves(e,t){if(0===t.changes.length)return;for(const o of t.changes){const t=o.id,r=e.instances.get(t);if(!r)continue;e.deleteInstance(t);const s=x.back();if(s){if(s.to===r.from){s.to=r.to;continue}if(s.from===r.to){s.from=r.from;continue}}const i=x.pushNew();i.from=r.from,i.to=r.to}w(x);const r=this._bufferWriter.vertexBufferLayout.stride/4,s=x.reduce(((e,t)=>Math.max(e,t.numElements)),0)*r,i=W(s);i.fill(0,0,s);const a=e.vao.vertexBuffers.geometry;x.forAll((e=>a.setSubData(i,e.from*r,0,e.numElements*r))),P(),e.holes.pushArray(x.data,x.length),x.forAll(((e,t)=>x.data[t]=null)),x.clear(),e.drawCommandsDirty=!0}_applyAdds(e,r){if(0===r.length)return;if(!O(e))return void this._applyAndRebuild(e,r,null);const s=this._bufferWriter,i=s.vertexBufferLayout.stride/4,a=e.numElements,o=r.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),n=Math.min((a+o)*i,R),l=4*n;if(e.vao.byteSize<V(R-j)&&l>e.vao.byteSize)return void this._applyAndRebuild(e,r,null);w(e.holes);const u=new Array;for(const t of r){const r=s.elementCount(t.geometry),i=H(e.holes,r);u.push(i)}const h=e.vao.vertexBuffers.geometry;let f=0,c=0,d=0;const g=W(n),p=s.vertexBufferLayout.createView(g.buffer);r.forEach(((t,r)=>{const a=u[r];if(null==a)return;if(!(d===a)){const e=d-c;e>0&&h.setSubData(g,c*i,0,e*i),c=a,f=0}const o=s.elementCount(t.geometry);this._writeGeometry(t,p,f),f+=o,d=a+o;const n=new b(t,a,a+o);m(null==e.instances.get(t.id)),e.addInstance(t.id,n),e.drawCommandsDirty=!0}));const y=d-c;y>0&&h.setSubData(g,c*i,0,y*i),t(r,((e,t)=>null==u[t])),P()}_writeGeometry(e,t,r){const s=e.localOrigin.vec3;g(D,-s[0],-s[1],-s[2]);const i=a(S,D,e.transformation);o(M,i),n(M,M),this._bufferWriter.write(i,M,e.geometry,t,r)}updateAnimation(e){return this.material.update(e)}requiresSlot(e,t){return this.material.requiresSlot(e,t)}prepareTechnique(e){const{output:t,bindParameters:r}=e;if(!this.requiresSlot(r.slot,t))return null;const s=t===h.Highlight||t===h.ShadowHighlight;if(s&&!this._hasHighlights)return null;const i=t===h.ShadowExcludeHighlight,a=!(s||i);for(const o of this._dataByOrigin.values())for(const n of o.buffers){if(s&&!n.hasHighlights)continue;const o=(s?n.drawCommandsHighlight:i&&n.needsMultipleCommands()?n.drawCommandsShadowHighlightRest:n.drawCommandsDefault)||null,l=a&&n.drawCommandsOccludees||null;if(o?.length||l?.length){const s=this._glMaterials.load(e.rctx,r.slot,t),i=null!=s?s.beginSlot(r):null;if(null!=i)return i}}return null}render(e,t){const{output:r,bindParameters:s}=e,i=r===h.Highlight||r===h.ShadowHighlight,a=r===h.ShadowExcludeHighlight,o=!(i||a),n=this._rctx;n.appleAmdDriverHelper?.resetIndicesType(),n.bindTechnique(t,this.material.parameters,s);for(const l of this._dataByOrigin.values())for(const e of l.buffers){if(i&&!e.hasHighlights)continue;const r=(i?e.drawCommandsHighlight:a&&e.needsMultipleCommands()?e.drawCommandsShadowHighlightRest:e.drawCommandsDefault)||null,u=o&&e.drawCommandsOccludees||null;if(r?.length||u?.length){t.program.bindDraw(new p(l.origin),s,this.material.parameters),t.ensureAttributeLocations(e.vao),n.bindVAO(e.vao),r?.length&&(t.bindPipelineState(n,s.slot,!1),r.forAll((e=>n.drawArrays(t.primitiveType,e.first,e.count)))),u?.length&&(t.bindPipelineState(n,s.slot,!0),u.forAll((e=>n.drawArrays(t.primitiveType,e.first,e.count))))}}}get test(){return{material:this.material,glMaterials:this._glMaterials,dataByOrigin:this._dataByOrigin}}}class A{constructor(e){this.origin=e,this.changes=new Array}}function H(e,t){let r;if(!e.some((e=>!(e.numElements<t)&&(r=e,!0))))return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}const D=l(),S=l(),M=l(),x=new i({allocator:e=>e||new _,deallocator:null}),j=65536,I=4*j,L=1024,G=16777216,R=G/4;let T=new Float32Array(j);function W(e){return T.length<e&&(T=new Float32Array(e)),T}function V(e){const t=4*e;return t<=L?L:t<I?I:Math.max(Math.min(Math.ceil(1.5*t/I)*I,G),t)}function P(){T=new Float32Array(2)}export{E as MergedRenderer};
@@ -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 i from"../core/Error.js";import t from"../core/Logger.js";import{someMap as s}from"../core/MapUtils.js";import{removeMaybe as a}from"../core/maybe.js";import{createResolver as o,createAbortError as l,isAbortError as n,onAbort as y,throwIfAborted as h}from"../core/promiseUtils.js";import{on as c,watch as p,syncAndInitial as w}from"../core/reactiveUtils.js";import{schedule as d}from"../core/scheduling.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as f}from"../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as u}from"../core/support/WatchUpdatingTracking.js";import{destroyMap as _}from"../support/collectionUtils.js";function g(e){return"tryRecycleWith"in e}class v{constructor(e,r,t){this.layer=e,this.view=r,this.layerViewImporter=t,this._controller=new AbortController,this._deferred=o(),this._started=!1,this.done=!1,this.promise=this._deferred.promise,y(this._controller.signal,(()=>{const r=new i("cancelled:layerview-create","layerview creation cancelled",{layer:e});this._deferred.reject(r)}))}tryRecycle(e){if(!this.done||!this.layerView||!g(this.layerView))return null;const r=this.layer.type,i=this._controller.signal;for(let t=0;t<e.length;t++){const s=e[t];if(s.type!==r)continue;const a=this.layerView.tryRecycleWith(s,{signal:i});if(a){e.splice(t,1),this.layer=s;const r=this.layerView,i=r.view;return this.promise=Promise.race([a.then((()=>(h(this._controller.signal),s.emit("layerview-destroy",{view:i,layerView:r}),i.emit("layerview-destroy",{view:i,layerView:r}),s.emit("layerview-create",{view:i,layerView:r}),i.emit("layerview-create",{view:i,layerView:r}),r))),new Promise(((e,r)=>y(this._controller.signal,(()=>r(l())))))]),this.promise}}return null}destroy(){this._controller.abort();const{layerView:e}=this;if(e){const{layer:r,view:i}=this;r.emit("layerview-destroy",{view:i,layerView:e}),i.emit("layerview-destroy",{layer:r,layerView:e})}this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null,this._map=null}async start(){if(this._started)return;this._started=!0;const{_controller:{signal:e},layer:r,view:t}=this;this._map=t.map;try{let o,l;if(await r.load({signal:e}),"prefetchResources"in r&&await(r.prefetchResources?.({signal:e})),M(r))o=await r.createLayerView(t,{signal:e});else{if(!this.layerViewImporter.hasLayerViewModule(r))throw new i("layer:view-not-supported","No layerview implementation was found");const s=await this.layerViewImporter.importLayerView(r);h(e),o="default"in s?new s.default({layer:r,view:t}):new s({layer:r,view:t})}const n=()=>{l=a(l),o.destroyed||o.destroy(),o.layer=null,o.parent=null,o.view=null,this.done=!0};l=y(e,n),h(e);try{await o.when()}catch(s){throw n(),s}const c=this._map?.allLayers?.includes(r);if(!c)return n(),void this._deferred.reject(new i("view:no-layerview-for-layer","The layer has been removed from the map",{layer:r}));this.layerView=o,r.emit("layerview-create",{view:t,layerView:o}),t.emit("layerview-create",{layer:r,layerView:o}),this.done=!0,this._deferred.resolve(o)}catch(s){r.emit("layerview-create-error",{view:t,error:s}),t.emit("layerview-create-error",{layer:r,error:s}),this.done=!0,this._deferred.reject(new i("layerview:create-error","layerview creation failed",{layer:r,error:s}))}}}let V=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new u,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=o(),this._workPromise.promise.catch((()=>{}))),this.removeHandles("reschedule"),this.addHandles(d(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const e=this.view.map;if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const a of e)if(a){r.add(a);const e=this._layerLayerViewInfoMap.get(a);e&&t?e.start():e||this._recyclingInfoMap.has(a)||i.push(a),"layers"in a&&a.layers&&s(a.layers)}};for(const o of this._rootCollectionNames)s(this.get(o));for(const[o,l]of this._layerLayerViewInfoMap)if(!r.has(o)){this._layerLayerViewInfoMap.delete(l.layer);const e=l.tryRecycle(i);e?(this.notifyChange("updating"),this._recyclingInfoMap.set(l.layer,l),e.then((()=>{this.notifyChange("updating"),this._recyclingInfoMap.delete(l.layer),this._layerLayerViewInfoMap.set(l.layer,l),this._reschedule()})).catch((()=>{this.notifyChange("updating"),this._recyclingInfoMap.delete(l.layer),l.destroy(),this._reschedule()}))):l.destroy()}for(const[o,l]of this._recyclingInfoMap)r.has(o)||(this.notifyChange("updating"),this._recyclingInfoMap.delete(l.layer),l.destroy());for(const o of i)this._createLayerView(o);this._refreshCollections();const a=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.referenceLayers,e?.layers].filter((e=>!!e));r.forEach((e=>"layers"in e&&a.push(e.layers))),this.addHandles(a.map((e=>this._watchUpdatingTracking.addOnCollectionChange((()=>e),this._reschedule))),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.own([c((()=>this.view?.map?.allLayers),"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),p((()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]}),(()=>this._reschedule()),w)]),this._preloadLayerViewModules(),this._reschedule()}destroy(){this.clear(),_(this._recyclingInfoMap),_(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(l()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,(e=>!e.done))||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(_(this._layerLayerViewInfoMap),this._refreshCollections())}async whenLayerView(e){if(await this._reschedule(),!this._layerLayerViewInfoMap.has(e)){if(this._recyclingInfoMap.has(e))return this._recyclingInfoMap.get(e).promise;throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e})}return this._layerLayerViewInfoMap.get(e).promise}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(this.get(e),this.get(r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void(r&&r.removeAll());let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e||!e.layerView)continue;const a=e.layerView;a.layer=s,a.parent=i,r.at(t)!==a&&r.splice(t,0,a),s.layers&&this._populateLayerViewsOwners(s.layers,a.layerViews,a),t+=1}t<r.length&&r.splice(t,r.length)}_createLayerView(e){e.load().catch((()=>{})),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new v(e,this.view,this.layerViewImporter);r.promise.then((()=>this._refreshCollections()),(r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this._refreshCollections()})),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([m()],V.prototype,"_workPromise",void 0),e([m({readOnly:!0})],V.prototype,"_watchUpdatingTracking",void 0),e([m({readOnly:!0})],V.prototype,"_layersToLayerViews",null),e([m({readOnly:!0})],V.prototype,"_rootCollectionNames",null),e([m()],V.prototype,"layerViewImporter",void 0),e([m()],V.prototype,"supportsGround",void 0),e([m({readOnly:!0})],V.prototype,"updating",null),e([m({readOnly:!0})],V.prototype,"updatingRemaining",null),e([m({constructOnly:!0})],V.prototype,"view",void 0),V=e([f("esri.views.LayerViewManager")],V);const L=V;function M(e){return"createLayerView"in e&&null!=e.createLayerView}export{L as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import r from"../core/Accessor.js";import i from"../core/Error.js";import t from"../core/Logger.js";import{someMap as s}from"../core/MapUtils.js";import{removeMaybe as a}from"../core/maybe.js";import{createResolver as o,createAbortError as l,isAbortError as n,onAbort as y,throwIfAborted as h}from"../core/promiseUtils.js";import{on as c,watch as p,syncAndInitial as w}from"../core/reactiveUtils.js";import{schedule as d}from"../core/scheduling.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as f}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../core/support/UpdatingHandles.js";import{destroyMap as _}from"../support/collectionUtils.js";function g(e){return"tryRecycleWith"in e}class v{constructor(e,r,t){this.layer=e,this.view=r,this.layerViewImporter=t,this._controller=new AbortController,this._deferred=o(),this._started=!1,this.done=!1,this.promise=this._deferred.promise,y(this._controller.signal,(()=>{const r=new i("cancelled:layerview-create","layerview creation cancelled",{layer:e});this._deferred.reject(r)}))}tryRecycle(e){if(!this.done||!this.layerView||!g(this.layerView))return null;const r=this.layer.type,i=this._controller.signal;for(let t=0;t<e.length;t++){const s=e[t];if(s.type!==r)continue;const a=this.layerView.tryRecycleWith(s,{signal:i});if(a){e.splice(t,1),this.layer=s;const r=this.layerView,i=r.view;return this.promise=Promise.race([a.then((()=>(h(this._controller.signal),s.emit("layerview-destroy",{view:i,layerView:r}),i.emit("layerview-destroy",{view:i,layerView:r}),s.emit("layerview-create",{view:i,layerView:r}),i.emit("layerview-create",{view:i,layerView:r}),r))),new Promise(((e,r)=>y(this._controller.signal,(()=>r(l())))))]),this.promise}}return null}destroy(){this._controller.abort();const{layerView:e}=this;if(e){const{layer:r,view:i}=this;r.emit("layerview-destroy",{view:i,layerView:e}),i.emit("layerview-destroy",{layer:r,layerView:e})}this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null,this._map=null}async start(){if(this._started)return;this._started=!0;const{_controller:{signal:e},layer:r,view:t}=this;this._map=t.map;try{let o,l;if(await r.load({signal:e}),"prefetchResources"in r&&await(r.prefetchResources?.({signal:e})),M(r))o=await r.createLayerView(t,{signal:e});else{if(!this.layerViewImporter.hasLayerViewModule(r))throw new i("layer:view-not-supported","No layerview implementation was found");const s=await this.layerViewImporter.importLayerView(r);h(e),o="default"in s?new s.default({layer:r,view:t}):new s({layer:r,view:t})}const n=()=>{l=a(l),o.destroyed||o.destroy(),o.layer=null,o.parent=null,o.view=null,this.done=!0};l=y(e,n),h(e);try{await o.when()}catch(s){throw n(),s}const c=this._map?.allLayers?.includes(r);if(!c)return n(),void this._deferred.reject(new i("view:no-layerview-for-layer","The layer has been removed from the map",{layer:r}));this.layerView=o,r.emit("layerview-create",{view:t,layerView:o}),t.emit("layerview-create",{layer:r,layerView:o}),this.done=!0,this._deferred.resolve(o)}catch(s){r.emit("layerview-create-error",{view:t,error:s}),t.emit("layerview-create-error",{layer:r,error:s}),this.done=!0,this._deferred.reject(new i("layerview:create-error","layerview creation failed",{layer:r,error:s}))}}}let V=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new u,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=o(),this._workPromise.promise.catch((()=>{}))),this.removeHandles("reschedule"),this.addHandles(d(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const e=this.view.map;if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const a of e)if(a){r.add(a);const e=this._layerLayerViewInfoMap.get(a);e&&t?e.start():e||this._recyclingInfoMap.has(a)||i.push(a),"layers"in a&&a.layers&&s(a.layers)}};for(const o of this._rootCollectionNames)s(this.get(o));for(const[o,l]of this._layerLayerViewInfoMap)if(!r.has(o)){this._layerLayerViewInfoMap.delete(l.layer);const e=l.tryRecycle(i);e?(this.notifyChange("updating"),this._recyclingInfoMap.set(l.layer,l),e.then((()=>{this.notifyChange("updating"),this._recyclingInfoMap.delete(l.layer),this._layerLayerViewInfoMap.set(l.layer,l),this._reschedule()})).catch((()=>{this.notifyChange("updating"),this._recyclingInfoMap.delete(l.layer),l.destroy(),this._reschedule()}))):l.destroy()}for(const[o,l]of this._recyclingInfoMap)r.has(o)||(this.notifyChange("updating"),this._recyclingInfoMap.delete(l.layer),l.destroy());for(const o of i)this._createLayerView(o);this._refreshCollections();const a=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.referenceLayers,e?.layers].filter((e=>!!e));r.forEach((e=>"layers"in e&&a.push(e.layers))),this.addHandles(a.map((e=>this._watchUpdatingTracking.addOnCollectionChange((()=>e),this._reschedule))),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.own([c((()=>this.view?.map?.allLayers),"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),p((()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]}),(()=>this._reschedule()),w)]),this._preloadLayerViewModules(),this._reschedule()}destroy(){this.clear(),_(this._recyclingInfoMap),_(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(l()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,(e=>!e.done))||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(_(this._layerLayerViewInfoMap),this._refreshCollections())}async whenLayerView(e){if(await this._reschedule(),!this._layerLayerViewInfoMap.has(e)){if(this._recyclingInfoMap.has(e))return this._recyclingInfoMap.get(e).promise;throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e})}return this._layerLayerViewInfoMap.get(e).promise}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(this.get(e),this.get(r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void(r&&r.removeAll());let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e||!e.layerView)continue;const a=e.layerView;a.layer=s,a.parent=i,r.at(t)!==a&&r.splice(t,0,a),s.layers&&this._populateLayerViewsOwners(s.layers,a.layerViews,a),t+=1}t<r.length&&r.splice(t,r.length)}_createLayerView(e){e.load().catch((()=>{})),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new v(e,this.view,this.layerViewImporter);r.promise.then((()=>this._refreshCollections()),(r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this._refreshCollections()})),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([m()],V.prototype,"_workPromise",void 0),e([m({readOnly:!0})],V.prototype,"_watchUpdatingTracking",void 0),e([m({readOnly:!0})],V.prototype,"_layersToLayerViews",null),e([m({readOnly:!0})],V.prototype,"_rootCollectionNames",null),e([m()],V.prototype,"layerViewImporter",void 0),e([m()],V.prototype,"supportsGround",void 0),e([m({readOnly:!0})],V.prototype,"updating",null),e([m({readOnly:!0})],V.prototype,"updatingRemaining",null),e([m({constructOnly:!0})],V.prototype,"view",void 0),V=e([f("esri.views.LayerViewManager")],V);const L=V;function M(e){return"createLayerView"in e&&null!=e.createLayerView}export{L as default};